summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-16 07:52:55 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-16 07:52:55 +0300
commit7c8697f48e3a7729a5aa4ecc5c189bf151070915 (patch)
tree9accf94b349ec717feb8238e7fe3e794cadfc1c0 /main.go
parent7f8bbefb05d85dcbcc560a0fb23256b912676486 (diff)
Enha (cli): -msg -continue flags
Diffstat (limited to 'main.go')
-rw-r--r--main.go45
1 files changed, 34 insertions, 11 deletions
diff --git a/main.go b/main.go
index 2f02b8e..1af3c26 100644
--- a/main.go
+++ b/main.go
@@ -30,18 +30,21 @@ var (
focusSwitcher = map[tview.Primitive]tview.Primitive{}
app *tview.Application
cliCardPath string
+ cliContinue bool
+ cliMsg string
)
func main() {
flag.BoolVar(&cfg.CLIMode, "cli", false, "Run in CLI mode without TUI")
+ flag.BoolVar(&cfg.ToolUse, "tools", true, "run with tools")
flag.StringVar(&cliCardPath, "card", "", "Path to syscard JSON file")
+ flag.BoolVar(&cliContinue, "continue", false, "Continue from last chat (by agent or card)")
+ flag.StringVar(&cliMsg, "msg", "", "Send message and exit (one-shot mode)")
flag.Parse()
-
if cfg.CLIMode {
runCLIMode()
return
}
-
pages.AddPage("main", flex, true, true)
if err := app.SetRoot(pages,
true).EnableMouse(cfg.EnableMouse).EnablePaste(true).Run(); err != nil {
@@ -53,7 +56,6 @@ func main() {
func runCLIMode() {
outputHandler = &CLIOutputHandler{}
cliRespDone = make(chan bool, 1)
-
if cliCardPath != "" {
card, err := pngmeta.ReadCardJson(cliCardPath)
if err != nil {
@@ -66,16 +68,38 @@ func runCLIMode() {
charToStart(card.Role, false)
fmt.Printf("Loaded syscard: %s (%s)\n", card.Role, card.FilePath)
}
-
- startNewCLIChat()
-
+ if cliContinue {
+ if cliCardPath != "" {
+ history, err := loadAgentsLastChat(cfg.AssistantRole)
+ if err != nil {
+ fmt.Printf("No previous chat found for %s, starting new chat\n", cfg.AssistantRole)
+ startNewCLIChat()
+ } else {
+ chatBody.Messages = history
+ fmt.Printf("Continued chat: %s\n", activeChatName)
+ }
+ } else {
+ chatBody.Messages = loadOldChatOrGetNew()
+ fmt.Printf("Continued chat: %s\n", activeChatName)
+ }
+ } else {
+ startNewCLIChat()
+ }
printCLIWelcome()
-
go func() {
<-ctx.Done()
os.Exit(0)
}()
-
+ if cliMsg != "" {
+ persona := cfg.UserRole
+ if cfg.WriteNextMsgAs != "" {
+ persona = cfg.WriteNextMsgAs
+ }
+ chatRoundChan <- &models.ChatRoundReq{Role: persona, UserMsg: cliMsg}
+ <-cliRespDone
+ fmt.Println()
+ return
+ }
scanner := bufio.NewScanner(os.Stdin)
for {
fmt.Print("> ")
@@ -86,7 +110,6 @@ func runCLIMode() {
if msg == "" {
continue
}
-
if strings.HasPrefix(msg, "/") {
if !handleCLICommand(msg) {
return
@@ -94,7 +117,6 @@ func runCLIMode() {
fmt.Println()
continue
}
-
persona := cfg.UserRole
if cfg.WriteNextMsgAs != "" {
persona = cfg.WriteNextMsgAs
@@ -196,7 +218,8 @@ func handleCLICommand(msg string) bool {
fmt.Printf("Loaded chat: %s\n", name)
case "/model", "/m":
if len(args) == 0 {
- fmt.Printf("Current model: %s\n", chatBody.Model)
+ // fmt.Printf("Current model: %s\n", chatBody.Model)
+ fmt.Println("Models: ", LocalModels)
return true
}
chatBody.Model = args[0]