@oscaner-skills/cdd-engine 4.3.0 → 4.5.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/dist/face/gate.js CHANGED
@@ -1,43 +1,54 @@
1
1
  // packages/cdd-engine/src-next/face/gate.ts
2
2
  // T8 — the split contract's gate face (§6.2: face/gate.ts — the target/line gate
3
- // family). The work commands' readiness gates — the single-target line's phase
4
- // derivation (lineGate/#linePhase/#lineKey), the doc line's revision-aware BLOCK +
5
- // pending-fix faces (#docLineBlock/#pendingFixBlock/#docContent/#docVersionOf), the
6
- // ONE line-hop object the CLI refusal renders (lineHop + lineHopMessage, P22 §5.2)
7
- // and the group/line helpers (#tasksOf/#renderBrief). The method bodies are the
3
+ // family). The work commands' readiness gate facts — the single-target line's phase
4
+ // derivation (lineGate/#lineKey, reading the ONE walk
5
+ // `DispatchAuthority#linePhaseFacts`), the line identity facts the dispatch request
6
+ // assembles from (lineIdentity), the refusal-prose renderers the CLI still prints
7
+ // (`lineHopMessage` for the lifecycle's peeked hop, `hopCommand` for the dispatch
8
+ // verdict's `next:` value, P22 §5.2) and the group helpers (#tasksOf/#renderBrief).
9
+ // The dispatch VERDICT itself is not this face's: `session/dispatch-authority.ts`
10
+ // owns it, and the CLI refusal renders the authority's hop
11
+ // (`PipelineFrontier#hopOf`) on the ONE `reason · next:` line (P27 §2.4) — the
12
+ // pre-P27 doc BLOCK and pending-fix prose rows retired with that collapse, so this
13
+ // face renders no literal of its own for a refusal. The method bodies are the
8
14
  // pre-split Cli members moved verbatim — behavior bytes identical; the root Cli
9
15
  // holds the gate instance and composes through it via its .action thin shells (zero
10
16
  // bare functions).
11
- import { readFileSync } from "node:fs";
12
17
  import process from "node:process";
13
- import { FrontMatterExtractor } from "../contract/frontmatter.js";
14
18
  import { BriefRenderer } from "../render/brief.js";
19
+ import { DispatchAuthority } from "../session/dispatch-authority.js";
15
20
  import { RoundNaming } from "../session/round-naming.js";
16
- import { BoardView } from "./board-view.js";
17
21
  import { ARGV_CHANNEL } from "./declare.js";
18
22
  import { HostDetect } from "./host.js";
19
23
  import { RouteRenderer } from "./route-render.js";
20
24
  /**
21
25
  * CliGate — the target/line gate family (the split contract's gate face): the
22
- * readiness judgments the work commands consult before dispatching a round. The
23
- * instance's methods take the per-invocation scene; the gate holds only the stable
24
- * collaborators it needs (the brief renderer). The verdict-bearing methods return
25
- * their ruling + message — the root renders, never re-judges.
26
+ * readiness FACTS the work commands render around a dispatch. The instance's methods
27
+ * take the per-invocation scene; the gate holds only the stable collaborators it
28
+ * needs — the brief renderer and the dispatch authority whose ONE line-phase walk it
29
+ * reads (P27 §2.7; the verdict itself is never this face's to judge). The
30
+ * verdict-bearing methods return their ruling + message — the root renders, never
31
+ * re-judges.
26
32
  */
27
33
  export class CliGate {
28
34
  #brief;
35
+ #authority;
29
36
  constructor(opts = {}) {
30
37
  this.#brief = opts.brief ?? new BriefRenderer();
38
+ this.#authority = opts.authority ?? new DispatchAuthority();
31
39
  }
32
40
  /** The single-target line's current open phase plus the doc-line verdict the gate
33
- * judged — the {phase, verdict} pair IS the gate's ruling: the revision-aware
34
- * BLOCK renders only the "same" verdict the gate returned, the pending-fix note
35
- * only the derived pending face, never a recomputed one. The task face holds no
36
- * separate gate here: the WaveGate's wrong-phase verdict (the pre-flight) IS the
37
- * task-face phase authority — the wave gate is the single phase authority. A
38
- * doc line's gate is the reviewGate method family (T8 · §3.5), shared by the
39
- * lifecycle's frame phase so an opened gate dispatches: a moved doc reopens the
40
- * review lead on a line whose C5 hop is on the EXIT side (a closed line, `null`,
41
+ * judged — a FACE-LEVEL FACT READ (P27 §2.7): the walk itself lives ONCE, on the
42
+ * session plane (`DispatchAuthority#linePhaseFacts`), so the dispatch VERDICT and
43
+ * this face read one derivation and can never disagree on the line's phase. The
44
+ * gate renders the value; it never judges a dispatch.
45
+ *
46
+ * The {phase, verdict} pair IS the gate's ruling: the verdict is the one the
47
+ * authority's walk returned, never a recomputed one. The task face holds no
48
+ * separate gate here: the wave rows are the authority's line leg — the ONE phase
49
+ * authority. A doc line's gate is the reviewGate method family (T8 · §3.5), shared
50
+ * by the lifecycle's frame phase so an opened gate dispatches: a moved doc reopens
51
+ * the review lead on a line whose C5 hop is on the EXIT side (a closed line, `null`,
41
52
  * or a face-to-face station — the ONE `Ledger#docReopens` judgment), while a
42
53
  * still-pending fix keeps its hop (drift never outranks it, §5.5 ②) so the gate
43
54
  * never refuses the round the ONE derivation names. An unchanged doc yields the
@@ -46,9 +57,8 @@ export class CliGate {
46
57
  * falls back to the legacy rounds/routes judgment: a completed-fix line reopens
47
58
  * the review lead through its fix round's C5-1 route (the lifecycle's own
48
59
  * fall-through — an open gate and a dispatchable frame agree), a truly closed line
49
- * keeps the revision-aware BLOCK. An unbound line (no identity on record / an
50
- * unreadable doc) keeps the legacy round/route judgment + the generic closed
51
- * message (only present facts land).
60
+ * keeps the revision-aware "same" verdict. An unbound line (no identity on
61
+ * record / an unreadable doc) keeps the legacy round/route judgment.
52
62
  *
53
63
  * The branch line rides the SAME drift leg (its identity document is the PLAN,
54
64
  * P21 §3/§4.1 — the very document a branch re-review judges): a plan revision
@@ -56,84 +66,13 @@ export class CliGate {
56
66
  * lead, so the `next:` a closure hands the user is never a command this gate
57
67
  * refuses. An unchanged plan falls through to the SAME derived faces the doc lines
58
68
  * reach: a branch review that left findings yields the derived `fix` face
59
- * (`pending-fix` — no doc-class BLOCK message binds the branch face, so the refusal
60
- * renders through the ONE line hop), while only a fully closed, drift-free branch
69
+ * (`pending-fix`), while only a fully closed, drift-free branch
61
70
  * line keeps the generic `face-closed` row. */
62
71
  lineGate(scene) {
63
- const key = this.#lineKey(scene);
64
- const doc = this.#docOf(scene);
65
- const verdict = key !== null && doc !== null ? scene.ledger.reviewGate(key, doc, scene.face.type) : null;
66
- // The drift leg reads the ONE reopen judgment (exit-side routes only): a moved doc
67
- // reopens the review lead on a line whose C5 hop is gone, while a still-pending
68
- // fix keeps its own hop — drift never outranks it (§5.1 · §5.5 ②), so this gate
69
- // always accepts the round the ONE derivation names.
70
- if (key !== null &&
71
- verdict !== null &&
72
- scene.ledger.docReopens(key, scene.face.type, verdict)) {
73
- return { phase: scene.face.product.reviewLead, verdict: null, reviewed: null };
74
- }
75
- if (verdict !== null && verdict.kind === "same") {
76
- if (verdict.pending) {
77
- return { phase: "fix", verdict: "pending-fix", reviewed: verdict.reviewed };
78
- }
79
- // same + no pending fix — the legacy rounds/routes judgment (the lifecycle's
80
- // own fall-through): a completed-fix line reopens the review lead through its
81
- // fix round's C5-1 route; a truly closed line keeps the revision-aware BLOCK.
82
- const open = this.#linePhase(scene);
83
- return open !== null
84
- ? { phase: open, verdict: null, reviewed: null }
85
- : { phase: null, verdict: "same", reviewed: verdict.reviewed };
86
- }
87
- const open = this.#linePhase(scene);
88
- return { phase: open, verdict: null, reviewed: null };
89
- }
90
- /** The doc line's revision-aware BLOCK message (T7/T8) — the unchanged-approved
91
- * face: "{plan|spec} already reviewed at vX.Y (doc-hash …) — target revision
92
- * unchanged; amend body/version to open a new review". Renders ONLY on the
93
- * gate's "same" verdict — the approved identity the gate judged, whose reviewed
94
- * ref the message names: the block consumes the verdict's identity, never a
95
- * second ledger lookup (the face's judgment read points converge to the
96
- * method family). Null off that face or with no identity ("target revision
97
- * unchanged" is a present fact only there). */
98
- docLineBlock(scene, reviewed) {
99
- if (reviewed === null || (scene.target?.kind !== "plan" && scene.target?.kind !== "spec"))
100
- return null;
101
- const version = this.#docVersionOf(this.#docContent(scene.target.doc));
102
- return `${scene.type} already reviewed at ${version ?? "the current version"} (doc-hash ${reviewed.doc_hash.slice(0, 12)}…) — target revision unchanged; amend body/version to open a new review`;
103
- }
104
- /** The doc line's derived pending-fix note (T8) — the unchanged + non-APPROVED
105
- * face: "the pending fix applies to the unchanged doc (doc-hash …) — run cdd
106
- * fix first". Renders ONLY for the gate's "pending-fix" verdict — the derived
107
- * fix-awaited face (a same-doc re-review stays refused until its fix lands,
108
- * Review Convergence anti-spin); the message names the reviewed identity the
109
- * gate judged. */
110
- pendingFixBlock(scene, reviewed) {
111
- if (reviewed === null || (scene.target?.kind !== "plan" && scene.target?.kind !== "spec"))
112
- return null;
113
- return `the pending fix applies to the unchanged doc (doc-hash ${reviewed.doc_hash.slice(0, 12)}…) — run cdd fix first`;
114
- }
115
- /** lineHop(scene) — the line's ONE next-hop object (§5.2): the SAME derivation
116
- * the capsule, the board and the lifecycle frontier read, built from this line's
117
- * facts through `Ledger#nextHopOf` (the ONE assembly entry: the drift gate + the
118
- * declaration read). The CLI rejection message renders THIS object's `reason` +
119
- * hop/station — never a second judgment, never a second shape. The doc-class
120
- * discrimination is ROOTED in the workspace's own repo basis (the same basis the
121
- * lifecycle frontier injects), so an engine invoked from a subdirectory reads the
122
- * same declared `doc-type:` the board does. Null when the scene holds no
123
- * registered line (no fixed target → there is no line to name). */
124
- lineHop(scene) {
125
- const key = this.#lineKey(scene);
126
- const target = this.#routeTargetOf(scene);
127
- if (key === null || target === null)
128
- return null;
129
- const basis = scene.workspace.root.basis;
130
- return scene.ledger.nextHopOf({
131
- type: scene.face.type,
132
- key,
133
- route: scene.ledger.lineRoute(key, scene.face.type),
134
- target,
72
+ return this.#authority.linePhaseFacts(scene.ledger, {
73
+ key: this.#lineKey(scene),
135
74
  doc: this.#docOf(scene),
136
- docClassOf: (candidate) => BoardView.docClassOf(basis, candidate),
75
+ type: scene.face.type,
137
76
  });
138
77
  }
139
78
  /** lineHopMessage(scene, hop, words) — the CLI rejection prose of one `NextHop`
@@ -143,9 +82,30 @@ export class CliGate {
143
82
  lineHopMessage(scene, hop, words) {
144
83
  if (hop === null)
145
84
  return "the line holds no open round";
146
- const renderer = new RouteRenderer(words, ARGV_CHANNEL, HostDetect.detect(process.env), scene.workspace.root.basis);
85
+ const renderer = this.#renderer(scene, words);
147
86
  return scene.router.message(hop, (entry) => renderer.render({ kind: "handoff", entry }, hop.target));
148
87
  }
88
+ /** hopCommand(scene, hop, words) — the `next:` VALUE of one hop through the SAME
89
+ * route renderer the capsule and the board read, so a dispatch refusal's `next:`
90
+ * and the board's `next:` row are byte-identical by construction. Empty string
91
+ * when the hop renders no command (the bare terminal rows). */
92
+ hopCommand(scene, hop, words) {
93
+ return this.#renderer(scene, words).renderHop(hop) ?? "";
94
+ }
95
+ /** lineIdentity(scene) — this line's stable identity facts: the ledger KEY (the
96
+ * branch line's constant, a doc line's declared word) and the judged document (a
97
+ * doc line's own path, the branch line's plan, P21 §4.1). A FACT read, never a
98
+ * judgment: the dispatch verdict belongs to `session/dispatch-authority.ts`, so
99
+ * this accessor only spares its request assembly a second key/doc derivation. */
100
+ lineIdentity(scene) {
101
+ return { key: this.#lineKey(scene), doc: this.#docOf(scene) };
102
+ }
103
+ /** The ONE route renderer of this face — the argv channel, the host spelling and
104
+ * the scene's repo basis (the same instance shape the capsule and the board
105
+ * build), so every `next:` literal this file prints speaks one rendering. */
106
+ #renderer(scene, words) {
107
+ return new RouteRenderer(words, ARGV_CHANNEL, HostDetect.detect(process.env), scene.workspace.root.basis);
108
+ }
149
109
  /** The line's judged document — the doc line's own path, the branch line's plan
150
110
  * (its identity document, P21 §4.1); null off the doc faces. */
151
111
  #docOf(scene) {
@@ -155,19 +115,6 @@ export class CliGate {
155
115
  return scene.planPath;
156
116
  return null;
157
117
  }
158
- /** The dispatch frame's own render target (§5.2's `target` cell) — the fixed
159
- * line's type + stable key (+ the plan fact the branch literal needs). A doc shape
160
- * (the `--spec` channel: phase-spec / overall / single-spec) renders its OWN
161
- * target-type word, never a folded `spec` spelling. */
162
- #routeTargetOf(scene) {
163
- if (scene.target?.kind === "branch")
164
- return { type: "branch", id: "branch", plan: scene.planPath ?? undefined };
165
- if (scene.target?.kind === "spec")
166
- return { type: scene.face.type, id: scene.target.doc };
167
- if (scene.target?.kind === "plan")
168
- return { type: "plan", id: scene.target.doc };
169
- return null;
170
- }
171
118
  /** The requested group ints — the normalized tasks value split. */
172
119
  tasksOf(parsed) {
173
120
  return (parsed.args.tasks ?? "").split(",").map((part) => Number(part));
@@ -185,22 +132,13 @@ export class CliGate {
185
132
  const name = new RoundNaming(scene.workspace).briefName(parsed.args.tasks ?? "");
186
133
  return scene.workspace.writeText(name, content);
187
134
  }
188
- /** The single-target line's current open phase — fix-awaits / re-review / closure
189
- * read from the ledger's SINGLE line-phase judge (`Ledger#linePhase`, D40 — the
190
- * retired gate twin): the gate and the lifecycle's frame frontier now read ONE
191
- * source, never a second walk. */
192
- #linePhase(scene) {
193
- const key = this.#lineKey(scene);
194
- if (key === null)
195
- return null;
196
- return scene.ledger.linePhase(key, scene.face.type);
197
- }
198
135
  /** The line key of a fixed-target face — the line's STABLE key (find #9 · spec
199
136
  * §6.5/§3.7 — `"branch"` per workspace for the branch line; a doc line keys by
200
137
  * its target-type word (`"phase-spec"` / `"overall"` / `"plan"` / `"single-spec"`)
201
138
  * — never the argv path: a moved argv
202
139
  * string must not fork the same line into two ledger rows, resetting its round),
203
- * the lifecycle's own key derivation (run.ts #lineKey). */
140
+ * the lifecycle's own key derivation (run.ts #lineKey). Read here as a line
141
+ * IDENTITY fact; the phase judgment is the authority's. */
204
142
  #lineKey(scene) {
205
143
  if (scene.target?.kind === "branch")
206
144
  return "branch";
@@ -208,28 +146,4 @@ export class CliGate {
208
146
  return scene.face.type;
209
147
  return null;
210
148
  }
211
- /** The doc's live content — readable doc else null. This helper backs the face's
212
- * one remaining doc read site, the revision-aware BLOCK's version token — a read
213
- * fired only when the BLOCK message actually renders (the version is raw doc
214
- * grammar — zero parse dependence: the revision hash is a raw-content digest).
215
- * The gate's own doc read lives in the ledger (Ledger#docLineVerdict — one read
216
- * per reviewGate, the shared comparison). A BLOCK render is a run-failure prose
217
- * channel — never a usage face — so the read is guarded here (null on unreadable),
218
- * not routed through the artifacts readText's usage error. */
219
- #docContent(doc) {
220
- try {
221
- return readFileSync(doc, "utf8");
222
- }
223
- catch {
224
- return null;
225
- }
226
- }
227
- /** The doc's `v<major>.<minor>` version token — the front-matter `version:`
228
- * scalar (the T6 read point: the header version facts ride the typed head
229
- * record — the fence split + `yaml` engine, never a line scan). */
230
- #docVersionOf(content) {
231
- if (content === null)
232
- return null;
233
- return FrontMatterExtractor.split(content).head.version;
234
- }
235
149
  }
package/dist/face/init.js CHANGED
@@ -62,47 +62,106 @@ export class CliInit {
62
62
  this.#runner = opts.runner;
63
63
  this.#header = opts.header;
64
64
  }
65
- /** The ordered step plan for one harness + shape — the ONE flatten source the
66
- * preview and the real run both read. The only branch point between them is
67
- * whether `StepRunner` is called, so a preview can never drift from the run. */
68
- #stepsOf(host, update) {
65
+ /** The ordered step plan for one request — the ONE flatten source the preview and
66
+ * the real run both read. A `recommended === false` request takes the `core` rows
67
+ * only, which is the flag-less face's byte-identical plan; `true` takes the whole
68
+ * table in roster order (the recommended rows carry zero claude commands, so a
69
+ * claude request cannot grow beyond its core span). The only branch point between
70
+ * preview and run is whether `StepRunner` is called, so a preview can never drift
71
+ * from the run. */
72
+ #stepsOf(request) {
69
73
  const steps = [];
70
74
  for (const row of PLUGINS) {
71
- for (const argv of update ? row[host].update : row[host].install) {
72
- steps.push({ packageName: row.name, argv });
75
+ if (!request.recommended && row.tier !== "core")
76
+ continue;
77
+ const column = row[request.host];
78
+ for (const argv of request.shape === "update" ? column.update : column.install) {
79
+ steps.push({ packageName: row.name, argv, tier: row.tier });
73
80
  }
74
81
  }
75
82
  return steps;
76
83
  }
84
+ /** The tier split of one flattened plan — counted off each step's own `tier`.
85
+ * The tier fact travels with the step (§4.1), so no surface below re-reads the
86
+ * roster: `#stepsOf` is the only tier judge in this face. */
87
+ #tierCountsOf(steps) {
88
+ let core = 0;
89
+ for (const step of steps)
90
+ if (step.tier === "core")
91
+ core += 1;
92
+ return { core, recommended: steps.length - core };
93
+ }
94
+ /** The summary line — the flag-less bytes, plus the tier split only when the
95
+ * recommended tier was requested (§5.2). `ok` selects the run face's `ok` word;
96
+ * the preview face adds its dry-run tail instead. */
97
+ #summaryOf(steps, request, ok) {
98
+ const { core, recommended } = this.#tierCountsOf(steps);
99
+ const head = ok ? `init: ${steps.length} steps ok` : `init: ${steps.length} steps`;
100
+ const tier = request.recommended ? ` · ${core} core + ${recommended} recommended` : "";
101
+ const tail = ok ? "" : " — dry run, nothing executed";
102
+ return `${head} (${request.host} · ${request.shape}${tier})${tail}`;
103
+ }
104
+ /** The empty-tier info line — written only when the flag was requested and the
105
+ * flattened plan carries zero recommended steps (today: claude). A silent no-op
106
+ * would read as "installed", so the line is a hard requirement (§5.2). */
107
+ #emptyTierLinesOf(steps, request) {
108
+ if (!request.recommended || this.#tierCountsOf(steps).recommended > 0)
109
+ return [];
110
+ return [`init: no recommended packages for ${request.host}`];
111
+ }
112
+ /** The recommended-tier failure line — one wording per command shape (§5.3): the
113
+ * install form states the core set is already in place, the update form points at
114
+ * the install run instead of repeating the update that just failed. */
115
+ #recommendedFailureOf(step, request) {
116
+ const head = `init: ${step.packageName} is a recommended package — `;
117
+ return request.shape === "update"
118
+ ? `${head}run cdd init --harness=${request.host} --include-recommends without --update first`
119
+ : `${head}the core plugin set is already installed`;
120
+ }
121
+ /** The first-failure report — the pinned failure line, then the recommended-tier
122
+ * line (recommended steps only), then the unchanged update hint. Always exits 1. */
123
+ #reportFailure(steps, index, code, request) {
124
+ const step = steps[index];
125
+ this.#io.stderr(`init[${index + 1}/${steps.length}] · ${step.argv.join(" ")} · exit ${code}\n`);
126
+ if (step.tier === "recommended") {
127
+ this.#io.stderr(`${this.#recommendedFailureOf(step, request)}\n`);
128
+ }
129
+ // The hint is conditional wording — the engine parses zero harness output,
130
+ // so it cannot know whether "not installed" caused this failure.
131
+ if (request.shape === "update") {
132
+ this.#io.stderr(`if the package is not installed, run cdd init --harness=${request.host} without --update first\n`);
133
+ }
134
+ return 1;
135
+ }
136
+ /** The green close — the summary line, then the empty-tier info line when the flag
137
+ * was requested and nothing recommended was planned (§5.2 order: summary first). */
138
+ #writeGreenSummary(steps, request) {
139
+ this.#header(this.#summaryOf(steps, request, true));
140
+ for (const line of this.#emptyTierLinesOf(steps, request))
141
+ this.#header(line);
142
+ }
77
143
  /** Render the step plan the run would execute — one `would run: <argv join>` line
78
144
  * per step, then the summary. Zero spawn, zero write: the runner is never
79
145
  * reached on this path (a preview is a rendering, not an execution). */
80
- preview(host, update) {
81
- const steps = this.#stepsOf(host, update);
146
+ preview(request) {
147
+ const steps = this.#stepsOf(request);
82
148
  return [
83
149
  ...steps.map((step) => `would run: ${step.argv.join(" ")}`),
84
- `init: ${steps.length} steps (${host} · ${update ? "update" : "install"}) — dry run, nothing executed`,
150
+ this.#summaryOf(steps, request, false),
151
+ ...this.#emptyTierLinesOf(steps, request),
85
152
  ];
86
153
  }
87
- /** Run the harness's sequence — 0 all green, 1 the first failed step. */
88
- async run(host, update) {
89
- const steps = this.#stepsOf(host, update);
90
- const total = steps.length;
154
+ /** Run one request — 0 all green, 1 the first failed step. */
155
+ async run(request) {
156
+ const steps = this.#stepsOf(request);
91
157
  for (const [index, step] of steps.entries()) {
92
158
  const ordinal = index + 1;
93
- this.#header(`init[${ordinal}/${total}] ${host} · ${step.packageName} · ${step.argv.slice(1).join(" ")}`);
159
+ this.#header(`init[${ordinal}/${steps.length}] ${request.host} · ${step.packageName} · ${step.argv.slice(1).join(" ")}`);
94
160
  const code = await this.#runner.run(step.argv);
95
- if (code !== 0) {
96
- this.#io.stderr(`init[${ordinal}/${total}] · ${step.argv.join(" ")} · exit ${code}\n`);
97
- // The hint is conditional wording — the engine parses zero harness output,
98
- // so it cannot know whether "not installed" caused this failure.
99
- if (update) {
100
- this.#io.stderr(`if the package is not installed, run cdd init --harness=${host} without --update first\n`);
101
- }
102
- return 1;
103
- }
161
+ if (code !== 0)
162
+ return this.#reportFailure(steps, index, code, request);
104
163
  }
105
- this.#header(`init: ${total} steps ok (${host} · ${update ? "update" : "install"})`);
164
+ this.#writeGreenSummary(steps, request);
106
165
  return 0;
107
166
  }
108
167
  }
@@ -6,8 +6,15 @@
6
6
  // plus a gate, never a second source.
7
7
  //
8
8
  // Row order is a first-class fact — the array order IS the execution order and the
9
- // README row order (upstream dependencies first, kairos last). Object key order
10
- // would not carry that promise, so the roster is an array of rows, not an object.
9
+ // README row order (the core three first: upstream dependencies then kairos; the six
10
+ // recommended capability packages after them). Object key order would not carry that
11
+ // promise, so the roster is an array of rows, not an object.
12
+ //
13
+ // The `tier` field splits the same table in two without a second list: `core` rows
14
+ // are the install contract `cdd init` always runs, `recommended` rows are the pi
15
+ // capability packages the `--include-recommends` flag opts into. Claude Code carries
16
+ // those six capabilities natively, so a recommended row's claude column is an EMPTY
17
+ // array — an empty cell, never a missing column.
11
18
  //
12
19
  // The host vocabulary stays single-sourced in `face/host.ts`: this module declares
13
20
  // no host id list — the row's column set closes over `HostId` (a missing column, or
@@ -21,6 +28,7 @@
21
28
  export const PLUGINS = [
22
29
  {
23
30
  name: "superpowers",
31
+ tier: "core",
24
32
  claude: {
25
33
  install: [
26
34
  ["claude", "plugin", "marketplace", "add", "obra/superpowers-marketplace"],
@@ -38,6 +46,7 @@ export const PLUGINS = [
38
46
  },
39
47
  {
40
48
  name: "mattpocock-skills",
49
+ tier: "core",
41
50
  claude: {
42
51
  install: [
43
52
  ["claude", "plugin", "marketplace", "add", "mattpocock/skills"],
@@ -55,6 +64,7 @@ export const PLUGINS = [
55
64
  },
56
65
  {
57
66
  name: "kairos",
67
+ tier: "core",
58
68
  claude: {
59
69
  install: [
60
70
  ["claude", "plugin", "marketplace", "add", "oscaner/skills"],
@@ -70,4 +80,62 @@ export const PLUGINS = [
70
80
  update: [["pi", "update", "npm:@oscaner-skills/kairos"]],
71
81
  },
72
82
  },
83
+ // The six recommended capability packages — pi-only rows. Claude Code carries file
84
+ // search, todo tracking, structured questioning, web access, background tasks and
85
+ // AGENTS.md injection natively, so the claude column stays EMPTY here: an empty
86
+ // array is the fact, never a placeholder to be filled for symmetry.
87
+ {
88
+ name: "pi-fff",
89
+ tier: "recommended",
90
+ claude: { install: [], update: [] },
91
+ pi: {
92
+ install: [["pi", "install", "npm:@ff-labs/pi-fff"]],
93
+ update: [["pi", "update", "npm:@ff-labs/pi-fff"]],
94
+ },
95
+ },
96
+ {
97
+ name: "rpiv-todo",
98
+ tier: "recommended",
99
+ claude: { install: [], update: [] },
100
+ pi: {
101
+ install: [["pi", "install", "npm:@juicesharp/rpiv-todo"]],
102
+ update: [["pi", "update", "npm:@juicesharp/rpiv-todo"]],
103
+ },
104
+ },
105
+ {
106
+ name: "rpiv-ask-user-question",
107
+ tier: "recommended",
108
+ claude: { install: [], update: [] },
109
+ pi: {
110
+ install: [["pi", "install", "npm:@juicesharp/rpiv-ask-user-question"]],
111
+ update: [["pi", "update", "npm:@juicesharp/rpiv-ask-user-question"]],
112
+ },
113
+ },
114
+ {
115
+ name: "pi-web-access",
116
+ tier: "recommended",
117
+ claude: { install: [], update: [] },
118
+ pi: {
119
+ install: [["pi", "install", "npm:pi-web-access"]],
120
+ update: [["pi", "update", "npm:pi-web-access"]],
121
+ },
122
+ },
123
+ {
124
+ name: "pi-background-tasks",
125
+ tier: "recommended",
126
+ claude: { install: [], update: [] },
127
+ pi: {
128
+ install: [["pi", "install", "npm:pi-background-tasks"]],
129
+ update: [["pi", "update", "npm:pi-background-tasks"]],
130
+ },
131
+ },
132
+ {
133
+ name: "pi-agentsmd",
134
+ tier: "recommended",
135
+ claude: { install: [], update: [] },
136
+ pi: {
137
+ install: [["pi", "install", "npm:pi-agentsmd"]],
138
+ update: [["pi", "update", "npm:pi-agentsmd"]],
139
+ },
140
+ },
73
141
  ];
@@ -17,6 +17,7 @@
17
17
  //
18
18
  // Module-level exports are the class — zero behavior-carrying bare functions.
19
19
  import process from "node:process";
20
+ import { ReviewedIdentity } from "../session/reviewed-identity.js";
20
21
  import { RoundNaming } from "../session/round-naming.js";
21
22
  import { HOSTS, HostDetect } from "./host.js";
22
23
  import { Words } from "./words.js";
@@ -129,22 +130,39 @@ export class Preview {
129
130
  .join(" · ");
130
131
  }
131
132
  /** The ledger writes the round would record — the round RECORD it would append
132
- * (identity: op · cycle · attempt) plus, on a completed review, the
133
- * reviewed-revision write-back. The three legs are `#bookkeep`'s own: the doc line
134
- * binds its document's revision, the wave line its RENDERED brief's, and the
135
- * branch line binds none (its review judges the live tree). */
133
+ * (identity: op · cycle · attempt) plus, when the round lands one, the
134
+ * reviewed-revision write-back. WHICH reviewed input the round binds is the ONE
135
+ * judgment both faces share (`ReviewedIdentity.legOf`): the same phases — review,
136
+ * branch-review, fix — and the same kind → leg mapping. The verdict's
137
+ * `targetAction` is the lifecycle's own input and never rides a dry run: the
138
+ * preview states the write-back a completed round WOULD record. */
136
139
  #recordsOf(frame) {
137
140
  const parts = [
138
141
  `progress.waves["${frame.key}"].rounds += { op: ${this.#naming.op(frame)}, cycle: ${frame.round}, attempt: ${frame.attempt ?? 1} }`,
139
142
  ];
140
- if (frame.phase === "review") {
141
- if (frame.target.kind === "wave")
142
- parts.push("reviewedRevision(brief)");
143
- else if (frame.target.kind === "plan" || frame.target.kind === "spec")
144
- parts.push("reviewedRevision(doc)");
143
+ const leg = ReviewedIdentity.legOf(frame.phase, frame.target.kind);
144
+ if (leg !== null) {
145
+ const stated = this.#reviewedLegOf(leg);
146
+ if (stated !== null)
147
+ parts.push(stated);
145
148
  }
146
149
  return parts.join(" · ");
147
150
  }
151
+ /** The rendered write-back leg of one judgment leg: the wave line states its
152
+ * RENDERED brief, the doc lines their judged document, the branch line its plan
153
+ * document. The branch leg's plan path is an INPUT, not part of the judgment —
154
+ * with no plan fact the preview states no leg rather than an empty identity (the
155
+ * same source the `reads:` row names, and what the real run records too). */
156
+ #reviewedLegOf(leg) {
157
+ switch (leg) {
158
+ case "doc":
159
+ return "reviewedRevision(doc)";
160
+ case "brief":
161
+ return "reviewedRevision(brief)";
162
+ case "branch":
163
+ return this.#scene.planPath === null ? null : "reviewedRevision(doc)";
164
+ }
165
+ }
148
166
  /** The child invocation the real run would spawn — `<HostId> <invoke>`: the host
149
167
  * id then the harness row's invoke argument string verbatim (the binary name is a
150
168
  * separate row column and never rides the invoke value). With no host detected the
@@ -80,6 +80,15 @@ export class RouteRenderer {
80
80
  }
81
81
  return this.#words.routeWord("done");
82
82
  }
83
+ /** renderReason(hop) → the `reason:` VALUE of one derived NextHop — the named fact
84
+ * that selected the hop (one of the seven `NEXT_HOP_REASON` tokens), rendered as a
85
+ * row of its OWN so the dispatchable `next:` literal keeps its exact bytes. A
86
+ * hop-absent round renders no row at all: the caller gates on the SAME hop object
87
+ * its `next:` render reads, so the two rows can never disagree. The station word
88
+ * rides the word table, so the capsule's prefix and this face's value never fork. */
89
+ renderReason(hop) {
90
+ return `${this.#words.station("reason")} ${hop.reason}`;
91
+ }
83
92
  /** render(route, target) → the `next:` value: the complete executable command (a
84
93
  * C5 hop), the pipeline entry (a `handoff`), or the bare terminal word (`done`).
85
94
  * The additive optional RouteTarget supplies the frame's own type + id + plan for
@@ -5,9 +5,10 @@
5
5
  // table with three families served by one class:
6
6
  //
7
7
  // capsule — the capsule-station words: the capsule keys (status · handoff, the
8
- // pinned emit order), the `next:` route station + the stderr stations, the
9
- // status vocabulary and the route classifier words. Every byte the capsule
10
- // emits rides this family — a reorder is a red test.
8
+ // pinned emit order), the two route stations (`next:` + `reason:`) and
9
+ // the stderr stations, the status vocabulary and the route classifier
10
+ // words. Every byte the capsule emits rides this family — a reorder is a
11
+ // red test.
11
12
  // guard — the guard-ban words: the retired-vocabulary ban rows (STALE / GATE /
12
13
  // shape) the guards assert absent from the live faces. This is the ban
13
14
  // table's data-source face — the guard scan releases these rows as its
@@ -53,9 +54,12 @@ export const CAPSULE_WORDS = {
53
54
  separator: " · ",
54
55
  /** The status vocabulary — the five handoff-conclusion values. */
55
56
  status: ["APPROVED", "BLOCKED", "CHANGES_REQUESTED", "REVIEW_FIX", "TIMEOUT"],
56
- /** The route stations — the `: `-suffixed channel anchors. */
57
+ /** The route stations — the `: `-suffixed channel anchors. The two route anchors
58
+ * (`next:` and the `reason:` row that follows it) open the capsule's output;
59
+ * the three stderr anchors open the diagnostics channels. */
57
60
  stations: {
58
61
  next: "next:",
62
+ reason: "reason:",
59
63
  blocked: "CDD_BLOCKED:",
60
64
  warn: "CDD_WARN:",
61
65
  cliMissing: "CDD_CLI_MISSING:",