guanghu/docs/adr/0028-cli-agent-only-no-api-key.md
Guanghu Domestic Migration 9b41d51231
Some checks are pending
Auto-update PR branches / Update open PR branches (push) Waiting to run
CI / Frontend Static Quality Checks (push) Waiting to run
CI / Frontend Tests & Coverage (push) Waiting to run
CI / Rust Tests & Quality Checks (push) Waiting to run
CI / Linux build verification (push) Waiting to run
Deploy docs / Build VitePress site (push) Waiting to run
Deploy docs / Deploy to GitHub Pages (push) Blocked by required conditions
Release (Alpha) / Compute alpha version (push) Waiting to run
Release (Alpha) / Build release artifacts (push) Blocked by required conditions
Release (Alpha) / GitHub Release (alpha) (push) Blocked by required conditions
Release (Alpha) / Update docs and release pages (push) Blocked by required conditions
chore: import sanitized domestic snapshot for REPO-004
Source snapshot: 514ab1975951d94342ea38e64101d5a0f1c51c77
2026-07-17 15:55:28 +08:00

2.2 KiB

type, id, title, status, date, supersedes
type id title status date supersedes
ADR 0028 CLI agent only — no direct Anthropic API key active 2026-03-29 0027

Context

ADR-0027 introduced a dual AI architecture: a lightweight API-based chat (AIChatPanel) using the Anthropic API directly, and a full CLI agent (AiPanel) spawning Claude CLI as a subprocess with MCP tool access. In practice, the API chat was never shipped to users — the CLI agent covered all use cases and provided a superior experience through tool access and MCP integration. Maintaining two codepaths added complexity, and requiring users to manage an Anthropic API key created friction.

Decision

Remove the direct Anthropic API integration entirely. AI is available exclusively via CLI agent subprocesses (Claude Code, and in the future Codex or other CLI agents). No API key field in settings. The CLI agent authenticates via its own mechanism (e.g. claude CLI login).

Removed:

  • AIChatPanel component, useAIChat hook
  • Rust ai_chat command and ai_chat.rs module
  • anthropic_key field from Settings (Rust and TypeScript)
  • Vite dev-server Anthropic API proxy (aiChatProxyPlugin, aiAgentProxyPlugin)

Kept:

  • AiPanel + useAiAgent — Claude CLI subprocess with MCP vault integration
  • Shared utilities in ai-chat.ts (trimHistory, formatMessageWithHistory, streamClaudeChat, etc.)
  • Cmd+I keyboard shortcut and menu item for toggling the AI panel

Options considered

  • Option A (chosen): Remove API chat, keep CLI agent only. Simplifies codebase, removes API key management, single codepath.
  • Option B: Keep both but hide API chat behind feature flag. Adds dead code weight without benefit.
  • Option C: Replace CLI agent with API chat + manual tool calling. Loses MCP integration and Claude CLI features.

Consequences

  • Users no longer need to obtain or manage an Anthropic API key
  • Existing saved API keys are silently ignored (the field no longer exists in the Settings struct; serde skips unknown fields on deserialization)
  • Future CLI agents (Codex, etc.) can plug into the same AiPanel architecture
  • If a lightweight chat mode is needed later, it should be built as a CLI agent mode, not a separate API integration