@tekyzinc/gsd-t 3.29.11 → 4.0.14

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 (114) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/bin/gsd-t-parallel.cjs +64 -13
  3. package/bin/gsd-t.js +48 -376
  4. package/bin/journey-coverage.cjs +6 -3
  5. package/bin/parallel-cli.cjs +13 -1
  6. package/commands/gsd-t-complete-milestone.md +6 -12
  7. package/commands/gsd-t-debug.md +47 -533
  8. package/commands/gsd-t-design-decompose.md +24 -497
  9. package/commands/gsd-t-doc-ripple.md +23 -139
  10. package/commands/gsd-t-execute.md +41 -958
  11. package/commands/gsd-t-feature.md +2 -6
  12. package/commands/gsd-t-gap-analysis.md +3 -6
  13. package/commands/gsd-t-help.md +2 -4
  14. package/commands/gsd-t-impact.md +26 -295
  15. package/commands/gsd-t-init-scan-setup.md +7 -7
  16. package/commands/gsd-t-integrate.md +44 -369
  17. package/commands/gsd-t-milestone.md +25 -124
  18. package/commands/gsd-t-partition.md +28 -539
  19. package/commands/gsd-t-plan.md +26 -472
  20. package/commands/gsd-t-prd.md +25 -311
  21. package/commands/gsd-t-quick.md +1 -1
  22. package/commands/gsd-t-resume.md +0 -33
  23. package/commands/gsd-t-scan.md +45 -652
  24. package/commands/gsd-t-verify.md +52 -569
  25. package/commands/gsd-t-wave.md +41 -430
  26. package/package.json +1 -1
  27. package/scripts/gsd-t-calibration-hook.js +3 -1
  28. package/scripts/hooks/pre-commit-journey-coverage +0 -2
  29. package/scripts/hooks/pre-commit-playwright-gate +0 -2
  30. package/templates/CLAUDE-global.md +44 -173
  31. package/templates/CLAUDE-project.md +118 -104
  32. package/templates/prompts/design-verify-subagent.md +3 -0
  33. package/templates/prompts/qa-subagent.md +3 -0
  34. package/templates/prompts/red-team-subagent.md +5 -2
  35. package/templates/workflows/_lib.js +176 -0
  36. package/templates/workflows/gsd-t-debug.workflow.js +86 -0
  37. package/templates/workflows/gsd-t-execute.workflow.js +206 -0
  38. package/templates/workflows/gsd-t-integrate.workflow.js +71 -0
  39. package/templates/workflows/gsd-t-phase.workflow.js +94 -0
  40. package/templates/workflows/gsd-t-quick.workflow.js +72 -0
  41. package/templates/workflows/gsd-t-scan.workflow.js +711 -0
  42. package/templates/workflows/gsd-t-verify.workflow.js +348 -0
  43. package/templates/workflows/gsd-t-wave.workflow.js +43 -0
  44. package/bin/check-headless-sessions.js +0 -140
  45. package/bin/context-budget-audit.cjs +0 -447
  46. package/bin/context-meter-config.cjs +0 -101
  47. package/bin/context-meter-config.test.cjs +0 -101
  48. package/bin/event-stream.cjs +0 -205
  49. package/bin/gsd-t-benchmark-orchestrator.js +0 -437
  50. package/bin/gsd-t-capture-lint.cjs +0 -440
  51. package/bin/gsd-t-economics.cjs +0 -315
  52. package/bin/gsd-t-in-session-usage.cjs +0 -213
  53. package/bin/gsd-t-orchestrator-config.cjs +0 -161
  54. package/bin/gsd-t-orchestrator-queue.cjs +0 -180
  55. package/bin/gsd-t-orchestrator-recover.cjs +0 -231
  56. package/bin/gsd-t-orchestrator-worker.cjs +0 -219
  57. package/bin/gsd-t-orchestrator.js +0 -535
  58. package/bin/gsd-t-parallel-probe.cjs +0 -132
  59. package/bin/gsd-t-ratelimit-probe-worker.cjs +0 -237
  60. package/bin/gsd-t-ratelimit-probe.cjs +0 -648
  61. package/bin/gsd-t-report-tokens.cjs +0 -549
  62. package/bin/gsd-t-stream-feed-client.cjs +0 -151
  63. package/bin/gsd-t-token-backfill.cjs +0 -366
  64. package/bin/gsd-t-token-capture.cjs +0 -321
  65. package/bin/gsd-t-token-dashboard.cjs +0 -353
  66. package/bin/gsd-t-token-regenerate-log.cjs +0 -129
  67. package/bin/gsd-t-tool-attribution.cjs +0 -377
  68. package/bin/gsd-t-tool-cost.cjs +0 -195
  69. package/bin/gsd-t-transcript-tee.cjs +0 -246
  70. package/bin/gsd-t-unattended-heartbeat.cjs +0 -188
  71. package/bin/gsd-t-unattended-platform.cjs +0 -551
  72. package/bin/gsd-t-unattended-platform.js +0 -381
  73. package/bin/gsd-t-unattended-safety.cjs +0 -773
  74. package/bin/gsd-t-unattended-safety.js +0 -788
  75. package/bin/gsd-t-unattended.cjs +0 -2109
  76. package/bin/gsd-t-unattended.js +0 -1367
  77. package/bin/gsd-t-worker-dispatch.cjs +0 -211
  78. package/bin/handoff-lock.cjs +0 -249
  79. package/bin/handoff-lock.js +0 -249
  80. package/bin/headless-auto-spawn.cjs +0 -711
  81. package/bin/headless-auto-spawn.js +0 -373
  82. package/bin/headless-exit-codes.cjs +0 -67
  83. package/bin/live-activity-report.cjs +0 -615
  84. package/bin/log-tail.cjs +0 -81
  85. package/bin/m44-proof-measure.cjs +0 -285
  86. package/bin/m46-iter-proof.cjs +0 -149
  87. package/bin/m46-worker-proof.cjs +0 -201
  88. package/bin/m55-substrate-proof.cjs +0 -134
  89. package/bin/metrics-rollup.js +0 -200
  90. package/bin/model-windows.cjs +0 -99
  91. package/bin/model-windows.test.cjs +0 -75
  92. package/bin/parallelism-report.cjs +0 -535
  93. package/bin/runway-estimator.cjs +0 -242
  94. package/bin/spawn-plan-derive.cjs +0 -163
  95. package/bin/spawn-plan-status-updater.cjs +0 -292
  96. package/bin/spawn-plan-writer.cjs +0 -204
  97. package/bin/supervisor-pid-fingerprint.cjs +0 -126
  98. package/bin/token-budget.cjs +0 -265
  99. package/bin/unattended-watch-format.cjs +0 -178
  100. package/bin/watch-progress.js +0 -155
  101. package/commands/gsd-t-unattended-stop.md +0 -85
  102. package/commands/gsd-t-unattended-watch.md +0 -465
  103. package/commands/gsd-t-unattended.md +0 -476
  104. package/commands/gsd-t-visualize.md +0 -116
  105. package/scripts/gsd-t-context-meter.e2e.test.js +0 -364
  106. package/scripts/gsd-t-context-meter.js +0 -341
  107. package/scripts/gsd-t-context-meter.test.js +0 -471
  108. package/scripts/gsd-t-dashboard-server.js +0 -1203
  109. package/scripts/gsd-t-post-commit-spawn-plan.sh +0 -86
  110. package/scripts/gsd-t-transcript.html +0 -1821
  111. package/scripts/hooks/gsd-t-conversation-capture.js +0 -439
  112. package/scripts/hooks/gsd-t-in-session-usage-hook.js +0 -84
  113. package/scripts/spawn-plan-fmt-tokens.cjs +0 -80
  114. package/templates/hooks/post-commit-spawn-plan.sh +0 -85
@@ -1,381 +0,0 @@
1
- /**
2
- * gsd-t-unattended-platform.js
3
- *
4
- * Cross-platform helpers for the unattended supervisor (M36).
5
- *
6
- * This module is the SINGLE place where `process.platform` branches live.
7
- * Supervisor-core, watch-loop, and safety-rails import from here so that
8
- * the rest of the supervisor can stay platform-agnostic.
9
- *
10
- * Contract: .gsd-t/contracts/unattended-supervisor-contract.md v1.0.0
11
- * §5 Exit Code Table (timeout = 3, OS process-timeout = 124)
12
- * §7 Launch Handshake (spawn semantics)
13
- *
14
- * Task 1 of m36-cross-platform delivers:
15
- * - resolveClaudePath()
16
- * - isAlive(pid)
17
- * - spawnWorker(projectDir, timeoutMs)
18
- *
19
- * Cross-platform notes:
20
- * - darwin / linux paths are runtime-tested.
21
- * - win32 paths are implementation-complete but NOT runtime-tested on the
22
- * dev host (macOS). Spike C and the full Windows caveats matrix ship in
23
- * Task 3 (`docs/unattended-windows-caveats.md`).
24
- *
25
- * Zero external dependencies — Node built-ins only.
26
- */
27
-
28
- "use strict";
29
-
30
- const { spawnSync, spawn } = require("node:child_process");
31
-
32
- // ─── resolveClaudePath ───────────────────────────────────────────────────────
33
-
34
- /**
35
- * Resolve the executable name for the `claude` CLI on the current platform.
36
- *
37
- * Returns `'claude.cmd'` on win32 and `'claude'` everywhere else.
38
- *
39
- * This is intentionally a simple platform branch — it does NOT shell out to
40
- * `which` / `where`. The resolver assumes `claude` is on PATH; PATH lookup is
41
- * delegated to `spawnSync`, which is cross-platform and quoting-safe.
42
- *
43
- * Cross-platform:
44
- * - darwin / linux: returns `'claude'`. The macOS / Linux installer puts
45
- * `claude` on PATH via `/usr/local/bin` or `/opt/homebrew/bin`.
46
- * - win32: returns `'claude.cmd'`. The Anthropic Windows installer ships a
47
- * `.cmd` shim. Using the `.cmd` filename explicitly (instead of bare
48
- * `claude`) avoids `spawnSync` falling through to `cmd.exe /c claude`,
49
- * which would re-introduce the Spike C PowerShell quoting hazard.
50
- *
51
- * @returns {string} `'claude'` or `'claude.cmd'`
52
- */
53
- function resolveClaudePath() {
54
- return process.platform === "win32" ? "claude.cmd" : "claude";
55
- }
56
-
57
- // ─── isAlive ─────────────────────────────────────────────────────────────────
58
-
59
- /**
60
- * Cross-platform liveness check for a PID.
61
- *
62
- * Uses the POSIX trick `kill(pid, 0)` — sends signal 0, which performs all
63
- * permission and existence checks but delivers no signal. Node's
64
- * `process.kill` implements the same semantics on Windows.
65
- *
66
- * Errors:
67
- * - `ESRCH` → no such process. Returns `false`.
68
- * - `EPERM` → process exists but we don't own it. Returns `true` (we got
69
- * permission feedback, which proves the PID is live).
70
- * - other → unexpected; rethrown.
71
- *
72
- * @param {number} pid
73
- * @returns {boolean}
74
- */
75
- function isAlive(pid) {
76
- if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) {
77
- return false;
78
- }
79
- try {
80
- process.kill(pid, 0);
81
- return true;
82
- } catch (err) {
83
- if (err && err.code === "ESRCH") return false;
84
- if (err && err.code === "EPERM") return true; // exists, not ours
85
- throw err;
86
- }
87
- }
88
-
89
- // ─── spawnWorker ─────────────────────────────────────────────────────────────
90
-
91
- /**
92
- * Spawn a synchronous `claude -p '/gsd-t-resume'` worker iteration for the
93
- * unattended supervisor.
94
- *
95
- * Returns a normalized result object: `{ status, stdout, stderr, signal,
96
- * timedOut, error }`. Never throws — spawn errors are returned in `error`.
97
- *
98
- * Timeout semantics: when `spawnSync`'s `timeout` fires, the child is sent
99
- * SIGTERM (or the equivalent on win32), `status` is `null`, and `signal` is
100
- * non-null. We surface this as `timedOut: true` so callers can map to exit
101
- * code 3 per contract §5.
102
- *
103
- * Spawn recipe (uniform across platforms):
104
- * - `shell: false` → no shell quoting hazards
105
- * - `windowsHide: true` → no flashed window on win32
106
- * - explicit `claude.cmd` filename on win32 (see resolveClaudePath JSDoc)
107
- *
108
- * @todo Spike C: verify `claude.cmd -p "/gsd-t-resume"` dispatches correctly
109
- * under PowerShell + cmd.exe + Git Bash. See
110
- * `docs/unattended-windows-caveats.md` (Task 3 of m36-cross-platform).
111
- *
112
- * @param {string} projectDir Absolute path to the project directory (cwd).
113
- * @param {number} timeoutMs Wall-clock cap per worker iteration in ms.
114
- * @param {object} [opts] Optional overrides (test-mode hooks).
115
- * @param {string} [opts.bin] Override the resolved binary (test-mode only).
116
- * @param {string[]} [opts.args] Override args (defaults to `['-p', '/gsd-t-resume']`).
117
- * @param {object} [opts.env] Override env (defaults to `process.env`).
118
- * @returns {{
119
- * status: number|null,
120
- * stdout: string,
121
- * stderr: string,
122
- * signal: string|null,
123
- * timedOut: boolean,
124
- * error: Error|null
125
- * }}
126
- */
127
- function spawnWorker(projectDir, timeoutMs, opts = {}) {
128
- const bin = opts.bin || resolveClaudePath();
129
- const args = opts.args || ["-p", "/gsd-t-resume"];
130
- const env = opts.env || process.env;
131
-
132
- const result = spawnSync(bin, args, {
133
- cwd: projectDir,
134
- encoding: "utf8",
135
- timeout: timeoutMs,
136
- env,
137
- stdio: ["ignore", "pipe", "pipe"],
138
- shell: false,
139
- windowsHide: true,
140
- });
141
-
142
- // Normalize. spawnSync may return error if the binary cannot be launched
143
- // (ENOENT etc.) — surface it instead of throwing.
144
- const stdout = typeof result.stdout === "string" ? result.stdout : "";
145
- const stderr = typeof result.stderr === "string" ? result.stderr : "";
146
- const signal = result.signal || null;
147
- const status = typeof result.status === "number" ? result.status : null;
148
-
149
- // Timeout detection: when spawnSync's `timeout` option fires it sets
150
- // - status === null
151
- // - signal !== null (SIGTERM on POSIX, equivalent on win32)
152
- // - error.code === 'ETIMEDOUT' (Node surfaces it as a synthetic Error)
153
- // The ETIMEDOUT code is the authoritative signal — checking it
154
- // discriminates a genuine timeout from an ENOENT/spawn failure.
155
- const errCode = result.error && result.error.code;
156
- const timedOut =
157
- errCode === "ETIMEDOUT" || (status === null && signal !== null && !result.error);
158
-
159
- return {
160
- status,
161
- stdout,
162
- stderr,
163
- signal,
164
- timedOut,
165
- // Suppress the synthetic ETIMEDOUT error so callers can rely on
166
- // `timedOut` for the timeout case and `error` for genuine spawn failures.
167
- error: errCode === "ETIMEDOUT" ? null : result.error || null,
168
- };
169
- }
170
-
171
- // ─── spawnSupervisor ─────────────────────────────────────────────────────────
172
-
173
- /**
174
- * Spawn a detached unattended supervisor process.
175
- *
176
- * Implements the Launch Handshake from contract §7: the interactive launch
177
- * command forks a long-lived supervisor that outlives the parent, reads the
178
- * state file, and relays `claude -p` workers until the milestone terminates.
179
- *
180
- * Spawn recipe:
181
- * - `node {binPath} {...args}` — binPath should be the absolute path to
182
- * `bin/gsd-t-unattended.cjs` (the supervisor entry point), NOT gsd-t.js.
183
- * - `detached: true` — the child becomes a process-group leader on POSIX
184
- * (darwin/linux) so it survives the parent closing its terminal. On win32
185
- * the equivalent flag produces a separate process tree.
186
- * - `stdio: 'ignore'` — no pipes held open that would block the parent
187
- * from exiting.
188
- * - `windowsHide: true` (win32 only) — no flashed console window.
189
- * - `child.unref()` — the parent event loop will not wait on the child.
190
- *
191
- * Cross-platform notes:
192
- * - darwin / linux: runtime-tested.
193
- * - win32: implementation-complete; documented in
194
- * `docs/unattended-windows-caveats.md` (Task 3).
195
- *
196
- * @param {object} params
197
- * @param {string} params.binPath Absolute path to `bin/gsd-t-unattended.cjs`.
198
- * @param {string[]} params.args CLI args passed directly to the supervisor.
199
- * @param {string} params.cwd Project directory (supervisor's cwd).
200
- * @returns {{ pid: number }} The detached child's PID.
201
- */
202
- function spawnSupervisor({ binPath, args, cwd }) {
203
- const spawnArgs = [binPath, ...(args || [])];
204
- const opts = {
205
- cwd,
206
- detached: true,
207
- stdio: "ignore",
208
- };
209
- if (process.platform === "win32") {
210
- opts.windowsHide = true;
211
- }
212
- const child = spawn("node", spawnArgs, opts);
213
- child.unref();
214
- return { pid: child.pid };
215
- }
216
-
217
- // ─── preventSleep ────────────────────────────────────────────────────────────
218
-
219
- /**
220
- * Prevent the OS from going to sleep while the supervisor is running.
221
- *
222
- * Returns a handle that must be passed to `releaseSleep` when the supervisor
223
- * terminates.
224
- *
225
- * Cross-platform:
226
- * - darwin: `caffeinate -i -w <supervisor-pid>` — the `-w` flag ties the
227
- * caffeinate lifetime to the supervisor's PID. Even if the supervisor
228
- * forgets to call `releaseSleep`, caffeinate will self-exit when the
229
- * supervisor dies. Returns the caffeinate child PID as the handle.
230
- * - linux: returns `null`. Reliable sleep prevention requires
231
- * `systemd-inhibit`, which only works under a user session bus and is
232
- * not universally available. v1 documents the gap; v2 may add opt-in
233
- * systemd-inhibit. Prints a one-line notice to stderr.
234
- * - win32: returns `null`. `SetThreadExecutionState` is the native API but
235
- * requires a C binding. v1 documents the gap; see
236
- * `docs/unattended-windows-caveats.md` (Task 3).
237
- *
238
- * @param {string} [reason] Informational label (reserved; not currently used
239
- * — darwin's caffeinate has no reason field, and
240
- * linux/win32 don't have sleep prevention yet).
241
- * @returns {number|null} PID handle on darwin, `null` elsewhere.
242
- */
243
- function preventSleep(reason) {
244
- void reason; // reserved for future implementations
245
- if (process.platform === "darwin") {
246
- try {
247
- const child = spawn("caffeinate", ["-i", "-w", String(process.pid)], {
248
- detached: true,
249
- stdio: "ignore",
250
- });
251
- child.unref();
252
- return typeof child.pid === "number" ? child.pid : null;
253
- } catch (err) {
254
- process.stderr.write(
255
- `[platform] caffeinate failed to spawn: ${err && err.message}\n`,
256
- );
257
- return null;
258
- }
259
- }
260
- if (process.platform === "linux") {
261
- process.stderr.write(
262
- "[platform] sleep prevention not implemented on linux\n",
263
- );
264
- return null;
265
- }
266
- process.stderr.write(
267
- "[platform] sleep prevention not implemented on win32 (see docs/unattended-windows-caveats.md)\n",
268
- );
269
- return null;
270
- }
271
-
272
- // ─── releaseSleep ────────────────────────────────────────────────────────────
273
-
274
- /**
275
- * Release a sleep-prevention handle obtained from `preventSleep`.
276
- *
277
- * Idempotent and tolerant:
278
- * - `null` / non-number handle → no-op.
279
- * - handle is a dead PID → no-op (ESRCH is swallowed).
280
- * - handle is a live PID → `SIGTERM` is delivered (EPERM and other unusual
281
- * errors are swallowed — caller cannot reasonably act on them).
282
- *
283
- * @param {number|null} handle
284
- * @returns {void}
285
- */
286
- function releaseSleep(handle) {
287
- if (handle == null) return;
288
- if (typeof handle !== "number" || !Number.isInteger(handle) || handle <= 0) {
289
- return;
290
- }
291
- if (!isAlive(handle)) return;
292
- try {
293
- process.kill(handle, "SIGTERM");
294
- } catch (_err) {
295
- // Swallow — releaseSleep must never throw. A dead/gone process is fine;
296
- // an EPERM on an adopted PID is also fine (not ours to reap).
297
- }
298
- }
299
-
300
- // ─── notify ──────────────────────────────────────────────────────────────────
301
-
302
- /**
303
- * Emit an OS-level desktop notification. Fire-and-forget — never throws.
304
- *
305
- * Cross-platform:
306
- * - darwin: `osascript -e 'display notification "msg" with title "title"'`.
307
- * - linux: `notify-send "title" "message"` (requires libnotify).
308
- * - win32: `msg.exe * "title: message"` (console msg; ships with Windows).
309
- *
310
- * All platform helpers are fire-and-forget `spawn` calls. Errors are caught
311
- * and logged to stderr so a missing binary (e.g., no libnotify installed on a
312
- * headless Linux box) does NOT break the supervisor.
313
- *
314
- * @param {string} title
315
- * @param {string} message
316
- * @param {string} [level] `info` | `warn` | `done` | `failed` — accepted but
317
- * currently unused. Reserved for future formatting.
318
- * @returns {void}
319
- */
320
- function notify(title, message, level) {
321
- void level; // reserved for future formatting
322
- const safeTitle = String(title || "");
323
- const safeMessage = String(message || "");
324
- try {
325
- if (process.platform === "darwin") {
326
- // Escape double-quotes and backslashes for the AppleScript string
327
- // literal. osascript uses double-quoted string syntax.
328
- const esc = (s) => s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
329
- const script =
330
- `display notification "${esc(safeMessage)}" ` +
331
- `with title "${esc(safeTitle)}"`;
332
- const child = spawn("osascript", ["-e", script], { stdio: "ignore" });
333
- child.on("error", (err) => {
334
- process.stderr.write(
335
- `[platform] notify(osascript) failed: ${err && err.message}\n`,
336
- );
337
- });
338
- child.unref && child.unref();
339
- return;
340
- }
341
- if (process.platform === "linux") {
342
- const child = spawn("notify-send", [safeTitle, safeMessage], {
343
- stdio: "ignore",
344
- });
345
- child.on("error", (err) => {
346
- process.stderr.write(
347
- `[platform] notify(notify-send) failed: ${err && err.message}\n`,
348
- );
349
- });
350
- child.unref && child.unref();
351
- return;
352
- }
353
- // win32
354
- const child = spawn("msg.exe", ["*", `${safeTitle}: ${safeMessage}`], {
355
- stdio: "ignore",
356
- windowsHide: true,
357
- });
358
- child.on("error", (err) => {
359
- process.stderr.write(
360
- `[platform] notify(msg.exe) failed: ${err && err.message}\n`,
361
- );
362
- });
363
- child.unref && child.unref();
364
- } catch (err) {
365
- // Defense in depth — spawn() itself can throw synchronously on certain
366
- // argument errors. Never propagate.
367
- process.stderr.write(
368
- `[platform] notify synchronous error: ${err && err.message}\n`,
369
- );
370
- }
371
- }
372
-
373
- module.exports = {
374
- resolveClaudePath,
375
- isAlive,
376
- spawnWorker,
377
- spawnSupervisor,
378
- preventSleep,
379
- releaseSleep,
380
- notify,
381
- };