add agent brief for token diagnostics · Entire

add agent brief for token diagnostics

Sessions

Changes

    68 unmodified lines
    ```

```go
func newTokensCmd() *cobra.Command {
    var jsonFlag bool
    var currentFlag bool
    var agentBriefFlag bool

cmd := &cobra.Command{
        Use:   "tokens [session-id]",
    
    // Other code omitted for brevity

return cmd
}

The Usage

When no session ID is provided, Entire reports on the most recently active session, preferring the current worktree and falling back to the newest session if no state matches this worktree.

Example Usage

Use --agent-brief when an agent needs compact guidance for the next step, for example: "Use Entire token tracking to check how this session is doing and optimize next steps."

func runSessionTokens(ctx context.Context, cmd *cobra.Command, sessionID string, current, jsonOutput bool) error {
    // Code implementation
}

Recommendations Function

func writeTokenRecommendations(w io.Writer, recs []sessionTokensRecommendation) {
    fmt.Fprintln(w)
    fmt.Fprintln(w, "Recommendations")
}

Testing Example

func TestTokensCmd_AgentBriefPrioritizesNextAction(t *testing.T) {
    setupStopTestRepo(t)
    // Test implementation
}