@gobing-ai/spur 0.4.2 → 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 (133) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/config/decisions/maker-liveness.yaml +39 -0
  3. package/config/plugin-scripts.json +0 -4
  4. package/config/rules/README.md +1 -0
  5. package/config/rules/docs/sourced-api-claims.yaml +56 -12
  6. package/config/rules/strict/runtime-boundaries.yaml +7 -0
  7. package/config/script-placement-baseline.json +1 -19
  8. package/config/workflows/feature-lifecycle.yaml +46 -1
  9. package/config/workflows/feature-verification.yaml +11 -0
  10. package/package.json +9 -9
  11. package/plugins/sp/README.md +22 -16
  12. package/plugins/sp/agents/super-reviewer.md +43 -0
  13. package/plugins/sp/bunfig.toml +8 -5
  14. package/plugins/sp/hooks/careful-guard.ts +1 -1
  15. package/plugins/sp/hooks/context-post-tool.ts +7 -427
  16. package/plugins/sp/hooks/context-session-start.ts +5 -213
  17. package/plugins/sp/hooks/context-session-stop.ts +5 -191
  18. package/plugins/sp/hooks/pi/guard-extension.ts +6 -5
  19. package/plugins/sp/hooks/task-write-guard.ts +1 -1
  20. package/plugins/sp/{hooks → lib}/agent-hint.ts +1 -1
  21. package/plugins/sp/lib/context-post-tool.ts +432 -0
  22. package/plugins/sp/lib/context-session-start.ts +214 -0
  23. package/plugins/sp/lib/context-session-stop.ts +196 -0
  24. package/plugins/sp/lib/dogfood-pipeline.ts +265 -0
  25. package/plugins/sp/lib/dogfood-report.ts +278 -0
  26. package/plugins/sp/lib/idea-handoff.generated.mjs +3 -3
  27. package/plugins/sp/lib/inline-run-app.ts +40 -0
  28. package/plugins/sp/lib/inline-run.generated.d.mts +3 -3
  29. package/plugins/sp/lib/inline-run.generated.mjs +1347 -90
  30. package/plugins/sp/lib/plan-projection.generated.d.mts +150 -0
  31. package/plugins/sp/lib/plan-projection.generated.mjs +591 -1
  32. package/plugins/sp/lib/quality-gate.generated.mjs +38 -25
  33. package/plugins/sp/lib/residual-scan.generated.d.mts +7 -1
  34. package/plugins/sp/lib/residual-scan.generated.mjs +71 -6
  35. package/plugins/sp/lib/run-summary-core.ts +34 -370
  36. package/plugins/sp/lib/transcript.ts +37 -228
  37. package/plugins/sp/plugin.json +1 -1
  38. package/plugins/sp/scripts/batch-plan.mjs +586 -0
  39. package/plugins/sp/scripts/batch-preflight.mjs +23 -1
  40. package/plugins/sp/scripts/batch-preflight.ts +35 -295
  41. package/plugins/sp/scripts/daily-summary/daily-summary.mjs +108 -87
  42. package/plugins/sp/scripts/daily-summary/daily-summary.ts +111 -104
  43. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +2 -1
  44. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +7 -265
  45. package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +3 -0
  46. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +6 -272
  47. package/plugins/sp/scripts/feature-verification-steps.mjs +7 -123
  48. package/plugins/sp/scripts/feature-verification-steps.ts +29 -181
  49. package/plugins/sp/scripts/inline-run-dispatch.mjs +27 -26
  50. package/plugins/sp/scripts/inline-run-dispatch.ts +1 -21
  51. package/plugins/sp/scripts/inline-run-setup.mjs +149 -122
  52. package/plugins/sp/scripts/inline-run-setup.ts +1 -21
  53. package/plugins/sp/scripts/quality-gate.mjs +14 -2
  54. package/plugins/sp/scripts/residual-scan.mjs +73 -6
  55. package/plugins/sp/scripts/residual-scan.ts +8 -5
  56. package/plugins/sp/scripts/run-summary.mjs +151 -97
  57. package/plugins/sp/scripts/run-summary.ts +7 -5
  58. package/plugins/sp/scripts/session-timeline.mjs +46 -19
  59. package/plugins/sp/scripts/task-diffstat.mjs +11 -1
  60. package/plugins/sp/scripts/task-diffstat.ts +8 -39
  61. package/plugins/sp/skills/code-implementation/SKILL.md +7 -1
  62. package/plugins/sp/skills/code-verification/references/secu-review.md +2 -1
  63. package/plugins/sp/skills/code-verification/references/verdict-schema.md +4 -0
  64. package/plugins/sp/skills/dogfood-testing/SKILL.md +2 -2
  65. package/plugins/sp/skills/next-feature/SKILL.md +1 -1
  66. package/plugins/sp/skills/parallel-execution/references/dispatch-surface.md +1 -1
  67. package/plugins/sp/skills/source-driven-development/SKILL.md +7 -4
  68. package/plugins/sp/skills/spur-cli/references/builder.md +3 -2
  69. package/plugins/sp/skills/spur-cli/references/decision.md +32 -7
  70. package/plugins/sp/skills/spur-cli/references/features.md +46 -5
  71. package/plugins/sp/skills/spur-dev/references/execution-batch-report.md +1 -1
  72. package/plugins/sp/skills/spur-dev/references/execution-batch.md +13 -3
  73. package/plugins/sp/skills/spur-dev/references/execution-worktree-landing.md +22 -0
  74. package/plugins/sp/skills/spur-dev/references/execution-worktree-setup.md +14 -0
  75. package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +29 -12
  76. package/spur.js +80681 -79296
  77. package/web/_astro/{BoardApp.B3GQZvj8.js → BoardApp.5IIl2O-z.js} +1 -1
  78. package/web/_astro/{BoardApp.BT7L2kSb.js → BoardApp.Drnx-KeM.js} +150 -150
  79. package/web/_astro/{TaskDetail.Cxov1_N_.js → TaskDetail.Ci4LNn9S.js} +1 -1
  80. package/web/_astro/{arc.vaT7tPOB.js → arc.j2EVkYVd.js} +1 -1
  81. package/web/_astro/{architectureDiagram-3BPJPVTR.DRMmTjkN.js → architectureDiagram-3BPJPVTR.DZWSFqEG.js} +1 -1
  82. package/web/_astro/{blockDiagram-GPEHLZMM.cla0LO_q.js → blockDiagram-GPEHLZMM.DE6GpXCN.js} +1 -1
  83. package/web/_astro/{c4Diagram-AAUBKEIU.D4YAIBKn.js → c4Diagram-AAUBKEIU.DoVR1G6B.js} +1 -1
  84. package/web/_astro/channel.DmdDxGsq.js +1 -0
  85. package/web/_astro/{chunk-2J33WTMH.BrSJbMRZ.js → chunk-2J33WTMH.Do6-Gbyf.js} +1 -1
  86. package/web/_astro/{chunk-4BX2VUAB.CuLMgKF5.js → chunk-4BX2VUAB.BYV1HGHx.js} +1 -1
  87. package/web/_astro/{chunk-55IACEB6.zkvgu54F.js → chunk-55IACEB6.CvI1zkrc.js} +1 -1
  88. package/web/_astro/{chunk-727SXJPM.DxWkACh8.js → chunk-727SXJPM.DNGSCRlX.js} +1 -1
  89. package/web/_astro/{chunk-AQP2D5EJ.42XrmIlH.js → chunk-AQP2D5EJ.DXhhgT5z.js} +1 -1
  90. package/web/_astro/{chunk-FMBD7UC4.Bao2wMK9.js → chunk-FMBD7UC4.dzkRKP2u.js} +1 -1
  91. package/web/_astro/{chunk-ND2GUHAM.BhydojD1.js → chunk-ND2GUHAM.DujGLeEf.js} +1 -1
  92. package/web/_astro/{chunk-QZHKN3VN.CmZ82g-H.js → chunk-QZHKN3VN.BWtIT3ZU.js} +1 -1
  93. package/web/_astro/{classDiagram-4FO5ZUOK.Blr83Gt_.js → classDiagram-4FO5ZUOK.DyApg0Nn.js} +1 -1
  94. package/web/_astro/{classDiagram-v2-Q7XG4LA2.Blr83Gt_.js → classDiagram-v2-Q7XG4LA2.DyApg0Nn.js} +1 -1
  95. package/web/_astro/{cose-bilkent-S5V4N54A.qmfv0SPn.js → cose-bilkent-S5V4N54A.DJQB-u_l.js} +1 -1
  96. package/web/_astro/{cynefin-OW5HDTMX.BtELhXPR.js → cynefin-OW5HDTMX.bi3D_siV.js} +1 -1
  97. package/web/_astro/{dagre-BM42HDAG.AWmaAvXo.js → dagre-BM42HDAG.C-f7TrRg.js} +1 -1
  98. package/web/_astro/{diagram-2AECGRRQ.DdH34KDi.js → diagram-2AECGRRQ.DrPfjHQB.js} +1 -1
  99. package/web/_astro/{diagram-5GNKFQAL.BmNPix1k.js → diagram-5GNKFQAL.C9S4WUHO.js} +1 -1
  100. package/web/_astro/{diagram-KO2AKTUF.BNQd_Ppo.js → diagram-KO2AKTUF.Dzzye8QH.js} +1 -1
  101. package/web/_astro/{diagram-LMA3HP47.BAPgDi0e.js → diagram-LMA3HP47.DX-LRiof.js} +1 -1
  102. package/web/_astro/{diagram-OG6HWLK6.DZ4zyLdC.js → diagram-OG6HWLK6.Z-kAKwIz.js} +1 -1
  103. package/web/_astro/{erDiagram-TEJ5UH35.Q1TySMmw.js → erDiagram-TEJ5UH35.D6dyClSv.js} +1 -1
  104. package/web/_astro/{flowDiagram-I6XJVG4X.BXhFBicG.js → flowDiagram-I6XJVG4X.Cx3q2cxD.js} +1 -1
  105. package/web/_astro/{ganttDiagram-6RSMTGT7.vHSgcuo2.js → ganttDiagram-6RSMTGT7.DU3gH6CT.js} +1 -1
  106. package/web/_astro/{gitGraphDiagram-PVQCEYII.Bi1f73C7.js → gitGraphDiagram-PVQCEYII.ISmCnJ87.js} +1 -1
  107. package/web/_astro/index.Do2lLdgo.css +1 -0
  108. package/web/_astro/{infoDiagram-5YYISTIA.DPvXZEWm.js → infoDiagram-5YYISTIA.DR6_iNOK.js} +1 -1
  109. package/web/_astro/{ishikawaDiagram-YF4QCWOH.Cz829fsV.js → ishikawaDiagram-YF4QCWOH.D7wY-ZGA.js} +1 -1
  110. package/web/_astro/{journeyDiagram-JHISSGLW.enRnB9Me.js → journeyDiagram-JHISSGLW.DkP9-WK8.js} +1 -1
  111. package/web/_astro/{kanban-definition-UN3LZRKU.DnTNk6d2.js → kanban-definition-UN3LZRKU.wtgY98M2.js} +1 -1
  112. package/web/_astro/{linear.BzGnBwNL.js → linear.CI6djNi7.js} +1 -1
  113. package/web/_astro/{mermaid.core.CSbTpIVz.js → mermaid.core.CuQPxS8b.js} +4 -4
  114. package/web/_astro/{mindmap-definition-RKZ34NQL.DGJDy8zT.js → mindmap-definition-RKZ34NQL.5HNIEG7R.js} +1 -1
  115. package/web/_astro/{pieDiagram-4H26LBE5.HSPdi5_8.js → pieDiagram-4H26LBE5.CchhDFjE.js} +1 -1
  116. package/web/_astro/{quadrantDiagram-W4KKPZXB.6Gv8mz2Y.js → quadrantDiagram-W4KKPZXB.PYXXJPSJ.js} +1 -1
  117. package/web/_astro/{requirementDiagram-4Y6WPE33.CnBCtFwa.js → requirementDiagram-4Y6WPE33.cUQuNAKU.js} +1 -1
  118. package/web/_astro/{sankeyDiagram-5OEKKPKP.5M8VWAu8.js → sankeyDiagram-5OEKKPKP.BO7MnRIA.js} +1 -1
  119. package/web/_astro/{sequenceDiagram-3UESZ5HK.DN41XN-U.js → sequenceDiagram-3UESZ5HK.D9bElyD6.js} +1 -1
  120. package/web/_astro/{stateDiagram-AJRCARHV.ErOO3W8j.js → stateDiagram-AJRCARHV.DhGdRz7I.js} +1 -1
  121. package/web/_astro/{stateDiagram-v2-BHNVJYJU.B_ZHICM-.js → stateDiagram-v2-BHNVJYJU.5GvLeAoL.js} +1 -1
  122. package/web/_astro/{timeline-definition-PNZ67QCA.CWdosr07.js → timeline-definition-PNZ67QCA.LtAT9haM.js} +1 -1
  123. package/web/_astro/{vennDiagram-CIIHVFJN.BHzYjNV5.js → vennDiagram-CIIHVFJN.DRth1yLA.js} +1 -1
  124. package/web/_astro/{wardleyDiagram-YWT4CUSO.h8x4IwPX.js → wardleyDiagram-YWT4CUSO.h9MlZfcr.js} +1 -1
  125. package/web/_astro/{xychartDiagram-2RQKCTM6.RTapW2X8.js → xychartDiagram-2RQKCTM6.DHqy9DYA.js} +1 -1
  126. package/web/index.html +2 -2
  127. package/config/proportional-route-table.ts +0 -155
  128. package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
  129. package/web/_astro/channel.D4nG9YLf.js +0 -1
  130. package/web/_astro/index.BhSwN8yY.css +0 -1
  131. /package/plugins/sp/{hooks → lib}/context-owner.ts +0 -0
  132. /package/plugins/sp/{hooks → lib}/destructive-policy.ts +0 -0
  133. /package/plugins/sp/{hooks → lib}/task-file-policy.ts +0 -0
@@ -5,6 +5,572 @@
5
5
  import { readFileSync } from "fs";
6
6
 
7
7
  // plugins/sp/lib/plan-projection.generated.mjs
8
+ var NON_ABORTING_PREFLIGHT_CODES = new Set([
9
+ "L4.scenario-unverified",
10
+ "L4.verifying-incomplete-tasks"
11
+ ]);
12
+ function classifyFeaturePreflightFindings(findings) {
13
+ const aborting = [];
14
+ const nonAborting = [];
15
+ for (const f of findings) {
16
+ if (f.severity === "error") {
17
+ if (NON_ABORTING_PREFLIGHT_CODES.has(f.code)) {
18
+ nonAborting.push(f);
19
+ } else {
20
+ aborting.push(f);
21
+ }
22
+ } else {
23
+ nonAborting.push(f);
24
+ }
25
+ }
26
+ return {
27
+ aborting,
28
+ nonAborting,
29
+ shouldAbort: aborting.length > 0
30
+ };
31
+ }
32
+ function quickReadiness(input) {
33
+ const status = (input.status ?? "").toLowerCase();
34
+ const operation = input.operation;
35
+ if (operation !== "run" && operation !== "refine" && operation !== "verify") {
36
+ return {
37
+ action: "invalid",
38
+ code: "IV",
39
+ reason: `quick-readiness: unknown operation '${operation}' (${input.wbs})`
40
+ };
41
+ }
42
+ if (input.filteredCount !== undefined) {
43
+ if (input.filteredCount < 0) {
44
+ return {
45
+ action: "invalid",
46
+ code: "IV",
47
+ reason: `quick-readiness: invalid negative filtered count '${input.filteredCount}' (${input.wbs})`
48
+ };
49
+ }
50
+ if (input.filteredCount === 0) {
51
+ return {
52
+ action: "skipped",
53
+ code: "EMPTY",
54
+ reason: `quick-readiness: empty status-filtered set — nothing to ${operation} (${input.wbs})`
55
+ };
56
+ }
57
+ }
58
+ if (status === "cancelled" || status === "done") {
59
+ if (operation === "verify" && input.force === true) {
60
+ return {
61
+ action: "runnable",
62
+ code: "FORCE",
63
+ reason: `quick-readiness: verify --force re-verification of ${status} task ${input.wbs}`
64
+ };
65
+ }
66
+ return {
67
+ action: "skipped",
68
+ code: status === "done" ? "DONE" : "CANCELLED",
69
+ reason: `quick-readiness: already ${status} — no ${operation} hop (${input.wbs})`
70
+ };
71
+ }
72
+ if (status === "blocked") {
73
+ return {
74
+ action: "blocked",
75
+ code: "BLK",
76
+ reason: `quick-readiness: blocked — human/handover first (${input.wbs})`
77
+ };
78
+ }
79
+ if (operation === "run" && input.dependencies && input.dependencies.length > 0) {
80
+ const unmet = input.dependencies.filter((d) => (input.depStatuses?.[d] ?? "missing").toLowerCase() !== "done");
81
+ if (unmet.length > 0) {
82
+ return {
83
+ action: "blocked",
84
+ code: "DEP",
85
+ reason: `quick-readiness: unmet deps — ${unmet.join(", ")} (${input.wbs})`,
86
+ unmetDeps: unmet
87
+ };
88
+ }
89
+ }
90
+ const required = input.requiredSections ?? [];
91
+ const present = input.presentSections ?? [];
92
+ const gaps = required.filter((s) => {
93
+ const finding = input.sectionFindings?.[s];
94
+ return !present.includes(s) || finding !== undefined && finding !== "";
95
+ });
96
+ if (operation === "refine") {
97
+ if (status !== "backlog" && status !== "todo") {
98
+ return {
99
+ action: "skipped",
100
+ code: "NONPLAN",
101
+ reason: `quick-readiness: refine targets backlog/todo only, not '${status}' (${input.wbs})`
102
+ };
103
+ }
104
+ return {
105
+ action: "runnable",
106
+ code: "OK",
107
+ reason: `quick-readiness: refine ready for ${input.wbs} (${gaps.length} planning gap(s) to fill)`
108
+ };
109
+ }
110
+ if (operation === "verify") {
111
+ if (status !== "testing" && status !== "wip") {
112
+ return {
113
+ action: "invalid",
114
+ code: "NOVERIFY",
115
+ reason: `quick-readiness: verify needs testing/wip, not '${status}' (${input.wbs})`
116
+ };
117
+ }
118
+ return {
119
+ action: "runnable",
120
+ code: "OK",
121
+ reason: `quick-readiness: verify ready for ${input.wbs}`
122
+ };
123
+ }
124
+ if (status !== "todo" && status !== "wip" && status !== "testing") {
125
+ return {
126
+ action: "invalid",
127
+ code: "NORUN",
128
+ reason: `quick-readiness: run needs todo/wip/testing, not '${status}' (${input.wbs})`
129
+ };
130
+ }
131
+ if (gaps.length > 0) {
132
+ return {
133
+ action: "needs-refinement",
134
+ code: "REFINE",
135
+ reason: `quick-readiness: implementation sections incomplete (${input.wbs})`,
136
+ gaps
137
+ };
138
+ }
139
+ return {
140
+ action: "runnable",
141
+ code: "OK",
142
+ reason: `quick-readiness: run ready for ${input.wbs}`
143
+ };
144
+ }
145
+ function preflightTask(input) {
146
+ const status = (input.status ?? "").toLowerCase();
147
+ const deps = input.dependencies ?? [];
148
+ const depStatuses = input.depStatuses ?? {};
149
+ if (status === "cancelled") {
150
+ return {
151
+ action: "skip",
152
+ code: "A9",
153
+ reason: `dev-next: cancelled — nothing to advance (${input.wbs})`
154
+ };
155
+ }
156
+ if (status === "done") {
157
+ return {
158
+ action: "skip",
159
+ code: "A8",
160
+ reason: `dev-next: already done — batch does not auto-wrap (${input.wbs})`
161
+ };
162
+ }
163
+ if (status === "blocked") {
164
+ return {
165
+ action: "skip",
166
+ code: "A7",
167
+ reason: `dev-next: blocked — do not launch pipeline; human/handover first (${input.wbs})`
168
+ };
169
+ }
170
+ if (status === "todo" || status === "backlog") {
171
+ const unmet = deps.filter((d) => {
172
+ const st = (depStatuses[d] ?? "missing").toLowerCase();
173
+ return st !== "done";
174
+ });
175
+ if (unmet.length > 0) {
176
+ return {
177
+ action: "skip",
178
+ code: "A2",
179
+ reason: `dev-next: blocked by deps — unmet: ${unmet.join(", ")} (${input.wbs})`,
180
+ unmetDeps: unmet
181
+ };
182
+ }
183
+ }
184
+ return { action: "run", code: "OK", reason: `preflight clear — launch task-pipeline for ${input.wbs}` };
185
+ }
186
+ var zeroTokens = () => ({ input: 0, cacheCreate: 0, cacheRead: 0, output: 0 });
187
+ function formatDuration(ms) {
188
+ const s = Math.round(ms / 1000);
189
+ const h = Math.floor(s / 3600);
190
+ const m = Math.floor(s % 3600 / 60);
191
+ const ss = String(s % 60).padStart(2, "0");
192
+ return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${ss}` : `${m}:${ss}`;
193
+ }
194
+ function formatTokens(n) {
195
+ if (n >= 999500)
196
+ return `${(n / 1e6).toFixed(1)}M`;
197
+ return n >= 1000 ? `${Math.round(n / 1000)}k` : String(n);
198
+ }
199
+ function formatTokenSplit(t) {
200
+ if (!t)
201
+ return "n/a";
202
+ const nonCached = t.input + t.cacheCreate + t.output;
203
+ return `${formatTokens(nonCached + t.cacheRead)} / ${formatTokens(nonCached)}`;
204
+ }
205
+ var OPERATOR_TOOLS = new Set(["AskUserQuestion", "ask_user_question"]);
206
+ function isCompaction(row) {
207
+ return row.type === "compaction" || row.type === "system" && row.subtype === "compact_boundary";
208
+ }
209
+ function firstTextContent(row) {
210
+ const content = row.message?.content;
211
+ if (typeof content === "string")
212
+ return content;
213
+ if (!Array.isArray(content))
214
+ return;
215
+ return content.find((b) => b.type === "text")?.text;
216
+ }
217
+ function skillInvocationPrompt(text) {
218
+ const name = /^\s*<skill name="([^"]+)"/.exec(text)?.[1];
219
+ if (name === undefined)
220
+ return;
221
+ const close = text.lastIndexOf("</skill>");
222
+ const args = close < 0 ? "" : text.slice(close + "</skill>".length).trim();
223
+ return args === "" ? `/${name}` : `/${name} ${args}`;
224
+ }
225
+ function promptText(row) {
226
+ if (row.type === "custom_message") {
227
+ if (row.display === false)
228
+ return;
229
+ const text = typeof row.content === "string" ? row.content.trim() : "";
230
+ return text === "" ? undefined : text;
231
+ }
232
+ if (row.type === "message") {
233
+ if (row.message?.role !== "user")
234
+ return;
235
+ const text = firstTextContent(row);
236
+ if (text === undefined)
237
+ return;
238
+ return skillInvocationPrompt(text) ?? text;
239
+ }
240
+ if (row.type !== "user" || row.isMeta || row.isCompactSummary)
241
+ return;
242
+ const content = row.message?.content;
243
+ if (typeof content === "string")
244
+ return content;
245
+ if (!Array.isArray(content) || content.some((b) => b.type === "tool_result"))
246
+ return;
247
+ return content.find((b) => b.type === "text")?.text;
248
+ }
249
+ function sumTokens(all) {
250
+ const total = zeroTokens();
251
+ for (const t of all)
252
+ for (const k of Object.keys(total))
253
+ total[k] += t[k];
254
+ return total;
255
+ }
256
+ function sumSpans(spans) {
257
+ return {
258
+ workMs: spans.reduce((n, s) => n + s.workMs, 0),
259
+ waitMs: spans.reduce((n, s) => n + s.waitMs, 0),
260
+ toolCalls: spans.reduce((n, s) => n + s.toolCalls, 0),
261
+ tokens: sumTokens(spans.map((s) => s.tokens))
262
+ };
263
+ }
264
+ var newAcc = (ts) => ({
265
+ last: ts,
266
+ askMs: 0,
267
+ asks: new Map,
268
+ toolIds: new Set,
269
+ messages: new Map,
270
+ compactions: 0
271
+ });
272
+ function accumulate(acc, row, ts) {
273
+ acc.last = Math.max(acc.last, ts);
274
+ if (row.type === "message") {
275
+ const m = row.message;
276
+ if (m?.role === "assistant") {
277
+ const blocks2 = Array.isArray(m.content) ? m.content : [];
278
+ for (const b of blocks2) {
279
+ if (b.type === "toolCall" && b.id) {
280
+ acc.toolIds.add(b.id);
281
+ if (b.name && OPERATOR_TOOLS.has(b.name))
282
+ acc.asks.set(b.id, ts);
283
+ }
284
+ }
285
+ const u2 = m.usage;
286
+ if (u2 && row.id)
287
+ acc.messages.set(row.id, {
288
+ input: u2.input ?? 0,
289
+ cacheCreate: u2.cacheWrite ?? 0,
290
+ cacheRead: u2.cacheRead ?? 0,
291
+ output: u2.output ?? 0
292
+ });
293
+ } else if (m?.role === "toolResult" && m.toolCallId && acc.asks.has(m.toolCallId)) {
294
+ acc.askMs += ts - (acc.asks.get(m.toolCallId) ?? ts);
295
+ }
296
+ return;
297
+ }
298
+ if (row.type === "compaction")
299
+ acc.compactions++;
300
+ const blocks = Array.isArray(row.message?.content) ? row.message.content : [];
301
+ for (const b of blocks) {
302
+ if (b.type === "tool_use" && b.id) {
303
+ acc.toolIds.add(b.id);
304
+ if (b.name && OPERATOR_TOOLS.has(b.name))
305
+ acc.asks.set(b.id, ts);
306
+ } else if (b.type === "tool_result" && b.tool_use_id && acc.asks.has(b.tool_use_id)) {
307
+ acc.askMs += ts - (acc.asks.get(b.tool_use_id) ?? ts);
308
+ }
309
+ }
310
+ const u = row.message?.usage;
311
+ if (row.type === "assistant" && u && row.message?.id) {
312
+ acc.messages.set(row.message.id, {
313
+ input: u.input_tokens ?? 0,
314
+ cacheCreate: u.cache_creation_input_tokens ?? 0,
315
+ cacheRead: u.cache_read_input_tokens ?? 0,
316
+ output: u.output_tokens ?? 0
317
+ });
318
+ }
319
+ }
320
+ var IDLE_GAP_MS = 300000;
321
+ var SHELL_TOOLS = new Set(["bash", "shell", "exec", "exec_command", "run_command", "command"]);
322
+ var SUBAGENT_TOOLS = new Set(["agent", "task", "invoke_subagent", "subagent", "dispatch_agent"]);
323
+ var LOWERCASE_OPERATOR_TOOLS = new Set(["askuserquestion", "ask_user_question"]);
324
+ var ACTOR_PRECEDENCE = ["operator", "subagent", "shell", "other"];
325
+ function actorOf(tool) {
326
+ const t = tool.toLowerCase().replace(/[^a-z_]/g, "");
327
+ if (LOWERCASE_OPERATOR_TOOLS.has(t))
328
+ return "operator";
329
+ if (SUBAGENT_TOOLS.has(t))
330
+ return "subagent";
331
+ if (SHELL_TOOLS.has(t))
332
+ return "shell";
333
+ return "other";
334
+ }
335
+ function unionMs(spans, start, end) {
336
+ const clipped = spans.map(([a, b]) => [Math.max(a, start), Math.min(b, end)]).filter(([a, b]) => b > a).sort((x, y) => x[0] - y[0]);
337
+ let total = 0;
338
+ let cursor = Number.NaN;
339
+ let openUntil = Number.NaN;
340
+ for (const [a, b] of clipped) {
341
+ if (!Number.isFinite(cursor)) {
342
+ cursor = a;
343
+ openUntil = b;
344
+ continue;
345
+ }
346
+ if (a > openUntil) {
347
+ total += openUntil - cursor;
348
+ cursor = a;
349
+ openUntil = b;
350
+ } else {
351
+ openUntil = Math.max(openUntil, b);
352
+ }
353
+ }
354
+ if (Number.isFinite(cursor))
355
+ total += openUntil - cursor;
356
+ return total;
357
+ }
358
+ function subtract(spans, claimed) {
359
+ let free = spans;
360
+ for (const [ca, cb] of claimed) {
361
+ const next = [];
362
+ for (const [a, b] of free) {
363
+ if (cb <= a || ca >= b) {
364
+ next.push([a, b]);
365
+ continue;
366
+ }
367
+ if (ca > a)
368
+ next.push([a, ca]);
369
+ if (cb < b)
370
+ next.push([cb, b]);
371
+ }
372
+ free = next;
373
+ }
374
+ return free;
375
+ }
376
+ function actorSplit(rows, start, end) {
377
+ const empty = {
378
+ operatorMs: 0,
379
+ longestOperatorWaitMs: 0,
380
+ modelMs: 0,
381
+ shellMs: 0,
382
+ subagentMs: 0,
383
+ otherToolMs: 0,
384
+ idleMs: 0,
385
+ compactions: 0,
386
+ subagentErrors: 0
387
+ };
388
+ const window = end - start;
389
+ if (window <= 0)
390
+ return empty;
391
+ const calls = new Map;
392
+ const results = new Map;
393
+ const eventTs = [];
394
+ let compactions = 0;
395
+ for (const [row, ts] of rows) {
396
+ if (ts < start || ts > end)
397
+ continue;
398
+ eventTs.push(ts);
399
+ if (isCompaction(row))
400
+ compactions++;
401
+ const blocks = Array.isArray(row.message?.content) ? row.message?.content : [];
402
+ if (row.message?.role === "toolResult" && row.message.toolCallId !== undefined) {
403
+ results.set(row.message.toolCallId, { ts, isError: row.message.isError === true });
404
+ }
405
+ for (const b of blocks) {
406
+ if ((b.type === "tool_use" || b.type === "toolCall") && b.id !== undefined && b.name !== undefined) {
407
+ calls.set(b.id, { id: b.id, actor: actorOf(b.name), ts });
408
+ } else if (b.type === "tool_result" && b.tool_use_id !== undefined) {
409
+ results.set(b.tool_use_id, { ts, isError: b.is_error === true });
410
+ }
411
+ }
412
+ }
413
+ let subagentErrors = 0;
414
+ const resolved = [];
415
+ for (const call of calls.values()) {
416
+ const result = results.get(call.id);
417
+ if (result?.isError === true && call.actor === "subagent")
418
+ subagentErrors++;
419
+ resolved.push({ ...call, end: Math.min(result?.ts ?? end, end) });
420
+ }
421
+ const claimed = [];
422
+ const byActor = new Map;
423
+ for (const actor of ACTOR_PRECEDENCE) {
424
+ const mine = resolved.filter((r) => r.actor === actor).map((r) => [r.ts, r.end]);
425
+ const free = subtract(mine, claimed);
426
+ for (const span of free)
427
+ claimed.push(span);
428
+ const ms = unionMs(free, start, end);
429
+ byActor.set(actor, ms);
430
+ if (actor === "operator") {
431
+ empty.longestOperatorWaitMs = Math.max(0, ...mine.map(([a, b]) => b - a));
432
+ }
433
+ }
434
+ const boundaries = [...new Set([start, end, ...eventTs, ...claimed.flat()])].sort((a, b) => a - b);
435
+ const claimedSorted = [...claimed].sort((a, b) => a[0] - b[0]);
436
+ let idleMs = 0;
437
+ for (let i = 0;i < boundaries.length - 1; i++) {
438
+ const a = boundaries[i];
439
+ const b = boundaries[i + 1];
440
+ if (b - a < IDLE_GAP_MS)
441
+ continue;
442
+ if (claimedSorted.some(([ca, cb]) => ca < b && cb > a))
443
+ continue;
444
+ idleMs += b - a;
445
+ }
446
+ const accounted = (byActor.get("operator") ?? 0) + (byActor.get("subagent") ?? 0) + (byActor.get("shell") ?? 0) + (byActor.get("other") ?? 0) + idleMs;
447
+ return {
448
+ ...empty,
449
+ operatorMs: byActor.get("operator") ?? 0,
450
+ subagentMs: byActor.get("subagent") ?? 0,
451
+ shellMs: byActor.get("shell") ?? 0,
452
+ otherToolMs: byActor.get("other") ?? 0,
453
+ idleMs,
454
+ modelMs: Math.max(0, window - accounted),
455
+ compactions,
456
+ subagentErrors
457
+ };
458
+ }
459
+ function attemptWindow(attempts) {
460
+ const starts = attempts.map((a) => Date.parse(a.startedAt ?? "")).filter((n) => !Number.isNaN(n));
461
+ const ends = attempts.map((a) => Date.parse(a.completedAt ?? "")).filter((n) => !Number.isNaN(n));
462
+ return starts.length && ends.length ? [Math.min(...starts), Math.max(...ends)] : undefined;
463
+ }
464
+ function summaryRow(stage, status, span, measured) {
465
+ return {
466
+ stage,
467
+ status,
468
+ workMs: span.workMs,
469
+ waitMs: span.waitMs,
470
+ toolCalls: measured ? span.toolCalls : null,
471
+ tokens: measured ? span.tokens : null,
472
+ time: formatDuration(span.workMs),
473
+ wait: formatDuration(span.waitMs),
474
+ token: formatTokenSplit(measured ? span.tokens : null)
475
+ };
476
+ }
477
+ function buildRunSummary(rows, inputs, opts = {}) {
478
+ const { since, until } = opts;
479
+ const windows = [];
480
+ for (const { label, progress } of inputs) {
481
+ const states = (progress.states ?? []).flatMap((s) => {
482
+ const w = attemptWindow((s.actions ?? []).flatMap((a) => a.attempts ?? []));
483
+ return w ? [{ s, w }] : [];
484
+ });
485
+ if (!states.length)
486
+ throw new Error(`progress for run ${progress.runId} has no timed attempts`);
487
+ if (inputs.length === 1) {
488
+ for (const { s, w } of states) {
489
+ const stage = (s.visit ?? 1) > 1 ? `${s.state} (visit ${s.visit})` : s.state;
490
+ windows.push({ stage, status: s.status ?? "", start: w[0], end: w[1] });
491
+ }
492
+ } else {
493
+ const stage = label ?? `${progress.workflow ?? "run"} ${progress.runId.slice(0, 8)}`;
494
+ const start = Math.min(...states.map(({ w }) => w[0]));
495
+ windows.push({
496
+ stage,
497
+ status: progress.status ?? "",
498
+ start,
499
+ end: Math.max(...states.map(({ w }) => w[1]))
500
+ });
501
+ }
502
+ }
503
+ windows.sort((a, b) => a.start - b.start);
504
+ const measure = (start, end) => {
505
+ const acc = newAcc(start);
506
+ for (const [row, ts] of rows)
507
+ if (ts >= start && ts <= end && promptText(row) === undefined)
508
+ accumulate(acc, row, ts);
509
+ const span = {
510
+ workMs: end - start - acc.askMs,
511
+ waitMs: acc.askMs,
512
+ toolCalls: acc.toolIds.size,
513
+ tokens: sumTokens([...acc.messages.values()])
514
+ };
515
+ return { span, measured: acc.toolIds.size > 0 || acc.messages.size > 0 };
516
+ };
517
+ const sinceMs = since ? Date.parse(since) : Number.NaN;
518
+ const totalStart = Number.isNaN(sinceMs) ? Math.min(...windows.map((w) => w.start)) : sinceMs;
519
+ let totalEnd = Math.max(...windows.map((w) => w.end));
520
+ if (!Number.isNaN(sinceMs)) {
521
+ for (const [, ts] of rows)
522
+ if (ts >= sinceMs)
523
+ totalEnd = Math.max(totalEnd, ts);
524
+ }
525
+ const untilMs = until ? Date.parse(until) : Number.NaN;
526
+ if (!Number.isNaN(untilMs) && untilMs > totalStart)
527
+ totalEnd = untilMs;
528
+ const stageRows = windows.map((w) => {
529
+ const { span, measured } = measure(w.start, w.end);
530
+ return summaryRow(w.stage, w.status, span, measured);
531
+ });
532
+ const totalMeasure = measure(totalStart, totalEnd);
533
+ const statuses = [...new Set(inputs.map((i) => i.progress.status ?? ""))].join("/");
534
+ const total = summaryRow("Total", statuses, totalMeasure.span, totalMeasure.measured);
535
+ const overlaps = windows.some((w, i) => i > 0 && w.start < (windows[i - 1]?.end ?? 0));
536
+ const sum = sumSpans(stageRows.map((r) => ({ ...r, toolCalls: r.toolCalls ?? 0, tokens: r.tokens ?? zeroTokens() })));
537
+ const overhead = {
538
+ workMs: total.workMs - sum.workMs,
539
+ waitMs: total.waitMs - sum.waitMs,
540
+ toolCalls: (total.toolCalls ?? 0) - sum.toolCalls,
541
+ tokens: Object.fromEntries(Object.keys(sum.tokens).map((k) => [k, (total.tokens?.[k] ?? 0) - sum.tokens[k]]))
542
+ };
543
+ if (!overlaps && overhead.workMs > 0)
544
+ stageRows.push(summaryRow("driver overhead", "", overhead, totalMeasure.measured));
545
+ return {
546
+ available: true,
547
+ rows: stageRows,
548
+ total,
549
+ actors: actorSplit(rows, totalStart, totalEnd),
550
+ gate: { ms: null, reason: "no matching check receipt" },
551
+ skippedLines: opts.skippedLines ?? 0
552
+ };
553
+ }
554
+ var SENSITIVE_PREFIXES = ["drizzle/", "packages/config/", ".github/", "plugins/sp/hooks/"];
555
+ var SENSITIVE_GLOBS = ["apps/server/src/**/auth*", "**/*secret*", "**/*.sql"];
556
+ function globToRegex(glob) {
557
+ const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("**/", "\x00").replaceAll("**", "\x01").replaceAll("*", "[^/]*").replaceAll("\x00", "(?:.*/)?").replaceAll("\x01", ".*");
558
+ return new RegExp(`^${escaped}$`, "s");
559
+ }
560
+ var SENSITIVE_MATCHERS = [
561
+ ...SENSITIVE_PREFIXES.map((prefix) => ({
562
+ label: prefix,
563
+ test: (path) => path.startsWith(prefix)
564
+ })),
565
+ ...SENSITIVE_GLOBS.map((glob) => {
566
+ const regex = globToRegex(glob);
567
+ return { label: glob, test: (path) => regex.test(path) };
568
+ })
569
+ ];
570
+ function sensitiveReasonForPath(path) {
571
+ const match = SENSITIVE_MATCHERS.find((entry) => entry.test(path));
572
+ return match ? `matches sensitive pattern ${match.label}` : null;
573
+ }
8
574
  function planLetter(index) {
9
575
  if (!Number.isInteger(index) || index < 0 || index > 25) {
10
576
  throw new Error(`plan letter out of range: ${index} (expected 0..25)`);
@@ -473,16 +1039,36 @@ function main(argv) {
473
1039
  process.exit(main(process.argv.slice(2)));
474
1040
  }
475
1041
  export {
1042
+ zeroTokens,
476
1043
  validatePhaseTable,
477
1044
  taskPhaseChildren,
1045
+ sumTokens,
1046
+ sumSpans,
1047
+ skillInvocationPrompt,
1048
+ sensitiveReasonForPath,
478
1049
  scheduleBatch,
1050
+ quickReadiness,
1051
+ promptText,
1052
+ preflightTask,
479
1053
  planLetter,
480
1054
  planChild,
1055
+ newAcc,
481
1056
  main,
1057
+ isCompaction,
482
1058
  insertOnEntry,
483
1059
  hostText,
484
1060
  hostStatus,
1061
+ formatTokens,
1062
+ formatTokenSplit,
1063
+ formatDuration,
1064
+ classifyFeaturePreflightFindings,
1065
+ buildRunSummary,
485
1066
  buildPhasedPlan,
486
1067
  buildBatchPlan,
1068
+ actorSplit,
1069
+ accumulate,
1070
+ SENSITIVE_PREFIXES,
1071
+ SENSITIVE_GLOBS,
1072
+ NON_ABORTING_PREFLIGHT_CODES,
487
1073
  BATCH_PLAN_USAGE
488
1074
  };
@@ -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) {