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