gmc-openspec 1.0.0

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 (333) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +207 -0
  3. package/bin/openspec.js +3 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.js +494 -0
  6. package/dist/commands/change.d.ts +35 -0
  7. package/dist/commands/change.js +277 -0
  8. package/dist/commands/completion.d.ts +72 -0
  9. package/dist/commands/completion.js +264 -0
  10. package/dist/commands/config.d.ts +36 -0
  11. package/dist/commands/config.js +611 -0
  12. package/dist/commands/feedback.d.ts +9 -0
  13. package/dist/commands/feedback.js +183 -0
  14. package/dist/commands/jira.d.ts +3 -0
  15. package/dist/commands/jira.js +249 -0
  16. package/dist/commands/schema.d.ts +6 -0
  17. package/dist/commands/schema.js +869 -0
  18. package/dist/commands/show.d.ts +14 -0
  19. package/dist/commands/show.js +132 -0
  20. package/dist/commands/spec.d.ts +15 -0
  21. package/dist/commands/spec.js +225 -0
  22. package/dist/commands/validate.d.ts +24 -0
  23. package/dist/commands/validate.js +294 -0
  24. package/dist/commands/workflow/index.d.ts +17 -0
  25. package/dist/commands/workflow/index.js +12 -0
  26. package/dist/commands/workflow/instructions.d.ts +29 -0
  27. package/dist/commands/workflow/instructions.js +336 -0
  28. package/dist/commands/workflow/new-change.d.ts +13 -0
  29. package/dist/commands/workflow/new-change.js +92 -0
  30. package/dist/commands/workflow/schemas.d.ts +10 -0
  31. package/dist/commands/workflow/schemas.js +34 -0
  32. package/dist/commands/workflow/shared.d.ts +57 -0
  33. package/dist/commands/workflow/shared.js +116 -0
  34. package/dist/commands/workflow/status.d.ts +14 -0
  35. package/dist/commands/workflow/status.js +87 -0
  36. package/dist/commands/workflow/templates.d.ts +16 -0
  37. package/dist/commands/workflow/templates.js +69 -0
  38. package/dist/commands/workspace/open.d.ts +29 -0
  39. package/dist/commands/workspace/open.js +84 -0
  40. package/dist/commands/workspace/operations.d.ts +23 -0
  41. package/dist/commands/workspace/operations.js +475 -0
  42. package/dist/commands/workspace/selection.d.ts +6 -0
  43. package/dist/commands/workspace/selection.js +113 -0
  44. package/dist/commands/workspace/types.d.ts +88 -0
  45. package/dist/commands/workspace/types.js +36 -0
  46. package/dist/commands/workspace.d.ts +6 -0
  47. package/dist/commands/workspace.js +868 -0
  48. package/dist/core/archive.d.ts +11 -0
  49. package/dist/core/archive.js +318 -0
  50. package/dist/core/artifact-graph/graph.d.ts +56 -0
  51. package/dist/core/artifact-graph/graph.js +141 -0
  52. package/dist/core/artifact-graph/index.d.ts +8 -0
  53. package/dist/core/artifact-graph/index.js +14 -0
  54. package/dist/core/artifact-graph/instruction-loader.d.ts +196 -0
  55. package/dist/core/artifact-graph/instruction-loader.js +317 -0
  56. package/dist/core/artifact-graph/outputs.d.ts +14 -0
  57. package/dist/core/artifact-graph/outputs.js +39 -0
  58. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  59. package/dist/core/artifact-graph/resolver.js +257 -0
  60. package/dist/core/artifact-graph/schema.d.ts +13 -0
  61. package/dist/core/artifact-graph/schema.js +108 -0
  62. package/dist/core/artifact-graph/state.d.ts +12 -0
  63. package/dist/core/artifact-graph/state.js +31 -0
  64. package/dist/core/artifact-graph/types.d.ts +47 -0
  65. package/dist/core/artifact-graph/types.js +48 -0
  66. package/dist/core/available-tools.d.ts +17 -0
  67. package/dist/core/available-tools.js +43 -0
  68. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  69. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  70. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  71. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  72. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  73. package/dist/core/command-generation/adapters/auggie.js +27 -0
  74. package/dist/core/command-generation/adapters/bob.d.ts +14 -0
  75. package/dist/core/command-generation/adapters/bob.js +45 -0
  76. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  77. package/dist/core/command-generation/adapters/claude.js +50 -0
  78. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  79. package/dist/core/command-generation/adapters/cline.js +27 -0
  80. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  81. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  82. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  83. package/dist/core/command-generation/adapters/codex.js +39 -0
  84. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  85. package/dist/core/command-generation/adapters/continue.js +28 -0
  86. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  87. package/dist/core/command-generation/adapters/costrict.js +27 -0
  88. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  89. package/dist/core/command-generation/adapters/crush.js +30 -0
  90. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  91. package/dist/core/command-generation/adapters/cursor.js +44 -0
  92. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  93. package/dist/core/command-generation/adapters/factory.js +27 -0
  94. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  95. package/dist/core/command-generation/adapters/gemini.js +26 -0
  96. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  97. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  98. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  99. package/dist/core/command-generation/adapters/iflow.js +29 -0
  100. package/dist/core/command-generation/adapters/index.d.ts +32 -0
  101. package/dist/core/command-generation/adapters/index.js +32 -0
  102. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  103. package/dist/core/command-generation/adapters/junie.js +26 -0
  104. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  105. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  106. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  107. package/dist/core/command-generation/adapters/kiro.js +26 -0
  108. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  109. package/dist/core/command-generation/adapters/lingma.js +30 -0
  110. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  111. package/dist/core/command-generation/adapters/opencode.js +29 -0
  112. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  113. package/dist/core/command-generation/adapters/pi.js +55 -0
  114. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  115. package/dist/core/command-generation/adapters/qoder.js +30 -0
  116. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  117. package/dist/core/command-generation/adapters/qwen.js +26 -0
  118. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  119. package/dist/core/command-generation/adapters/roocode.js +27 -0
  120. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  121. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  122. package/dist/core/command-generation/generator.d.ts +21 -0
  123. package/dist/core/command-generation/generator.js +27 -0
  124. package/dist/core/command-generation/index.d.ts +22 -0
  125. package/dist/core/command-generation/index.js +24 -0
  126. package/dist/core/command-generation/registry.d.ts +36 -0
  127. package/dist/core/command-generation/registry.js +98 -0
  128. package/dist/core/command-generation/types.d.ts +56 -0
  129. package/dist/core/command-generation/types.js +8 -0
  130. package/dist/core/completions/command-registry.d.ts +7 -0
  131. package/dist/core/completions/command-registry.js +626 -0
  132. package/dist/core/completions/completion-provider.d.ts +71 -0
  133. package/dist/core/completions/completion-provider.js +129 -0
  134. package/dist/core/completions/factory.d.ts +64 -0
  135. package/dist/core/completions/factory.js +75 -0
  136. package/dist/core/completions/generators/bash-generator.d.ts +35 -0
  137. package/dist/core/completions/generators/bash-generator.js +230 -0
  138. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  139. package/dist/core/completions/generators/fish-generator.js +160 -0
  140. package/dist/core/completions/generators/powershell-generator.d.ts +36 -0
  141. package/dist/core/completions/generators/powershell-generator.js +266 -0
  142. package/dist/core/completions/generators/zsh-generator.d.ts +47 -0
  143. package/dist/core/completions/generators/zsh-generator.js +274 -0
  144. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  145. package/dist/core/completions/installers/bash-installer.js +318 -0
  146. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  147. package/dist/core/completions/installers/fish-installer.js +143 -0
  148. package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
  149. package/dist/core/completions/installers/powershell-installer.js +387 -0
  150. package/dist/core/completions/installers/zsh-installer.d.ts +117 -0
  151. package/dist/core/completions/installers/zsh-installer.js +421 -0
  152. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  153. package/dist/core/completions/templates/bash-templates.js +30 -0
  154. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  155. package/dist/core/completions/templates/fish-templates.js +45 -0
  156. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  157. package/dist/core/completions/templates/powershell-templates.js +34 -0
  158. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  159. package/dist/core/completions/templates/zsh-templates.js +45 -0
  160. package/dist/core/completions/types.d.ts +101 -0
  161. package/dist/core/completions/types.js +2 -0
  162. package/dist/core/config-prompts.d.ts +9 -0
  163. package/dist/core/config-prompts.js +34 -0
  164. package/dist/core/config-schema.d.ts +86 -0
  165. package/dist/core/config-schema.js +213 -0
  166. package/dist/core/config.d.ts +18 -0
  167. package/dist/core/config.js +38 -0
  168. package/dist/core/converters/json-converter.d.ts +6 -0
  169. package/dist/core/converters/json-converter.js +51 -0
  170. package/dist/core/global-config.d.ts +49 -0
  171. package/dist/core/global-config.js +124 -0
  172. package/dist/core/index.d.ts +5 -0
  173. package/dist/core/index.js +6 -0
  174. package/dist/core/init.d.ts +37 -0
  175. package/dist/core/init.js +593 -0
  176. package/dist/core/jira/config.d.ts +35 -0
  177. package/dist/core/jira/config.js +151 -0
  178. package/dist/core/jira/constants.d.ts +20 -0
  179. package/dist/core/jira/constants.js +49 -0
  180. package/dist/core/jira/doctor.d.ts +19 -0
  181. package/dist/core/jira/doctor.js +173 -0
  182. package/dist/core/jira/hash.d.ts +3 -0
  183. package/dist/core/jira/hash.js +9 -0
  184. package/dist/core/jira/index.d.ts +11 -0
  185. package/dist/core/jira/index.js +11 -0
  186. package/dist/core/jira/intake.d.ts +40 -0
  187. package/dist/core/jira/intake.js +54 -0
  188. package/dist/core/jira/mcp-config.d.ts +13 -0
  189. package/dist/core/jira/mcp-config.js +259 -0
  190. package/dist/core/jira/paths.d.ts +12 -0
  191. package/dist/core/jira/paths.js +66 -0
  192. package/dist/core/jira/setup.d.ts +30 -0
  193. package/dist/core/jira/setup.js +99 -0
  194. package/dist/core/jira/templates.d.ts +12 -0
  195. package/dist/core/jira/templates.js +204 -0
  196. package/dist/core/jira/validation.d.ts +17 -0
  197. package/dist/core/jira/validation.js +341 -0
  198. package/dist/core/legacy-cleanup.d.ts +162 -0
  199. package/dist/core/legacy-cleanup.js +514 -0
  200. package/dist/core/list.d.ts +9 -0
  201. package/dist/core/list.js +171 -0
  202. package/dist/core/migration.d.ts +23 -0
  203. package/dist/core/migration.js +108 -0
  204. package/dist/core/parsers/change-parser.d.ts +13 -0
  205. package/dist/core/parsers/change-parser.js +197 -0
  206. package/dist/core/parsers/markdown-parser.d.ts +26 -0
  207. package/dist/core/parsers/markdown-parser.js +227 -0
  208. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  209. package/dist/core/parsers/requirement-blocks.js +201 -0
  210. package/dist/core/parsers/spec-structure.d.ts +9 -0
  211. package/dist/core/parsers/spec-structure.js +88 -0
  212. package/dist/core/planning-home.d.ts +21 -0
  213. package/dist/core/planning-home.js +124 -0
  214. package/dist/core/profile-sync-drift.d.ts +38 -0
  215. package/dist/core/profile-sync-drift.js +200 -0
  216. package/dist/core/profiles.d.ts +26 -0
  217. package/dist/core/profiles.js +40 -0
  218. package/dist/core/project-config.d.ts +64 -0
  219. package/dist/core/project-config.js +223 -0
  220. package/dist/core/schemas/base.schema.d.ts +13 -0
  221. package/dist/core/schemas/base.schema.js +13 -0
  222. package/dist/core/schemas/change.schema.d.ts +73 -0
  223. package/dist/core/schemas/change.schema.js +31 -0
  224. package/dist/core/schemas/index.d.ts +4 -0
  225. package/dist/core/schemas/index.js +4 -0
  226. package/dist/core/schemas/spec.schema.d.ts +18 -0
  227. package/dist/core/schemas/spec.schema.js +15 -0
  228. package/dist/core/shared/index.d.ts +8 -0
  229. package/dist/core/shared/index.js +8 -0
  230. package/dist/core/shared/skill-generation.d.ts +49 -0
  231. package/dist/core/shared/skill-generation.js +96 -0
  232. package/dist/core/shared/tool-detection.d.ts +71 -0
  233. package/dist/core/shared/tool-detection.js +158 -0
  234. package/dist/core/specs-apply.d.ts +73 -0
  235. package/dist/core/specs-apply.js +392 -0
  236. package/dist/core/styles/palette.d.ts +7 -0
  237. package/dist/core/styles/palette.js +8 -0
  238. package/dist/core/templates/index.d.ts +8 -0
  239. package/dist/core/templates/index.js +9 -0
  240. package/dist/core/templates/skill-templates.d.ts +19 -0
  241. package/dist/core/templates/skill-templates.js +18 -0
  242. package/dist/core/templates/types.d.ts +19 -0
  243. package/dist/core/templates/types.js +5 -0
  244. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  245. package/dist/core/templates/workflows/apply-change.js +314 -0
  246. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  247. package/dist/core/templates/workflows/archive-change.js +277 -0
  248. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  249. package/dist/core/templates/workflows/bulk-archive-change.js +492 -0
  250. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  251. package/dist/core/templates/workflows/continue-change.js +234 -0
  252. package/dist/core/templates/workflows/explore.d.ts +10 -0
  253. package/dist/core/templates/workflows/explore.js +459 -0
  254. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  255. package/dist/core/templates/workflows/feedback.js +108 -0
  256. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  257. package/dist/core/templates/workflows/ff-change.js +200 -0
  258. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  259. package/dist/core/templates/workflows/new-change.js +143 -0
  260. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  261. package/dist/core/templates/workflows/onboard.js +563 -0
  262. package/dist/core/templates/workflows/propose.d.ts +10 -0
  263. package/dist/core/templates/workflows/propose.js +218 -0
  264. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  265. package/dist/core/templates/workflows/sync-specs.js +290 -0
  266. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  267. package/dist/core/templates/workflows/verify-change.js +338 -0
  268. package/dist/core/update.d.ts +83 -0
  269. package/dist/core/update.js +573 -0
  270. package/dist/core/validation/constants.d.ts +34 -0
  271. package/dist/core/validation/constants.js +40 -0
  272. package/dist/core/validation/types.d.ts +18 -0
  273. package/dist/core/validation/types.js +2 -0
  274. package/dist/core/validation/validator.d.ts +33 -0
  275. package/dist/core/validation/validator.js +418 -0
  276. package/dist/core/view.d.ts +8 -0
  277. package/dist/core/view.js +168 -0
  278. package/dist/core/workspace/foundation.d.ts +87 -0
  279. package/dist/core/workspace/foundation.js +379 -0
  280. package/dist/core/workspace/index.d.ts +6 -0
  281. package/dist/core/workspace/index.js +6 -0
  282. package/dist/core/workspace/link-input.d.ts +9 -0
  283. package/dist/core/workspace/link-input.js +32 -0
  284. package/dist/core/workspace/open-surface.d.ts +24 -0
  285. package/dist/core/workspace/open-surface.js +137 -0
  286. package/dist/core/workspace/openers.d.ts +21 -0
  287. package/dist/core/workspace/openers.js +119 -0
  288. package/dist/core/workspace/skills.d.ts +55 -0
  289. package/dist/core/workspace/skills.js +334 -0
  290. package/dist/index.d.ts +3 -0
  291. package/dist/index.js +3 -0
  292. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  293. package/dist/prompts/searchable-multi-select.js +159 -0
  294. package/dist/telemetry/config.d.ts +38 -0
  295. package/dist/telemetry/config.js +136 -0
  296. package/dist/telemetry/index.d.ts +31 -0
  297. package/dist/telemetry/index.js +164 -0
  298. package/dist/ui/ascii-patterns.d.ts +16 -0
  299. package/dist/ui/ascii-patterns.js +133 -0
  300. package/dist/ui/welcome-screen.d.ts +10 -0
  301. package/dist/ui/welcome-screen.js +146 -0
  302. package/dist/utils/change-metadata.d.ts +51 -0
  303. package/dist/utils/change-metadata.js +147 -0
  304. package/dist/utils/change-utils.d.ts +71 -0
  305. package/dist/utils/change-utils.js +123 -0
  306. package/dist/utils/command-references.d.ts +18 -0
  307. package/dist/utils/command-references.js +20 -0
  308. package/dist/utils/file-system.d.ts +41 -0
  309. package/dist/utils/file-system.js +301 -0
  310. package/dist/utils/index.d.ts +6 -0
  311. package/dist/utils/index.js +9 -0
  312. package/dist/utils/interactive.d.ts +18 -0
  313. package/dist/utils/interactive.js +21 -0
  314. package/dist/utils/item-discovery.d.ts +4 -0
  315. package/dist/utils/item-discovery.js +72 -0
  316. package/dist/utils/match.d.ts +3 -0
  317. package/dist/utils/match.js +22 -0
  318. package/dist/utils/shell-detection.d.ts +20 -0
  319. package/dist/utils/shell-detection.js +41 -0
  320. package/dist/utils/task-progress.d.ts +8 -0
  321. package/dist/utils/task-progress.js +36 -0
  322. package/package.json +79 -0
  323. package/schemas/spec-driven/schema.yaml +153 -0
  324. package/schemas/spec-driven/templates/design.md +19 -0
  325. package/schemas/spec-driven/templates/proposal.md +23 -0
  326. package/schemas/spec-driven/templates/spec.md +8 -0
  327. package/schemas/spec-driven/templates/tasks.md +9 -0
  328. package/schemas/workspace-planning/schema.yaml +72 -0
  329. package/schemas/workspace-planning/templates/design.md +33 -0
  330. package/schemas/workspace-planning/templates/proposal.md +28 -0
  331. package/schemas/workspace-planning/templates/spec.md +9 -0
  332. package/schemas/workspace-planning/templates/tasks.md +15 -0
  333. package/scripts/postinstall.js +83 -0
@@ -0,0 +1,514 @@
1
+ /**
2
+ * Legacy cleanup module for detecting and removing OpenSpec artifacts
3
+ * from previous init versions during the migration to the skill-based workflow.
4
+ */
5
+ import { promises as fs } from 'fs';
6
+ import chalk from 'chalk';
7
+ import { FileSystemUtils, removeMarkerBlock as removeMarkerBlockUtil } from '../utils/file-system.js';
8
+ import { OPENSPEC_MARKERS } from './config.js';
9
+ /**
10
+ * Legacy config file names from the old ToolRegistry.
11
+ * These were config files created at project root with OpenSpec markers.
12
+ */
13
+ export const LEGACY_CONFIG_FILES = [
14
+ 'CLAUDE.md',
15
+ 'CLINE.md',
16
+ 'CODEBUDDY.md',
17
+ 'COSTRICT.md',
18
+ 'QODER.md',
19
+ 'IFLOW.md',
20
+ 'AGENTS.md', // root AGENTS.md (not openspec/AGENTS.md)
21
+ 'QWEN.md',
22
+ ];
23
+ /**
24
+ * Legacy slash command patterns from the old SlashCommandRegistry.
25
+ * These map toolId to the path pattern where legacy commands were created.
26
+ * Some tools used a directory structure, others used individual files.
27
+ */
28
+ export const LEGACY_SLASH_COMMAND_PATHS = {
29
+ // Directory-based: .tooldir/commands/openspec/ or .tooldir/commands/openspec/*.md
30
+ 'claude': { type: 'directory', path: '.claude/commands/openspec' },
31
+ 'codebuddy': { type: 'directory', path: '.codebuddy/commands/openspec' },
32
+ 'qoder': { type: 'directory', path: '.qoder/commands/openspec' },
33
+ 'lingma': { type: 'directory', path: '.lingma/commands/openspec' },
34
+ 'crush': { type: 'directory', path: '.crush/commands/openspec' },
35
+ 'gemini': { type: 'directory', path: '.gemini/commands/openspec' },
36
+ 'costrict': { type: 'directory', path: '.cospec/openspec/commands' },
37
+ // File-based: individual openspec-*.md files in a commands/workflows/prompts folder
38
+ 'cursor': { type: 'files', pattern: '.cursor/commands/openspec-*.md' },
39
+ 'windsurf': { type: 'files', pattern: '.windsurf/workflows/openspec-*.md' },
40
+ 'kilocode': { type: 'files', pattern: '.kilocode/workflows/openspec-*.md' },
41
+ 'kiro': { type: 'files', pattern: '.kiro/prompts/openspec-*.prompt.md' },
42
+ 'github-copilot': { type: 'files', pattern: '.github/prompts/openspec-*.prompt.md' },
43
+ 'amazon-q': { type: 'files', pattern: '.amazonq/prompts/openspec-*.md' },
44
+ 'cline': { type: 'files', pattern: '.clinerules/workflows/openspec-*.md' },
45
+ 'roocode': { type: 'files', pattern: '.roo/commands/openspec-*.md' },
46
+ 'auggie': { type: 'files', pattern: '.augment/commands/openspec-*.md' },
47
+ 'factory': { type: 'files', pattern: '.factory/commands/openspec-*.md' },
48
+ 'opencode': { type: 'files', pattern: ['.opencode/command/opsx-*.md', '.opencode/command/openspec-*.md'] },
49
+ 'continue': { type: 'files', pattern: '.continue/prompts/openspec-*.prompt' },
50
+ 'antigravity': { type: 'files', pattern: '.agent/workflows/openspec-*.md' },
51
+ 'iflow': { type: 'files', pattern: '.iflow/commands/openspec-*.md' },
52
+ 'junie': { type: 'files', pattern: ['.junie/commands/opsx-*.md', '.junie/commands/openspec-*.md'] },
53
+ 'qwen': { type: 'files', pattern: '.qwen/commands/openspec-*.toml' },
54
+ 'codex': { type: 'files', pattern: '.codex/prompts/openspec-*.md' },
55
+ };
56
+ /**
57
+ * Detects all legacy OpenSpec artifacts in a project.
58
+ *
59
+ * @param projectPath - The root path of the project
60
+ * @returns Detection result with all found legacy artifacts
61
+ */
62
+ export async function detectLegacyArtifacts(projectPath) {
63
+ const result = {
64
+ configFiles: [],
65
+ configFilesToUpdate: [],
66
+ slashCommandDirs: [],
67
+ slashCommandFiles: [],
68
+ hasOpenspecAgents: false,
69
+ hasProjectMd: false,
70
+ hasRootAgentsWithMarkers: false,
71
+ hasLegacyArtifacts: false,
72
+ };
73
+ // Detect legacy config files
74
+ const configResult = await detectLegacyConfigFiles(projectPath);
75
+ result.configFiles = configResult.allFiles;
76
+ result.configFilesToUpdate = configResult.filesToUpdate;
77
+ // Detect legacy slash commands
78
+ const slashResult = await detectLegacySlashCommands(projectPath);
79
+ result.slashCommandDirs = slashResult.directories;
80
+ result.slashCommandFiles = slashResult.files;
81
+ // Detect legacy structure files
82
+ const structureResult = await detectLegacyStructureFiles(projectPath);
83
+ result.hasOpenspecAgents = structureResult.hasOpenspecAgents;
84
+ result.hasProjectMd = structureResult.hasProjectMd;
85
+ result.hasRootAgentsWithMarkers = structureResult.hasRootAgentsWithMarkers;
86
+ // Determine if any legacy artifacts exist
87
+ result.hasLegacyArtifacts =
88
+ result.configFiles.length > 0 ||
89
+ result.slashCommandDirs.length > 0 ||
90
+ result.slashCommandFiles.length > 0 ||
91
+ result.hasOpenspecAgents ||
92
+ result.hasRootAgentsWithMarkers ||
93
+ result.hasProjectMd;
94
+ return result;
95
+ }
96
+ /**
97
+ * Detects legacy config files with OpenSpec markers.
98
+ * All config files with markers are candidates for update (marker removal only).
99
+ * Config files are NEVER deleted - they belong to the user's project root.
100
+ *
101
+ * @param projectPath - The root path of the project
102
+ * @returns Object with all files found and files to update
103
+ */
104
+ export async function detectLegacyConfigFiles(projectPath) {
105
+ const allFiles = [];
106
+ const filesToUpdate = [];
107
+ for (const fileName of LEGACY_CONFIG_FILES) {
108
+ const filePath = FileSystemUtils.joinPath(projectPath, fileName);
109
+ if (await FileSystemUtils.fileExists(filePath)) {
110
+ const content = await FileSystemUtils.readFile(filePath);
111
+ if (hasOpenSpecMarkers(content)) {
112
+ allFiles.push(fileName);
113
+ filesToUpdate.push(fileName); // Always update, never delete config files
114
+ }
115
+ }
116
+ }
117
+ return { allFiles, filesToUpdate };
118
+ }
119
+ /**
120
+ * Detects legacy slash command directories and files.
121
+ *
122
+ * @param projectPath - The root path of the project
123
+ * @returns Object with directories and individual files found
124
+ */
125
+ export async function detectLegacySlashCommands(projectPath) {
126
+ const directories = [];
127
+ const files = [];
128
+ for (const [toolId, pattern] of Object.entries(LEGACY_SLASH_COMMAND_PATHS)) {
129
+ if (pattern.type === 'directory' && pattern.path) {
130
+ const dirPath = FileSystemUtils.joinPath(projectPath, pattern.path);
131
+ if (await FileSystemUtils.directoryExists(dirPath)) {
132
+ directories.push(pattern.path);
133
+ }
134
+ }
135
+ else if (pattern.type === 'files' && pattern.pattern) {
136
+ // For file-based patterns, check for individual files
137
+ const patterns = Array.isArray(pattern.pattern) ? pattern.pattern : [pattern.pattern];
138
+ for (const p of patterns) {
139
+ const foundFiles = await findLegacySlashCommandFiles(projectPath, p);
140
+ files.push(...foundFiles);
141
+ }
142
+ }
143
+ }
144
+ return { directories, files };
145
+ }
146
+ /**
147
+ * Finds legacy slash command files matching a glob pattern.
148
+ *
149
+ * @param projectPath - The root path of the project
150
+ * @param pattern - Glob pattern like '.cursor/commands/openspec-*.md'
151
+ * @returns Array of matching file paths relative to projectPath
152
+ */
153
+ async function findLegacySlashCommandFiles(projectPath, pattern) {
154
+ const foundFiles = [];
155
+ // Extract directory and file pattern from glob
156
+ // Handle both forward and backward slashes for Windows compatibility
157
+ const lastForwardSlash = pattern.lastIndexOf('/');
158
+ const lastBackSlash = pattern.lastIndexOf('\\');
159
+ const lastSeparator = Math.max(lastForwardSlash, lastBackSlash);
160
+ const dirPart = pattern.substring(0, lastSeparator);
161
+ const filePart = pattern.substring(lastSeparator + 1);
162
+ const dirPath = FileSystemUtils.joinPath(projectPath, dirPart);
163
+ if (!(await FileSystemUtils.directoryExists(dirPath))) {
164
+ return foundFiles;
165
+ }
166
+ try {
167
+ const entries = await fs.readdir(dirPath);
168
+ // Convert glob pattern to regex
169
+ // openspec-*.md -> /^openspec-.*\.md$/
170
+ // openspec-*.prompt.md -> /^openspec-.*\.prompt\.md$/
171
+ // openspec-*.toml -> /^openspec-.*\.toml$/
172
+ const regexPattern = filePart
173
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape regex special chars except *
174
+ .replace(/\*/g, '.*'); // Replace * with .*
175
+ const regex = new RegExp(`^${regexPattern}$`);
176
+ for (const entry of entries) {
177
+ if (regex.test(entry)) {
178
+ // Use forward slashes for consistency in relative paths (cross-platform)
179
+ const normalizedDir = dirPart.replace(/\\/g, '/');
180
+ foundFiles.push(`${normalizedDir}/${entry}`);
181
+ }
182
+ }
183
+ }
184
+ catch {
185
+ // Directory doesn't exist or can't be read
186
+ }
187
+ return foundFiles;
188
+ }
189
+ /**
190
+ * Detects legacy OpenSpec structure files (AGENTS.md and project.md).
191
+ *
192
+ * @param projectPath - The root path of the project
193
+ * @returns Object with detection results for structure files
194
+ */
195
+ export async function detectLegacyStructureFiles(projectPath) {
196
+ let hasOpenspecAgents = false;
197
+ let hasProjectMd = false;
198
+ let hasRootAgentsWithMarkers = false;
199
+ // Check for openspec/AGENTS.md
200
+ const openspecAgentsPath = FileSystemUtils.joinPath(projectPath, 'openspec', 'AGENTS.md');
201
+ hasOpenspecAgents = await FileSystemUtils.fileExists(openspecAgentsPath);
202
+ // Check for openspec/project.md (for migration messaging, not deleted)
203
+ const projectMdPath = FileSystemUtils.joinPath(projectPath, 'openspec', 'project.md');
204
+ hasProjectMd = await FileSystemUtils.fileExists(projectMdPath);
205
+ // Check for root AGENTS.md with OpenSpec markers
206
+ const rootAgentsPath = FileSystemUtils.joinPath(projectPath, 'AGENTS.md');
207
+ if (await FileSystemUtils.fileExists(rootAgentsPath)) {
208
+ const content = await FileSystemUtils.readFile(rootAgentsPath);
209
+ hasRootAgentsWithMarkers = hasOpenSpecMarkers(content);
210
+ }
211
+ return { hasOpenspecAgents, hasProjectMd, hasRootAgentsWithMarkers };
212
+ }
213
+ /**
214
+ * Checks if content contains OpenSpec markers.
215
+ *
216
+ * @param content - File content to check
217
+ * @returns True if both start and end markers are present
218
+ */
219
+ export function hasOpenSpecMarkers(content) {
220
+ return (content.includes(OPENSPEC_MARKERS.start) && content.includes(OPENSPEC_MARKERS.end));
221
+ }
222
+ /**
223
+ * Checks if file content is 100% OpenSpec content (only markers and whitespace outside).
224
+ *
225
+ * @param content - File content to check
226
+ * @returns True if content outside markers is only whitespace
227
+ */
228
+ export function isOnlyOpenSpecContent(content) {
229
+ const startIndex = content.indexOf(OPENSPEC_MARKERS.start);
230
+ const endIndex = content.indexOf(OPENSPEC_MARKERS.end);
231
+ if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
232
+ return false;
233
+ }
234
+ const before = content.substring(0, startIndex);
235
+ const after = content.substring(endIndex + OPENSPEC_MARKERS.end.length);
236
+ return before.trim() === '' && after.trim() === '';
237
+ }
238
+ /**
239
+ * Removes the OpenSpec marker block from file content.
240
+ * Only removes markers that are on their own lines (ignores inline mentions).
241
+ * Cleans up double blank lines that may result from removal.
242
+ *
243
+ * @param content - File content with OpenSpec markers
244
+ * @returns Content with marker block removed
245
+ */
246
+ export function removeMarkerBlock(content) {
247
+ return removeMarkerBlockUtil(content, OPENSPEC_MARKERS.start, OPENSPEC_MARKERS.end);
248
+ }
249
+ /**
250
+ * Cleans up legacy OpenSpec artifacts from a project.
251
+ * Preserves openspec/project.md (shows migration hint instead of deleting).
252
+ *
253
+ * @param projectPath - The root path of the project
254
+ * @param detection - Detection result from detectLegacyArtifacts
255
+ * @returns Cleanup result with summary of actions taken
256
+ */
257
+ export async function cleanupLegacyArtifacts(projectPath, detection) {
258
+ const result = {
259
+ deletedFiles: [],
260
+ modifiedFiles: [],
261
+ deletedDirs: [],
262
+ projectMdNeedsMigration: detection.hasProjectMd,
263
+ errors: [],
264
+ };
265
+ // Remove marker blocks from config files (NEVER delete config files)
266
+ // Config files like CLAUDE.md, AGENTS.md belong to the user's project root
267
+ for (const fileName of detection.configFilesToUpdate) {
268
+ const filePath = FileSystemUtils.joinPath(projectPath, fileName);
269
+ try {
270
+ const content = await FileSystemUtils.readFile(filePath);
271
+ const newContent = removeMarkerBlock(content);
272
+ // Always write the file, even if empty - never delete user config files
273
+ await FileSystemUtils.writeFile(filePath, newContent);
274
+ result.modifiedFiles.push(fileName);
275
+ }
276
+ catch (error) {
277
+ result.errors.push(`Failed to modify ${fileName}: ${error.message}`);
278
+ }
279
+ }
280
+ // Delete legacy slash command directories (these are 100% OpenSpec-managed)
281
+ for (const dirPath of detection.slashCommandDirs) {
282
+ const fullPath = FileSystemUtils.joinPath(projectPath, dirPath);
283
+ try {
284
+ await fs.rm(fullPath, { recursive: true, force: true });
285
+ result.deletedDirs.push(dirPath);
286
+ }
287
+ catch (error) {
288
+ result.errors.push(`Failed to delete directory ${dirPath}: ${error.message}`);
289
+ }
290
+ }
291
+ // Delete legacy slash command files (these are 100% OpenSpec-managed)
292
+ for (const filePath of detection.slashCommandFiles) {
293
+ const fullPath = FileSystemUtils.joinPath(projectPath, filePath);
294
+ try {
295
+ await fs.unlink(fullPath);
296
+ result.deletedFiles.push(filePath);
297
+ }
298
+ catch (error) {
299
+ result.errors.push(`Failed to delete ${filePath}: ${error.message}`);
300
+ }
301
+ }
302
+ // Delete openspec/AGENTS.md (this is inside openspec/, it's OpenSpec-managed)
303
+ if (detection.hasOpenspecAgents) {
304
+ const agentsPath = FileSystemUtils.joinPath(projectPath, 'openspec', 'AGENTS.md');
305
+ if (await FileSystemUtils.fileExists(agentsPath)) {
306
+ try {
307
+ await fs.unlink(agentsPath);
308
+ result.deletedFiles.push('openspec/AGENTS.md');
309
+ }
310
+ catch (error) {
311
+ result.errors.push(`Failed to delete openspec/AGENTS.md: ${error.message}`);
312
+ }
313
+ }
314
+ }
315
+ // Handle root AGENTS.md with OpenSpec markers - remove markers only, NEVER delete
316
+ // Note: Root AGENTS.md is handled via configFilesToUpdate above (it's in LEGACY_CONFIG_FILES)
317
+ // This hasRootAgentsWithMarkers flag is just for detection, cleanup happens via configFilesToUpdate
318
+ return result;
319
+ }
320
+ /**
321
+ * Generates a cleanup summary message for display.
322
+ *
323
+ * @param result - Cleanup result from cleanupLegacyArtifacts
324
+ * @returns Formatted summary string for console output
325
+ */
326
+ export function formatCleanupSummary(result) {
327
+ const lines = [];
328
+ if (result.deletedFiles.length > 0 || result.deletedDirs.length > 0 || result.modifiedFiles.length > 0) {
329
+ lines.push('Cleaned up legacy files:');
330
+ for (const file of result.deletedFiles) {
331
+ lines.push(` ✓ Removed ${file}`);
332
+ }
333
+ for (const dir of result.deletedDirs) {
334
+ lines.push(` ✓ Removed ${dir}/ (replaced by /opsx:*)`);
335
+ }
336
+ for (const file of result.modifiedFiles) {
337
+ lines.push(` ✓ Removed OpenSpec markers from ${file}`);
338
+ }
339
+ }
340
+ if (result.projectMdNeedsMigration) {
341
+ if (lines.length > 0) {
342
+ lines.push('');
343
+ }
344
+ lines.push(formatProjectMdMigrationHint());
345
+ }
346
+ if (result.errors.length > 0) {
347
+ if (lines.length > 0) {
348
+ lines.push('');
349
+ }
350
+ lines.push('Errors during cleanup:');
351
+ for (const error of result.errors) {
352
+ lines.push(` ⚠ ${error}`);
353
+ }
354
+ }
355
+ return lines.join('\n');
356
+ }
357
+ /**
358
+ * Build list of files to be removed with explanations.
359
+ * Only includes OpenSpec-managed files (slash commands, openspec/AGENTS.md).
360
+ * Config files like CLAUDE.md, AGENTS.md are NEVER deleted.
361
+ *
362
+ * @param detection - Detection result from detectLegacyArtifacts
363
+ * @returns Array of objects with path and explanation
364
+ */
365
+ function buildRemovalsList(detection) {
366
+ const removals = [];
367
+ // Slash command directories (these are 100% OpenSpec-managed)
368
+ for (const dir of detection.slashCommandDirs) {
369
+ // Split on both forward and backward slashes for Windows compatibility
370
+ const toolDir = dir.split(/[\/\\]/)[0];
371
+ removals.push({ path: dir + '/', explanation: `replaced by ${toolDir}/skills/` });
372
+ }
373
+ // Slash command files (these are 100% OpenSpec-managed)
374
+ for (const file of detection.slashCommandFiles) {
375
+ removals.push({ path: file, explanation: 'replaced by skills/' });
376
+ }
377
+ // openspec/AGENTS.md (inside openspec/, it's OpenSpec-managed)
378
+ if (detection.hasOpenspecAgents) {
379
+ removals.push({ path: 'openspec/AGENTS.md', explanation: 'obsolete workflow file' });
380
+ }
381
+ // Note: Config files (CLAUDE.md, AGENTS.md, etc.) are NEVER in the removals list
382
+ // They always go to the updates list where only markers are removed
383
+ return removals;
384
+ }
385
+ /**
386
+ * Build list of files to be updated with explanations.
387
+ * Includes ALL config files with markers - markers are removed, file is never deleted.
388
+ *
389
+ * @param detection - Detection result from detectLegacyArtifacts
390
+ * @returns Array of objects with path and explanation
391
+ */
392
+ function buildUpdatesList(detection) {
393
+ const updates = [];
394
+ // All config files with markers get updated (markers removed, file preserved)
395
+ for (const file of detection.configFilesToUpdate) {
396
+ updates.push({ path: file, explanation: 'removing OpenSpec markers' });
397
+ }
398
+ return updates;
399
+ }
400
+ /**
401
+ * Generates a detection summary message for display before cleanup.
402
+ * Groups files by action type: removals, updates, and manual migration.
403
+ *
404
+ * @param detection - Detection result from detectLegacyArtifacts
405
+ * @returns Formatted summary string showing what was found
406
+ */
407
+ export function formatDetectionSummary(detection) {
408
+ const lines = [];
409
+ const removals = buildRemovalsList(detection);
410
+ const updates = buildUpdatesList(detection);
411
+ // If nothing to show, return empty
412
+ if (removals.length === 0 && updates.length === 0 && !detection.hasProjectMd) {
413
+ return '';
414
+ }
415
+ // Header - welcoming upgrade message
416
+ lines.push(chalk.bold('Upgrading to the new OpenSpec'));
417
+ lines.push('');
418
+ lines.push('OpenSpec now uses agent skills, the emerging standard across coding');
419
+ lines.push('agents. This simplifies your setup while keeping everything working');
420
+ lines.push('as before.');
421
+ lines.push('');
422
+ // Section 1: Files to remove (no user content to preserve)
423
+ if (removals.length > 0) {
424
+ lines.push(chalk.bold('Files to remove'));
425
+ lines.push(chalk.dim('No user content to preserve:'));
426
+ for (const { path } of removals) {
427
+ lines.push(` • ${path}`);
428
+ }
429
+ }
430
+ // Section 2: Files to update (markers removed, content preserved)
431
+ if (updates.length > 0) {
432
+ if (removals.length > 0)
433
+ lines.push('');
434
+ lines.push(chalk.bold('Files to update'));
435
+ lines.push(chalk.dim('OpenSpec markers will be removed, your content preserved:'));
436
+ for (const { path } of updates) {
437
+ lines.push(` • ${path}`);
438
+ }
439
+ }
440
+ // Section 3: Manual migration (project.md)
441
+ if (detection.hasProjectMd) {
442
+ if (removals.length > 0 || updates.length > 0)
443
+ lines.push('');
444
+ lines.push(formatProjectMdMigrationHint());
445
+ }
446
+ return lines.join('\n');
447
+ }
448
+ /**
449
+ * Extract tool IDs from detected legacy artifacts.
450
+ * Uses LEGACY_SLASH_COMMAND_PATHS to map paths back to tool IDs.
451
+ *
452
+ * @param detection - Detection result from detectLegacyArtifacts
453
+ * @returns Array of tool IDs that had legacy artifacts
454
+ */
455
+ export function getToolsFromLegacyArtifacts(detection) {
456
+ const tools = new Set();
457
+ // Match directories to tool IDs
458
+ for (const dir of detection.slashCommandDirs) {
459
+ for (const [toolId, pattern] of Object.entries(LEGACY_SLASH_COMMAND_PATHS)) {
460
+ if (pattern.type === 'directory' && pattern.path === dir) {
461
+ tools.add(toolId);
462
+ break;
463
+ }
464
+ }
465
+ }
466
+ // Match files to tool IDs using glob patterns
467
+ for (const file of detection.slashCommandFiles) {
468
+ // Normalize file path to use forward slashes for consistent matching (Windows compatibility)
469
+ const normalizedFile = file.replace(/\\/g, '/');
470
+ for (const [toolId, pattern] of Object.entries(LEGACY_SLASH_COMMAND_PATHS)) {
471
+ if (pattern.type === 'files' && pattern.pattern) {
472
+ // Convert glob pattern to regex for matching
473
+ // e.g., '.cursor/commands/openspec-*.md' -> /^\.cursor\/commands\/openspec-.*\.md$/
474
+ const patterns = Array.isArray(pattern.pattern) ? pattern.pattern : [pattern.pattern];
475
+ let matched = false;
476
+ for (const p of patterns) {
477
+ const regexPattern = p
478
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&') // Escape regex special chars except *
479
+ .replace(/\*/g, '.*'); // Replace * with .*
480
+ const regex = new RegExp(`^${regexPattern}$`);
481
+ if (regex.test(normalizedFile)) {
482
+ tools.add(toolId);
483
+ matched = true;
484
+ break;
485
+ }
486
+ }
487
+ if (matched)
488
+ break;
489
+ }
490
+ }
491
+ }
492
+ return Array.from(tools);
493
+ }
494
+ /**
495
+ * Generates a migration hint message for project.md.
496
+ * This is shown when project.md exists and needs manual migration to config.yaml.
497
+ *
498
+ * @returns Formatted migration hint string for console output
499
+ */
500
+ export function formatProjectMdMigrationHint() {
501
+ const lines = [];
502
+ lines.push(chalk.yellow.bold('Needs your attention'));
503
+ lines.push(' • openspec/project.md');
504
+ lines.push(chalk.dim(' We won\'t delete this file. It may contain useful project context.'));
505
+ lines.push('');
506
+ lines.push(chalk.dim(' The new openspec/config.yaml has a "context:" section for planning'));
507
+ lines.push(chalk.dim(' context. This is included in every OpenSpec request and works more'));
508
+ lines.push(chalk.dim(' reliably than the old project.md approach.'));
509
+ lines.push('');
510
+ lines.push(chalk.dim(' Review project.md, move any useful content to config.yaml\'s context'));
511
+ lines.push(chalk.dim(' section, then delete the file when ready.'));
512
+ return lines.join('\n');
513
+ }
514
+ //# sourceMappingURL=legacy-cleanup.js.map
@@ -0,0 +1,9 @@
1
+ interface ListOptions {
2
+ sort?: 'recent' | 'name';
3
+ json?: boolean;
4
+ }
5
+ export declare class ListCommand {
6
+ execute(targetPath?: string, mode?: 'changes' | 'specs', options?: ListOptions): Promise<void>;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=list.d.ts.map