gsd-pi 2.29.0-dev.7612840 → 2.29.0-dev.77f06e2
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/README.md +24 -17
- package/dist/resources/extensions/bg-shell/process-manager.ts +13 -0
- package/dist/resources/extensions/gsd/auto-dashboard.ts +186 -65
- package/dist/resources/extensions/gsd/auto-post-unit.ts +6 -3
- package/dist/resources/extensions/gsd/auto-recovery.ts +16 -22
- package/dist/resources/extensions/gsd/auto-worktree-sync.ts +7 -6
- package/dist/resources/extensions/gsd/commands-handlers.ts +20 -1
- package/dist/resources/extensions/gsd/commands-logs.ts +13 -14
- package/dist/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
- package/dist/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
- package/dist/resources/extensions/gsd/commands.ts +53 -21
- package/dist/resources/extensions/gsd/json-persistence.ts +16 -1
- package/dist/resources/extensions/gsd/prompts/workflow-start.md +28 -0
- package/dist/resources/extensions/gsd/queue-order.ts +10 -11
- package/dist/resources/extensions/gsd/session-status-io.ts +23 -41
- package/dist/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
- package/dist/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
- package/dist/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
- package/dist/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
- package/dist/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
- package/dist/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
- package/dist/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
- package/dist/resources/extensions/gsd/workflow-templates/registry.json +85 -0
- package/dist/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
- package/dist/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
- package/dist/resources/extensions/gsd/workflow-templates/spike.md +69 -0
- package/dist/resources/extensions/gsd/workflow-templates.ts +241 -0
- package/dist/resources/extensions/mcp-client/index.ts +459 -0
- package/package.json +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +13 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +13 -0
- package/src/resources/extensions/bg-shell/process-manager.ts +13 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +186 -65
- package/src/resources/extensions/gsd/auto-post-unit.ts +6 -3
- package/src/resources/extensions/gsd/auto-recovery.ts +16 -22
- package/src/resources/extensions/gsd/auto-worktree-sync.ts +7 -6
- package/src/resources/extensions/gsd/commands-handlers.ts +20 -1
- package/src/resources/extensions/gsd/commands-logs.ts +13 -14
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
- package/src/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
- package/src/resources/extensions/gsd/commands.ts +53 -21
- package/src/resources/extensions/gsd/json-persistence.ts +16 -1
- package/src/resources/extensions/gsd/prompts/workflow-start.md +28 -0
- package/src/resources/extensions/gsd/queue-order.ts +10 -11
- package/src/resources/extensions/gsd/session-status-io.ts +23 -41
- package/src/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
- package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
- package/src/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
- package/src/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
- package/src/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
- package/src/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
- package/src/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
- package/src/resources/extensions/gsd/workflow-templates/registry.json +85 -0
- package/src/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
- package/src/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
- package/src/resources/extensions/gsd/workflow-templates/spike.md +69 -0
- package/src/resources/extensions/gsd/workflow-templates.ts +241 -0
- package/src/resources/extensions/mcp-client/index.ts +459 -0
- package/dist/resources/extensions/mcporter/index.ts +0 -525
- package/src/resources/extensions/mcporter/index.ts +0 -525
package/README.md
CHANGED
|
@@ -24,20 +24,21 @@ One command. Walk away. Come back to a built project with clean git history.
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
## What's New in v2.
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **CI/CD Pipeline** — three-stage promotion (Dev → Test → Prod) with automated versioning
|
|
36
|
-
- **Docker support** — containerized builds with multi-stage Dockerfile
|
|
37
|
-
- **`/gsd keys`** — full API key lifecycle management (list, add, remove, test, rotate, doctor)
|
|
38
|
-
- **Milestone parking** — park in-progress milestones to work on something else, unpark to resume
|
|
39
|
-
- **Studio** — experimental Electron desktop app (early preview)
|
|
27
|
+
## What's New in v2.29
|
|
28
|
+
|
|
29
|
+
- **Node.js 24 LTS** — CI, Docker, and package config all upgraded to Node 24 (Krypton)
|
|
30
|
+
- **`searchExcludeDirs` setting** — blacklist directories from `@` file autocomplete (e.g., `node_modules`, `dist`)
|
|
31
|
+
- **Automated releases** — prod-release now auto-generates changelogs, bumps versions, and publishes to npm
|
|
32
|
+
- **`/gsd logs`** — browse activity, debug, and metrics logs from within a session
|
|
33
|
+
- **Configurable screenshots** — browser-tools now support custom resolution, format, and quality
|
|
34
|
+
- **Pre-commit secret scanning** — automatic detection of hardcoded secrets in CI and locally
|
|
40
35
|
- **Per-project MCP config** — `.gsd/mcp.json` for project-scoped MCP server definitions
|
|
36
|
+
- **API request metrics** — track request counts for Copilot/subscription users
|
|
37
|
+
- **`/gsd keys`** — full API key lifecycle management (list, add, remove, test, rotate, doctor)
|
|
38
|
+
- **Advisory verification gate** — auto-discovered checks (lint/test from package.json) no longer doom-loop on pre-existing errors
|
|
39
|
+
- **Worktree living doc sync** — DECISIONS, REQUIREMENTS, PROJECT, and KNOWLEDGE now sync between worktree and project root
|
|
40
|
+
- **Windows non-ASCII path support** — `cpSync` fallback for usernames with special characters
|
|
41
|
+
- **`needs-discussion` routing** — milestones with draft context now route to the interactive discussion flow instead of stopping
|
|
41
42
|
|
|
42
43
|
See the full [Changelog](./CHANGELOG.md) for details.
|
|
43
44
|
|
|
@@ -62,6 +63,8 @@ Full documentation is available in the [`docs/`](./docs/) directory:
|
|
|
62
63
|
- **[CI/CD Pipeline](./docs/ci-cd-pipeline.md)** — three-stage promotion pipeline (Dev → Test → Prod)
|
|
63
64
|
- **[VS Code Extension](./vscode-extension/README.md)** — chat participant, sidebar dashboard, RPC integration
|
|
64
65
|
- **[Visualizer](./docs/visualizer.md)** — workflow visualizer with stats and discussion status
|
|
66
|
+
- **[Remote Questions](./docs/remote-questions.md)** — route decisions to Slack or Discord when human input is needed
|
|
67
|
+
- **[Dynamic Model Routing](./docs/dynamic-model-routing.md)** — complexity-based model selection and budget pressure
|
|
65
68
|
- **[Migration from v1](./docs/migration.md)** — `.planning` → `.gsd` migration
|
|
66
69
|
|
|
67
70
|
---
|
|
@@ -175,7 +178,7 @@ Auto mode is a state machine driven by files on disk. It reads `.gsd/STATE.md`,
|
|
|
175
178
|
|
|
176
179
|
9. **Adaptive replanning** — After each slice completes, the roadmap is reassessed. If the work revealed new information that changes the plan, slices are reordered, added, or removed before continuing.
|
|
177
180
|
|
|
178
|
-
10. **Verification enforcement** — Configure shell commands (`npm run lint`, `npm run test`, etc.) that run automatically after task execution. Failures trigger auto-fix retries before advancing. Configurable via `verification_commands`, `verification_auto_fix`, and `verification_max_retries` preferences.
|
|
181
|
+
10. **Verification enforcement** — Configure shell commands (`npm run lint`, `npm run test`, etc.) that run automatically after task execution. Failures trigger auto-fix retries before advancing. Auto-discovered checks from `package.json` run in advisory mode — they log warnings but don't block on pre-existing errors. Configurable via `verification_commands`, `verification_auto_fix`, and `verification_max_retries` preferences.
|
|
179
182
|
|
|
180
183
|
11. **Milestone validation** — After all slices complete, a `validate-milestone` gate compares roadmap success criteria against actual results before sealing the milestone.
|
|
181
184
|
|
|
@@ -307,6 +310,7 @@ On first run, GSD launches a branded setup wizard that walks you through LLM pro
|
|
|
307
310
|
| `/gsd cleanup` | Archive phase directories from completed milestones |
|
|
308
311
|
| `/gsd doctor` | Runtime health checks with auto-fix for common issues |
|
|
309
312
|
| `/gsd keys` | API key manager — list, add, remove, test, rotate, doctor |
|
|
313
|
+
| `/gsd logs` | Browse activity, debug, and metrics logs |
|
|
310
314
|
| `/gsd export --html` | Generate HTML report for current or completed milestone |
|
|
311
315
|
| `/worktree` (`/wt`) | Git worktree lifecycle — create, switch, merge, remove |
|
|
312
316
|
| `/voice` | Toggle real-time speech-to-text (macOS, Linux) |
|
|
@@ -447,6 +451,7 @@ auto_report: true
|
|
|
447
451
|
| `verification_max_retries` | Max retries for verification failures (default: 2) |
|
|
448
452
|
| `require_slice_discussion` | Pause auto-mode before each slice for human discussion review |
|
|
449
453
|
| `auto_report` | Auto-generate HTML reports after milestone completion (default: true) |
|
|
454
|
+
| `searchExcludeDirs` | Directories to exclude from `@` file autocomplete (e.g., `["node_modules", ".git", "dist"]`) |
|
|
450
455
|
|
|
451
456
|
### Agent Instructions
|
|
452
457
|
|
|
@@ -478,7 +483,7 @@ See the full [Token Optimization Guide](./docs/token-optimization.md) for detail
|
|
|
478
483
|
|
|
479
484
|
### Bundled Tools
|
|
480
485
|
|
|
481
|
-
GSD ships with
|
|
486
|
+
GSD ships with 16 extensions, all loaded automatically:
|
|
482
487
|
|
|
483
488
|
| Extension | What it provides |
|
|
484
489
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -490,12 +495,14 @@ GSD ships with 14 extensions, all loaded automatically:
|
|
|
490
495
|
| **Background Shell** | Long-running process management with readiness detection |
|
|
491
496
|
| **Subagent** | Delegated tasks with isolated context windows |
|
|
492
497
|
| **Mac Tools** | macOS native app automation via Accessibility APIs |
|
|
493
|
-
| **
|
|
498
|
+
| **MCP Client** | Native MCP server integration via @modelcontextprotocol/sdk |
|
|
494
499
|
| **Voice** | Real-time speech-to-text transcription (macOS, Linux — Ubuntu 22.04+) |
|
|
495
500
|
| **Slash Commands** | Custom command creation |
|
|
496
501
|
| **LSP** | Language Server Protocol integration — diagnostics, go-to-definition, references, hover, symbols, rename, code actions |
|
|
497
502
|
| **Ask User Questions** | Structured user input with single/multi-select |
|
|
498
503
|
| **Secure Env Collect** | Masked secret collection without manual .env editing |
|
|
504
|
+
| **Remote Questions** | Route decisions to Slack/Discord when human input is needed in headless/CI mode |
|
|
505
|
+
| **Universal Config** | Discover and import MCP servers and rules from other AI coding tools |
|
|
499
506
|
|
|
500
507
|
### Bundled Agents
|
|
501
508
|
|
|
@@ -597,7 +604,7 @@ gsd (CLI binary)
|
|
|
597
604
|
|
|
598
605
|
## Requirements
|
|
599
606
|
|
|
600
|
-
- **Node.js** ≥
|
|
607
|
+
- **Node.js** ≥ 22.0.0 (24 LTS recommended)
|
|
601
608
|
- **An LLM provider** — any of the 20+ supported providers (see [Use Any Model](#use-any-model))
|
|
602
609
|
- **Git** — initialized automatically if missing
|
|
603
610
|
|
|
@@ -375,6 +375,19 @@ export function cleanupAll(): void {
|
|
|
375
375
|
processes.clear();
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Kill all alive, non-persistent bg processes.
|
|
380
|
+
* Called between auto-mode units to prevent orphaned servers from
|
|
381
|
+
* keeping ports bound across task boundaries (#1209).
|
|
382
|
+
*/
|
|
383
|
+
export function killSessionProcesses(): void {
|
|
384
|
+
for (const [id, bg] of processes) {
|
|
385
|
+
if (bg.alive && !bg.persistAcrossSessions) {
|
|
386
|
+
killProcess(id, "SIGTERM");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
378
391
|
async function waitForProcessExit(bg: BgProcess, timeoutMs: number): Promise<boolean> {
|
|
379
392
|
if (!bg.alive) return true;
|
|
380
393
|
await new Promise<void>((resolve) => {
|
|
@@ -204,6 +204,13 @@ export function estimateTimeRemaining(): string | null {
|
|
|
204
204
|
|
|
205
205
|
// ─── Slice Progress Cache ─────────────────────────────────────────────────────
|
|
206
206
|
|
|
207
|
+
/** Cached task detail for the widget task checklist */
|
|
208
|
+
interface CachedTaskDetail {
|
|
209
|
+
id: string;
|
|
210
|
+
title: string;
|
|
211
|
+
done: boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
207
214
|
/** Cached slice progress for the widget — avoid async in render */
|
|
208
215
|
let cachedSliceProgress: {
|
|
209
216
|
done: number;
|
|
@@ -211,6 +218,8 @@ let cachedSliceProgress: {
|
|
|
211
218
|
milestoneId: string;
|
|
212
219
|
/** Real task progress for the active slice, if its plan file exists */
|
|
213
220
|
activeSliceTasks: { done: number; total: number } | null;
|
|
221
|
+
/** Full task list for the active slice checklist */
|
|
222
|
+
taskDetails: CachedTaskDetail[] | null;
|
|
214
223
|
} | null = null;
|
|
215
224
|
|
|
216
225
|
export function updateSliceProgressCache(base: string, mid: string, activeSid?: string): void {
|
|
@@ -221,6 +230,7 @@ export function updateSliceProgressCache(base: string, mid: string, activeSid?:
|
|
|
221
230
|
const roadmap = parseRoadmap(content);
|
|
222
231
|
|
|
223
232
|
let activeSliceTasks: { done: number; total: number } | null = null;
|
|
233
|
+
let taskDetails: CachedTaskDetail[] | null = null;
|
|
224
234
|
if (activeSid) {
|
|
225
235
|
try {
|
|
226
236
|
const planFile = resolveSliceFile(base, mid, activeSid, "PLAN");
|
|
@@ -231,6 +241,7 @@ export function updateSliceProgressCache(base: string, mid: string, activeSid?:
|
|
|
231
241
|
done: plan.tasks.filter(t => t.done).length,
|
|
232
242
|
total: plan.tasks.length,
|
|
233
243
|
};
|
|
244
|
+
taskDetails = plan.tasks.map(t => ({ id: t.id, title: t.title, done: t.done }));
|
|
234
245
|
}
|
|
235
246
|
} catch {
|
|
236
247
|
// Non-fatal — just omit task count
|
|
@@ -242,13 +253,19 @@ export function updateSliceProgressCache(base: string, mid: string, activeSid?:
|
|
|
242
253
|
total: roadmap.slices.length,
|
|
243
254
|
milestoneId: mid,
|
|
244
255
|
activeSliceTasks,
|
|
256
|
+
taskDetails,
|
|
245
257
|
};
|
|
246
258
|
} catch {
|
|
247
259
|
// Non-fatal — widget just won't show progress bar
|
|
248
260
|
}
|
|
249
261
|
}
|
|
250
262
|
|
|
251
|
-
export function getRoadmapSlicesSync(): {
|
|
263
|
+
export function getRoadmapSlicesSync(): {
|
|
264
|
+
done: number;
|
|
265
|
+
total: number;
|
|
266
|
+
activeSliceTasks: { done: number; total: number } | null;
|
|
267
|
+
taskDetails: CachedTaskDetail[] | null;
|
|
268
|
+
} | null {
|
|
252
269
|
return cachedSliceProgress;
|
|
253
270
|
}
|
|
254
271
|
|
|
@@ -349,87 +366,84 @@ export function updateProgressWidget(
|
|
|
349
366
|
const lines: string[] = [];
|
|
350
367
|
const pad = INDENT.base;
|
|
351
368
|
|
|
352
|
-
// ──
|
|
369
|
+
// ── Top bar ─────────────────────────────────────────────────────
|
|
353
370
|
lines.push(...ui.bar());
|
|
354
371
|
|
|
372
|
+
// ── Header: GSD AUTO ... elapsed ────────────────────────────────
|
|
355
373
|
const dot = pulseBright
|
|
356
374
|
? theme.fg("accent", GLYPH.statusActive)
|
|
357
375
|
: theme.fg("dim", GLYPH.statusPending);
|
|
358
376
|
const elapsed = formatAutoElapsed(accessors.getAutoStartTime());
|
|
359
377
|
const modeTag = accessors.isStepMode() ? "NEXT" : "AUTO";
|
|
360
|
-
const headerLeft = `${pad}${dot} ${theme.fg("accent", theme.bold("GSD"))}
|
|
378
|
+
const headerLeft = `${pad}${dot} ${theme.fg("accent", theme.bold("GSD"))} ${theme.fg("success", modeTag)}`;
|
|
361
379
|
const headerRight = elapsed ? theme.fg("dim", elapsed) : "";
|
|
362
380
|
lines.push(rightAlign(headerLeft, headerRight, width));
|
|
363
381
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (mid)
|
|
367
|
-
lines.push(truncateToWidth(`${pad}${theme.fg("dim", mid.title)}`, width));
|
|
368
|
-
}
|
|
369
|
-
|
|
382
|
+
// ── Context: project · slice · action (merged into one line) ────
|
|
383
|
+
const contextParts: string[] = [];
|
|
384
|
+
if (mid) contextParts.push(theme.fg("dim", mid.title));
|
|
370
385
|
if (slice && unitType !== "research-milestone" && unitType !== "plan-milestone") {
|
|
371
|
-
|
|
372
|
-
`${pad}${theme.fg("text", theme.bold(`${slice.id}: ${slice.title}`))}`,
|
|
373
|
-
width,
|
|
374
|
-
));
|
|
386
|
+
contextParts.push(theme.fg("text", theme.bold(`${slice.id}: ${slice.title}`)));
|
|
375
387
|
}
|
|
376
|
-
|
|
377
|
-
lines.push("");
|
|
378
|
-
|
|
379
388
|
const isHook = unitType.startsWith("hook/");
|
|
380
389
|
const target = isHook
|
|
381
390
|
? (unitId.split("/").pop() ?? unitId)
|
|
382
391
|
: (task ? `${task.id}: ${task.title}` : unitId);
|
|
383
|
-
|
|
392
|
+
contextParts.push(`${theme.fg("accent", "▸")} ${theme.fg("accent", verb)} ${theme.fg("text", target)}`);
|
|
393
|
+
|
|
384
394
|
const tierTag = tierBadge ? theme.fg("dim", `[${tierBadge}] `) : "";
|
|
385
395
|
const phaseBadge = `${tierTag}${theme.fg("dim", phaseLabel)}`;
|
|
386
|
-
|
|
387
|
-
lines.push(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
396
|
+
const contextLine = contextParts.join(theme.fg("dim", " · "));
|
|
397
|
+
lines.push(rightAlign(`${pad}${contextLine}`, phaseBadge, width));
|
|
398
|
+
|
|
399
|
+
// ── Two-column body ─────────────────────────────────────────────
|
|
400
|
+
// Left: progress, ETA, next, stats (fixed) | Right: task checklist (fixed, adjacent)
|
|
401
|
+
// Both columns sit left-to-center; empty space is on the right.
|
|
402
|
+
const divider = theme.fg("dim", "│");
|
|
403
|
+
const minTwoColWidth = 100;
|
|
404
|
+
const rightColFixed = 44;
|
|
405
|
+
const colGap = 5; // breathing room between columns
|
|
406
|
+
// Left column takes remaining space — no truncation on wide terminals
|
|
407
|
+
const useTwoCol = width >= minTwoColWidth;
|
|
408
|
+
const rightColWidth = useTwoCol ? rightColFixed : 0;
|
|
409
|
+
const leftColWidth = useTwoCol ? width - rightColWidth - colGap : width;
|
|
410
|
+
|
|
411
|
+
const roadmapSlices = mid ? getRoadmapSlicesSync() : null;
|
|
412
|
+
|
|
413
|
+
// Build left column: progress bar, ETA, next step, token stats
|
|
414
|
+
const leftLines: string[] = [];
|
|
415
|
+
|
|
416
|
+
if (roadmapSlices) {
|
|
417
|
+
const { done, total, activeSliceTasks } = roadmapSlices;
|
|
418
|
+
const barWidth = Math.max(6, Math.min(18, Math.floor(leftColWidth * 0.4)));
|
|
419
|
+
const pct = total > 0 ? done / total : 0;
|
|
420
|
+
const filled = Math.round(pct * barWidth);
|
|
421
|
+
const bar = theme.fg("success", "█".repeat(filled))
|
|
422
|
+
+ theme.fg("dim", "░".repeat(barWidth - filled));
|
|
423
|
+
|
|
424
|
+
let meta = theme.fg("dim", `${done}/${total} slices`);
|
|
425
|
+
if (activeSliceTasks && activeSliceTasks.total > 0) {
|
|
426
|
+
const taskNum = isHook
|
|
427
|
+
? Math.max(activeSliceTasks.done, 1)
|
|
428
|
+
: Math.min(activeSliceTasks.done + 1, activeSliceTasks.total);
|
|
429
|
+
meta += theme.fg("dim", ` · task ${taskNum}/${activeSliceTasks.total}`);
|
|
430
|
+
}
|
|
431
|
+
leftLines.push(truncateToWidth(`${pad}${bar} ${meta}`, leftColWidth));
|
|
414
432
|
|
|
415
|
-
|
|
433
|
+
const eta = estimateTimeRemaining();
|
|
434
|
+
if (eta) {
|
|
435
|
+
leftLines.push(truncateToWidth(`${pad}${theme.fg("dim", eta)}`, leftColWidth));
|
|
416
436
|
}
|
|
417
437
|
}
|
|
418
438
|
|
|
419
|
-
lines.push("");
|
|
420
|
-
|
|
421
439
|
if (next) {
|
|
422
|
-
|
|
440
|
+
leftLines.push(truncateToWidth(
|
|
423
441
|
`${pad}${theme.fg("dim", "→")} ${theme.fg("dim", `then ${next}`)}`,
|
|
424
|
-
|
|
442
|
+
leftColWidth,
|
|
425
443
|
));
|
|
426
444
|
}
|
|
427
445
|
|
|
428
|
-
//
|
|
429
|
-
lines.push("");
|
|
430
|
-
lines.push(truncateToWidth(theme.fg("dim", `${pad}${widgetPwd}`), width, theme.fg("dim", "…")));
|
|
431
|
-
|
|
432
|
-
// Token stats from current unit session + cumulative cost from metrics
|
|
446
|
+
// Token stats
|
|
433
447
|
{
|
|
434
448
|
const cmdCtx = accessors.getCmdCtx();
|
|
435
449
|
let totalInput = 0, totalOutput = 0;
|
|
@@ -464,7 +478,6 @@ export function updateProgressWidget(
|
|
|
464
478
|
if (totalOutput) sp.push(`↓${formatWidgetTokens(totalOutput)}`);
|
|
465
479
|
if (totalCacheRead) sp.push(`R${formatWidgetTokens(totalCacheRead)}`);
|
|
466
480
|
if (totalCacheWrite) sp.push(`W${formatWidgetTokens(totalCacheWrite)}`);
|
|
467
|
-
// Cache hit rate for current unit
|
|
468
481
|
if (totalCacheRead + totalInput > 0) {
|
|
469
482
|
const hitRate = Math.round((totalCacheRead / (totalCacheRead + totalInput)) * 100);
|
|
470
483
|
sp.push(`\u26A1${hitRate}%`);
|
|
@@ -483,33 +496,134 @@ export function updateProgressWidget(
|
|
|
483
496
|
sp.push(cxDisplay);
|
|
484
497
|
}
|
|
485
498
|
|
|
486
|
-
const
|
|
499
|
+
const tokenLine = sp.map(p => p.includes("\x1b[") ? p : theme.fg("dim", p))
|
|
487
500
|
.join(theme.fg("dim", " "));
|
|
501
|
+
leftLines.push(truncateToWidth(`${pad}${tokenLine}`, leftColWidth));
|
|
488
502
|
|
|
489
503
|
const modelId = cmdCtx?.model?.id ?? "";
|
|
490
504
|
const modelProvider = cmdCtx?.model?.provider ?? "";
|
|
491
|
-
const modelPhase = phaseLabel ? theme.fg("dim", `[${phaseLabel}] `) : "";
|
|
492
505
|
const modelDisplay = modelProvider && modelId
|
|
493
506
|
? `${modelProvider}/${modelId}`
|
|
494
507
|
: modelId;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
lines.push(rightAlign(`${pad}${sLeft}`, sRight, width));
|
|
508
|
+
if (modelDisplay) {
|
|
509
|
+
leftLines.push(truncateToWidth(`${pad}${theme.fg("dim", modelDisplay)}`, leftColWidth));
|
|
510
|
+
}
|
|
499
511
|
|
|
500
|
-
// Dynamic routing savings
|
|
512
|
+
// Dynamic routing savings
|
|
501
513
|
if (mLedger && mLedger.units.some(u => u.tier)) {
|
|
502
514
|
const savings = formatTierSavings(mLedger.units);
|
|
503
515
|
if (savings) {
|
|
504
|
-
|
|
516
|
+
leftLines.push(truncateToWidth(`${pad}${theme.fg("dim", savings)}`, leftColWidth));
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Build right column: task checklist (pegged to right edge)
|
|
522
|
+
const rightLines: string[] = [];
|
|
523
|
+
const taskDetails = roadmapSlices?.taskDetails ?? null;
|
|
524
|
+
const maxVisibleTasks = 8;
|
|
525
|
+
const rpad = " ";
|
|
526
|
+
|
|
527
|
+
if (useTwoCol) {
|
|
528
|
+
if (taskDetails && taskDetails.length > 0) {
|
|
529
|
+
const visibleTasks = taskDetails.slice(0, maxVisibleTasks);
|
|
530
|
+
for (const t of visibleTasks) {
|
|
531
|
+
const isCurrent = task && t.id === task.id;
|
|
532
|
+
const glyph = t.done
|
|
533
|
+
? theme.fg("success", GLYPH.statusDone)
|
|
534
|
+
: isCurrent
|
|
535
|
+
? theme.fg("accent", "▸")
|
|
536
|
+
: theme.fg("dim", " ");
|
|
537
|
+
const label = isCurrent
|
|
538
|
+
? theme.fg("text", `${t.id}: ${t.title}`)
|
|
539
|
+
: t.done
|
|
540
|
+
? theme.fg("dim", `${t.id}: ${t.title}`)
|
|
541
|
+
: theme.fg("text", `${t.id}: ${t.title}`);
|
|
542
|
+
rightLines.push(truncateToWidth(`${rpad}${glyph} ${label}`, rightColWidth));
|
|
543
|
+
}
|
|
544
|
+
if (taskDetails.length > maxVisibleTasks) {
|
|
545
|
+
rightLines.push(truncateToWidth(
|
|
546
|
+
`${rpad}${theme.fg("dim", ` …+${taskDetails.length - maxVisibleTasks} more`)}`,
|
|
547
|
+
rightColWidth,
|
|
548
|
+
));
|
|
549
|
+
}
|
|
550
|
+
} else if (roadmapSlices?.activeSliceTasks) {
|
|
551
|
+
const { done: tDone, total: tTotal } = roadmapSlices.activeSliceTasks;
|
|
552
|
+
rightLines.push(`${rpad}${theme.fg("dim", `${tDone}/${tTotal} tasks`)}`);
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
// Narrow single-column: task list goes into left column
|
|
556
|
+
if (taskDetails && taskDetails.length > 0) {
|
|
557
|
+
for (const t of taskDetails.slice(0, maxVisibleTasks)) {
|
|
558
|
+
const isCurrent = task && t.id === task.id;
|
|
559
|
+
const glyph = t.done
|
|
560
|
+
? theme.fg("success", GLYPH.statusDone)
|
|
561
|
+
: isCurrent
|
|
562
|
+
? theme.fg("accent", "▸")
|
|
563
|
+
: theme.fg("dim", " ");
|
|
564
|
+
const label = isCurrent
|
|
565
|
+
? theme.fg("text", `${t.id}: ${t.title}`)
|
|
566
|
+
: t.done
|
|
567
|
+
? theme.fg("dim", `${t.id}: ${t.title}`)
|
|
568
|
+
: theme.fg("text", `${t.id}: ${t.title}`);
|
|
569
|
+
leftLines.push(truncateToWidth(`${pad}${glyph} ${label}`, leftColWidth));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// Add progress bar inline
|
|
573
|
+
if (roadmapSlices) {
|
|
574
|
+
const { done, total, activeSliceTasks } = roadmapSlices;
|
|
575
|
+
const barWidth = Math.max(6, Math.min(18, Math.floor(leftColWidth * 0.4)));
|
|
576
|
+
const pct = total > 0 ? done / total : 0;
|
|
577
|
+
const filled = Math.round(pct * barWidth);
|
|
578
|
+
const bar = theme.fg("success", "█".repeat(filled))
|
|
579
|
+
+ theme.fg("dim", "░".repeat(barWidth - filled));
|
|
580
|
+
let meta = theme.fg("dim", `${done}/${total} slices`);
|
|
581
|
+
if (activeSliceTasks && activeSliceTasks.total > 0) {
|
|
582
|
+
const taskNum = isHook
|
|
583
|
+
? Math.max(activeSliceTasks.done, 1)
|
|
584
|
+
: Math.min(activeSliceTasks.done + 1, activeSliceTasks.total);
|
|
585
|
+
meta += theme.fg("dim", ` · task ${taskNum}/${activeSliceTasks.total}`);
|
|
505
586
|
}
|
|
587
|
+
const eta = estimateTimeRemaining();
|
|
588
|
+
if (eta) meta += theme.fg("dim", ` · ${eta}`);
|
|
589
|
+
leftLines.push(truncateToWidth(`${pad}${bar} ${meta}`, leftColWidth));
|
|
590
|
+
}
|
|
591
|
+
if (next) {
|
|
592
|
+
leftLines.push(truncateToWidth(
|
|
593
|
+
`${pad}${theme.fg("dim", "→")} ${theme.fg("dim", `then ${next}`)}`,
|
|
594
|
+
leftColWidth,
|
|
595
|
+
));
|
|
506
596
|
}
|
|
507
597
|
}
|
|
508
598
|
|
|
599
|
+
// Compose columns
|
|
600
|
+
if (useTwoCol) {
|
|
601
|
+
const maxRows = Math.max(leftLines.length, rightLines.length);
|
|
602
|
+
if (maxRows > 0) {
|
|
603
|
+
lines.push(""); // spacer before columns
|
|
604
|
+
for (let i = 0; i < maxRows; i++) {
|
|
605
|
+
const left = padToWidth(leftLines[i] ?? "", leftColWidth);
|
|
606
|
+
const gap = " ".repeat(colGap - 2); // colGap minus divider and its trailing space
|
|
607
|
+
const right = rightLines[i] ?? "";
|
|
608
|
+
lines.push(truncateToWidth(`${left}${gap}${divider} ${right}`, width));
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
// Narrow single-column: just stack
|
|
613
|
+
if (leftLines.length > 0) {
|
|
614
|
+
lines.push("");
|
|
615
|
+
for (const l of leftLines) lines.push(l);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// ── Footer: pwd + hints ─────────────────────────────────────────
|
|
620
|
+
lines.push("");
|
|
509
621
|
const hintParts: string[] = [];
|
|
510
622
|
hintParts.push("esc pause");
|
|
511
623
|
hintParts.push(process.platform === "darwin" ? "⌃⌥G dashboard" : "Ctrl+Alt+G dashboard");
|
|
512
|
-
|
|
624
|
+
const hintStr = theme.fg("dim", hintParts.join(" | "));
|
|
625
|
+
const pwdStr = theme.fg("dim", widgetPwd);
|
|
626
|
+
lines.push(rightAlign(`${pad}${pwdStr}`, hintStr, width));
|
|
513
627
|
|
|
514
628
|
lines.push(...ui.bar());
|
|
515
629
|
|
|
@@ -597,3 +711,10 @@ function rightAlign(left: string, right: string, width: number): string {
|
|
|
597
711
|
const gap = Math.max(1, width - leftVis - rightVis);
|
|
598
712
|
return truncateToWidth(left + " ".repeat(gap) + right, width);
|
|
599
713
|
}
|
|
714
|
+
|
|
715
|
+
/** Pad a string with trailing spaces to fill exactly `colWidth` (ANSI-aware). */
|
|
716
|
+
function padToWidth(s: string, colWidth: number): string {
|
|
717
|
+
const vis = visibleWidth(s);
|
|
718
|
+
if (vis >= colWidth) return truncateToWidth(s, colWidth);
|
|
719
|
+
return s + " ".repeat(colWidth - vis);
|
|
720
|
+
}
|
|
@@ -176,7 +176,7 @@ export async function postUnitPreVerification(pctx: PostUnitContext): Promise<"d
|
|
|
176
176
|
);
|
|
177
177
|
try {
|
|
178
178
|
const { formatDoctorIssuesForPrompt, formatDoctorReport } = await import("./doctor.js");
|
|
179
|
-
const { dispatchDoctorHeal } = await import("./commands.js");
|
|
179
|
+
const { dispatchDoctorHeal } = await import("./commands-handlers.js");
|
|
180
180
|
const actionable = report.issues.filter(i => i.severity === "error");
|
|
181
181
|
const reportText = formatDoctorReport(report, { scope: doctorScope, includeWarnings: true });
|
|
182
182
|
const structuredIssues = formatDoctorIssuesForPrompt(actionable);
|
|
@@ -202,10 +202,13 @@ export async function postUnitPreVerification(pctx: PostUnitContext): Promise<"d
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
// Prune dead bg-shell processes
|
|
205
|
+
// Prune dead bg-shell processes and kill non-persistent live ones.
|
|
206
|
+
// Without killing live processes between units, dev servers spawned during
|
|
207
|
+
// one task keep ports bound, causing conflicts in subsequent tasks (#1209).
|
|
206
208
|
try {
|
|
207
|
-
const { pruneDeadProcesses } = await import("../bg-shell/process-manager.js");
|
|
209
|
+
const { pruneDeadProcesses, killSessionProcesses } = await import("../bg-shell/process-manager.js");
|
|
208
210
|
pruneDeadProcesses();
|
|
211
|
+
killSessionProcesses();
|
|
209
212
|
} catch {
|
|
210
213
|
// Non-fatal
|
|
211
214
|
}
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
import { isValidationTerminal } from "./state.js";
|
|
40
40
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "node:fs";
|
|
41
41
|
import { atomicWriteSync } from "./atomic-write.js";
|
|
42
|
+
import { loadJsonFileOrNull } from "./json-persistence.js";
|
|
42
43
|
import { dirname, join } from "node:path";
|
|
43
44
|
|
|
44
45
|
// ─── Artifact Resolution & Verification ───────────────────────────────────────
|
|
@@ -354,6 +355,10 @@ export function skipExecuteTask(
|
|
|
354
355
|
|
|
355
356
|
// ─── Disk-backed completed-unit helpers ───────────────────────────────────────
|
|
356
357
|
|
|
358
|
+
function isStringArray(data: unknown): data is string[] {
|
|
359
|
+
return Array.isArray(data) && data.every(item => typeof item === "string");
|
|
360
|
+
}
|
|
361
|
+
|
|
357
362
|
/** Path to the persisted completed-unit keys file. */
|
|
358
363
|
export function completedKeysPath(base: string): string {
|
|
359
364
|
return join(base, ".gsd", "completed-units.json");
|
|
@@ -362,12 +367,7 @@ export function completedKeysPath(base: string): string {
|
|
|
362
367
|
/** Write a completed unit key to disk (read-modify-write append to set). */
|
|
363
368
|
export function persistCompletedKey(base: string, key: string): void {
|
|
364
369
|
const file = completedKeysPath(base);
|
|
365
|
-
|
|
366
|
-
try {
|
|
367
|
-
if (existsSync(file)) {
|
|
368
|
-
keys = JSON.parse(readFileSync(file, "utf-8"));
|
|
369
|
-
}
|
|
370
|
-
} catch (e) { /* corrupt file — start fresh */ void e; }
|
|
370
|
+
const keys = loadJsonFileOrNull(file, isStringArray) ?? [];
|
|
371
371
|
const keySet = new Set(keys);
|
|
372
372
|
if (!keySet.has(key)) {
|
|
373
373
|
keys.push(key);
|
|
@@ -378,27 +378,21 @@ export function persistCompletedKey(base: string, key: string): void {
|
|
|
378
378
|
/** Remove a stale completed unit key from disk. */
|
|
379
379
|
export function removePersistedKey(base: string, key: string): void {
|
|
380
380
|
const file = completedKeysPath(base);
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
atomicWriteSync(file, JSON.stringify(filtered));
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
} catch (e) { /* non-fatal: removePersistedKey failure */ void e; }
|
|
381
|
+
const keys = loadJsonFileOrNull(file, isStringArray);
|
|
382
|
+
if (!keys) return;
|
|
383
|
+
const filtered = keys.filter(k => k !== key);
|
|
384
|
+
if (filtered.length !== keys.length) {
|
|
385
|
+
atomicWriteSync(file, JSON.stringify(filtered));
|
|
386
|
+
}
|
|
391
387
|
}
|
|
392
388
|
|
|
393
389
|
/** Load all completed unit keys from disk into the in-memory set. */
|
|
394
390
|
export function loadPersistedKeys(base: string, target: Set<string>): void {
|
|
395
391
|
const file = completedKeysPath(base);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
} catch (e) { /* non-fatal: loadPersistedKeys failure */ void e; }
|
|
392
|
+
const keys = loadJsonFileOrNull(file, isStringArray);
|
|
393
|
+
if (keys) {
|
|
394
|
+
for (const k of keys) target.add(k);
|
|
395
|
+
}
|
|
402
396
|
}
|
|
403
397
|
|
|
404
398
|
// ─── Merge State Reconciliation ───────────────────────────────────────────────
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { existsSync, mkdirSync, readFileSync, cpSync, unlinkSync, readdirSync } from "node:fs";
|
|
14
|
+
import { loadJsonFileOrNull } from "./json-persistence.js";
|
|
14
15
|
import { join, sep as pathSep } from "node:path";
|
|
15
16
|
import { homedir } from "node:os";
|
|
16
17
|
import { safeCopy, safeCopyRecursive } from "./safe-fs.js";
|
|
@@ -112,15 +113,15 @@ export function syncStateToProjectRoot(worktreePath: string, projectRoot: string
|
|
|
112
113
|
* Uses gsdVersion instead of syncedAt so that launching a second session
|
|
113
114
|
* doesn't falsely trigger staleness (#804).
|
|
114
115
|
*/
|
|
116
|
+
function isManifestWithVersion(data: unknown): data is { gsdVersion: string } {
|
|
117
|
+
return data !== null && typeof data === "object" && "gsdVersion" in data! && typeof (data as Record<string, unknown>).gsdVersion === "string";
|
|
118
|
+
}
|
|
119
|
+
|
|
115
120
|
export function readResourceVersion(): string | null {
|
|
116
121
|
const agentDir = process.env.GSD_CODING_AGENT_DIR || join(homedir(), ".gsd", "agent");
|
|
117
122
|
const manifestPath = join(agentDir, "managed-resources.json");
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return typeof manifest?.gsdVersion === "string" ? manifest.gsdVersion : null;
|
|
121
|
-
} catch {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
123
|
+
const manifest = loadJsonFileOrNull(manifestPath, isManifestWithVersion);
|
|
124
|
+
return manifest?.gsdVersion ?? null;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
/**
|
|
@@ -19,7 +19,26 @@ import {
|
|
|
19
19
|
filterDoctorIssues,
|
|
20
20
|
} from "./doctor.js";
|
|
21
21
|
import { isAutoActive } from "./auto.js";
|
|
22
|
-
import { projectRoot
|
|
22
|
+
import { projectRoot } from "./commands.js";
|
|
23
|
+
import { loadPrompt } from "./prompt-loader.js";
|
|
24
|
+
|
|
25
|
+
export function dispatchDoctorHeal(pi: ExtensionAPI, scope: string | undefined, reportText: string, structuredIssues: string): void {
|
|
26
|
+
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(process.env.HOME ?? "~", ".pi", "GSD-WORKFLOW.md");
|
|
27
|
+
const workflow = readFileSync(workflowPath, "utf-8");
|
|
28
|
+
const prompt = loadPrompt("doctor-heal", {
|
|
29
|
+
doctorSummary: reportText,
|
|
30
|
+
structuredIssues,
|
|
31
|
+
scopeLabel: scope ?? "active milestone / blocking scope",
|
|
32
|
+
doctorCommandSuffix: scope ? ` ${scope}` : "",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const content = `Read the following GSD workflow protocol and execute exactly.\n\n${workflow}\n\n## Your Task\n\n${prompt}`;
|
|
36
|
+
|
|
37
|
+
pi.sendMessage(
|
|
38
|
+
{ customType: "gsd-doctor-heal", content, display: false },
|
|
39
|
+
{ triggerTurn: true },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
23
42
|
|
|
24
43
|
export async function handleDoctor(args: string, ctx: ExtensionCommandContext, pi: ExtensionAPI): Promise<void> {
|
|
25
44
|
const trimmed = args.trim();
|