@bobby_z/openspec 0.0.1

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