anchorspec 1.3.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 (273) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +230 -0
  3. package/bin/anchorspec.js +3 -0
  4. package/bin/openspec.js +3 -0
  5. package/dist/cli/index.d.ts +2 -0
  6. package/dist/cli/index.js +455 -0
  7. package/dist/commands/change.d.ts +35 -0
  8. package/dist/commands/change.js +277 -0
  9. package/dist/commands/completion.d.ts +72 -0
  10. package/dist/commands/completion.js +257 -0
  11. package/dist/commands/config.d.ts +36 -0
  12. package/dist/commands/config.js +552 -0
  13. package/dist/commands/feedback.d.ts +9 -0
  14. package/dist/commands/feedback.js +183 -0
  15. package/dist/commands/schema.d.ts +6 -0
  16. package/dist/commands/schema.js +869 -0
  17. package/dist/commands/show.d.ts +14 -0
  18. package/dist/commands/show.js +132 -0
  19. package/dist/commands/spec.d.ts +15 -0
  20. package/dist/commands/spec.js +225 -0
  21. package/dist/commands/validate.d.ts +24 -0
  22. package/dist/commands/validate.js +294 -0
  23. package/dist/commands/workflow/index.d.ts +17 -0
  24. package/dist/commands/workflow/index.js +12 -0
  25. package/dist/commands/workflow/instructions.d.ts +29 -0
  26. package/dist/commands/workflow/instructions.js +381 -0
  27. package/dist/commands/workflow/new-change.d.ts +11 -0
  28. package/dist/commands/workflow/new-change.js +44 -0
  29. package/dist/commands/workflow/schemas.d.ts +10 -0
  30. package/dist/commands/workflow/schemas.js +34 -0
  31. package/dist/commands/workflow/shared.d.ts +57 -0
  32. package/dist/commands/workflow/shared.js +116 -0
  33. package/dist/commands/workflow/status.d.ts +14 -0
  34. package/dist/commands/workflow/status.js +75 -0
  35. package/dist/commands/workflow/templates.d.ts +16 -0
  36. package/dist/commands/workflow/templates.js +68 -0
  37. package/dist/core/archive.d.ts +11 -0
  38. package/dist/core/archive.js +318 -0
  39. package/dist/core/artifact-graph/graph.d.ts +56 -0
  40. package/dist/core/artifact-graph/graph.js +141 -0
  41. package/dist/core/artifact-graph/index.d.ts +7 -0
  42. package/dist/core/artifact-graph/index.js +13 -0
  43. package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
  44. package/dist/core/artifact-graph/instruction-loader.js +214 -0
  45. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  46. package/dist/core/artifact-graph/resolver.js +257 -0
  47. package/dist/core/artifact-graph/schema.d.ts +13 -0
  48. package/dist/core/artifact-graph/schema.js +108 -0
  49. package/dist/core/artifact-graph/state.d.ts +12 -0
  50. package/dist/core/artifact-graph/state.js +54 -0
  51. package/dist/core/artifact-graph/types.d.ts +45 -0
  52. package/dist/core/artifact-graph/types.js +43 -0
  53. package/dist/core/available-tools.d.ts +17 -0
  54. package/dist/core/available-tools.js +43 -0
  55. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  56. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  57. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  58. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  59. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  60. package/dist/core/command-generation/adapters/auggie.js +27 -0
  61. package/dist/core/command-generation/adapters/bob.d.ts +14 -0
  62. package/dist/core/command-generation/adapters/bob.js +45 -0
  63. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  64. package/dist/core/command-generation/adapters/claude.js +50 -0
  65. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  66. package/dist/core/command-generation/adapters/cline.js +27 -0
  67. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  68. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  69. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  70. package/dist/core/command-generation/adapters/codex.js +39 -0
  71. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  72. package/dist/core/command-generation/adapters/continue.js +28 -0
  73. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  74. package/dist/core/command-generation/adapters/costrict.js +27 -0
  75. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  76. package/dist/core/command-generation/adapters/crush.js +30 -0
  77. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  78. package/dist/core/command-generation/adapters/cursor.js +44 -0
  79. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  80. package/dist/core/command-generation/adapters/factory.js +27 -0
  81. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  82. package/dist/core/command-generation/adapters/gemini.js +26 -0
  83. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  84. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  85. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  86. package/dist/core/command-generation/adapters/iflow.js +29 -0
  87. package/dist/core/command-generation/adapters/index.d.ts +32 -0
  88. package/dist/core/command-generation/adapters/index.js +32 -0
  89. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  90. package/dist/core/command-generation/adapters/junie.js +26 -0
  91. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  92. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  93. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  94. package/dist/core/command-generation/adapters/kiro.js +26 -0
  95. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  96. package/dist/core/command-generation/adapters/lingma.js +30 -0
  97. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  98. package/dist/core/command-generation/adapters/opencode.js +29 -0
  99. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  100. package/dist/core/command-generation/adapters/pi.js +55 -0
  101. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  102. package/dist/core/command-generation/adapters/qoder.js +30 -0
  103. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  104. package/dist/core/command-generation/adapters/qwen.js +26 -0
  105. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  106. package/dist/core/command-generation/adapters/roocode.js +27 -0
  107. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  108. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  109. package/dist/core/command-generation/generator.d.ts +21 -0
  110. package/dist/core/command-generation/generator.js +27 -0
  111. package/dist/core/command-generation/index.d.ts +22 -0
  112. package/dist/core/command-generation/index.js +24 -0
  113. package/dist/core/command-generation/registry.d.ts +36 -0
  114. package/dist/core/command-generation/registry.js +98 -0
  115. package/dist/core/command-generation/types.d.ts +56 -0
  116. package/dist/core/command-generation/types.js +8 -0
  117. package/dist/core/completions/command-registry.d.ts +7 -0
  118. package/dist/core/completions/command-registry.js +461 -0
  119. package/dist/core/completions/completion-provider.d.ts +60 -0
  120. package/dist/core/completions/completion-provider.js +102 -0
  121. package/dist/core/completions/factory.d.ts +64 -0
  122. package/dist/core/completions/factory.js +75 -0
  123. package/dist/core/completions/generators/bash-generator.d.ts +32 -0
  124. package/dist/core/completions/generators/bash-generator.js +174 -0
  125. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  126. package/dist/core/completions/generators/fish-generator.js +157 -0
  127. package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
  128. package/dist/core/completions/generators/powershell-generator.js +207 -0
  129. package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
  130. package/dist/core/completions/generators/zsh-generator.js +250 -0
  131. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  132. package/dist/core/completions/installers/bash-installer.js +318 -0
  133. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  134. package/dist/core/completions/installers/fish-installer.js +143 -0
  135. package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
  136. package/dist/core/completions/installers/powershell-installer.js +387 -0
  137. package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
  138. package/dist/core/completions/installers/zsh-installer.js +449 -0
  139. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  140. package/dist/core/completions/templates/bash-templates.js +24 -0
  141. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  142. package/dist/core/completions/templates/fish-templates.js +39 -0
  143. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  144. package/dist/core/completions/templates/powershell-templates.js +25 -0
  145. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  146. package/dist/core/completions/templates/zsh-templates.js +36 -0
  147. package/dist/core/completions/types.d.ts +79 -0
  148. package/dist/core/completions/types.js +2 -0
  149. package/dist/core/config-prompts.d.ts +9 -0
  150. package/dist/core/config-prompts.js +34 -0
  151. package/dist/core/config-schema.d.ts +86 -0
  152. package/dist/core/config-schema.js +213 -0
  153. package/dist/core/config.d.ts +18 -0
  154. package/dist/core/config.js +37 -0
  155. package/dist/core/converters/json-converter.d.ts +6 -0
  156. package/dist/core/converters/json-converter.js +51 -0
  157. package/dist/core/global-config.d.ts +44 -0
  158. package/dist/core/global-config.js +125 -0
  159. package/dist/core/index.d.ts +2 -0
  160. package/dist/core/index.js +3 -0
  161. package/dist/core/init.d.ts +37 -0
  162. package/dist/core/init.js +593 -0
  163. package/dist/core/legacy-cleanup.d.ts +162 -0
  164. package/dist/core/legacy-cleanup.js +514 -0
  165. package/dist/core/list.d.ts +9 -0
  166. package/dist/core/list.js +171 -0
  167. package/dist/core/migration.d.ts +23 -0
  168. package/dist/core/migration.js +108 -0
  169. package/dist/core/parsers/change-parser.d.ts +13 -0
  170. package/dist/core/parsers/change-parser.js +193 -0
  171. package/dist/core/parsers/markdown-parser.d.ts +22 -0
  172. package/dist/core/parsers/markdown-parser.js +187 -0
  173. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  174. package/dist/core/parsers/requirement-blocks.js +201 -0
  175. package/dist/core/profile-sync-drift.d.ts +38 -0
  176. package/dist/core/profile-sync-drift.js +200 -0
  177. package/dist/core/profiles.d.ts +26 -0
  178. package/dist/core/profiles.js +40 -0
  179. package/dist/core/project-config.d.ts +64 -0
  180. package/dist/core/project-config.js +223 -0
  181. package/dist/core/schemas/base.schema.d.ts +13 -0
  182. package/dist/core/schemas/base.schema.js +13 -0
  183. package/dist/core/schemas/change.schema.d.ts +73 -0
  184. package/dist/core/schemas/change.schema.js +31 -0
  185. package/dist/core/schemas/index.d.ts +4 -0
  186. package/dist/core/schemas/index.js +4 -0
  187. package/dist/core/schemas/spec.schema.d.ts +18 -0
  188. package/dist/core/schemas/spec.schema.js +15 -0
  189. package/dist/core/shared/index.d.ts +8 -0
  190. package/dist/core/shared/index.js +8 -0
  191. package/dist/core/shared/skill-generation.d.ts +49 -0
  192. package/dist/core/shared/skill-generation.js +96 -0
  193. package/dist/core/shared/tool-detection.d.ts +71 -0
  194. package/dist/core/shared/tool-detection.js +158 -0
  195. package/dist/core/specs-apply.d.ts +73 -0
  196. package/dist/core/specs-apply.js +384 -0
  197. package/dist/core/styles/palette.d.ts +7 -0
  198. package/dist/core/styles/palette.js +8 -0
  199. package/dist/core/templates/index.d.ts +8 -0
  200. package/dist/core/templates/index.js +9 -0
  201. package/dist/core/templates/skill-templates.d.ts +19 -0
  202. package/dist/core/templates/skill-templates.js +18 -0
  203. package/dist/core/templates/types.d.ts +19 -0
  204. package/dist/core/templates/types.js +5 -0
  205. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  206. package/dist/core/templates/workflows/apply-change.js +308 -0
  207. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  208. package/dist/core/templates/workflows/archive-change.js +271 -0
  209. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  210. package/dist/core/templates/workflows/bulk-archive-change.js +488 -0
  211. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  212. package/dist/core/templates/workflows/continue-change.js +232 -0
  213. package/dist/core/templates/workflows/explore.d.ts +10 -0
  214. package/dist/core/templates/workflows/explore.js +461 -0
  215. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  216. package/dist/core/templates/workflows/feedback.js +108 -0
  217. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  218. package/dist/core/templates/workflows/ff-change.js +198 -0
  219. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  220. package/dist/core/templates/workflows/new-change.js +143 -0
  221. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  222. package/dist/core/templates/workflows/onboard.js +565 -0
  223. package/dist/core/templates/workflows/propose.d.ts +10 -0
  224. package/dist/core/templates/workflows/propose.js +216 -0
  225. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  226. package/dist/core/templates/workflows/sync-specs.js +272 -0
  227. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  228. package/dist/core/templates/workflows/verify-change.js +332 -0
  229. package/dist/core/update.d.ts +77 -0
  230. package/dist/core/update.js +537 -0
  231. package/dist/core/validation/constants.d.ts +34 -0
  232. package/dist/core/validation/constants.js +40 -0
  233. package/dist/core/validation/types.d.ts +18 -0
  234. package/dist/core/validation/types.js +2 -0
  235. package/dist/core/validation/validator.d.ts +33 -0
  236. package/dist/core/validation/validator.js +409 -0
  237. package/dist/core/view.d.ts +8 -0
  238. package/dist/core/view.js +168 -0
  239. package/dist/index.d.ts +3 -0
  240. package/dist/index.js +3 -0
  241. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  242. package/dist/prompts/searchable-multi-select.js +159 -0
  243. package/dist/ui/ascii-patterns.d.ts +16 -0
  244. package/dist/ui/ascii-patterns.js +133 -0
  245. package/dist/ui/welcome-screen.d.ts +10 -0
  246. package/dist/ui/welcome-screen.js +146 -0
  247. package/dist/utils/change-metadata.d.ts +51 -0
  248. package/dist/utils/change-metadata.js +147 -0
  249. package/dist/utils/change-utils.d.ts +62 -0
  250. package/dist/utils/change-utils.js +121 -0
  251. package/dist/utils/command-references.d.ts +18 -0
  252. package/dist/utils/command-references.js +20 -0
  253. package/dist/utils/file-system.d.ts +36 -0
  254. package/dist/utils/file-system.js +281 -0
  255. package/dist/utils/index.d.ts +6 -0
  256. package/dist/utils/index.js +9 -0
  257. package/dist/utils/interactive.d.ts +18 -0
  258. package/dist/utils/interactive.js +21 -0
  259. package/dist/utils/item-discovery.d.ts +4 -0
  260. package/dist/utils/item-discovery.js +72 -0
  261. package/dist/utils/match.d.ts +3 -0
  262. package/dist/utils/match.js +22 -0
  263. package/dist/utils/shell-detection.d.ts +20 -0
  264. package/dist/utils/shell-detection.js +41 -0
  265. package/dist/utils/task-progress.d.ts +8 -0
  266. package/dist/utils/task-progress.js +36 -0
  267. package/package.json +78 -0
  268. package/schemas/spec-driven/schema.yaml +153 -0
  269. package/schemas/spec-driven/templates/design.md +19 -0
  270. package/schemas/spec-driven/templates/proposal.md +23 -0
  271. package/schemas/spec-driven/templates/spec.md +8 -0
  272. package/schemas/spec-driven/templates/tasks.md +9 -0
  273. package/scripts/postinstall.js +83 -0
@@ -0,0 +1,162 @@
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
+ /**
6
+ * Legacy config file names from the old ToolRegistry.
7
+ * These were config files created at project root with OpenSpec markers.
8
+ */
9
+ export declare const LEGACY_CONFIG_FILES: readonly ["CLAUDE.md", "CLINE.md", "CODEBUDDY.md", "COSTRICT.md", "QODER.md", "IFLOW.md", "AGENTS.md", "QWEN.md"];
10
+ /**
11
+ * Legacy slash command patterns from the old SlashCommandRegistry.
12
+ * These map toolId to the path pattern where legacy commands were created.
13
+ * Some tools used a directory structure, others used individual files.
14
+ */
15
+ export declare const LEGACY_SLASH_COMMAND_PATHS: Record<string, LegacySlashCommandPattern>;
16
+ /**
17
+ * Pattern types for legacy slash commands
18
+ */
19
+ export interface LegacySlashCommandPattern {
20
+ type: 'directory' | 'files';
21
+ path?: string;
22
+ pattern?: string | string[];
23
+ }
24
+ /**
25
+ * Result of legacy artifact detection
26
+ */
27
+ export interface LegacyDetectionResult {
28
+ /** Config files with OpenSpec markers detected */
29
+ configFiles: string[];
30
+ /** Config files to update (remove markers only, never delete) */
31
+ configFilesToUpdate: string[];
32
+ /** Legacy slash command directories found */
33
+ slashCommandDirs: string[];
34
+ /** Legacy slash command files found (for file-based tools) */
35
+ slashCommandFiles: string[];
36
+ /** Whether openspec/AGENTS.md exists */
37
+ hasOpenspecAgents: boolean;
38
+ /** Whether openspec/project.md exists (preserved, migration hint only) */
39
+ hasProjectMd: boolean;
40
+ /** Whether root AGENTS.md has OpenSpec markers */
41
+ hasRootAgentsWithMarkers: boolean;
42
+ /** Whether any legacy artifacts were found */
43
+ hasLegacyArtifacts: boolean;
44
+ }
45
+ /**
46
+ * Detects all legacy OpenSpec artifacts in a project.
47
+ *
48
+ * @param projectPath - The root path of the project
49
+ * @returns Detection result with all found legacy artifacts
50
+ */
51
+ export declare function detectLegacyArtifacts(projectPath: string): Promise<LegacyDetectionResult>;
52
+ /**
53
+ * Detects legacy config files with OpenSpec markers.
54
+ * All config files with markers are candidates for update (marker removal only).
55
+ * Config files are NEVER deleted - they belong to the user's project root.
56
+ *
57
+ * @param projectPath - The root path of the project
58
+ * @returns Object with all files found and files to update
59
+ */
60
+ export declare function detectLegacyConfigFiles(projectPath: string): Promise<{
61
+ allFiles: string[];
62
+ filesToUpdate: string[];
63
+ }>;
64
+ /**
65
+ * Detects legacy slash command directories and files.
66
+ *
67
+ * @param projectPath - The root path of the project
68
+ * @returns Object with directories and individual files found
69
+ */
70
+ export declare function detectLegacySlashCommands(projectPath: string): Promise<{
71
+ directories: string[];
72
+ files: string[];
73
+ }>;
74
+ /**
75
+ * Detects legacy OpenSpec structure files (AGENTS.md and project.md).
76
+ *
77
+ * @param projectPath - The root path of the project
78
+ * @returns Object with detection results for structure files
79
+ */
80
+ export declare function detectLegacyStructureFiles(projectPath: string): Promise<{
81
+ hasOpenspecAgents: boolean;
82
+ hasProjectMd: boolean;
83
+ hasRootAgentsWithMarkers: boolean;
84
+ }>;
85
+ /**
86
+ * Checks if content contains OpenSpec markers.
87
+ *
88
+ * @param content - File content to check
89
+ * @returns True if both start and end markers are present
90
+ */
91
+ export declare function hasOpenSpecMarkers(content: string): boolean;
92
+ /**
93
+ * Checks if file content is 100% OpenSpec content (only markers and whitespace outside).
94
+ *
95
+ * @param content - File content to check
96
+ * @returns True if content outside markers is only whitespace
97
+ */
98
+ export declare function isOnlyOpenSpecContent(content: string): boolean;
99
+ /**
100
+ * Removes the OpenSpec marker block from file content.
101
+ * Only removes markers that are on their own lines (ignores inline mentions).
102
+ * Cleans up double blank lines that may result from removal.
103
+ *
104
+ * @param content - File content with OpenSpec markers
105
+ * @returns Content with marker block removed
106
+ */
107
+ export declare function removeMarkerBlock(content: string): string;
108
+ /**
109
+ * Result of cleanup operation
110
+ */
111
+ export interface CleanupResult {
112
+ /** Files that were deleted entirely */
113
+ deletedFiles: string[];
114
+ /** Files that had marker blocks removed */
115
+ modifiedFiles: string[];
116
+ /** Directories that were deleted */
117
+ deletedDirs: string[];
118
+ /** Whether project.md exists and needs manual migration */
119
+ projectMdNeedsMigration: boolean;
120
+ /** Error messages if any operations failed */
121
+ errors: string[];
122
+ }
123
+ /**
124
+ * Cleans up legacy OpenSpec artifacts from a project.
125
+ * Preserves openspec/project.md (shows migration hint instead of deleting).
126
+ *
127
+ * @param projectPath - The root path of the project
128
+ * @param detection - Detection result from detectLegacyArtifacts
129
+ * @returns Cleanup result with summary of actions taken
130
+ */
131
+ export declare function cleanupLegacyArtifacts(projectPath: string, detection: LegacyDetectionResult): Promise<CleanupResult>;
132
+ /**
133
+ * Generates a cleanup summary message for display.
134
+ *
135
+ * @param result - Cleanup result from cleanupLegacyArtifacts
136
+ * @returns Formatted summary string for console output
137
+ */
138
+ export declare function formatCleanupSummary(result: CleanupResult): string;
139
+ /**
140
+ * Generates a detection summary message for display before cleanup.
141
+ * Groups files by action type: removals, updates, and manual migration.
142
+ *
143
+ * @param detection - Detection result from detectLegacyArtifacts
144
+ * @returns Formatted summary string showing what was found
145
+ */
146
+ export declare function formatDetectionSummary(detection: LegacyDetectionResult): string;
147
+ /**
148
+ * Extract tool IDs from detected legacy artifacts.
149
+ * Uses LEGACY_SLASH_COMMAND_PATHS to map paths back to tool IDs.
150
+ *
151
+ * @param detection - Detection result from detectLegacyArtifacts
152
+ * @returns Array of tool IDs that had legacy artifacts
153
+ */
154
+ export declare function getToolsFromLegacyArtifacts(detection: LegacyDetectionResult): string[];
155
+ /**
156
+ * Generates a migration hint message for project.md.
157
+ * This is shown when project.md exists and needs manual migration to config.yaml.
158
+ *
159
+ * @returns Formatted migration hint string for console output
160
+ */
161
+ export declare function formatProjectMdMigrationHint(): string;
162
+ //# sourceMappingURL=legacy-cleanup.d.ts.map
@@ -0,0 +1,514 @@
1
+ /**
2
+ * Legacy cleanup module for detecting and removing AnchorSpec 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 { ANCHORSPEC_MARKERS } from './config.js';
9
+ /**
10
+ * Legacy config file names from the old ToolRegistry.
11
+ * These were config files created at project root with AnchorSpec 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 anchorspec/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/anchorspec/ or .tooldir/commands/anchorspec/*.md
30
+ 'claude': { type: 'directory', path: '.claude/commands/anchorspec' },
31
+ 'codebuddy': { type: 'directory', path: '.codebuddy/commands/anchorspec' },
32
+ 'qoder': { type: 'directory', path: '.qoder/commands/anchorspec' },
33
+ 'lingma': { type: 'directory', path: '.lingma/commands/anchorspec' },
34
+ 'crush': { type: 'directory', path: '.crush/commands/anchorspec' },
35
+ 'gemini': { type: 'directory', path: '.gemini/commands/anchorspec' },
36
+ 'costrict': { type: 'directory', path: '.cospec/anchorspec/commands' },
37
+ // File-based: individual anchorspec-*.md files in a commands/workflows/prompts folder
38
+ 'cursor': { type: 'files', pattern: '.cursor/commands/anchorspec-*.md' },
39
+ 'windsurf': { type: 'files', pattern: '.windsurf/workflows/anchorspec-*.md' },
40
+ 'kilocode': { type: 'files', pattern: '.kilocode/workflows/anchorspec-*.md' },
41
+ 'kiro': { type: 'files', pattern: '.kiro/prompts/anchorspec-*.prompt.md' },
42
+ 'github-copilot': { type: 'files', pattern: '.github/prompts/anchorspec-*.prompt.md' },
43
+ 'amazon-q': { type: 'files', pattern: '.amazonq/prompts/anchorspec-*.md' },
44
+ 'cline': { type: 'files', pattern: '.clinerules/workflows/anchorspec-*.md' },
45
+ 'roocode': { type: 'files', pattern: '.roo/commands/anchorspec-*.md' },
46
+ 'auggie': { type: 'files', pattern: '.augment/commands/anchorspec-*.md' },
47
+ 'factory': { type: 'files', pattern: '.factory/commands/anchorspec-*.md' },
48
+ 'opencode': { type: 'files', pattern: ['.opencode/command/ansx-*.md', '.opencode/command/anchorspec-*.md'] },
49
+ 'continue': { type: 'files', pattern: '.continue/prompts/anchorspec-*.prompt' },
50
+ 'antigravity': { type: 'files', pattern: '.agent/workflows/anchorspec-*.md' },
51
+ 'iflow': { type: 'files', pattern: '.iflow/commands/anchorspec-*.md' },
52
+ 'junie': { type: 'files', pattern: ['.junie/commands/ansx-*.md', '.junie/commands/anchorspec-*.md'] },
53
+ 'qwen': { type: 'files', pattern: '.qwen/commands/anchorspec-*.toml' },
54
+ 'codex': { type: 'files', pattern: '.codex/prompts/anchorspec-*.md' },
55
+ };
56
+ /**
57
+ * Detects all legacy AnchorSpec 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 AnchorSpec 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 (hasAnchorSpecMarkers(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/anchorspec-*.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
+ // anchorspec-*.md -> /^anchorspec-.*\.md$/
170
+ // anchorspec-*.prompt.md -> /^anchorspec-.*\.prompt\.md$/
171
+ // anchorspec-*.toml -> /^anchorspec-.*\.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 AnchorSpec 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 anchorspec/AGENTS.md
200
+ const anchorspecAgentsPath = FileSystemUtils.joinPath(projectPath, 'anchorspec', 'AGENTS.md');
201
+ hasOpenspecAgents = await FileSystemUtils.fileExists(anchorspecAgentsPath);
202
+ // Check for anchorspec/project.md (for migration messaging, not deleted)
203
+ const projectMdPath = FileSystemUtils.joinPath(projectPath, 'anchorspec', 'project.md');
204
+ hasProjectMd = await FileSystemUtils.fileExists(projectMdPath);
205
+ // Check for root AGENTS.md with AnchorSpec markers
206
+ const rootAgentsPath = FileSystemUtils.joinPath(projectPath, 'AGENTS.md');
207
+ if (await FileSystemUtils.fileExists(rootAgentsPath)) {
208
+ const content = await FileSystemUtils.readFile(rootAgentsPath);
209
+ hasRootAgentsWithMarkers = hasAnchorSpecMarkers(content);
210
+ }
211
+ return { hasOpenspecAgents, hasProjectMd, hasRootAgentsWithMarkers };
212
+ }
213
+ /**
214
+ * Checks if content contains AnchorSpec markers.
215
+ *
216
+ * @param content - File content to check
217
+ * @returns True if both start and end markers are present
218
+ */
219
+ export function hasAnchorSpecMarkers(content) {
220
+ return (content.includes(ANCHORSPEC_MARKERS.start) && content.includes(ANCHORSPEC_MARKERS.end));
221
+ }
222
+ /**
223
+ * Checks if file content is 100% AnchorSpec 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 isOnlyAnchorSpecContent(content) {
229
+ const startIndex = content.indexOf(ANCHORSPEC_MARKERS.start);
230
+ const endIndex = content.indexOf(ANCHORSPEC_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 + ANCHORSPEC_MARKERS.end.length);
236
+ return before.trim() === '' && after.trim() === '';
237
+ }
238
+ /**
239
+ * Removes the AnchorSpec 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 AnchorSpec markers
244
+ * @returns Content with marker block removed
245
+ */
246
+ export function removeMarkerBlock(content) {
247
+ return removeMarkerBlockUtil(content, ANCHORSPEC_MARKERS.start, ANCHORSPEC_MARKERS.end);
248
+ }
249
+ /**
250
+ * Cleans up legacy AnchorSpec artifacts from a project.
251
+ * Preserves anchorspec/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% AnchorSpec-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% AnchorSpec-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 anchorspec/AGENTS.md (this is inside anchorspec/, it's AnchorSpec-managed)
303
+ if (detection.hasOpenspecAgents) {
304
+ const agentsPath = FileSystemUtils.joinPath(projectPath, 'anchorspec', 'AGENTS.md');
305
+ if (await FileSystemUtils.fileExists(agentsPath)) {
306
+ try {
307
+ await fs.unlink(agentsPath);
308
+ result.deletedFiles.push('anchorspec/AGENTS.md');
309
+ }
310
+ catch (error) {
311
+ result.errors.push(`Failed to delete anchorspec/AGENTS.md: ${error.message}`);
312
+ }
313
+ }
314
+ }
315
+ // Handle root AGENTS.md with AnchorSpec 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 /ansx:*)`);
335
+ }
336
+ for (const file of result.modifiedFiles) {
337
+ lines.push(` ✓ Removed AnchorSpec 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 AnchorSpec-managed files (slash commands, anchorspec/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% AnchorSpec-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% AnchorSpec-managed)
374
+ for (const file of detection.slashCommandFiles) {
375
+ removals.push({ path: file, explanation: 'replaced by skills/' });
376
+ }
377
+ // anchorspec/AGENTS.md (inside anchorspec/, it's AnchorSpec-managed)
378
+ if (detection.hasOpenspecAgents) {
379
+ removals.push({ path: 'anchorspec/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 AnchorSpec 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 AnchorSpec'));
417
+ lines.push('');
418
+ lines.push('AnchorSpec 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('AnchorSpec 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/anchorspec-*.md' -> /^\.cursor\/commands\/anchorspec-.*\.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(' • anchorspec/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 anchorspec/config.yaml has a "context:" section for planning'));
507
+ lines.push(chalk.dim(' context. This is included in every AnchorSpec 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