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,6 @@
1
+ /**
2
+ * Static template strings for Zsh completion scripts.
3
+ * These are Zsh-specific helper functions that never change.
4
+ */
5
+ export declare const ZSH_DYNAMIC_HELPERS = "# Dynamic completion helpers\n\n# Use openspec __complete to get available changes\n_openspec_complete_changes() {\n local -a changes\n while IFS=$'\\t' read -r id desc; do\n changes+=(\"$id:$desc\")\n done < <(openspec __complete changes 2>/dev/null)\n _describe \"change\" changes\n}\n\n# Use openspec __complete to get available specs\n_openspec_complete_specs() {\n local -a specs\n while IFS=$'\\t' read -r id desc; do\n specs+=(\"$id:$desc\")\n done < <(openspec __complete specs 2>/dev/null)\n _describe \"spec\" specs\n}\n\n# Get both changes and specs\n_openspec_complete_items() {\n local -a items\n while IFS=$'\\t' read -r id desc; do\n items+=(\"$id:$desc\")\n done < <(openspec __complete changes 2>/dev/null)\n while IFS=$'\\t' read -r id desc; do\n items+=(\"$id:$desc\")\n done < <(openspec __complete specs 2>/dev/null)\n _describe \"item\" items\n}";
6
+ //# sourceMappingURL=zsh-templates.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Static template strings for Zsh completion scripts.
3
+ * These are Zsh-specific helper functions that never change.
4
+ */
5
+ export const ZSH_DYNAMIC_HELPERS = `# Dynamic completion helpers
6
+
7
+ # Use anchorspec __complete to get available changes
8
+ _anchorspec_complete_changes() {
9
+ local -a changes
10
+ while IFS=$'\\t' read -r id desc; do
11
+ changes+=("$id:$desc")
12
+ done < <(anchorspec __complete changes 2>/dev/null)
13
+ _describe "change" changes
14
+ }
15
+
16
+ # Use anchorspec __complete to get available specs
17
+ _anchorspec_complete_specs() {
18
+ local -a specs
19
+ while IFS=$'\\t' read -r id desc; do
20
+ specs+=("$id:$desc")
21
+ done < <(anchorspec __complete specs 2>/dev/null)
22
+ _describe "spec" specs
23
+ }
24
+
25
+ # Get both changes and specs
26
+ _anchorspec_complete_items() {
27
+ local -a items
28
+ while IFS=$'\\t' read -r id desc; do
29
+ items+=("$id:$desc")
30
+ done < <(anchorspec __complete changes 2>/dev/null)
31
+ while IFS=$'\\t' read -r id desc; do
32
+ items+=("$id:$desc")
33
+ done < <(anchorspec __complete specs 2>/dev/null)
34
+ _describe "item" items
35
+ }`;
36
+ //# sourceMappingURL=zsh-templates.js.map
@@ -0,0 +1,79 @@
1
+ import { SupportedShell } from '../../utils/shell-detection.js';
2
+ /**
3
+ * Definition of a command-line flag/option
4
+ */
5
+ export interface FlagDefinition {
6
+ /**
7
+ * Flag name without dashes (e.g., "json", "strict", "no-interactive")
8
+ */
9
+ name: string;
10
+ /**
11
+ * Short flag name without dash (e.g., "y" for "-y")
12
+ */
13
+ short?: string;
14
+ /**
15
+ * Human-readable description of what the flag does
16
+ */
17
+ description: string;
18
+ /**
19
+ * Whether the flag takes an argument value
20
+ */
21
+ takesValue?: boolean;
22
+ /**
23
+ * Possible values for the flag (for completion suggestions)
24
+ */
25
+ values?: string[];
26
+ }
27
+ /**
28
+ * Definition of a CLI command
29
+ */
30
+ export interface CommandDefinition {
31
+ /**
32
+ * Command name (e.g., "init", "validate", "show")
33
+ */
34
+ name: string;
35
+ /**
36
+ * Human-readable description of the command
37
+ */
38
+ description: string;
39
+ /**
40
+ * Flags/options supported by this command
41
+ */
42
+ flags: FlagDefinition[];
43
+ /**
44
+ * Subcommands (e.g., "change show", "spec validate")
45
+ */
46
+ subcommands?: CommandDefinition[];
47
+ /**
48
+ * Whether this command accepts a positional argument (e.g., item name, path)
49
+ */
50
+ acceptsPositional?: boolean;
51
+ /**
52
+ * Type of positional argument for dynamic completion
53
+ * - 'change-id': Complete with active change IDs
54
+ * - 'spec-id': Complete with spec IDs
55
+ * - 'change-or-spec-id': Complete with both changes and specs
56
+ * - 'path': Complete with file paths
57
+ * - 'shell': Complete with supported shell names
58
+ * - 'schema-name': Complete with available schema names
59
+ * - undefined: No specific completion
60
+ */
61
+ positionalType?: 'change-id' | 'spec-id' | 'change-or-spec-id' | 'path' | 'shell' | 'schema-name';
62
+ }
63
+ /**
64
+ * Interface for shell-specific completion script generators
65
+ */
66
+ export interface CompletionGenerator {
67
+ /**
68
+ * The shell type this generator targets
69
+ */
70
+ readonly shell: SupportedShell;
71
+ /**
72
+ * Generate the completion script content
73
+ *
74
+ * @param commands - Command definitions to generate completions for
75
+ * @returns The shell-specific completion script as a string
76
+ */
77
+ generate(commands: CommandDefinition[]): string;
78
+ }
79
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,9 @@
1
+ import type { ProjectConfig } from './project-config.js';
2
+ /**
3
+ * Serialize config to YAML string with helpful comments.
4
+ *
5
+ * @param config - Partial config object (schema required, context/rules optional)
6
+ * @returns YAML string ready to write to file
7
+ */
8
+ export declare function serializeConfig(config: Partial<ProjectConfig>): string;
9
+ //# sourceMappingURL=config-prompts.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Serialize config to YAML string with helpful comments.
3
+ *
4
+ * @param config - Partial config object (schema required, context/rules optional)
5
+ * @returns YAML string ready to write to file
6
+ */
7
+ export function serializeConfig(config) {
8
+ const lines = [];
9
+ // Schema (required)
10
+ lines.push(`schema: ${config.schema}`);
11
+ lines.push('');
12
+ // Context section with comments
13
+ lines.push('# Project context (optional)');
14
+ lines.push('# This is shown to AI when creating artifacts.');
15
+ lines.push('# Add your tech stack, conventions, style guides, domain knowledge, etc.');
16
+ lines.push('# Example:');
17
+ lines.push('# context: |');
18
+ lines.push('# Tech stack: TypeScript, React, Node.js');
19
+ lines.push('# We use conventional commits');
20
+ lines.push('# Domain: e-commerce platform');
21
+ lines.push('');
22
+ // Rules section with comments
23
+ lines.push('# Per-artifact rules (optional)');
24
+ lines.push('# Add custom rules for specific artifacts.');
25
+ lines.push('# Example:');
26
+ lines.push('# rules:');
27
+ lines.push('# proposal:');
28
+ lines.push('# - Keep proposals under 500 words');
29
+ lines.push('# - Always include a "Non-goals" section');
30
+ lines.push('# tasks:');
31
+ lines.push('# - Break tasks into chunks of max 2 hours');
32
+ return lines.join('\n') + '\n';
33
+ }
34
+ //# sourceMappingURL=config-prompts.js.map
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Zod schema for global OpenSpec configuration.
4
+ * Uses passthrough() to preserve unknown fields for forward compatibility.
5
+ */
6
+ export declare const GlobalConfigSchema: z.ZodObject<{
7
+ featureFlags: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>>;
8
+ profile: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
9
+ core: "core";
10
+ custom: "custom";
11
+ }>>>;
12
+ delivery: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
13
+ commands: "commands";
14
+ skills: "skills";
15
+ both: "both";
16
+ }>>>;
17
+ workflows: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ }, z.core.$loose>;
19
+ export type GlobalConfigType = z.infer<typeof GlobalConfigSchema>;
20
+ /**
21
+ * Default configuration values.
22
+ */
23
+ export declare const DEFAULT_CONFIG: GlobalConfigType;
24
+ /**
25
+ * Validate a config key path for CLI set operations.
26
+ * Unknown top-level keys are rejected unless explicitly allowed by the caller.
27
+ */
28
+ export declare function validateConfigKeyPath(path: string): {
29
+ valid: boolean;
30
+ reason?: string;
31
+ };
32
+ /**
33
+ * Get a nested value from an object using dot notation.
34
+ *
35
+ * @param obj - The object to access
36
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
37
+ * @returns The value at the path, or undefined if not found
38
+ */
39
+ export declare function getNestedValue(obj: Record<string, unknown>, path: string): unknown;
40
+ /**
41
+ * Set a nested value in an object using dot notation.
42
+ * Creates intermediate objects as needed.
43
+ *
44
+ * @param obj - The object to modify (mutated in place)
45
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
46
+ * @param value - The value to set
47
+ */
48
+ export declare function setNestedValue(obj: Record<string, unknown>, path: string, value: unknown): void;
49
+ /**
50
+ * Delete a nested value from an object using dot notation.
51
+ *
52
+ * @param obj - The object to modify (mutated in place)
53
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
54
+ * @returns true if the key existed and was deleted, false otherwise
55
+ */
56
+ export declare function deleteNestedValue(obj: Record<string, unknown>, path: string): boolean;
57
+ /**
58
+ * Coerce a string value to its appropriate type.
59
+ * - "true" / "false" -> boolean
60
+ * - Numeric strings -> number
61
+ * - Everything else -> string
62
+ *
63
+ * @param value - The string value to coerce
64
+ * @param forceString - If true, always return the value as a string
65
+ * @returns The coerced value
66
+ */
67
+ export declare function coerceValue(value: string, forceString?: boolean): string | number | boolean;
68
+ /**
69
+ * Format a value for YAML-like display.
70
+ *
71
+ * @param value - The value to format
72
+ * @param indent - Current indentation level
73
+ * @returns Formatted string
74
+ */
75
+ export declare function formatValueYaml(value: unknown, indent?: number): string;
76
+ /**
77
+ * Validate a configuration object against the schema.
78
+ *
79
+ * @param config - The configuration to validate
80
+ * @returns Validation result with success status and optional error message
81
+ */
82
+ export declare function validateConfig(config: unknown): {
83
+ success: boolean;
84
+ error?: string;
85
+ };
86
+ //# sourceMappingURL=config-schema.d.ts.map
@@ -0,0 +1,213 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Zod schema for global AnchorSpec configuration.
4
+ * Uses passthrough() to preserve unknown fields for forward compatibility.
5
+ */
6
+ export const GlobalConfigSchema = z
7
+ .object({
8
+ featureFlags: z
9
+ .record(z.string(), z.boolean())
10
+ .optional()
11
+ .default({}),
12
+ profile: z
13
+ .enum(['core', 'custom'])
14
+ .optional()
15
+ .default('core'),
16
+ delivery: z
17
+ .enum(['both', 'skills', 'commands'])
18
+ .optional()
19
+ .default('both'),
20
+ workflows: z
21
+ .array(z.string())
22
+ .optional(),
23
+ })
24
+ .passthrough();
25
+ /**
26
+ * Default configuration values.
27
+ */
28
+ export const DEFAULT_CONFIG = {
29
+ featureFlags: {},
30
+ profile: 'core',
31
+ delivery: 'both',
32
+ };
33
+ const KNOWN_TOP_LEVEL_KEYS = new Set([...Object.keys(DEFAULT_CONFIG), 'workflows']);
34
+ /**
35
+ * Validate a config key path for CLI set operations.
36
+ * Unknown top-level keys are rejected unless explicitly allowed by the caller.
37
+ */
38
+ export function validateConfigKeyPath(path) {
39
+ const rawKeys = path.split('.');
40
+ if (rawKeys.length === 0 || rawKeys.some((key) => key.trim() === '')) {
41
+ return { valid: false, reason: 'Key path must not be empty' };
42
+ }
43
+ const rootKey = rawKeys[0];
44
+ if (!KNOWN_TOP_LEVEL_KEYS.has(rootKey)) {
45
+ return { valid: false, reason: `Unknown top-level key "${rootKey}"` };
46
+ }
47
+ if (rootKey === 'featureFlags') {
48
+ if (rawKeys.length > 2) {
49
+ return { valid: false, reason: 'featureFlags values are booleans and do not support nested keys' };
50
+ }
51
+ return { valid: true };
52
+ }
53
+ if (rawKeys.length > 1) {
54
+ return { valid: false, reason: `"${rootKey}" does not support nested keys` };
55
+ }
56
+ return { valid: true };
57
+ }
58
+ /**
59
+ * Get a nested value from an object using dot notation.
60
+ *
61
+ * @param obj - The object to access
62
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
63
+ * @returns The value at the path, or undefined if not found
64
+ */
65
+ export function getNestedValue(obj, path) {
66
+ const keys = path.split('.');
67
+ let current = obj;
68
+ for (const key of keys) {
69
+ if (current === null || current === undefined) {
70
+ return undefined;
71
+ }
72
+ if (typeof current !== 'object') {
73
+ return undefined;
74
+ }
75
+ current = current[key];
76
+ }
77
+ return current;
78
+ }
79
+ /**
80
+ * Set a nested value in an object using dot notation.
81
+ * Creates intermediate objects as needed.
82
+ *
83
+ * @param obj - The object to modify (mutated in place)
84
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
85
+ * @param value - The value to set
86
+ */
87
+ export function setNestedValue(obj, path, value) {
88
+ const keys = path.split('.');
89
+ let current = obj;
90
+ for (let i = 0; i < keys.length - 1; i++) {
91
+ const key = keys[i];
92
+ if (current[key] === undefined || current[key] === null || typeof current[key] !== 'object') {
93
+ current[key] = {};
94
+ }
95
+ current = current[key];
96
+ }
97
+ const lastKey = keys[keys.length - 1];
98
+ current[lastKey] = value;
99
+ }
100
+ /**
101
+ * Delete a nested value from an object using dot notation.
102
+ *
103
+ * @param obj - The object to modify (mutated in place)
104
+ * @param path - Dot-separated path (e.g., "featureFlags.someFlag")
105
+ * @returns true if the key existed and was deleted, false otherwise
106
+ */
107
+ export function deleteNestedValue(obj, path) {
108
+ const keys = path.split('.');
109
+ let current = obj;
110
+ for (let i = 0; i < keys.length - 1; i++) {
111
+ const key = keys[i];
112
+ if (current[key] === undefined || current[key] === null || typeof current[key] !== 'object') {
113
+ return false;
114
+ }
115
+ current = current[key];
116
+ }
117
+ const lastKey = keys[keys.length - 1];
118
+ if (lastKey in current) {
119
+ delete current[lastKey];
120
+ return true;
121
+ }
122
+ return false;
123
+ }
124
+ /**
125
+ * Coerce a string value to its appropriate type.
126
+ * - "true" / "false" -> boolean
127
+ * - Numeric strings -> number
128
+ * - Everything else -> string
129
+ *
130
+ * @param value - The string value to coerce
131
+ * @param forceString - If true, always return the value as a string
132
+ * @returns The coerced value
133
+ */
134
+ export function coerceValue(value, forceString = false) {
135
+ if (forceString) {
136
+ return value;
137
+ }
138
+ // Boolean coercion
139
+ if (value === 'true') {
140
+ return true;
141
+ }
142
+ if (value === 'false') {
143
+ return false;
144
+ }
145
+ // Number coercion - must be a valid finite number
146
+ const num = Number(value);
147
+ if (!isNaN(num) && isFinite(num) && value.trim() !== '') {
148
+ return num;
149
+ }
150
+ return value;
151
+ }
152
+ /**
153
+ * Format a value for YAML-like display.
154
+ *
155
+ * @param value - The value to format
156
+ * @param indent - Current indentation level
157
+ * @returns Formatted string
158
+ */
159
+ export function formatValueYaml(value, indent = 0) {
160
+ const indentStr = ' '.repeat(indent);
161
+ if (value === null || value === undefined) {
162
+ return 'null';
163
+ }
164
+ if (typeof value === 'boolean' || typeof value === 'number') {
165
+ return String(value);
166
+ }
167
+ if (typeof value === 'string') {
168
+ return value;
169
+ }
170
+ if (Array.isArray(value)) {
171
+ if (value.length === 0) {
172
+ return '[]';
173
+ }
174
+ return value.map((item) => `${indentStr}- ${formatValueYaml(item, indent + 1)}`).join('\n');
175
+ }
176
+ if (typeof value === 'object') {
177
+ const entries = Object.entries(value);
178
+ if (entries.length === 0) {
179
+ return '{}';
180
+ }
181
+ return entries
182
+ .map(([key, val]) => {
183
+ const formattedVal = formatValueYaml(val, indent + 1);
184
+ if (typeof val === 'object' && val !== null && Object.keys(val).length > 0) {
185
+ return `${indentStr}${key}:\n${formattedVal}`;
186
+ }
187
+ return `${indentStr}${key}: ${formattedVal}`;
188
+ })
189
+ .join('\n');
190
+ }
191
+ return String(value);
192
+ }
193
+ /**
194
+ * Validate a configuration object against the schema.
195
+ *
196
+ * @param config - The configuration to validate
197
+ * @returns Validation result with success status and optional error message
198
+ */
199
+ export function validateConfig(config) {
200
+ try {
201
+ GlobalConfigSchema.parse(config);
202
+ return { success: true };
203
+ }
204
+ catch (error) {
205
+ if (error instanceof z.ZodError) {
206
+ const zodError = error;
207
+ const messages = zodError.issues.map((e) => `${e.path.join('.')}: ${e.message}`);
208
+ return { success: false, error: messages.join('; ') };
209
+ }
210
+ return { success: false, error: 'Unknown validation error' };
211
+ }
212
+ }
213
+ //# sourceMappingURL=config-schema.js.map
@@ -0,0 +1,18 @@
1
+ export declare const OPENSPEC_DIR_NAME = "openspec";
2
+ export declare const OPENSPEC_MARKERS: {
3
+ start: string;
4
+ end: string;
5
+ };
6
+ export interface OpenSpecConfig {
7
+ aiTools: string[];
8
+ }
9
+ export interface AIToolOption {
10
+ name: string;
11
+ value: string;
12
+ available: boolean;
13
+ successLabel?: string;
14
+ skillsDir?: string;
15
+ detectionPaths?: string[];
16
+ }
17
+ export declare const AI_TOOLS: AIToolOption[];
18
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,37 @@
1
+ export const ANCHORSPEC_DIR_NAME = 'anchorspec';
2
+ export const ANCHORSPEC_MARKERS = {
3
+ start: '<!-- ANCHORSPEC:START -->',
4
+ end: '<!-- ANCHORSPEC:END -->'
5
+ };
6
+ export const AI_TOOLS = [
7
+ { name: 'Amazon Q Developer', value: 'amazon-q', available: true, successLabel: 'Amazon Q Developer', skillsDir: '.amazonq' },
8
+ { name: 'Antigravity', value: 'antigravity', available: true, successLabel: 'Antigravity', skillsDir: '.agent' },
9
+ { name: 'Auggie (Augment CLI)', value: 'auggie', available: true, successLabel: 'Auggie', skillsDir: '.augment' },
10
+ { name: 'Bob Shell', value: 'bob', available: true, successLabel: 'Bob Shell', skillsDir: '.bob' },
11
+ { name: 'Claude Code', value: 'claude', available: true, successLabel: 'Claude Code', skillsDir: '.claude' },
12
+ { name: 'Cline', value: 'cline', available: true, successLabel: 'Cline', skillsDir: '.cline' },
13
+ { name: 'Codex', value: 'codex', available: true, successLabel: 'Codex', skillsDir: '.codex' },
14
+ { name: 'ForgeCode', value: 'forgecode', available: true, successLabel: 'ForgeCode', skillsDir: '.forge' },
15
+ { name: 'CodeBuddy Code (CLI)', value: 'codebuddy', available: true, successLabel: 'CodeBuddy Code', skillsDir: '.codebuddy' },
16
+ { name: 'Continue', value: 'continue', available: true, successLabel: 'Continue (VS Code / JetBrains / Cli)', skillsDir: '.continue' },
17
+ { name: 'CoStrict', value: 'costrict', available: true, successLabel: 'CoStrict', skillsDir: '.cospec' },
18
+ { name: 'Crush', value: 'crush', available: true, successLabel: 'Crush', skillsDir: '.crush' },
19
+ { name: 'Cursor', value: 'cursor', available: true, successLabel: 'Cursor', skillsDir: '.cursor' },
20
+ { name: 'Factory Droid', value: 'factory', available: true, successLabel: 'Factory Droid', skillsDir: '.factory' },
21
+ { name: 'Gemini CLI', value: 'gemini', available: true, successLabel: 'Gemini CLI', skillsDir: '.gemini' },
22
+ { name: 'GitHub Copilot', value: 'github-copilot', available: true, successLabel: 'GitHub Copilot', skillsDir: '.github', detectionPaths: ['.github/copilot-instructions.md', '.github/instructions', '.github/workflows/copilot-setup-steps.yml', '.github/prompts', '.github/agents', '.github/skills', '.github/.mcp.json'] },
23
+ { name: 'iFlow', value: 'iflow', available: true, successLabel: 'iFlow', skillsDir: '.iflow' },
24
+ { name: 'Junie', value: 'junie', available: true, successLabel: 'Junie', skillsDir: '.junie' },
25
+ { name: 'Kilo Code', value: 'kilocode', available: true, successLabel: 'Kilo Code', skillsDir: '.kilocode' },
26
+ { name: 'Kiro', value: 'kiro', available: true, successLabel: 'Kiro', skillsDir: '.kiro' },
27
+ { name: 'OpenCode', value: 'opencode', available: true, successLabel: 'OpenCode', skillsDir: '.opencode' },
28
+ { name: 'Pi', value: 'pi', available: true, successLabel: 'Pi', skillsDir: '.pi' },
29
+ { name: 'Qoder', value: 'qoder', available: true, successLabel: 'Qoder', skillsDir: '.qoder' },
30
+ { name: 'Lingma', value: 'lingma', available: true, successLabel: 'Lingma', skillsDir: '.lingma' },
31
+ { name: 'Qwen Code', value: 'qwen', available: true, successLabel: 'Qwen Code', skillsDir: '.qwen' },
32
+ { name: 'RooCode', value: 'roocode', available: true, successLabel: 'RooCode', skillsDir: '.roo' },
33
+ { name: 'Trae', value: 'trae', available: true, successLabel: 'Trae', skillsDir: '.trae' },
34
+ { name: 'Windsurf', value: 'windsurf', available: true, successLabel: 'Windsurf', skillsDir: '.windsurf' },
35
+ { name: 'AGENTS.md (works with Amp, VS Code, …)', value: 'agents', available: false, successLabel: 'your AGENTS.md-compatible assistant' }
36
+ ];
37
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,6 @@
1
+ export declare class JsonConverter {
2
+ convertSpecToJson(filePath: string): string;
3
+ convertChangeToJson(filePath: string): Promise<string>;
4
+ private extractNameFromPath;
5
+ }
6
+ //# sourceMappingURL=json-converter.d.ts.map
@@ -0,0 +1,51 @@
1
+ import { readFileSync } from 'fs';
2
+ import path from 'path';
3
+ import { MarkdownParser } from '../parsers/markdown-parser.js';
4
+ import { ChangeParser } from '../parsers/change-parser.js';
5
+ import { FileSystemUtils } from '../../utils/file-system.js';
6
+ export class JsonConverter {
7
+ convertSpecToJson(filePath) {
8
+ const content = readFileSync(filePath, 'utf-8');
9
+ const parser = new MarkdownParser(content);
10
+ const specName = this.extractNameFromPath(filePath);
11
+ const spec = parser.parseSpec(specName);
12
+ const jsonSpec = {
13
+ ...spec,
14
+ metadata: {
15
+ ...spec.metadata,
16
+ sourcePath: filePath,
17
+ },
18
+ };
19
+ return JSON.stringify(jsonSpec, null, 2);
20
+ }
21
+ async convertChangeToJson(filePath) {
22
+ const content = readFileSync(filePath, 'utf-8');
23
+ const changeName = this.extractNameFromPath(filePath);
24
+ const changeDir = path.dirname(filePath);
25
+ const parser = new ChangeParser(content, changeDir);
26
+ const change = await parser.parseChangeWithDeltas(changeName);
27
+ const jsonChange = {
28
+ ...change,
29
+ metadata: {
30
+ ...change.metadata,
31
+ sourcePath: filePath,
32
+ },
33
+ };
34
+ return JSON.stringify(jsonChange, null, 2);
35
+ }
36
+ extractNameFromPath(filePath) {
37
+ const normalizedPath = FileSystemUtils.toPosixPath(filePath);
38
+ const parts = normalizedPath.split('/');
39
+ for (let i = parts.length - 1; i >= 0; i--) {
40
+ if (parts[i] === 'specs' || parts[i] === 'changes') {
41
+ if (i < parts.length - 1) {
42
+ return parts[i + 1];
43
+ }
44
+ }
45
+ }
46
+ const fileName = parts[parts.length - 1] ?? '';
47
+ const dotIndex = fileName.lastIndexOf('.');
48
+ return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
49
+ }
50
+ }
51
+ //# sourceMappingURL=json-converter.js.map
@@ -0,0 +1,44 @@
1
+ export declare const GLOBAL_CONFIG_DIR_NAME = "openspec";
2
+ export declare const GLOBAL_CONFIG_FILE_NAME = "config.json";
3
+ export declare const GLOBAL_DATA_DIR_NAME = "openspec";
4
+ export type Profile = 'core' | 'custom';
5
+ export type Delivery = 'both' | 'skills' | 'commands';
6
+ export interface GlobalConfig {
7
+ featureFlags?: Record<string, boolean>;
8
+ profile?: Profile;
9
+ delivery?: Delivery;
10
+ workflows?: string[];
11
+ }
12
+ /**
13
+ * Gets the global configuration directory path following XDG Base Directory Specification.
14
+ *
15
+ * - All platforms: $XDG_CONFIG_HOME/openspec/ if XDG_CONFIG_HOME is set
16
+ * - Unix/macOS fallback: ~/.config/openspec/
17
+ * - Windows fallback: %APPDATA%/openspec/
18
+ */
19
+ export declare function getGlobalConfigDir(): string;
20
+ /**
21
+ * Gets the global data directory path following XDG Base Directory Specification.
22
+ * Used for user data like schema overrides.
23
+ *
24
+ * - All platforms: $XDG_DATA_HOME/openspec/ if XDG_DATA_HOME is set
25
+ * - Unix/macOS fallback: ~/.local/share/openspec/
26
+ * - Windows fallback: %LOCALAPPDATA%/openspec/
27
+ */
28
+ export declare function getGlobalDataDir(): string;
29
+ /**
30
+ * Gets the path to the global config file.
31
+ */
32
+ export declare function getGlobalConfigPath(): string;
33
+ /**
34
+ * Loads the global configuration from disk.
35
+ * Returns default configuration if file doesn't exist or is invalid.
36
+ * Merges loaded config with defaults to ensure new fields are available.
37
+ */
38
+ export declare function getGlobalConfig(): GlobalConfig;
39
+ /**
40
+ * Saves the global configuration to disk.
41
+ * Creates the config directory if it doesn't exist.
42
+ */
43
+ export declare function saveGlobalConfig(config: GlobalConfig): void;
44
+ //# sourceMappingURL=global-config.d.ts.map