Add BD_AGENT_MODE for ultra-compact output

Adds agent-optimized output mode for `bd list` triggered by:
- BD_AGENT_MODE=1 environment variable (explicit)
- CLAUDE_CODE environment variable (auto-detect)

Agent mode provides:
- Ultra-compact format: just "ID: Title" per line
- Lower default limit (20 vs 50) for context efficiency
- No colors, no emojis, no pager
- Defaults to open/in_progress only (existing behavior)

(bd-x2ht)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 15:59:11 -08:00
parent 288334f8b4
commit b45e68c5ce
3 changed files with 66 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ package ui
import (
"fmt"
"os"
"strings"
"github.com/charmbracelet/lipgloss"
@@ -17,6 +18,23 @@ func init() {
}
}
// IsAgentMode returns true if the CLI is running in agent-optimized mode.
// This is triggered by:
// - BD_AGENT_MODE=1 environment variable (explicit)
// - CLAUDE_CODE environment variable (auto-detect Claude Code)
//
// Agent mode provides ultra-compact output optimized for LLM context windows.
func IsAgentMode() bool {
if os.Getenv("BD_AGENT_MODE") == "1" {
return true
}
// Auto-detect Claude Code environment
if os.Getenv("CLAUDE_CODE") != "" {
return true
}
return false
}
// Ayu theme color palette
// Dark: https://terminalcolors.com/themes/ayu/dark/
// Light: https://terminalcolors.com/themes/ayu/light/

View File

@@ -152,3 +152,26 @@ func TestRenderCommandAndCategoryAreUppercaseSafe(t *testing.T) {
t.Fatalf("command output missing text: %q", cmd)
}
}
func TestIsAgentMode(t *testing.T) {
// Test default (no env vars) - t.Setenv automatically restores after test
t.Setenv("BD_AGENT_MODE", "")
t.Setenv("CLAUDE_CODE", "")
if IsAgentMode() {
t.Fatal("expected false with no env vars")
}
// Test BD_AGENT_MODE=1
t.Setenv("BD_AGENT_MODE", "1")
t.Setenv("CLAUDE_CODE", "")
if !IsAgentMode() {
t.Fatal("expected true with BD_AGENT_MODE=1")
}
// Test CLAUDE_CODE auto-detection
t.Setenv("BD_AGENT_MODE", "")
t.Setenv("CLAUDE_CODE", "something")
if !IsAgentMode() {
t.Fatal("expected true with CLAUDE_CODE set")
}
}