Surface Inventory
The layered files and Built specs that shape agent behavior
Prompt surfaces exist to prevent private forks of the AI workflow. If every developer edits local guidance, the repository only looks harnessed. The actual agent behavior has drifted.
Harness splits prompt surfaces into two groups. A few files are managed by hi: inspectable in the repo, changed at the Harness source, and redistributed in a new Baseline. The prompts that describe the repository are owned by the project and written by the agent. The job of the split is to make context ownership explicit.
Surface Inventory
The core prompt-surface question is: where does this rule belong? Broad quality criteria belong high. Repo identity belongs at the root. Scoped skills and examples belong near the code. Project invariants belong in Codebase Rules. Durable non-obvious knowledge belongs in notes. Short-lived intent belongs in the current run.
| Surface | Artifact kind | Owns | Must not own |
|---|---|---|---|
Repo .agents/AGENTS.md | Copied verbatim from apps/cli/src/data/shared-agents.md | Shared quality criteria, engineering posture, validation habits, source inspection habits, and team operating taste. | Repo-specific app maps, package invariants, product requirements, or local business logic. |
Root AGENTS.md | Authored starter; then project-owned | Repo identity, app/package ownership, workflow routing, cross-surface contract rules, validation routing, and source-of-truth rules. | Detailed rules for one app, package, docs surface, framework-specific task, or root Primary skills here lists. |
Scoped AGENTS.md | Agent-written; project-owned | Local ownership rules, scoped skill activation, upstream examples to inspect, and one pointer to the Codebase Rule Registry. | Company-wide quality criteria or broad lifecycle workflow definitions. |
Codebase Rules in .agents/rules/ | Project-owned; no Registry Item writes them | One stable invariant per rule, with triggers, verification, and exceptions. | Workflow sequencing or one-off task notes. |
| Memory notes | Project-owned | Durable non-obvious gotchas, decisions, setup quirks, and hard-won debugging findings. | Session summaries, changelogs, obvious file maps, or material that belongs in specs, runbooks, or wiki pages. |
| Prompt specs and handoff | Built; re-rendered on every hi update | Instructions for the next agent run: which Packs and skills apply, which AGENTS.md each spec targets, and the ordered next steps. | Private local preferences or final product truth that belongs in the consumer repository. |
| Subagent manifest and agent files | manifest.mjs Authored; agent files Built | Specialist ownership, guidance files, and skills, rendered for every harness. | Hand edits in .claude/agents, .codex/agents, .cursor/agents, or .opencode/agents. |
| Hooks and required tools | Hooks Copied; tools recorded in settings requiredTools | Repeatable guardrails for the Baseline check, formatting, linting, and tool availability. | Explanations that belong in docs or rules that require human judgment. |
Artifact Kinds
.devpunks/installed.json, the Installed Record, lists every managed path with its artifact kind. The kind decides what hi update does with the path and whether the agent may edit it.
| Kind | hi update behavior | May the agent edit it? |
|---|---|---|
| Copied | Writes the Registry bytes. Skips identical content. Keeps a local edit unless --yes, and reports partial when the Baseline also changed the file. | No |
| Built | Re-renders from the template, the settings, and the Recorded Shape. Skips identical content. | No; change the inputs instead |
| Authored | Writes once when absent. Never compares or overwrites it, even with --yes. | Yes; the project owns it |
The root AGENTS.md starter, .agents/subagents/manifest.mjs, .codex/config.toml, and each <scope>/oxlint.local.ts are Authored. Scoped AGENTS.md files and their CLAUDE.md mirrors are not in the Installed Record at all; the agent writes them and hi never compares them.
Consumer-repo business logic stays in the consumer repo. The CLI distributes the Harness surfaces and the post-command contract, but it does not become the source of truth for a target product.
Setup Flow
hi init and hi update install the resolved Registry Items in a fixed order and write the Installed Record last:
The agent then writes the root and scoped AGENTS.md files from the prompt specs and the repository it is standing in. Root specs carry criteria and invariants for that step; they are not a hardcoded final root prompt.
That split keeps two things true:
- the CLI stays deterministic at detection, Pack resolution, and Baseline install time
- the written prompts are tailored to the current repo instead of copied as generic text
Harness Adapters
The Harness Adapters turn one Authored file, .agents/subagents/manifest.mjs, into specialist agent files for all four harnesses on every hi update:
.claude/agents/<name>.mdwithmodel: inheritand askillslist.codex/agents/<name>.tomlwithdeveloper_instructionsand one[[skills.config]]entry per skill.cursor/agents/<name>.mdand.opencode/agents/<name>.mdwithout a skills field
Each body inlines the agent's ownership, capability packs, boundaries, activation instructions, and the content of every guidanceFiles entry. An agent's skills are its skills list when present; otherwise they are the union of its packs from the manifest's capabilityPacks. The CLI loads the manifest from a data: URL, so it must stay self-contained, with no relative imports.
To change specialists, edit manifest.mjs (follow the Built guide .agents/subagents/manifest.prompt.md) and run hi update. Never edit the generated agent files; hi diff reports them as stale until the next update. The edit hook does not rebuild them.
Agent-Facing Authoring
The CLI deterministically resolves Packs, writes managed artifacts, and renders the handoff. It prints no handoff prompt: .devpunks/AGENT-SYSTEM-PROMPT.md is the prompt to give the next agent, and the $hi-cli operator skill owns the follow-through. Step 1 of .devpunks/AGENT-HANDOFF.md activates writing-for-agents, then rule-authoring, before the agent writes prompts, scoped guidance, or .agents/rules/. The skills govern the agent-authored prose; they do not run inside the CLI.
writing-for-agents keeps triggers and context pointers precise so an agent loads deeper instructions only when the relevant branch applies. The handoff is complete when hi diff shows no local-edit, conflict, or missing row.
Drift Signals
Prompt drift has three main causes:
- The Harness Baseline changes. Shared guidance, Packs, skills, hooks, or templates changed upstream.
hi checkreportsupdate-available, and a manualhi updateinstalls the new managed surface and re-renders the specs. - A managed file was edited by hand.
hi diffreports it aslocal-edit, or asconflictwhen the Baseline also changed it.hi updatekeeps the edit and reportskept;hi update --yesoverwrites it. Move a needed change into an Authored or project-owned file, or into the Harness source. - The repository shape changed. A new workspace makes a Built spec render differently, and
hi diffreportsshape-drift. Afterhi update, the agent reconciles theAGENTS.mdfiles with the new specs.
The fix is not a longer one-off prompt. Upstream changes flow through hi update. Project-owned prompts change in place, by the agent, from current specs and evidence.