Merge branch 't3/claude-chat-panel'

# Conflicts:
#	.agents/mind/gotchas.md
#	packages/core/src/protocol.ts
This commit is contained in:
Florian Schmidt
2026-11-16 10:23:05 +01:00
18 changed files with 600 additions and 15 deletions
+23 -9
View File
@@ -5,7 +5,7 @@ A notebook is a Markdown file: prose plus shell blocks. The shell is the primary
artifact — always shown literally, with parameter values filled in, copyable into
any terminal. ShellBook adds buttons around it: run on a host over SSH, check a
condition, download a produced file. Claude Code (the real CLI, subscription
login) runs in a built-in terminal and edits the notebooks.
login) runs behind chat or in a built-in terminal and edits the notebooks.
## 1. Goals
@@ -157,14 +157,28 @@ only, then removed.
## 6. AI: Claude Code
- The right panel is a real terminal (xterm.js ↔ node-pty) running `claude` in the
workspace, inside `tmux` so the session survives closed tabs and app restarts.
This is the genuine CLI with the user's own subscription login — no API key, no SDK.
- The workspace ships a `CLAUDE.md` describing this notebook format, so Claude writes
shell-first notebooks (literal commands, no wrapper code).
- Live reload (§5) makes Claude's edits appear immediately.
- Later option: `ANTHROPIC_BASE_URL` / token for a custom endpoint, set in the
panel's environment.
- The right panel offers chat and a real terminal. Both use the real `claude`
CLI with the user's own subscription login; no API key or embedded SDK.
- Chat runs one headless CLI process per turn (`-p`, stream-json stdin/stdout),
in the workspace, with explicit `--resume` of the CLI session ID. A dedicated,
authenticated same-origin `/api/chat` WebSocket streams text deltas, compact
tool summaries, completion metadata and safe errors. Disconnect/Stop/timeout
terminate the process; only one active turn per conversation is allowed.
- File tools are restricted to workspace working directories using CLI restricted
mode (Claude Code 2.1.248+). Available tools are Read, Glob, Grep, Edit, Write,
MultiEdit; Bash is added only by the off-by-default shell-command toggle. Web
and MCP tools are unavailable. Never use bypassPermissions.
- The data directory persists conversation titles (first message), session IDs
and timestamps, not messages or tool contents. The CLI keeps its own session
transcripts. Never send secrets in chat. History resumes CLI context; the web
view retains messages only for the lifetime of the mounted panel.
- The terminal (xterm.js and node-pty) uses tmux, so interactive sessions survive
closed tabs and app restarts. Missing CLI/login errors offer this panel with
instructions to run `claude`, then `/login`.
- The workspace ships a `CLAUDE.md` describing the notebook format. The chat
appends ShellBook context and the open notebook path to the system prompt.
Live reload (section 5) makes actual notebook edits appear immediately.
- Details, resource limits and verified CLI flags: `apps/server/src/chat/README.md`.
## 7. Security