Skill Tracer
Skills › gstack › gstack › plan-reality.ts

plan-reality.ts

64 lines · scripts/resolvers/plan-reality.ts at 3f79d81

1/**
2 * Plan reality rows (multi-agent wave D1, release promise P5).
3 *
4 * {{PLAN_REALITY_ROWS}} and its variants render lib/plan-reality.ts's one row
5 * table into the plan-review skills and the autoplan phase files, so the rows a
6 * review must carry, the `REALITY:` line a reviewer emits and the check a
7 * parent runs never drift apart:
8 *
9 * {{PLAN_REALITY_ROWS:eng}} / {{PLAN_REALITY_ROWS:ceo}}
10 * the operative block for an interactive plan review (tier 1 row ids, the
11 * bin that prints every applicable row, the line grammar, the miss rule)
12 * {{PLAN_REALITY_ROWS:deep}}
13 * the full table with each row's incident note, for the deep section
14 * {{PLAN_REALITY_ROWS:autoplan:<phase>}}
15 * one checklist item for an autoplan phase file
16 * {{PLAN_REALITY_ROWS:pregate}}
17 * the Pre-Gate rule: unattended a miss is `incomplete`, never a warning
18 * {{PLAN_REALITY_ROWS:summary}}
19 * the Completion Summary line
20 *
21 * The rows themselves are printed by `gstack-plan-reality rows` at run time so
22 * the zero-headroom skills carry the contract, not eighteen rows of prose.
23 */
24import type { TemplateContext } from './types';
25import { REALITY_LINE_SHAPE, REALITY_ROWS, TIER1_ROW_IDS, renderIncidentTable } from '../../lib/plan-reality';
27const BIN = '~/.claude/skills/gstack/bin/gstack-plan-reality';
29function phaseFor(ctx: TemplateContext, arg: string | undefined): string {
30 if (arg && arg !== 'deep' && arg !== 'summary' && arg !== 'pregate' && arg !== 'autoplan') return arg;
31 const m = /^plan-(ceo|eng|devex|design)-review$/.exec(ctx.skillName);
32 return m ? (m[1] === 'devex' ? 'dx' : m[1]) : 'eng';
35export function generatePlanRealityRows(ctx: TemplateContext, args?: string[]): string {
36 const mode = args?.[0];
37 if (mode === 'deep') {
38 return `### Reality rows (why each exists)
40Each row is tied to the incident that earned it; its check is what
41\`${BIN} rows --phase <p> --deep\` prints. Tier 1 rows are required in every review and never
42\`n/a\`; a tier 2 row is required only when the detected scope names its scope (\`--scope\`).
44${renderIncidentTable(REALITY_ROWS)}`;
45 }
46 if (mode === 'summary') return `- Reality rows: ___/___ applicable rows emitted (\`PLAN_REALITY\` line), ___ unverified premises`;
47 if (mode === 'pregate') {
48 return `Reality rows: each phase's \`PLAN_REALITY: … verdict=complete\` from
49\`${BIN} check --phase <ceo|eng> <review-file|->\`. A missing applicable row is \`incomplete\`
50in an unattended run, never a warning; interactive runs follow the repair rule above.`;
51 }
52 if (mode === 'autoplan') {
53 return `Reality rows: the loaded skill's \`REALITY:\` lines, one per applicable row;
54 \`${BIN} check --phase ${args?.[1] ?? 'ceo'} --plan <reviewed snapshot> <review-file|->\` prints \`PLAN_REALITY: … verdict=complete\` before the phase closes
55 (unattended: \`incomplete\` keeps it open).`;
56 }
57 const phase = phaseFor(ctx, mode);
58 return `**Reality rows (required):** run \`${BIN} rows --phase ${phase}\` and work its
59rows (tier 1 always, never \`n/a\`: ${TIER1_ROW_IDS.join(', ')}; tier 2 by detected scope, \`--scope <csv>\`).
60Every row cites a file:line receipt (with no linked issue, deferred-asks is \`pass\`); the premise table counts \`unverified=<n>\`. End with
61one line per row, \`${REALITY_LINE_SHAPE}\`, then run
62\`${BIN} check --phase ${phase} <review-file|->\` (prints \`PLAN_REALITY\`): a missing row is \`incomplete\`
63unattended; interactive runs repair twice, then warn at the gate.`;