more stuff for importing JSON output from gemini-cli

This commit is contained in:
Jeff Carr 2025-09-01 22:19:44 -05:00
parent 559e276c44
commit 49ad81bc27
3 changed files with 58 additions and 2 deletions

28
addChat.go Normal file
View File

@ -0,0 +1,28 @@
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package chatpb
import (
"time"
"go.wit.com/log"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
// returns true if the pb was added
// to indicate that ConfigSave() should be run to write it out to disk
func (c *Chat) AddGeminiRequest(fname string, age time.Time, pb *GeminiRequest) bool {
for _, e := range c.GetEntries() {
if e.GetContentFile() == fname {
log.Info("fname already here", fname)
return false
}
}
e := new(ChatEntry)
e.Ctime = timestamppb.New(age)
e.From = Who_USER
e.ContentFile = fname
e.GeminiRequest = pb
c.AppendEntry(e)
return true
}

24
find.go Normal file
View File

@ -0,0 +1,24 @@
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package chatpb
func (all *Chats) FindUuid(id string) *Chat {
for chat := range all.IterAll() {
if chat.Uuid == id {
return chat
}
for _, e := range chat.GetSession() {
if id == e.Uuid {
return chat
}
}
for _, e := range chat.GetEntries() {
if id == e.Uuid {
return chat
}
}
}
return nil
}

View File

@ -78,7 +78,7 @@ func (c *Chat) PrintChatGeminiTable() {
// print the header
args := []string{"uuid", "age", "ID", "Who", "model", "", "", "", "", ""}
sizes := []int{40, 5, 5, 8, 12, 2, 2, 2, 2, 2}
sizes := []int{40, 5, 5, 8, 16, 2, 2, 2, 2, 2}
log.Info(cobol.StandardTableSize10(sizes, args))
for _, e := range c.GetEntries() {
@ -94,7 +94,11 @@ func (c *Chat) PrintChatGeminiTable() {
}
if e.GetContentFile() != "" {
parts := strings.Split(e.GetContentFile(), ".")
id = parts[3]
if len(parts) < 4 {
id = "??"
} else {
id = parts[3]
}
}
args = []string{e.Uuid, age, id, e.From.String(), model, "", "", "", "", ""}