pizza-bot
AGENTS.md428 starsChanged 58 days agoApache-2.0View on GitHub
Guidance for working in this repo. Start with README.md (layout + how to run) and docs/ARCHITECTURE.md (seams, event model, design decisions) — this file is the operational overlay, not a duplicate. A stateful agentic inbox running one runtime (DeepAgents/LangGraph). The runtime emits native @langchain/protocol ProtocolEvent frames via streamEvents(v3); every frontend consumes them through the @langchain/langgraph-sdk Client/ThreadStream/StreamController over HTTP/SSE. The seam is that protocol + SDK projection boundary; keep React coupling outside it. - packages/core is nearly pure — no node:*,…
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- pizza-bot-guideSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 148
When driving the protocol endpoints by hand, two contracts trip people up:
- Very specific: line 178
Don't restate the signature: If the comment just rephrases the name/type (/ Cache key for the cache.
- Distinctive: line 182
When you change behavior at a seam, update its comment — replace the stale note, don't append a "now X" correction beside it.
- Very specific: line 188
Don't add standalone design docs to docs/ for routine work — fold durable decisions into docs/ARCHITECTURE.md, README.md, or the relevant …
- Distinctive: line 194
Every agent-driven change MUST use a dedicated branch in an isolated worktree.
- Very specific: line 200
Create worktrees under the main checkout's repo-local .worktrees/<kebab-case-description> directory.
- Distinctive: line 220
After a PR is merged, clean up from the main checkout by removing the worktree before deleting its local branch:
- Very specific: line 229
If GitHub did not delete the remote head branch, remove it with git push origin --delete <type>/<kebab-case-description>.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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
AGENTS.md
Guidance for working in this repo. Start with README.md (layout + how to run) and docs/ARCHITECTURE.md (seams, event model, design decisions) — this file is the operational overlay, not a duplicate.
The one-line mental model
A stateful agentic inbox running one runtime (DeepAgents/LangGraph). The runtime
emits native
@langchain/protocol ProtocolEvent frames via streamEvents(v3); every
frontend consumes them through the @langchain/langgraph-sdk
Client/ThreadStream/StreamController over HTTP/SSE. The seam is that
protocol + SDK projection boundary; keep React coupling outside it.
Layering discipline (don't break these)
packages/coreis nearly pure — nonode:*, no DOM, nodeepagents/@langchain/langgraph, noai— but it MAY import@langchain/coremodel/agent types (BaseChatModel), because the app is coupled to LangGraph by design and the model seam is honestly typed, not laundered throughunknown. Core also owns the pure protocol/wire types (protocol-types.ts). The framework-agnostic message/thread-slice projection helpers live inapps/web/src/projection— the only consumer is the web app, so they sit beside it rather than in a shared package. The eslint layering rule enforces core's purity.packages/plugin-apiis the public, browser-safe plugin contract — nonode:*, LangChain, runtime, or UI imports.packages/plugin-sdkowns the Node-bound filesystem loader, materializers, MCP clients, and contribution registries. The eslint layering rule enforces plugin-api's purity.packages/runtime-langgraphis the ONLY production package that importsdeepagents— the graph engine. Thetests/langgraph-compatworkspace is a test-only exception because it pins DeepAgents' public exports. If the DeepAgents API churns, the runtime blast radius must stay one package. In production, two narrow, deliberate exceptions touch@langchain/langgraphWITHOUT the engine:packages/storageimports itsInMemoryStore(a checkpoint-store primitive, kept out of runtime-langgraph because it's Node-bound), andapps/api-serverimportsProtocolEventas a TYPE only (the wire event). The conformance workspace may import upstream types for tests. The eslint layering guards enforce the core/ui purity + frontend rules; thedeepagents"only" invariant is a convention, not lint-enforced.- The frontend (
apps/web) never imports a runtime or a model binding. It MAY import the transport SDK (@langchain/langgraph-sdk) — that's the wire — but never the runtime graph engine. - The api-server assembles the concrete runtime through
createPizzaBotAgent(packages/runtime-langgraph). Core knows only the minimal structuralAgentHandle(core/src/agent-run.ts) the concrete agent satisfies (state read/write; the streaming methodstreamProtocollives on the concreteLangGraphAgent, since itsProtocolEvents can't be named without a@langchain/langgraphimport). The runtime is stateful and checkpointer-backed.
Where things live (for the common asks)
- Runtime → protocol stream (LangGraph →
ProtocolEventframes):runtime-langgraph/src/stream-protocol.tsholdsstreamProtocolEvents+toLangGraphInput;index.ts'sLangGraphAgent.streamProtocol()is the thin driver over it and the only streaming path. Native v3 correlation is reassembled client-side by the SDKStreamController. The offline conformance guard istests/langgraph-compat/protocol-stream-conformance.test.ts. - The protocol/wire types:
packages/core/src/protocol-types.ts(NormalizedMessage,ThreadStateValues, HITL vocab,ErrorCode,RunStatus,PROTOCOL_VERSION, and wire schemas). - Runtime factory + agent handle:
runtime-langgraph'sindex.tsexportscreatePizzaBotAgent(systemPrompt, deps)returning aLangGraphAgent; the run data types + the structuralAgentHandleit satisfies live inpackages/core/src/agent-run.ts. - Server composition root (wires the runtime factory + storage + model):
apps/api-server(agent-host.tsis the assembly;index.tsserves it). The in-process run registry isProtocolRunManager(protocol-run-manager.ts— buffers frames per run, fans out to observers withsince-based replay, cancels viaAbortSignal); the SDK-facing wire isroutes-protocol.ts(4 Agent-Protocol endpoints:POST /threads/:id/commands,POST /threads/:id/runs/:run_id/cancel— what the SDK'sstop()calls —POST /threads/:id/stream/events,GET /threads/:id/state). - Message/thread projection (SDK projections → feed messages/cards): the
pure helpers in
apps/web/src/projection(messages.ts=messagesToUI/interrupt overlays/hydrate helpers,thread-slice.ts=ThreadSlice/StreamStatus). The web binds viaapps/web/src/protocol-stream-store.ts(a headless SDKStreamControllerper thread) behind the thinuse-thread-slice.tshook;components/ActivityRail.tsxrenders delegated work in the Activity panel. - Model providers:
packages/inference-providers(one adapter per provider undersrc/providers/, with flat files except for Bedrock's multi-file shim insrc/providers/bedrock/). - Agent definition:
packages/core/src/agent.ts(pizzaBotSystemPrompt+ the singlePIZZA_BOT_AGENTorchestrator). Capabilities come from skills underskills/<id>/SKILL.md, projected into delegatable subagents byresolveSkillSubagentsand seeded into run state bybuildSkillSeed/withSkillSeed(runtime-langgraph/src/index.ts).
Testing
npm testis the supported entrypoint — it runs the license-generator tests, thenturbo run test --concurrency=2; the cap is deliberate (uncapped, the parallel vitest+esbuild workers can exhaust file descriptors / memory and fail en masse). CI runs the same command.- For a tight iteration loop, run one workspace directly:
npx vitest run --dir packages/<pkg>(or--dir apps/web). - Typecheck a package with
npx tsc --noEmit -p <path>/tsconfig.json, or the whole graph withnpm run typecheck. Lint withnpm run lint(typescript-eslint flat config).
Windows: constraints the suite has to respect
npm test is green on Windows. Five platform differences shape how these tests
are written — keep them in mind when adding assertions or temp-dir cleanup:
- Two
realpaths that disagree.fs.realpathSyncis Node's JS implementation and preserves 8.3 short names, which is whatos.tmpdir()yields on CI (C:\Users\RUNNER~1\...);fs/promisesrealpathandrealpathSync.nativecall libuv and expand them. Never compare paths canonicalized by different ones — a containment check across the two silently fails on Windows only. - No POSIX mode bits. Windows
chmodonly toggles the read-only bit, so0o700/0o600assertions can never hold. Gate them onprocess.platform !== "win32"(seepackages/loggingfile-store.test.tsandpackages/storageapp-db.test.ts). - Symlinks need elevation.
symlink()throwsEPERMwithout Developer Mode, so symlink-behavior tests useit.skipIf(process.platform === "win32"). - CRLF checkouts.
core.autocrlfyields CRLF and the repo has no.gitattributes, so never assert an exact\nagainst on-disk repo content — match\r?\n. Production parsers already tolerate both (e.g.plugin-sdk/frontmatter.ts). - Deleting a directory races the OS. Windows keeps directory/file handles open
briefly after a child process exits, so
rmSyncin anafterAllthrowsEPERMeven though the owning process is gone. Always passmaxRetries/retryDelay(seeapps/desktop-shellsidecar.test.ts). This surfaces under full-suite load and usually not in an isolated run, so reproduce withnpm test.
npm install does not need MSVC — see CONTRIBUTING's setup note for how
allowScripts denies better-sqlite3's implicit node-gyp rebuild, which
would otherwise be both mandatory (node-gyp fails at configure without a
toolchain) and unused (prebuilt binaries ship for every platform). Electron 44
has no postinstall; index.js downloads the binary lazily on first launch.
Verify in the browser, not just tests
For frontend/runtime-seam work, passing unit tests are necessary but not
sufficient — tests inject fakes and have missed real cross-environment bugs.
Actually run it. Fastest loop for a runtime-side change: a small tsx script that
drives createPizzaBotAgent(systemPrompt, deps).then(a => a.streamProtocol(input, opts))
against live Bedrock and inspects the emitted ProtocolEvent frames (needs
AWS_REGION + Bedrock creds). For UI work,
launch the app per docs/RUNNING.md and drive it. Delete throwaway probe scripts
when done.
When driving the protocol endpoints by hand, two contracts trip people up:
POST /threads/:id/commandsexpects{id, method, params}(run.start,input.respond, …). A body that is not a JSON object returns400 invalid_argument; an unrecognized method returns422 unknown_command. The only empty204isrun.stop's acknowledgement, whether it stopped a run or found none.POST /threads/:id/stream/eventsfilters bychannels, and an empty/absent array silently matches no frames (frameMatchesFilter), which looks like a broken server. Name them explicitly:values,messages,updates,lifecycle,tools,tasks,input,custom.
apps/api-server needs PIZZA_ALLOWED_ORIGINS set to the web origin when Vite
runs on a non-default port, or every request fails 403 origin_not_allowed. Point
PIZZA_DATA_ROOT at a scratch directory so probing never touches real threads.
Comments
Comment to explain what the code cannot say about itself, nothing more. A comment
earns its place ONLY if it is one of: a non-obvious why, a workaround (name the
cause), a TODO/FIXME, an invariant lint/types don't enforce, or a
cross-environment gotcha. Default to no comment — clear names and types are the
first line of documentation.
- Never narrate history. No "was / now / no longer / used to / renamed / deleted in Pn / relocated from / survivor of". Git holds the past; the comment describes the present. This is a new project — there is no legacy to explain.
- No roadmap breadcrumbs in code. No
§x.y,Phase X,Pn,WSn, or codenames like "Option A". If a plan section anchors a real invariant, state the invariant in plain terms instead of pointing at the doc. - Don't restate the signature. If the comment just rephrases the name/type
(
/** Cache key for the cache. */), delete it. - One clause, not an essay. Say the single surprising thing; cut the setup. File headers: ≤3 lines — what the file is plus its one load-bearing seam fact.
- When you change behavior at a seam, update its comment — replace the stale note, don't append a "now X" correction beside it.
Conventions
- Match surrounding code (naming, idiom, structure).
- Don't add standalone design docs to
docs/for routine work — fold durable decisions intodocs/ARCHITECTURE.md,README.md, or the relevantpackages/*/README.md. Keep the maintained-doc set small.
Git workflow
Every agent-driven change MUST use a dedicated branch in an isolated worktree.
Make all edits in that worktree; keep the main checkout available for review.
Name branches <type>/<kebab-case-description> using an intent such as fix,
feat, refactor, docs, test, or chore. Branch names MUST describe the
change, not the implementation tool, agent, author, or worktree.
Create worktrees under the main checkout's repo-local
.worktrees/<kebab-case-description> directory. The worktree directory MUST
match the description portion of its branch name; omit the <type>/ prefix.
For example:
git worktree add .worktrees/skill-worker-bundled-files -b fix/skill-worker-bundled-files main.
A fresh worktree needs its own npm install before building or testing;
otherwise workspace imports can resolve against stale output from another
checkout. Run npm run build before starting any application entrypoint:
@pizza-bot/* imports resolve to their built dist/ output, while typecheck
and test build only their task dependencies. Keep the affected tests and
typecheck green, and run the full CI checks before opening a PR. Do not merge to
main or push a branch unless the repository owner asks.
On macOS, gh credentials may be stored in Keychain and unavailable to
sandboxed commands. If gh auth status or another gh command reports an
authentication failure in the sandbox, rerun that command outside the sandbox
before diagnosing an expired credential or requesting reauthentication. Do not
extract or repackage credentials as a workaround.
After a PR is merged, clean up from the main checkout by removing the worktree before deleting its local branch:
git worktree remove .worktrees/<kebab-case-description>
git branch -d <type>/<kebab-case-description>
git fetch --pruneIf GitHub did not delete the remote head branch, remove it with
git push origin --delete <type>/<kebab-case-description>. Use
git worktree prune only to clear stale metadata for worktree directories that
were already removed; it does not remove a valid worktree.
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.

