@gobing-ai/spur 0.3.95 → 0.3.97

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 (165) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/config/plugin-scripts.json +0 -54
  3. package/config/rules/boundary/sp-script-placement.yaml +19 -0
  4. package/config/rules/strict/runtime-boundaries.yaml +6 -0
  5. package/config/rules/structure/test-location.yaml +2 -0
  6. package/config/rules/typescript/no-syscall-emulation-in-boundary-mock.yaml +1 -1
  7. package/config/rules/typescript/output-boundaries.yaml +15 -2
  8. package/config/script-placement-baseline.json +51 -0
  9. package/config/templates/AGENTS.md +3 -3
  10. package/config/workflows/feature-verification.yaml +1 -1
  11. package/config/workflows/history-anatomy.yaml +23 -11
  12. package/config/workflows/idea-pipeline.yaml +80 -85
  13. package/config/workflows/pr-review.yaml +18 -9
  14. package/config/workflows/task-pipeline.yaml +42 -95
  15. package/config/workflows/wrapup-pipeline.yaml +91 -38
  16. package/package.json +2 -2
  17. package/plugins/sp/README.md +14 -10
  18. package/plugins/sp/agents/super-reviewer.md +43 -18
  19. package/plugins/sp/commands/dev-fixgha.md +83 -0
  20. package/plugins/sp/commands/dev-gitmsg.md +8 -6
  21. package/plugins/sp/commands/dev-gtd.md +2 -2
  22. package/plugins/sp/commands/dev-idea.md +22 -12
  23. package/plugins/sp/commands/dev-job-dump.md +29 -0
  24. package/plugins/sp/commands/dev-job-resume.md +29 -0
  25. package/plugins/sp/commands/dev-plan.md +8 -9
  26. package/plugins/sp/commands/dev-review.md +22 -13
  27. package/plugins/sp/commands/dev-verifyall.md +1 -1
  28. package/plugins/sp/commands/spur-init.md +2 -2
  29. package/plugins/sp/lib/history-anatomy.generated.d.mts +112 -0
  30. package/plugins/sp/lib/history-anatomy.generated.mjs +686 -0
  31. package/plugins/sp/lib/idea-handoff.generated.mjs +5 -4
  32. package/plugins/sp/lib/inline-run.generated.d.mts +11 -0
  33. package/plugins/sp/lib/inline-run.generated.mjs +39 -13
  34. package/plugins/sp/lib/quality-gate.generated.d.mts +104 -0
  35. package/plugins/sp/lib/quality-gate.generated.mjs +445 -0
  36. package/plugins/sp/lib/residual-scan.generated.d.mts +63 -0
  37. package/plugins/sp/lib/residual-scan.generated.mjs +226 -0
  38. package/plugins/sp/lib/spur-bin.ts +36 -0
  39. package/plugins/sp/lib/step-profile.generated.d.mts +71 -0
  40. package/plugins/sp/lib/step-profile.generated.mjs +174 -0
  41. package/plugins/sp/plugin.json +1 -1
  42. package/plugins/sp/references/roles.md +3 -3
  43. package/plugins/sp/scripts/feature-verification-steps.mjs +14 -1
  44. package/plugins/sp/scripts/feature-verification-steps.ts +14 -1
  45. package/plugins/sp/scripts/history-anatomy-cache.mjs +20 -19
  46. package/plugins/sp/scripts/history-anatomy-cache.ts +23 -928
  47. package/plugins/sp/scripts/inline-run-setup.mjs +85 -320
  48. package/plugins/sp/scripts/inline-run-setup.ts +104 -667
  49. package/plugins/sp/scripts/quality-gate.mjs +46 -24
  50. package/plugins/sp/scripts/quality-gate.ts +13 -659
  51. package/plugins/sp/scripts/residual-scan.mjs +179 -174
  52. package/plugins/sp/scripts/residual-scan.ts +125 -517
  53. package/plugins/sp/scripts/script-root.mjs +5 -1
  54. package/plugins/sp/scripts/script-root.ts +5 -1
  55. package/plugins/sp/scripts/workflow-step-profile.mjs +25 -17
  56. package/plugins/sp/scripts/workflow-step-profile.ts +21 -315
  57. package/plugins/sp/scripts/wrapup-drift-probe.mjs +8 -2
  58. package/plugins/sp/scripts/wrapup-drift-probe.ts +3 -2
  59. package/plugins/sp/scripts/wrapup-steps.mjs +72 -33
  60. package/plugins/sp/scripts/wrapup-steps.ts +128 -37
  61. package/plugins/sp/skills/code-improvement/SKILL.md +5 -4
  62. package/plugins/sp/skills/code-verification/SKILL.md +34 -9
  63. package/plugins/sp/skills/code-verification/references/verdict-schema.md +3 -3
  64. package/plugins/sp/skills/functional-review/SKILL.md +7 -4
  65. package/plugins/sp/skills/functional-review/references/verdict-schema.md +1 -1
  66. package/plugins/sp/skills/history-anatomy/references/modes.md +2 -1
  67. package/plugins/sp/skills/next-feature/references/handoff-routing.md +1 -1
  68. package/plugins/sp/skills/next-router/references/routing-table.md +1 -1
  69. package/plugins/sp/skills/source-driven-development/SKILL.md +11 -0
  70. package/plugins/sp/skills/spur-cli/SKILL.md +3 -3
  71. package/plugins/sp/skills/spur-cli/references/agent.md +10 -10
  72. package/plugins/sp/skills/spur-cli/references/features.md +17 -6
  73. package/plugins/sp/skills/spur-cli/references/init.md +17 -16
  74. package/plugins/sp/skills/spur-cli/references/self.md +3 -2
  75. package/plugins/sp/skills/spur-cli/references/serve.md +10 -10
  76. package/plugins/sp/skills/spur-cli/references/tasks/section-editing.md +9 -5
  77. package/plugins/sp/skills/spur-cli/references/tasks/verbs.md +21 -6
  78. package/plugins/sp/skills/spur-cli/references/tasks.md +14 -8
  79. package/plugins/sp/skills/spur-cli/references/workflows.md +17 -14
  80. package/plugins/sp/skills/spur-dev/SKILL.md +2 -0
  81. package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +4 -3
  82. package/plugins/sp/skills/spur-dev/references/cross-cutting.md +14 -10
  83. package/plugins/sp/skills/spur-dev/references/decision-brief.md +1 -1
  84. package/plugins/sp/skills/spur-dev/references/dev-operations.md +165 -75
  85. package/plugins/sp/skills/spur-dev/references/done-housekeeping.md +7 -5
  86. package/plugins/sp/skills/spur-dev/references/execution-batch.md +84 -39
  87. package/plugins/sp/skills/spur-dev/references/execution-workflow.md +8 -12
  88. package/plugins/sp/skills/spur-dev/references/feature-link-helper.md +3 -3
  89. package/plugins/sp/skills/spur-dev/references/flag-glossary.md +40 -21
  90. package/plugins/sp/skills/spur-dev/references/gate-checklists.md +19 -19
  91. package/plugins/sp/skills/spur-dev/references/idea-evaluation.md +4 -3
  92. package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +72 -15
  93. package/plugins/sp/skills/spur-doctor/SKILL.md +1 -1
  94. package/plugins/sp/skills/sys-architecture/SKILL.md +3 -2
  95. package/spur.js +4461 -2085
  96. package/web/_astro/{BoardApp.Cpxntzad.js → BoardApp.Bmv5WkJ9.js} +1 -1
  97. package/web/_astro/BoardApp.vveLOdDq.js +322 -0
  98. package/web/_astro/{TaskDetail.C5bW4WGV.js → TaskDetail.IKc3uDYV.js} +1 -1
  99. package/web/_astro/{arc.CyjRvNMY.js → arc.C63Ufg35.js} +1 -1
  100. package/web/_astro/{architectureDiagram-3BPJPVTR.B4lWRzJA.js → architectureDiagram-3BPJPVTR.CP8Hyldk.js} +1 -1
  101. package/web/_astro/{blockDiagram-GPEHLZMM.Be38USQ2.js → blockDiagram-GPEHLZMM.Bo_48MRA.js} +1 -1
  102. package/web/_astro/{c4Diagram-AAUBKEIU.DT9Fj5Qx.js → c4Diagram-AAUBKEIU.Ch61sw-O.js} +1 -1
  103. package/web/_astro/channel.BKCmJpWM.js +1 -0
  104. package/web/_astro/{chunk-2J33WTMH.SeSBWLg5.js → chunk-2J33WTMH.CHpzS7xf.js} +1 -1
  105. package/web/_astro/{chunk-4BX2VUAB.DoO4VE14.js → chunk-4BX2VUAB.DzMNNWIw.js} +1 -1
  106. package/web/_astro/{chunk-55IACEB6.DrmTFA53.js → chunk-55IACEB6.BqPrDw_Q.js} +1 -1
  107. package/web/_astro/{chunk-727SXJPM.Bi-TUb_V.js → chunk-727SXJPM.ZzBHhNw-.js} +1 -1
  108. package/web/_astro/{chunk-AQP2D5EJ.B-xp8Uhi.js → chunk-AQP2D5EJ.1_O_LLkx.js} +1 -1
  109. package/web/_astro/{chunk-FMBD7UC4.DGWrDnUU.js → chunk-FMBD7UC4.GS4UHg7_.js} +1 -1
  110. package/web/_astro/{chunk-ND2GUHAM._BagvPDy.js → chunk-ND2GUHAM.BnqotN4g.js} +1 -1
  111. package/web/_astro/{chunk-QZHKN3VN.VOboYWQ0.js → chunk-QZHKN3VN.Ghuh8zoJ.js} +1 -1
  112. package/web/_astro/{classDiagram-4FO5ZUOK.D_apfHS7.js → classDiagram-4FO5ZUOK.BW9vC3zg.js} +1 -1
  113. package/web/_astro/{classDiagram-v2-Q7XG4LA2.D_apfHS7.js → classDiagram-v2-Q7XG4LA2.BW9vC3zg.js} +1 -1
  114. package/web/_astro/{cose-bilkent-S5V4N54A.DNLU_L-x.js → cose-bilkent-S5V4N54A.D6jNC0ti.js} +1 -1
  115. package/web/_astro/{cynefin-OW5HDTMX.D8borhV-.js → cynefin-OW5HDTMX.BOGoCs4L.js} +1 -1
  116. package/web/_astro/{dagre-BM42HDAG.Uc0lvjcV.js → dagre-BM42HDAG.8iU5VcWi.js} +1 -1
  117. package/web/_astro/{diagram-2AECGRRQ.DDIxtDBo.js → diagram-2AECGRRQ.CVt88HwH.js} +1 -1
  118. package/web/_astro/{diagram-5GNKFQAL.DVoDnD3H.js → diagram-5GNKFQAL.C9HxUUMl.js} +1 -1
  119. package/web/_astro/{diagram-KO2AKTUF.CRubTJ-0.js → diagram-KO2AKTUF.4ywkQN3t.js} +1 -1
  120. package/web/_astro/{diagram-LMA3HP47.m9SeYcXQ.js → diagram-LMA3HP47.C48A6gpz.js} +1 -1
  121. package/web/_astro/{diagram-OG6HWLK6.C6s2ZjV5.js → diagram-OG6HWLK6.DxFieQW4.js} +1 -1
  122. package/web/_astro/{erDiagram-TEJ5UH35.nSzr5KTj.js → erDiagram-TEJ5UH35.CtjtQqYs.js} +1 -1
  123. package/web/_astro/{flowDiagram-I6XJVG4X.DrZcys16.js → flowDiagram-I6XJVG4X.C5zAiahU.js} +1 -1
  124. package/web/_astro/{ganttDiagram-6RSMTGT7.Do4M1b-K.js → ganttDiagram-6RSMTGT7.D_L6zsny.js} +1 -1
  125. package/web/_astro/{gitGraphDiagram-PVQCEYII.BWc9oJ4l.js → gitGraphDiagram-PVQCEYII.Ignnrk3V.js} +1 -1
  126. package/web/_astro/index.CbNz17Sx.css +1 -0
  127. package/web/_astro/{infoDiagram-5YYISTIA.BIdOctFk.js → infoDiagram-5YYISTIA.DLv8-P5u.js} +1 -1
  128. package/web/_astro/{ishikawaDiagram-YF4QCWOH.CV5SuG2t.js → ishikawaDiagram-YF4QCWOH.p0OTpwFO.js} +1 -1
  129. package/web/_astro/{journeyDiagram-JHISSGLW.CxE-rEJ-.js → journeyDiagram-JHISSGLW.CIaBt-DD.js} +1 -1
  130. package/web/_astro/{kanban-definition-UN3LZRKU.BPRdKWs_.js → kanban-definition-UN3LZRKU.DGySIntq.js} +1 -1
  131. package/web/_astro/{linear.zRsuuDTE.js → linear.BATV4RXu.js} +1 -1
  132. package/web/_astro/{mermaid.core.jAJTcMKc.js → mermaid.core.DzkwM3VX.js} +4 -4
  133. package/web/_astro/{mindmap-definition-RKZ34NQL.BffJxfCr.js → mindmap-definition-RKZ34NQL.3piBRRzA.js} +1 -1
  134. package/web/_astro/{pieDiagram-4H26LBE5.CacwWaE3.js → pieDiagram-4H26LBE5.DUNueLub.js} +1 -1
  135. package/web/_astro/{quadrantDiagram-W4KKPZXB.hXELD06-.js → quadrantDiagram-W4KKPZXB.9bihVbrt.js} +1 -1
  136. package/web/_astro/{requirementDiagram-4Y6WPE33.DdEbPcqT.js → requirementDiagram-4Y6WPE33.CkjsC-YT.js} +1 -1
  137. package/web/_astro/{sankeyDiagram-5OEKKPKP.DgaDocKv.js → sankeyDiagram-5OEKKPKP.Dbq4vaoQ.js} +1 -1
  138. package/web/_astro/{sequenceDiagram-3UESZ5HK.B0KScnAu.js → sequenceDiagram-3UESZ5HK.BivrH99P.js} +1 -1
  139. package/web/_astro/{stateDiagram-AJRCARHV.CV9M_WNc.js → stateDiagram-AJRCARHV.CqLQ1Vzz.js} +1 -1
  140. package/web/_astro/{stateDiagram-v2-BHNVJYJU.BOAo74Et.js → stateDiagram-v2-BHNVJYJU.DvvoLD3b.js} +1 -1
  141. package/web/_astro/{timeline-definition-PNZ67QCA.CqqepUMe.js → timeline-definition-PNZ67QCA.B-KR78gv.js} +1 -1
  142. package/web/_astro/{vennDiagram-CIIHVFJN.DDqe4dOG.js → vennDiagram-CIIHVFJN.Ck0Eieb5.js} +1 -1
  143. package/web/_astro/{wardleyDiagram-YWT4CUSO.B3R9OPdO.js → wardleyDiagram-YWT4CUSO.CRfdd_do.js} +1 -1
  144. package/web/_astro/{xychartDiagram-2RQKCTM6.B3SvgXpQ.js → xychartDiagram-2RQKCTM6.Ck_Jxk9C.js} +1 -1
  145. package/web/index.html +2 -2
  146. package/plugins/sp/lib/artifact-digest.generated.d.mts +0 -7
  147. package/plugins/sp/lib/artifact-digest.generated.mjs +0 -48
  148. package/plugins/sp/scripts/feature-sync-bounded.mjs +0 -301
  149. package/plugins/sp/scripts/feature-sync-bounded.ts +0 -481
  150. package/plugins/sp/scripts/idea-coverage-check.ts +0 -168
  151. package/plugins/sp/scripts/inline-pipeline-parity-check.ts +0 -298
  152. package/plugins/sp/scripts/record-feature-sync.mjs +0 -63
  153. package/plugins/sp/scripts/record-feature-sync.ts +0 -84
  154. package/plugins/sp/scripts/script-contract-check.ts +0 -506
  155. package/plugins/sp/scripts/stage-registry-adapter.ts +0 -1533
  156. package/plugins/sp/scripts/surface-drift-inventory.ts +0 -989
  157. package/plugins/sp/scripts/task-evidence-precheck.ts +0 -189
  158. package/plugins/sp/scripts/task-size-precheck.ts +0 -212
  159. package/plugins/sp/scripts/transition-shim-check.ts +0 -238
  160. package/plugins/sp/scripts/validate-commands.ts +0 -689
  161. package/plugins/sp/scripts/validate-flag-contracts.ts +0 -890
  162. package/plugins/sp/scripts/verify-answer-lint.ts +0 -549
  163. package/web/_astro/BoardApp.BxJuwD7I.js +0 -191
  164. package/web/_astro/channel.CI6N_tCg.js +0 -1
  165. package/web/_astro/index.CENnIEqT.css +0 -1
@@ -0,0 +1,226 @@
1
+ // packages/app/src/services/residual-scan.ts
2
+ import { join } from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ var MARKER_PATTERN = /TODO|FIXME|XXX|HACK/;
5
+ var PRIORITY_PATTERN = /^P[1-4]/;
6
+ var NONE_FINDING = /^(none( found)?|no (findings?|issues?)( found)?|—)\s*(\(.*\))?\.?$/i;
7
+ var DISPOSITION_HEADER = /^(Disposition|Action|Status|Resolution|Fixed)$/i;
8
+ var RESOLVED_DISPOSITION = /^(FIXED|RESOLVED|DONE)\b/i;
9
+ var DEFERRED_DISPOSITION = /^DEFER(RED)?\b/i;
10
+ var ANCHOR_PATTERN = /[A-Za-z0-9_./-]+\.[A-Za-z]+:[0-9]+/g;
11
+ var RANGE_ANCHOR = /([A-Za-z0-9_./-]+\.[A-Za-z]+):([0-9]+)-[0-9]+/g;
12
+ var EXCLUDED_PATHS = ["docs/tasks", "docs/features/", ".spur/"];
13
+ var ALLOW_PRAGMA = "residual-scan:allow";
14
+ function makeItemId(category, location, text) {
15
+ const normalized = text.trim().replace(/\s+/g, " ");
16
+ const hex = createHash("sha256").update(`${location}${normalized}`).digest("hex");
17
+ return `${category}:${hex.slice(0, 8)}`;
18
+ }
19
+ function normalizeAnchor(location) {
20
+ return location.replace(RANGE_ANCHOR, "$1:$2");
21
+ }
22
+ function locationOf(locationCell, finding) {
23
+ const cell = locationCell.trim().replace(/`/g, "");
24
+ if (cell.length > 0 && cell !== "—")
25
+ return normalizeAnchor(cell);
26
+ const backtick = finding.match(/`([^`]+)`/)?.[1];
27
+ return backtick === undefined ? "" : normalizeAnchor(backtick);
28
+ }
29
+ function parseReviewFindings(taskContent) {
30
+ const section = taskContent.split(/^### Review\b/m)[1];
31
+ if (section === undefined)
32
+ return [];
33
+ const body = section.split(/^### /m)[0] ?? "";
34
+ const out = [];
35
+ const lines = body.split(`
36
+ `);
37
+ for (let i = 0;i < lines.length; i++) {
38
+ const line = lines[i];
39
+ if (line === undefined || !line.trimStart().startsWith("|"))
40
+ continue;
41
+ const header = splitRow(line);
42
+ const priorityCol = header.findIndex((h) => h.trim() === "Priority");
43
+ if (priorityCol === -1) {
44
+ while (i + 1 < lines.length && lines[i + 1]?.trimStart().startsWith("|"))
45
+ i++;
46
+ continue;
47
+ }
48
+ const findingCol = header.findIndex((h) => h.trim() === "Finding");
49
+ const locationCol = header.findIndex((h) => h.trim() === "Location");
50
+ const dispositionCol = header.findIndex((h) => DISPOSITION_HEADER.test(h.trim()));
51
+ i++;
52
+ const sep = lines[i];
53
+ if (sep !== undefined && /^\s*\|[\s:|-]+\|\s*$/.test(sep))
54
+ i++;
55
+ while (i < lines.length) {
56
+ const row = lines[i];
57
+ if (row === undefined || !row.trimStart().startsWith("|"))
58
+ break;
59
+ const cells = splitRow(row);
60
+ const priority = (cells[priorityCol] ?? "").trim();
61
+ const finding = (cells[findingCol] ?? "").trim();
62
+ const disposition = dispositionCol === -1 ? "" : (cells[dispositionCol] ?? "").trim();
63
+ if (PRIORITY_PATTERN.test(priority) && !NONE_FINDING.test(finding) && finding.length > 0 && !RESOLVED_DISPOSITION.test(disposition)) {
64
+ const location = locationOf(cells[locationCol] ?? "", finding);
65
+ out.push(DEFERRED_DISPOSITION.test(disposition) ? { priority, location, text: finding, deferral: disposition } : { priority, location, text: finding });
66
+ }
67
+ i++;
68
+ }
69
+ }
70
+ return out;
71
+ }
72
+ function splitRow(line) {
73
+ return line.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
74
+ }
75
+ function parseDiffMarkers(addedLines) {
76
+ return addedLines.filter((l) => !EXCLUDED_PATHS.some((p) => l.file.startsWith(p))).filter((l) => !l.text.includes(ALLOW_PRAGMA)).filter((l) => MARKER_PATTERN.test(l.text)).map((l) => ({ location: `${l.file}:${l.line}`, text: l.text.trim() }));
77
+ }
78
+ function findUncheckedBoxes(taskContent) {
79
+ const path = "task-file";
80
+ return taskContent.split(`
81
+ `).map((text, idx) => ({ text: text.trim(), line: idx + 1 })).filter((l) => l.text.startsWith("- [ ]")).map((l) => ({ location: `${path}:${l.line}`, text: l.text }));
82
+ }
83
+ function classify(items, deferrals) {
84
+ const deferred = new Map(deferrals.map((d) => [d.id, d.reason]));
85
+ return items.map((item) => {
86
+ const id = makeItemId(item.category, item.location, item.text);
87
+ let klass;
88
+ if (item.category === "review-finding")
89
+ klass = item.priority?.startsWith("P4") ? "advisory" : "blocking";
90
+ else if (item.category === "staging-residue")
91
+ klass = "housekeeping";
92
+ else
93
+ klass = "blocking";
94
+ if (klass === "blocking" && item.category !== "unchecked-box") {
95
+ const p3Like = item.category === "diff-marker" || item.category === "review-finding" && (item.priority ?? "").startsWith("P3");
96
+ const reason = deferred.get(id);
97
+ if (p3Like && reason !== undefined && reason.trim().length > 0)
98
+ klass = "deferrable";
99
+ }
100
+ return {
101
+ id,
102
+ category: item.category,
103
+ class: klass,
104
+ priority: item.priority,
105
+ location: item.location,
106
+ text: item.text
107
+ };
108
+ });
109
+ }
110
+ function scanResiduals(inputs) {
111
+ const { wbs, base, taskContent, addedLines, stagingResidue, deferrals } = inputs;
112
+ const reviewRows = parseReviewFindings(taskContent);
113
+ const tableDeferrals = reviewRows.flatMap((r) => r.deferral === undefined ? [] : [{ id: makeItemId("review-finding", r.location, r.text), reason: r.deferral }]);
114
+ const review = reviewRows.map((r) => ({
115
+ category: "review-finding",
116
+ priority: r.priority,
117
+ location: r.location,
118
+ text: r.text
119
+ }));
120
+ const markers = base === null ? [] : parseDiffMarkers(addedLines).map((m) => ({
121
+ category: "diff-marker",
122
+ location: m.location,
123
+ text: m.text
124
+ }));
125
+ const boxes = findUncheckedBoxes(taskContent).map((b) => ({
126
+ category: "unchecked-box",
127
+ location: b.location,
128
+ text: b.text
129
+ }));
130
+ const residue = stagingResidue.map((p) => ({
131
+ category: "staging-residue",
132
+ location: p,
133
+ text: p
134
+ }));
135
+ const items = classify([...review, ...markers, ...boxes, ...residue], [...tableDeferrals, ...deferrals]);
136
+ const counts = { blocking: 0, deferrable: 0, advisory: 0, housekeeping: 0 };
137
+ for (const item of items)
138
+ counts[item.class]++;
139
+ return {
140
+ wbs,
141
+ base,
142
+ scanned: {
143
+ "review-finding": true,
144
+ "diff-marker": base !== null,
145
+ "unchecked-box": true,
146
+ "staging-residue": true
147
+ },
148
+ items,
149
+ counts
150
+ };
151
+ }
152
+ function blockingAnchors(items) {
153
+ const anchors = new Set;
154
+ for (const item of items) {
155
+ if (item.class !== "blocking")
156
+ continue;
157
+ for (const m of normalizeAnchor(item.location).matchAll(ANCHOR_PATTERN))
158
+ anchors.add(m[0]);
159
+ }
160
+ return [...anchors];
161
+ }
162
+ function foldVerdict(verdict, scan, existingFindings, maxFindings = 20) {
163
+ const blocking = scan.items.filter((i) => i.class === "blocking");
164
+ const deferrable = scan.items.filter((i) => i.class === "deferrable");
165
+ const evidence = `blocking=${blocking.length} deferrable=${deferrable.length} advisory=${scan.counts.advisory} housekeeping=${scan.counts.housekeeping}` + (blocking.length > 0 ? `; blocking ids: ${blocking.map((i) => i.id).join(", ")}` : "") + (deferrable.length > 0 ? `; deferrable ids: ${deferrable.map((i) => i.id).join(", ")}` : "");
166
+ const checks = verdict.checks.filter((c) => c.name !== "residual-sweep");
167
+ checks.push({ name: "residual-sweep", status: blocking.length > 0 ? "fail" : "pass", evidence });
168
+ const merged = new Set([
169
+ ...existingFindings.split(/\s+/).filter((a) => a.length > 0),
170
+ ...blockingAnchors(scan.items)
171
+ ]);
172
+ const findings = [...merged].sort().slice(0, maxFindings).map((a) => `${a} `).join("");
173
+ let verdictStatus = verdict.verdict === "PASS" ? "PASS" : "FAIL";
174
+ if (verdict.verdict === "PARTIAL")
175
+ verdictStatus = "PARTIAL";
176
+ else if (verdict.verdict === "FAIL")
177
+ verdictStatus = "FAIL";
178
+ else if (blocking.length > 0)
179
+ verdictStatus = "PARTIAL";
180
+ return { verdict: verdictStatus, checks, findings };
181
+ }
182
+ function renderReport(wbs, items, attemptCount) {
183
+ const lines = [
184
+ `# Residual report — ${wbs}`,
185
+ "",
186
+ `Attempt: ${attemptCount}`,
187
+ "",
188
+ "| Category | Class | Location | Text |",
189
+ "| --- | --- | --- | --- |"
190
+ ];
191
+ for (const item of items) {
192
+ lines.push(`| ${item.category} | ${item.class} | ${item.location} | ${item.text.replace(/\|/g, "\\|")} |`);
193
+ }
194
+ return `${lines.join(`
195
+ `)}
196
+ `;
197
+ }
198
+ function recordedVerdictPath(runDir, wbs, fs) {
199
+ const evidence = join(runDir, "..", "memory", "evidence");
200
+ const durable = join(evidence, `${wbs}-verdict.json`);
201
+ for (const path of [join(runDir, ".."), join(evidence, ".."), evidence, durable]) {
202
+ try {
203
+ if (fs.lstatSync(path).isSymbolicLink())
204
+ throw new Error(`residual-scan: symlink evidence path: ${path}`);
205
+ } catch (error) {
206
+ if (error.code !== "ENOENT")
207
+ throw error;
208
+ }
209
+ }
210
+ return fs.existsSync(durable) ? durable : join(runDir, `${wbs}-verdict.json`);
211
+ }
212
+ export {
213
+ scanResiduals,
214
+ renderReport,
215
+ recordedVerdictPath,
216
+ parseReviewFindings,
217
+ parseDiffMarkers,
218
+ normalizeAnchor,
219
+ makeItemId,
220
+ locationOf,
221
+ foldVerdict,
222
+ findUncheckedBoxes,
223
+ classify,
224
+ blockingAnchors,
225
+ ALLOW_PRAGMA
226
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shared spur-invocation helper for the sp plugin scripts (task 1007 R9, RF-architect-001).
3
+ *
4
+ * `spurCommand` and `defaultSpurBin` moved verbatim from `wrapup-steps.ts` and
5
+ * `workflow-step-profile.ts` so every surviving plugin script imports one copy (imported by
6
+ * relative path like `lib/env.ts`, so the standalone contract holds; not an app bundle
7
+ * because it carries no Spur-domain logic). Node/bun builtins and the vendored `./env`
8
+ * gateway only — bundled standalone by `superskill install`, so no `@gobing-ai/*` value
9
+ * imports (task 0669).
10
+ */
11
+
12
+ import { existsSync } from 'node:fs';
13
+ import { fileURLToPath } from 'node:url';
14
+ import { getEnvVar } from './env';
15
+
16
+ /** `spurBin` splits on whitespace into a command plus prefix args (so `bun x.ts` works). */
17
+ export function spurCommand(spurBin: string | undefined): { cmd: string; prefix: string[] } {
18
+ const parts = (spurBin ?? 'spur')
19
+ .trim()
20
+ .split(/\s+/)
21
+ .filter((p) => p.length > 0);
22
+ return { cmd: parts[0] ?? 'spur', prefix: parts.slice(1) };
23
+ }
24
+
25
+ /**
26
+ * Resolve the spur CLI monorepo-safely (twin-safe resolution:
27
+ * self-contained and no plugin script imports another):
28
+ * --spur-bin > SPUR_BIN > monorepo-local CLI entry > PATH `spur`.
29
+ */
30
+ export function defaultSpurBin(): string {
31
+ const fromEnv = getEnvVar('SPUR_BIN');
32
+ if (fromEnv) return fromEnv;
33
+ const local = fileURLToPath(new URL('../../../apps/cli/src/index.ts', import.meta.url));
34
+ if (existsSync(local)) return `bun ${local}`;
35
+ return 'spur';
36
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * GENERATED by scripts/commands/bundle-plugin-lib.ts — do not edit.
3
+ * Source of truth: packages/app/src/workflow/step-profile.ts (task 1005 R1).
4
+ */
5
+ export declare interface ActionCostLike {
6
+ cacheHit: number | null;
7
+ }
8
+ export declare interface ActionCostAttributionLike {
9
+ exact: ActionCostLike | null;
10
+ estimated: ActionCostLike | null;
11
+ }
12
+ export declare interface TraceActionEvent {
13
+ kind: string;
14
+ node?: string;
15
+ actionKind?: string;
16
+ durationMs?: number | null;
17
+ startedAt?: string | null;
18
+ completedAt?: string | null;
19
+ invocation?: Record<string, string | number | boolean> | null;
20
+ cost?: ActionCostAttributionLike | null;
21
+ }
22
+ export declare interface StepProfileRun {
23
+ runId: string;
24
+ events: readonly TraceActionEvent[];
25
+ }
26
+ export declare interface TraceRunEntry {
27
+ runId: string;
28
+ isDryRun?: boolean;
29
+ status?: string;
30
+ workflowName?: string;
31
+ }
32
+ export declare type SessionMode = 'fresh' | 'resumed' | 'mixed';
33
+ export declare interface StepProfileExecution {
34
+ runId: string;
35
+ node: string;
36
+ actionKind: string;
37
+ durationMs: number | null;
38
+ idleGapMs: number | null;
39
+ session: 'fresh' | 'resumed' | null;
40
+ cacheHit: number | null;
41
+ }
42
+ export declare interface StepProfileRow {
43
+ node: string;
44
+ actionKind: string;
45
+ runs: number;
46
+ executions: number;
47
+ durationMs: { p50: number | null; max: number | null };
48
+ idleGapMs: { p50: number | null };
49
+ session: SessionMode | null;
50
+ cacheHit: { p50: number | null; known: number; of: number };
51
+ flags: string[];
52
+ }
53
+ export declare interface StepProfile {
54
+ workflow: string;
55
+ windowSec: number;
56
+ sampledRuns: number;
57
+ rows: StepProfileRow[];
58
+ }
59
+ export declare const DEFAULT_LAST: number;
60
+ export declare const DEFAULT_WINDOW_SEC: number;
61
+ export declare function nearestRankP50(values: readonly number[]): number | null;
62
+ export declare function extractExecutions(runId: string, events: readonly TraceActionEvent[]): StepProfileExecution[];
63
+ export declare function rowFlags(row: StepProfileRow, windowSec: number): string[];
64
+ export declare function buildRows(executions: readonly StepProfileExecution[], windowSec: number): StepProfileRow[];
65
+ export declare function buildStepProfile(input: {
66
+ workflow: string;
67
+ windowSec: number;
68
+ runs: readonly StepProfileRun[];
69
+ }): StepProfile;
70
+ export declare function nonDryRuns(entries: readonly TraceRunEntry[]): TraceRunEntry[];
71
+ export declare function formatStepProfileHuman(profile: StepProfile): string;
@@ -0,0 +1,174 @@
1
+ // packages/app/src/workflow/step-profile.ts
2
+ var DEFAULT_LAST = 20;
3
+ var DEFAULT_WINDOW_SEC = 300;
4
+ function nearestRankP50(values) {
5
+ if (values.length === 0)
6
+ return null;
7
+ const sorted = [...values].sort((a, b) => a - b);
8
+ return sorted[Math.ceil(sorted.length / 2) - 1] ?? null;
9
+ }
10
+ function numeric(value) {
11
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
12
+ }
13
+ function msBetween(from, to) {
14
+ if (typeof from !== "string" || typeof to !== "string")
15
+ return null;
16
+ const start = Date.parse(from);
17
+ const end = Date.parse(to);
18
+ if (!Number.isFinite(start) || !Number.isFinite(end))
19
+ return null;
20
+ return end - start;
21
+ }
22
+ function sessionOf(event) {
23
+ const value = event.invocation?.continue;
24
+ if (value === true)
25
+ return "resumed";
26
+ if (value === false)
27
+ return "fresh";
28
+ return null;
29
+ }
30
+ function cacheHitOf(event) {
31
+ return numeric(event.cost?.exact?.cacheHit);
32
+ }
33
+ function startKey(event) {
34
+ const parsed = typeof event.startedAt === "string" ? Date.parse(event.startedAt) : Number.NaN;
35
+ return Number.isFinite(parsed) ? parsed : Number.POSITIVE_INFINITY;
36
+ }
37
+ function extractExecutions(runId, events) {
38
+ const actions = events.filter((e) => e.kind === "action").sort((a, b) => {
39
+ const left = startKey(a);
40
+ const right = startKey(b);
41
+ return left === right ? 0 : left - right;
42
+ });
43
+ const executions = [];
44
+ for (const [index, event] of actions.entries()) {
45
+ const previous = index === 0 ? undefined : actions[index - 1];
46
+ executions.push({
47
+ runId,
48
+ node: event.node ?? "",
49
+ actionKind: event.actionKind ?? "",
50
+ durationMs: numeric(event.durationMs),
51
+ idleGapMs: msBetween(previous?.completedAt, event.startedAt),
52
+ session: sessionOf(event),
53
+ cacheHit: cacheHitOf(event)
54
+ });
55
+ }
56
+ return executions;
57
+ }
58
+ function foldSession(executions) {
59
+ const known = new Set(executions.map((e) => e.session).filter((s) => s !== null));
60
+ if (known.size === 0)
61
+ return null;
62
+ if (known.size === 1)
63
+ return [...known][0] ?? null;
64
+ return "mixed";
65
+ }
66
+ function rowFlags(row, windowSec) {
67
+ const wMs = windowSec * 1000;
68
+ const flags = [];
69
+ const agentRun = row.actionKind === "agent.run";
70
+ const resumed = row.session === "resumed" || row.session === "mixed";
71
+ const p50 = row.durationMs.p50;
72
+ if (!agentRun && p50 !== null && p50 > wMs)
73
+ flags.push("step-over-window");
74
+ const idle = row.idleGapMs.p50;
75
+ if (agentRun && resumed && idle !== null && idle > wMs)
76
+ flags.push("resume-after-idle");
77
+ const hit = row.cacheHit.p50;
78
+ if (agentRun && resumed && row.cacheHit.known > 0 && hit !== null && hit < 0.5)
79
+ flags.push("resume-cold-cache");
80
+ if (agentRun && p50 !== null && p50 > 2 * wMs)
81
+ flags.push("agent-run-over-2w");
82
+ return flags;
83
+ }
84
+ function buildRows(executions, windowSec) {
85
+ const grouped = new Map;
86
+ for (const execution of executions) {
87
+ const key = `${execution.node}\x00${execution.actionKind}`;
88
+ const bucket = grouped.get(key);
89
+ if (bucket === undefined)
90
+ grouped.set(key, [execution]);
91
+ else
92
+ bucket.push(execution);
93
+ }
94
+ const rows = [];
95
+ for (const bucket of grouped.values()) {
96
+ const first = bucket[0];
97
+ if (first === undefined)
98
+ continue;
99
+ const durations = bucket.map((e) => e.durationMs).filter((d) => d !== null);
100
+ const gaps = bucket.map((e) => e.idleGapMs).filter((g) => g !== null);
101
+ const hits = bucket.map((e) => e.cacheHit).filter((h) => h !== null);
102
+ const row = {
103
+ node: first.node,
104
+ actionKind: first.actionKind,
105
+ runs: new Set(bucket.map((e) => e.runId)).size,
106
+ executions: bucket.length,
107
+ durationMs: {
108
+ p50: nearestRankP50(durations),
109
+ max: durations.length === 0 ? null : Math.max(...durations)
110
+ },
111
+ idleGapMs: { p50: nearestRankP50(gaps) },
112
+ session: first.actionKind === "agent.run" ? foldSession(bucket) : null,
113
+ cacheHit: {
114
+ p50: nearestRankP50(hits),
115
+ known: hits.length,
116
+ of: bucket.length
117
+ },
118
+ flags: []
119
+ };
120
+ row.flags = rowFlags(row, windowSec);
121
+ rows.push(row);
122
+ }
123
+ return rows.sort((a, b) => a.node === b.node ? a.actionKind.localeCompare(b.actionKind) : a.node.localeCompare(b.node));
124
+ }
125
+ function buildStepProfile(input) {
126
+ const executions = input.runs.flatMap((run) => extractExecutions(run.runId, run.events));
127
+ return {
128
+ workflow: input.workflow,
129
+ windowSec: input.windowSec,
130
+ sampledRuns: input.runs.length,
131
+ rows: buildRows(executions, input.windowSec)
132
+ };
133
+ }
134
+ function nonDryRuns(entries) {
135
+ return entries.filter((e) => e.isDryRun !== true && typeof e.runId === "string" && e.runId.length > 0);
136
+ }
137
+ function seconds(value) {
138
+ return value === null ? "?" : `${(value / 1000).toFixed(1)}s`;
139
+ }
140
+ function ratio(value) {
141
+ return value === null ? "?" : value.toFixed(2);
142
+ }
143
+ function formatStepProfileHuman(profile) {
144
+ const lines = [
145
+ `step profile — ${profile.workflow} (window ${profile.windowSec}s, ${profile.sampledRuns} sampled runs)`
146
+ ];
147
+ for (const row of profile.rows) {
148
+ lines.push([
149
+ row.node.padEnd(20),
150
+ row.actionKind.padEnd(14),
151
+ `${row.runs}/${row.executions}`.padEnd(8),
152
+ `p50=${seconds(row.durationMs.p50)}`.padEnd(12),
153
+ `max=${seconds(row.durationMs.max)}`.padEnd(12),
154
+ `idle=${seconds(row.idleGapMs.p50)}`.padEnd(12),
155
+ `session=${row.session ?? "?"}`.padEnd(15),
156
+ `cacheHit=${ratio(row.cacheHit.p50)} (${row.cacheHit.known}/${row.cacheHit.of})`.padEnd(20),
157
+ `flags=${row.flags.length === 0 ? "-" : row.flags.join(",")}`
158
+ ].join(" "));
159
+ }
160
+ return `${lines.join(`
161
+ `)}
162
+ `;
163
+ }
164
+ export {
165
+ rowFlags,
166
+ nonDryRuns,
167
+ nearestRankP50,
168
+ formatStepProfileHuman,
169
+ extractExecutions,
170
+ buildStepProfile,
171
+ buildRows,
172
+ DEFAULT_WINDOW_SEC,
173
+ DEFAULT_LAST
174
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sp",
3
- "version": "0.3.95",
3
+ "version": "0.3.97",
4
4
  "description": "Spur — a local-first harness engineering toolkit that wraps mainstream coding agents with constraint checking, workflow orchestration, and history analytics.",
5
5
  "extensions": {
6
6
  "pi": ["./hooks/pi/guard-extension.ts"]
@@ -50,11 +50,11 @@ version: 1
50
50
  roles:
51
51
  - id: scribe
52
52
  tier: cheap
53
- commands: [dev-gitmsg, dev-handover, dev-daily, dev-changelog, dev-refresh, rule-add, rule-refine, workflow-add, workflow-refine, spur-init]
53
+ commands: [dev-gitmsg, dev-handover, dev-job-dump, dev-daily, dev-changelog, dev-refresh, rule-add, rule-refine, workflow-add, workflow-refine, spur-init]
54
54
  stages: [changelog]
55
55
  - id: coder
56
56
  tier: standard
57
- commands: [dev-run, dev-unit, dev-debug, dev-simplify, dev-fixall, dev-reverse, dev-wrap, dev-wrapall, dev-gtd]
57
+ commands: [dev-run, dev-unit, dev-debug, dev-simplify, dev-fixall, dev-fixgha, dev-reverse, dev-wrap, dev-wrapall, dev-gtd]
58
58
  stages: [implement, test, wrap]
59
59
  - id: reviewer
60
60
  tier: capable-1
@@ -62,7 +62,7 @@ roles:
62
62
  stages: [verify, review, dogfood]
63
63
  - id: planner
64
64
  tier: capable-2
65
- commands: [dev-plan, dev-refine, dev-brainstorm, dev-idea, dev-runall, dev-parallel, dev-next, dev-arch, dev-refineall, dev-find-next, dev-feature-change]
65
+ commands: [dev-plan, dev-refine, dev-brainstorm, dev-idea, dev-runall, dev-parallel, dev-next, dev-job-resume, dev-arch, dev-refineall, dev-find-next, dev-feature-change]
66
66
  stages: [plan, refine, brainstorm]
67
67
  ```
68
68
 
@@ -10,7 +10,9 @@ import {
10
10
  openSync,
11
11
  readdirSync,
12
12
  readFileSync,
13
+ realpathSync,
13
14
  renameSync,
15
+ statSync,
14
16
  writeFileSync
15
17
  } from "fs";
16
18
  import { join } from "path";
@@ -74,6 +76,17 @@ function findFeatureFile(featureDir, featureId) {
74
76
  return name === undefined ? undefined : join(featureDir, name);
75
77
  }
76
78
  var nodeFsShim = {
79
+ realPath: realpathSync,
80
+ readDir: readdirSync,
81
+ stat: (path) => {
82
+ try {
83
+ return statSync(path);
84
+ } catch (error) {
85
+ if (error.code === "ENOENT")
86
+ return null;
87
+ throw error;
88
+ }
89
+ },
77
90
  ensureDir: (dir) => {
78
91
  mkdirSync(dir, { recursive: true });
79
92
  },
@@ -123,7 +136,7 @@ async function verify(featureId, runId, cmdOverride, spurBin, mode) {
123
136
  try {
124
137
  await new mod.ArtifactDao(db.adapter).record({
125
138
  runId,
126
- path: join(runDir, `${runId}-feature-verification.json`),
139
+ path: mod.featureReceiptPaths(runDir, featureId, runId).runScoped,
127
140
  kind: "feature-verification"
128
141
  });
129
142
  } finally {
@@ -33,7 +33,9 @@ import {
33
33
  openSync,
34
34
  readdirSync,
35
35
  readFileSync,
36
+ realpathSync,
36
37
  renameSync,
38
+ statSync,
37
39
  writeFileSync,
38
40
  } from 'node:fs';
39
41
  import { join } from 'node:path';
@@ -45,6 +47,7 @@ const SAFE_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
45
47
 
46
48
  /** Shape of the generated inline bundle / repo app source this script consumes. */
47
49
  interface VerificationModule {
50
+ featureReceiptPaths: typeof import('../../../packages/app/src/workflow/feature-verification-receipt')['featureReceiptPaths'];
48
51
  startFeatureVerificationReceipt: typeof import('../../../packages/app/src/workflow/feature-verification-receipt')['startFeatureVerificationReceipt'];
49
52
  completeFeatureVerificationReceipt: typeof import('../../../packages/app/src/workflow/feature-verification-receipt')['completeFeatureVerificationReceipt'];
50
53
  captureFeatureReceiptDigest: typeof import('../../../packages/app/src/workflow/feature-verification-receipt')['captureFeatureReceiptDigest'];
@@ -143,6 +146,16 @@ function findFeatureFile(featureDir: string, featureId: string): string | undefi
143
146
  // FileSystem port; only ensureDir/writeFile/rename are exercised on the
144
147
  // start/complete paths. Swap to createNodeFileSystem if more surface is needed.
145
148
  const nodeFsShim = {
149
+ realPath: realpathSync,
150
+ readDir: readdirSync,
151
+ stat: (path: string) => {
152
+ try {
153
+ return statSync(path);
154
+ } catch (error) {
155
+ if ((error as { code?: string }).code === 'ENOENT') return null;
156
+ throw error;
157
+ }
158
+ },
146
159
  ensureDir: (dir: string) => {
147
160
  mkdirSync(dir, { recursive: true });
148
161
  },
@@ -209,7 +222,7 @@ async function verify(
209
222
  try {
210
223
  await new mod.ArtifactDao(db.adapter as never).record({
211
224
  runId,
212
- path: join(runDir, `${runId}-feature-verification.json`),
225
+ path: mod.featureReceiptPaths(runDir, featureId, runId).runScoped,
213
226
  kind: 'feature-verification',
214
227
  });
215
228
  } finally {