Files
Florian Schmidt 4fe64ee110 docs: record UI-first rule and deploy/integration lessons
AGENTS.md gains the invariant that servers, credentials, notebooks, chat and setup are all doable from the web UI. Project mind records #7-#10 status and the pct exec, TUN, path-convention and watcher-timing gotchas.
2026-11-16 10:32:37 +01:00

2.4 KiB

ShellBook — Agent Rules

Project rules on top of the global rules. These win on conflict.

What this is

Self-hosted web app for notebook-style server runbooks: Markdown notebooks whose shell blocks are shown literally (params filled in, copyable) and can be run on hosts over SSH. Spec: docs/spec.md — read it before any design change.

Invariants

  • Everything is doable from the web UI: servers and their SSH passwords/keys, notebooks, chatting with Claude, setup and password. Files (hosts.yaml, Markdown, git) remain the storage format, never the only way in.

  • The displayed script is the executed script. Rendering and execution use the same substitution result; never build a second, hidden command string.

  • All shell quoting goes through packages/core shellQuote. No ad-hoc escaping anywhere.

  • Secrets (type: secret params) are passed as env vars only; never rendered, logged, stored in audit records or artifacts metadata.

  • Strict SSH host key checking. Unknown keys require explicit user confirmation (TOFU).

  • check steps must be side-effect free; only run steps change hosts.

  • Notebooks stay valid, readable Markdown in any renderer (Gitea/GitHub).

  • AI integration uses the real claude CLI with the user's own login: interactively in the terminal panel or headless (-p, stream-json) behind the chat panel. No embedding of subscription credentials, API-key requirement, or SDK-based chat.

Stack and layout

TypeScript, Node 22 LTS, pnpm workspaces. packages/core (pure, no I/O), apps/server (Fastify, ws, ssh2, node-pty), apps/web (Vite + React, CodeMirror, xterm.js), deploy/. Tests with Vitest; core changes need unit tests.

  • @shellbook/core is consumed as TypeScript source (exports: ./src/index.ts); the server bundles it for production, the web app via Vite.
  • Contracts: packages/core/src/types.ts (notebook model), protocol.ts (HTTP/WS API), and the function signatures in index.ts. Change them only deliberately and update all consumers in the same change.
  • Commands (pnpm via corepack or npx [email protected]): pnpm install, pnpm typecheck, pnpm test, pnpm dev. All three must pass before a commit.

Workflow

  • Issue-first: work items are Gitea issues on FinalFactory/ShellBook; reference them in commits.
  • Conventional commit subjects (feat(core): …, fix(server): …).
  • New dependencies must be well-known and justified in the PR/commit message.