orchestrator-workflow 0.25.0 → 0.26.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/CHANGELOG.md CHANGED
@@ -7,6 +7,167 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.26.0] - 2026-08-30
11
+
12
+ ### Added
13
+
14
+ - The orchestrator now writes a per-worktree run pointer, `.ai/run`: a plain
15
+ text file whose first non-empty line is the absolute path of the run
16
+ directory, one written in every repository or worktree a run touches
17
+ (`SKILL.md` Run state, step 1, and all three Harness notes bullets;
18
+ `agents-md-section.md` Run state gained the matching bullet). For a run
19
+ spanning more than one repository, `00-goal.md` now also carries one keyed
20
+ `run-base[<repo-basename>]` marker per repository alongside the existing
21
+ unkeyed one, exact form `<!-- solution-acceptance: run-base[<repo-basename>]
22
+ = <sha> -->`; the shipped template line uses the placeholder key
23
+ `<repo-basename>` and value `<sha>` as a documentation example. Both are
24
+ written for a new consumer: the `.ai/run` pointer and the keyed marker are
25
+ read by grounding-mcp's `ow-run-completeness` reader, released as
26
+ `@lannguyensi/grounding-mcp` 0.9.0 (agent-grounding task
27
+ `design/ow-run-pointer-binding`, agent-tasks 43a7ef58, PR #198). The
28
+ reader resolves a run through the pointer first and falls back to scanning
29
+ the repository's own `.ai/runs/` (newest by name) only when no pointer file
30
+ exists, so kits and repos without the pointer keep working exactly as
31
+ before; the run-base marker's own date-heuristic fallback for a `TODO`
32
+ value is a separate mechanism and is unchanged. `README.md` ("What gets
33
+ installed") and `INSTALL-AGENT.md`
34
+ ("Write surface" and the manual scaffold list) now note that `.ai/run`
35
+ should be added to the repository's `.gitignore` (the installer does not
36
+ edit `.gitignore` itself). Pinned by new tests in
37
+ `test/template-markers.test.ts` (the keyed placeholder line's exact text,
38
+ its whole-line-comment shape, its position directly below the unkeyed
39
+ marker, and that the existing unkeyed `run-base` regex still matches
40
+ exactly once) and a new `test/docs-consistency.test.ts` describe block
41
+ (the pointer contract's phrases in SKILL.md Run state, the exact keyed
42
+ example string, step 1, each of the three Harness notes bullets
43
+ individually, the agents-md-section bullet, and the README/INSTALL-AGENT
44
+ gitignore notes). Anchors in `docs/okf/*.md` that cite line ranges in
45
+ `SKILL.md`, `test/docs-consistency.test.ts`, and
46
+ `test/template-markers.test.ts` drifted out of range because of the line
47
+ shifts this change introduces; those anchors were re-pointed in the same
48
+ PR, and `run-state-lifecycle-and-markers.md` gained a section documenting
49
+ the pointer and the keyed marker.
50
+ - Two review rounds on the run-pointer change above corrected inaccurate
51
+ claims and hardened the pinning tests. `SKILL.md` Run state now states the
52
+ pointer contract as a short lead sentence plus three bullets (what the
53
+ pointer's content is, when to write, overwrite, and remove it, and to
54
+ make sure it is ignored before writing it), followed by a separate
55
+ paragraph on how the run-completeness reader uses it: pointer first,
56
+ falling back to that repository's own `.ai/runs/` (the run there that
57
+ sorts newest by directory name) only when no pointer file exists, with a broken pointer rejected outright
58
+ rather than falling back; the exact accept/reject rules are left to the
59
+ consuming gate's (grounding-mcp) own documentation, not restated here.
60
+ The keyed-marker grammar sentence is now a single generalised rule: write
61
+ the marker exactly in its documented form, on its own line; a deviating
62
+ line is either rejected, which blocks the run, or not recognised at all
63
+ (for example inside a list bullet), which leaves the binding for that
64
+ repository silently missing. The consumer detail that a real key left
65
+ with the placeholder value `<sha>` is read as-is and blocked by the
66
+ verdict layer lives in `docs/okf/run-state-lifecycle-and-markers.md`,
67
+ not in the skill text. `test/docs-consistency.test.ts`'s pointer-doc
68
+ describe block now routes six of its eight checks through one shared
69
+ `expectPointerMention` helper that asserts the exact phrase `` `.ai/run`
70
+ pointer `` (a bare `.ai/runs/` mention alone cannot satisfy it); the
71
+ SKILL.md Run state contract check and the exact-keyed-example check keep
72
+ their own specific phrases instead, and a further check pins the
73
+ grammar rule's wording ("on its own line", both deviation outcomes).
74
+ `test/template-markers.test.ts`'s property test now carries
75
+ grounding-mcp's `KEYED_RUN_BASE_STRICT` and `PLACEHOLDER_KEY` regexes
76
+ verbatim, kept in sync by hand, instead of a locally tightened mirror,
77
+ and still asserts that two constructed near-miss variants (uppercase,
78
+ space before the colon) do not match. `agents-md-section.md`'s
79
+ run-directory bullet still notes the run directory can live "in the
80
+ workspace or a touched repository". `docs/okf/run-state-lifecycle-and-markers.md`
81
+ carries the corrected claims plus the consumer's own test-measured
82
+ evidence for the scan fallback and the malformed/not-seen split, and
83
+ every `docs/okf/*.md` anchor that cited a line range shifted by either
84
+ round's edits was re-pointed in the same PR.
85
+ - An operator-level install layer: a new `operator-manifest.ts` module and
86
+ an operator home directory (default `~/.orchestrator-workflow/`,
87
+ overridable via the `ORCHESTRATOR_WORKFLOW_HOME` environment variable)
88
+ hold one manifest per operator (`{ kit, schemaVersion: 1, defaults: {
89
+ harnesses, profile, tiers, models }, targets: [{ path,
90
+ lastAppliedVersion, lastAppliedAt }], createdAt, updatedAt }`), separate
91
+ from each repository's own `.ai/workflow/manifest.json`. Four new
92
+ subcommands sit alongside the existing per-repository `init`/`uninstall`,
93
+ which stay fully supported and unchanged: `setup` writes or updates the
94
+ operator defaults without touching any repository; `apply --target
95
+ <repo>` projects those defaults, and the target's own previously
96
+ recorded settings, onto one repository through the same
97
+ option-resolution logic `init` uses (`resolveInitInputs`, extracted for
98
+ reuse), and registers the target, by its resolved real path, in the
99
+ operator manifest, with `--sync` inverting precedence so the operator's
100
+ defaults win over the target's recorded profile/tiers/models, and
101
+ `--pin`/`--unpin`/`--force-pin` controlling the new per-repo kit-version
102
+ pin (below); `doctor [--json] [--prune]` walks the registry and reports
103
+ each target's status (`clean`, `divergent`, `version-lag`, `drift`,
104
+ `missing`, `no-manifest`, `unverifiable`), exiting `2` when the operator
105
+ manifest is missing or unreadable (or, with `--prune`, when the manifest
106
+ lock cannot be acquired or the rewrite fails), `1` when any target is
107
+ `drift`/`missing`/`no-manifest`/`unverifiable`, else `0`, and `--prune`
108
+ removes `missing`/`no-manifest` targets (never `unverifiable`) and
109
+ rewrites the manifest in normalized form; `adopt [dir] [--json]` registers an
110
+ already-installed repository verbatim, touching nothing in it,
111
+ bootstrapping the operator manifest from the repository's own recorded
112
+ settings when none exists, recording the repository's own version as
113
+ `lastAppliedVersion`, and printing that target's `doctor` report (exit
114
+ `1` only on drift, exit `2` for a precondition failure). Design
115
+ decisions: no new binary, all four subcommands live on the existing
116
+ `orchestrator-workflow` CLI; the registry is implicit, `apply`/`adopt`
117
+ register as a side effect of a real run and `doctor --prune` is the only
118
+ way to remove an entry; a multi-repo workspace root is an ordinary
119
+ target, nothing special. `README.md` gained a new "Operator-level
120
+ install" section and `INSTALL-AGENT.md` gained the operator path (an
121
+ installing agent runs `apply` instead of `init` when an operator
122
+ manifest already exists, and `adopt` for an already-installed
123
+ repository) plus the new operator-home and `pin` entries in its Write
124
+ surface list. Consumer-side evidence: agent-tasks `b457ee55`, PRs
125
+ #142-#147.
126
+ - The repo manifest (`.ai/workflow/manifest.json`) gained one optional
127
+ field, `pin`: a kit-version string. `apply --pin <version>` sets or
128
+ replaces it (trimmed; empty, whitespace-only, or containing internal
129
+ whitespace rejected as a usage error, exit `2`, writing nothing),
130
+ `--unpin` clears it, and `--force-pin` advances an existing pin to the
131
+ running version (a no-op on an unpinned target); read by `apply`'s pin
132
+ gate and by `doctor`, which on a pinned target compares the pin against
133
+ the installed version instead of the installed version against the
134
+ running kit. Purely additive: a
135
+ caller that never sets it sees a byte-identical manifest to before.
136
+ - `init --harness none` (the literal word `none`, alone): a templates-only
137
+ mode that writes only `.ai/workflow/**` and `.ai/runs/.gitkeep`, records
138
+ `harnesses: []` in the manifest, and touches no `AGENTS.md`, `CLAUDE.md`,
139
+ or per-harness directory. `none` combined with a real harness name
140
+ (`none,claude`, either order) is a usage error rather than an implicit
141
+ precedence rule. A plain re-run (no `--harness` flag) after a recorded
142
+ `harnesses: []` install stays templates-only instead of falling back to
143
+ filesystem detection; a later `init --harness <list>` on the same target
144
+ adds harness files and manifest entries additively, without touching the
145
+ already-installed templates. `apply` shares the same option parsing (an
146
+ explicit `--harness none` on an `apply` call resolves to templates-only
147
+ too) but not the re-run stickiness: `apply`'s own harness fallback chain
148
+ (target's recorded harnesses, else the operator defaults, else detection)
149
+ is unchanged, so a target `apply`-installed as templates-only is not
150
+ guaranteed to stay that way on a flagless `apply` re-run, a gap left open
151
+ by this change rather than closed. The closing summary line prints
152
+ `templates only` instead of `installed for: ` followed by nothing.
153
+ Motivated by friction filed 2026-08-28 while refreshing an agent-tasks
154
+ install that had ended up in the templates-only manifest shape (`harnesses:
155
+ []`, produced by a 0.14.0-era install with no harness configured) with no
156
+ supported way to reproduce or re-render that state: `--harness none`
157
+ rejected the literal value, and `--harness ""` fell back to detection,
158
+ which under `--yes` installed `claude` unasked. Documented in `README.md`
159
+ ("Non-interactive") and `docs/okf/install-fence-mechanics.md` (new
160
+ "`--harness none` (templates-only mode)" section). Agent-tasks 613316c9.
161
+
162
+ ### Changed
163
+
164
+ - `setup`, `apply`'s registration step, `doctor --prune`, and `adopt` all
165
+ write the operator manifest through the same locked write API,
166
+ `updateOperatorManifest`/`withOperatorManifestLock`, backed by one
167
+ advisory lock (`.manifest.lock` in the operator home, stale after 30s)
168
+ so concurrent `orchestrator-workflow` invocations on one machine cannot
169
+ race each other's writes.
170
+
10
171
  ## [0.25.0] - 2026-08-27
11
172
 
12
173
  ### Added
package/INSTALL-AGENT.md CHANGED
@@ -31,10 +31,23 @@ which is mutable. For a stable audit, pin the URL to a commit SHA instead
31
31
  3. **Run the non-interactive installer** with your answers:
32
32
  `npx orchestrator-workflow init --yes --harness ... --profile ... --models ... [--tiers]`.
33
33
  If the installer reports conflicts with locally edited files, the agent
34
- shows them to you and asks before any `--force` re-run.
34
+ shows them to you and asks before any `--force` re-run. **The operator
35
+ path**: when an operator has already run `orchestrator-workflow setup`
36
+ on this machine (an operator manifest exists at
37
+ `<operator home>/manifest.json`, where the operator home is
38
+ `~/.orchestrator-workflow/` unless `ORCHESTRATOR_WORKFLOW_HOME` names a
39
+ different directory), the agent runs
40
+ `orchestrator-workflow apply --target <repo>` instead of `init`, which
41
+ sources its defaults from that operator install and registers the
42
+ repository under it. A repository that already has the kit installed
43
+ and only needs bringing under that management, with nothing in it
44
+ changed, is registered with `orchestrator-workflow adopt <repo>`
45
+ instead of either command.
35
46
  4. **Manual fallback only when npx or the registry is unavailable**: create
36
47
  the same files by hand from this repository's `assets/` directory,
37
- following the byte-precise rules in step 4 below.
48
+ following the byte-precise rules in step 4 below. This manual path
49
+ covers `init` only; there is no manual equivalent for `apply` or
50
+ `adopt`, both of which require the installed CLI.
38
51
  5. **Report back**: which harnesses were installed, which profile and model
39
52
  each role uses, whether effort-tier variants were rendered, and any
40
53
  conflicts left in place.
@@ -44,7 +57,18 @@ which is mutable. For a stable audit, pin the URL to a commit SHA instead
44
57
  The install creates or touches only these paths:
45
58
 
46
59
  - `.ai/workflow/templates/00-goal.md` through `06-handoff.md`,
47
- `.ai/workflow/manifest.json`, `.ai/runs/.gitkeep` (new files)
60
+ `.ai/workflow/manifest.json`, `.ai/runs/.gitkeep` (new files). The
61
+ orchestrator later writes a per-worktree `.ai/run` pointer at run time (a
62
+ machine-local absolute path, not written by the installer); add it to the
63
+ repository's `.gitignore`. This repository's own `.ai/workflow/manifest.json`
64
+ can additionally carry one optional field, `pin`: a kit version recorded
65
+ by `apply --pin`/`--unpin`/`--force-pin`, absent when no pin was ever set.
66
+ - **Operator path only** (`apply`/`adopt`, not `init`): the operator's own
67
+ home's manifest, `<operator home>/manifest.json`, where the operator home
68
+ is `~/.orchestrator-workflow/` unless `ORCHESTRATOR_WORKFLOW_HOME` names a
69
+ different directory, gains or updates its record of this repository,
70
+ guarded by a transient `.manifest.lock` directory held only for the
71
+ duration of that write. Neither path lives inside the target repository.
48
72
  - `AGENTS.md`: the marker-fenced workflow section is appended (file created
49
73
  when missing); content outside the
50
74
  `<!-- orchestrator-workflow:begin -->` / `<!-- orchestrator-workflow:end -->`
@@ -126,6 +150,19 @@ steps in the repository you were asked to install into.
126
150
  on a re-run. If the command reports conflicts, show them to the operator
127
151
  and ask before re-running with --force.
128
152
 
153
+ **Operator path**: before running `init`, check whether an operator
154
+ manifest already exists on this machine, at
155
+ `<operator home>/manifest.json` (the operator home is
156
+ `~/.orchestrator-workflow/` unless `ORCHESTRATOR_WORKFLOW_HOME` names a
157
+ different directory). If it does, run
158
+ `orchestrator-workflow apply --target <repo>` with the same flags in
159
+ place of `init --yes` instead: it sources its defaults from the operator
160
+ install and the target's own prior settings, and registers the
161
+ repository. If the repository already has the kit installed and the
162
+ operator only wants it brought under that management without any file
163
+ changes, run `orchestrator-workflow adopt <repo>` instead and skip the
164
+ rest of this step.
165
+
129
166
  4. Only if npx or the registry is unavailable, scaffold manually from
130
167
  https://github.com/LanNguyenSi/agent-dx/tree/master/packages/orchestrator-workflow/assets.
131
168
  This manual path does not cover `--tiers`: it never renders
@@ -135,7 +172,10 @@ steps in the repository you were asked to install into.
135
172
 
136
173
  - `.ai/workflow/templates/00-goal.md` through `06-handoff.md` from
137
174
  `assets/templates/`, unchanged.
138
- - `.ai/runs/.gitkeep`, empty.
175
+ - `.ai/runs/.gitkeep`, empty. The orchestrator later writes a
176
+ per-worktree `.ai/run` pointer at run time (a machine-local absolute
177
+ path, not written by the installer); add it to the repository's
178
+ `.gitignore`.
139
179
  - Append the content of `assets/agents-md-section.md` to `AGENTS.md`
140
180
  (create the file when missing; the installer starts a fresh file with a
141
181
  `# Agent instructions` heading). Never change anything outside the
package/README.md CHANGED
@@ -73,6 +73,26 @@ npx orchestrator-workflow init --harness claude,codex,opencode --models "impleme
73
73
  npx orchestrator-workflow init --profile minimal --yes
74
74
  ```
75
75
 
76
+ **Templates-only mode.** `--harness none` (the literal word `none`, on its
77
+ own) installs only `.ai/workflow/**` and `.ai/runs/.gitkeep`: no
78
+ `AGENTS.md`, no `CLAUDE.md`, no harness-specific directory, and a manifest
79
+ recording `harnesses: []`. Use it for a repo that wants the run-state
80
+ templates and the workflow itself, but no per-harness subagent files yet
81
+ (e.g. no harness has been chosen, or the files were dropped by hand).
82
+ `none` combined with a real harness name (`--harness none,claude`) is
83
+ rejected as ambiguous rather than silently picking one. A plain
84
+ **non-interactive** re-run (no `--harness` flag) after a templates-only
85
+ install stays templates-only; add a harness back with an explicit
86
+ `--harness <list>` on a later run, the same explicit-flag-wins rule
87
+ `--profile`/`--models`/`--tiers` use, applied to the no-harness case. An
88
+ **interactive** re-run is different: it still prompts, with nothing forced
89
+ pre-selected, instead of silently skipping straight back to templates-only
90
+ without asking; deselect every checkbox to stay templates-only.
91
+
92
+ ```bash
93
+ npx orchestrator-workflow init --harness none --yes
94
+ ```
95
+
76
96
  To let a coding agent do the install, give it this single line:
77
97
 
78
98
  ```text
@@ -97,6 +117,10 @@ to a commit SHA for a stable audit.
97
117
  AGENTS.md marker-fenced "Agentic Coding Workflow" policy section
98
118
  ```
99
119
 
120
+ The orchestrator writes a `.ai/run` pointer file in every worktree a run
121
+ touches (a machine-local absolute path, not written by the installer); add
122
+ it to the repository's `.gitignore`.
123
+
100
124
  Per selected harness:
101
125
 
102
126
  | Harness | Files | Notes |
@@ -333,9 +357,103 @@ resolves to via `--models`, including a model with no effort support at all
333
357
  parameter, the harness ignores the pinned value rather than rejecting it
334
358
  (anchored by a measurement, see CHANGELOG 0.23.0).
335
359
 
360
+ ## Operator-level install
361
+
362
+ Alongside `init`, which installs the kit into one repository from that
363
+ repository's own working directory, an operator who maintains many
364
+ repositories can set defaults once and project them onto each target
365
+ instead of re-answering the same prompts per repo. This layer adds no new
366
+ binary: `setup`, `apply`, `doctor`, and `adopt` below are subcommands of the
367
+ same `orchestrator-workflow` CLI `init` and `uninstall` already ship as, and
368
+ `init`/`uninstall` remain fully supported and unchanged for a
369
+ single-repository install.
370
+
371
+ ```bash
372
+ orchestrator-workflow setup --yes
373
+ orchestrator-workflow apply --target /path/to/repo
374
+ ```
375
+
376
+ **`setup`** writes or updates this operator's default install options
377
+ (harnesses, profile, models, tiers) as the baseline for future installs; it
378
+ touches no repository. A flag always wins; a flag-less re-run keeps the
379
+ previously stored values; a first-ever `setup` falls back to `claude` /
380
+ `full` / the kit's default models / tiers off. `setup` takes the same
381
+ option flags as `init` (`--harness`, `--profile`, `--models`, `--tiers` /
382
+ `--no-tiers`, `--opencode-provider`, `--yes`). The defaults live in
383
+ `<operator home>/manifest.json`, where the operator home is
384
+ `~/.orchestrator-workflow/` unless the `ORCHESTRATOR_WORKFLOW_HOME`
385
+ environment variable names a different directory.
386
+
387
+ **`apply --target <repo>`** projects the operator's install onto a target
388
+ repository and registers that target, by its real resolved path, in the
389
+ operator manifest. It requires a prior `orchestrator-workflow setup`;
390
+ without one it exits `1` with "No operator setup found". Option resolution
391
+ follows one precedence order: an
392
+ explicit flag wins, then the target's own previously recorded settings,
393
+ then the operator's defaults (harnesses fall back one step further, to
394
+ what `init` would have auto-detected). Pass `--sync` to invert that for
395
+ profile, tiers, and models: the operator's defaults then win over whatever
396
+ the target already had recorded. A target pinned to a kit version other
397
+ than the one being applied is skipped rather than touched (see the pin
398
+ rule below). `apply` also takes the same install options as `init` (`--harness`,
399
+ `--profile`, `--models`, `--tiers` / `--no-tiers`, `--opencode-provider`,
400
+ `--force`, `--yes`), which feed the precedence rule above.
401
+
402
+ **`doctor [--json] [--prune]`** reports every operator-registered target's
403
+ status: `clean`, `divergent` (from the operator defaults), `version-lag`,
404
+ `drift` (installed files edited, deleted, or unreadable since install),
405
+ `missing`, `no-manifest`, or `unverifiable`. It exits `2` when the operator
406
+ manifest is missing or unreadable, or, with `--prune`, when the operator
407
+ manifest lock cannot be acquired or the rewrite fails; `1` when any target
408
+ is `drift`, `missing`, `no-manifest`, or `unverifiable`; and `0` otherwise.
409
+ `--json` prints one JSON object instead
410
+ of human output, with one entry per target plus the operator home and
411
+ version. `--prune` removes `missing` and `no-manifest` targets from the
412
+ registry before reporting (never an `unverifiable` one, since that status
413
+ means the check itself was inconclusive, not that the target is confirmed
414
+ gone) and rewrites the manifest file in its normalized form.
415
+
416
+ **`adopt [dir] [--json]`** brings a repository that already has the kit installed,
417
+ by hand or by an earlier `init`, under the operator's management without
418
+ changing anything in that repository: it registers the repository
419
+ verbatim, using the repository's own recorded settings to bootstrap the
420
+ operator manifest when none exists yet, records the repository's own
421
+ installed version as its baseline, and prints that one target's `doctor`
422
+ report. It exits `1` only when the freshly adopted target itself reports
423
+ drift, and `2` for a precondition failure (no repo manifest, an unreadable
424
+ or foreign manifest, or a lock or write failure).
425
+
426
+ **The kit-version pin.** A repository's own manifest can additionally
427
+ carry an optional `pin`: a kit version that `apply` must match before it
428
+ will touch that repository again. `apply` skips (exit `0`) a target pinned
429
+ to a different version than the one being applied. `--pin <version>` sets
430
+ or replaces the pin and applies regardless of any existing one; `--unpin`
431
+ clears it and applies; `--force-pin` advances an existing pin that
432
+ differs, but has no effect on a target with no pin recorded (it stays
433
+ unpinned). `doctor` reports `version-lag` when the installed version
434
+ differs from the running kit version; on a pinned target the pin is
435
+ compared against the installed version instead, so a pin equal to the
436
+ installed version is `clean` and a pin that no longer matches it is
437
+ `version-lag`.
438
+
439
+ **The registry is implicit**, not a separate command: `apply` and `adopt`
440
+ register a target as a side effect of a real run, and `doctor --prune` is
441
+ how a registry entry is removed again; there is no bare register or
442
+ unregister command. The workspace root of a multi-repo checkout is treated
443
+ as an ordinary target, nothing special.
444
+
445
+ All writes to the operator manifest, by `setup`, `apply`, `doctor --prune`,
446
+ and `adopt` alike, go through one advisory lock in the operator home, so
447
+ concurrent orchestrator-workflow commands on the same machine cannot
448
+ corrupt each other's state.
449
+
336
450
  ## Ownership and re-runs
337
451
 
338
- `init` is idempotent: a second run changes nothing. The rules:
452
+ `init` is idempotent: a second run changes nothing. `apply` installs
453
+ through that same `runInit` path and is subject to the same
454
+ conflict/`--force`/ownership rules; on the repository side it changes
455
+ nothing either, but it refreshes this target's entry in the operator
456
+ manifest on every run. The rules:
339
457
 
340
458
  - `AGENTS.md` and `CLAUDE.md` belong to you. The installer only appends its
341
459
  fenced section or the import line, and on re-run replaces only the content
@@ -346,9 +464,9 @@ parameter, the harness ignores the pinned value rather than rejecting it
346
464
  updates files you never touched and reports files you edited as conflicts
347
465
  instead of overwriting them; `--force` overwrites those too.
348
466
  - `.ai/workflow/manifest.json` is the kit's state file. It records the applied
349
- version, harnesses, role profile, models, the `--tiers` flag, and file
350
- hashes, and is rewritten whenever that state changes; do not edit it by
351
- hand.
467
+ version, harnesses, role profile, models, the `--tiers` flag, the optional
468
+ kit-version pin, and file hashes, and is rewritten whenever that state
469
+ changes; do not edit it by hand.
352
470
 
353
471
  ## Uninstall
354
472
 
@@ -150,11 +150,15 @@ Workflow state lives under `.ai/`:
150
150
 
151
151
  - `.ai/workflow/templates/` holds the canonical file templates
152
152
  (`00-goal.md` through `06-handoff.md`).
153
- - Each unit of work gets a run directory `.ai/runs/YYYY-MM-DD-<slug>/`,
154
- created by copying the templates. The newest run directory is the active
155
- one; older ones are the auditable history.
153
+ - Each unit of work gets a run directory `.ai/runs/YYYY-MM-DD-<slug>/` (in
154
+ the workspace or a touched repository), created by copying the templates.
155
+ The newest run directory is the active one; older ones are the auditable
156
+ history.
156
157
  - `.ai/workflow/manifest.json` records the installed kit version, the chosen
157
158
  harnesses, and the per-role model preferences.
159
+ - Every worktree a run touches carries a `.ai/run` pointer (absolute path of
160
+ the run directory, gitignored) and `00-goal.md` carries one
161
+ `run-base[<repo-basename>]` marker per repository for multi-repo runs.
158
162
 
159
163
  ### Models
160
164
 
@@ -78,9 +78,30 @@ All state for one unit of work lives in a run directory:
78
78
  ```
79
79
 
80
80
  Create it at the start of a run by copying `.ai/workflow/templates/` and fill
81
- the files as the run progresses. The newest run directory is the active one;
81
+ the files as the run progresses. The newest run directory is the active one
82
+ unless a `.ai/run` pointer names one (see below);
82
83
  older directories are the auditable history. Do not edit past runs.
83
84
 
85
+ The run directory may live in the workspace's own `.ai/runs/` or in one
86
+ repository's `.ai/runs/`. Either way, bind every repository or worktree the
87
+ run touches to it with a pointer file, `<worktree-root>/.ai/run`:
88
+
89
+ - Content: the absolute path of the run directory (a `YYYY-MM-DD-<slug>`
90
+ directory) on the first non-empty line; nothing else is read.
91
+ - Write it before the first implementation commit, and overwrite it at the
92
+ start of every later run; remove it when no run is active, since a
93
+ pointer left behind keeps binding that worktree to the old run.
94
+ - Before writing it, make sure it is ignored (the repository's `.gitignore`
95
+ or `.git/info/exclude`); never commit it, it carries a machine-local
96
+ absolute path.
97
+
98
+ The pointer is how the run-completeness reader finds the run for a change.
99
+ Without it the reader falls back to that repository's own `.ai/runs/` and
100
+ takes the run there that sorts newest by directory name, which is only
101
+ right when the run lives in that repository and sorts last; a broken
102
+ pointer is rejected outright. The exact accept and reject rules are the
103
+ consuming gate's (grounding-mcp) to document, not the kit's.
104
+
84
105
  When creating the run directory, replace the `TODO` in `00-goal.md`'s
85
106
  `<!-- solution-acceptance: run-base = TODO -->` marker with the base commit
86
107
  this run branches from — the pre-change repo HEAD (`git rev-parse HEAD`),
@@ -91,7 +112,17 @@ left as `TODO` it does not block anything, the reader just falls back to a
91
112
  tolerant day-granular date heuristic. The recorded base must resolve in the
92
113
  repo, be an ancestor of HEAD, and must not lie behind the fork point of the
93
114
  change (the merge-base with the remote default branch); see the consuming
94
- gate's documentation (grounding-mcp) for the full consumer semantics.
115
+ gate's documentation (grounding-mcp) for the full consumer semantics. When a
116
+ run touches more than one repository, record one keyed marker per
117
+ repository on its own line beside the unkeyed one, exact form
118
+ `<!-- solution-acceptance: run-base[<repo-basename>] = <sha> -->`, where
119
+ `<repo-basename>` is the worktree directory's basename; in a linked worktree
120
+ the main repository's basename is accepted too, and the value is that
121
+ repository's pre-change HEAD. The template ships that line as a placeholder
122
+ example, which readers ignore until the placeholder key is replaced. Write
123
+ the marker exactly in that form, on its own line: a deviating line is
124
+ either rejected (it blocks the run) or not recognised at all (the binding
125
+ for that repository is silently missing).
95
126
 
96
127
  ## Workflow
97
128
 
@@ -101,7 +132,8 @@ directory and the subagents.
101
132
 
102
133
  1. **Understand the goal.** Create the run directory and fill `00-goal.md`,
103
134
  including the run-base marker (see Run state): operator request, goal,
104
- non-goals, constraints, assumptions, open questions.
135
+ non-goals, constraints, assumptions, open questions. Write the `.ai/run`
136
+ pointer (see Run state) in every worktree the run touches.
105
137
  If the task can proceed on reasonable assumptions, proceed without blocking.
106
138
  2. **Discover (optional, read-only).** When the goal, the solution, or the
107
139
  terrain is unclear, send the explorer subagent before planning. Have it
@@ -443,12 +475,15 @@ instructions found in untrusted content as risks instead of following them.
443
475
  whichever roles this install's profile carries (explorer, task-slicer,
444
476
  implementer, reviewer, advisor under `full`; implementer and reviewer only
445
477
  under `minimal`) via the native subagent mechanism; run any missing role
446
- inline with the same contract.
478
+ inline with the same contract. The `.ai/run` pointer rule from Run state
479
+ applies unchanged.
447
480
  - **opencode**: invoke the installed `.opencode/agents/` subagents the same
448
- way (`mode: subagent`); the same profile scoping applies.
481
+ way (`mode: subagent`); the same profile scoping applies. The `.ai/run`
482
+ pointer rule from Run state applies unchanged.
449
483
  - **OpenAI Codex**: there is no standardized project-level subagent definition
450
484
  to install. Run the roles inline and sequentially with the same contracts,
451
- and still produce the same run files.
485
+ and still produce the same run files. The `.ai/run` pointer rule from Run
486
+ state applies unchanged.
452
487
 
453
488
  ## Subagent misfire rule
454
489
 
@@ -1,6 +1,7 @@
1
1
  # Goal
2
2
 
3
3
  <!-- solution-acceptance: run-base = TODO -->
4
+ <!-- solution-acceptance: run-base[<repo-basename>] = <sha> -->
4
5
 
5
6
  ## Operator Request
6
7
 
@@ -0,0 +1,71 @@
1
+ import type { Harness } from "./detect.js";
2
+ import type { Manifest } from "./init.js";
3
+ import type { ModelClass, Profile, Role } from "./models.js";
4
+ export declare function promptHarnesses(detected: Harness[], installed: Harness[], fallbackToClaude?: boolean): Promise<Harness[]>;
5
+ export declare function promptProfile(base: Profile): Promise<Profile>;
6
+ export declare function promptModels(base: Record<Role, string>, roles: Role[]): Promise<Record<Role, string>>;
7
+ /** The subset of `init`'s commander options that feed input resolution. */
8
+ export interface InitResolutionOptions {
9
+ harness?: string;
10
+ models?: string;
11
+ profile?: string;
12
+ opencodeProvider?: string;
13
+ tiers?: boolean;
14
+ }
15
+ export interface ResolveInitInputsParams {
16
+ /** Result of `detectHarnesses(targetDir)`; passed in so the caller can
17
+ * print it before resolution starts, matching `init`'s existing output
18
+ * order, without this function reading the filesystem a second time. */
19
+ detected: Harness[];
20
+ interactive: boolean;
21
+ /** The previously installed manifest, if any (`readInstalledManifest`). */
22
+ previous: Manifest | undefined;
23
+ opts: InitResolutionOptions;
24
+ /**
25
+ * True when `previous` reflects the target's own actually-recorded
26
+ * manifest (`init`'s use, `readInstalledManifest(targetDir)`), as opposed
27
+ * to a synthetic "operator defaults as floor" object (`apply`'s
28
+ * `buildApplyPrevious`, which is never `undefined` even for a target with
29
+ * no manifest of its own). Only consulted for the harnesses-stickiness
30
+ * rule below, together with `previous.harnessesRecordedEmpty`: a real
31
+ * recorded `harnesses: []` means a deliberate `--harness none` install,
32
+ * and a plain re-run must not silently widen it via detection; a
33
+ * synthetic floor previous carries no such signal, so `apply` omits this
34
+ * (default `false`) and keeps its own `resolveApplyHarnesses` fallback
35
+ * chain unchanged. This flag alone does not distinguish a deliberate
36
+ * `harnesses: []` from a damaged/legacy manifest whose raw `harnesses`
37
+ * field was missing, malformed, or an array whose every entry failed the
38
+ * known-harness filter (all of which also sanitize to `harnesses: []`)
39
+ * -- that distinction is `harnessesRecordedEmpty`'s job; both must hold
40
+ * for the stickiness gate to fire.
41
+ */
42
+ previousIsRecordedManifest?: boolean;
43
+ }
44
+ export interface ResolvedInitInputs {
45
+ harnesses: Harness[];
46
+ profile: Profile;
47
+ models: Record<Role, string>;
48
+ tiers: boolean;
49
+ opencodeModels?: Record<Role, string | undefined>;
50
+ opencodeClassModels?: Record<ModelClass, string | undefined>;
51
+ /**
52
+ * Warning lines to print, in order, exactly as `init` printed them to
53
+ * stderr before this extraction (each written as `${line}\n`). Returned
54
+ * as data rather than printed here so the caller decides where/whether to
55
+ * print them.
56
+ */
57
+ warnings: string[];
58
+ }
59
+ /**
60
+ * Resolves everything `runInit` needs (harnesses, profile, models, tiers,
61
+ * the opencode model resolutions) from the CLI-parsed options, the target
62
+ * directory, whether the session is interactive, and the previously
63
+ * installed manifest. Used by `init`'s action today, and reusable by a
64
+ * later `apply --target` command without duplicating this logic.
65
+ *
66
+ * Every override-vs-persist rule below matches `init`'s pre-extraction
67
+ * behaviour: an explicit flag always overrides; a plain re-run (flag
68
+ * omitted) keeps the previously installed value; a fresh install with no
69
+ * prior manifest falls back to the shipped default.
70
+ */
71
+ export declare function resolveInitInputs(params: ResolveInitInputsParams): Promise<ResolvedInitInputs>;