refactor: Store all log content in external files
- Modify the logging system to store all conversation text, code snippets, and other content in external files within the log/content/ directory. - The main .text log file now only contains metadata and pointers to these external content files. - Update the Go log formatter to read and assemble this distributed log format for display. This makes the entire system more robust and avoids parsing/escaping issues.
This commit is contained in:
parent
d0a00107b9
commit
83d59c4095
7
Makefile
7
Makefile
|
@ -24,6 +24,11 @@ gemini-config:
|
|||
gemini-go:
|
||||
~/go/bin/gemini playback
|
||||
|
||||
add:
|
||||
add-BACnet:
|
||||
~/go/bin/gemini --add log/BACnet.text
|
||||
ls -lt ~/.config/gemini/
|
||||
|
||||
add-shell:
|
||||
ls -lt ~/.config/gemini/
|
||||
gemini --add log/2025-08-21-shell-v2.text
|
||||
ls -lt ~/.config/gemini/
|
||||
|
|
|
@ -60,7 +60,38 @@ func main() {
|
|||
for _, toolCall := range chat.GetToolCalls() {
|
||||
printToolCallBox(toolCall)
|
||||
}
|
||||
|
||||
// Handle the new CodeSnippet field.
|
||||
if snippets := chat.GetSnippets(); snippets != nil {
|
||||
logDir := filepath.Dir(filename)
|
||||
for _, snippet := range snippets {
|
||||
printCodeSnippet(snippet, logDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// printCodeSnippet formats a code snippet block by reading its content from a file.
|
||||
func printCodeSnippet(snippet *chatpb.CodeSnippet, logDir string) {
|
||||
snippetPath := filepath.Join(logDir, snippet.GetFilename())
|
||||
|
||||
codeBytes, err := os.ReadFile(snippetPath)
|
||||
if err != nil {
|
||||
fmt.Printf("┌─[ ERROR: Could not read snippet file %s ]─\n\n", snippetPath)
|
||||
return
|
||||
}
|
||||
|
||||
code := string(codeBytes)
|
||||
language := filepath.Base(snippet.GetFilename()) // Use the filename as the language for display
|
||||
|
||||
fmt.Printf("┌─[ Code Snippet: %s ]──────────────────────────────────\n", language)
|
||||
|
||||
// Print each line of the code indented.
|
||||
for _, line := range strings.Split(strings.TrimSpace(code), "\n") {
|
||||
fmt.Printf("│ %s\n", line)
|
||||
}
|
||||
|
||||
fmt.Printf("└─────────────────────────────────────────────────────────\n\n")
|
||||
}
|
||||
|
||||
// printToolCallBox handles the decorative formatting for a single tool call.
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
uuid: "shell-path-log-02"
|
||||
version: "v0.0.4 go.wit.com/lib/protobuf/chatpb"
|
||||
Chats: {
|
||||
from: USER
|
||||
ctime: { seconds: 1724168400 }
|
||||
ContentFile: "content/shell_v2_q1.content"
|
||||
}
|
||||
Chats: {
|
||||
from: GEMINI
|
||||
ctime: { seconds: 1724168460 }
|
||||
ContentFile: "content/shell_v2_a1.content"
|
||||
Snippets: {
|
||||
filename: "content/shell_v2_a1.snippet"
|
||||
}
|
||||
}
|
||||
Chats: {
|
||||
from: USER
|
||||
ctime: { seconds: 1724168520 }
|
||||
ContentFile: "content/shell_v2_q2.content"
|
||||
}
|
||||
Chats: {
|
||||
from: GEMINI
|
||||
ctime: { seconds: 1724168580 }
|
||||
ContentFile: "content/shell_v2_a2.content"
|
||||
Snippets: {
|
||||
filename: "content/shell_v2_a2.snippet"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
You are absolutely right in your understanding, and your confusion is completely justified. The `PATH` variable **is** processed in order from left to right. The output you are seeing means that the `PATH` your shell is *actually* using is different from the one you've posted. The problem almost always comes from the shell startup files. The solution is to **prepend, don't append** your custom directories to the PATH.
|
|
@ -0,0 +1 @@
|
|||
export PATH="/home/jcarr/go/bin:$PATH"
|
|
@ -0,0 +1 @@
|
|||
You've found the root cause perfectly. This is a classic shell precedence issue. The order is: Aliases -> Keywords -> Functions -> Built-ins -> $PATH lookup. Your alias is being found at step 1, so the shell never even gets to step 5. The best solution is often to rename the alias in your `~/.bashrc` to something more specific, like `gemini-cli`.
|
|
@ -0,0 +1,5 @@
|
|||
# To bypass the alias for a single command:
|
||||
\gemini --version
|
||||
|
||||
# To rename the alias permanently in your ~/.bashrc:
|
||||
alias gemini-cli='node /home/jcarr/go/src/github.com/google-gemini/gemini-cli/scripts/start.js'
|
|
@ -0,0 +1,2 @@
|
|||
My PATH is: PATH=/home/jcarr/.local/bin/:/home/jcarr/jcarr/bin/:/home/jcarr/go/bin/:/sbin:/usr/sbin:/home/jcarr/go/bin:/usr/games:/home/jcarr/.local/bin/:/home/jcarr/go/bin/:/sbin:/usr/sbin:/home/jcarr/go/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
|
||||
but for some reason it is finding binaries in /usr/local/bin before /home/jcarr/go/bin. I thought the PATH was processed in order?
|
|
@ -0,0 +1,10 @@
|
|||
I see the problem. gemini is an alias. I'm not sure how to resolve this problem
|
||||
jcarr@framebook:~/go/src/gemini$ which gemini
|
||||
/home/jcarr/go/bin/gemini
|
||||
jcarr@framebook:~/go/src/gemini$ /home/jcarr/go/bin/gemini --version
|
||||
gemini v0.0.1-3-ga10b75d Built on 2025.08.21_1551
|
||||
jcarr@framebook:~/go/src/gemini$ gemini --version
|
||||
Checking build status...
|
||||
Build is up-to-date.
|
||||
jcarr@framebook:~/go/src/gemini$ alias |grep gemini
|
||||
alias gemini='node /home/jcarr/go/src/github.com/google-gemini/gemini-cli/scripts/start.js'
|
Loading…
Reference in New Issue