synapse-agent / web
AGENTS.md7 starsChanged 49 days agoApache-2.0View on GitHub
- A turn's change cards are the runtime's, not the browser's: runtime/workspace_changes.py snapshots the workspace before and after the turn (read-only git) and reports that turn's own per-file line counts, which the daemon persists as a changes transcript event and emits live as turn_changes at settlement. The console only paints them (transcriptRows/ChangesRow.tsx), so nothing here may recompute them from runtime.git.status -- that is the workspace's standing delta against HEAD, which counts every earlier turn again. - Undoing one file of…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 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 repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cua-driverSkill
- file-cleanupSkill
- game-controlSkill
- project-session-readerSkill
- session-cache-analysisSkill
- session-crash-repairSkill
The file
We split this AGENTS.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 31
Keep browser APIs out of src/runtime-client/.
- Very specific: line 33
Update web/README.md when console-visible behavior changes (layout, shortcuts, panels, PWA surface) and docs/web-console/ when host/runtime …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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
- A turn's change cards are the runtime's, not the browser's:
runtime/workspace_changes.pysnapshots the workspace before and after the turn (read-only git) and reports that turn's own per-file line counts, which the daemon persists as achangestranscript event and emits live asturn_changesat settlement. The console only paints them (transcriptRows/ChangesRow.tsx), so nothing here may recompute them fromruntime.git.status-- that is the workspace's standing delta againstHEAD, which counts every earlier turn again. - Undoing one file of one turn is the runtime's write, not the browser's:
runtime.workspace.revertrestores that single path from the copyruntime/turn_reverts.pykept before the turn (under the workspace's own.synapse/turn-snapshots/), refuses while a turn is running or once the file has moved on, and never touchesHEAD, the index or any other file. The console only asks and repaints (ChangesRow.tsx->useConsoleStore.revertTurnChange), and it learns the reverted state from the history read (HistoryEvent.reverted_paths) or from its own successful call -- never by recomputing anything fromgit.status, and never by editing a projected transcript row.
Synapse Web Console — Collaboration Guide
Frontend conventions for web/. The repository-wide guide is the root AGENTS.md
(domain packages, Python/Rust, release process); this file only covers the browser
console. Note that the agent-md middleware (src/synapse/app/agent_md.py) injects
only a project-root AGENTS.md, so when working from the repository root this file
is a reference, not an automatically injected instruction block.
Architecture
web/is the React 19 + TypeScript + Vite console frontend for the runtime daemon. It builds toweb/dist/, which the Python wheel carries assynapse/web_console/static([tool.hatch.build.targets.wheel.force-include]inpyproject.toml) and the desktop sidecar embeds with--add-data; the host resolves--static-dirfirst, then that bundled copy, then<workspace>/web/dist(src/synapse/web_console/config.py). Host/runtime docs live indocs/web-console/; the user-facing layout description isweb/README.md.src/runtime-client/is the DOM-free protocol core: host coupling goes through an injectedSocketLike, and only the default implementation namesWebSocket.src/client/holds the browser-side host HTTP surface (bootstrap.tspairing/session,runtimeStatus.tsdiagnostics,deepLink.tslaunch params) plusexport *shims for modules that moved into the core (artifacts,artifactsDiff,recoverability,SynapseRuntimeClient,types) — new protocol code goes insrc/runtime-client/, and the shims stay so existing import paths keep resolving.- That boundary is machine-checked:
tsconfig.runtime-client.jsontype-checkssrc/runtime-clientwithlib: ["ES2023"], no DOM lib,strict, so a straywindow/document/WebSocketfails there instead of silently depending on the browser.tests/runtimeClientBoundary.test.tsguards the same boundary. src/runtime-client/contract.generated.tsis generated fromsrc/synapse/runtime/service/contract_registry.pybyscripts/export_contract_manifest.py(same source assrc/synapse/runtime/service/contract_manifest.json). Never hand-write wire DTOs;types.tsonly re-exports the generated shapes.- Components live in
src/components/. The bottom bar is a "static manifest + item module" host: a new entry is onesrc/components/bottomBar/*Item.tsxmodule plus one line insrc/components/bottomBar/manifest.tsx. The host owns the shared rules (three-track grid, singleopenId, popover/modal ownership, narrow-screenkeep/compact/morepolicy) and is not edited per entry; keyboard entries come fromsrc/components/consoleShortcuts.ts. - The transcript is the same shape for rows: a row kind is one
src/components/transcriptRows/*.tsxmodule plus one line in that directory'sregistry.tsx(aRecord<TranscriptMessage['type'], RowRenderer>), and how it folds is one line insrc/stores/transcriptRowPolicy.ts.Transcript.tsxkeeps only the scroller, the virtualizer and the dispatcher, so no row kind is special-cased by position there. Guards read the row directory throughtests/helpers/transcriptSource.tsinstead of one component, and layout order that only a browser can measure (where a rule sits, how far apart two rows land) is pinned intests/transcriptFoldSpace.verify.ts. - Zustand stores live in
src/stores/. Entry-local lifecycles (e.g.codexUsage) stay out ofuseConsoleStore, and per-row view state (folding, measured heights) stays local so it cannot rebuild the transcript. - Speech input is three engines behind one capture path.
src/components/composer/sttEngine.ts(speechRoute) decides the route from the engine the runtime reports and the platform: the browser's own recognizer (useSpeechInput.ts, still the only module that names the Web Speech globals), the daemon's offline engine, or the desktop shell's hosted cloud engine.sttTransport.tsis the interface both streaming ends implement, souseLocalSpeechInput.tsnever learns which one it was handed and the chunk window follows the transport (a cloud engine is asked for 100–200 ms packets). The cloud end goes throughsrc/client/tauriStt.ts(stt_cloud_*IPC): the shell opens that socket because the vendor authenticates the handshake with headers a browser cannot set, and the API key stays on the shell's side, so this adds no credential path here. A cloud engine in a plain browser falls back to the browser recognizer and says so — it must never look idle. src/markdown/is the render pipeline (parse, highlight, mermaid, tex, ansi, file paths, image refs).- There is no router: the only URL is the origin (
/runtime-wsis derived from it), and?action=new-sessionis the single shortcut action. - Layout is a two-column shell in
src/App.tsx; shared geometry lives insrc/index.css(.console-gutter,.console-column,.no-scrollbar). The invariants are described in prose inweb/README.mdand pinned by static guards. get_runtime_config.pyandget_transcript.pyare dev-only debug helpers; run them from the repository root withuv run --no-sync python web/get_runtime_config.py.
Coding standards
- TypeScript + React only. oxlint is the only automated baseline (
npm run lint);react/rules-of-hooksis an error. There is no formatter config — match the surrounding file (2-space indent;src/**uses semicolons and relative imports carry the.ts/.tsxextension). - The console holds no credential path: no token file, no
Authorizationheader, no credential in a URL or in the socket URL, no credential in browser storage, no pairing code from the environment.tests/sourceGuard.test.tsasserts this statically oversrc/**+vite.config.ts; the only browser-storage exemptions are the non-secrettranscriptCacheandappearancestores. - Vite is development-only: hot reload plus a controlled proxy for
/apiand/runtime-ws. The proxy targets only a loopback console host, rewritesOrigin, never injects credentials, and keepsserver.hoston loopback. Do not add business logic or an auth bypass there. - Keep browser APIs out of
src/runtime-client/; DOM access belongs to components and stores. - Comment the why — invariants, state transitions, and layout constraints — as the existing modules do; a guard test usually pins the same rule.
- Update
web/README.mdwhen console-visible behavior changes (layout, shortcuts, panels, PWA surface) anddocs/web-console/when host/runtime behavior changes.
Development & testing
Node >= 22.18 (CI pins 24) strips TypeScript natively, so node --test runs the .ts sources with no transpiler step.
cd web
npm ci
npm run lint # oxlint (local only; CI runs ruff, not oxlint)
npx tsc -b # type-check all three tsconfig projects
npm test # node --test "tests/*.test.ts"
npm run build # tsc -b && vite build -> dist/Verification order: narrowest test file → related guards → full npm test.
cd web
node --test tests/bottomBarContract.test.ts
node --test tests/transcriptLabels.test.ts tests/transcriptLayoutGuard.test.ts*.test.ts are the fast regression net. The *Guard.test.ts / sourceGuard.test.ts / *LayoutGuard files pin source-level contracts (geometry, regions, ordering, forbidden APIs) — change them deliberately, not incidentally. CI's contract job only type-checks and runs runtimeContractFixture / runtimeClientBoundary / sourceGuard, so run the files related to your change locally.
*.verify.ts are real-browser acceptance scripts. They are not matched by npm test; run them explicitly:
cd web
$env:NODE_OPTIONS=''; $env:NODE_USE_ENV_PROXY=''
node --test tests/shellLayout.verify.tsThey launch headless Chrome/Edge through tests/helpers/cdp.ts (SYNAPSE_CDP_BROWSER overrides the executable) and each brings up what it needs — its own synapse-web-console host or a fixture server. Use them when a change alters rendered geometry, focus/keyboard behavior, or virtualized scrolling: a green static guard does not prove a flex chain still stretches.
| Change area | Preferred tests |
| composer (input, mentions, images) | tests/composerSerialization.test.ts, composerMentions.test.ts, composerKeyboardGuard.test.ts, composerAttachmentGuard.test.ts, attachmentViewGuard.test.ts, attachmentErrors.test.ts, composerEditing.verify.ts |
| bottom bar / shortcuts | tests/bottomBarContract.test.ts, bottomBarLayout.test.ts, bottomBarDismiss.test.ts, bottomBarInteraction.verify.ts, bottomBarMore.verify.ts |
| shell / top bar / transcript layout | tests/shellLayout.test.ts, topBarLayout.test.ts, transcriptLayoutGuard.test.ts, transcriptScrollGuard.test.ts, plus the matching .verify.ts |
| sidebar session actions (rename / delete confirmation) | tests/sessionManagement.test.ts, tests/sessionDeleteDialog.test.ts, tests/dialogKeyboardNav.verify.ts |
| transcript view model | tests/historyMapper.test.ts, liveEventReducer.test.ts, liveDeltaBatch.test.ts, transcriptLabels.test.ts, transcriptVirtualization.test.ts |
| markdown / math / mermaid / images | tests/markdownParser.test.ts, markdownRenderGuard.test.ts, markdownTableGuard.test.ts, mathBlocks.test.ts, mathRender.test.ts, mermaidPolicy.test.ts, imageRefs.test.ts |
| runtime client / wire contract | tests/runtimeContractFixture.test.ts, runtimeClientBoundary.test.ts, runtimeClientReconcile.test.ts, runtimeClientRecovery.test.ts, sourceGuard.test.ts |
| stores / views | the tests/<name>.test.ts matching the store (goalView, mcpRuntimeView, usageView, todoView, sessionList, appearance, ...) |
| PWA / window controls overlay | tests/pwaManifest.test.ts, tests/windowControlsOverlay.test.ts |
Contract changes (wire types, versions, capability lists) go through the generator first:
# from the repository root
uv run --no-sync python scripts/export_contract_manifest.py # regenerate both artifacts
uv run --no-sync python scripts/export_contract_manifest.py --check # fail on drift
# then from web/
npx tsc -b
node --test tests/runtimeContractFixture.test.ts tests/runtimeClientBoundary.test.ts tests/sourceGuard.test.tsThe cross-language fixtures live in tests/fixtures/runtime_contract/ and are consumed by both the Python and the TypeScript side.
PWA icons under public/ are committed and have no generation script; after regenerating them run npm test — tests/pwaManifest.test.ts reads the real PNG headers and fails on a wrong size or a non-root-path reference.
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.

