@gobing-ai/spur 0.4.1 → 0.4.3

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.
Files changed (159) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/config/config.global.yaml +4 -2
  3. package/config/decisions/maker-liveness.yaml +39 -0
  4. package/config/plugin-scripts.json +0 -4
  5. package/config/rules/README.md +1 -0
  6. package/config/rules/docs/sourced-api-claims.yaml +56 -12
  7. package/config/rules/strict/runtime-boundaries.yaml +7 -0
  8. package/config/script-placement-baseline.json +1 -19
  9. package/config/templates/AGENTS.md +1 -1
  10. package/config/workflows/feature-lifecycle.yaml +46 -1
  11. package/config/workflows/feature-verification.yaml +11 -0
  12. package/config/workflows/wrapup-pipeline.yaml +1 -1
  13. package/package.json +10 -10
  14. package/plugins/sp/README.md +23 -18
  15. package/plugins/sp/agents/super-planner.md +5 -6
  16. package/plugins/sp/agents/super-reviewer.md +43 -0
  17. package/plugins/sp/bunfig.toml +8 -5
  18. package/plugins/sp/commands/dev-review-session.md +2 -1
  19. package/plugins/sp/commands/dev-runall.md +18 -9
  20. package/plugins/sp/hooks/careful-guard.ts +1 -1
  21. package/plugins/sp/hooks/context-post-tool.ts +7 -404
  22. package/plugins/sp/hooks/context-session-start.ts +6 -192
  23. package/plugins/sp/hooks/context-session-stop.ts +6 -91
  24. package/plugins/sp/hooks/pi/guard-extension.ts +26 -12
  25. package/plugins/sp/hooks/task-write-guard.ts +1 -1
  26. package/plugins/sp/{hooks → lib}/agent-hint.ts +1 -1
  27. package/plugins/sp/lib/context-owner.ts +56 -0
  28. package/plugins/sp/lib/context-post-tool.ts +432 -0
  29. package/plugins/sp/lib/context-session-start.ts +214 -0
  30. package/plugins/sp/lib/context-session-stop.ts +196 -0
  31. package/plugins/sp/lib/dogfood-pipeline.ts +265 -0
  32. package/plugins/sp/lib/dogfood-report.ts +278 -0
  33. package/plugins/sp/lib/idea-handoff.generated.mjs +6 -4
  34. package/plugins/sp/lib/inline-run-app.ts +40 -0
  35. package/plugins/sp/lib/inline-run.generated.d.mts +3 -3
  36. package/plugins/sp/lib/inline-run.generated.mjs +1361 -87
  37. package/plugins/sp/lib/plan-projection.generated.d.mts +169 -0
  38. package/plugins/sp/lib/plan-projection.generated.mjs +704 -1
  39. package/plugins/sp/lib/quality-gate.generated.d.mts +0 -12
  40. package/plugins/sp/lib/quality-gate.generated.mjs +62 -231
  41. package/plugins/sp/lib/residual-scan.generated.d.mts +7 -1
  42. package/plugins/sp/lib/residual-scan.generated.mjs +71 -6
  43. package/plugins/sp/lib/run-summary-core.ts +34 -370
  44. package/plugins/sp/lib/transcript.ts +37 -200
  45. package/plugins/sp/plugin.json +1 -1
  46. package/plugins/sp/references/roles.md +1 -1
  47. package/plugins/sp/scripts/batch-plan.mjs +740 -1
  48. package/plugins/sp/scripts/batch-plan.ts +48 -3
  49. package/plugins/sp/scripts/batch-preflight.mjs +23 -1
  50. package/plugins/sp/scripts/batch-preflight.ts +35 -295
  51. package/plugins/sp/scripts/daily-summary/daily-summary.mjs +108 -87
  52. package/plugins/sp/scripts/daily-summary/daily-summary.ts +111 -104
  53. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +2 -1
  54. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +7 -265
  55. package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +3 -0
  56. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +6 -272
  57. package/plugins/sp/scripts/feature-verification-steps.mjs +7 -123
  58. package/plugins/sp/scripts/feature-verification-steps.ts +29 -181
  59. package/plugins/sp/scripts/inline-run-dispatch.mjs +27 -26
  60. package/plugins/sp/scripts/inline-run-dispatch.ts +1 -21
  61. package/plugins/sp/scripts/inline-run-setup.mjs +158 -120
  62. package/plugins/sp/scripts/inline-run-setup.ts +1 -21
  63. package/plugins/sp/scripts/pr-reviewing.mjs +19 -5
  64. package/plugins/sp/scripts/pr-reviewing.ts +34 -9
  65. package/plugins/sp/scripts/quality-gate.mjs +38 -208
  66. package/plugins/sp/scripts/residual-scan.mjs +73 -6
  67. package/plugins/sp/scripts/residual-scan.ts +8 -5
  68. package/plugins/sp/scripts/run-summary.mjs +160 -95
  69. package/plugins/sp/scripts/run-summary.ts +7 -5
  70. package/plugins/sp/scripts/session-timeline.mjs +57 -29
  71. package/plugins/sp/scripts/session-timeline.ts +4 -18
  72. package/plugins/sp/scripts/task-diffstat.mjs +43 -30
  73. package/plugins/sp/scripts/task-diffstat.ts +40 -71
  74. package/plugins/sp/skills/code-implementation/SKILL.md +7 -1
  75. package/plugins/sp/skills/code-verification/references/secu-review.md +2 -1
  76. package/plugins/sp/skills/code-verification/references/verdict-schema.md +4 -0
  77. package/plugins/sp/skills/dogfood-testing/SKILL.md +2 -2
  78. package/plugins/sp/skills/indexed-context/SKILL.md +14 -7
  79. package/plugins/sp/skills/next-feature/SKILL.md +1 -1
  80. package/plugins/sp/skills/parallel-execution/SKILL.md +2 -2
  81. package/plugins/sp/skills/parallel-execution/references/dispatch-surface.md +2 -2
  82. package/plugins/sp/skills/parallel-execution/references/fan-out-patterns.md +2 -2
  83. package/plugins/sp/skills/pr-reviewing/SKILL.md +7 -3
  84. package/plugins/sp/skills/session-review/SKILL.md +5 -3
  85. package/plugins/sp/skills/source-driven-development/SKILL.md +7 -4
  86. package/plugins/sp/skills/spur-cli/references/builder.md +3 -2
  87. package/plugins/sp/skills/spur-cli/references/decision.md +40 -8
  88. package/plugins/sp/skills/spur-cli/references/features.md +46 -5
  89. package/plugins/sp/skills/spur-cli/references/projects.md +7 -5
  90. package/plugins/sp/skills/spur-dev/SKILL.md +2 -0
  91. package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +27 -0
  92. package/plugins/sp/skills/spur-dev/references/dev-operations.md +2 -3
  93. package/plugins/sp/skills/spur-dev/references/execution-batch-report.md +6 -1
  94. package/plugins/sp/skills/spur-dev/references/execution-batch.md +56 -7
  95. package/plugins/sp/skills/spur-dev/references/execution-parallel-isolation.md +4 -1
  96. package/plugins/sp/skills/spur-dev/references/execution-worktree-landing.md +22 -0
  97. package/plugins/sp/skills/spur-dev/references/execution-worktree-setup.md +14 -0
  98. package/plugins/sp/skills/spur-dev/references/flag-glossary.md +13 -11
  99. package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +37 -25
  100. package/spur.js +89792 -76992
  101. package/web/_astro/{BoardApp.D66k_s_T.js → BoardApp.5IIl2O-z.js} +1 -1
  102. package/web/_astro/BoardApp.Drnx-KeM.js +324 -0
  103. package/web/_astro/TaskDetail.Ci4LNn9S.js +1 -0
  104. package/web/_astro/{arc._BUadrdH.js → arc.j2EVkYVd.js} +1 -1
  105. package/web/_astro/{architectureDiagram-3BPJPVTR.Dh7xS1Pp.js → architectureDiagram-3BPJPVTR.DZWSFqEG.js} +1 -1
  106. package/web/_astro/{blockDiagram-GPEHLZMM.DFDVpfXm.js → blockDiagram-GPEHLZMM.DE6GpXCN.js} +1 -1
  107. package/web/_astro/{c4Diagram-AAUBKEIU.V7_3_glh.js → c4Diagram-AAUBKEIU.DoVR1G6B.js} +1 -1
  108. package/web/_astro/channel.DmdDxGsq.js +1 -0
  109. package/web/_astro/{chunk-2J33WTMH.De1yx7Jz.js → chunk-2J33WTMH.Do6-Gbyf.js} +1 -1
  110. package/web/_astro/{chunk-4BX2VUAB.BDhHFuxx.js → chunk-4BX2VUAB.BYV1HGHx.js} +1 -1
  111. package/web/_astro/{chunk-55IACEB6.DDLkWnmC.js → chunk-55IACEB6.CvI1zkrc.js} +1 -1
  112. package/web/_astro/{chunk-727SXJPM.CwfiLnA7.js → chunk-727SXJPM.DNGSCRlX.js} +1 -1
  113. package/web/_astro/{chunk-AQP2D5EJ.CtGDmUnM.js → chunk-AQP2D5EJ.DXhhgT5z.js} +1 -1
  114. package/web/_astro/{chunk-FMBD7UC4.BOLjpw73.js → chunk-FMBD7UC4.dzkRKP2u.js} +1 -1
  115. package/web/_astro/{chunk-ND2GUHAM.BDhQls6O.js → chunk-ND2GUHAM.DujGLeEf.js} +1 -1
  116. package/web/_astro/{chunk-QZHKN3VN.76qBynDF.js → chunk-QZHKN3VN.BWtIT3ZU.js} +1 -1
  117. package/web/_astro/{classDiagram-4FO5ZUOK.N0mpPHT0.js → classDiagram-4FO5ZUOK.DyApg0Nn.js} +1 -1
  118. package/web/_astro/{classDiagram-v2-Q7XG4LA2.N0mpPHT0.js → classDiagram-v2-Q7XG4LA2.DyApg0Nn.js} +1 -1
  119. package/web/_astro/{cose-bilkent-S5V4N54A.CKknFfjB.js → cose-bilkent-S5V4N54A.DJQB-u_l.js} +1 -1
  120. package/web/_astro/{cynefin-OW5HDTMX.Cw3ZWBAh.js → cynefin-OW5HDTMX.bi3D_siV.js} +1 -1
  121. package/web/_astro/{dagre-BM42HDAG.D3yIKCRD.js → dagre-BM42HDAG.C-f7TrRg.js} +1 -1
  122. package/web/_astro/{diagram-2AECGRRQ.D51dO83Z.js → diagram-2AECGRRQ.DrPfjHQB.js} +1 -1
  123. package/web/_astro/{diagram-5GNKFQAL.Bb-FViDj.js → diagram-5GNKFQAL.C9S4WUHO.js} +1 -1
  124. package/web/_astro/{diagram-KO2AKTUF.D3mN8S6x.js → diagram-KO2AKTUF.Dzzye8QH.js} +1 -1
  125. package/web/_astro/{diagram-LMA3HP47.dMMyPcbJ.js → diagram-LMA3HP47.DX-LRiof.js} +1 -1
  126. package/web/_astro/{diagram-OG6HWLK6.AzbvzY4C.js → diagram-OG6HWLK6.Z-kAKwIz.js} +1 -1
  127. package/web/_astro/{erDiagram-TEJ5UH35.BR5I4OZb.js → erDiagram-TEJ5UH35.D6dyClSv.js} +1 -1
  128. package/web/_astro/{flowDiagram-I6XJVG4X.DFqvhGkn.js → flowDiagram-I6XJVG4X.Cx3q2cxD.js} +1 -1
  129. package/web/_astro/{ganttDiagram-6RSMTGT7.ByJbhH6J.js → ganttDiagram-6RSMTGT7.DU3gH6CT.js} +1 -1
  130. package/web/_astro/{gitGraphDiagram-PVQCEYII.CInHjQR3.js → gitGraphDiagram-PVQCEYII.ISmCnJ87.js} +1 -1
  131. package/web/_astro/index.Do2lLdgo.css +1 -0
  132. package/web/_astro/{infoDiagram-5YYISTIA.Cm0dGVjJ.js → infoDiagram-5YYISTIA.DR6_iNOK.js} +1 -1
  133. package/web/_astro/{ishikawaDiagram-YF4QCWOH.C3nOP6Sj.js → ishikawaDiagram-YF4QCWOH.D7wY-ZGA.js} +1 -1
  134. package/web/_astro/{journeyDiagram-JHISSGLW.4IvLa2MW.js → journeyDiagram-JHISSGLW.DkP9-WK8.js} +1 -1
  135. package/web/_astro/{kanban-definition-UN3LZRKU.DS87Cl-k.js → kanban-definition-UN3LZRKU.wtgY98M2.js} +1 -1
  136. package/web/_astro/{linear.MzmRrNER.js → linear.CI6djNi7.js} +1 -1
  137. package/web/_astro/{mermaid.core.fK-WNswS.js → mermaid.core.CuQPxS8b.js} +4 -4
  138. package/web/_astro/{mindmap-definition-RKZ34NQL.BqipOHhY.js → mindmap-definition-RKZ34NQL.5HNIEG7R.js} +1 -1
  139. package/web/_astro/{pieDiagram-4H26LBE5.0nBiPqFG.js → pieDiagram-4H26LBE5.CchhDFjE.js} +1 -1
  140. package/web/_astro/{quadrantDiagram-W4KKPZXB.Szj7Zpx5.js → quadrantDiagram-W4KKPZXB.PYXXJPSJ.js} +1 -1
  141. package/web/_astro/{requirementDiagram-4Y6WPE33.D4UR6TWo.js → requirementDiagram-4Y6WPE33.cUQuNAKU.js} +1 -1
  142. package/web/_astro/{sankeyDiagram-5OEKKPKP.DAE7BdOs.js → sankeyDiagram-5OEKKPKP.BO7MnRIA.js} +1 -1
  143. package/web/_astro/{sequenceDiagram-3UESZ5HK.BP9ZVq25.js → sequenceDiagram-3UESZ5HK.D9bElyD6.js} +1 -1
  144. package/web/_astro/{stateDiagram-AJRCARHV.BQW7mIxk.js → stateDiagram-AJRCARHV.DhGdRz7I.js} +1 -1
  145. package/web/_astro/{stateDiagram-v2-BHNVJYJU.PbK4nDih.js → stateDiagram-v2-BHNVJYJU.5GvLeAoL.js} +1 -1
  146. package/web/_astro/{timeline-definition-PNZ67QCA.Ci_GvUpo.js → timeline-definition-PNZ67QCA.LtAT9haM.js} +1 -1
  147. package/web/_astro/{vennDiagram-CIIHVFJN.DNw1Y5qx.js → vennDiagram-CIIHVFJN.DRth1yLA.js} +1 -1
  148. package/web/_astro/{wardleyDiagram-YWT4CUSO.CwlkaaNe.js → wardleyDiagram-YWT4CUSO.h9MlZfcr.js} +1 -1
  149. package/web/_astro/{xychartDiagram-2RQKCTM6.MI6ZuiH_.js → xychartDiagram-2RQKCTM6.DHqy9DYA.js} +1 -1
  150. package/web/index.html +2 -2
  151. package/config/proportional-route-table.ts +0 -155
  152. package/plugins/sp/commands/dev-parallel.md +0 -37
  153. package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
  154. package/web/_astro/BoardApp.D6sjAJr_.js +0 -324
  155. package/web/_astro/TaskDetail.BynLnMNc.js +0 -1
  156. package/web/_astro/channel.DZVfto-r.js +0 -1
  157. package/web/_astro/index.COh_kBxN.css +0 -1
  158. /package/plugins/sp/{hooks → lib}/destructive-policy.ts +0 -0
  159. /package/plugins/sp/{hooks → lib}/task-file-policy.ts +0 -0
@@ -9,6 +9,10 @@
9
9
  * Modes:
10
10
  * waves --tasks <file> file: JSON array of {wbs, name}; prints `{ waves: [...] }` — waves
11
11
  * of 24 tasks as A Prepare batch + A1..A4 + B..Y task rows + Z Batch report.
12
+ * order --tasks <file> [--concurrency <n>]
13
+ * file: JSON array of {wbs, dependencies?, files?}; prints the scheduleBatch
14
+ * result `{ order, waves, cycle, overlaps, mode, reason }` (dev-runall §2.4
15
+ * order + the --mode auto recommendation). A cycle is data, not an error.
12
16
  * task-children --letter <A-Z> --plan <file>
13
17
  * file: a `workflow show --format todo --json` payload (or a bare plan
14
18
  * array); prints the task's phase digits as a JSON array.
@@ -16,13 +20,13 @@
16
20
  * `node batch-plan.mjs` (committed twin) — keep the twin in lockstep.
17
21
  */
18
22
  import { readFileSync } from 'node:fs';
19
- import type { BatchTask, PhasedPlanItem } from '../lib/plan-projection.generated.mjs';
20
- import { buildBatchPlan, taskPhaseChildren } from '../lib/plan-projection.generated.mjs';
23
+ import type { BatchTask, PhasedPlanItem, ScheduleTask } from '../lib/plan-projection.generated.mjs';
24
+ import { buildBatchPlan, scheduleBatch, taskPhaseChildren } from '../lib/plan-projection.generated.mjs';
21
25
 
22
26
  export * from '../lib/plan-projection.generated.mjs';
23
27
 
24
28
  export const BATCH_PLAN_USAGE =
25
- 'usage: batch-plan.ts waves --tasks <tasks.json> | task-children --letter <A-Z> --plan <plan.json>';
29
+ 'usage: batch-plan.ts waves --tasks <tasks.json> | order --tasks <tasks.json> [--concurrency <n>] | task-children --letter <A-Z> --plan <plan.json>';
26
30
 
27
31
  function readJsonFile(path: string): unknown {
28
32
  return JSON.parse(readFileSync(path, 'utf8'));
@@ -37,6 +41,20 @@ function isBatchTask(value: unknown): value is BatchTask {
37
41
  );
38
42
  }
39
43
 
44
+ function isStringArray(value: unknown): value is string[] {
45
+ return Array.isArray(value) && value.every((v) => typeof v === 'string');
46
+ }
47
+
48
+ function isScheduleTask(value: unknown): value is ScheduleTask {
49
+ if (typeof value !== 'object' || value === null) return false;
50
+ const t = value as ScheduleTask;
51
+ return (
52
+ typeof t.wbs === 'string' &&
53
+ (t.dependencies === undefined || isStringArray(t.dependencies)) &&
54
+ (t.files === undefined || isStringArray(t.files))
55
+ );
56
+ }
57
+
40
58
  export function main(argv: string[]): number {
41
59
  const mode = argv[0];
42
60
  if (mode === 'waves') {
@@ -60,6 +78,33 @@ export function main(argv: string[]): number {
60
78
  process.stdout.write(`${JSON.stringify({ waves: buildBatchPlan(tasks) })}\n`);
61
79
  return 0;
62
80
  }
81
+ if (mode === 'order') {
82
+ let tasksPath = '';
83
+ let concurrency = 2;
84
+ for (let i = 1; i + 1 < argv.length; i += 2) {
85
+ if (argv[i] === '--tasks') tasksPath = argv[i + 1] ?? '';
86
+ else if (argv[i] === '--concurrency') concurrency = Number(argv[i + 1]);
87
+ }
88
+ if (tasksPath === '' || !Number.isInteger(concurrency) || concurrency < 1) {
89
+ process.stderr.write(`${BATCH_PLAN_USAGE}\n`);
90
+ return 2;
91
+ }
92
+ let tasks: unknown;
93
+ try {
94
+ tasks = readJsonFile(tasksPath);
95
+ } catch (error) {
96
+ process.stderr.write(
97
+ `batch-plan: cannot read ${tasksPath} — ${error instanceof Error ? error.message : String(error)}\n`,
98
+ );
99
+ return 1;
100
+ }
101
+ if (!Array.isArray(tasks) || !tasks.every(isScheduleTask)) {
102
+ process.stderr.write('batch-plan: --tasks file must be a JSON array of {wbs, dependencies?, files?}\n');
103
+ return 1;
104
+ }
105
+ process.stdout.write(`${JSON.stringify(scheduleBatch(tasks, { concurrency }))}\n`);
106
+ return 0;
107
+ }
63
108
  if (mode === 'task-children') {
64
109
  let letter = '';
65
110
  let planPath = '';
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from "node:module";
3
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
 
5
- // plugins/sp/scripts/batch-preflight.ts
5
+ // plugins/sp/lib/plan-projection.generated.mjs
6
6
  var NON_ABORTING_PREFLIGHT_CODES = new Set([
7
7
  "L4.scenario-unverified",
8
8
  "L4.verifying-incomplete-tasks"
@@ -181,6 +181,28 @@ function preflightTask(input) {
181
181
  }
182
182
  return { action: "run", code: "OK", reason: `preflight clear — launch task-pipeline for ${input.wbs}` };
183
183
  }
184
+ var OPERATOR_TOOLS = new Set(["AskUserQuestion", "ask_user_question"]);
185
+ var SHELL_TOOLS = new Set(["bash", "shell", "exec", "exec_command", "run_command", "command"]);
186
+ var SUBAGENT_TOOLS = new Set(["agent", "task", "invoke_subagent", "subagent", "dispatch_agent"]);
187
+ var LOWERCASE_OPERATOR_TOOLS = new Set(["askuserquestion", "ask_user_question"]);
188
+ var SENSITIVE_PREFIXES = ["drizzle/", "packages/config/", ".github/", "plugins/sp/hooks/"];
189
+ var SENSITIVE_GLOBS = ["apps/server/src/**/auth*", "**/*secret*", "**/*.sql"];
190
+ function globToRegex(glob) {
191
+ const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("**/", "\x00").replaceAll("**", "\x01").replaceAll("*", "[^/]*").replaceAll("\x00", "(?:.*/)?").replaceAll("\x01", ".*");
192
+ return new RegExp(`^${escaped}$`, "s");
193
+ }
194
+ var SENSITIVE_MATCHERS = [
195
+ ...SENSITIVE_PREFIXES.map((prefix) => ({
196
+ label: prefix,
197
+ test: (path) => path.startsWith(prefix)
198
+ })),
199
+ ...SENSITIVE_GLOBS.map((glob) => {
200
+ const regex = globToRegex(glob);
201
+ return { label: glob, test: (path) => regex.test(path) };
202
+ })
203
+ ];
204
+
205
+ // plugins/sp/scripts/batch-preflight.ts
184
206
  function recoveryHint(status, wbs) {
185
207
  const st = (status ?? "").toLowerCase();
186
208
  switch (st) {
@@ -1,303 +1,43 @@
1
1
  /**
2
- * batch-preflight — pure TABLE A STOP evaluation for sp:super-planner (task 0279).
2
+ * batch-preflight — planner adapter over the pure admission policy (task 0279; task 1176 move).
3
3
  *
4
- * Mirrors routing-table.md TABLE A hard-STOP preconditions so the batch driver can
5
- * skip doomed pipeline launches without spawning a Skill subprocess. Happy-path
6
- * statuses still return `action: 'run'` — the caller launches task-pipeline.yaml
7
- * verbatim (preflight is readiness only, never a pipeline substitute).
4
+ * The decisions — TABLE A STOP evaluation, quick command-aware readiness and feature-finding
5
+ * classification — are application policy in `packages/app/src/services/planning-admission.ts`,
6
+ * reached through the generated pure bundle. This entry keeps what belongs to the planner: the CLI
7
+ * surface, its argv/usage/error contracts, and the one-shot recovery hints the batch driver prints.
8
8
  *
9
- * Recovery hints (one-shot after FAIL) map stuck statuses to a single /sp:dev-* hop
10
- * per TABLE A; the batch driver prints or dispatches at most once per WBS.
9
+ * Recovery hints (one-shot after FAIL) map stuck statuses to a single /sp:dev-* hop per TABLE A; the
10
+ * batch driver prints or dispatches at most once per WBS.
11
11
  */
12
12
 
13
- export type TaskStatus = 'backlog' | 'todo' | 'wip' | 'testing' | 'blocked' | 'done' | 'cancelled' | string;
14
-
15
- export interface PreflightInput {
16
- wbs: string;
17
- status: TaskStatus;
18
- /** Frontmatter dependencies[] WBS list. */
19
- dependencies: string[];
20
- /** Status of each dependency WBS (from spur task show). Missing → treated as unmet. */
21
- depStatuses: Record<string, string>;
22
- }
23
-
24
- export type PreflightResult =
25
- | { action: 'run'; code?: string; reason?: string }
26
- | { action: 'skip'; code: string; reason: string; unmetDeps?: string[] };
27
-
28
- // ── Feature preflight classification (1132 R4) ──────────────────────────────
29
- /**
30
- * 1132 R4: Codes that are expected pre-run states under `feature check --strict`
31
- * and must not abort the batch. Structured classification in code (replaces prose-only).
32
- */
33
- export const NON_ABORTING_PREFLIGHT_CODES = new Set<string>([
34
- 'L4.scenario-unverified',
35
- 'L4.verifying-incomplete-tasks',
36
- ]);
37
-
38
- export interface FeaturePreflightFinding {
39
- layer: string;
40
- code: string;
41
- severity: string;
42
- message: string;
43
- section?: string;
44
- }
45
-
46
- export interface FeaturePreflightClassification {
47
- aborting: FeaturePreflightFinding[];
48
- nonAborting: FeaturePreflightFinding[];
49
- shouldAbort: boolean;
50
- }
51
-
52
- export function classifyFeaturePreflightFindings(findings: FeaturePreflightFinding[]): FeaturePreflightClassification {
53
- const aborting: FeaturePreflightFinding[] = [];
54
- const nonAborting: FeaturePreflightFinding[] = [];
55
- for (const f of findings) {
56
- if (f.severity === 'error') {
57
- if (NON_ABORTING_PREFLIGHT_CODES.has(f.code)) {
58
- nonAborting.push(f);
59
- } else {
60
- aborting.push(f);
61
- }
62
- } else {
63
- nonAborting.push(f);
64
- }
65
- }
66
- return {
67
- aborting,
68
- nonAborting,
69
- shouldAbort: aborting.length > 0,
70
- };
71
- }
72
-
73
- // ── Command-aware quick readiness (task 0814 R2) ──────────────────────────────
74
- // Read-only admission decision for the requested dev operation. Distinguishes
75
- // runnable / needs-refinement / blocked / skipped / invalid outcomes without
76
- // LLM dispatch, full tests/lint, live-data probes, feature mutation, or
77
- // corpus-wide relational checking. Refinement gaps are work to do, not errors.
78
-
79
- export type ReadinessOperation = 'run' | 'refine' | 'verify';
80
-
81
- export interface QuickReadinessInput {
82
- wbs: string;
83
- status: TaskStatus;
84
- operation: ReadinessOperation;
85
- /** Frontmatter dependencies[] WBS list (run only). */
86
- dependencies?: string[];
87
- /** Status of each dependency WBS; missing → treated as unmet (run only). */
88
- depStatuses?: Record<string, string>;
89
- /** Size of the status-filtered candidate set after the selector resolved; 0 = empty set. */
90
- filteredCount?: number;
91
- /** Required planning sections for this variant+status; empty = not applicable. */
92
- requiredSections?: string[];
93
- /** Sections that are actually present (non-placeholder) in the task. */
94
- presentSections?: string[];
95
- /** L1/L2/L3 content-policy findings keyed by section; empty = clean. */
96
- sectionFindings?: Record<string, string>;
97
- /** Verify only: re-verification semantics (--force) — never a dirty-tree bypass. */
98
- force?: boolean;
99
- }
100
-
101
- export type QuickReadinessResult =
102
- | { action: 'runnable'; code: string; reason: string }
103
- | { action: 'needs-refinement'; code: string; reason: string; gaps: string[] }
104
- | { action: 'blocked'; code: string; reason: string; unmetDeps?: string[] }
105
- | { action: 'skipped'; code: string; reason: string }
106
- | { action: 'invalid'; code: string; reason: string };
107
-
108
- /**
109
- * Evaluate quick readiness for a requested dev operation (0814 R2). Read-only:
110
- * no model, no full tests/lint, no live-data probe, no feature mutation, no
111
- * corpus-wide relational check. An empty status-filtered set is `skipped`
112
- * (mirrors the zero-task rule), never an error. Refinement gaps under `refine`
113
- * are work to do, so they do not block; under `run` they are `needs-refinement`.
114
- */
115
- export function quickReadiness(input: QuickReadinessInput): QuickReadinessResult {
116
- const status = (input.status ?? '').toLowerCase();
117
- const operation = input.operation;
118
-
119
- if (operation !== 'run' && operation !== 'refine' && operation !== 'verify') {
120
- return {
121
- action: 'invalid',
122
- code: 'IV',
123
- reason: `quick-readiness: unknown operation '${operation}' (${input.wbs})`,
124
- };
125
- }
126
-
127
- if (input.filteredCount !== undefined) {
128
- if (input.filteredCount < 0) {
129
- return {
130
- action: 'invalid',
131
- code: 'IV',
132
- reason: `quick-readiness: invalid negative filtered count '${input.filteredCount}' (${input.wbs})`,
133
- };
134
- }
135
- if (input.filteredCount === 0) {
136
- return {
137
- action: 'skipped',
138
- code: 'EMPTY',
139
- reason: `quick-readiness: empty status-filtered set — nothing to ${operation} (${input.wbs})`,
140
- };
141
- }
142
- }
143
-
144
- if (status === 'cancelled' || status === 'done') {
145
- // verify --force re-verification (R2 AC): an already-verified terminal task
146
- // is re-checked, not skipped — but force never bypasses a dirty tree or the
147
- // owning gates; it only re-admits a terminal task for re-verification.
148
- if (operation === 'verify' && input.force === true) {
149
- return {
150
- action: 'runnable',
151
- code: 'FORCE',
152
- reason: `quick-readiness: verify --force re-verification of ${status} task ${input.wbs}`,
153
- };
154
- }
155
- return {
156
- action: 'skipped',
157
- code: status === 'done' ? 'DONE' : 'CANCELLED',
158
- reason: `quick-readiness: already ${status} — no ${operation} hop (${input.wbs})`,
159
- };
160
- }
161
-
162
- if (status === 'blocked') {
163
- return {
164
- action: 'blocked',
165
- code: 'BLK',
166
- reason: `quick-readiness: blocked — human/handover first (${input.wbs})`,
167
- };
168
- }
169
-
170
- // Unmet out-of-set dependency is a block for the operation that needs it.
171
- if (operation === 'run' && input.dependencies && input.dependencies.length > 0) {
172
- const unmet = input.dependencies.filter((d) => (input.depStatuses?.[d] ?? 'missing').toLowerCase() !== 'done');
173
- if (unmet.length > 0) {
174
- return {
175
- action: 'blocked',
176
- code: 'DEP',
177
- reason: `quick-readiness: unmet deps — ${unmet.join(', ')} (${input.wbs})`,
178
- unmetDeps: unmet,
179
- };
180
- }
181
- }
182
-
183
- const required = input.requiredSections ?? [];
184
- const present = input.presentSections ?? [];
185
- // A required section is a gap when it is absent from the present-set OR carries a
186
- // content-policy finding (the caller-supplied `sectionFindings` from the matrix /
187
- // `TaskCheckService.checkContentPolicy`). This lets the function detect a gap itself
188
- // rather than depending on the caller to pre-enumerate every missing section.
189
- const gaps = required.filter((s) => {
190
- const finding = input.sectionFindings?.[s];
191
- return !present.includes(s) || (finding !== undefined && finding !== '');
192
- });
193
-
194
- // refine: missing/incomplete planning sections are the work, not a failure.
195
- if (operation === 'refine') {
196
- if (status !== 'backlog' && status !== 'todo') {
197
- return {
198
- action: 'skipped',
199
- code: 'NONPLAN',
200
- reason: `quick-readiness: refine targets backlog/todo only, not '${status}' (${input.wbs})`,
201
- };
202
- }
203
- return {
204
- action: 'runnable',
205
- code: 'OK',
206
- reason: `quick-readiness: refine ready for ${input.wbs} (${gaps.length} planning gap(s) to fill)`,
207
- };
208
- }
209
-
210
- if (operation === 'verify') {
211
- if (status !== 'testing' && status !== 'wip') {
212
- return {
213
- action: 'invalid',
214
- code: 'NOVERIFY',
215
- reason: `quick-readiness: verify needs testing/wip, not '${status}' (${input.wbs})`,
216
- };
217
- }
218
- return {
219
- action: 'runnable',
220
- code: 'OK',
221
- reason: `quick-readiness: verify ready for ${input.wbs}`,
222
- };
223
- }
224
-
225
- // run: implementation admission. Eligible statuses are todo/wip/testing;
226
- // a backlog task needs the chain's auto-promotion first (step 0).
227
- if (status !== 'todo' && status !== 'wip' && status !== 'testing') {
228
- return {
229
- action: 'invalid',
230
- code: 'NORUN',
231
- reason: `quick-readiness: run needs todo/wip/testing, not '${status}' (${input.wbs})`,
232
- };
233
- }
234
- if (gaps.length > 0) {
235
- return {
236
- action: 'needs-refinement',
237
- code: 'REFINE',
238
- reason: `quick-readiness: implementation sections incomplete (${input.wbs})`,
239
- gaps,
240
- };
241
- }
242
- return {
243
- action: 'runnable',
244
- code: 'OK',
245
- reason: `quick-readiness: run ready for ${input.wbs}`,
246
- };
247
- }
248
-
249
- /**
250
- * Evaluate whether the batch should launch task-pipeline.yaml for this WBS.
251
- * STOP codes align with routing-table TABLE A row ids (A2, A7, A8, A9).
252
- */
253
- export function preflightTask(input: PreflightInput): PreflightResult {
254
- const status = (input.status ?? '').toLowerCase();
255
- const deps = input.dependencies ?? [];
256
- const depStatuses = input.depStatuses ?? {};
257
-
258
- if (status === 'cancelled') {
259
- return {
260
- action: 'skip',
261
- code: 'A9',
262
- reason: `dev-next: cancelled — nothing to advance (${input.wbs})`,
263
- };
264
- }
265
-
266
- if (status === 'done') {
267
- return {
268
- action: 'skip',
269
- code: 'A8',
270
- reason: `dev-next: already done — batch does not auto-wrap (${input.wbs})`,
271
- };
272
- }
273
-
274
- if (status === 'blocked') {
275
- return {
276
- action: 'skip',
277
- code: 'A7',
278
- reason: `dev-next: blocked — do not launch pipeline; human/handover first (${input.wbs})`,
279
- };
280
- }
281
-
282
- // A2: todo/backlog with any dependency not done (mirrors TABLE A2 / ready filter).
283
- if (status === 'todo' || status === 'backlog') {
284
- const unmet = deps.filter((d) => {
285
- const st = (depStatuses[d] ?? 'missing').toLowerCase();
286
- return st !== 'done';
287
- });
288
- if (unmet.length > 0) {
289
- return {
290
- action: 'skip',
291
- code: 'A2',
292
- reason: `dev-next: blocked by deps — unmet: ${unmet.join(', ')} (${input.wbs})`,
293
- unmetDeps: unmet,
294
- };
295
- }
296
- }
297
-
298
- // Ready for pipeline: backlog/todo (deps ok), wip, testing.
299
- return { action: 'run', code: 'OK', reason: `preflight clear — launch task-pipeline for ${input.wbs}` };
300
- }
13
+ import {
14
+ classifyFeaturePreflightFindings,
15
+ type FeaturePreflightClassification,
16
+ type FeaturePreflightFinding,
17
+ NON_ABORTING_PREFLIGHT_CODES,
18
+ type PreflightInput,
19
+ type PreflightResult,
20
+ preflightTask,
21
+ type QuickReadinessInput,
22
+ type QuickReadinessResult,
23
+ quickReadiness,
24
+ type ReadinessOperation,
25
+ type TaskStatus,
26
+ } from '../lib/plan-projection.generated.mjs';
27
+
28
+ export type {
29
+ FeaturePreflightClassification,
30
+ FeaturePreflightFinding,
31
+ PreflightInput,
32
+ PreflightResult,
33
+ QuickReadinessInput,
34
+ QuickReadinessResult,
35
+ ReadinessOperation,
36
+ TaskStatus,
37
+ };
38
+ // R1: existing plugin callers keep their import path — the moved names are re-exported, not relocated
39
+ // out from under them.
40
+ export { classifyFeaturePreflightFindings, NON_ABORTING_PREFLIGHT_CODES, preflightTask, quickReadiness };
301
41
 
302
42
  /**
303
43
  * One-shot recovery hint after a non-PASS pipeline or stuck status (TABLE A primary hop).