Read AGENTS.md first — it covers architecture, commands, conventions, and file structure.
- This is an npm workspaces monorepo. Always build in order:
npm run buildhandles this (protocol -> client -> directory). - Run tests per-package with
cd <package> && npx vitest run. Directory tests use pg-mem, no database needed. - Lint with
npm run lint, format withnpm run format. CI enforces both. - Protocol version:
REEF_VERSION("0.2.1") andA2A_PROTOCOL_VERSION("0.3.0") inprotocol/src/types.ts. Never hardcode — import from@reef-protocol/protocol. - A2A types are re-exported from
@a2a-js/sdkthroughprotocol/src/types.ts. UseAgentCard,Task,Message,Part, etc. - The transport layer is in
protocol/src/transport.ts:encodeA2AMessage(),decodeA2AMessage(),isA2ARequest(),isA2AResponse(). - Builder helpers in
protocol/src/builders.ts:textPart(),createMessage(),createSendMessageRequest(),buildReefAgentCard(),buildSkill(). - Registration uses
{ address, agentCard: AgentCard }format. The directory extracts flat fields (name, skill tags) from the AgentCard for search compat. - When editing directory models, remember they use init functions (
initAgentModel(sequelize)) called fromdb.ts, not top-levelModel.init(). - The
agent_cardcolumn in theagentstable is JSONB (nullable for migration compat). - XMTP addresses require
0x${string}type — useas \0x${string}`casts. Messages are sent viadm.sendText(), notdm.send()`. InMemoryTaskStoreis imported from@a2a-js/sdk/server. Task state is volatile (lost on restart).- Apps are markdown files at
~/.reef/apps/<appId>.md— YAML frontmatter for metadata, markdown body for rules. Parsed byapp-markdown.ts, managed byapp-store.ts. AppManifest.typeis a required enum:"p2p" | "coordinated".buildAppManifest()defaults to"p2p". Validated by Zod (z.enum(["p2p", "coordinated"])).- Well-known apps (e.g., tic-tac-toe) are auto-installed to
~/.reef/apps/on first daemon start.reef apps read <appId>prints rules for agents to reason about. - Every app interaction follows the
request→accept→ ... →terminallifecycle. Actions markedterminal: truein the manifest signal interaction completion. Agents send terminal actions with--terminalflag.formatAppActionForAgent()inclient/src/messages.tsprovides action-specific agent guidance. App markdowns SHOULD declarerequestandacceptas their first two actions, and mark their completion action withterminal: true. reef apps validate <appId|file>validates app markdown against the Zod schema.- Branch protection requires CI pass + 1 reviewer. Always work on feature branches.