flanders 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # Flanders
2
+
3
+ Hi-diddly-ho, neighbor! Flanders is a Node.js toolkit that helps you author contracts, derive work plans from them, and implement those plans through a mix of plain code and AI orchestration. It reaches you through two surfaces — a CLI invoked as `npx flanders <command>`, and three AI-tool skills invoked from inside an AI-coding-tool session.
4
+
5
+ ## Contents
6
+
7
+ - [How it works](#how-it-works)
8
+ - [Requirements](#requirements)
9
+ - [Installation](#installation)
10
+ - [Updating](#updating)
11
+ - [Configuration](#configuration)
12
+ - [Usage](#usage)
13
+ - [A worked example](#a-worked-example)
14
+
15
+ ## How it works
16
+
17
+ Flanders speaks to you through two surfaces. The **CLI** — invoked as `npx flanders <command>` — carries three commands: `install`, which sets Flanders up in your project or your home directory; `update`, which refreshes the already-installed skills in place; and `implement [plan]`, which builds a plan from start to finish. The three **AI-tool skills** — `/flanders-spec`, `/flanders-plan`, and `/flanders-work` — are invoked from right inside an AI-coding-tool session.
18
+
19
+ Underneath, Flanders keeps a tidy little spec corpus alongside your code, and everything flows from it:
20
+
21
+ - **`.spec/contracts`** holds the public obligations a scope exposes — the promises its surface makes to the outside world.
22
+ - **`.spec/rules`** holds the internal conventions its code follows — the house rules it keeps for itself.
23
+ - **`.spec/flanders`** holds behavior rules — the obligations that govern how Flanders' own commands and skills behave while they work in your project.
24
+
25
+ Ordered work plans then live under **`plans/`**: each plan is a sequence of tasks derived from the contracts and rules, ready to be built one at a time.
26
+
27
+ The whole neighborly cycle runs **spec → plan → implement**:
28
+
29
+ 1. Capture obligations and conventions as contracts, rules, and behavior rules in the spec corpus (with `/flanders-spec`).
30
+ 2. Derive an ordered work plan from them under `plans/` (with `/flanders-plan`).
31
+ 3. Implement the plan task by task, gating each result through build, test, and adversarial review (with `npx flanders implement`).
32
+
33
+ For a small, self-contained change that doesn't need a whole plan, there's a friendly shortcut: **`/flanders-work`** implements the request directly and gates it through the same build, test, and adversarial review, all in one invocation.
34
+
35
+ ## Requirements
36
+
37
+ A few neighborly things to have on hand before you start:
38
+
39
+ - **Node.js** — the CLI is run with `npx`.
40
+ - **A git repository** — the `implement` command requires the project to be a git repository.
41
+ - **A supported AI coding tool** — currently Claude Code or Codex CLI.
42
+
43
+ ## Installation
44
+
45
+ Setting Flanders up is a breeze, neighbor — just run:
46
+
47
+ ```sh
48
+ npx flanders install
49
+ ```
50
+
51
+ This is how Flanders first sets up on disk: it is the only command that writes the persistent `.flanders/` configuration that `implement` reads, and the way you publish the skills to a fresh scope. Once the skills are in place, `npx flanders update` refreshes them where they already live (see [Updating](#updating)).
52
+
53
+ ### Scope
54
+
55
+ Flanders installs at one of two scopes, chosen with a pair of mutually exclusive flags:
56
+
57
+ - `--project` — the scope is the current working directory. Skills go into the project's AI-tool skill folders, and the `.flanders/` configuration is written at the project root.
58
+ - `--global` — the scope is your home directory. Skills go into the user-level AI-tool skill folders, and the `.flanders/` configuration is written at your home directory.
59
+
60
+ Passing both at once is a usage error. When you supply neither, the command kindly prompts you to pick one.
61
+
62
+ ### What it writes
63
+
64
+ For each AI tool you select for skills, `install` writes one skill artifact per Flanders skill (`/flanders-spec`, `/flanders-plan`, and `/flanders-work`) into that tool's skill folder for the chosen scope:
65
+
66
+ | Tool | Project scope | Global scope |
67
+ | --- | --- | --- |
68
+ | Claude Code | `.claude/skills/` | `~/.claude/skills/` |
69
+ | Codex CLI | `.codex/prompts/` | `~/.codex/prompts/` |
70
+
71
+ Select `both` and the artifacts are written for both tools, each into its own folder. Alongside the skills, the command writes the `.flanders/` configuration at the chosen scope (see [Configuration](#configuration)).
72
+
73
+ ### Interactive prompts
74
+
75
+ Run it without flags and Flanders walks you through the setup, asking in this order:
76
+
77
+ 1. **Skills tool** — `claude`, `codex`, or `both`.
78
+ 2. **Scope** — `--project` or `--global`, each option labelled with the concrete destination path(s) for the skills tool you picked.
79
+ 3. **Worker tool, model, and effort** — the AI the `implement` command's worker uses.
80
+ 4. **Reviewer configuration** — an ordered list of one or more adversarial reviewers, each with its own tool, model, and effort.
81
+ 5. **Weighted-review configuration** — when two or more reviewers are configured, the minimum number of reviewers that must run to a verdict, and which reviewers are optional.
82
+
83
+ Any question whose answer you supply by flag is not prompted again.
84
+
85
+ And if a `.flanders/` configuration already lives at the scope you choose, neighbor, `install` reads it the moment you pick that scope and pre-selects your stored answers as the question defaults — the worker's tool, model, and effort; the reviewer list, including how many reviewers there are and, for each one, its tool, model, effort, and whether it's optional; and the minimum number of reviewers that must run. Press Enter straight through and, but for one edge case, you reproduce your saved configuration just as it was. That edge case is a stored Codex model the probe no longer offers: with it no longer on the menu, that one question is shown with no pre-selected default and you answer it afresh. The skills tool and the scope aren't kept in that file, so they're always asked fresh too, and any flag you pass still wins over a pre-selected default. When no configuration lives at that scope yet — or the file can't be read — Flanders gently falls back to its fresh-install defaults and pre-selects nothing.
86
+
87
+ ### Flags
88
+
89
+ Every question has an equivalent command-line flag, so the whole setup can run without a single prompt:
90
+
91
+ **Scope** (mutually exclusive)
92
+
93
+ - `--project` — install into the current working directory.
94
+ - `--global` — install into your home directory.
95
+
96
+ **Skills and worker**
97
+
98
+ - `--skills-tool=<claude|codex|both>` — which AI tool(s) the skills are installed for.
99
+ - `--worker-tool=<claude|codex>` — which AI tool the `implement` worker uses.
100
+ - `--worker-model=<value>` — model the worker tool invokes; an empty value means "use the tool's default configured model".
101
+ - `--worker-effort=<value>` — reasoning effort the worker tool invokes; an empty value means "use the tool's default configured effort".
102
+
103
+ **Reviewers** — an ordered list, where reviewer 1 uses the unindexed names and reviewer `N` (2 or greater) carries the index:
104
+
105
+ - `--reviewer-tool=<claude|codex>` / `--reviewer-N-tool=<claude|codex>`
106
+ - `--reviewer-model=<value>` / `--reviewer-N-model=<value>`
107
+ - `--reviewer-effort=<value>` / `--reviewer-N-effort=<value>`
108
+
109
+ The reviewer indices must form a contiguous run starting at reviewer 1. Supplying any reviewer flag fixes the reviewer list to those indices and skips the "configure another reviewer?" prompt.
110
+
111
+ **Weighted review** — only meaningful with two or more reviewers:
112
+
113
+ - `--reviewer-optional` / `--reviewer-N-optional` — a presence flag that marks that reviewer optional; a reviewer with no such flag is required.
114
+ - `--reviewer-minimum=<value>` — the minimum number of reviewers that must run to a verdict each round, an integer between `1` and the number of configured reviewers.
115
+
116
+ A tool flag, or the `codex` effort flag, rejects a value outside its accepted set; model flags and the `claude` effort flag accept any value verbatim. Supplying a weighted-review flag with a single reviewer — or a `--reviewer-minimum` equal to the reviewer count together with any optional flag — is a usage error.
117
+
118
+ ### Overwriting and output
119
+
120
+ Existing files at the destination — both skill artifacts and `.flanders/` configuration files — are overwritten silently, with no backup and no prompt, so preserving prior versions is up to your own version control. On success, the command prints the full list of files it wrote, one path per line.
121
+
122
+ ## Updating
123
+
124
+ Already set up and itching for the freshest skills, neighbor? Just run:
125
+
126
+ ```sh
127
+ npx flanders update
128
+ ```
129
+
130
+ `update` takes no flags. It scans the four skill destinations `install` writes to — Claude Code and Codex CLI, each at project and global scope — and wherever it finds at least one Flanders skill artifact already in place, it rewrites the full `/flanders-spec`, `/flanders-plan`, and `/flanders-work` trio there with the current version. A destination where no Flanders skill artifact is present is left untouched, so `update` refreshes the installations you already have and never creates one where you had none.
131
+
132
+ It is entirely hands-off: `update` asks you nothing, and it never reads or writes your `.flanders/` configuration — the worker and reviewer answers a previous `install` saved carry over exactly as they were. Existing skill files are overwritten silently, the same way `install` overwrites them. On success it prints every file it wrote, one path per line.
133
+
134
+ If no Flanders skills are installed at any scope or tool, `update` has nothing to refresh: it exits with an error that points you to `npx flanders install` to set one up first.
135
+
136
+ ## Configuration
137
+
138
+ The `install` command tucks your answers into a `.flanders/` folder so the command that consumes them — `implement` — knows just how you like things done. (`update` leaves this configuration untouched; it only refreshes the skills.) Where that folder lives depends on the scope you chose:
139
+
140
+ - **Project scope** — `.flanders/` at the project root.
141
+ - **Global scope** — `~/.flanders/` in your home directory.
142
+
143
+ It persists exactly the answers downstream commands need at run time:
144
+
145
+ - The **worker** the `implement` command uses: its tool (`claude` or `codex`), its model, and its reasoning effort.
146
+ - The **ordered list of adversarial reviewers**, in the order you configured them. Each reviewer carries its own tool (`claude` or `codex`), model, and effort, plus whether it is optional.
147
+ - The **minimum number of reviewers** that must run to a verdict in each review round.
148
+
149
+ For any model or effort you leave unset — the worker's or a reviewer's — Flanders doesn't record a concrete value; instead it persists the explicit marker `default configured model` or `default configured effort`, which tells the tool to fall back to its own default at run time.
150
+
151
+ The skills-tool answer is used by `install` itself to decide which folders to write into, so it isn't persisted here.
152
+
153
+ ### Which configuration wins
154
+
155
+ When a command reads the configuration, a project-scope `.flanders/` always takes precedence over a global one — and it's all or nothing, with no field-by-field merge between the two. So a project `.flanders/` is used in full when it's present; otherwise the global `~/.flanders/` is used.
156
+
157
+ ## Usage
158
+
159
+ With Flanders installed, here's how to put it to work — running plans from the CLI and shaping them with the three skills.
160
+
161
+ ### Implementing a plan
162
+
163
+ ```sh
164
+ npx flanders implement [plan]
165
+ ```
166
+
167
+ `implement` takes a plan from your `plans/` folder and carries it through from start to finish. Leave `[plan]` off and Flanders runs the single plan in `plans/` for you automatically; when there's more than one, it lists them and asks you to re-run naming the one to implement. From there it works through each open task with the worker AI, gating every result through build, test, and adversarial review before marking that task complete in the plan — and it commits once per accepted task, so each step lands as its own neat little commit. The whole run is non-interactive: once started, it never stops to ask you anything, and it caps each task at five attempts before halting. The project must be a git repository: `implement` needs git and has no flag to turn it off.
168
+
169
+ ### The three skills
170
+
171
+ The skills become available after a successful `npx flanders install` run, and each is invoked from inside your AI-coding-tool session. Each one shapes a different part of the spec → plan → implement cycle:
172
+
173
+ - **`/flanders-spec`** — turns a free-form request into your contracts, rules, and behavior rules, written into the `.spec/contracts`, `.spec/rules`, and `.spec/flanders` folders.
174
+ - **`/flanders-plan`** — derives a single, ordered, contract-aware work plan under `plans/` from your request.
175
+ - **`/flanders-work`** — implements a small, self-contained request directly and gates it through build, test, and a single adversarial review, all in one invocation — no plan file and no commit.
176
+
177
+ Each skill takes the same optional `<data>` argument:
178
+
179
+ ```
180
+ /flanders-spec [<data>]
181
+ /flanders-plan [<data>]
182
+ /flanders-work [<data>]
183
+ ```
184
+
185
+ - Omit it, and the skill takes your request straight from the conversation.
186
+ - Give it a path to an existing file, and the skill reads that file as the input.
187
+ - Give it any other text, and the skill uses that text verbatim.
188
+
189
+ ### A typical workflow
190
+
191
+ Here's the neighborly path from a blank slate to shipped code:
192
+
193
+ 1. **`npx flanders install`** — set Flanders up and deliver the skills.
194
+ 2. **`/flanders-spec`** — capture your obligations and conventions as contracts, rules, and behavior rules.
195
+ 3. **`/flanders-plan`** — derive an ordered work plan from them under `plans/`.
196
+ 4. **`npx flanders implement`** — build the plan task by task, each result gated through build, test, and review.
197
+
198
+ And when a change is small enough that a whole plan would be overkill, **`/flanders-work`** is your shortcut — it carries that one request from request to reviewed finish without a plan or a commit.
199
+
200
+ ## A worked example
201
+
202
+ Let's build a tiny web calculator that only multiplies and subtracts, neighbor — start to finish, the whole spec → plan → implement stroll.
203
+
204
+ 1. **Set Flanders up** in your project and deliver the skills:
205
+
206
+ ```sh
207
+ npx flanders install
208
+ ```
209
+
210
+ 2. **Capture the spec** with `/flanders-spec`. You describe what you want; the skill sorts each obligation into the right folder — public behavior into `.spec/contracts`, internal conventions into `.spec/rules`:
211
+
212
+ ```
213
+ /flanders-spec A web calculator with exactly two operations — multiply and
214
+ subtract — over two number inputs, showing the result. The operation buttons
215
+ are teal, the result panel is white, and the page background is slate. Build
216
+ the UI with React bundled by Vite, and use no other UI framework.
217
+ ```
218
+
219
+ From that one request it writes, for example:
220
+
221
+ - a **functionality contract** under `.spec/contracts/` — the calculator offers exactly two operations, multiply and subtract, over two numeric inputs, and shows the result;
222
+ - a **colors contract** under `.spec/contracts/` — the operation buttons are teal, the result panel white, and the background slate;
223
+ - a **frameworks rule** under `.spec/rules/` — the UI is built with React bundled by Vite, and no other UI framework is introduced.
224
+
225
+ The skill shows you the planned layout first and writes the files once you approve.
226
+
227
+ 3. **Derive the plan** with `/flanders-plan` — one ordered, contract-aware plan under `plans/`, each task linked back to the contracts and rules it satisfies:
228
+
229
+ ```
230
+ /flanders-plan
231
+ ```
232
+
233
+ 4. **Build it** with `implement` — Flanders works each task with the worker AI, gates every result through build, test, and adversarial review, and lands one commit per accepted task:
234
+
235
+ ```sh
236
+ npx flanders implement
237
+ ```
238
+
239
+ When it finishes, the contracts are honored by code: a calculator that multiplies and subtracts and nothing else, in teal, white, and slate, built on the framework your rule pinned.
240
+
241
+ 5. **Tweak it later** with the shortcut — a small change that doesn't need a whole plan:
242
+
243
+ ```
244
+ /flanders-work make the result panel use a larger font
245
+ ```
package/lib/Flanders.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { ImplementContexts } from "./commands/Implement";
2
2
  import { InstallContexts } from "./commands/Install";
3
+ import { UpdateContexts } from "./commands/Update";
3
4
  import type { AskContext, OutputContext } from "./contexts";
4
- export type FlandersContexts = ImplementContexts & InstallContexts & Readonly<{
5
+ export type FlandersContexts = ImplementContexts & InstallContexts & UpdateContexts & Readonly<{
5
6
  output: OutputContext;
6
7
  ask: AskContext;
7
8
  }>;
package/lib/Flanders.js CHANGED
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Flanders = void 0;
4
4
  const Implement_1 = require("./commands/Implement");
5
5
  const Install_1 = require("./commands/Install");
6
+ const Update_1 = require("./commands/Update");
6
7
  const USAGE = `usage: flanders <command> [arguments...]
7
8
  install [--global | --project] install Claude Code skills
9
+ update refresh installed skills in place
8
10
  implement [plan] run the iterative implementation loop`;
9
11
  class Flanders {
10
12
  constructor(args, _options, _contexts) {
@@ -26,6 +28,11 @@ class Flanders {
26
28
  this._command = cmd;
27
29
  return await cmd.result();
28
30
  }
31
+ case "update": {
32
+ const cmd = new Update_1.Update(rest, { projectRoot: this._options.projectRoot }, this._contexts);
33
+ this._command = cmd;
34
+ return await cmd.result();
35
+ }
29
36
  case "implement": {
30
37
  const cmd = new Implement_1.Implement(rest, { projectRoot: this._options.projectRoot }, this._contexts);
31
38
  this._command = cmd;
package/lib/cli.js CHANGED
@@ -234,7 +234,8 @@ const ask = (() => {
234
234
  for (let i = 0; i < q.options.length; i++) {
235
235
  const o = q.options[i];
236
236
  const marker = pickedLabels.has(o.label) ? "*" : " ";
237
- out.write(` ${marker} ${i + 1}) ${o.label}${o.description ? ` — ${o.description}` : ""}\n`);
237
+ const isDefault = q.defaultIndex === i;
238
+ out.write(` ${marker} ${i + 1}) ${o.label}${o.description ? ` — ${o.description}` : ""}${isDefault ? " (default — press Enter)" : ""}\n`);
238
239
  }
239
240
  if (existing) {
240
241
  const labels = existing.picked.map(p => p.label).join(", ");
@@ -258,6 +259,9 @@ const ask = (() => {
258
259
  hints.push(q.multiSelect
259
260
  ? `[1-${q.options.length}, comma-separated; free-text OK]`
260
261
  : `[1-${q.options.length}; free-text OK]`);
262
+ if (q.defaultIndex !== undefined) {
263
+ hints.push("Enter for default");
264
+ }
261
265
  if (idx > 0) {
262
266
  hints.push("'-' back");
263
267
  }
@@ -288,6 +292,11 @@ const ask = (() => {
288
292
  }
289
293
  continue;
290
294
  }
295
+ if (raw === "" && q.defaultIndex !== undefined) {
296
+ answers[idx] = { picked: [q.options[q.defaultIndex]] };
297
+ idx++;
298
+ continue;
299
+ }
291
300
  const parsed = parseAnswer(raw, q.options.length, q.multiSelect);
292
301
  if (!parsed) {
293
302
  out.writeError("Invalid input. Pick a valid option number, type free-form text, or use '-' / '+' to navigate.\n");
@@ -55,10 +55,12 @@ export declare class Implement {
55
55
  private _gitOutputContext;
56
56
  private _runTask;
57
57
  private _workerStage;
58
- private _appendLinkedContent;
58
+ private _buildSpecContent;
59
59
  private _buildStage;
60
60
  private _testStage;
61
61
  private _setReviewerState;
62
+ private _setReviewerWaiting;
63
+ private _writeReviewerEntry;
62
64
  private _renderReviewingFooter;
63
65
  private _setReviewerLogicalStatus;
64
66
  private _evaluateReviewRoundCompletion;
@@ -13,6 +13,7 @@ const prompts_1 = require("../prompts/prompts");
13
13
  const ScriptRunner_1 = require("../system/ScriptRunner");
14
14
  const BottomBlock_1 = require("../ui/BottomBlock");
15
15
  const formatters_1 = require("../ui/formatters");
16
+ const voiceVariants_1 = require("../voiceVariants");
16
17
  const Workspace_1 = require("../workspace/Workspace");
17
18
  const MAX_ITER = 5;
18
19
  class LineBufferedBlock {
@@ -86,7 +87,7 @@ class Implement {
86
87
  write: text => this._contexts.output.write(text),
87
88
  columns: () => this._contexts.output.columns(),
88
89
  onResize: listener => this._contexts.output.onResize(listener)
89
- }, this._contexts.time);
90
+ }, this._contexts.time, this._contexts.random);
90
91
  this._block = block;
91
92
  block.mount();
92
93
  this._buffered = new LineBufferedBlock(block);
@@ -141,7 +142,7 @@ class Implement {
141
142
  if (initialParse.tasks.every(t => t.done)) {
142
143
  this._block.setHeader({ indexLabel: `${totalTasks}/${totalTasks}` });
143
144
  this._block.setMetrics({ plan: { tokens: planTotals.it + planTotals.ot, seconds: planTotals.t } });
144
- this._buffered.write("tasks completed\n");
145
+ this._buffered.write(`${(0, voiceVariants_1.pickVariant)(voiceVariants_1.tasksCompletedPool, this._contexts.random)}\n`);
145
146
  this._finalizeBlock("Done");
146
147
  return 0;
147
148
  }
@@ -193,7 +194,7 @@ class Implement {
193
194
  return 1;
194
195
  }
195
196
  }
196
- this._buffered.write("all tasks completed\n");
197
+ this._buffered.write(`${(0, voiceVariants_1.pickVariant)(voiceVariants_1.allTasksCompletedPool, this._contexts.random)}\n`);
197
198
  this._finalizeBlock("Done");
198
199
  return 0;
199
200
  }
@@ -371,7 +372,7 @@ class Implement {
371
372
  taskText = "(The full task text and the contracts and rules it references were provided when this session began and remain available to you through session continuity; they are not repeated here.)";
372
373
  }
373
374
  else {
374
- taskText = `(Your previous session for this task could not be resumed, so this is a fresh invocation. You are continuing work on the task at line ${task.line} of the plan file, titled "${task.title}". Re-read that task and the contracts and rules it references directly from the files on diskthey are not re-injected hereand address the previous-iteration briefing below.)`;
375
+ taskText = `(Your previous session for this task could not be resumed, so this is a fresh invocation. You are continuing work on the task at line ${task.line} of the plan file, titled "${task.title}". The task text and its referenced content are not re-injected here: re-read that task from the plan file, and for the contracts and rules it references reread the consolidated spec.md the orchestrator left in the temporary folder at ${ws.specFile} read that single file rather than reopening each referenced file then address the previous-iteration briefing below.)`;
375
376
  }
376
377
  let prompt = prompts_1.prompts.worker
377
378
  .split("<PLAN_PATH>").join(plan.path)
@@ -389,7 +390,8 @@ class Implement {
389
390
  }
390
391
  try {
391
392
  if (iteration === 1) {
392
- prompt = await this._appendLinkedContent(plan, task, prompt);
393
+ await this._contexts.fs.writeFile(ws.specFile, await this._buildSpecContent(plan, task));
394
+ prompt = `${prompt}\n\n${(0, prompts_1.linkedReferenceDirective)(ws.specFile)}`;
393
395
  }
394
396
  const { result, capturedOutput } = iteration === 1
395
397
  ? await this._runAi(this._config.worker.tool, this._config.worker.model, this._config.worker.effort, prompt)
@@ -411,19 +413,15 @@ class Implement {
411
413
  return false;
412
414
  }
413
415
  }
414
- async _appendLinkedContent(plan, task, prompt) {
415
- const linked = plan.linkedPaths(task);
416
- const allPaths = [...linked.contracts, ...linked.rules];
417
- if (allPaths.length === 0) {
418
- return prompt;
419
- }
420
- const sections = [];
421
- for (const relPath of allPaths) {
422
- const absPath = (0, fsUtils_1.joinPath)(this._options.projectRoot, relPath);
423
- const content = await this._contexts.fs.readFile(absPath);
424
- sections.push(`## ${relPath}\n\n${content}`);
416
+ async _buildSpecContent(plan, task) {
417
+ const references = plan.linkedReferences(task);
418
+ const fileContents = new Map();
419
+ for (const { path } of references) {
420
+ if (!fileContents.has(path)) {
421
+ fileContents.set(path, await this._contexts.fs.readFile((0, fsUtils_1.joinPath)(this._options.projectRoot, path)));
422
+ }
425
423
  }
426
- return `${prompt}\n\n## Linked reference content\n\nThe full content of every contract and rule this task references is included below, so you do not need to open these files for this iteration:\n\n${sections.join("\n\n")}`;
424
+ return (0, PlanFile_1.buildSpecFileContent)(references, fileContents);
427
425
  }
428
426
  async _buildStage(plan, taskLine, ws, iteration) {
429
427
  if (!(await (0, fsUtils_1.isNonEmptyFile)(this._contexts.fs, ws.buildScript))) {
@@ -460,12 +458,22 @@ class Implement {
460
458
  return true;
461
459
  }
462
460
  _setReviewerState(reviewerIdx, state) {
461
+ this._writeReviewerEntry(reviewerIdx, state, undefined);
462
+ }
463
+ _setReviewerWaiting(reviewerIdx, endTimeMs) {
464
+ this._writeReviewerEntry(reviewerIdx, "waiting", endTimeMs);
465
+ }
466
+ _writeReviewerEntry(reviewerIdx, state, endTime) {
463
467
  if (!this._reviewerStates)
464
468
  return;
465
469
  const entry = this._reviewerStates[reviewerIdx];
466
470
  if (!entry)
467
471
  return;
468
- this._reviewerStates[reviewerIdx] = { tool: entry.tool, model: entry.model, effort: entry.effort, state };
472
+ const next = { tool: entry.tool, model: entry.model, effort: entry.effort, state };
473
+ if (endTime !== undefined) {
474
+ next.endTime = endTime;
475
+ }
476
+ this._reviewerStates[reviewerIdx] = next;
469
477
  this._renderReviewingFooter();
470
478
  }
471
479
  _renderReviewingFooter() {
@@ -551,8 +559,9 @@ class Implement {
551
559
  .split("<CONTRACT_LIST>").join(this._formatPathList(this._contractList))
552
560
  .split("<RULE_LIST>").join(this._formatPathList(this._ruleList))
553
561
  .split("<BEHAVIOR_RULE_LIST>").join(this._formatPathList(this._behaviorRuleList))
554
- .split("<ERROR_LOG_PATH>").join(ws.reviewerErrorLog(reviewerNum));
555
- prompt = await this._appendLinkedContent(plan, task, prompt);
562
+ .split("<ERROR_LOG_PATH>").join(ws.reviewerErrorLog(reviewerNum))
563
+ .split("<SPEC_PATH>").join(ws.reviewerSpecFile(reviewerNum));
564
+ await this._contexts.fs.writeFile(ws.reviewerSpecFile(reviewerNum), await this._buildSpecContent(plan, task));
556
565
  const controller = new AbortController();
557
566
  this._reviewerAbortControllers.set(idx, controller);
558
567
  try {
@@ -570,10 +579,10 @@ class Implement {
570
579
  void currentSession.dispose();
571
580
  };
572
581
  const callbacks = {
573
- onLongWaitStart: () => {
582
+ onLongWaitStart: (_kind, endTimeMs) => {
574
583
  if (this._disposed)
575
584
  return;
576
- this._setReviewerState(idx, "waiting");
585
+ this._setReviewerWaiting(idx, endTimeMs);
577
586
  this._setReviewerLogicalStatus(idx, "waiting");
578
587
  },
579
588
  onLongWaitEnd: () => {
@@ -614,7 +623,7 @@ class Implement {
614
623
  continue;
615
624
  }
616
625
  const trimmed = (await this._workspace.readReviewerErrorLog(reviewerNum)).trim();
617
- this._setReviewerState(idx, trimmed.length === 0 ? "ok" : "fail");
626
+ this._setReviewerState(idx, trimmed.length === 0 ? "pass" : "fail");
618
627
  this._setReviewerLogicalStatus(idx, "done");
619
628
  const verdictLine = trimmed.length === 0
620
629
  ? "Verdict: PASS"
@@ -10,7 +10,6 @@ export type InstallContexts = Readonly<{
10
10
  export type InstallOptions = Readonly<{
11
11
  projectRoot: string;
12
12
  }>;
13
- export declare function stripYamlFrontmatter(body: string): string;
14
13
  type ReviewerFlagAnswers = Readonly<{
15
14
  tool?: "claude" | "codex";
16
15
  model?: string;