Surface token diagnostics in labs · Entire
Surface token diagnostics in labs
a8f6f46·
peyton-alt·3w ago·3 files·+61 added/-40 removed
Sessions
642c25c2fd0cView transcript
Changes
3
cmd/entire/cli
Mlabs.go+39/-27
Mlabs_test.go+19/-11
Mtokens_profile.go+3/-2
8 unmodified lines
```go
type experimentalCommandInfo struct {
Name string
Invocation string
Summary string
CommandPath []string
Invocation string
Summary string
}
var experimentalCommands = []experimentalCommandInfo{
{
Name: "review",
Invocation: "entire review",
Summary: "Run configured review skills against the current branch",
CommandPath: []string{"review"},
Invocation: "entire review",
Summary: "Run configured review skills against the current branch",
},
{
Name: "investigate",
Invocation: "entire investigate",
Summary: "Run a multi-agent investigation against a topic, issue, or seed doc",
CommandPath: []string{"investigate"},
Invocation: "entire investigate",
Summary: "Run a multi-agent investigation against a topic, issue, or seed doc",
},
{
Name: "org",
Invocation: "entire org",
Summary: "Manage Entire organizations (create, list)",
CommandPath: []string{"tokens"},
Invocation: "entire tokens",
Summary: "Analyze experimental token usage diagnostics",
},
{
Name: "project",
Invocation: "entire project",
Summary: "Manage Entire projects (create, list)",
CommandPath: []string{"tokens", "profile"},
Invocation: "entire tokens profile",
Summary: "Aggregate token usage across committed checkpoints",
},
{
Name: "repo",
Invocation: "entire repo",
Summary: "Manage Entire repositories (create, list, get, delete)",
CommandPath: []string{"org"},
Invocation: "entire org",
Summary: "Manage Entire organizations (create, list)",
},
{
Name: "grant",
Invocation: "entire grant",
Summary: "Manage access grants and org membership (org, project, repo)",
CommandPath: []string{"project"},
Invocation: "entire project",
Summary: "Manage Entire projects (create, list)",
},
{
Name: "blame",
Invocation: "entire blame",
Summary: "Show which lines came from Entire checkpoints",
CommandPath: []string{"repo"},
Invocation: "entire repo",
Summary: "Manage Entire repositories (create, list, get, delete)",
},
{
Name: "why",
Invocation: "entire why",
Summary: "Show why a line exists (commit, checkpoint, prompt, session)",
CommandPath: []string{"grant"},
Invocation: "entire grant",
Summary: "Manage access grants and org membership (org, project, repo)",
},
{
CommandPath: []string{"blame"},
Invocation: "entire blame",
Summary: "Show which lines came from Entire checkpoints",
},
{
CommandPath: []string{"why"},
Invocation: "entire why",
Summary: "Show why a line exists (commit, checkpoint, prompt, session)",
},
}
37 unmodified lines
Try:
entire review --help
entire investigate --help
entire tokens --help
entire tokens profile --help
entire org --help
entire project --help
entire repo --help
Mcmd/entire/cli/labs.go+39/-27
25 unmodified lines
26
27
28
29
30
31
32
33
34
61 unmodified lines
96
97
98
96
97
99
100
101
102
103
104
105
106
107
108
42 unmodified lines
151
152
153
146
147
154
155
156
157
150
151
158
159
160
161
162
18 unmodified lines
181
182
183
176
177
184
185
186
187
188
11 unmodified lines
200
201
202
195
203
204
197
205
206
207
200
208
209
210
211
25 unmodified lines
"Available experimental commands",
"entire review",
"entire review --help",
"entire tokens",
"entire tokens profile",
"entire tokens profile --help",
} {
if !strings.Contains(got, want) {
t.Fatalf("entire labs output missing %q:\n%s", want, got)
}
61 unmodified lines
if !strings.Contains(got, "labs") || !strings.Contains(got, "Explore experimental Entire workflows") {
t.Fatalf("root help should include labs command, got:\n%s", got)
}
if strings.Contains(got, "review") {
t.Fatalf("root help should not include review while it is listed in labs, got:\n%s", got)
}
for _, hiddenExperimentalCommand := range []string{
"review",
"tokens Analyze token usage across sessions and checkpoints",
} {
if strings.Contains(got, hiddenExperimentalCommand) {
t.Fatalf("root help should not include %q while it is listed in labs, got:\n%s", hiddenExperimentalCommand, got)
}
}
}
42 unmodified lines
t.Parallel()
short := []experimentalCommandInfo{
{Name: "a", Invocation: "entire a", Summary: "first"},
{Name: "b", Invocation: "entire b", Summary: "second"},
{Invocation: "entire a", Summary: "first"},
{Invocation: "entire b", Summary: "second"},
}
long := []experimentalCommandInfo{
{Name: "a", Invocation: "entire a", Summary: "first"},
{Name: "verylongcommand", Invocation: "entire verylongcommand", Summary: "second"},
{Invocation: "entire a", Summary: "first"},
{Invocation: "entire verylongcommand", Summary: "second"},
}
shortCol := summaryColumns(t, short)[0]
18 unmodified lines
// padding, len("entire ▶▶") == 13 >= 12 would skip padding and misalign the
// row; rune-based padding correctly adds 3 spaces.
commands := []experimentalCommandInfo{
{Name: "long", Invocation: "entire aaaaa", Summary: "first"},
{Name: "multibyte", Invocation: "entire ▶▶", Summary: "second"},
{Invocation: "entire aaaaa", Summary: "first"},
{Invocation: "entire ▶▶", Summary: "second"},
}
if got := len("entire ▶▶"); got < 12 {
11 unmodified lines
root := NewRootCmd()
for _, info := range experimentalCommands {
cmd, _, err := root.Find([]string{info.Name})
cmd, _, err := root.Find(info.CommandPath)
if err != nil {
t.Fatalf("labs command %q should exist at canonical path: %v", info.Name, err)
t.Fatalf("labs command %q should exist at canonical path: %v", info.Invocation, err)
}
if cmd == nil {
t.Fatalf("labs command %q resolved to nil command", info.Name)
t.Fatalf("labs command %q resolved to nil command", info.Invocation)
}
}
}
Mcmd/entire/cli/labs_test.go+19/-11
50 unmodified lines
51
52
53
54
55
54
55
56
57
58
59
50 unmodified lines
func newTokensGroupCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "tokens",
Short: "Analyze token usage across sessions and checkpoints",
Use: "tokens",
Short: "Analyze token usage across sessions and checkpoints",
Hidden: true,
Long: `Analyze token usage across sessions and checkpoints.
Commands:
Mcmd/entire/cli/tokens_profile.go+3/-2