44 lines
2.2 KiB
Markdown
44 lines
2.2 KiB
Markdown
# 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
|
|
|
|
- **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.
|