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