gsd-pi 2.80.0-dev.96f4d89d5 → 2.80.0-dev.b2a374d5b

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 (239) hide show
  1. package/dist/resources/.managed-resources-content-hash +1 -1
  2. package/dist/resources/GSD-WORKFLOW.md +2 -2
  3. package/dist/resources/extensions/gsd/auto/loop.js +32 -1
  4. package/dist/resources/extensions/gsd/auto/phases.js +37 -30
  5. package/dist/resources/extensions/gsd/auto-dispatch.js +10 -0
  6. package/dist/resources/extensions/gsd/auto-post-unit.js +10 -10
  7. package/dist/resources/extensions/gsd/auto-prompts.js +111 -1
  8. package/dist/resources/extensions/gsd/auto-recovery.js +154 -8
  9. package/dist/resources/extensions/gsd/auto-start.js +2 -3
  10. package/dist/resources/extensions/gsd/auto.js +16 -3
  11. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +32 -1
  12. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +129 -1
  13. package/dist/resources/extensions/gsd/clean-root-preflight.js +42 -4
  14. package/dist/resources/extensions/gsd/commands/dispatcher.js +5 -0
  15. package/dist/resources/extensions/gsd/commands-extract-learnings.js +17 -12
  16. package/dist/resources/extensions/gsd/crash-recovery.js +56 -10
  17. package/dist/resources/extensions/gsd/db-base-schema.js +14 -0
  18. package/dist/resources/extensions/gsd/db-migration-steps.js +16 -0
  19. package/dist/resources/extensions/gsd/detection.js +106 -0
  20. package/dist/resources/extensions/gsd/gsd-db.js +102 -2
  21. package/dist/resources/extensions/gsd/guided-flow.js +63 -12
  22. package/dist/resources/extensions/gsd/migrate/command.js +40 -1
  23. package/dist/resources/extensions/gsd/migration-auto-check.js +87 -0
  24. package/dist/resources/extensions/gsd/planning-path-scope.js +26 -0
  25. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +7 -8
  26. package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
  27. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
  28. package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  29. package/dist/resources/extensions/gsd/prompts/quick-task.md +1 -5
  30. package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  31. package/dist/resources/extensions/gsd/quick.js +34 -2
  32. package/dist/resources/extensions/gsd/safety/evidence-collector.js +10 -2
  33. package/dist/resources/extensions/gsd/tools/plan-slice.js +9 -0
  34. package/dist/resources/extensions/gsd/tools/plan-task.js +9 -0
  35. package/dist/resources/extensions/gsd/unit-runtime.js +11 -0
  36. package/dist/resources/extensions/gsd/worktree-manager.js +16 -14
  37. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  38. package/dist/web/standalone/.next/BUILD_ID +1 -1
  39. package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
  40. package/dist/web/standalone/.next/build-manifest.json +2 -2
  41. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  42. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  43. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  44. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  45. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  46. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  47. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  48. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  49. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  50. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  51. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  52. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  53. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  54. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  55. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  56. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  57. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  58. package/dist/web/standalone/.next/server/app/index.html +1 -1
  59. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  60. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  61. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  62. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  63. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  64. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  65. package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
  66. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  67. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  68. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  69. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  70. package/package.json +4 -2
  71. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  72. package/packages/pi-coding-agent/dist/core/agent-session.js +3 -0
  73. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  74. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +76 -0
  75. package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
  76. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +11 -0
  77. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  78. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +9 -0
  79. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  80. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts +2 -0
  81. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.d.ts.map +1 -0
  82. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js +103 -0
  83. package/packages/pi-coding-agent/dist/core/compaction-threshold.test.js.map +1 -0
  84. package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts +15 -0
  85. package/packages/pi-coding-agent/dist/core/db-snapshot.d.ts.map +1 -0
  86. package/packages/pi-coding-agent/dist/core/db-snapshot.js +66 -0
  87. package/packages/pi-coding-agent/dist/core/db-snapshot.js.map +1 -0
  88. package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts +2 -0
  89. package/packages/pi-coding-agent/dist/core/db-snapshot.test.d.ts.map +1 -0
  90. package/packages/pi-coding-agent/dist/core/db-snapshot.test.js +24 -0
  91. package/packages/pi-coding-agent/dist/core/db-snapshot.test.js.map +1 -0
  92. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +3 -0
  93. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  94. package/packages/pi-coding-agent/dist/core/extensions/runner.js +17 -1
  95. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  96. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +99 -0
  97. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  98. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +7 -0
  99. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  100. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  101. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -0
  102. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  103. package/packages/pi-coding-agent/dist/core/settings-manager.js +25 -0
  104. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  105. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js +6 -4
  106. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.js.map +1 -1
  107. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js +50 -19
  108. package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-execution.test.js.map +1 -1
  109. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js +2 -2
  110. package/packages/pi-coding-agent/dist/modes/interactive/components/adaptive-layout.js.map +1 -1
  111. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  112. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
  113. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
  114. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +2 -1
  115. package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
  116. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +7 -6
  117. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -1
  118. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +13 -0
  119. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  120. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +77 -13
  121. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  122. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
  123. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +68 -2
  124. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
  125. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js +53 -0
  126. package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.test.js.map +1 -1
  127. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  128. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3 -0
  129. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  130. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  131. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +36 -27
  132. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
  133. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js +21 -0
  134. package/packages/pi-coding-agent/dist/modes/interactive/tui-mode.test.js.map +1 -1
  135. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts +2 -0
  136. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.d.ts.map +1 -0
  137. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js +10 -0
  138. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage-safety-guard.test.js.map +1 -0
  139. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
  140. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +3 -2
  141. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
  142. package/packages/pi-coding-agent/src/core/agent-session.ts +3 -0
  143. package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +89 -0
  144. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +18 -0
  145. package/packages/pi-coding-agent/src/core/compaction-threshold.test.ts +121 -0
  146. package/packages/pi-coding-agent/src/core/db-snapshot.test.ts +32 -0
  147. package/packages/pi-coding-agent/src/core/db-snapshot.ts +66 -0
  148. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +110 -0
  149. package/packages/pi-coding-agent/src/core/extensions/runner.ts +19 -1
  150. package/packages/pi-coding-agent/src/core/extensions/types.ts +7 -0
  151. package/packages/pi-coding-agent/src/core/settings-manager.ts +39 -1
  152. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/chat-frame-compaction-tone.test.ts +7 -5
  153. package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-execution.test.ts +68 -19
  154. package/packages/pi-coding-agent/src/modes/interactive/components/adaptive-layout.ts +2 -2
  155. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +1 -0
  156. package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +2 -1
  157. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +10 -9
  158. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +88 -13
  159. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.test.ts +56 -0
  160. package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +91 -3
  161. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +3 -0
  162. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +36 -27
  163. package/packages/pi-coding-agent/src/modes/interactive/tui-mode.test.ts +25 -0
  164. package/packages/pi-coding-agent/src/resources/extensions/memory/storage-safety-guard.test.ts +14 -0
  165. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +3 -2
  166. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  167. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  168. package/packages/pi-tui/dist/tui.js +17 -7
  169. package/packages/pi-tui/dist/tui.js.map +1 -1
  170. package/packages/pi-tui/src/tui.ts +19 -7
  171. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  172. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -1
  173. package/pkg/dist/modes/interactive/theme/themes.js +36 -27
  174. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
  175. package/src/resources/GSD-WORKFLOW.md +2 -2
  176. package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -0
  177. package/src/resources/extensions/gsd/auto/loop.ts +50 -8
  178. package/src/resources/extensions/gsd/auto/phases.ts +42 -28
  179. package/src/resources/extensions/gsd/auto-dispatch.ts +17 -0
  180. package/src/resources/extensions/gsd/auto-post-unit.ts +10 -10
  181. package/src/resources/extensions/gsd/auto-prompts.ts +116 -1
  182. package/src/resources/extensions/gsd/auto-recovery.ts +153 -7
  183. package/src/resources/extensions/gsd/auto-start.ts +7 -6
  184. package/src/resources/extensions/gsd/auto.ts +23 -3
  185. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +39 -1
  186. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +135 -1
  187. package/src/resources/extensions/gsd/clean-root-preflight.ts +41 -3
  188. package/src/resources/extensions/gsd/commands/dispatcher.ts +6 -0
  189. package/src/resources/extensions/gsd/commands-extract-learnings.ts +17 -12
  190. package/src/resources/extensions/gsd/crash-recovery.ts +67 -10
  191. package/src/resources/extensions/gsd/db-base-schema.ts +15 -0
  192. package/src/resources/extensions/gsd/db-migration-steps.ts +17 -0
  193. package/src/resources/extensions/gsd/detection.ts +128 -0
  194. package/src/resources/extensions/gsd/gsd-db.ts +119 -1
  195. package/src/resources/extensions/gsd/guided-flow.ts +66 -12
  196. package/src/resources/extensions/gsd/migrate/command.ts +47 -1
  197. package/src/resources/extensions/gsd/migration-auto-check.ts +129 -0
  198. package/src/resources/extensions/gsd/planning-path-scope.ts +35 -0
  199. package/src/resources/extensions/gsd/prompts/complete-milestone.md +7 -8
  200. package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +1 -1
  201. package/src/resources/extensions/gsd/prompts/plan-milestone.md +3 -1
  202. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  203. package/src/resources/extensions/gsd/prompts/quick-task.md +1 -5
  204. package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -2
  205. package/src/resources/extensions/gsd/quick.ts +37 -2
  206. package/src/resources/extensions/gsd/safety/evidence-collector.ts +11 -2
  207. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +1 -1
  208. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +170 -1
  209. package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +88 -2
  210. package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +9 -0
  211. package/src/resources/extensions/gsd/tests/crash-handler-secondary.test.ts +55 -0
  212. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +22 -0
  213. package/src/resources/extensions/gsd/tests/db-schema-metadata.test.ts +2 -2
  214. package/src/resources/extensions/gsd/tests/detection.test.ts +140 -0
  215. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +44 -0
  216. package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +33 -1
  217. package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +48 -0
  218. package/src/resources/extensions/gsd/tests/migration-auto-check.test.ts +127 -0
  219. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +50 -0
  220. package/src/resources/extensions/gsd/tests/plan-task.test.ts +21 -0
  221. package/src/resources/extensions/gsd/tests/prompt-path-audit.test.ts +40 -0
  222. package/src/resources/extensions/gsd/tests/quick-external-gsd.test.ts +40 -0
  223. package/src/resources/extensions/gsd/tests/right-sized-workflow-prompts.test.ts +192 -0
  224. package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +29 -0
  225. package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +38 -0
  226. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +63 -2
  227. package/src/resources/extensions/gsd/tests/status-db-open.test.ts +9 -0
  228. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +7 -0
  229. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +1 -1
  230. package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +37 -6
  231. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +7 -0
  232. package/src/resources/extensions/gsd/tests/worktree-nested-git-safety.test.ts +9 -2
  233. package/src/resources/extensions/gsd/tests/worktree-write-gate.test.ts +179 -0
  234. package/src/resources/extensions/gsd/tools/plan-slice.ts +13 -0
  235. package/src/resources/extensions/gsd/tools/plan-task.ts +10 -0
  236. package/src/resources/extensions/gsd/unit-runtime.ts +14 -0
  237. package/src/resources/extensions/gsd/worktree-manager.ts +15 -4
  238. /package/dist/web/standalone/.next/static/{y7d--cnc6Cibuva-Lzzw_ → FU0iL9dhdc2IBzEYBDOlY}/_buildManifest.js +0 -0
  239. /package/dist/web/standalone/.next/static/{y7d--cnc6Cibuva-Lzzw_ → FU0iL9dhdc2IBzEYBDOlY}/_ssgManifest.js +0 -0
@@ -0,0 +1,192 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { execFileSync } from "node:child_process";
4
+ import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { tmpdir } from "node:os";
7
+
8
+ import { buildCompleteMilestonePrompt, buildPlanMilestonePrompt } from "../auto-prompts.ts";
9
+
10
+ function git(cwd: string, args: string[]): string {
11
+ return execFileSync("git", args, {
12
+ cwd,
13
+ stdio: ["ignore", "pipe", "pipe"],
14
+ encoding: "utf-8",
15
+ env: { ...process.env, GIT_AUTHOR_NAME: "Test User", GIT_AUTHOR_EMAIL: "test@example.com", GIT_COMMITTER_NAME: "Test User", GIT_COMMITTER_EMAIL: "test@example.com" },
16
+ }).trim();
17
+ }
18
+
19
+ function makeRepo(files: Record<string, string>): string {
20
+ const base = mkdtempSync(join(tmpdir(), "gsd-right-size-"));
21
+ git(base, ["init", "-b", "main"]);
22
+ mkdirSync(join(base, ".gsd", "milestones", "M001"), { recursive: true });
23
+ writeFileSync(join(base, ".gsd", "milestones", "M001", "M001-CONTEXT.md"), "# Context\n\nTest milestone.");
24
+ for (const [path, content] of Object.entries(files)) {
25
+ const abs = join(base, path);
26
+ mkdirSync(join(abs, ".."), { recursive: true });
27
+ writeFileSync(abs, content);
28
+ }
29
+ git(base, ["add", "."]);
30
+ git(base, ["commit", "-m", "init"]);
31
+ return base;
32
+ }
33
+
34
+ function writeCompleteMilestoneFiles(base: string, validation: string): void {
35
+ const dir = join(base, ".gsd", "milestones", "M001");
36
+ mkdirSync(join(dir, "slices", "S01"), { recursive: true });
37
+ writeFileSync(join(dir, "M001-ROADMAP.md"), "# M001\n\n## Slices\n- [x] **S01: One** `risk:low` `depends:[]`\n > Done\n");
38
+ writeFileSync(join(dir, "M001-VALIDATION.md"), validation);
39
+ writeFileSync(join(dir, "slices", "S01", "S01-SUMMARY.md"), "# S01 Summary\n\n**Verification:** passed\n");
40
+ }
41
+
42
+ function validationMetadata(): string {
43
+ return [
44
+ "validation_metadata:",
45
+ " covered_artifacts:",
46
+ " - `.gsd/milestones/M001/M001-VALIDATION.md`",
47
+ " - `.gsd/milestones/M001/M001-ROADMAP.md`",
48
+ " - `.gsd/milestones/M001/slices/S01/S01-SUMMARY.md`",
49
+ ].join("\n");
50
+ }
51
+
52
+ test("plan-milestone prompt includes tiny untyped project classification and one-slice guidance", async () => {
53
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
54
+ try {
55
+ const prompt = await buildPlanMilestonePrompt("M001", "Polish static page", base, "minimal");
56
+ assert.match(prompt, /\*\*Kind:\*\* untyped-existing/);
57
+ assert.match(prompt, /\*\*Content files:\*\* 1/);
58
+ assert.match(prompt, /`index\.html`/);
59
+ assert.match(prompt, /Prefer exactly one slice/);
60
+ } finally {
61
+ rmSync(base, { recursive: true, force: true });
62
+ }
63
+ });
64
+
65
+ test("plan-milestone prompt includes small untyped project 1-2 slice guidance", async () => {
66
+ const base = makeRepo({
67
+ "index.html": "html",
68
+ "README.md": "readme",
69
+ "styles.css": "body {}",
70
+ });
71
+ try {
72
+ const prompt = await buildPlanMilestonePrompt("M001", "Polish static files", base, "minimal");
73
+ assert.match(prompt, /\*\*Kind:\*\* untyped-existing/);
74
+ assert.match(prompt, /\*\*Content files:\*\* 3/);
75
+ assert.match(prompt, /Prefer 1-2 slices/);
76
+ } finally {
77
+ rmSync(base, { recursive: true, force: true });
78
+ }
79
+ });
80
+
81
+ test("plan-milestone prompt keeps normal guidance for typed projects", async () => {
82
+ const base = makeRepo({
83
+ "package.json": "{\"scripts\":{\"test\":\"node --test\"}}\n",
84
+ "src/index.js": "console.log('ok');\n",
85
+ });
86
+ try {
87
+ const prompt = await buildPlanMilestonePrompt("M001", "Update app", base, "minimal");
88
+ assert.match(prompt, /\*\*Kind:\*\* typed-existing/);
89
+ assert.match(prompt, /Use normal ecosystem-aware planning guidance/);
90
+ assert.doesNotMatch(prompt, /Prefer exactly one slice/);
91
+ } finally {
92
+ rmSync(base, { recursive: true, force: true });
93
+ }
94
+ });
95
+
96
+ test("workflow docs no longer contain blanket 4-10 slice guidance", () => {
97
+ const docs = readFileSync(join(process.cwd(), "src", "resources", "GSD-WORKFLOW.md"), "utf-8");
98
+ assert.doesNotMatch(docs, /4-10 slices/);
99
+ assert.match(docs, /1-10 slices/);
100
+ assert.match(docs, /single-file/);
101
+ });
102
+
103
+ test("prompt templates carry right-sized planning and closeout mode guidance", () => {
104
+ const planTemplate = readFileSync(join(process.cwd(), "src", "resources", "extensions", "gsd", "prompts", "plan-milestone.md"), "utf-8");
105
+ const completeTemplate = readFileSync(join(process.cwd(), "src", "resources", "extensions", "gsd", "prompts", "complete-milestone.md"), "utf-8");
106
+
107
+ assert.match(planTemplate, /Use 1-10 slices, sized to the work/);
108
+ assert.match(planTemplate, /tiny\/single-file\/static work should usually be one slice/);
109
+ assert.match(planTemplate, /untyped-existing/);
110
+ assert.match(completeTemplate, /Closeout Review Mode/);
111
+ assert.match(completeTemplate, /passing validation artifact is present/);
112
+ assert.doesNotMatch(completeTemplate, /^### Delegate Review Work/m);
113
+ });
114
+
115
+ test("complete-milestone prompt trusts passing validation artifact", async () => {
116
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
117
+ try {
118
+ writeCompleteMilestoneFiles(base, `---\nverdict: pass\nremediation_round: 0\n---\n\n# Validation\n${validationMetadata()}\n\nAll checks passed.`);
119
+ const prompt = await buildCompleteMilestonePrompt("M001", "Polish static page", base, "minimal");
120
+ assert.match(prompt, /Passing Validation Artifact/);
121
+ assert.match(prompt, /Treat it as authoritative/);
122
+ assert.match(prompt, /Do not delegate fresh reviewer\/security\/tester audits/);
123
+ assert.match(prompt, /All checks passed/);
124
+ } finally {
125
+ rmSync(base, { recursive: true, force: true });
126
+ }
127
+ });
128
+
129
+ test("complete-milestone prompt trusts centralized markdown body pass verdict", async () => {
130
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
131
+ try {
132
+ writeCompleteMilestoneFiles(base, `# Validation\n\n**Verdict:** PASS\n\n${validationMetadata()}\n\nAll checks passed.`);
133
+ const prompt = await buildCompleteMilestonePrompt("M001", "Polish static page", base, "minimal");
134
+ assert.match(prompt, /Passing Validation Artifact/);
135
+ assert.match(prompt, /Treat it as authoritative/);
136
+ assert.match(prompt, /Do not delegate fresh reviewer\/security\/tester audits/);
137
+ } finally {
138
+ rmSync(base, { recursive: true, force: true });
139
+ }
140
+ });
141
+
142
+ test("complete-milestone prompt does not trust stale pass validation without metadata", async () => {
143
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
144
+ try {
145
+ writeCompleteMilestoneFiles(base, "---\nverdict: pass\nremediation_round: 0\n---\n\n# Validation\nAll checks passed.");
146
+ const prompt = await buildCompleteMilestonePrompt("M001", "Polish static page", base, "minimal");
147
+ assert.match(prompt, /Validation Requires Attention/);
148
+ assert.match(prompt, /missing freshness metadata/);
149
+ assert.doesNotMatch(prompt, /Passing Validation Artifact/);
150
+ } finally {
151
+ rmSync(base, { recursive: true, force: true });
152
+ }
153
+ });
154
+
155
+ test("complete-milestone prompt does not trust pass validation missing current summary coverage", async () => {
156
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
157
+ try {
158
+ writeCompleteMilestoneFiles(base, [
159
+ "---",
160
+ "verdict: pass",
161
+ "remediation_round: 0",
162
+ "---",
163
+ "",
164
+ "# Validation",
165
+ "validation_metadata:",
166
+ " covered_artifacts:",
167
+ " - `.gsd/milestones/M001/M001-VALIDATION.md`",
168
+ " - `.gsd/milestones/M001/M001-ROADMAP.md`",
169
+ "",
170
+ "All checks passed.",
171
+ ].join("\n"));
172
+ const prompt = await buildCompleteMilestonePrompt("M001", "Polish static page", base, "minimal");
173
+ assert.match(prompt, /Validation Requires Attention/);
174
+ assert.match(prompt, /does not cover current milestone artifacts/);
175
+ assert.doesNotMatch(prompt, /Passing Validation Artifact/);
176
+ } finally {
177
+ rmSync(base, { recursive: true, force: true });
178
+ }
179
+ });
180
+
181
+ test("complete-milestone prompt keeps deeper review path without passing validation", async () => {
182
+ const base = makeRepo({ "index.html": "<!doctype html>\n<title>Test</title>\n" });
183
+ try {
184
+ writeCompleteMilestoneFiles(base, "---\nverdict: needs-attention\nremediation_round: 0\n---\n\n# Validation\nFix gaps.");
185
+ const prompt = await buildCompleteMilestonePrompt("M001", "Polish static page", base, "minimal");
186
+ assert.match(prompt, /Validation Requires Attention/);
187
+ assert.match(prompt, /verdict `needs-attention`/);
188
+ assert.match(prompt, /Use `subagent` for review work needing fresh context/i);
189
+ } finally {
190
+ rmSync(base, { recursive: true, force: true });
191
+ }
192
+ });
@@ -144,6 +144,18 @@ test("safety-harness-bug2-race: bash evidence survives mid-unit reset between to
144
144
  assert.ok(bash[0].outputSnippet.includes("found"), "output snippet captured");
145
145
  });
146
146
 
147
+ test("safety-harness: gsd_exec counts as execution evidence", () => {
148
+ resetEvidence();
149
+
150
+ recordToolCall("tc-exec-1", "gsd_exec", { command: "grep -n render index.html" });
151
+ recordToolResult("tc-exec-1", "gsd_exec", "Command exited with code 0\n1:render\n", false);
152
+
153
+ const bash = getEvidence().filter((e): e is BashEvidence => e.kind === "bash");
154
+ assert.equal(bash.length, 1, "gsd_exec must be tracked as execution evidence");
155
+ assert.equal(bash[0].command, "grep -n render index.html");
156
+ assert.equal(bash[0].exitCode, 0);
157
+ });
158
+
147
159
  // ─── Bug 3: git diff HEAD~1 scope check ─────────────────────────────────────
148
160
 
149
161
  test("safety-harness-bug3: validateFileChanges works on initial commit (no HEAD~1)", (t) => {
@@ -237,3 +249,20 @@ test("safety-harness-bug3: validateFileChanges works on merge commit", (t) => {
237
249
  // Must produce a valid result without throwing
238
250
  assert.ok(audit !== null, "audit must be produced for merge commit repo");
239
251
  });
252
+
253
+ test("safety-harness: planned changed file avoids unexpected-file warning", (t) => {
254
+ const base = mkdtempSync(join(tmpdir(), "gsd-planned-file-"));
255
+ t.after(() => rmSync(base, { recursive: true, force: true }));
256
+
257
+ execFileSync("git", ["init"], { cwd: base });
258
+ execFileSync("git", ["config", "user.email", "test@example.com"], { cwd: base });
259
+ execFileSync("git", ["config", "user.name", "Test User"], { cwd: base });
260
+ writeFileSync(join(base, "index.html"), "<main></main>\n");
261
+ execFileSync("git", ["add", "index.html"], { cwd: base });
262
+ execFileSync("git", ["commit", "-m", "add static app"], { cwd: base });
263
+
264
+ const audit = validateFileChanges(base, [], ["index.html"]);
265
+ assert.ok(audit !== null, "audit must be produced");
266
+ assert.deepEqual(audit!.unexpectedFiles, [], "planned index.html must not be unexpected");
267
+ assert.deepEqual(audit!.missingFiles, [], "planned index.html must not be missing");
268
+ });
@@ -47,6 +47,9 @@ test("guided-flow complete branch offers a chooser for next milestone or status"
47
47
  const branchChunk = guidedFlowSource.slice(branchIdx, nextBranchIdx === -1 ? branchIdx + 1600 : nextBranchIdx);
48
48
 
49
49
  assert.match(branchChunk, /showNextAction\(/, "complete branch should present a chooser");
50
+ assert.match(branchChunk, /id:\s*"quick_task"/, "complete branch should offer quick task before milestone planning");
51
+ assert.match(branchChunk, /Do a small bounded task without opening a milestone/, "quick task action should explain that it avoids milestones");
52
+ assert.match(branchChunk, /recommended:\s*true/, "quick task action should be the recommended complete-state action");
50
53
  assert.match(branchChunk, /findMilestoneIds\(basePath\)/, "complete branch should compute the next milestone id");
51
54
  assert.match(
52
55
  branchChunk,
@@ -56,6 +59,41 @@ test("guided-flow complete branch offers a chooser for next milestone or status"
56
59
  assert.match(branchChunk, /dispatchWorkflow\(pi, await prepareAndBuildDiscussPrompt\(/, "complete branch should dispatch the prepared discuss prompt");
57
60
  });
58
61
 
62
+ test("guided-flow quick task choices prompt for text and route through /gsd quick", () => {
63
+ const guidedFlowSource = readFileSync(join(import.meta.dirname, "..", "guided-flow.ts"), "utf-8");
64
+
65
+ assert.match(
66
+ guidedFlowSource,
67
+ /async function runQuickTaskChoice\([\s\S]*ctx\.ui\.input\("Quick task"[\s\S]*await import\("\.\/quick\.js"\)[\s\S]*await handleQuick\(task,\s*ctx,\s*pi\)/,
68
+ "quick task chooser should prompt for task text and route through handleQuick",
69
+ );
70
+
71
+ const notifyOnlyPattern = /if \(choice === "quick_task"\) \{\s*ctx\.ui\.notify\("Run \/gsd quick <task>/;
72
+ assert.doesNotMatch(
73
+ guidedFlowSource,
74
+ notifyOnlyPattern,
75
+ "quick task chooser must not merely print instructions after selection",
76
+ );
77
+
78
+ const quickChoiceCalls = guidedFlowSource.match(/if \(choice === "quick_task"\) \{\s*await runQuickTaskChoice\(ctx,\s*pi\);/g) ?? [];
79
+ assert.equal(quickChoiceCalls.length, 3, "all guided-flow quick task choices should dispatch the helper");
80
+ });
81
+
82
+ test("dispatcher routes multi-word freeform /gsd input through /gsd do", () => {
83
+ const dispatcherSource = readFileSync(join(import.meta.dirname, "..", "commands", "dispatcher.ts"), "utf-8");
84
+
85
+ assert.match(
86
+ dispatcherSource,
87
+ /if\s*\(trimmed\.includes\(" "\)\)\s*\{[\s\S]*handleDo\(trimmed,\s*ctx,\s*pi\)/,
88
+ "dispatcher should treat multi-word unknown input as natural-language /gsd do work",
89
+ );
90
+ assert.match(
91
+ dispatcherSource,
92
+ /Unknown: \/gsd/,
93
+ "single-token unknown commands should still report the normal unknown-command warning",
94
+ );
95
+ });
96
+
59
97
  test("guided-flow needs-discussion skip branch opens the project DB before reserving a new milestone", () => {
60
98
  const guidedFlowSource = readFileSync(join(import.meta.dirname, "..", "guided-flow.ts"), "utf-8");
61
99
  const laterDbOpenIdx = guidedFlowSource.indexOf("// Ensure DB is open before querying slices (#2560).");
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
5
 
6
+ import { _withDetachedAutoKeepaliveForTest } from "../auto.ts";
7
+
6
8
  const gsdDir = resolve(import.meta.dirname, "..");
7
9
 
8
10
  function readGsdFile(relativePath: string): string {
@@ -94,6 +96,23 @@ test("auto bootstrap validates blocked directories before touching .gsd migratio
94
96
  );
95
97
  });
96
98
 
99
+ test("fresh start registers the auto worker before bootstrap enters worktree flow (#5405)", () => {
100
+ const autoSrc = readGsdFile("auto.ts");
101
+ const startAutoIdx = autoSrc.indexOf("export async function startAuto(");
102
+ const startAutoBody = autoSrc.slice(startAutoIdx);
103
+
104
+ const preBootstrapRegisterIdx = startAutoBody.indexOf("registerAutoWorkerForSession(s, base);");
105
+ const bootstrapCallIdx = startAutoBody.indexOf("const ready = await bootstrapAutoSession(");
106
+
107
+ assert.ok(startAutoIdx > -1, "startAuto should exist");
108
+ assert.ok(preBootstrapRegisterIdx > -1, "startAuto should register worker before bootstrap");
109
+ assert.ok(bootstrapCallIdx > -1, "startAuto should call bootstrapAutoSession");
110
+ assert.ok(
111
+ preBootstrapRegisterIdx < bootstrapCallIdx,
112
+ "worker registration must happen before bootstrap so enterMilestone can claim milestone leases on first entry",
113
+ );
114
+ });
115
+
97
116
  test("startAutoDetached reports failures asynchronously (#3733)", () => {
98
117
  const autoSrc = readGsdFile("auto.ts");
99
118
 
@@ -102,8 +121,8 @@ test("startAutoDetached reports failures asynchronously (#3733)", () => {
102
121
  "auto.ts should export startAutoDetached",
103
122
  );
104
123
  assert.ok(
105
- autoSrc.includes("void startAuto(ctx, pi, base, verboseMode, options).catch"),
106
- "startAutoDetached should launch startAuto without awaiting it",
124
+ autoSrc.includes("void withDetachedAutoKeepalive(startAuto(ctx, pi, base, verboseMode, options)).catch"),
125
+ "startAutoDetached should launch startAuto without awaiting it and keep the process alive",
107
126
  );
108
127
  assert.ok(
109
128
  autoSrc.includes("ctx.ui.notify(`Auto-start failed: ${message}`, \"error\")"),
@@ -111,6 +130,48 @@ test("startAutoDetached reports failures asynchronously (#3733)", () => {
111
130
  );
112
131
  });
113
132
 
133
+ test("detached auto-start keeps a ref'ed handle until the run settles", async () => {
134
+ const originalSetInterval = globalThis.setInterval;
135
+ const originalClearInterval = globalThis.clearInterval;
136
+ let intervalCreated = false;
137
+ let intervalCleared = false;
138
+ let createdHandle: NodeJS.Timeout | undefined;
139
+ let resolveRun!: () => void;
140
+ const run = new Promise<void>((resolve) => {
141
+ resolveRun = resolve;
142
+ });
143
+
144
+ globalThis.setInterval = ((handler: TimerHandler, timeout?: number, ...args: unknown[]) => {
145
+ intervalCreated = true;
146
+ assert.equal(timeout, 30_000);
147
+ void handler;
148
+ void args;
149
+ createdHandle = originalSetInterval(() => {}, 1_000_000);
150
+ assert.equal(createdHandle.hasRef(), true, "detached auto keepalive must be ref'ed");
151
+ return createdHandle;
152
+ }) as unknown as typeof setInterval;
153
+
154
+ globalThis.clearInterval = ((handle?: NodeJS.Timeout | number | string) => {
155
+ if (handle === createdHandle) intervalCleared = true;
156
+ return originalClearInterval(handle);
157
+ }) as unknown as typeof clearInterval;
158
+
159
+ try {
160
+ const heldRun = _withDetachedAutoKeepaliveForTest(run);
161
+ assert.equal(intervalCreated, true, "keepalive interval should start immediately");
162
+ assert.equal(intervalCleared, false, "keepalive should remain active while auto-mode is running");
163
+
164
+ resolveRun();
165
+ await heldRun;
166
+
167
+ assert.equal(intervalCleared, true, "keepalive interval should clear when auto-mode settles");
168
+ } finally {
169
+ if (createdHandle) originalClearInterval(createdHandle);
170
+ globalThis.setInterval = originalSetInterval;
171
+ globalThis.clearInterval = originalClearInterval;
172
+ }
173
+ });
174
+
114
175
  test("detached auto-start preserves milestone lock across pause/stop cleanup (#3733)", () => {
115
176
  const autoSrc = readGsdFile("auto.ts");
116
177
  const sessionSrc = readGsdFile("auto/session.ts");
@@ -44,4 +44,13 @@ describe('status opens DB before deriveState (#3691)', () => {
44
44
  assert.match(quickSrc, /getIsolationMode\(\)\s*!==\s*"none"/,
45
45
  'quick.ts should compare isolation mode against "none"');
46
46
  });
47
+
48
+ test('quick task prompt handles external .gsd without staging quick files', () => {
49
+ assert.match(quickSrc, /isExternalGsdRoot/,
50
+ 'quick.ts should detect whether .gsd resolves outside the project repo');
51
+ assert.match(quickSrc, /do not stage or commit `\.gsd\/quick\/\.\.\.`/,
52
+ 'external-state quick tasks must tell the agent not to stage .gsd/quick files');
53
+ assert.match(quickSrc, /nothing in the project repo to commit/,
54
+ 'external-state quick tasks should allow summary-only work without a git commit');
55
+ });
47
56
  });
@@ -5,6 +5,7 @@ import {
5
5
  clearUnitRuntimeRecord,
6
6
  formatExecuteTaskRecoveryStatus,
7
7
  inspectExecuteTaskDurability,
8
+ isInFlightRuntimePhase,
8
9
  readUnitRuntimeRecord,
9
10
  writeUnitRuntimeRecord,
10
11
  } from "../unit-runtime.ts";
@@ -22,6 +23,12 @@ writeFileSync(
22
23
  "utf-8",
23
24
  );
24
25
 
26
+ console.log("\n=== in-flight runtime phases ===");
27
+ {
28
+ assert.equal(isInFlightRuntimePhase("crashed"), true, "crashed records remain recoverable");
29
+ assert.equal(isInFlightRuntimePhase("finalized"), false, "finalized records are terminal");
30
+ }
31
+
25
32
  console.log("\n=== runtime record write/read/update ===");
26
33
  {
27
34
  const first = writeUnitRuntimeRecord(base, "execute-task", "M100/S02/T09", 1000, { phase: "dispatched" });
@@ -118,7 +118,7 @@ test("guided flow checks pending deep setup before plan-v2 gate", () => {
118
118
  const source = readFileSync(join(gsdDir, "guided-flow.ts"), "utf-8");
119
119
  const showSmartEntryIdx = source.indexOf("export async function showSmartEntry");
120
120
  assert.notEqual(showSmartEntryIdx, -1);
121
- const deepIdx = source.indexOf("hasPendingDeepStage(prefs, basePath)", showSmartEntryIdx);
121
+ const deepIdx = source.indexOf("shouldRunDeepProjectSetup(state, prefs, basePath)", showSmartEntryIdx);
122
122
  const planIdx = source.indexOf("runPlanV2Gate(ctx, basePath, state)", showSmartEntryIdx);
123
123
  assert.ok(
124
124
  deepIdx > -1 && planIdx > -1 && deepIdx < planIdx,
@@ -9,12 +9,12 @@
9
9
 
10
10
  import { describe, test, beforeEach, afterEach } from "node:test";
11
11
  import assert from "node:assert/strict";
12
- import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readdirSync } from "node:fs";
12
+ import { existsSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, readdirSync } from "node:fs";
13
13
  import { join } from "node:path";
14
14
  import { tmpdir } from "node:os";
15
15
  import { execSync } from "node:child_process";
16
16
 
17
- import { PROJECT_FILES } from "../detection.js";
17
+ import { PROJECT_FILES, classifyProject } from "../detection.js";
18
18
 
19
19
  // ─── Helpers ─────────────────────────────────────────────────────────────────
20
20
 
@@ -30,6 +30,14 @@ function createGitRepo(): string {
30
30
  return dir;
31
31
  }
32
32
 
33
+ function createEmptyGitRepo(): string {
34
+ const dir = mkdtempSync(join(tmpdir(), "wt-dispatch-test-empty-"));
35
+ execSync("git init", { cwd: dir, stdio: "ignore" });
36
+ execSync("git config user.email test@test.com", { cwd: dir, stdio: "ignore" });
37
+ execSync("git config user.name Test", { cwd: dir, stdio: "ignore" });
38
+ return dir;
39
+ }
40
+
33
41
  /**
34
42
  * Simulate the health check logic from auto/phases.ts.
35
43
  *
@@ -64,8 +72,6 @@ function hasXcodeBundle(basePath: string): boolean {
64
72
  } catch { return false; }
65
73
  }
66
74
 
67
- import { existsSync } from "node:fs";
68
-
69
75
  // ─── Tests ───────────────────────────────────────────────────────────────────
70
76
 
71
77
  test("PROJECT_FILES is exported and contains expected multi-ecosystem entries", () => {
@@ -80,6 +86,21 @@ test("PROJECT_FILES is exported and contains expected multi-ecosystem entries",
80
86
  assert.ok(PROJECT_FILES.includes("Package.swift"), "includes Swift marker");
81
87
  });
82
88
 
89
+ test("runUnitPhase fails closed when classification returns invalid-repo", () => {
90
+ const source = readFileSync(join(process.cwd(), "src/resources/extensions/gsd/auto/phases.ts"), "utf-8");
91
+ const invalidRepoBranch = source.slice(
92
+ source.indexOf('projectClassification.kind === "invalid-repo"'),
93
+ source.indexOf('projectClassification.kind === "greenfield"'),
94
+ );
95
+
96
+ assert.match(invalidRepoBranch, /projectClassification\.reason === "missing \.git" && hasGit/);
97
+ assert.match(invalidRepoBranch, /project classification could not confirm \.git/);
98
+ assert.match(invalidRepoBranch, /ctx\.ui\.notify\(msg,\s*"error"\)/);
99
+ assert.match(invalidRepoBranch, /await deps\.stopAuto\(ctx,\s*pi,\s*msg\)/);
100
+ assert.match(invalidRepoBranch, /return \{ action: "break", reason: "worktree-invalid" \}/);
101
+ assert.match(invalidRepoBranch, /classified as invalid-repo/);
102
+ });
103
+
83
104
  describe("health check with git repo", () => {
84
105
  let dir: string;
85
106
  beforeEach(() => { dir = createGitRepo(); });
@@ -132,8 +153,18 @@ describe("health check with git repo", () => {
132
153
  });
133
154
 
134
155
  test("health check passes for empty git repo (greenfield project)", () => {
135
- assert.ok(wouldPassHealthCheck(dir, existsSync), "empty git repo should pass health check (greenfield)");
136
- assert.ok(!hasRecognizedProjectFiles(dir, existsSync), "empty git repo has no recognized project files");
156
+ const empty = createEmptyGitRepo();
157
+ try {
158
+ assert.ok(wouldPassHealthCheck(empty, existsSync), "empty git repo should pass health check (greenfield)");
159
+ assert.equal(classifyProject(empty).kind, "greenfield");
160
+ } finally {
161
+ rmSync(empty, { recursive: true, force: true });
162
+ }
163
+ });
164
+
165
+ test("health check classifies README-only repo as untyped existing, not greenfield", () => {
166
+ assert.ok(wouldPassHealthCheck(dir, existsSync), "README-only repo should pass health check");
167
+ assert.equal(classifyProject(dir).kind, "untyped-existing");
137
168
  });
138
169
  });
139
170
 
@@ -235,4 +235,11 @@ describe("removeWorktree — missing worktree", () => {
235
235
  "should not throw when worktree does not exist",
236
236
  );
237
237
  });
238
+
239
+ test("deleteBranch is quiet when the branch is already gone", () => {
240
+ assert.doesNotThrow(
241
+ () => removeWorktree(base, "nonexistent", { deleteBranch: true }),
242
+ "missing branch should be treated as already cleaned up",
243
+ );
244
+ });
238
245
  });
@@ -56,11 +56,11 @@ test("#2616: findNestedGitDirs ignores .git files (worktree pointers)", (t) => {
56
56
  );
57
57
  });
58
58
 
59
- test("#2616: findNestedGitDirs skips excluded directories (node_modules, .gsd, target)", (t) => {
59
+ test("#2616: findNestedGitDirs skips excluded directories (node_modules, .gsd, .bg-shell, target)", (t) => {
60
60
  const root = makeRoot(t);
61
61
 
62
62
  // All three of these contain a .git *directory*, but the scan must skip them.
63
- for (const excluded of ["node_modules", ".gsd", "target"]) {
63
+ for (const excluded of ["node_modules", ".gsd", ".bg-shell", "target"]) {
64
64
  const inside = join(root, excluded, "vendored-pkg");
65
65
  mkdirSync(join(inside, ".git"), { recursive: true });
66
66
  }
@@ -73,6 +73,13 @@ test("#2616: findNestedGitDirs skips excluded directories (node_modules, .gsd, t
73
73
  );
74
74
  });
75
75
 
76
+ test("#2616: findNestedGitDirs ignores normal missing child .git probes", (t) => {
77
+ const root = makeRoot(t);
78
+ mkdirSync(join(root, "plain-dir"), { recursive: true });
79
+
80
+ assert.deepEqual(findNestedGitDirs(root), []);
81
+ });
82
+
76
83
  test("#2616: findNestedGitDirs finds deeply nested repos", (t) => {
77
84
  const root = makeRoot(t);
78
85
  const deep = join(root, "a", "b", "c", "scaffolded");