@dynamicworks/br-openspec 1.3.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 (291) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +210 -0
  3. package/README.pt-BR.md +212 -0
  4. package/bin/openspec.js +3 -0
  5. package/dist/cli/index.d.ts +2 -0
  6. package/dist/cli/index.js +484 -0
  7. package/dist/commands/change.d.ts +35 -0
  8. package/dist/commands/change.js +278 -0
  9. package/dist/commands/completion.d.ts +72 -0
  10. package/dist/commands/completion.js +258 -0
  11. package/dist/commands/config.d.ts +36 -0
  12. package/dist/commands/config.js +553 -0
  13. package/dist/commands/feedback.d.ts +9 -0
  14. package/dist/commands/feedback.js +184 -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 +133 -0
  19. package/dist/commands/spec.d.ts +15 -0
  20. package/dist/commands/spec.js +226 -0
  21. package/dist/commands/tools.d.ts +11 -0
  22. package/dist/commands/tools.js +252 -0
  23. package/dist/commands/validate.d.ts +24 -0
  24. package/dist/commands/validate.js +295 -0
  25. package/dist/commands/workflow/index.d.ts +17 -0
  26. package/dist/commands/workflow/index.js +12 -0
  27. package/dist/commands/workflow/instructions.d.ts +29 -0
  28. package/dist/commands/workflow/instructions.js +328 -0
  29. package/dist/commands/workflow/new-change.d.ts +11 -0
  30. package/dist/commands/workflow/new-change.js +44 -0
  31. package/dist/commands/workflow/schemas.d.ts +10 -0
  32. package/dist/commands/workflow/schemas.js +35 -0
  33. package/dist/commands/workflow/shared.d.ts +57 -0
  34. package/dist/commands/workflow/shared.js +117 -0
  35. package/dist/commands/workflow/status.d.ts +14 -0
  36. package/dist/commands/workflow/status.js +76 -0
  37. package/dist/commands/workflow/templates.d.ts +16 -0
  38. package/dist/commands/workflow/templates.js +70 -0
  39. package/dist/core/archive.d.ts +11 -0
  40. package/dist/core/archive.js +322 -0
  41. package/dist/core/artifact-graph/graph.d.ts +56 -0
  42. package/dist/core/artifact-graph/graph.js +141 -0
  43. package/dist/core/artifact-graph/index.d.ts +8 -0
  44. package/dist/core/artifact-graph/index.js +14 -0
  45. package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
  46. package/dist/core/artifact-graph/instruction-loader.js +217 -0
  47. package/dist/core/artifact-graph/outputs.d.ts +14 -0
  48. package/dist/core/artifact-graph/outputs.js +39 -0
  49. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  50. package/dist/core/artifact-graph/resolver.js +258 -0
  51. package/dist/core/artifact-graph/schema.d.ts +13 -0
  52. package/dist/core/artifact-graph/schema.js +108 -0
  53. package/dist/core/artifact-graph/state.d.ts +12 -0
  54. package/dist/core/artifact-graph/state.js +31 -0
  55. package/dist/core/artifact-graph/types.d.ts +45 -0
  56. package/dist/core/artifact-graph/types.js +43 -0
  57. package/dist/core/available-tools.d.ts +17 -0
  58. package/dist/core/available-tools.js +43 -0
  59. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  60. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  61. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  62. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  63. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  64. package/dist/core/command-generation/adapters/auggie.js +27 -0
  65. package/dist/core/command-generation/adapters/bob.d.ts +14 -0
  66. package/dist/core/command-generation/adapters/bob.js +45 -0
  67. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  68. package/dist/core/command-generation/adapters/claude.js +50 -0
  69. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  70. package/dist/core/command-generation/adapters/cline.js +27 -0
  71. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  72. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  73. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  74. package/dist/core/command-generation/adapters/codex.js +39 -0
  75. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  76. package/dist/core/command-generation/adapters/continue.js +28 -0
  77. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  78. package/dist/core/command-generation/adapters/costrict.js +27 -0
  79. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  80. package/dist/core/command-generation/adapters/crush.js +30 -0
  81. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  82. package/dist/core/command-generation/adapters/cursor.js +44 -0
  83. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  84. package/dist/core/command-generation/adapters/factory.js +27 -0
  85. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  86. package/dist/core/command-generation/adapters/gemini.js +26 -0
  87. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  88. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  89. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  90. package/dist/core/command-generation/adapters/iflow.js +29 -0
  91. package/dist/core/command-generation/adapters/index.d.ts +32 -0
  92. package/dist/core/command-generation/adapters/index.js +32 -0
  93. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  94. package/dist/core/command-generation/adapters/junie.js +26 -0
  95. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  96. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  97. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  98. package/dist/core/command-generation/adapters/kiro.js +26 -0
  99. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  100. package/dist/core/command-generation/adapters/lingma.js +30 -0
  101. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  102. package/dist/core/command-generation/adapters/opencode.js +29 -0
  103. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  104. package/dist/core/command-generation/adapters/pi.js +55 -0
  105. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  106. package/dist/core/command-generation/adapters/qoder.js +30 -0
  107. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  108. package/dist/core/command-generation/adapters/qwen.js +26 -0
  109. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  110. package/dist/core/command-generation/adapters/roocode.js +27 -0
  111. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  112. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  113. package/dist/core/command-generation/generator.d.ts +21 -0
  114. package/dist/core/command-generation/generator.js +27 -0
  115. package/dist/core/command-generation/index.d.ts +22 -0
  116. package/dist/core/command-generation/index.js +24 -0
  117. package/dist/core/command-generation/registry.d.ts +36 -0
  118. package/dist/core/command-generation/registry.js +98 -0
  119. package/dist/core/command-generation/types.d.ts +56 -0
  120. package/dist/core/command-generation/types.js +8 -0
  121. package/dist/core/completions/command-registry.d.ts +7 -0
  122. package/dist/core/completions/command-registry.js +462 -0
  123. package/dist/core/completions/completion-provider.d.ts +60 -0
  124. package/dist/core/completions/completion-provider.js +102 -0
  125. package/dist/core/completions/factory.d.ts +64 -0
  126. package/dist/core/completions/factory.js +75 -0
  127. package/dist/core/completions/generators/bash-generator.d.ts +32 -0
  128. package/dist/core/completions/generators/bash-generator.js +174 -0
  129. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  130. package/dist/core/completions/generators/fish-generator.js +157 -0
  131. package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
  132. package/dist/core/completions/generators/powershell-generator.js +208 -0
  133. package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
  134. package/dist/core/completions/generators/zsh-generator.js +250 -0
  135. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  136. package/dist/core/completions/installers/bash-installer.js +319 -0
  137. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  138. package/dist/core/completions/installers/fish-installer.js +143 -0
  139. package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
  140. package/dist/core/completions/installers/powershell-installer.js +400 -0
  141. package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
  142. package/dist/core/completions/installers/zsh-installer.js +450 -0
  143. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  144. package/dist/core/completions/templates/bash-templates.js +24 -0
  145. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  146. package/dist/core/completions/templates/fish-templates.js +39 -0
  147. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  148. package/dist/core/completions/templates/powershell-templates.js +25 -0
  149. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  150. package/dist/core/completions/templates/zsh-templates.js +36 -0
  151. package/dist/core/completions/types.d.ts +79 -0
  152. package/dist/core/completions/types.js +2 -0
  153. package/dist/core/config-prompts.d.ts +9 -0
  154. package/dist/core/config-prompts.js +34 -0
  155. package/dist/core/config-schema.d.ts +86 -0
  156. package/dist/core/config-schema.js +213 -0
  157. package/dist/core/config.d.ts +18 -0
  158. package/dist/core/config.js +38 -0
  159. package/dist/core/converters/json-converter.d.ts +6 -0
  160. package/dist/core/converters/json-converter.js +51 -0
  161. package/dist/core/global-config.d.ts +44 -0
  162. package/dist/core/global-config.js +125 -0
  163. package/dist/core/index.d.ts +2 -0
  164. package/dist/core/index.js +3 -0
  165. package/dist/core/init.d.ts +37 -0
  166. package/dist/core/init.js +549 -0
  167. package/dist/core/is-project-initialized.d.ts +12 -0
  168. package/dist/core/is-project-initialized.js +18 -0
  169. package/dist/core/legacy-cleanup.d.ts +162 -0
  170. package/dist/core/legacy-cleanup.js +515 -0
  171. package/dist/core/list.d.ts +9 -0
  172. package/dist/core/list.js +172 -0
  173. package/dist/core/migration.d.ts +23 -0
  174. package/dist/core/migration.js +109 -0
  175. package/dist/core/parsers/change-parser.d.ts +13 -0
  176. package/dist/core/parsers/change-parser.js +197 -0
  177. package/dist/core/parsers/markdown-parser.d.ts +26 -0
  178. package/dist/core/parsers/markdown-parser.js +228 -0
  179. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  180. package/dist/core/parsers/requirement-blocks.js +201 -0
  181. package/dist/core/parsers/spec-structure.d.ts +9 -0
  182. package/dist/core/parsers/spec-structure.js +88 -0
  183. package/dist/core/profile-sync-drift.d.ts +38 -0
  184. package/dist/core/profile-sync-drift.js +200 -0
  185. package/dist/core/profiles.d.ts +26 -0
  186. package/dist/core/profiles.js +40 -0
  187. package/dist/core/project-config.d.ts +64 -0
  188. package/dist/core/project-config.js +224 -0
  189. package/dist/core/schemas/base.schema.d.ts +13 -0
  190. package/dist/core/schemas/base.schema.js +13 -0
  191. package/dist/core/schemas/change.schema.d.ts +73 -0
  192. package/dist/core/schemas/change.schema.js +31 -0
  193. package/dist/core/schemas/index.d.ts +4 -0
  194. package/dist/core/schemas/index.js +4 -0
  195. package/dist/core/schemas/spec.schema.d.ts +18 -0
  196. package/dist/core/schemas/spec.schema.js +15 -0
  197. package/dist/core/shared/index.d.ts +8 -0
  198. package/dist/core/shared/index.js +8 -0
  199. package/dist/core/shared/skill-generation.d.ts +49 -0
  200. package/dist/core/shared/skill-generation.js +96 -0
  201. package/dist/core/shared/tool-detection.d.ts +71 -0
  202. package/dist/core/shared/tool-detection.js +158 -0
  203. package/dist/core/specs-apply.d.ts +73 -0
  204. package/dist/core/specs-apply.js +393 -0
  205. package/dist/core/styles/palette.d.ts +7 -0
  206. package/dist/core/styles/palette.js +8 -0
  207. package/dist/core/templates/index.d.ts +8 -0
  208. package/dist/core/templates/index.js +9 -0
  209. package/dist/core/templates/skill-templates.d.ts +20 -0
  210. package/dist/core/templates/skill-templates.js +19 -0
  211. package/dist/core/templates/types.d.ts +19 -0
  212. package/dist/core/templates/types.js +5 -0
  213. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  214. package/dist/core/templates/workflows/apply-change.js +308 -0
  215. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  216. package/dist/core/templates/workflows/archive-change.js +271 -0
  217. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  218. package/dist/core/templates/workflows/bulk-archive-change.js +492 -0
  219. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  220. package/dist/core/templates/workflows/continue-change.js +232 -0
  221. package/dist/core/templates/workflows/explore.d.ts +10 -0
  222. package/dist/core/templates/workflows/explore.js +463 -0
  223. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  224. package/dist/core/templates/workflows/feedback.js +108 -0
  225. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  226. package/dist/core/templates/workflows/ff-change.js +198 -0
  227. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  228. package/dist/core/templates/workflows/new-change.js +21 -0
  229. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  230. package/dist/core/templates/workflows/onboard.js +21 -0
  231. package/dist/core/templates/workflows/propose.d.ts +10 -0
  232. package/dist/core/templates/workflows/propose.js +216 -0
  233. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  234. package/dist/core/templates/workflows/sync-specs.js +272 -0
  235. package/dist/core/templates/workflows/upstream-sync.d.ts +10 -0
  236. package/dist/core/templates/workflows/upstream-sync.js +116 -0
  237. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  238. package/dist/core/templates/workflows/verify-change.js +21 -0
  239. package/dist/core/tools-manager.d.ts +56 -0
  240. package/dist/core/tools-manager.js +215 -0
  241. package/dist/core/update.d.ts +77 -0
  242. package/dist/core/update.js +538 -0
  243. package/dist/core/validation/constants.d.ts +34 -0
  244. package/dist/core/validation/constants.js +40 -0
  245. package/dist/core/validation/types.d.ts +18 -0
  246. package/dist/core/validation/types.js +2 -0
  247. package/dist/core/validation/validator.d.ts +33 -0
  248. package/dist/core/validation/validator.js +419 -0
  249. package/dist/core/view.d.ts +8 -0
  250. package/dist/core/view.js +169 -0
  251. package/dist/index.d.ts +3 -0
  252. package/dist/index.js +3 -0
  253. package/dist/messages/index.d.ts +867 -0
  254. package/dist/messages/index.js +1960 -0
  255. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  256. package/dist/prompts/searchable-multi-select.js +160 -0
  257. package/dist/telemetry/config.d.ts +38 -0
  258. package/dist/telemetry/config.js +136 -0
  259. package/dist/telemetry/index.d.ts +31 -0
  260. package/dist/telemetry/index.js +165 -0
  261. package/dist/ui/ascii-patterns.d.ts +16 -0
  262. package/dist/ui/ascii-patterns.js +133 -0
  263. package/dist/ui/welcome-screen.d.ts +10 -0
  264. package/dist/ui/welcome-screen.js +147 -0
  265. package/dist/utils/change-metadata.d.ts +51 -0
  266. package/dist/utils/change-metadata.js +147 -0
  267. package/dist/utils/change-utils.d.ts +62 -0
  268. package/dist/utils/change-utils.js +121 -0
  269. package/dist/utils/command-references.d.ts +18 -0
  270. package/dist/utils/command-references.js +20 -0
  271. package/dist/utils/file-system.d.ts +41 -0
  272. package/dist/utils/file-system.js +302 -0
  273. package/dist/utils/index.d.ts +6 -0
  274. package/dist/utils/index.js +9 -0
  275. package/dist/utils/interactive.d.ts +18 -0
  276. package/dist/utils/interactive.js +21 -0
  277. package/dist/utils/item-discovery.d.ts +4 -0
  278. package/dist/utils/item-discovery.js +72 -0
  279. package/dist/utils/match.d.ts +3 -0
  280. package/dist/utils/match.js +22 -0
  281. package/dist/utils/shell-detection.d.ts +20 -0
  282. package/dist/utils/shell-detection.js +41 -0
  283. package/dist/utils/task-progress.d.ts +8 -0
  284. package/dist/utils/task-progress.js +37 -0
  285. package/package.json +84 -0
  286. package/schemas/spec-driven/schema.yaml +153 -0
  287. package/schemas/spec-driven/templates/design.md +19 -0
  288. package/schemas/spec-driven/templates/proposal.md +23 -0
  289. package/schemas/spec-driven/templates/spec.md +8 -0
  290. package/schemas/spec-driven/templates/tasks.md +9 -0
  291. package/scripts/postinstall.js +83 -0
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Tools Manager
3
+ *
4
+ * Encapsulates adding and removing IDE/Code Agent OpenSpec configuration files.
5
+ * Shared by `openspec init` (via InitCommand) and `openspec tools`.
6
+ */
7
+ import { TOOLS_MESSAGES } from '../messages/index.js';
8
+ import path from 'path';
9
+ import * as fs from 'fs';
10
+ import { createRequire } from 'module';
11
+ import { FileSystemUtils } from '../utils/file-system.js';
12
+ import { transformToHyphenCommands } from '../utils/command-references.js';
13
+ import { AI_TOOLS } from './config.js';
14
+ import { generateCommands, CommandAdapterRegistry, } from './command-generation/index.js';
15
+ import { getSkillTemplates, getCommandContents, generateSkillContent, } from './shared/index.js';
16
+ import { getToolStates, getToolsWithSkillsDir, } from './shared/index.js';
17
+ import { getGlobalConfig } from './global-config.js';
18
+ import { getProfileWorkflows, ALL_WORKFLOWS } from './profiles.js';
19
+ const require = createRequire(import.meta.url);
20
+ const { version: OPENSPEC_VERSION } = require('../../package.json');
21
+ // Map from workflow ID to the skill directory name it uses
22
+ const WORKFLOW_TO_SKILL_DIR = {
23
+ explore: 'openspec-explore',
24
+ new: 'openspec-new-change',
25
+ continue: 'openspec-continue-change',
26
+ apply: 'openspec-apply-change',
27
+ ff: 'openspec-ff-change',
28
+ sync: 'openspec-sync-specs',
29
+ archive: 'openspec-archive-change',
30
+ 'bulk-archive': 'openspec-bulk-archive-change',
31
+ verify: 'openspec-verify-change',
32
+ onboard: 'openspec-onboard',
33
+ propose: 'openspec-propose',
34
+ };
35
+ // ─────────────────────────────────────────────────────────────────────────────
36
+ // Shared remove helpers (also used by InitCommand)
37
+ // ─────────────────────────────────────────────────────────────────────────────
38
+ /**
39
+ * Removes all OpenSpec-owned skill directories under the given `skillsDir`.
40
+ * Only directories whose names match known workflow skill dir names are removed.
41
+ * Other files and directories are left intact.
42
+ *
43
+ * @returns Number of directories removed
44
+ */
45
+ export async function removeOpenSpecSkillDirs(skillsDir) {
46
+ let removed = 0;
47
+ for (const workflow of ALL_WORKFLOWS) {
48
+ const dirName = WORKFLOW_TO_SKILL_DIR[workflow];
49
+ if (!dirName)
50
+ continue;
51
+ const skillDir = path.join(skillsDir, dirName);
52
+ try {
53
+ if (fs.existsSync(skillDir)) {
54
+ await fs.promises.rm(skillDir, { recursive: true, force: true });
55
+ removed++;
56
+ }
57
+ }
58
+ catch {
59
+ // Ignore individual errors
60
+ }
61
+ }
62
+ return removed;
63
+ }
64
+ /**
65
+ * Removes all OpenSpec-owned command files for the given tool.
66
+ * Only files whose paths are produced by the tool's adapter `getFilePath()` are removed.
67
+ * The tool's configuration directory is left intact.
68
+ *
69
+ * @returns Number of files removed
70
+ */
71
+ export async function removeOpenSpecCommandFiles(projectPath, toolId) {
72
+ let removed = 0;
73
+ const adapter = CommandAdapterRegistry.get(toolId);
74
+ if (!adapter)
75
+ return 0;
76
+ for (const workflow of ALL_WORKFLOWS) {
77
+ const cmdPath = adapter.getFilePath(workflow);
78
+ const fullPath = path.isAbsolute(cmdPath)
79
+ ? cmdPath
80
+ : path.join(projectPath, cmdPath);
81
+ try {
82
+ if (fs.existsSync(fullPath)) {
83
+ await fs.promises.unlink(fullPath);
84
+ removed++;
85
+ }
86
+ }
87
+ catch {
88
+ // Ignore individual errors
89
+ }
90
+ }
91
+ return removed;
92
+ }
93
+ // ─────────────────────────────────────────────────────────────────────────────
94
+ // Add / Remove API
95
+ // ─────────────────────────────────────────────────────────────────────────────
96
+ /**
97
+ * Adds OpenSpec skill and command files for the given tool.
98
+ * Creates the tool's configuration directory if it does not exist.
99
+ * Respects the active global config (profile and delivery settings).
100
+ */
101
+ export async function addTool(projectPath, tool) {
102
+ if (!tool.skillsDir) {
103
+ throw new Error(`Tool '${tool.value}' does not support skill generation.`);
104
+ }
105
+ const globalConfig = getGlobalConfig();
106
+ const profile = globalConfig.profile ?? 'core';
107
+ const delivery = globalConfig.delivery ?? 'both';
108
+ const workflows = getProfileWorkflows(profile, globalConfig.workflows);
109
+ const shouldGenerateSkills = delivery !== 'commands';
110
+ const shouldGenerateCommands = delivery !== 'skills';
111
+ // Write skill files
112
+ if (shouldGenerateSkills) {
113
+ const skillsDir = path.join(projectPath, tool.skillsDir, 'skills');
114
+ const skillTemplates = getSkillTemplates(workflows);
115
+ for (const { template, dirName } of skillTemplates) {
116
+ const skillDir = path.join(skillsDir, dirName);
117
+ const skillFile = path.join(skillDir, 'SKILL.md');
118
+ const transformer = tool.value === 'opencode' || tool.value === 'pi'
119
+ ? transformToHyphenCommands
120
+ : undefined;
121
+ const skillContent = generateSkillContent(template, OPENSPEC_VERSION, transformer);
122
+ await FileSystemUtils.writeFile(skillFile, skillContent);
123
+ }
124
+ }
125
+ // Write command files
126
+ if (shouldGenerateCommands) {
127
+ const adapter = CommandAdapterRegistry.get(tool.value);
128
+ if (adapter) {
129
+ const commandContents = getCommandContents(workflows);
130
+ const generatedCommands = generateCommands(commandContents, adapter);
131
+ for (const cmd of generatedCommands) {
132
+ const commandFile = path.isAbsolute(cmd.path)
133
+ ? cmd.path
134
+ : path.join(projectPath, cmd.path);
135
+ await FileSystemUtils.writeFile(commandFile, cmd.fileContent);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ /**
141
+ * Removes OpenSpec-owned skill and command files for the given tool.
142
+ * The tool's configuration directory itself is left intact; only files and
143
+ * directories created by OpenSpec are removed.
144
+ *
145
+ * @returns Counts of removed skill dirs and command files
146
+ */
147
+ export async function removeTool(projectPath, tool) {
148
+ if (!tool.skillsDir) {
149
+ return { removedSkillCount: 0, removedCommandCount: 0 };
150
+ }
151
+ const skillsDir = path.join(projectPath, tool.skillsDir, 'skills');
152
+ const removedSkillCount = await removeOpenSpecSkillDirs(skillsDir);
153
+ const removedCommandCount = await removeOpenSpecCommandFiles(projectPath, tool.value);
154
+ return { removedSkillCount, removedCommandCount };
155
+ }
156
+ // ─────────────────────────────────────────────────────────────────────────────
157
+ // Query helpers
158
+ // ─────────────────────────────────────────────────────────────────────────────
159
+ /**
160
+ * Returns the IDs of all tools that are currently configured in the project.
161
+ */
162
+ export function getCurrentToolIds(projectPath) {
163
+ const toolStates = getToolStates(projectPath);
164
+ const configured = new Set();
165
+ for (const [toolId, status] of toolStates) {
166
+ if (status.configured)
167
+ configured.add(toolId);
168
+ }
169
+ return configured;
170
+ }
171
+ /**
172
+ * Returns all tools eligible for skill generation (those with a skillsDir).
173
+ */
174
+ export function getEligibleTools() {
175
+ return AI_TOOLS.filter((t) => !!t.skillsDir);
176
+ }
177
+ /**
178
+ * Resolves a comma-separated tool list string to an array of valid tool IDs.
179
+ *
180
+ * Accepts the special values "all" and "none".
181
+ * Throws a descriptive error for invalid or ambiguous inputs.
182
+ */
183
+ export function resolveToolsArg(raw) {
184
+ const trimmed = raw.trim();
185
+ if (trimmed.length === 0) {
186
+ throw new Error(TOOLS_MESSAGES.addRemoveRequiresValue);
187
+ }
188
+ const availableTools = getToolsWithSkillsDir();
189
+ const availableSet = new Set(availableTools);
190
+ if (trimmed.toLowerCase() === 'all') {
191
+ return availableTools;
192
+ }
193
+ if (trimmed.toLowerCase() === 'none') {
194
+ return [];
195
+ }
196
+ const tokens = trimmed
197
+ .split(',')
198
+ .map((t) => t.trim().toLowerCase())
199
+ .filter((t) => t.length > 0);
200
+ if (tokens.some((t) => t === 'all' || t === 'none')) {
201
+ throw new Error(TOOLS_MESSAGES.cannotCombineReserved);
202
+ }
203
+ const invalid = tokens.filter((t) => !availableSet.has(t));
204
+ if (invalid.length > 0) {
205
+ throw new Error(TOOLS_MESSAGES.invalidTools(invalid.join(', '), availableTools.join(', ')));
206
+ }
207
+ // Deduplicate preserving order
208
+ const deduped = [];
209
+ for (const t of tokens) {
210
+ if (!deduped.includes(t))
211
+ deduped.push(t);
212
+ }
213
+ return deduped;
214
+ }
215
+ //# sourceMappingURL=tools-manager.js.map
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Update Command
3
+ *
4
+ * Refreshes BR-OpenSpec skills and commands for configured tools.
5
+ * Supports profile-aware updates, delivery changes, migration, and smart update detection.
6
+ */
7
+ /**
8
+ * Options for the update command.
9
+ */
10
+ export interface UpdateCommandOptions {
11
+ /** Force update even when tools are up to date */
12
+ force?: boolean;
13
+ }
14
+ /**
15
+ * Scans installed workflow artifacts (skills and managed commands) across all configured tools.
16
+ * Returns the union of detected workflow IDs that match ALL_WORKFLOWS.
17
+ *
18
+ * Wrapper around the shared migration module's scanInstalledWorkflows that accepts tool IDs.
19
+ */
20
+ export declare function scanInstalledWorkflows(projectPath: string, toolIds: string[]): string[];
21
+ export declare class UpdateCommand {
22
+ private readonly force;
23
+ constructor(options?: UpdateCommandOptions);
24
+ execute(projectPath: string): Promise<void>;
25
+ /**
26
+ * Display message when all tools are up to date.
27
+ */
28
+ private displayUpToDateMessage;
29
+ /**
30
+ * Display the update plan showing which tools need updating.
31
+ */
32
+ private displayUpdatePlan;
33
+ /**
34
+ * Detects new tool directories that aren't currently configured and displays a hint.
35
+ */
36
+ private detectNewTools;
37
+ /**
38
+ * Displays a note about extra workflows installed that aren't in the current profile.
39
+ */
40
+ private displayExtraWorkflowsNote;
41
+ /**
42
+ * Removes skill directories for workflows when delivery changed to commands-only.
43
+ * Returns the number of directories removed.
44
+ */
45
+ private removeSkillDirs;
46
+ /**
47
+ * Removes skill directories for workflows that are no longer selected in the active profile.
48
+ * Returns the number of directories removed.
49
+ */
50
+ private removeUnselectedSkillDirs;
51
+ /**
52
+ * Removes command files for workflows when delivery changed to skills-only.
53
+ * Returns the number of files removed.
54
+ */
55
+ private removeCommandFiles;
56
+ /**
57
+ * Removes command files for workflows that are no longer selected in the active profile.
58
+ * Returns the number of files removed.
59
+ */
60
+ private removeUnselectedCommandFiles;
61
+ /**
62
+ * Detect and handle legacy BR-OpenSpec artifacts.
63
+ * Unlike init, update warns but continues if legacy files found in non-interactive mode.
64
+ * Returns array of tool IDs that were newly configured during legacy upgrade.
65
+ */
66
+ private handleLegacyCleanup;
67
+ /**
68
+ * Perform cleanup of legacy artifacts.
69
+ */
70
+ private performLegacyCleanup;
71
+ /**
72
+ * Upgrade legacy tools to new skills system.
73
+ * Returns array of tool IDs that were newly configured.
74
+ */
75
+ private upgradeLegacyTools;
76
+ }
77
+ //# sourceMappingURL=update.d.ts.map