guanghu/docs/adr/0028-cli-agent-only-no-api-key.md
冰朔 8739805f99
Some checks failed
Auto-update PR branches / Update open PR branches (push) Has been cancelled
CI / Frontend Static Quality Checks (push) Has been cancelled
CI / Frontend Tests & Coverage (push) Has been cancelled
CI / Rust Tests & Quality Checks (push) Has been cancelled
CI / Linux build verification (push) Has been cancelled
Release (Alpha) / Compute alpha version (push) Has been cancelled
Release (Alpha) / Build release artifacts (push) Has been cancelled
Release (Alpha) / GitHub Release (alpha) (push) Has been cancelled
Release (Alpha) / Update docs and release pages (push) Has been cancelled
Deploy docs / Build VitePress site (push) Has been cancelled
Deploy docs / Deploy to GitHub Pages (push) Has been cancelled
光湖开源源码快照 · Tolaria AGPL 分叉基线 · 独立更新链
2026-07-05 17:45:16 +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