Skip to content

Commit ac18bc0

Browse files
authored
Merge pull request #7 from sky-xo/gemini
feat: add Gemini agent spawn support
2 parents a0e1f45 + f1511e4 commit ac18bc0

18 files changed

Lines changed: 1621 additions & 45 deletions

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ require (
5151
golang.org/x/net v0.33.0 // indirect
5252
golang.org/x/sys v0.39.0 // indirect
5353
golang.org/x/text v0.26.0 // indirect
54+
gopkg.in/yaml.v3 v3.0.1 // indirect
5455
modernc.org/libc v1.66.10 // indirect
5556
modernc.org/mathutil v1.7.1 // indirect
5657
modernc.org/memory v1.11.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
114114
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
115115
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
116116
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
117+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
118+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
117119
modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4=
118120
modernc.org/cc/v4 v4.26.5/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
119121
modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A=

internal/agent/agent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ const (
1212
const (
1313
SourceClaude = "claude"
1414
SourceCodex = "codex"
15+
SourceGemini = "gemini"
1516
)
1617

1718
// Agent represents any AI coding agent (Claude, Codex, etc.)
1819
type Agent struct {
1920
// Identity
2021
ID string // ULID or extracted from filename
2122
Name string // Display name (user-given for Codex, extracted from transcript for Claude)
22-
Source string // "claude" or "codex"
23+
Source string // "claude", "codex", or "gemini"
2324

2425
// Channel grouping
2526
RepoPath string // Git repo path

internal/cli/logs.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/sky-xo/june/internal/codex"
88
"github.com/sky-xo/june/internal/db"
9+
"github.com/sky-xo/june/internal/gemini"
910
"github.com/spf13/cobra"
1011
)
1112

@@ -47,24 +48,39 @@ func runLogs(name string) error {
4748
// Find session file if not set
4849
sessionFile := agent.SessionFile
4950
if sessionFile == "" {
50-
found, err := codex.FindSessionFile(agent.ULID)
51-
if err != nil {
51+
var findErr error
52+
if agent.Type == "gemini" {
53+
sessionFile, findErr = gemini.FindSessionFile(agent.ULID)
54+
} else {
55+
sessionFile, findErr = codex.FindSessionFile(agent.ULID)
56+
}
57+
if findErr != nil {
5258
return fmt.Errorf("session file not found for agent %q", name)
5359
}
54-
sessionFile = found
5560
}
5661

57-
// Read from beginning (cursor 0), don't update cursor
58-
entries, _, err := codex.ReadTranscript(sessionFile, 0)
59-
if err != nil {
60-
return fmt.Errorf("failed to read transcript: %w", err)
62+
// Read transcript based on agent type
63+
var output string
64+
65+
if agent.Type == "gemini" {
66+
entries, _, err := gemini.ReadTranscript(sessionFile, 0)
67+
if err != nil {
68+
return fmt.Errorf("failed to read transcript: %w", err)
69+
}
70+
output = gemini.FormatEntries(entries)
71+
} else {
72+
entries, _, err := codex.ReadTranscript(sessionFile, 0)
73+
if err != nil {
74+
return fmt.Errorf("failed to read transcript: %w", err)
75+
}
76+
output = codex.FormatEntries(entries)
6177
}
6278

63-
if len(entries) == 0 {
79+
if output == "" {
6480
fmt.Println("(no output)")
6581
return nil
6682
}
6783

68-
fmt.Print(codex.FormatEntries(entries))
84+
fmt.Print(output)
6985
return nil
7086
}

internal/cli/peek.go

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/sky-xo/june/internal/codex"
99
"github.com/sky-xo/june/internal/db"
10+
"github.com/sky-xo/june/internal/gemini"
1011
"github.com/spf13/cobra"
1112
)
1213

@@ -48,25 +49,41 @@ func runPeek(name string) error {
4849
// Find session file if not set
4950
sessionFile := agent.SessionFile
5051
if sessionFile == "" {
51-
found, err := codex.FindSessionFile(agent.ULID)
52-
if err != nil {
52+
var findErr error
53+
if agent.Type == "gemini" {
54+
sessionFile, findErr = gemini.FindSessionFile(agent.ULID)
55+
} else {
56+
sessionFile, findErr = codex.FindSessionFile(agent.ULID)
57+
}
58+
if findErr != nil {
5359
return fmt.Errorf("session file not found for agent %q", name)
5460
}
55-
sessionFile = found
56-
// Update in database
57-
if err := database.UpdateSessionFile(name, found); err != nil {
58-
// Log warning but continue - this is not fatal
61+
if err := database.UpdateSessionFile(name, sessionFile); err != nil {
5962
fmt.Fprintf(os.Stderr, "warning: failed to update session file in database: %v\n", err)
6063
}
6164
}
6265

63-
// Read from cursor
64-
entries, newCursor, err := codex.ReadTranscript(sessionFile, agent.Cursor)
65-
if err != nil {
66-
return fmt.Errorf("failed to read transcript: %w", err)
66+
// Read transcript based on agent type
67+
var output string
68+
var newCursor int
69+
70+
if agent.Type == "gemini" {
71+
entries, cursor, err := gemini.ReadTranscript(sessionFile, agent.Cursor)
72+
if err != nil {
73+
return fmt.Errorf("failed to read transcript: %w", err)
74+
}
75+
newCursor = cursor
76+
output = gemini.FormatEntries(entries)
77+
} else {
78+
entries, cursor, err := codex.ReadTranscript(sessionFile, agent.Cursor)
79+
if err != nil {
80+
return fmt.Errorf("failed to read transcript: %w", err)
81+
}
82+
newCursor = cursor
83+
output = codex.FormatEntries(entries)
6784
}
6885

69-
if len(entries) == 0 {
86+
if output == "" {
7087
fmt.Println("(no new output)")
7188
return nil
7289
}
@@ -76,7 +93,6 @@ func runPeek(name string) error {
7693
return fmt.Errorf("failed to update cursor: %w", err)
7794
}
7895

79-
// Print entries
80-
fmt.Print(codex.FormatEntries(entries))
96+
fmt.Print(output)
8197
return nil
8298
}

0 commit comments

Comments
 (0)