@gobing-ai/spur 0.4.0 → 0.4.2

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 (172) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/config/config.global.yaml +4 -2
  3. package/config/decisions/gates.yaml +36 -0
  4. package/config/decisions/history-anatomy.yaml +35 -0
  5. package/config/decisions/idea-pipeline.yaml +38 -0
  6. package/config/plugin-scripts.json +15 -0
  7. package/config/rules/docs/sourced-api-claims.yaml +60 -0
  8. package/config/rules/recommended-pre-check.yaml +8 -3
  9. package/config/rules/structure/scratch-evidence-pointer.yaml +35 -0
  10. package/config/script-placement-baseline.json +2 -2
  11. package/config/templates/AGENTS.md +1 -1
  12. package/config/workflows/feature-lifecycle.yaml +9 -2
  13. package/config/workflows/history-anatomy.yaml +22 -0
  14. package/config/workflows/idea-pipeline.yaml +75 -0
  15. package/config/workflows/task-pipeline.yaml +216 -57
  16. package/config/workflows/wrapup-pipeline.yaml +107 -14
  17. package/package.json +10 -10
  18. package/plugins/sp/README.md +12 -3
  19. package/plugins/sp/agents/super-planner.md +16 -6
  20. package/plugins/sp/agents/super-reviewer.md +14 -0
  21. package/plugins/sp/bunfig.toml +8 -0
  22. package/plugins/sp/commands/dev-brainstorm.md +29 -16
  23. package/plugins/sp/commands/dev-find-way.md +80 -0
  24. package/plugins/sp/commands/dev-idea.md +6 -0
  25. package/plugins/sp/commands/dev-plan.md +6 -0
  26. package/plugins/sp/commands/dev-review-session.md +4 -1
  27. package/plugins/sp/commands/dev-run.md +12 -2
  28. package/plugins/sp/commands/dev-runall.md +32 -15
  29. package/plugins/sp/hooks/context-owner.ts +56 -0
  30. package/plugins/sp/hooks/context-post-tool.ts +23 -0
  31. package/plugins/sp/hooks/context-session-start.ts +49 -27
  32. package/plugins/sp/hooks/context-session-stop.ts +131 -30
  33. package/plugins/sp/hooks/pi/guard-extension.ts +21 -8
  34. package/plugins/sp/lib/idea-handoff.generated.mjs +43 -5
  35. package/plugins/sp/lib/inline-run-app.ts +28 -0
  36. package/plugins/sp/lib/inline-run.generated.d.mts +5 -0
  37. package/plugins/sp/lib/inline-run.generated.mjs +351 -46
  38. package/plugins/sp/lib/plan-projection.generated.d.mts +47 -0
  39. package/plugins/sp/lib/plan-projection.generated.mjs +368 -0
  40. package/plugins/sp/lib/quality-gate.generated.d.mts +35 -1
  41. package/plugins/sp/lib/quality-gate.generated.mjs +30296 -71
  42. package/plugins/sp/lib/residual-scan.generated.d.mts +19 -0
  43. package/plugins/sp/lib/residual-scan.generated.mjs +66 -0
  44. package/plugins/sp/lib/run-summary-core.ts +561 -0
  45. package/plugins/sp/lib/transcript.ts +150 -7
  46. package/plugins/sp/plugin.json +1 -1
  47. package/plugins/sp/references/roles.md +1 -1
  48. package/plugins/sp/scripts/batch-plan.mjs +488 -0
  49. package/plugins/sp/scripts/batch-plan.ts +145 -0
  50. package/plugins/sp/scripts/batch-preflight.mjs +51 -3
  51. package/plugins/sp/scripts/batch-preflight.ts +72 -1
  52. package/plugins/sp/scripts/commit-guard.mjs +216 -0
  53. package/plugins/sp/scripts/commit-guard.ts +249 -0
  54. package/plugins/sp/scripts/inline-run-dispatch.mjs +130 -0
  55. package/plugins/sp/scripts/inline-run-dispatch.ts +135 -0
  56. package/plugins/sp/scripts/inline-run-setup.mjs +562 -80
  57. package/plugins/sp/scripts/inline-run-setup.ts +52 -78
  58. package/plugins/sp/scripts/persist-out-check.mjs +90 -41
  59. package/plugins/sp/scripts/persist-out-check.ts +112 -57
  60. package/plugins/sp/scripts/pr-reviewing.mjs +19 -5
  61. package/plugins/sp/scripts/pr-reviewing.ts +34 -9
  62. package/plugins/sp/scripts/quality-gate.mjs +30213 -61
  63. package/plugins/sp/scripts/quality-gate.ts +21 -5
  64. package/plugins/sp/scripts/residual-scan.mjs +86 -31
  65. package/plugins/sp/scripts/residual-scan.ts +28 -30
  66. package/plugins/sp/scripts/run-summary.mjs +432 -14
  67. package/plugins/sp/scripts/run-summary.ts +41 -177
  68. package/plugins/sp/scripts/session-timeline.mjs +109 -11
  69. package/plugins/sp/scripts/session-timeline.ts +57 -19
  70. package/plugins/sp/scripts/task-diffstat.mjs +32 -29
  71. package/plugins/sp/scripts/task-diffstat.ts +34 -34
  72. package/plugins/sp/scripts/wrapup-steps.mjs +150 -2
  73. package/plugins/sp/scripts/wrapup-steps.ts +203 -1
  74. package/plugins/sp/skills/brainstorm/SKILL.md +9 -47
  75. package/plugins/sp/skills/branch-workflow/SKILL.md +1 -0
  76. package/plugins/sp/skills/branch-workflow/references/worktree-patterns.md +1 -0
  77. package/plugins/sp/skills/code-implementation/SKILL.md +48 -1
  78. package/plugins/sp/skills/code-verification/SKILL.md +3 -4
  79. package/plugins/sp/skills/code-verification/references/secu-review.md +3 -0
  80. package/plugins/sp/skills/code-verification/references/verdict-schema.md +68 -0
  81. package/plugins/sp/skills/fleet-join/SKILL.md +1 -1
  82. package/plugins/sp/skills/indexed-context/SKILL.md +14 -7
  83. package/plugins/sp/skills/parallel-execution/SKILL.md +2 -2
  84. package/plugins/sp/skills/parallel-execution/references/dispatch-surface.md +1 -1
  85. package/plugins/sp/skills/parallel-execution/references/fan-out-patterns.md +2 -2
  86. package/plugins/sp/skills/pr-reviewing/SKILL.md +7 -3
  87. package/plugins/sp/skills/session-review/SKILL.md +40 -7
  88. package/plugins/sp/skills/source-driven-development/SKILL.md +5 -0
  89. package/plugins/sp/skills/spec-decomposition/references/decomposition.md +5 -3
  90. package/plugins/sp/skills/spur-cli/SKILL.md +5 -2
  91. package/plugins/sp/skills/spur-cli/references/agent.md +20 -15
  92. package/plugins/sp/skills/spur-cli/references/decision.md +16 -8
  93. package/plugins/sp/skills/spur-cli/references/message.md +7 -7
  94. package/plugins/sp/skills/spur-cli/references/projects.md +7 -5
  95. package/plugins/sp/skills/spur-cli/references/tasks/verbs.md +19 -3
  96. package/plugins/sp/skills/spur-cli/references/tasks.md +10 -7
  97. package/plugins/sp/skills/spur-cli/references/workflows/authoring-workflows.md +7 -0
  98. package/plugins/sp/skills/spur-cli/references/workflows.md +7 -2
  99. package/plugins/sp/skills/spur-composer/SKILL.md +1 -1
  100. package/plugins/sp/skills/spur-dev/SKILL.md +20 -14
  101. package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +33 -3
  102. package/plugins/sp/skills/spur-dev/references/cross-cutting.md +49 -14
  103. package/plugins/sp/skills/spur-dev/references/dev-operations.md +37 -17
  104. package/plugins/sp/skills/spur-dev/references/execution-batch-continuation.md +68 -0
  105. package/plugins/sp/skills/spur-dev/references/execution-batch-report.md +199 -0
  106. package/plugins/sp/skills/spur-dev/references/execution-batch.md +156 -1024
  107. package/plugins/sp/skills/spur-dev/references/execution-parallel-isolation.md +133 -0
  108. package/plugins/sp/skills/spur-dev/references/execution-workflow.md +6 -0
  109. package/plugins/sp/skills/spur-dev/references/execution-worktree-landing.md +471 -0
  110. package/plugins/sp/skills/spur-dev/references/execution-worktree-setup.md +379 -0
  111. package/plugins/sp/skills/spur-dev/references/flag-glossary.md +44 -12
  112. package/plugins/sp/skills/spur-dev/references/glossary.md +2 -2
  113. package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +340 -165
  114. package/plugins/sp/skills/spur-dev/references/structured-trace-emission.md +178 -0
  115. package/plugins/sp/skills/wayfinder/SKILL.md +10 -14
  116. package/schemas/state-machine-workflow.schema.json +23 -0
  117. package/spur.js +42402 -26889
  118. package/web/_astro/{BoardApp.VeoxxLBy.js → BoardApp.B3GQZvj8.js} +1 -1
  119. package/web/_astro/BoardApp.BT7L2kSb.js +324 -0
  120. package/web/_astro/TaskDetail.Cxov1_N_.js +1 -0
  121. package/web/_astro/{arc.f4e0OYLg.js → arc.vaT7tPOB.js} +1 -1
  122. package/web/_astro/{architectureDiagram-3BPJPVTR.SSIvxi-Z.js → architectureDiagram-3BPJPVTR.DRMmTjkN.js} +1 -1
  123. package/web/_astro/{blockDiagram-GPEHLZMM.DSXIHOFf.js → blockDiagram-GPEHLZMM.cla0LO_q.js} +1 -1
  124. package/web/_astro/{c4Diagram-AAUBKEIU.DG9Ubu85.js → c4Diagram-AAUBKEIU.D4YAIBKn.js} +1 -1
  125. package/web/_astro/channel.D4nG9YLf.js +1 -0
  126. package/web/_astro/{chunk-2J33WTMH.C7QU88Qh.js → chunk-2J33WTMH.BrSJbMRZ.js} +1 -1
  127. package/web/_astro/{chunk-4BX2VUAB.26Z94xBj.js → chunk-4BX2VUAB.CuLMgKF5.js} +1 -1
  128. package/web/_astro/{chunk-55IACEB6.DYRiBkqw.js → chunk-55IACEB6.zkvgu54F.js} +1 -1
  129. package/web/_astro/{chunk-727SXJPM.D5Vfv5pe.js → chunk-727SXJPM.DxWkACh8.js} +1 -1
  130. package/web/_astro/{chunk-AQP2D5EJ.DXHV47bN.js → chunk-AQP2D5EJ.42XrmIlH.js} +1 -1
  131. package/web/_astro/{chunk-FMBD7UC4.D1suAfOs.js → chunk-FMBD7UC4.Bao2wMK9.js} +1 -1
  132. package/web/_astro/{chunk-ND2GUHAM.D6BmdHEY.js → chunk-ND2GUHAM.BhydojD1.js} +1 -1
  133. package/web/_astro/{chunk-QZHKN3VN.rnPU-Ak-.js → chunk-QZHKN3VN.CmZ82g-H.js} +1 -1
  134. package/web/_astro/{classDiagram-4FO5ZUOK.CvEfXIo1.js → classDiagram-4FO5ZUOK.Blr83Gt_.js} +1 -1
  135. package/web/_astro/{classDiagram-v2-Q7XG4LA2.CvEfXIo1.js → classDiagram-v2-Q7XG4LA2.Blr83Gt_.js} +1 -1
  136. package/web/_astro/{cose-bilkent-S5V4N54A.DkMisLSm.js → cose-bilkent-S5V4N54A.qmfv0SPn.js} +1 -1
  137. package/web/_astro/{cynefin-OW5HDTMX.C77Q-pF6.js → cynefin-OW5HDTMX.BtELhXPR.js} +1 -1
  138. package/web/_astro/{dagre-BM42HDAG.YaV8ce27.js → dagre-BM42HDAG.AWmaAvXo.js} +1 -1
  139. package/web/_astro/{diagram-2AECGRRQ.CUyGEKge.js → diagram-2AECGRRQ.DdH34KDi.js} +1 -1
  140. package/web/_astro/{diagram-5GNKFQAL.CRgd8dgj.js → diagram-5GNKFQAL.BmNPix1k.js} +1 -1
  141. package/web/_astro/{diagram-KO2AKTUF.Bmzys9hq.js → diagram-KO2AKTUF.BNQd_Ppo.js} +1 -1
  142. package/web/_astro/{diagram-LMA3HP47.BvmJY4Lw.js → diagram-LMA3HP47.BAPgDi0e.js} +1 -1
  143. package/web/_astro/{diagram-OG6HWLK6.0hEhD30d.js → diagram-OG6HWLK6.DZ4zyLdC.js} +1 -1
  144. package/web/_astro/{erDiagram-TEJ5UH35.Bjt8lrnm.js → erDiagram-TEJ5UH35.Q1TySMmw.js} +1 -1
  145. package/web/_astro/{flowDiagram-I6XJVG4X.CJZTjRDV.js → flowDiagram-I6XJVG4X.BXhFBicG.js} +1 -1
  146. package/web/_astro/{ganttDiagram-6RSMTGT7._VqoVafc.js → ganttDiagram-6RSMTGT7.vHSgcuo2.js} +1 -1
  147. package/web/_astro/{gitGraphDiagram-PVQCEYII.CEDb7tVo.js → gitGraphDiagram-PVQCEYII.Bi1f73C7.js} +1 -1
  148. package/web/_astro/index.BhSwN8yY.css +1 -0
  149. package/web/_astro/{infoDiagram-5YYISTIA.CgwifPpK.js → infoDiagram-5YYISTIA.DPvXZEWm.js} +1 -1
  150. package/web/_astro/{ishikawaDiagram-YF4QCWOH.B99wx2J1.js → ishikawaDiagram-YF4QCWOH.Cz829fsV.js} +1 -1
  151. package/web/_astro/{journeyDiagram-JHISSGLW.2hRwJbEo.js → journeyDiagram-JHISSGLW.enRnB9Me.js} +1 -1
  152. package/web/_astro/{kanban-definition-UN3LZRKU.BahJkKNC.js → kanban-definition-UN3LZRKU.DnTNk6d2.js} +1 -1
  153. package/web/_astro/{linear.DguUUe6V.js → linear.BzGnBwNL.js} +1 -1
  154. package/web/_astro/{mermaid.core.CvgfmqVr.js → mermaid.core.CSbTpIVz.js} +4 -4
  155. package/web/_astro/{mindmap-definition-RKZ34NQL.B3qEA3x9.js → mindmap-definition-RKZ34NQL.DGJDy8zT.js} +1 -1
  156. package/web/_astro/{pieDiagram-4H26LBE5.FlWA-_ru.js → pieDiagram-4H26LBE5.HSPdi5_8.js} +1 -1
  157. package/web/_astro/{quadrantDiagram-W4KKPZXB.9bVn35X7.js → quadrantDiagram-W4KKPZXB.6Gv8mz2Y.js} +1 -1
  158. package/web/_astro/{requirementDiagram-4Y6WPE33.ChykIhct.js → requirementDiagram-4Y6WPE33.CnBCtFwa.js} +1 -1
  159. package/web/_astro/{sankeyDiagram-5OEKKPKP.Z2Y3hkYb.js → sankeyDiagram-5OEKKPKP.5M8VWAu8.js} +1 -1
  160. package/web/_astro/{sequenceDiagram-3UESZ5HK.J7JsHWDt.js → sequenceDiagram-3UESZ5HK.DN41XN-U.js} +1 -1
  161. package/web/_astro/{stateDiagram-AJRCARHV.DAPbiCSS.js → stateDiagram-AJRCARHV.ErOO3W8j.js} +1 -1
  162. package/web/_astro/{stateDiagram-v2-BHNVJYJU.D2jvSi0q.js → stateDiagram-v2-BHNVJYJU.B_ZHICM-.js} +1 -1
  163. package/web/_astro/{timeline-definition-PNZ67QCA.psW2ci29.js → timeline-definition-PNZ67QCA.CWdosr07.js} +1 -1
  164. package/web/_astro/{vennDiagram-CIIHVFJN.DlILYVmg.js → vennDiagram-CIIHVFJN.BHzYjNV5.js} +1 -1
  165. package/web/_astro/{wardleyDiagram-YWT4CUSO.xNWwLJnn.js → wardleyDiagram-YWT4CUSO.h8x4IwPX.js} +1 -1
  166. package/web/_astro/{xychartDiagram-2RQKCTM6.EU_BuH7V.js → xychartDiagram-2RQKCTM6.RTapW2X8.js} +1 -1
  167. package/web/index.html +2 -2
  168. package/plugins/sp/commands/dev-parallel.md +0 -31
  169. package/web/_astro/BoardApp.Bzr4OXrW.js +0 -324
  170. package/web/_astro/TaskDetail.LAyR_Pvn.js +0 -1
  171. package/web/_astro/channel.CUFdtWhm.js +0 -1
  172. package/web/_astro/index.Dg_3bOaJ.css +0 -1
@@ -3,8 +3,8 @@
3
3
 
4
4
  // plugins/sp/scripts/inline-run-setup.ts
5
5
  import { spawnSync } from "child_process";
6
- import { existsSync } from "fs";
7
- import { dirname, join, resolve } from "path";
6
+ import { existsSync as existsSync3 } from "fs";
7
+ import { dirname, join as join3, resolve } from "path";
8
8
  import { fileURLToPath } from "url";
9
9
 
10
10
  // plugins/sp/lib/env.ts
@@ -13,14 +13,530 @@ function getEnvVar(name, fallback) {
13
13
  return raw === undefined ? fallback : raw;
14
14
  }
15
15
 
16
+ // plugins/sp/lib/inline-run-app.ts
17
+ async function loadInlineApp(spurBin, resolveAppEntry, required) {
18
+ const { entry, portable } = resolveAppEntry(spurBin);
19
+ const app = await import(entry);
20
+ const missing = portable ? required.filter((name) => typeof app[name] !== "function") : [];
21
+ if (missing.length > 0) {
22
+ throw new Error(`inline application bundle ${entry} is older than its scripts — missing ${missing.join(", ")}. Reinstall sp with a superskill release that stages lib/ (commit b42961b), or pass --spur-bin <spur checkout>/apps/cli/src/index.ts.`);
23
+ }
24
+ return { app, portable };
25
+ }
26
+
27
+ // plugins/sp/lib/env.ts
28
+ function getEnvVars() {
29
+ return process.env;
30
+ }
31
+
32
+ // plugins/sp/lib/run-summary-core.ts
33
+ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
34
+ import { join as join2 } from "node:path";
35
+
36
+ // plugins/sp/lib/transcript.ts
37
+ import { existsSync, readdirSync } from "node:fs";
38
+ import { homedir } from "node:os";
39
+ import { join } from "node:path";
40
+ var SESSION_ID = /^[A-Za-z0-9_-]+$/;
41
+ var OPERATOR_TOOLS = new Set(["AskUserQuestion", "ask_user_question"]);
42
+ var PI_ROLES = new Set(["user", "assistant", "toolResult"]);
43
+ var zeroTokens = () => ({ input: 0, cacheCreate: 0, cacheRead: 0, output: 0 });
44
+ function formatDuration(ms) {
45
+ const s = Math.round(ms / 1000);
46
+ const h = Math.floor(s / 3600);
47
+ const m = Math.floor(s % 3600 / 60);
48
+ const ss = String(s % 60).padStart(2, "0");
49
+ return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${ss}` : `${m}:${ss}`;
50
+ }
51
+ function formatTokens(n) {
52
+ if (n >= 999500)
53
+ return `${(n / 1e6).toFixed(1)}M`;
54
+ return n >= 1000 ? `${Math.round(n / 1000)}k` : String(n);
55
+ }
56
+ function formatTokenSplit(t) {
57
+ if (!t)
58
+ return "n/a";
59
+ const nonCached = t.input + t.cacheCreate + t.output;
60
+ return `${formatTokens(nonCached + t.cacheRead)} / ${formatTokens(nonCached)}`;
61
+ }
62
+ function promptText(row) {
63
+ if (row.type === "custom_message") {
64
+ if (row.display === false)
65
+ return;
66
+ const text = typeof row.content === "string" ? row.content.trim() : "";
67
+ return text === "" ? undefined : text;
68
+ }
69
+ if (row.type === "message") {
70
+ if (row.message?.role !== "user")
71
+ return;
72
+ const text = firstTextContent(row);
73
+ if (text === undefined)
74
+ return;
75
+ return skillInvocationPrompt(text) ?? text;
76
+ }
77
+ if (row.type !== "user" || row.isMeta || row.isCompactSummary)
78
+ return;
79
+ const content = row.message?.content;
80
+ if (typeof content === "string")
81
+ return content;
82
+ if (!Array.isArray(content) || content.some((b) => b.type === "tool_result"))
83
+ return;
84
+ return content.find((b) => b.type === "text")?.text;
85
+ }
86
+ function firstTextContent(row) {
87
+ const content = row.message?.content;
88
+ if (typeof content === "string")
89
+ return content;
90
+ if (!Array.isArray(content))
91
+ return;
92
+ return content.find((b) => b.type === "text")?.text;
93
+ }
94
+ function skillInvocationPrompt(text) {
95
+ const name = /^\s*<skill name="([^"]+)"/.exec(text)?.[1];
96
+ if (name === undefined)
97
+ return;
98
+ const close = text.lastIndexOf("</skill>");
99
+ const args = close < 0 ? "" : text.slice(close + "</skill>".length).trim();
100
+ return args === "" ? `/${name}` : `/${name} ${args}`;
101
+ }
102
+ function sumTokens(all) {
103
+ const total = zeroTokens();
104
+ for (const t of all)
105
+ for (const k of Object.keys(total))
106
+ total[k] += t[k];
107
+ return total;
108
+ }
109
+ function sumSpans(spans) {
110
+ return {
111
+ workMs: spans.reduce((n, s) => n + s.workMs, 0),
112
+ waitMs: spans.reduce((n, s) => n + s.waitMs, 0),
113
+ toolCalls: spans.reduce((n, s) => n + s.toolCalls, 0),
114
+ tokens: sumTokens(spans.map((s) => s.tokens))
115
+ };
116
+ }
117
+ var newAcc = (ts) => ({
118
+ last: ts,
119
+ askMs: 0,
120
+ asks: new Map,
121
+ toolIds: new Set,
122
+ messages: new Map,
123
+ compactions: 0
124
+ });
125
+ function accumulate(acc, row, ts) {
126
+ acc.last = Math.max(acc.last, ts);
127
+ if (row.type === "message") {
128
+ const m = row.message;
129
+ if (m?.role === "assistant") {
130
+ const blocks2 = Array.isArray(m.content) ? m.content : [];
131
+ for (const b of blocks2) {
132
+ if (b.type === "toolCall" && b.id) {
133
+ acc.toolIds.add(b.id);
134
+ if (b.name && OPERATOR_TOOLS.has(b.name))
135
+ acc.asks.set(b.id, ts);
136
+ }
137
+ }
138
+ const u2 = m.usage;
139
+ if (u2 && row.id)
140
+ acc.messages.set(row.id, {
141
+ input: u2.input ?? 0,
142
+ cacheCreate: u2.cacheWrite ?? 0,
143
+ cacheRead: u2.cacheRead ?? 0,
144
+ output: u2.output ?? 0
145
+ });
146
+ } else if (m?.role === "toolResult" && m.toolCallId && acc.asks.has(m.toolCallId)) {
147
+ acc.askMs += ts - (acc.asks.get(m.toolCallId) ?? ts);
148
+ }
149
+ return;
150
+ }
151
+ if (row.type === "compaction")
152
+ acc.compactions++;
153
+ const blocks = Array.isArray(row.message?.content) ? row.message.content : [];
154
+ for (const b of blocks) {
155
+ if (b.type === "tool_use" && b.id) {
156
+ acc.toolIds.add(b.id);
157
+ if (b.name && OPERATOR_TOOLS.has(b.name))
158
+ acc.asks.set(b.id, ts);
159
+ } else if (b.type === "tool_result" && b.tool_use_id && acc.asks.has(b.tool_use_id)) {
160
+ acc.askMs += ts - (acc.asks.get(b.tool_use_id) ?? ts);
161
+ }
162
+ }
163
+ const u = row.message?.usage;
164
+ if (row.type === "assistant" && u && row.message?.id) {
165
+ acc.messages.set(row.message.id, {
166
+ input: u.input_tokens ?? 0,
167
+ cacheCreate: u.cache_creation_input_tokens ?? 0,
168
+ cacheRead: u.cache_read_input_tokens ?? 0,
169
+ output: u.output_tokens ?? 0
170
+ });
171
+ }
172
+ }
173
+ function isCompaction(row) {
174
+ return row.type === "compaction" || row.type === "system" && row.subtype === "compact_boundary";
175
+ }
176
+ function sniffFormat(rows) {
177
+ for (const row of rows) {
178
+ if (row.type === "message" && PI_ROLES.has(row.message?.role ?? ""))
179
+ return "pi";
180
+ if (row.type === "user" || row.type === "assistant")
181
+ return "claude";
182
+ }
183
+ return "unknown";
184
+ }
185
+ function parseRows(lines) {
186
+ const rows = [];
187
+ let skippedLines = 0;
188
+ for (const line of lines) {
189
+ if (!line.trim())
190
+ continue;
191
+ let row;
192
+ try {
193
+ row = JSON.parse(line);
194
+ } catch {
195
+ skippedLines++;
196
+ continue;
197
+ }
198
+ const ts = row.timestamp ? Date.parse(row.timestamp) : Number.NaN;
199
+ if (!Number.isNaN(ts))
200
+ rows.push([row, ts]);
201
+ }
202
+ return { rows, skippedLines, format: sniffFormat(rows.map(([r]) => r)) };
203
+ }
204
+ function resolveTranscript(env, projectsRoot = join(homedir(), ".claude", "projects"), override) {
205
+ if (override)
206
+ return existsSync(override) ? { ok: true, path: override } : { ok: false, reason: "no transcript" };
207
+ const id = env.CLAUDE_CODE_SESSION_ID;
208
+ if (!id) {
209
+ const piFile = env.PI_SESSION_FILE;
210
+ if (piFile !== undefined && piFile !== "") {
211
+ return existsSync(piFile) ? { ok: true, path: piFile } : { ok: false, reason: `PI_SESSION_FILE ${piFile} does not exist` };
212
+ }
213
+ return {
214
+ ok: false,
215
+ reason: "no host session id; pass --transcript <path> (pi: ~/.pi/agent/sessions/<cwd-slug>/<file>.jsonl, " + "or set PI_SESSION_FILE)"
216
+ };
217
+ }
218
+ if (!SESSION_ID.test(id))
219
+ return { ok: false, reason: "refusing a session id with path characters" };
220
+ if (!existsSync(projectsRoot))
221
+ return { ok: false, reason: `no transcript root ${projectsRoot}` };
222
+ for (const dir of readdirSync(projectsRoot)) {
223
+ const path = join(projectsRoot, dir, `${id}.jsonl`);
224
+ if (existsSync(path))
225
+ return { ok: true, path };
226
+ }
227
+ return { ok: false, reason: `no transcript for session ${id}` };
228
+ }
229
+
230
+ // plugins/sp/lib/run-summary-core.ts
231
+ var IDLE_GAP_MS = 300000;
232
+ var SHELL_TOOLS = new Set(["bash", "shell", "exec", "exec_command", "run_command", "command"]);
233
+ var SUBAGENT_TOOLS = new Set(["agent", "task", "invoke_subagent", "subagent", "dispatch_agent"]);
234
+ var OPERATOR_TOOLS2 = new Set(["askuserquestion", "ask_user_question"]);
235
+ var ACTOR_PRECEDENCE = ["operator", "subagent", "shell", "other"];
236
+ function actorOf(tool) {
237
+ const t = tool.toLowerCase().replace(/[^a-z_]/g, "");
238
+ if (OPERATOR_TOOLS2.has(t))
239
+ return "operator";
240
+ if (SUBAGENT_TOOLS.has(t))
241
+ return "subagent";
242
+ if (SHELL_TOOLS.has(t))
243
+ return "shell";
244
+ return "other";
245
+ }
246
+ function unionMs(spans, start, end) {
247
+ 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]);
248
+ let total = 0;
249
+ let cursor = Number.NaN;
250
+ let openUntil = Number.NaN;
251
+ for (const [a, b] of clipped) {
252
+ if (!Number.isFinite(cursor)) {
253
+ cursor = a;
254
+ openUntil = b;
255
+ continue;
256
+ }
257
+ if (a > openUntil) {
258
+ total += openUntil - cursor;
259
+ cursor = a;
260
+ openUntil = b;
261
+ } else {
262
+ openUntil = Math.max(openUntil, b);
263
+ }
264
+ }
265
+ if (Number.isFinite(cursor))
266
+ total += openUntil - cursor;
267
+ return total;
268
+ }
269
+ function subtract(spans, claimed) {
270
+ let free = spans;
271
+ for (const [ca, cb] of claimed) {
272
+ const next = [];
273
+ for (const [a, b] of free) {
274
+ if (cb <= a || ca >= b) {
275
+ next.push([a, b]);
276
+ continue;
277
+ }
278
+ if (ca > a)
279
+ next.push([a, ca]);
280
+ if (cb < b)
281
+ next.push([cb, b]);
282
+ }
283
+ free = next;
284
+ }
285
+ return free;
286
+ }
287
+ function actorSplit(rows, start, end) {
288
+ const empty = {
289
+ operatorMs: 0,
290
+ longestOperatorWaitMs: 0,
291
+ modelMs: 0,
292
+ shellMs: 0,
293
+ subagentMs: 0,
294
+ otherToolMs: 0,
295
+ idleMs: 0,
296
+ compactions: 0,
297
+ subagentErrors: 0
298
+ };
299
+ const window = end - start;
300
+ if (window <= 0)
301
+ return empty;
302
+ const calls = new Map;
303
+ const results = new Map;
304
+ const eventTs = [];
305
+ let compactions = 0;
306
+ for (const [row, ts] of rows) {
307
+ if (ts < start || ts > end)
308
+ continue;
309
+ eventTs.push(ts);
310
+ if (isCompaction(row))
311
+ compactions++;
312
+ const blocks = Array.isArray(row.message?.content) ? row.message?.content : [];
313
+ if (row.message?.role === "toolResult" && row.message.toolCallId !== undefined) {
314
+ results.set(row.message.toolCallId, { ts, isError: row.message.isError === true });
315
+ }
316
+ for (const b of blocks) {
317
+ if ((b.type === "tool_use" || b.type === "toolCall") && b.id !== undefined && b.name !== undefined) {
318
+ calls.set(b.id, { id: b.id, actor: actorOf(b.name), ts });
319
+ } else if (b.type === "tool_result" && b.tool_use_id !== undefined) {
320
+ results.set(b.tool_use_id, { ts, isError: b.is_error === true });
321
+ }
322
+ }
323
+ }
324
+ let subagentErrors = 0;
325
+ const resolved = [];
326
+ for (const call of calls.values()) {
327
+ const result = results.get(call.id);
328
+ if (result?.isError === true && call.actor === "subagent")
329
+ subagentErrors++;
330
+ resolved.push({ ...call, end: Math.min(result?.ts ?? end, end) });
331
+ }
332
+ const claimed = [];
333
+ const byActor = new Map;
334
+ for (const actor of ACTOR_PRECEDENCE) {
335
+ const mine = resolved.filter((r) => r.actor === actor).map((r) => [r.ts, r.end]);
336
+ const free = subtract(mine, claimed);
337
+ for (const span of free)
338
+ claimed.push(span);
339
+ const ms = unionMs(free, start, end);
340
+ byActor.set(actor, ms);
341
+ if (actor === "operator") {
342
+ empty.longestOperatorWaitMs = Math.max(0, ...mine.map(([a, b]) => b - a));
343
+ }
344
+ }
345
+ const boundaries = [...new Set([start, end, ...eventTs, ...claimed.flat()])].sort((a, b) => a - b);
346
+ const claimedSorted = [...claimed].sort((a, b) => a[0] - b[0]);
347
+ let idleMs = 0;
348
+ for (let i = 0;i < boundaries.length - 1; i++) {
349
+ const a = boundaries[i];
350
+ const b = boundaries[i + 1];
351
+ if (b - a < IDLE_GAP_MS)
352
+ continue;
353
+ if (claimedSorted.some(([ca, cb]) => ca < b && cb > a))
354
+ continue;
355
+ idleMs += b - a;
356
+ }
357
+ const accounted = (byActor.get("operator") ?? 0) + (byActor.get("subagent") ?? 0) + (byActor.get("shell") ?? 0) + (byActor.get("other") ?? 0) + idleMs;
358
+ return {
359
+ ...empty,
360
+ operatorMs: byActor.get("operator") ?? 0,
361
+ subagentMs: byActor.get("subagent") ?? 0,
362
+ shellMs: byActor.get("shell") ?? 0,
363
+ otherToolMs: byActor.get("other") ?? 0,
364
+ idleMs,
365
+ modelMs: Math.max(0, window - accounted),
366
+ compactions,
367
+ subagentErrors
368
+ };
369
+ }
370
+ function attemptWindow(attempts) {
371
+ const starts = attempts.map((a) => Date.parse(a.startedAt ?? "")).filter((n) => !Number.isNaN(n));
372
+ const ends = attempts.map((a) => Date.parse(a.completedAt ?? "")).filter((n) => !Number.isNaN(n));
373
+ return starts.length && ends.length ? [Math.min(...starts), Math.max(...ends)] : undefined;
374
+ }
375
+ function summaryRow(stage, status, span, measured) {
376
+ return {
377
+ stage,
378
+ status,
379
+ workMs: span.workMs,
380
+ waitMs: span.waitMs,
381
+ toolCalls: measured ? span.toolCalls : null,
382
+ tokens: measured ? span.tokens : null,
383
+ time: formatDuration(span.workMs),
384
+ wait: formatDuration(span.waitMs),
385
+ token: formatTokenSplit(measured ? span.tokens : null)
386
+ };
387
+ }
388
+ function buildRunSummary(lines, inputs, since, until) {
389
+ const windows = [];
390
+ for (const { label, progress } of inputs) {
391
+ const states = (progress.states ?? []).flatMap((s) => {
392
+ const w = attemptWindow((s.actions ?? []).flatMap((a) => a.attempts ?? []));
393
+ return w ? [{ s, w }] : [];
394
+ });
395
+ if (!states.length)
396
+ throw new Error(`progress for run ${progress.runId} has no timed attempts`);
397
+ if (inputs.length === 1) {
398
+ for (const { s, w } of states) {
399
+ const stage = (s.visit ?? 1) > 1 ? `${s.state} (visit ${s.visit})` : s.state;
400
+ windows.push({ stage, status: s.status ?? "", start: w[0], end: w[1] });
401
+ }
402
+ } else {
403
+ const stage = label ?? `${progress.workflow ?? "run"} ${progress.runId.slice(0, 8)}`;
404
+ const start = Math.min(...states.map(({ w }) => w[0]));
405
+ windows.push({
406
+ stage,
407
+ status: progress.status ?? "",
408
+ start,
409
+ end: Math.max(...states.map(({ w }) => w[1]))
410
+ });
411
+ }
412
+ }
413
+ windows.sort((a, b) => a.start - b.start);
414
+ const { rows, skippedLines } = parseRows(lines);
415
+ const measure = (start, end) => {
416
+ const acc = newAcc(start);
417
+ for (const [row, ts] of rows)
418
+ if (ts >= start && ts <= end && promptText(row) === undefined)
419
+ accumulate(acc, row, ts);
420
+ const span = {
421
+ workMs: end - start - acc.askMs,
422
+ waitMs: acc.askMs,
423
+ toolCalls: acc.toolIds.size,
424
+ tokens: sumTokens([...acc.messages.values()])
425
+ };
426
+ return { span, measured: acc.toolIds.size > 0 || acc.messages.size > 0 };
427
+ };
428
+ const sinceMs = since ? Date.parse(since) : Number.NaN;
429
+ const totalStart = Number.isNaN(sinceMs) ? Math.min(...windows.map((w) => w.start)) : sinceMs;
430
+ let totalEnd = Math.max(...windows.map((w) => w.end));
431
+ if (!Number.isNaN(sinceMs)) {
432
+ for (const [, ts] of rows)
433
+ if (ts >= sinceMs)
434
+ totalEnd = Math.max(totalEnd, ts);
435
+ }
436
+ const untilMs = until ? Date.parse(until) : Number.NaN;
437
+ if (!Number.isNaN(untilMs) && untilMs > totalStart)
438
+ totalEnd = untilMs;
439
+ const stageRows = windows.map((w) => {
440
+ const { span, measured } = measure(w.start, w.end);
441
+ return summaryRow(w.stage, w.status, span, measured);
442
+ });
443
+ const totalMeasure = measure(totalStart, totalEnd);
444
+ const statuses = [...new Set(inputs.map((i) => i.progress.status ?? ""))].join("/");
445
+ const total = summaryRow("Total", statuses, totalMeasure.span, totalMeasure.measured);
446
+ const overlaps = windows.some((w, i) => i > 0 && w.start < (windows[i - 1]?.end ?? 0));
447
+ const sum = sumSpans(stageRows.map((r) => ({ ...r, toolCalls: r.toolCalls ?? 0, tokens: r.tokens ?? zeroTokens() })));
448
+ const overhead = {
449
+ workMs: total.workMs - sum.workMs,
450
+ waitMs: total.waitMs - sum.waitMs,
451
+ toolCalls: (total.toolCalls ?? 0) - sum.toolCalls,
452
+ tokens: Object.fromEntries(Object.keys(sum.tokens).map((k) => [k, (total.tokens?.[k] ?? 0) - sum.tokens[k]]))
453
+ };
454
+ if (!overlaps && overhead.workMs > 0)
455
+ stageRows.push(summaryRow("driver overhead", "", overhead, totalMeasure.measured));
456
+ return {
457
+ available: true,
458
+ rows: stageRows,
459
+ total,
460
+ actors: actorSplit(rows, totalStart, totalEnd),
461
+ gate: { ms: null, reason: "no matching check receipt" },
462
+ skippedLines
463
+ };
464
+ }
465
+ function renderSummaryMarkdown(summary) {
466
+ const line = (r, bold = false) => {
467
+ const stage = bold ? `**${r.stage}**` : r.stage;
468
+ return `| ${stage} | ${r.status} | ${r.time} | ${r.wait} | ${r.toolCalls ?? "n/a"} | ${r.token} |`;
469
+ };
470
+ const a = summary.actors;
471
+ const window = summary.total.workMs + summary.total.waitMs;
472
+ const share = (ms) => window > 0 ? `${Math.round(ms / window * 100)}%` : "n/a";
473
+ const gate = summary.gate.ms === null ? `n/a (${summary.gate.reason})` : formatDuration(summary.gate.ms);
474
+ return [
475
+ "| Stage | Status | Time | Wait | Tool calls | Token (total / non-cached) |",
476
+ "| --- | --- | ---: | ---: | ---: | ---: |",
477
+ ...summary.rows.map((r) => line(r)),
478
+ line(summary.total, true),
479
+ "",
480
+ "| Actor | Time | Share |",
481
+ "| --- | ---: | ---: |",
482
+ `| operator wait (longest ${formatDuration(a.longestOperatorWaitMs)}) | ${formatDuration(a.operatorMs)} | ${share(a.operatorMs)} |`,
483
+ `| model | ${formatDuration(a.modelMs)} | ${share(a.modelMs)} |`,
484
+ `| shell | ${formatDuration(a.shellMs)} | ${share(a.shellMs)} |`,
485
+ `| of which gate (informational) | ${gate} | — |`,
486
+ `| subagent | ${formatDuration(a.subagentMs)} | ${share(a.subagentMs)} |`,
487
+ `| other tools | ${formatDuration(a.otherToolMs)} | ${share(a.otherToolMs)} |`,
488
+ `| idle / unattributed | ${formatDuration(a.idleMs)} | ${share(a.idleMs)} |`,
489
+ "",
490
+ `Compactions: ${a.compactions} · Subagent errors: ${a.subagentErrors}`
491
+ ].join(`
492
+ `);
493
+ }
494
+ function writeCloseSummary(run, opts = {}) {
495
+ const cwd = opts.cwd ?? process.cwd();
496
+ const runDir = join2(cwd, ".spur", "run");
497
+ const rel = join2(".spur", "run", `${run.runId}-summary.md`);
498
+ const abs = join2(cwd, rel);
499
+ const na = (reason) => {
500
+ mkdirSync(runDir, { recursive: true });
501
+ writeFileSync(abs, `Execution summary: n/a (${reason})
502
+ `);
503
+ return rel;
504
+ };
505
+ try {
506
+ if (run.startedAt === undefined)
507
+ return na("run row has no started_at");
508
+ const resolved = resolveTranscript(opts.env ?? getEnvVars(), opts.projectsRoot);
509
+ if (!resolved.ok)
510
+ return na(resolved.reason);
511
+ const lines = readFileSync(resolved.path, "utf8").split(`
512
+ `);
513
+ const summary = buildRunSummary(lines, [{ progress: run.progress }], run.startedAt, run.completedAt);
514
+ if (summary.rows.length === 0)
515
+ return na("no timed attempts");
516
+ mkdirSync(runDir, { recursive: true });
517
+ writeFileSync(abs, `${renderSummaryMarkdown(summary)}
518
+ `);
519
+ writeFileSync(join2(runDir, `${run.runId}-summary.json`), JSON.stringify({ ...summary, runId: run.runId, startedAt: run.startedAt, completedAt: run.completedAt }, null, 2));
520
+ return rel;
521
+ } catch (error) {
522
+ return na(error instanceof Error ? error.message : String(error));
523
+ }
524
+ }
525
+ // plugins/sp/scripts/run-summary.ts
526
+ if (false)
527
+ ;
528
+
16
529
  // plugins/sp/scripts/inline-run-setup.ts
17
530
  function usage() {
18
531
  const text = [
19
532
  "Usage: bun plugins/sp/scripts/inline-run-setup.ts --run-id <id> --file <definition> [--spur-bin <path>]",
20
533
  " bun plugins/sp/scripts/inline-run-setup.ts --fingerprint --task-file <path> [--feature-file <path>] [--spur-bin <path>]",
21
- " bun plugins/sp/scripts/inline-run-setup.ts --action --run-id <id> --node <state> --kind <kind> --status <done|failed> --ok <true|false> --duration-ms <n> [--estimated] [--spur-bin <path>]",
22
- " bun plugins/sp/scripts/inline-run-setup.ts --actions-file <json-file> --run-id <id> [--spur-bin <path>] (1007 R5 batch trace emission)",
23
- " bun plugins/sp/scripts/inline-run-setup.ts --close --run-id <id> --status <done|failed|paused> [--reason <terminal-reason>] [--spur-bin <path>]",
534
+ " bun plugins/sp/scripts/inline-run-setup.ts --action --run-id <id> --node <state> --kind <kind> --status <done|failed> --ok <true|false> [--duration-ms <n>] [--estimated] [--project-root <path>] [--spur-bin <path>]",
535
+ " bun plugins/sp/scripts/inline-run-setup.ts --node-enter --run-id <id> --node <state> [--project-root <path>] [--spur-bin <path>] (1136 R4: stamps the node enter time)",
536
+ " bun plugins/sp/scripts/inline-run-setup.ts --actions-file <json-file> --run-id <id> [--project-root <path>] [--spur-bin <path>] (1007 R5 batch trace emission)",
537
+ " bun plugins/sp/scripts/inline-run-setup.ts --close --run-id <id> --status <done|failed|paused> [--reason <terminal-reason>] [--no-summary] [--project-root <path>] [--spur-bin <path>]",
538
+ " --project-root (1136 R1) names the tree that OWNS the run row; without it the run row is read from the cwd tree, and a miss exits 1 with RUN_NOT_FOUND",
539
+ " --duration-ms is optional on --action (1136 R4): omitted, the duration is measured from the calling --node-enter; supplied, it records provenance host-reported",
24
540
  " bun plugins/sp/scripts/inline-run-setup.ts --persist-out --from <worktree-path> [--task-file <path>]... [--spur-bin <path>]",
25
541
  " terminal-reason is a closed enum (0937 R2): done, paused-operator, failed-check, failed-agent, failed-timeout, failed-guard, cancelled, interrupted, retry-exhausted",
26
542
  " close defaults (1051 AC1): --status done \u2192 reason done, --status paused \u2192 reason paused-operator; --status failed requires an explicit --reason",
@@ -42,30 +558,20 @@ function resolveAppEntry(spurBin) {
42
558
  for (const candidate of candidates) {
43
559
  const tokens = candidate.split(/\s+/).filter(Boolean);
44
560
  const mainModule = [...tokens].reverse().find((t) => t.endsWith(".ts"));
45
- if (mainModule === undefined || !existsSync(mainModule))
561
+ if (mainModule === undefined || !existsSync3(mainModule))
46
562
  continue;
47
563
  const repoRoot = resolve(dirname(mainModule), "..", "..", "..");
48
- const appEntry = join(repoRoot, "packages", "app", "src", "index.ts");
49
- if (existsSync(appEntry))
564
+ const appEntry = join3(repoRoot, "packages", "app", "src", "index.ts");
565
+ if (existsSync3(appEntry))
50
566
  return { entry: appEntry, portable: false };
51
567
  }
52
568
  const entry = fileURLToPath(new URL("../lib/inline-run.generated.mjs", import.meta.url));
53
- if (!existsSync(entry)) {
569
+ if (!existsSync3(entry)) {
54
570
  throw new Error("inline application bundle is missing \u2014 rebuild/install the sp plugin before running inline");
55
571
  }
56
572
  return { entry, portable: true };
57
573
  }
58
- var TERMINAL_REASONS = new Set([
59
- "done",
60
- "paused-operator",
61
- "failed-check",
62
- "failed-agent",
63
- "failed-timeout",
64
- "failed-guard",
65
- "cancelled",
66
- "interrupted",
67
- "retry-exhausted"
68
- ]);
574
+ var SETUP_EXPORTS = ["readInstalledInventory", "runInlineRunSetup", "writeInlineRunOutcome"];
69
575
  async function main() {
70
576
  if (!process.versions.bun) {
71
577
  const child = spawnSync("bun", [fileURLToPath(import.meta.url), ...process.argv.slice(2)], {
@@ -76,7 +582,7 @@ async function main() {
76
582
  process.exit(child.status ?? 1);
77
583
  }
78
584
  const flags = new Map;
79
- let fingerprint = false, action = false, close = false, decide = false, persistOut = false, estimated = false;
585
+ let fingerprint = false, action = false, close = false, decide = false, persistOut = false, nodeEnter = false, estimated = false, noSummary = false;
80
586
  const taskFiles = [];
81
587
  let spurBin = getEnvVar("SPUR_BIN") ?? "";
82
588
  const argv = process.argv.slice(2);
@@ -90,10 +596,14 @@ async function main() {
90
596
  close = true;
91
597
  else if (flag === "--decide")
92
598
  decide = true;
599
+ else if (flag === "--node-enter")
600
+ nodeEnter = true;
93
601
  else if (flag === "--persist-out")
94
602
  persistOut = true;
95
603
  else if (flag === "--estimated")
96
604
  estimated = true;
605
+ else if (flag === "--no-summary")
606
+ noSummary = true;
97
607
  else if (flag === "--task-file")
98
608
  taskFiles.push(argv[++i] ?? "");
99
609
  else if (flag === "--spur-bin")
@@ -108,6 +618,7 @@ async function main() {
108
618
  const optionsJson = flags.get("--options-json") ?? "";
109
619
  const node = flags.get("--node") ?? "";
110
620
  const kind = flags.get("--kind") ?? "";
621
+ const projectRoot = flags.get("--project-root") ?? "";
111
622
  const status = flags.get("--status") ?? "";
112
623
  const reason = flags.get("--reason") ?? "";
113
624
  const okRaw = flags.get("--ok") ?? "";
@@ -115,24 +626,14 @@ async function main() {
115
626
  const actionsFile = flags.get("--actions-file") ?? "";
116
627
  if (estimated && !action)
117
628
  usage();
629
+ if (noSummary && !close)
630
+ usage();
118
631
  if (fingerprint) {
119
632
  if (runId !== "" || file !== "" || taskFiles.length !== 1 || (taskFiles[0] ?? "").trim() === "")
120
633
  usage();
121
- const app2 = await import(resolveAppEntry(spurBin).entry);
634
+ const { app: app2 } = await loadInlineApp(spurBin, resolveAppEntry, ["runInlineRunFingerprint"]);
122
635
  process.exit(await app2.runInlineRunFingerprint({ taskFile: taskFiles[0] ?? "", featureFile }));
123
636
  }
124
- if (actionsFile !== "") {
125
- if (action || close || fingerprint || decide || persistOut || file !== "" || taskFiles.length > 0)
126
- usage();
127
- if (runId.trim() === "" || status !== "" || node !== "" || kind !== "")
128
- usage();
129
- if (okRaw !== "" || durationRaw !== "")
130
- usage();
131
- if (!SAFE_RUN_ID_RE.test(runId))
132
- refuseUnsafeRunId(runId);
133
- const app2 = await import(resolveAppEntry(spurBin).entry);
134
- process.exit(await app2.runInlineRunTraceBatch({ runId, actionsFile }));
135
- }
136
637
  if (decide) {
137
638
  if (action || close || fingerprint || file !== "" || taskFiles.length > 0)
138
639
  usage();
@@ -141,12 +642,14 @@ async function main() {
141
642
  if (!SAFE_RUN_ID_RE.test(runId))
142
643
  refuseUnsafeRunId(runId);
143
644
  try {
144
- const { entry: entry2, portable: portable2 } = resolveAppEntry(spurBin);
145
- const app2 = await import(entry2);
146
- const bundlePath = fileURLToPath(new URL("../lib/inline-run.generated.mjs", import.meta.url));
147
- const lib = await import(bundlePath);
148
- const enabled = await lib.resolveDecideDecisionMakerEnabled(process.cwd(), portable2 ? { embeddedSchemas: lib.EMBEDDED_SPUR_SCHEMAS } : undefined);
149
- process.exit(await app2.runInlineRunDecide({ runId, node, optionsFile: optionsJson, enabled }));
645
+ const { app: app2, portable: portable2 } = await loadInlineApp(spurBin, resolveAppEntry, ["runInlineRunDecide"]);
646
+ const { app: lib } = await loadInlineApp(spurBin, () => ({ entry: fileURLToPath(new URL("../lib/inline-run.generated.mjs", import.meta.url)), portable: portable2 }), ["resolveDecideDecisionMakerEnabled", "loadSpurConfig"]);
647
+ const loadOpts = portable2 ? { embeddedSchemas: lib.EMBEDDED_SPUR_SCHEMAS } : undefined;
648
+ const [enabled, spurConfig] = await Promise.all([
649
+ lib.resolveDecideDecisionMakerEnabled(process.cwd(), loadOpts),
650
+ lib.loadSpurConfig(process.cwd(), loadOpts)
651
+ ]);
652
+ process.exit(await app2.runInlineRunDecide({ runId, node, optionsFile: optionsJson, enabled, spurConfig }));
150
653
  } catch (error) {
151
654
  const message = error instanceof Error ? error.message : String(error);
152
655
  process.stdout.write(`${JSON.stringify({ ok: false, runId, error: message })}
@@ -159,59 +662,38 @@ async function main() {
159
662
  usage();
160
663
  if (from.trim() === "" || taskFiles.some((taskFile) => taskFile.trim() === ""))
161
664
  usage();
162
- const app2 = await import(resolveAppEntry(spurBin).entry);
665
+ const { app: app2 } = await loadInlineApp(spurBin, resolveAppEntry, ["runInlineRunPersistOut"]);
163
666
  process.exit(await app2.runInlineRunPersistOut({ from, taskFiles }));
164
667
  }
165
- if (action || close) {
166
- if (action && close)
167
- usage();
168
- if (runId.trim() === "" || status.trim() === "")
169
- usage();
668
+ if (nodeEnter || actionsFile !== "" || action || close) {
170
669
  if (!SAFE_RUN_ID_RE.test(runId))
171
670
  refuseUnsafeRunId(runId);
172
- const app2 = await import(resolveAppEntry(spurBin).entry);
173
- if (close) {
174
- if (!app2.isInlineRunCloseStatus(status))
175
- usage();
176
- if (reason.trim() === "" ? status === "failed" : !TERMINAL_REASONS.has(reason))
177
- usage();
178
- process.exit(await app2.runInlineRunTrace({
179
- runId,
180
- close: true,
181
- node: "",
182
- kind: "",
183
- status,
184
- ok: true,
185
- durationMs: 0,
186
- ...reason.trim() === "" ? {} : { reason }
187
- }));
188
- }
189
- if (node.trim() === "" || kind.trim() === "")
190
- usage();
191
- if (!app2.isInlineRunActionStatus(status))
192
- usage();
193
- if (okRaw !== "true" && okRaw !== "false")
194
- usage();
195
- const durationMs = Number(durationRaw);
196
- if (durationRaw.trim() === "" || !Number.isFinite(durationMs) || durationMs < 0)
197
- usage();
198
- process.exit(await app2.runInlineRunTrace({
671
+ const mode = nodeEnter ? "node-enter" : actionsFile !== "" ? "actions-file" : close ? "close" : "action";
672
+ const { app: app2 } = await loadInlineApp(spurBin, resolveAppEntry, ["runInlineRunTraceMode"]);
673
+ const code = await app2.runInlineRunTraceMode({
674
+ mode,
199
675
  runId,
200
- close: false,
201
676
  node,
202
677
  kind,
203
678
  status,
204
- ok: okRaw === "true",
205
- durationMs,
206
- ...estimated ? { estimated: true } : {}
207
- }));
679
+ reason,
680
+ ok: okRaw,
681
+ durationMs: durationRaw,
682
+ actionsFile,
683
+ projectRoot,
684
+ estimated,
685
+ noSummary,
686
+ ...noSummary ? {} : { summarize: async (run) => writeCloseSummary(run) }
687
+ });
688
+ if (code === 2)
689
+ usage();
690
+ process.exit(code);
208
691
  }
209
692
  if (runId.trim() === "" || file.trim() === "")
210
693
  usage();
211
694
  if (!SAFE_RUN_ID_RE.test(runId))
212
695
  refuseUnsafeRunId(runId);
213
- const { entry, portable } = resolveAppEntry(spurBin);
214
- const app = await import(entry);
696
+ const { app, portable } = await loadInlineApp(spurBin, resolveAppEntry, SETUP_EXPORTS);
215
697
  let inventory;
216
698
  try {
217
699
  inventory = await app.readInstalledInventory({