gsd-pi 2.29.0 → 2.30.0-dev.7e1bbce

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 (328) hide show
  1. package/README.md +24 -17
  2. package/dist/cli.js +51 -0
  3. package/dist/extension-registry.d.ts +63 -0
  4. package/dist/extension-registry.js +166 -0
  5. package/dist/headless.js +4 -0
  6. package/dist/help-text.js +35 -0
  7. package/dist/loader.js +10 -1
  8. package/dist/resource-loader.js +11 -1
  9. package/dist/resources/extensions/async-jobs/extension-manifest.json +13 -0
  10. package/dist/resources/extensions/bg-shell/extension-manifest.json +14 -0
  11. package/dist/resources/extensions/bg-shell/process-manager.ts +13 -0
  12. package/dist/resources/extensions/browser-tools/extension-manifest.json +37 -0
  13. package/dist/resources/extensions/context7/extension-manifest.json +12 -0
  14. package/dist/resources/extensions/google-search/extension-manifest.json +12 -0
  15. package/dist/resources/extensions/gsd/auto-dashboard.ts +31 -0
  16. package/dist/resources/extensions/gsd/auto-dispatch.ts +32 -3
  17. package/dist/resources/extensions/gsd/auto-post-unit.ts +45 -13
  18. package/dist/resources/extensions/gsd/auto-prompts.ts +40 -17
  19. package/dist/resources/extensions/gsd/auto-recovery.ts +18 -23
  20. package/dist/resources/extensions/gsd/auto-start.ts +18 -32
  21. package/dist/resources/extensions/gsd/auto-worktree.ts +21 -182
  22. package/dist/resources/extensions/gsd/auto.ts +2 -24
  23. package/dist/resources/extensions/gsd/captures.ts +4 -10
  24. package/dist/resources/extensions/gsd/commands-extensions.ts +328 -0
  25. package/dist/resources/extensions/gsd/commands-handlers.ts +22 -2
  26. package/dist/resources/extensions/gsd/commands-logs.ts +13 -14
  27. package/dist/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
  28. package/dist/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
  29. package/dist/resources/extensions/gsd/commands.ts +108 -24
  30. package/dist/resources/extensions/gsd/dashboard-overlay.ts +2 -1
  31. package/dist/resources/extensions/gsd/detection.ts +2 -1
  32. package/dist/resources/extensions/gsd/doctor-checks.ts +49 -1
  33. package/dist/resources/extensions/gsd/doctor-types.ts +3 -1
  34. package/dist/resources/extensions/gsd/extension-manifest.json +18 -0
  35. package/dist/resources/extensions/gsd/forensics.ts +2 -2
  36. package/dist/resources/extensions/gsd/git-service.ts +3 -2
  37. package/dist/resources/extensions/gsd/gitignore.ts +9 -63
  38. package/dist/resources/extensions/gsd/gsd-db.ts +1 -165
  39. package/dist/resources/extensions/gsd/guided-flow.ts +8 -5
  40. package/dist/resources/extensions/gsd/index.ts +16 -3
  41. package/dist/resources/extensions/gsd/json-persistence.ts +16 -1
  42. package/dist/resources/extensions/gsd/md-importer.ts +3 -2
  43. package/dist/resources/extensions/gsd/mechanical-completion.ts +430 -0
  44. package/dist/resources/extensions/gsd/migrate/command.ts +3 -2
  45. package/dist/resources/extensions/gsd/migrate/writer.ts +2 -1
  46. package/dist/resources/extensions/gsd/migrate-external.ts +123 -0
  47. package/dist/resources/extensions/gsd/paths.ts +24 -2
  48. package/dist/resources/extensions/gsd/post-unit-hooks.ts +6 -5
  49. package/dist/resources/extensions/gsd/preferences-models.ts +7 -1
  50. package/dist/resources/extensions/gsd/preferences-validation.ts +2 -1
  51. package/dist/resources/extensions/gsd/preferences.ts +10 -5
  52. package/dist/resources/extensions/gsd/prompts/discuss-headless.md +4 -2
  53. package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
  54. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +26 -2
  55. package/dist/resources/extensions/gsd/prompts/plan-slice.md +15 -1
  56. package/dist/resources/extensions/gsd/prompts/workflow-start.md +28 -0
  57. package/dist/resources/extensions/gsd/queue-order.ts +10 -11
  58. package/dist/resources/extensions/gsd/repo-identity.ts +148 -0
  59. package/dist/resources/extensions/gsd/resource-version.ts +99 -0
  60. package/dist/resources/extensions/gsd/roadmap-slices.ts +22 -7
  61. package/dist/resources/extensions/gsd/session-forensics.ts +4 -3
  62. package/dist/resources/extensions/gsd/session-lock.ts +53 -4
  63. package/dist/resources/extensions/gsd/session-status-io.ts +23 -41
  64. package/dist/resources/extensions/gsd/tests/activity-log.test.ts +2 -2
  65. package/dist/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +1 -1
  66. package/dist/resources/extensions/gsd/tests/auto-recovery.test.ts +3 -3
  67. package/dist/resources/extensions/gsd/tests/auto-skip-loop.test.ts +1 -1
  68. package/dist/resources/extensions/gsd/tests/auto-worktree.test.ts +0 -58
  69. package/dist/resources/extensions/gsd/tests/doctor-runtime.test.ts +3 -4
  70. package/dist/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
  71. package/dist/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +5 -18
  72. package/dist/resources/extensions/gsd/tests/git-service.test.ts +10 -37
  73. package/dist/resources/extensions/gsd/tests/knowledge.test.ts +4 -4
  74. package/dist/resources/extensions/gsd/tests/mechanical-completion.test.ts +356 -0
  75. package/dist/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +1 -1
  76. package/dist/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +1 -0
  77. package/dist/resources/extensions/gsd/tests/token-profile.test.ts +14 -16
  78. package/dist/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
  79. package/dist/resources/extensions/gsd/triage-resolution.ts +2 -1
  80. package/dist/resources/extensions/gsd/types.ts +2 -0
  81. package/dist/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
  82. package/dist/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
  83. package/dist/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
  84. package/dist/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
  85. package/dist/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
  86. package/dist/resources/extensions/gsd/workflow-templates/registry.json +85 -0
  87. package/dist/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
  88. package/dist/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
  89. package/dist/resources/extensions/gsd/workflow-templates/spike.md +69 -0
  90. package/dist/resources/extensions/gsd/workflow-templates.ts +241 -0
  91. package/dist/resources/extensions/gsd/worktree-command.ts +1 -11
  92. package/dist/resources/extensions/gsd/worktree-manager.ts +3 -2
  93. package/dist/resources/extensions/gsd/worktree.ts +42 -5
  94. package/dist/resources/extensions/mac-tools/extension-manifest.json +16 -0
  95. package/dist/resources/extensions/mcp-client/index.ts +459 -0
  96. package/dist/resources/extensions/mcporter/extension-manifest.json +12 -0
  97. package/dist/resources/extensions/remote-questions/discord-adapter.ts +8 -19
  98. package/dist/resources/extensions/remote-questions/extension-manifest.json +11 -0
  99. package/dist/resources/extensions/remote-questions/http-client.ts +76 -0
  100. package/dist/resources/extensions/remote-questions/slack-adapter.ts +11 -17
  101. package/dist/resources/extensions/remote-questions/telegram-adapter.ts +8 -19
  102. package/dist/resources/extensions/search-the-web/extension-manifest.json +13 -0
  103. package/dist/resources/extensions/slash-commands/extension-manifest.json +11 -0
  104. package/dist/resources/extensions/subagent/extension-manifest.json +13 -0
  105. package/dist/resources/extensions/ttsr/extension-manifest.json +11 -0
  106. package/dist/resources/extensions/universal-config/extension-manifest.json +13 -0
  107. package/dist/resources/extensions/voice/extension-manifest.json +12 -0
  108. package/dist/resources/skills/create-gsd-extension/SKILL.md +87 -0
  109. package/dist/resources/skills/create-gsd-extension/references/compaction-session-control.md +77 -0
  110. package/dist/resources/skills/create-gsd-extension/references/custom-commands.md +139 -0
  111. package/dist/resources/skills/create-gsd-extension/references/custom-rendering.md +108 -0
  112. package/dist/resources/skills/create-gsd-extension/references/custom-tools.md +183 -0
  113. package/dist/resources/skills/create-gsd-extension/references/custom-ui.md +490 -0
  114. package/dist/resources/skills/create-gsd-extension/references/events-reference.md +126 -0
  115. package/dist/resources/skills/create-gsd-extension/references/extension-lifecycle.md +64 -0
  116. package/dist/resources/skills/create-gsd-extension/references/extensionapi-reference.md +75 -0
  117. package/dist/resources/skills/create-gsd-extension/references/extensioncontext-reference.md +53 -0
  118. package/dist/resources/skills/create-gsd-extension/references/key-rules-gotchas.md +36 -0
  119. package/dist/resources/skills/create-gsd-extension/references/mode-behavior.md +32 -0
  120. package/dist/resources/skills/create-gsd-extension/references/model-provider-management.md +89 -0
  121. package/dist/resources/skills/create-gsd-extension/references/packaging-distribution.md +55 -0
  122. package/dist/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +90 -0
  123. package/dist/resources/skills/create-gsd-extension/references/state-management.md +70 -0
  124. package/dist/resources/skills/create-gsd-extension/references/system-prompt-modification.md +52 -0
  125. package/dist/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
  126. package/dist/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
  127. package/dist/resources/skills/create-gsd-extension/workflows/add-capability.md +57 -0
  128. package/dist/resources/skills/create-gsd-extension/workflows/create-extension.md +156 -0
  129. package/dist/resources/skills/create-gsd-extension/workflows/debug-extension.md +74 -0
  130. package/dist/resources/skills/create-skill/SKILL.md +184 -0
  131. package/dist/resources/skills/create-skill/references/api-security.md +226 -0
  132. package/dist/resources/skills/create-skill/references/be-clear-and-direct.md +531 -0
  133. package/dist/resources/skills/create-skill/references/common-patterns.md +595 -0
  134. package/dist/resources/skills/create-skill/references/core-principles.md +437 -0
  135. package/dist/resources/skills/create-skill/references/executable-code.md +175 -0
  136. package/dist/resources/skills/create-skill/references/gsd-skill-ecosystem.md +68 -0
  137. package/dist/resources/skills/create-skill/references/iteration-and-testing.md +474 -0
  138. package/dist/resources/skills/create-skill/references/recommended-structure.md +168 -0
  139. package/dist/resources/skills/create-skill/references/skill-structure.md +372 -0
  140. package/dist/resources/skills/create-skill/references/use-xml-tags.md +466 -0
  141. package/dist/resources/skills/create-skill/references/using-scripts.md +113 -0
  142. package/dist/resources/skills/create-skill/references/using-templates.md +112 -0
  143. package/dist/resources/skills/create-skill/references/workflows-and-validation.md +510 -0
  144. package/dist/resources/skills/create-skill/templates/router-skill.md +73 -0
  145. package/dist/resources/skills/create-skill/templates/simple-skill.md +33 -0
  146. package/dist/resources/skills/create-skill/workflows/add-reference.md +96 -0
  147. package/dist/resources/skills/create-skill/workflows/add-script.md +93 -0
  148. package/dist/resources/skills/create-skill/workflows/add-template.md +74 -0
  149. package/dist/resources/skills/create-skill/workflows/add-workflow.md +120 -0
  150. package/dist/resources/skills/create-skill/workflows/audit-skill.md +148 -0
  151. package/dist/resources/skills/create-skill/workflows/create-new-skill.md +196 -0
  152. package/dist/resources/skills/create-skill/workflows/get-guidance.md +121 -0
  153. package/dist/resources/skills/create-skill/workflows/upgrade-to-router.md +161 -0
  154. package/dist/resources/skills/create-skill/workflows/verify-skill.md +204 -0
  155. package/dist/resources/skills/react-best-practices/SKILL.md +1 -1
  156. package/dist/worktree-cli.d.ts +34 -0
  157. package/dist/worktree-cli.js +294 -0
  158. package/dist/worktree-name-gen.d.ts +7 -0
  159. package/dist/worktree-name-gen.js +44 -0
  160. package/package.json +1 -1
  161. package/packages/native/dist/native.d.ts +2 -0
  162. package/packages/native/dist/native.js +19 -5
  163. package/packages/native/src/native.ts +23 -9
  164. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  165. package/packages/pi-coding-agent/dist/core/extensions/loader.js +13 -0
  166. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  167. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
  168. package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -0
  169. package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
  170. package/packages/pi-coding-agent/package.json +1 -1
  171. package/packages/pi-coding-agent/src/core/extensions/loader.ts +13 -0
  172. package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -0
  173. package/pkg/package.json +1 -1
  174. package/src/resources/extensions/async-jobs/extension-manifest.json +13 -0
  175. package/src/resources/extensions/bg-shell/extension-manifest.json +14 -0
  176. package/src/resources/extensions/bg-shell/process-manager.ts +13 -0
  177. package/src/resources/extensions/browser-tools/extension-manifest.json +37 -0
  178. package/src/resources/extensions/context7/extension-manifest.json +12 -0
  179. package/src/resources/extensions/google-search/extension-manifest.json +12 -0
  180. package/src/resources/extensions/gsd/auto-dashboard.ts +31 -0
  181. package/src/resources/extensions/gsd/auto-dispatch.ts +32 -3
  182. package/src/resources/extensions/gsd/auto-post-unit.ts +45 -13
  183. package/src/resources/extensions/gsd/auto-prompts.ts +40 -17
  184. package/src/resources/extensions/gsd/auto-recovery.ts +18 -23
  185. package/src/resources/extensions/gsd/auto-start.ts +18 -32
  186. package/src/resources/extensions/gsd/auto-worktree.ts +21 -182
  187. package/src/resources/extensions/gsd/auto.ts +2 -24
  188. package/src/resources/extensions/gsd/captures.ts +4 -10
  189. package/src/resources/extensions/gsd/commands-extensions.ts +328 -0
  190. package/src/resources/extensions/gsd/commands-handlers.ts +22 -2
  191. package/src/resources/extensions/gsd/commands-logs.ts +13 -14
  192. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +44 -14
  193. package/src/resources/extensions/gsd/commands-workflow-templates.ts +544 -0
  194. package/src/resources/extensions/gsd/commands.ts +108 -24
  195. package/src/resources/extensions/gsd/dashboard-overlay.ts +2 -1
  196. package/src/resources/extensions/gsd/detection.ts +2 -1
  197. package/src/resources/extensions/gsd/doctor-checks.ts +49 -1
  198. package/src/resources/extensions/gsd/doctor-types.ts +3 -1
  199. package/src/resources/extensions/gsd/extension-manifest.json +18 -0
  200. package/src/resources/extensions/gsd/forensics.ts +2 -2
  201. package/src/resources/extensions/gsd/git-service.ts +3 -2
  202. package/src/resources/extensions/gsd/gitignore.ts +9 -63
  203. package/src/resources/extensions/gsd/gsd-db.ts +1 -165
  204. package/src/resources/extensions/gsd/guided-flow.ts +8 -5
  205. package/src/resources/extensions/gsd/index.ts +16 -3
  206. package/src/resources/extensions/gsd/json-persistence.ts +16 -1
  207. package/src/resources/extensions/gsd/md-importer.ts +3 -2
  208. package/src/resources/extensions/gsd/mechanical-completion.ts +430 -0
  209. package/src/resources/extensions/gsd/migrate/command.ts +3 -2
  210. package/src/resources/extensions/gsd/migrate/writer.ts +2 -1
  211. package/src/resources/extensions/gsd/migrate-external.ts +123 -0
  212. package/src/resources/extensions/gsd/paths.ts +24 -2
  213. package/src/resources/extensions/gsd/post-unit-hooks.ts +6 -5
  214. package/src/resources/extensions/gsd/preferences-models.ts +7 -1
  215. package/src/resources/extensions/gsd/preferences-validation.ts +2 -1
  216. package/src/resources/extensions/gsd/preferences.ts +10 -5
  217. package/src/resources/extensions/gsd/prompts/discuss-headless.md +4 -2
  218. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +1 -1
  219. package/src/resources/extensions/gsd/prompts/plan-milestone.md +26 -2
  220. package/src/resources/extensions/gsd/prompts/plan-slice.md +15 -1
  221. package/src/resources/extensions/gsd/prompts/workflow-start.md +28 -0
  222. package/src/resources/extensions/gsd/queue-order.ts +10 -11
  223. package/src/resources/extensions/gsd/repo-identity.ts +148 -0
  224. package/src/resources/extensions/gsd/resource-version.ts +99 -0
  225. package/src/resources/extensions/gsd/roadmap-slices.ts +22 -7
  226. package/src/resources/extensions/gsd/session-forensics.ts +4 -3
  227. package/src/resources/extensions/gsd/session-lock.ts +53 -4
  228. package/src/resources/extensions/gsd/session-status-io.ts +23 -41
  229. package/src/resources/extensions/gsd/tests/activity-log.test.ts +2 -2
  230. package/src/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +1 -1
  231. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +3 -3
  232. package/src/resources/extensions/gsd/tests/auto-skip-loop.test.ts +1 -1
  233. package/src/resources/extensions/gsd/tests/auto-worktree.test.ts +0 -58
  234. package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +3 -4
  235. package/src/resources/extensions/gsd/tests/extension-selector-separator.test.ts +60 -38
  236. package/src/resources/extensions/gsd/tests/feature-branch-lifecycle-integration.test.ts +5 -18
  237. package/src/resources/extensions/gsd/tests/git-service.test.ts +10 -37
  238. package/src/resources/extensions/gsd/tests/knowledge.test.ts +4 -4
  239. package/src/resources/extensions/gsd/tests/mechanical-completion.test.ts +356 -0
  240. package/src/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +1 -1
  241. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +1 -0
  242. package/src/resources/extensions/gsd/tests/token-profile.test.ts +14 -16
  243. package/src/resources/extensions/gsd/tests/workflow-templates.test.ts +173 -0
  244. package/src/resources/extensions/gsd/triage-resolution.ts +2 -1
  245. package/src/resources/extensions/gsd/types.ts +2 -0
  246. package/src/resources/extensions/gsd/workflow-templates/bugfix.md +87 -0
  247. package/src/resources/extensions/gsd/workflow-templates/dep-upgrade.md +74 -0
  248. package/src/resources/extensions/gsd/workflow-templates/full-project.md +41 -0
  249. package/src/resources/extensions/gsd/workflow-templates/hotfix.md +45 -0
  250. package/src/resources/extensions/gsd/workflow-templates/refactor.md +83 -0
  251. package/src/resources/extensions/gsd/workflow-templates/registry.json +85 -0
  252. package/src/resources/extensions/gsd/workflow-templates/security-audit.md +73 -0
  253. package/src/resources/extensions/gsd/workflow-templates/small-feature.md +81 -0
  254. package/src/resources/extensions/gsd/workflow-templates/spike.md +69 -0
  255. package/src/resources/extensions/gsd/workflow-templates.ts +241 -0
  256. package/src/resources/extensions/gsd/worktree-command.ts +1 -11
  257. package/src/resources/extensions/gsd/worktree-manager.ts +3 -2
  258. package/src/resources/extensions/gsd/worktree.ts +42 -5
  259. package/src/resources/extensions/mac-tools/extension-manifest.json +16 -0
  260. package/src/resources/extensions/mcp-client/index.ts +459 -0
  261. package/src/resources/extensions/mcporter/extension-manifest.json +12 -0
  262. package/src/resources/extensions/remote-questions/discord-adapter.ts +8 -19
  263. package/src/resources/extensions/remote-questions/extension-manifest.json +11 -0
  264. package/src/resources/extensions/remote-questions/http-client.ts +76 -0
  265. package/src/resources/extensions/remote-questions/slack-adapter.ts +11 -17
  266. package/src/resources/extensions/remote-questions/telegram-adapter.ts +8 -19
  267. package/src/resources/extensions/search-the-web/extension-manifest.json +13 -0
  268. package/src/resources/extensions/slash-commands/extension-manifest.json +11 -0
  269. package/src/resources/extensions/subagent/extension-manifest.json +13 -0
  270. package/src/resources/extensions/ttsr/extension-manifest.json +11 -0
  271. package/src/resources/extensions/universal-config/extension-manifest.json +13 -0
  272. package/src/resources/extensions/voice/extension-manifest.json +12 -0
  273. package/src/resources/skills/create-gsd-extension/SKILL.md +87 -0
  274. package/src/resources/skills/create-gsd-extension/references/compaction-session-control.md +77 -0
  275. package/src/resources/skills/create-gsd-extension/references/custom-commands.md +139 -0
  276. package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +108 -0
  277. package/src/resources/skills/create-gsd-extension/references/custom-tools.md +183 -0
  278. package/src/resources/skills/create-gsd-extension/references/custom-ui.md +490 -0
  279. package/src/resources/skills/create-gsd-extension/references/events-reference.md +126 -0
  280. package/src/resources/skills/create-gsd-extension/references/extension-lifecycle.md +64 -0
  281. package/src/resources/skills/create-gsd-extension/references/extensionapi-reference.md +75 -0
  282. package/src/resources/skills/create-gsd-extension/references/extensioncontext-reference.md +53 -0
  283. package/src/resources/skills/create-gsd-extension/references/key-rules-gotchas.md +36 -0
  284. package/src/resources/skills/create-gsd-extension/references/mode-behavior.md +32 -0
  285. package/src/resources/skills/create-gsd-extension/references/model-provider-management.md +89 -0
  286. package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +55 -0
  287. package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +90 -0
  288. package/src/resources/skills/create-gsd-extension/references/state-management.md +70 -0
  289. package/src/resources/skills/create-gsd-extension/references/system-prompt-modification.md +52 -0
  290. package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +51 -0
  291. package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +143 -0
  292. package/src/resources/skills/create-gsd-extension/workflows/add-capability.md +57 -0
  293. package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +156 -0
  294. package/src/resources/skills/create-gsd-extension/workflows/debug-extension.md +74 -0
  295. package/src/resources/skills/create-skill/SKILL.md +184 -0
  296. package/src/resources/skills/create-skill/references/api-security.md +226 -0
  297. package/src/resources/skills/create-skill/references/be-clear-and-direct.md +531 -0
  298. package/src/resources/skills/create-skill/references/common-patterns.md +595 -0
  299. package/src/resources/skills/create-skill/references/core-principles.md +437 -0
  300. package/src/resources/skills/create-skill/references/executable-code.md +175 -0
  301. package/src/resources/skills/create-skill/references/gsd-skill-ecosystem.md +68 -0
  302. package/src/resources/skills/create-skill/references/iteration-and-testing.md +474 -0
  303. package/src/resources/skills/create-skill/references/recommended-structure.md +168 -0
  304. package/src/resources/skills/create-skill/references/skill-structure.md +372 -0
  305. package/src/resources/skills/create-skill/references/use-xml-tags.md +466 -0
  306. package/src/resources/skills/create-skill/references/using-scripts.md +113 -0
  307. package/src/resources/skills/create-skill/references/using-templates.md +112 -0
  308. package/src/resources/skills/create-skill/references/workflows-and-validation.md +510 -0
  309. package/src/resources/skills/create-skill/templates/router-skill.md +73 -0
  310. package/src/resources/skills/create-skill/templates/simple-skill.md +33 -0
  311. package/src/resources/skills/create-skill/workflows/add-reference.md +96 -0
  312. package/src/resources/skills/create-skill/workflows/add-script.md +93 -0
  313. package/src/resources/skills/create-skill/workflows/add-template.md +74 -0
  314. package/src/resources/skills/create-skill/workflows/add-workflow.md +120 -0
  315. package/src/resources/skills/create-skill/workflows/audit-skill.md +148 -0
  316. package/src/resources/skills/create-skill/workflows/create-new-skill.md +196 -0
  317. package/src/resources/skills/create-skill/workflows/get-guidance.md +121 -0
  318. package/src/resources/skills/create-skill/workflows/upgrade-to-router.md +161 -0
  319. package/src/resources/skills/create-skill/workflows/verify-skill.md +204 -0
  320. package/src/resources/skills/react-best-practices/SKILL.md +1 -1
  321. package/dist/resources/extensions/gsd/auto-worktree-sync.ts +0 -198
  322. package/dist/resources/extensions/gsd/tests/worktree-db-integration.test.ts +0 -205
  323. package/dist/resources/extensions/gsd/tests/worktree-db.test.ts +0 -442
  324. package/dist/resources/extensions/mcporter/index.ts +0 -525
  325. package/src/resources/extensions/gsd/auto-worktree-sync.ts +0 -198
  326. package/src/resources/extensions/gsd/tests/worktree-db-integration.test.ts +0 -205
  327. package/src/resources/extensions/gsd/tests/worktree-db.test.ts +0 -442
  328. package/src/resources/extensions/mcporter/index.ts +0 -525
@@ -6,25 +6,24 @@
6
6
  * manages create, enter, detect, and teardown for auto-mode worktrees.
7
7
  */
8
8
 
9
- import { existsSync, cpSync, readFileSync, readdirSync, mkdirSync, realpathSync, unlinkSync, statSync } from "node:fs";
9
+ import { existsSync, readFileSync, realpathSync, unlinkSync, statSync } from "node:fs";
10
10
  import { isAbsolute, join, sep } from "node:path";
11
11
  import { GSDError, GSD_IO_ERROR, GSD_GIT_ERROR } from "./errors.js";
12
- import { copyWorktreeDb, reconcileWorktreeDb, isDbAvailable } from "./gsd-db.js";
13
- import { atomicWriteSync } from "./atomic-write.js";
14
12
  import { execSync, execFileSync } from "node:child_process";
15
- import { safeCopy, safeCopyRecursive } from "./safe-fs.js";
16
13
  import {
17
14
  createWorktree,
18
15
  removeWorktree,
19
16
  worktreePath,
20
17
  } from "./worktree-manager.js";
21
18
  import { detectWorktreeName, resolveGitHeadPath, nudgeGitBranchCache } from "./worktree.js";
19
+ import { ensureGsdSymlink } from "./repo-identity.js";
22
20
  import {
23
21
  MergeConflictError,
24
22
  readIntegrationBranch,
25
23
  } from "./git-service.js";
26
24
  import { parseRoadmap } from "./files.js";
27
25
  import { loadEffectiveGSDPreferences } from "./preferences.js";
26
+ import { gsdRoot } from "./paths.js";
28
27
  import {
29
28
  nativeGetCurrentBranch,
30
29
  nativeWorkingTreeStatus,
@@ -103,111 +102,6 @@ export function autoWorktreeBranch(milestoneId: string): string {
103
102
  * to prevent split-brain.
104
103
  */
105
104
 
106
- /**
107
- * Forward-merge plan checkbox state from the project root into a freshly
108
- * re-attached worktree (#778).
109
- *
110
- * When auto-mode stops via crash (not graceful stop), the milestone branch
111
- * HEAD may be behind the filesystem state at the project root because
112
- * syncStateToProjectRoot() runs after every task completion but the final
113
- * git commit may not have happened before the crash. On restart the worktree
114
- * is re-attached to the branch HEAD, which has [ ] for the crashed task,
115
- * causing verifyExpectedArtifact() to fail and triggering an infinite
116
- * dispatch/skip loop.
117
- *
118
- * Fix: after re-attaching, read every *.md plan file in the milestone
119
- * directory at the project root and apply any [x] checkbox states that are
120
- * ahead of the worktree version (forward-only: never downgrade [x] → [ ]).
121
- *
122
- * This is safe because syncStateToProjectRoot() is the authoritative source
123
- * of post-task state at the project root — it writes the same [x] the LLM
124
- * produced, then the auto-commit follows. If the commit never happened, the
125
- * filesystem copy is still valid and correct.
126
- */
127
- function reconcilePlanCheckboxes(projectRoot: string, wtPath: string, milestoneId: string): void {
128
- const srcMilestone = join(projectRoot, ".gsd", "milestones", milestoneId);
129
- const dstMilestone = join(wtPath, ".gsd", "milestones", milestoneId);
130
- if (!existsSync(srcMilestone) || !existsSync(dstMilestone)) return;
131
-
132
- // Walk all markdown files in the milestone directory (plans, summaries, etc.)
133
- function walkMd(dir: string): string[] {
134
- const results: string[] = [];
135
- try {
136
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
137
- const full = join(dir, entry.name);
138
- if (entry.isDirectory()) {
139
- results.push(...walkMd(full));
140
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
141
- results.push(full);
142
- }
143
- }
144
- } catch { /* non-fatal */ }
145
- return results;
146
- }
147
-
148
- for (const srcFile of walkMd(srcMilestone)) {
149
- const rel = srcFile.slice(srcMilestone.length);
150
- const dstFile = dstMilestone + rel;
151
- if (!existsSync(dstFile)) continue; // only reconcile existing files
152
-
153
- let srcContent: string;
154
- let dstContent: string;
155
- try {
156
- srcContent = readFileSync(srcFile, "utf-8");
157
- dstContent = readFileSync(dstFile, "utf-8");
158
- } catch { continue; }
159
-
160
- if (srcContent === dstContent) continue;
161
-
162
- // Extract all checked task IDs from the source (project root)
163
- // Pattern: - [x] **T<id>: or - [x] **S<id>: (case-insensitive x)
164
- const checkedRe = /^- \[[xX]\] \*\*([TS]\d+):/gm;
165
- const srcChecked = new Set<string>();
166
- for (const m of srcContent.matchAll(checkedRe)) srcChecked.add(m[1]);
167
-
168
- if (srcChecked.size === 0) continue;
169
-
170
- // Forward-apply: replace [ ] → [x] for any IDs that are checked in src
171
- let updated = dstContent;
172
- let changed = false;
173
- for (const id of srcChecked) {
174
- const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
175
- const uncheckedRe = new RegExp(`^(- )\\[ \\]( \\*\\*${escapedId}:)`, "gm");
176
- if (uncheckedRe.test(updated)) {
177
- updated = updated.replace(
178
- new RegExp(`^(- )\\[ \\]( \\*\\*${escapedId}:)`, "gm"),
179
- "$1[x]$2",
180
- );
181
- changed = true;
182
- }
183
- }
184
-
185
- if (changed) {
186
- try {
187
- atomicWriteSync(dstFile, updated, "utf-8");
188
- } catch { /* non-fatal */ }
189
- }
190
- }
191
-
192
- // Also forward-merge completed-units.json (set-union)
193
- const srcKeys = join(projectRoot, ".gsd", "completed-units.json");
194
- const dstKeys = join(wtPath, ".gsd", "completed-units.json");
195
- if (existsSync(srcKeys)) {
196
- try {
197
- const src: string[] = JSON.parse(readFileSync(srcKeys, "utf-8"));
198
- let dst: string[] = [];
199
- if (existsSync(dstKeys)) {
200
- try { dst = JSON.parse(readFileSync(dstKeys, "utf-8")); } catch { /* ignore corrupt */ }
201
- }
202
- const merged = [...new Set([...dst, ...src])];
203
- if (merged.length > dst.length) {
204
- mkdirSync(join(wtPath, ".gsd"), { recursive: true });
205
- atomicWriteSync(dstKeys, JSON.stringify(merged), "utf-8");
206
- }
207
- } catch { /* non-fatal */ }
208
- }
209
- }
210
-
211
105
  export function createAutoWorktree(basePath: string, milestoneId: string): string {
212
106
  const branch = autoWorktreeBranch(milestoneId);
213
107
 
@@ -227,32 +121,8 @@ export function createAutoWorktree(basePath: string, milestoneId: string): strin
227
121
  info = createWorktree(basePath, milestoneId, { branch, startPoint: integrationBranch });
228
122
  }
229
123
 
230
- // Copy .gsd/ planning artifacts from the source repo into the new worktree.
231
- // Worktrees are fresh git checkouts — untracked files don't carry over.
232
- // Planning artifacts may be untracked if the project's .gitignore had a
233
- // blanket .gsd/ rule (pre-v2.14.0). Without this copy, auto-mode loops
234
- // on plan-slice because the plan file doesn't exist in the worktree.
235
- //
236
- // IMPORTANT: Skip when re-attaching to an existing branch (#759).
237
- // The branch checkout already has committed artifacts with correct state
238
- // (e.g. [x] for completed slices). Copying from the project root would
239
- // overwrite them with stale data ([ ] checkboxes) because the root is
240
- // not always fully synced.
241
- if (!branchExists) {
242
- copyPlanningArtifacts(basePath, info.path);
243
- } else {
244
- // Re-attaching to an existing branch: forward-merge any plan checkpoint
245
- // state from the project root into the worktree (#778).
246
- //
247
- // If auto-mode stopped via crash, the milestone branch HEAD may lag behind
248
- // the project root filesystem because syncStateToProjectRoot() ran after
249
- // task completion but the auto-commit never fired. On restart the worktree
250
- // is re-created from the branch HEAD (which has [ ] for the crashed task),
251
- // causing verifyExpectedArtifact() to return false → stale-key eviction →
252
- // infinite dispatch/skip loop. Reconciling here ensures the worktree sees
253
- // the same [x] state that syncStateToProjectRoot() wrote to the root.
254
- reconcilePlanCheckboxes(basePath, info.path, milestoneId);
255
- }
124
+ // Ensure worktree shares external state via symlink
125
+ ensureGsdSymlink(info.path);
256
126
 
257
127
  // Run user-configured post-create hook (#597) — e.g. copy .env, symlink assets
258
128
  const hookError = runWorktreePostCreateHook(basePath, info.path);
@@ -279,36 +149,6 @@ export function createAutoWorktree(basePath: string, milestoneId: string): strin
279
149
  return info.path;
280
150
  }
281
151
 
282
- /**
283
- * Copy .gsd/ planning artifacts from source repo to a new worktree.
284
- * Copies milestones/, DECISIONS.md, REQUIREMENTS.md, PROJECT.md, QUEUE.md,
285
- * STATE.md, KNOWLEDGE.md, and OVERRIDES.md.
286
- * Skips runtime files (auto.lock, metrics.json, etc.) and the worktrees/ dir.
287
- * Best-effort — failures are non-fatal since auto-mode can recreate artifacts.
288
- */
289
- function copyPlanningArtifacts(srcBase: string, wtPath: string): void {
290
- const srcGsd = join(srcBase, ".gsd");
291
- const dstGsd = join(wtPath, ".gsd");
292
- if (!existsSync(srcGsd)) return;
293
-
294
- // Copy milestones/ directory (planning files, roadmaps, plans, research)
295
- safeCopyRecursive(join(srcGsd, "milestones"), join(dstGsd, "milestones"), { force: true });
296
-
297
- // Copy top-level planning files
298
- for (const file of ["DECISIONS.md", "REQUIREMENTS.md", "PROJECT.md", "QUEUE.md", "STATE.md", "KNOWLEDGE.md", "OVERRIDES.md"]) {
299
- safeCopy(join(srcGsd, file), join(dstGsd, file), { force: true });
300
- }
301
-
302
- // Copy gsd.db if present in source
303
- const srcDb = join(srcGsd, "gsd.db");
304
- const destDb = join(dstGsd, "gsd.db");
305
- if (existsSync(srcDb)) {
306
- try {
307
- copyWorktreeDb(srcDb, destDb);
308
- } catch { /* non-fatal */ }
309
- }
310
- }
311
-
312
152
  /**
313
153
  * Teardown an auto-worktree: chdir back to original base, then remove
314
154
  * the worktree and its branch.
@@ -346,7 +186,7 @@ export function isInAutoWorktree(basePath: string): boolean {
346
186
  // Primary check: use originalBase if available (fast path)
347
187
  if (originalBase) {
348
188
  const resolvedBase = existsSync(basePath) ? realpathSync(basePath) : basePath;
349
- const wtDir = join(resolvedBase, ".gsd", "worktrees");
189
+ const wtDir = join(gsdRoot(resolvedBase), "worktrees");
350
190
  if (!cwd.startsWith(wtDir)) return false;
351
191
  const branch = nativeGetCurrentBranch(cwd);
352
192
  return branch.startsWith("milestone/");
@@ -364,8 +204,8 @@ export function isInAutoWorktree(basePath: string): boolean {
364
204
  // Worktrees have a .git file with "gitdir: ..." pointing to the main repo
365
205
  const gitContent = readFileSync(worktreeMarker, "utf-8").trim();
366
206
  if (!gitContent.startsWith("gitdir:")) return false;
367
- // Verify cwd path contains .gsd/worktrees/
368
- if (!cwd.includes(`${sep}.gsd${sep}worktrees${sep}`) && !cwd.includes("/.gsd/worktrees/")) return false;
207
+ // Verify we're inside a GSD-managed worktree
208
+ if (!detectWorktreeName(cwd)) return false;
369
209
  const branch = nativeGetCurrentBranch(cwd);
370
210
  return branch.startsWith("milestone/");
371
211
  } catch {
@@ -458,7 +298,7 @@ export function getActiveAutoWorktreeContext(): {
458
298
  if (!originalBase) return null;
459
299
  const cwd = process.cwd();
460
300
  const resolvedBase = existsSync(originalBase) ? realpathSync(originalBase) : originalBase;
461
- const wtDir = join(resolvedBase, ".gsd", "worktrees");
301
+ const wtDir = join(gsdRoot(resolvedBase), "worktrees");
462
302
  if (!cwd.startsWith(wtDir)) return null;
463
303
  const worktreeName = detectWorktreeName(cwd);
464
304
  if (!worktreeName) return null;
@@ -518,15 +358,6 @@ export function mergeMilestoneToMain(
518
358
  // 1. Auto-commit dirty state in worktree before leaving
519
359
  autoCommitDirtyState(worktreeCwd);
520
360
 
521
- // Reconcile worktree DB into main DB before leaving worktree context
522
- if (isDbAvailable()) {
523
- try {
524
- const worktreeDbPath = join(worktreeCwd, ".gsd", "gsd.db");
525
- const mainDbPath = join(originalBasePath_, ".gsd", "gsd.db");
526
- reconcileWorktreeDb(mainDbPath, worktreeDbPath);
527
- } catch { /* non-fatal */ }
528
- }
529
-
530
361
  // 2. Parse roadmap for slice listing
531
362
  const roadmap = parseRoadmap(roadmapContent);
532
363
  const completedSlices = roadmap.slices.filter(s => s.done);
@@ -535,11 +366,19 @@ export function mergeMilestoneToMain(
535
366
  const previousCwd = process.cwd();
536
367
  process.chdir(originalBasePath_);
537
368
 
538
- // 3a. Auto-commit any dirty state in the project root that syncStateToProjectRoot
539
- // wrote during execution. Without this, the squash merge can fail with
540
- // "Your local changes to the following files would be overwritten by merge" (#1127).
369
+ // 3a. Auto-commit any dirty state in the project root. Without this, the
370
+ // squash merge can fail with "Your local changes would be overwritten" (#1127).
541
371
  autoCommitDirtyState(originalBasePath_);
542
372
 
373
+ // 3b. Remove untracked .gsd/ files that syncStateToProjectRoot copied.
374
+ // autoCommitDirtyState stages and commits everything (git add -A), but if
375
+ // the project root branch has no .gsd/ tracking (e.g., .gsd/ is gitignored),
376
+ // these files remain untracked and cause "untracked working tree files would
377
+ // be overwritten by merge" during squash-merge (#1237).
378
+ try {
379
+ execFileSync("git", ["clean", "-fd", ".gsd/"], { cwd: originalBasePath_, stdio: "pipe" });
380
+ } catch { /* non-fatal — clean failure shouldn't block merge attempt */ }
381
+
543
382
  // 4. Resolve integration branch — prefer milestone metadata, fall back to preferences / "main"
544
383
  const prefs = loadEffectiveGSDPreferences()?.preferences?.git ?? {};
545
384
  const integrationBranch = readIntegrationBranch(originalBasePath_, milestoneId);
@@ -556,7 +395,7 @@ export function mergeMilestoneToMain(
556
395
  // "Your local changes would be overwritten" (#827).
557
396
  const gsdStateFiles = ["STATE.md", "completed-units.json", "auto.lock"];
558
397
  for (const f of gsdStateFiles) {
559
- const p = join(originalBasePath_, ".gsd", f);
398
+ const p = join(gsdRoot(originalBasePath_), f);
560
399
  try { unlinkSync(p); } catch { /* non-fatal — file may not exist */ }
561
400
  }
562
401
  nativeCheckoutBranch(originalBasePath_, mainBranch);
@@ -22,7 +22,6 @@ import { loadFile, getManifestStatus, resolveAllOverrides, parsePlan, parseSumma
22
22
  import { loadPrompt } from "./prompt-loader.js";
23
23
  import { runVerificationGate, formatFailureContext, captureRuntimeErrors, runDependencyAudit } from "./verification-gate.js";
24
24
  import { writeVerificationJSON } from "./verification-evidence.js";
25
- export { inlinePriorMilestoneSummary } from "./files.js";
26
25
  import { collectSecretsFromManifest } from "../get-secrets-from-user.js";
27
26
  import {
28
27
  gsdRoot, resolveMilestoneFile, resolveSliceFile, resolveSlicePath,
@@ -70,12 +69,10 @@ import { closeoutUnit } from "./auto-unit-closeout.js";
70
69
  import { recoverTimedOutUnit } from "./auto-timeout-recovery.js";
71
70
  import { selectAndApplyModel } from "./auto-model-selection.js";
72
71
  import {
73
- syncProjectRootToWorktree,
74
- syncStateToProjectRoot,
75
72
  readResourceVersion,
76
73
  checkResourcesStale,
77
74
  escapeStaleWorktree,
78
- } from "./auto-worktree-sync.js";
75
+ } from "./resource-version.js";
79
76
  import { initRoutingHistory, resetRoutingHistory, recordOutcome } from "./routing-history.js";
80
77
  import {
81
78
  checkPostUnitHooks,
@@ -181,7 +178,7 @@ import { runPostUnitVerification, type VerificationContext } from "./auto-verifi
181
178
  import { postUnitPreVerification, postUnitPostVerification, type PostUnitContext } from "./auto-post-unit.js";
182
179
  import { bootstrapAutoSession, type BootstrapDeps } from "./auto-start.js";
183
180
 
184
- // Worktree sync, resource staleness, stale worktree escape → auto-worktree-sync.ts
181
+ // Resource staleness, stale worktree escape → resource-version.ts
185
182
 
186
183
  // ─── Session State ─────────────────────────────────────────────────────────
187
184
 
@@ -192,12 +189,6 @@ import {
192
189
  NEW_SESSION_TIMEOUT_MS, DISPATCH_HANG_TIMEOUT_MS,
193
190
  } from "./auto/session.js";
194
191
  import type { CompletedUnit, CurrentUnit, UnitRouting, StartModel, PendingVerificationRetry } from "./auto/session.js";
195
- export {
196
- MAX_UNIT_DISPATCHES, STUB_RECOVERY_THRESHOLD, MAX_LIFETIME_DISPATCHES,
197
- MAX_CONSECUTIVE_SKIPS, DISPATCH_GAP_TIMEOUT_MS, MAX_SKIP_DEPTH,
198
- NEW_SESSION_TIMEOUT_MS, DISPATCH_HANG_TIMEOUT_MS,
199
- } from "./auto/session.js";
200
- export type { CompletedUnit, CurrentUnit, UnitRouting, StartModel } from "./auto/session.js";
201
192
 
202
193
  // ── ENCAPSULATION INVARIANT ─────────────────────────────────────────────────
203
194
  // ALL mutable auto-mode state lives in the AutoSession class (auto/session.ts).
@@ -268,8 +259,6 @@ export function shouldUseWorktreeIsolation(): boolean {
268
259
  * Maps toolCallId → start timestamp (ms) so the idle watchdog can detect tools that have been
269
260
  * running suspiciously long (e.g., a Bash command hung because `&` kept stdout open).
270
261
  */
271
- // Re-export budget utilities for external consumers
272
- export { getBudgetAlertLevel, getNewBudgetAlertLevel, getBudgetEnforcementAction } from "./auto-budget.js";
273
262
 
274
263
  /** Wrapper: register SIGTERM handler and store reference. */
275
264
  function registerSigtermHandler(currentBasePath: string): void {
@@ -282,8 +271,6 @@ function deregisterSigtermHandler(): void {
282
271
  s.sigtermHandler = null;
283
272
  }
284
273
 
285
- export { type AutoDashboardData } from "./auto-dashboard.js";
286
-
287
274
  export function getAutoDashboardData(): AutoDashboardData {
288
275
  const ledger = getLedger();
289
276
  const totals = ledger ? getProjectTotals(ledger.units) : null;
@@ -934,8 +921,6 @@ async function showStepWizard(
934
921
  }
935
922
  }
936
923
 
937
- // describeNextUnit is imported from auto-dashboard.ts and re-exported
938
- export { describeNextUnit } from "./auto-dashboard.js";
939
924
 
940
925
  /** Thin wrapper: delegates to auto-dashboard.ts, passing state accessors. */
941
926
  function updateProgressWidget(
@@ -1031,11 +1016,6 @@ async function dispatchNextUnit(
1031
1016
  // Non-fatal
1032
1017
  }
1033
1018
 
1034
- // ── Sync project root artifacts into worktree ──
1035
- if (s.originalBasePath && s.basePath !== s.originalBasePath && s.currentMilestoneId) {
1036
- syncProjectRootToWorktree(s.originalBasePath, s.basePath, s.currentMilestoneId);
1037
- }
1038
-
1039
1019
  const stopDeriveTimer = debugTime("derive-state");
1040
1020
  let state = await deriveState(s.basePath);
1041
1021
  stopDeriveTimer({
@@ -1905,5 +1885,3 @@ export async function dispatchHookUnit(
1905
1885
  }
1906
1886
 
1907
1887
 
1908
- // Direct phase dispatch → auto-direct-dispatch.ts
1909
- export { dispatchDirectPhase } from "./auto-direct-dispatch.js";
@@ -9,9 +9,10 @@
9
9
  */
10
10
 
11
11
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
12
- import { join, resolve, sep } from "node:path";
12
+ import { join, resolve } from "node:path";
13
13
  import { randomUUID } from "node:crypto";
14
14
  import { gsdRoot } from "./paths.js";
15
+ import { resolveProjectRoot } from "./worktree.js";
15
16
 
16
17
  // ─── Types ────────────────────────────────────────────────────────────────────
17
18
 
@@ -58,15 +59,8 @@ const VALID_CLASSIFICATIONS: readonly string[] = [
58
59
  * directory that contains `.gsd/worktrees/` — that's the project root.
59
60
  */
60
61
  export function resolveCapturesPath(basePath: string): string {
61
- const resolved = resolve(basePath);
62
- const worktreeMarker = `${sep}.gsd${sep}worktrees${sep}`;
63
- const idx = resolved.indexOf(worktreeMarker);
64
- if (idx !== -1) {
65
- // basePath is inside a worktree — resolve to project root
66
- const projectRoot = resolved.slice(0, idx);
67
- return join(projectRoot, ".gsd", CAPTURES_FILENAME);
68
- }
69
- return join(gsdRoot(basePath), CAPTURES_FILENAME);
62
+ const projectRoot = resolveProjectRoot(resolve(basePath));
63
+ return join(gsdRoot(projectRoot), CAPTURES_FILENAME);
70
64
  }
71
65
 
72
66
  // ─── File I/O ─────────────────────────────────────────────────────────────────