aesop / chat
CLAUDE.md2 starsChanged 31 days agoMITView on GitHub
Purpose: the aesop chat verb, a zero-dependency terminal chat on the stdio TTY seam. It renders a frame per change, reads keys through node:readline, and streams backend replies chunk by chunk. The default backend is the stdio pipe runtime (stdio/pipe.mjs, raw passthrough: the turn text is the pipe's stdin and the reply is its stdout bytes); pipeSource yields each stdout write as it arrives. Repaints are line-relative (no full-screen clear). This package makes no network call. Node stdlib only, ESM…
In this repository21 other files it gives its agents.
- auth/CLAUDE.mdCLAUDE.md
- bin/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- daemons/CLAUDE.mdCLAUDE.md
- dash/CLAUDE.mdCLAUDE.md
- driver/CLAUDE.mdCLAUDE.md
- hooks/CLAUDE.mdCLAUDE.md
- mcp/CLAUDE.mdCLAUDE.md
- monitor/CLAUDE.mdCLAUDE.md
- scan/CLAUDE.mdCLAUDE.md
- skills/CLAUDE.mdCLAUDE.md
- state_store/CLAUDE.mdCLAUDE.md
- stdio/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- tools/CLAUDE.mdCLAUDE.md
- ui/CLAUDE.mdCLAUDE.md
- buildsystemSkill
- dashboardSkill
- fleetSkill
- healthcheckSkill
- powerSkill
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Never import ui/ (the web dashboard).
- Very specific: line 55
Every rendered line fits within columns as measured with ANSI stripped.
≈ “Common” is an estimate: at least 1 in 5 of the 27,641 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
chat/ — Interactive chat TUI
Purpose: the aesop chat verb, a zero-dependency terminal chat on the stdio TTY seam. It renders a frame per change, reads keys through node:readline, and streams backend replies chunk by chunk. The default backend is the stdio pipe runtime (stdio/pipe.mjs, raw passthrough: the turn text is the pipe's stdin and the reply is its stdout bytes); pipeSource yields each stdout write as it arrives. Repaints are line-relative (no full-screen clear). This package makes no network call.
Keys
- Enter submits the buffer.
- Paste is bracketed paste (ESC[200~ ... ESC[201~): a pasted multi-line block keeps its newlines and stays one buffer until a plain Enter after the paste submits it. No Shift key is needed.
- A trailing backslash then Enter continues the line onto a new line.
- A backslash that is not the last character is literal text.
- ctrl-c once shows a hint; ctrl-c twice exits.
- ctrl-d on an empty line exits; on a non-empty line it deletes the character under the cursor.
- TAB expands to the next 8-column tab stop, counted from the screen column after the
>prefix (the buffer column restarts after each newline). - Esc is not yet bound.
Paste lifecycle
- PASTE_ON (ESC[?2004h) is written once at start. PASTE_OFF (ESC[?2004l) is written exactly once, by whichever comes first: finish (
/exit, ctrl-c twice, ctrl-d on an empty line), a processexit, SIGTERM (exit 143), SIGHUP (exit 129) or an external SIGINT (exit 130; POSIX only, on win32 these handlers are not reached). Raw mode is restored in the same single restore. - A throw while handling a key is rendered as an error line; it ends nothing, writes no PASTE_OFF, and ctrl-d still exits.
Universal rules (every domain)
- Feature branch only, never main; every push gated by
python ~/scripts/secret_scan.py --stagedexit 0. - Tests never pollute cwd or global git config; temp dirs only.
- In worktrees use ABSOLUTE paths under the worktree for every write.
- Domain docs stay minimal-but-complete; update this file in the same PR as the code it describes.
Runtime
Node stdlib only, ESM .mjs. No package.json inside chat/. The TTY decision comes from stdio/tty.mjs (detectMode, isTTY) and is never re-derived here.
Contract
Files
chat/render.mjs— pure.renderFrame(state, {columns, rows, color, unicode})returns lines joined by\n;resolveColor({env, argv, isTTY})(NO_COLOR and--no-coloroff, FORCE_COLOR on);resolveUnicode({env, unicode})(first of LC_ALL, LC_CTYPE, LANG decides; UTF-8 on).chat/input.mjs— pure reducer.createInputState();applyKey(state, key)returns{state, effect}for readline-shaped keys;parseSlash(line)returns{command, arg?},{error}, ornull.chat/session.mjs—class Session({columns, rows, color, status, onFrame, source?}).submit(line, chunks?)returns a promise;resize(columns, rows)sets the size the next frame uses.stateholdstranscriptandstatus.pipeSource(line, {stdin?})is the default backend (the pipe runtime;stdininjects the pipe input and each stdout write streams out as it arrives). The session exports no echo backend; the test-onlyechoSourcelives intests/helpers/chat-echo-source.mjs.chat/cli.mjs—runChat({argv, stdin, stdout, stderr, env, source?})returns an exit code. Input history persists in the JSON-array file named by envAESOP_CHAT_HISTORY(loaded on start, appended on submit, capped at 500 lines); unset (or empty) defaults to~/.aesop/chat-history.json(os.homedir(); tests redirect HOME/USERPROFILE via tests/helpers/isolated-env.mjs, so the default never touches the real home).shouldEnterChat({interactive, args, env})is the bare-invocation seam: true only on a TTY with--chat-defaultorAESOP_DEFAULT=chat.bin/cli.jsdynamic-imports this file for both thechatverb and the bare case.
Slash commands: /help, /model <provider>/<model>, /auth, /clear, /exit, /quit.
Exit codes
0— help printed, or the interactive session ended (/exit,/quit, ctrl-c twice, or ctrl-d on an empty line).2— usage error, or stdin/stdout is not a terminal. In that case stdout stays empty and stderr gets exactly one line namingaesop pipe.143(SIGTERM),129(SIGHUP),130(SIGINT) — the signal exits; the terminal is restored first. The PASTE_OFF write is best-effort and never changes the exit code, even when it throws.
Wiring in bin/cli.js: aesop chat; bare aesop on a TTY enters chat when --chat-default or AESOP_DEFAULT=chat is set. A bare aesop on a non-TTY stays the pipe filter.
Invariants
- Zero dependencies: only
node:builtins and in-repo relative modules, enforced bytests/chat-zero-dependency.test.mjs. - Never import
ui/(the web dashboard). renderFrameis pure: no I/O and no clock reads. Elapsed time and the spinner tick come fromstate.status.- The input reducer is pure:
applyKeynever touches a stream. - True streaming: each backend chunk is rendered and emitted before the next chunk is awaited. This holds for injected sources and for the default
pipeSource. A buffered implementation failssession_first_chunk_is_framed_before_stream_ends. color: falseemits noESCbyte. ANSI escapes are hand-written constants, not a library.- Box-drawing characters appear only when
unicodeis true. ASCII (+ - |) is the fallback;TERM=dumband a non-UTF-8 locale (first of LC_ALL, LC_CTYPE, LANG) force it. - Every rendered line fits within
columnsas measured with ANSI stripped. Prefixes are clipped before text is wrapped. A frame never has more thanrowslines: the oldest transcript lines go first, then the banner, and the input line always stays. - The spinner glyph is drawn only on the streaming assistant line. A timer (100 ms, unref'd, cleared when the reply ends) drives
status.spinnerTickandstatus.elapsedMs, so both move during a backend stall. Each frame repaints in place: the cursor moves up over the lines the previous frame drew, then ESC[J clears to the end of the screen. No ESC[2J or ESC[H is ever written, so scrollback is kept.
How to test
node --test tests/chat-render.test.mjs tests/chat-input.test.mjs tests/chat-cli-wiring.test.mjs tests/chat-zero-dependency.test.mjs
node --test tests/chat-visual.test.mjs
node --test tests/stdio-cli-wiring.test.mjs tests/stdio-pipe.test.mjs tests/stdio-zero-dependency.test.mjsAnti-vacuity: a test is only accepted when breaking the production code in chat/ turns it red. The streaming mutant (buffer every chunk before emitting) is the reference check.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

