|
| 1 | +# Research-first project bootstrap |
| 2 | + |
| 3 | +Agent instructions for this project. Read this before planning, designing, or building |
| 4 | +anything here. |
| 5 | + |
| 6 | +## How this project works: two phases, two roles |
| 7 | + |
| 8 | +**Phase 1 - research (this kit).** Close every blocking unknown with fetched primary |
| 9 | +sources, then pass the gate. The output is a briefing, not code: `research/DISCOVERY.md` |
| 10 | +(the contract), `research/EVIDENCE.md` (claims with cached pages behind them), and |
| 11 | +`research/BRIEF.md` (the handoff). Phase 1 never writes product code. |
| 12 | + |
| 13 | +**Phase 2 - build (someone else's job).** A builder - another agent, a different model, or |
| 14 | +a human - takes `research/BRIEF.md` plus `research/` and implements. They should not need |
| 15 | +to re-research anything: if they do, phase 1 was incomplete, and the fix is to collect the |
| 16 | +missing fact rather than to let the builder guess it. |
| 17 | + |
| 18 | +The gate is the handoff point. Before it passes, phase 2 does not start. |
| 19 | + |
| 20 | +## Two machines, two roles |
| 21 | + |
| 22 | +The role is machine config - `role: "collector" | "builder"` in |
| 23 | +`~/.agents/research-kit.config.json`, default `collector`; declare it with |
| 24 | +`node ~/.agents/research-kit/bin/install-hooks.mjs --role builder`. |
| 25 | + |
| 26 | +| | **collector** (the operator's PC) | **builder** (a sandbox, a CI box, a laptop) | |
| 27 | +|---|---|---| |
| 28 | +| holds | the Firecrawl key | no key, no Firecrawl egress | |
| 29 | +| runs | `decompose.mjs`, `research.mjs` | `handoff.mjs`, `preflight.mjs`, the build | |
| 30 | +| a missing key is | a **FAIL** | **informational** | |
| 31 | +| must | push `research/raw/` including its dotfiles | **not collect** - the collection CLIs refuse (exit 2) | |
| 32 | + |
| 33 | +**If you are on a builder machine and there is no brief: you do not collect.** A page |
| 34 | +fetched by hand is not evidence in this kit, and a builder that "re-collects" a missing |
| 35 | +page forges a corpus instead of reporting a gap. Name the missing fact instead. |
| 36 | + |
| 37 | +A builder's first command is: |
| 38 | + |
| 39 | +``` |
| 40 | +node ~/.agents/research-kit/bin/handoff.mjs |
| 41 | +``` |
| 42 | + |
| 43 | +The remedy depends on the cause, and the command says which: something that did not |
| 44 | +travel is the collector's to push (`git add -f research/raw/`, dotfiles included); |
| 45 | +a corpus that travelled whole and was rewritten on checkout here is fixed **here**, with |
| 46 | +`.gitattributes`, and costs no credits. |
| 47 | + |
| 48 | +## Starting in the wrong place: ask which project, do not hunt for it |
| 49 | + |
| 50 | +The project is the **current working directory**. The kit takes no project argument and |
| 51 | +never will. If the cwd is not the project the operator means - the kit's own repo, a |
| 52 | +parent folder, an unrelated checkout - **ask which project**, and wait. Do not search the |
| 53 | +filesystem, do not infer it from a name, do not look it up on a remote. Searching a |
| 54 | +person's disk to guess his intent reads directories nobody authorised, and the question |
| 55 | +it replaces takes one line. |
| 56 | + |
| 57 | +Signals: no `AGENTS.md`, no `research/` directory, or a `research/` corpus plainly about |
| 58 | +something else. An existing corpus about another topic is the signal doing its job. |
| 59 | + |
| 60 | +## Resuming after an interruption: resume, do not restart |
| 61 | + |
| 62 | +The gate is a pure function of repository state, so orient from disk before touching |
| 63 | +anything. `doctor.mjs` and preflight answer *where this project is*; the last commit |
| 64 | +report and `docs/ARCHITECTURE.md` say *what was happening and why*; `git status` answers |
| 65 | +what is unfinished, and its uncommitted changes are the interrupted task - partial and |
| 66 | +unverified, work in progress, never state to trust. The corpus is already collected and |
| 67 | +spent credits are not spent again. |
| 68 | + |
| 69 | +## Rule 1 - research first, then build |
| 70 | + |
| 71 | +The sequence is decompose -> contract -> collect -> gate -> brief. |
| 72 | + |
| 73 | +0. **Decompose** (collector machine): `node ~/.agents/research-kit/bin/decompose.mjs --topic "<topic>"` |
| 74 | + drafts `research/MAP.md` seeded with the universal checklist. The tool contains no |
| 75 | + judgment. Mark every row COVERED (citing U-## rows), DISMISSED (reason required), or |
| 76 | + GAP. |
| 77 | +1. **Write the intent** in `research/DISCOVERY.md` under `## Build intent`, and enumerate |
| 78 | + the blocking unknowns FROM the map. |
| 79 | +2. **Collect**: `node ~/.agents/research-kit/bin/research.mjs --plan research/plan.json`. Prefer the page |
| 80 | + that *owns* the fact over any write-up about it. |
| 81 | +3. **Rewrite** each auto-extracted `Finding` cell into a real claim, keeping the `Raw` |
| 82 | + cell pointing at the cached page. |
| 83 | +4. **Gate**: `node ~/.agents/research-kit/bin/preflight.mjs`. **Do not start building until it prints |
| 84 | + PASS.** Evidence must be *fetched*, not typed, and by a named transport. |
| 85 | +5. **Hand off**: write `research/BRIEF.md`. |
| 86 | + |
| 87 | +There are exactly three overrides - `git commit --no-verify`, a deliberate |
| 88 | +`research/GATE_OFF`, and a repository-local `core.hooksPath` - and all three are recorded |
| 89 | +in `research/overrides.log`. If you take one, say so in your reply. |
| 90 | + |
| 91 | +## Rule 2 - questions are for intent, never for facts |
| 92 | + |
| 93 | +At most **3** questions, once, up front, and only about things no document can answer. If |
| 94 | +a question's answer is in public documentation, it is a research task. **Never answer |
| 95 | +"insufficient info" and stop.** |
| 96 | + |
| 97 | +## Rule 3 - known unknowns are allowed, silence is not |
| 98 | + |
| 99 | +Mark a genuinely unreachable fact `KNOWN-UNKNOWN` and write the day-one verification step |
| 100 | +in the `Evidence` cell. An unlabeled gap is the failure mode this project exists to |
| 101 | +prevent. |
| 102 | + |
| 103 | +## Rule 4 - source quality |
| 104 | + |
| 105 | +`P` primary/official carries the design. `S` secondary is context. `L` lead-only is a |
| 106 | +hint, never proof. Never invent a citation. Flag contradictions instead of averaging them. |
| 107 | + |
| 108 | +## Rule 5 - cost discipline |
| 109 | + |
| 110 | +Every scrape spends credits. Plan the queries in `research/plan.json` first, reuse the |
| 111 | +cache (`--refresh-days`), and check the budget with `node ~/.agents/research-kit/bin/research.mjs --status`. |
| 112 | + |
| 113 | +## Rule 6 - secrets |
| 114 | + |
| 115 | +The key lives in the CLI config or the environment. Never write it into this repository. |
| 116 | + |
| 117 | +## The standing protocol |
| 118 | + |
| 119 | +Five rules for how work here is committed and recorded. Documentation, not enforcement: |
| 120 | +no check judges prose, because a gate that judges prose is a gate that will be wrong. |
| 121 | + |
| 122 | +1. **Architecture map current in the same commit.** A commit touching a declared code |
| 123 | + path (`research/kit.json`) stages `docs/ARCHITECTURE.md` with it. Enforced - and a |
| 124 | + prompt, not a proof: the gate checks the map was *staged*, not that it is *current*. |
| 125 | +2. **Commit report: five named parts** - what changed / why / what it touched / what you |
| 126 | + verified / what you got wrong and fixed. The got-wrong line is not optional; if |
| 127 | + nothing was gotten wrong it is written as "nothing to report". |
| 128 | +3. **An ADR for any choice with a rejected alternative**, dated, with the reason a future |
| 129 | + explorer would need to avoid re-suggesting it. |
| 130 | +4. **One commit per task - the revert test.** `git revert <sha>` undoes it alone. |
| 131 | +5. **A red suite stops work**, reported immediately and alone, **with the cwd recorded**. |
0 commit comments