day1
This commit is contained in:
commit
ad39cfacbd
|
@ -0,0 +1,6 @@
|
|||
*.swp
|
||||
go.mod
|
||||
go.sum
|
||||
/resources/*.so
|
||||
/files/*
|
||||
gemini
|
|
@ -0,0 +1,47 @@
|
|||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||
|
||||
default: verbose
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
@echo this go binary package builds okay
|
||||
|
||||
verbose: goimports vet plugin
|
||||
GO111MODULE=off go install -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
build: goimports vet plugin
|
||||
GO111MODULE=off go build -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install: goimports vet plugin
|
||||
GO111MODULE=off go install \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install-raw: goimports vet plugin
|
||||
go install \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
plugin:
|
||||
rm -f resources/*.so
|
||||
# -cp ../../toolkits/gocui/gocui.so resources/
|
||||
|
||||
andlabs: clean install
|
||||
gemini --gui gocui --gui-verbose --gui-file ../../toolkits/andlabs/andlabs.so
|
||||
|
||||
gocui: install
|
||||
gemini --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so >/tmp/gemini.log 2>&1
|
||||
|
||||
goimports:
|
||||
reset
|
||||
goimports -w *.go
|
||||
@# // to globally reset paths:
|
||||
@# // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go
|
||||
|
||||
clean:
|
||||
-rm -f gemini go.*
|
||||
go-mod-clean purge
|
||||
|
||||
identify-protobuf:
|
||||
autogenpb --identify ~/.gemini/gemini.pb
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
/*
|
||||
this parses the command line arguements using alex flint's go-arg
|
||||
*/
|
||||
|
||||
var argv args
|
||||
|
||||
type args struct {
|
||||
Playback *PlaybackCmd `arg:"subcommand:playback" help:"dump your prior conversations to the terminal'"`
|
||||
Add *EmptyCmd `arg:"subcommand:add" help:"add a conversation"`
|
||||
Force bool `arg:"--force" help:"try to strong arm things"`
|
||||
Verbose bool `arg:"--verbose" help:"show more output"`
|
||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
|
||||
}
|
||||
|
||||
type EmptyCmd struct {
|
||||
}
|
||||
|
||||
type PlaybackCmd struct {
|
||||
List *EmptyCmd `arg:"subcommand:list" help:"list memories"`
|
||||
Force bool `arg:"--all" help:"try to strong arm things"`
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
return ARGNAME + " " + VERSION + " Built on " + BUILDTIME
|
||||
}
|
||||
|
||||
func (a args) Description() string {
|
||||
return `
|
||||
gemini -- interact with Googles' Gemini AI
|
||||
`
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
/*
|
||||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
// used for shell auto completion
|
||||
// var ARGNAME string = "forge" // todo: get this from $0 ?
|
||||
|
||||
func deleteMatch() {
|
||||
// f := forgedb.InitSimple()
|
||||
fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this")
|
||||
}
|
||||
|
||||
func (args) doBashAuto() {
|
||||
argv.doBashHelp()
|
||||
switch argv.BashAuto[0] {
|
||||
case "playback":
|
||||
fmt.Println("list --force")
|
||||
case "clean":
|
||||
fmt.Println("user devel master")
|
||||
default:
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("playback add")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// prints help to STDERR // TODO: move everything below this to go-args
|
||||
func (args) doBashHelp() {
|
||||
if argv.BashAuto[1] != "''" {
|
||||
// if this is not blank, then the user has typed something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] != ARGNAME {
|
||||
// if this is not the name of the command, the user already started doing something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
me.pp.WriteHelp(os.Stderr)
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
fmt.Fprintln(os.Stderr, "hello world")
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
}
|
||||
|
||||
/*
|
||||
// complete -F forge --bash forge
|
||||
func (args) doBash() {
|
||||
fmt.Println("# add this in your bashrc:")
|
||||
fmt.Println("")
|
||||
fmt.Println("# todo: add this to go-arg as a 'hidden' go-arg option --bash")
|
||||
fmt.Println("#")
|
||||
fmt.Println("# todo: can this output work/parse with:")
|
||||
fmt.Println("# complete -C `" + ARGNAME + " --bash` " + ARGNAME)
|
||||
fmt.Println("")
|
||||
fmt.Println("_" + ARGNAME + "_complete()")
|
||||
fmt.Println("{")
|
||||
fmt.Println(" # sets local to this func vars")
|
||||
fmt.Println(" local cur prev all")
|
||||
fmt.Println(" cur=${COMP_WORDS[COMP_CWORD]}")
|
||||
fmt.Println(" prev=${COMP_WORDS[COMP_CWORD-1]}")
|
||||
fmt.Println(" all=${COMP_WORDS[@]}")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this is where we generate the go-arg output")
|
||||
fmt.Println(" GOARGS=$(" + ARGNAME + " --auto-complete $prev \\'$cur\\' $all)")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this compares the command line input from the user")
|
||||
fmt.Println(" # to whatever strings we output")
|
||||
fmt.Println(" COMPREPLY=( $(compgen -W \"$GOARGS\" -- $cur) ) # THIS WORKS")
|
||||
fmt.Println(" return 0")
|
||||
fmt.Println("}")
|
||||
fmt.Println("complete -F _" + ARGNAME + "_complete " + ARGNAME)
|
||||
fmt.Println("")
|
||||
fmt.Println("# copy and paste the above into your bash shell should work")
|
||||
os.Exit(0)
|
||||
}
|
||||
*/
|
||||
|
||||
// complete -F forge --bash forge
|
||||
func (args) doBash() {
|
||||
fmt.Println("# add this in your bashrc:")
|
||||
fmt.Println("")
|
||||
fmt.Println("# todo: add this to go-arg as a 'hidden' go-arg option --bash")
|
||||
fmt.Println("#")
|
||||
fmt.Println("# Put the below in the file: ~/.local/share/bash-completion/completions/" + ARGNAME)
|
||||
fmt.Println("#")
|
||||
fmt.Println("# todo: make this output work/parse with:")
|
||||
fmt.Println("# complete -C " + ARGNAME + " --bash go")
|
||||
fmt.Println("")
|
||||
fmt.Println("_" + ARGNAME + "_complete()")
|
||||
fmt.Println("{")
|
||||
fmt.Println(" # sets local to this func vars")
|
||||
fmt.Println(" local cur prev all")
|
||||
fmt.Println(" cur=${COMP_WORDS[COMP_CWORD]}")
|
||||
fmt.Println(" prev=${COMP_WORDS[COMP_CWORD-1]}")
|
||||
fmt.Println(" all=${COMP_WORDS[@]}")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this is where we generate the go-arg output")
|
||||
fmt.Println(" GOARGS=$(" + ARGNAME + " --auto-complete $prev \\'$cur\\' $all)")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this compares the command line input from the user")
|
||||
fmt.Println(" # to whatever strings we output")
|
||||
fmt.Println(" COMPREPLY=( $(compgen -W \"$GOARGS\" -- $cur) ) # THIS WORKS")
|
||||
fmt.Println(" return 0")
|
||||
fmt.Println("}")
|
||||
fmt.Println("complete -F _" + ARGNAME + "_complete " + ARGNAME)
|
||||
fmt.Println("")
|
||||
fmt.Println("# copy and paste the above into your bash shell should work")
|
||||
os.Exit(0)
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
Package: gemini
|
||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||
Depends: go-gui-toolkits
|
||||
Build-Depends: golang, protoc-gen-go, autogenpb, go-mod-clean
|
||||
Description: interact with Google's Gemini AI
|
||||
Goals:
|
||||
Save all interactions in a protobuf
|
||||
Have a Terminal UI, Console UI and GUI (GTK)
|
||||
Can "restart" from where you left off
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func okExit(thing string) {
|
||||
if thing != "" {
|
||||
log.Info("gemini exit:", thing, "ok")
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func badExit(err error) {
|
||||
log.Info("gemini failed: ", err)
|
||||
os.Exit(-1)
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
// An app to submit patches for the 30 GO GUI repos
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// sent via -ldflags
|
||||
var VERSION string
|
||||
var BUILDTIME string
|
||||
|
||||
// this optionally can store the GUI plugins
|
||||
//
|
||||
//go:embed resources/*
|
||||
var resources embed.FS
|
||||
|
||||
// used for shell auto completion
|
||||
var ARGNAME string = "gemini"
|
||||
|
||||
// using this for now. triggers config save
|
||||
var configSave bool
|
||||
|
||||
func getVersion(repo *gitpb.Repo, name string) string {
|
||||
cmd := []string{"git", "describe", "--tags", "--always", name}
|
||||
result, _ := repo.RunQuiet(cmd)
|
||||
output := strings.Join(result.Stdout, "\n")
|
||||
log.Info("cmd =", cmd, output)
|
||||
|
||||
return strings.TrimSpace(output)
|
||||
}
|
||||
|
||||
func main() {
|
||||
me = new(mainType)
|
||||
gui.InitArg()
|
||||
me.pp = arg.MustParse(&argv)
|
||||
|
||||
if argv.Bash {
|
||||
argv.doBash()
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(argv.BashAuto) != 0 {
|
||||
argv.doBashAuto()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if argv.Playback != nil {
|
||||
log.Info("do playback here")
|
||||
okExit("")
|
||||
}
|
||||
|
||||
if argv.Add != nil {
|
||||
log.Info("add new conversation to protobuf")
|
||||
okExit("")
|
||||
}
|
||||
|
||||
// if opening the GUI, always check git for dirty repos
|
||||
log.Info("open the gui here")
|
||||
// doGui()
|
||||
okExit("")
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# this file is intended to be used to customize settings on what
|
||||
# git repos you have write access to. That is, where you can run 'git push'
|
||||
#
|
||||
# add entries to this using 'forge config'
|
||||
|
||||
ForgeConfigs: {
|
||||
goPath: "go.wit.com"
|
||||
writable: true
|
||||
directory: true
|
||||
}
|
||||
repos: {
|
||||
goPath: "go.wit.com/apps/zookeeper"
|
||||
debName: "zookeeper-go"
|
||||
}
|
||||
xterm: "xterm"
|
||||
xtermArgv: "-bg"
|
||||
xtermArgv: "black"
|
||||
xtermArgv: "-fg"
|
||||
xtermArgv: "white"
|
||||
xtermArgv: "-geometry"
|
||||
xtermArgv: "140x32"
|
||||
xtermArgv: "-e"
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
)
|
||||
|
||||
var me *mainType
|
||||
|
||||
// this app's variables
|
||||
type mainType struct {
|
||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
||||
// myGui *gui.Node // the gui toolkit handle
|
||||
}
|
Loading…
Reference in New Issue