Overview/Architecture
A small engine, and data around it
Behaviour that must hold is Python. Behaviour that guides is data. That single split decides the module boundaries, the file formats and the test strategy.
Layers
Three layers, in one direction. Canonical source is written by a human. The engine reads it. Adapters render it outward.
Canonical source
Skills carry frontmatter for name, description,
allowed-tools, argument-hint,
depends-on and optional-depends-on. The body is
the procedure. Six of the thirteen roles also have a written contract in
agents/; a parametrised test checks each of those against
agents.py:REGISTRY and fails if they drift apart. Hook rules
are one JSON file per rule.
Everything else in the repository is generated or derived.
The engine
Fifteen modules in core/zyrompts/. No third-party imports,
so the same code runs inside a hook, in a CI job, or on an air-gapped
machine with only Python 3.9 or newer.
| Module | Responsibility | Invariant |
|---|---|---|
classify.py | intent, complexity, tier, injection signals | a code-changing request with no anchor is never DIRECT |
prompts.py | score, framework choice, rewrite | an explain request is not graded on success criteria |
policy.py | autonomy levels, hard denials, redaction | hard denials fire under YOLO |
hooks.py | rule loading, validation, priority merge | exit 0 on every path |
handlers.py | named handlers and matchers | string names only, never eval or importlib |
state.py | project state and event log | atomic write; schema downgrade refused |
workflow.py | phases, gates, bounded loops | a block records where to resume |
review.py | plan, spec and diff critique | a finding is reported only after refutation |
research.py | source tiering, confidence | confidence needs evidence, not vibes |
agents.py | roles, delegation, scheduling | no agent reviews its own output |
adapters.py | canonical to platform renderers | pure functions; no I/O except write |
evals.py | JSONL datasets, evaluators | one failing case does not stop the suite |
decorum.py | behaviour policy, plus a checker | claims without evidence are flagged |
telemetry.py | cost and duration accounting | priced by tier, not by product name |
cli.py | the command line | every capability scriptable without a model |
Hook dispatcher
The dispatcher loads every rule, validates it against the capability matrix, evaluates its criteria against the payload, and merges matching fragments by priority. Lower number runs first.
Handlers are named, not imported
A rule says "handler": "intake", and the dispatcher looks
the name up in a dictionary. There is no path-based import, no
getattr, no eval. A rule file stays data even
if an attacker controls it.
The dispatcher never fails loudly
Missing event, unparsable stdin, unknown rule, bad regex: each returns an empty result and exit 0. A hook that crashes blocks the user's prompt, which is worse than a hook that does nothing.
Bypass is a contract
* skips, # memorises, / is a
slash command, and harness machine events such as
<task-notification> and
<system-reminder> are silent. The handler layer
mirrors the engine's own check, so a handler-backed rule cannot diverge
from an action-backed one.
payload on stdin -> load rules for the event -> validate each against CAPABILITY_MATRIX -> evaluate criteria -> merge inject_context fragments by priority -> print one hookSpecificOutput object -> exit 0
Adapters
An adapter is a pure function from a list of skills to a mapping of
paths to contents. Writing is the only I/O. That makes the generated
trees byte-reproducible, and
scripts/generate-adapters.py --check turns drift into a CI
failure rather than a review comment.
| Canonical key | Claude Code | Gemini | Copilot | OpenCode |
|---|---|---|---|---|
name | as-is | zy-slug | zy-slug | omitted |
description | yes | yes | yes, with a use-when suffix | yes |
allowed-tools | yes | yes | dropped | as tools: |
argument-hint | yes | dropped | dropped | dropped |
depends-on | not emitted | not emitted | not emitted | not emitted |
depends-on is validated at build time for unknown names
and cycles, and used to order the Codex index. It is not emitted into
platform frontmatter because no platform reads it.
zyrompts classify works as a CLI step.
Lifecycle
Thirteen phases with a gate each, and four tiers that select a prefix. The tier is a floor, never a ceiling.
INTAKE -> CLARIFY -> RESEARCH -> SPECIFY -> PLAN -> CRITIQUE -> APPROVE
-> IMPLEMENT -> REVIEW -> FIX -> VERIFY -> ARCHIVE -> DONE
A blocked phase records resume_at, so the workflow stays
blocked until the gate is met instead of skipping forward. Two loops
are bounded: critique stops after 3 iterations and fix stops after 2,
both recorded in history when the cap is reached.
State
The state store writes .zyrompts/state/project.json
atomically: temporary file, flush, rename. It appends to an event log
in JSONL. The state file carries a schema version, and loading a newer
version raises rather than silently dropping fields the running code
does not understand.
The reason is narrow. A long agent run that loses its state has to re-derive every decision, and the second derivation will not match the first.
Data flow, end to end
- UserPromptSubmit fires. The dispatcher loads the intake rule, which calls the classifier and injects the tier, the intent and the first phase.
- The agent follows the named skill. Each skill's procedure is the contract, and its dependencies say what must exist first.
- Before every mutating tool, PreToolUse fires. The policy engine returns allow, ask or deny, with the rule that fired.
- On Stop, the completion check runs. A completion claim is checked against evidence in the transcript, and the missing proof is injected back.
- Archive writes the handoff. The state store records the decision so the next session starts from it.
Extending it
| Want to change | Where | Rebuild |
|---|---|---|
| a nudge's wording or trigger | hooks/rules/<Event>/*.json | no |
| a skill's procedure | skills/<name>/SKILL.md | adapters --write |
| a platform's output format | adapters.py renderer | adapters --write |
| a policy rule | policy.py tables | no |
| a lifecycle gate | workflow.py | no |
| an eval expectation | evals/datasets/*.jsonl | no |
Adding a platform means writing one renderer, one builder, and a test, then running the generator. The builder must be pure, because that is what makes the drift check meaningful.
Why no framework
The core is a few thousand lines of standard library. A dependency-free core is what makes the hooks safe to install, the evals fast enough to run on every commit, and the behavior reproducible on a machine with no network.
A framework would add an install step to a tool whose whole job is to run before the agent does. That trade is not worth it here.
Next: the security model
Every hard denial, the injection floor, and what is explicitly out of scope for a report.