gsd-pi 2.32.0-dev.1e39869 → 2.32.0-dev.3d7932c

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 (83) hide show
  1. package/README.md +27 -20
  2. package/dist/resource-loader.js +13 -3
  3. package/dist/resources/extensions/gsd/auto-dashboard.ts +3 -1
  4. package/dist/resources/extensions/gsd/auto-idempotency.ts +3 -2
  5. package/dist/resources/extensions/gsd/auto-observability.ts +2 -4
  6. package/dist/resources/extensions/gsd/auto-post-unit.ts +5 -5
  7. package/dist/resources/extensions/gsd/auto-prompts.ts +46 -44
  8. package/dist/resources/extensions/gsd/auto-recovery.ts +8 -22
  9. package/dist/resources/extensions/gsd/auto-start.ts +8 -6
  10. package/dist/resources/extensions/gsd/auto-stuck-detection.ts +3 -2
  11. package/dist/resources/extensions/gsd/auto-timeout-recovery.ts +2 -1
  12. package/dist/resources/extensions/gsd/auto-timers.ts +3 -2
  13. package/dist/resources/extensions/gsd/auto-verification.ts +6 -6
  14. package/dist/resources/extensions/gsd/auto-worktree.ts +5 -4
  15. package/dist/resources/extensions/gsd/auto.ts +28 -27
  16. package/dist/resources/extensions/gsd/commands-inspect.ts +2 -1
  17. package/dist/resources/extensions/gsd/commands-workflow-templates.ts +2 -1
  18. package/dist/resources/extensions/gsd/complexity-classifier.ts +5 -7
  19. package/dist/resources/extensions/gsd/crash-recovery.ts +15 -2
  20. package/dist/resources/extensions/gsd/dispatch-guard.ts +2 -1
  21. package/dist/resources/extensions/gsd/error-utils.ts +6 -0
  22. package/dist/resources/extensions/gsd/export.ts +2 -1
  23. package/dist/resources/extensions/gsd/git-service.ts +3 -2
  24. package/dist/resources/extensions/gsd/guided-flow.ts +3 -2
  25. package/dist/resources/extensions/gsd/index.ts +12 -5
  26. package/dist/resources/extensions/gsd/key-manager.ts +2 -1
  27. package/dist/resources/extensions/gsd/marketplace-discovery.ts +4 -3
  28. package/dist/resources/extensions/gsd/metrics.ts +3 -3
  29. package/dist/resources/extensions/gsd/migrate-external.ts +21 -4
  30. package/dist/resources/extensions/gsd/milestone-ids.ts +2 -1
  31. package/dist/resources/extensions/gsd/native-git-bridge.ts +2 -1
  32. package/dist/resources/extensions/gsd/parallel-merge.ts +2 -1
  33. package/dist/resources/extensions/gsd/parallel-orchestrator.ts +2 -1
  34. package/dist/resources/extensions/gsd/post-unit-hooks.ts +8 -9
  35. package/dist/resources/extensions/gsd/quick.ts +58 -3
  36. package/dist/resources/extensions/gsd/repo-identity.ts +22 -1
  37. package/dist/resources/extensions/gsd/session-lock.ts +12 -1
  38. package/dist/resources/extensions/gsd/tests/context-compression.test.ts +1 -1
  39. package/dist/resources/extensions/gsd/undo.ts +5 -7
  40. package/dist/resources/extensions/gsd/unit-id.ts +14 -0
  41. package/dist/resources/extensions/gsd/unit-runtime.ts +2 -1
  42. package/dist/resources/extensions/gsd/worktree-command.ts +8 -7
  43. package/package.json +1 -1
  44. package/src/resources/extensions/gsd/auto-dashboard.ts +3 -1
  45. package/src/resources/extensions/gsd/auto-idempotency.ts +3 -2
  46. package/src/resources/extensions/gsd/auto-observability.ts +2 -4
  47. package/src/resources/extensions/gsd/auto-post-unit.ts +5 -5
  48. package/src/resources/extensions/gsd/auto-prompts.ts +46 -44
  49. package/src/resources/extensions/gsd/auto-recovery.ts +8 -22
  50. package/src/resources/extensions/gsd/auto-start.ts +8 -6
  51. package/src/resources/extensions/gsd/auto-stuck-detection.ts +3 -2
  52. package/src/resources/extensions/gsd/auto-timeout-recovery.ts +2 -1
  53. package/src/resources/extensions/gsd/auto-timers.ts +3 -2
  54. package/src/resources/extensions/gsd/auto-verification.ts +6 -6
  55. package/src/resources/extensions/gsd/auto-worktree.ts +5 -4
  56. package/src/resources/extensions/gsd/auto.ts +28 -27
  57. package/src/resources/extensions/gsd/commands-inspect.ts +2 -1
  58. package/src/resources/extensions/gsd/commands-workflow-templates.ts +2 -1
  59. package/src/resources/extensions/gsd/complexity-classifier.ts +5 -7
  60. package/src/resources/extensions/gsd/crash-recovery.ts +15 -2
  61. package/src/resources/extensions/gsd/dispatch-guard.ts +2 -1
  62. package/src/resources/extensions/gsd/error-utils.ts +6 -0
  63. package/src/resources/extensions/gsd/export.ts +2 -1
  64. package/src/resources/extensions/gsd/git-service.ts +3 -2
  65. package/src/resources/extensions/gsd/guided-flow.ts +3 -2
  66. package/src/resources/extensions/gsd/index.ts +12 -5
  67. package/src/resources/extensions/gsd/key-manager.ts +2 -1
  68. package/src/resources/extensions/gsd/marketplace-discovery.ts +4 -3
  69. package/src/resources/extensions/gsd/metrics.ts +3 -3
  70. package/src/resources/extensions/gsd/migrate-external.ts +21 -4
  71. package/src/resources/extensions/gsd/milestone-ids.ts +2 -1
  72. package/src/resources/extensions/gsd/native-git-bridge.ts +2 -1
  73. package/src/resources/extensions/gsd/parallel-merge.ts +2 -1
  74. package/src/resources/extensions/gsd/parallel-orchestrator.ts +2 -1
  75. package/src/resources/extensions/gsd/post-unit-hooks.ts +8 -9
  76. package/src/resources/extensions/gsd/quick.ts +58 -3
  77. package/src/resources/extensions/gsd/repo-identity.ts +22 -1
  78. package/src/resources/extensions/gsd/session-lock.ts +12 -1
  79. package/src/resources/extensions/gsd/tests/context-compression.test.ts +1 -1
  80. package/src/resources/extensions/gsd/undo.ts +5 -7
  81. package/src/resources/extensions/gsd/unit-id.ts +14 -0
  82. package/src/resources/extensions/gsd/unit-runtime.ts +2 -1
  83. package/src/resources/extensions/gsd/worktree-command.ts +8 -7
@@ -154,12 +154,23 @@ export function acquireSessionLock(basePath: string): SessionLockResult {
154
154
  // Retry acquisition after cleanup
155
155
  const release = lockfile.lockSync(gsdDir, {
156
156
  realpath: false,
157
- stale: 300_000,
157
+ stale: 1_800_000, // 30 minutes — match primary lock settings
158
158
  update: 10_000,
159
+ onCompromised: () => {
160
+ _lockCompromised = true;
161
+ },
159
162
  });
160
163
  _releaseFunction = release;
161
164
  _lockedPath = basePath;
162
165
  _lockPid = process.pid;
166
+
167
+ // Safety net for retry path too
168
+ const retryLockDir = join(gsdDir + ".lock");
169
+ process.once("exit", () => {
170
+ try { if (_releaseFunction) { _releaseFunction(); _releaseFunction = null; } } catch {}
171
+ try { if (existsSync(retryLockDir)) rmSync(retryLockDir, { recursive: true, force: true }); } catch {}
172
+ });
173
+
163
174
  atomicWriteSync(lp, JSON.stringify(lockData, null, 2));
164
175
  return { acquired: true };
165
176
  } catch {
@@ -91,7 +91,7 @@ test("compression: buildPlanMilestonePrompt minimal drops project/requirements/d
91
91
  // The plan-milestone builder should gate root file inlining on inlineLevel
92
92
  assert.ok(
93
93
  promptsSrc.includes('inlineLevel !== "minimal"') &&
94
- promptsSrc.includes('inlineGsdRootFile(base, "project.md"'),
94
+ promptsSrc.includes("inlineProjectFromDb(base)"),
95
95
  "plan-milestone should conditionally include project.md based on level",
96
96
  );
97
97
  });
@@ -9,6 +9,7 @@ import { deriveState } from "./state.js";
9
9
  import { invalidateAllCaches } from "./cache.js";
10
10
  import { gsdRoot, resolveTasksDir, resolveSlicePath, buildTaskFileName } from "./paths.js";
11
11
  import { sendDesktopNotification } from "./notifications.js";
12
+ import { parseUnitId } from "./unit-id.js";
12
13
 
13
14
  /**
14
15
  * Undo the last completed unit: revert git commits, remove from completed-units,
@@ -62,11 +63,10 @@ export async function handleUndo(args: string, ctx: ExtensionCommandContext, _pi
62
63
  writeFileSync(completedKeysFile, JSON.stringify(keys), "utf-8");
63
64
 
64
65
  // 3. Delete summary artifact
65
- const parts = unitId.split("/");
66
+ const { milestone: mid, slice: sid, task: tid } = parseUnitId(unitId);
66
67
  let summaryRemoved = false;
67
- if (parts.length === 3) {
68
+ if (mid && sid && tid) {
68
69
  // Task-level: M001/S01/T01
69
- const [mid, sid, tid] = parts;
70
70
  const tasksDir = resolveTasksDir(basePath, mid, sid);
71
71
  if (tasksDir) {
72
72
  const summaryFile = join(tasksDir, buildTaskFileName(tid, "SUMMARY"));
@@ -75,9 +75,8 @@ export async function handleUndo(args: string, ctx: ExtensionCommandContext, _pi
75
75
  summaryRemoved = true;
76
76
  }
77
77
  }
78
- } else if (parts.length === 2) {
78
+ } else if (mid && sid) {
79
79
  // Slice-level: M001/S01
80
- const [mid, sid] = parts;
81
80
  const slicePath = resolveSlicePath(basePath, mid, sid);
82
81
  if (slicePath) {
83
82
  // Try common summary filenames
@@ -93,8 +92,7 @@ export async function handleUndo(args: string, ctx: ExtensionCommandContext, _pi
93
92
 
94
93
  // 4. Uncheck task in PLAN if execute-task
95
94
  let planUpdated = false;
96
- if (unitType === "execute-task" && parts.length === 3) {
97
- const [mid, sid, tid] = parts;
95
+ if (unitType === "execute-task" && mid && sid && tid) {
98
96
  planUpdated = uncheckTaskInPlan(basePath, mid, sid, tid);
99
97
  }
100
98
 
@@ -0,0 +1,14 @@
1
+ // GSD Extension — Unit ID Parsing
2
+ // Centralizes the milestone/slice/task decomposition of unit ID strings.
3
+
4
+ export interface ParsedUnitId {
5
+ milestone: string;
6
+ slice?: string;
7
+ task?: string;
8
+ }
9
+
10
+ /** Parse a unit ID string (e.g. "M1/S1/T1") into its milestone, slice, and task components. */
11
+ export function parseUnitId(unitId: string): ParsedUnitId {
12
+ const [milestone, slice, task] = unitId.split("/");
13
+ return { milestone: milestone!, slice, task };
14
+ }
@@ -9,6 +9,7 @@ import {
9
9
  } from "./paths.js";
10
10
  import { loadFile, parseTaskPlanMustHaves, countMustHavesMentionedInSummary } from "./files.js";
11
11
  import { loadJsonFileOrNull, saveJsonFile } from "./json-persistence.js";
12
+ import { parseUnitId } from "./unit-id.js";
12
13
 
13
14
  export type UnitRuntimePhase =
14
15
  | "dispatched"
@@ -131,7 +132,7 @@ export async function inspectExecuteTaskDurability(
131
132
  basePath: string,
132
133
  unitId: string,
133
134
  ): Promise<ExecuteTaskRecoveryStatus | null> {
134
- const [mid, sid, tid] = unitId.split("/");
135
+ const { milestone: mid, slice: sid, task: tid } = parseUnitId(unitId);
135
136
  if (!mid || !sid || !tid) return null;
136
137
 
137
138
  const planAbs = resolveSliceFile(basePath, mid, sid, "PLAN");
@@ -34,6 +34,7 @@ import type { FileLineStat } from "./worktree-manager.js";
34
34
  import { existsSync, realpathSync, readdirSync, rmSync, unlinkSync } from "node:fs";
35
35
  import { nativeMergeAbort } from "./native-git-bridge.js";
36
36
  import { join, sep } from "node:path";
37
+ import { getErrorMessage } from "./error-utils.js";
37
38
 
38
39
  /**
39
40
  * Tracks the original project root so we can switch back.
@@ -370,7 +371,7 @@ async function handleCreate(
370
371
  "info",
371
372
  );
372
373
  } catch (error) {
373
- const msg = error instanceof Error ? error.message : String(error);
374
+ const msg = getErrorMessage(error);
374
375
  ctx.ui.notify(`Failed to create worktree: ${msg}`, "error");
375
376
  }
376
377
  }
@@ -418,7 +419,7 @@ async function handleSwitch(
418
419
  "info",
419
420
  );
420
421
  } catch (error) {
421
- const msg = error instanceof Error ? error.message : String(error);
422
+ const msg = getErrorMessage(error);
422
423
  ctx.ui.notify(`Failed to switch to worktree: ${msg}`, "error");
423
424
  }
424
425
  }
@@ -528,7 +529,7 @@ async function handleList(
528
529
 
529
530
  ctx.ui.notify(lines.join("\n"), "info");
530
531
  } catch (error) {
531
- const msg = error instanceof Error ? error.message : String(error);
532
+ const msg = getErrorMessage(error);
532
533
  ctx.ui.notify(`Failed to list worktrees: ${msg}`, "error");
533
534
  }
534
535
  }
@@ -646,7 +647,7 @@ async function handleMerge(
646
647
  );
647
648
  return;
648
649
  } catch (mergeErr) {
649
- const mergeMsg = mergeErr instanceof Error ? mergeErr.message : String(mergeErr);
650
+ const mergeMsg = getErrorMessage(mergeErr);
650
651
  const isConflict = /conflict/i.test(mergeMsg);
651
652
 
652
653
  if (isConflict) {
@@ -703,7 +704,7 @@ async function handleMerge(
703
704
  "info",
704
705
  );
705
706
  } catch (error) {
706
- const msg = error instanceof Error ? error.message : String(error);
707
+ const msg = getErrorMessage(error);
707
708
  ctx.ui.notify(`Failed to start merge: ${msg}`, "error");
708
709
  }
709
710
  }
@@ -746,7 +747,7 @@ async function handleRemove(
746
747
 
747
748
  ctx.ui.notify(`${CLR.ok("✓")} Worktree ${CLR.name(name)} removed ${CLR.muted("(branch deleted)")}.`, "info");
748
749
  } catch (error) {
749
- const msg = error instanceof Error ? error.message : String(error);
750
+ const msg = getErrorMessage(error);
750
751
  ctx.ui.notify(`Failed to remove worktree: ${msg}`, "error");
751
752
  }
752
753
  }
@@ -800,7 +801,7 @@ async function handleRemoveAll(
800
801
  if (failed.length > 0) lines.push(`${CLR.warn("✗")} Failed: ${failed.map(n => CLR.name(n)).join(", ")}`);
801
802
  ctx.ui.notify(lines.join("\n"), failed.length > 0 ? "warning" : "info");
802
803
  } catch (error) {
803
- const msg = error instanceof Error ? error.message : String(error);
804
+ const msg = getErrorMessage(error);
804
805
  ctx.ui.notify(`Failed to remove worktrees: ${msg}`, "error");
805
806
  }
806
807
  }