@zhuan-ai/zhuanspec 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 (210) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +461 -0
  3. package/README.zh.md +434 -0
  4. package/bin/zhuanspec.js +3 -0
  5. package/dist/cli/index.d.ts +2 -0
  6. package/dist/cli/index.js +356 -0
  7. package/dist/commands/artifact-workflow.d.ts +13 -0
  8. package/dist/commands/artifact-workflow.js +916 -0
  9. package/dist/commands/change.d.ts +35 -0
  10. package/dist/commands/change.js +277 -0
  11. package/dist/commands/completion.d.ts +72 -0
  12. package/dist/commands/completion.js +221 -0
  13. package/dist/commands/config.d.ts +8 -0
  14. package/dist/commands/config.js +198 -0
  15. package/dist/commands/show.d.ts +14 -0
  16. package/dist/commands/show.js +132 -0
  17. package/dist/commands/spec.d.ts +15 -0
  18. package/dist/commands/spec.js +225 -0
  19. package/dist/commands/validate.d.ts +24 -0
  20. package/dist/commands/validate.js +294 -0
  21. package/dist/core/archive.d.ts +30 -0
  22. package/dist/core/archive.js +438 -0
  23. package/dist/core/artifact-graph/graph.d.ts +56 -0
  24. package/dist/core/artifact-graph/graph.js +141 -0
  25. package/dist/core/artifact-graph/index.d.ts +7 -0
  26. package/dist/core/artifact-graph/index.js +13 -0
  27. package/dist/core/artifact-graph/instruction-loader.d.ts +134 -0
  28. package/dist/core/artifact-graph/instruction-loader.js +180 -0
  29. package/dist/core/artifact-graph/resolver.d.ts +61 -0
  30. package/dist/core/artifact-graph/resolver.js +187 -0
  31. package/dist/core/artifact-graph/schema.d.ts +13 -0
  32. package/dist/core/artifact-graph/schema.js +108 -0
  33. package/dist/core/artifact-graph/state.d.ts +12 -0
  34. package/dist/core/artifact-graph/state.js +54 -0
  35. package/dist/core/artifact-graph/types.d.ts +45 -0
  36. package/dist/core/artifact-graph/types.js +43 -0
  37. package/dist/core/completions/command-registry.d.ts +7 -0
  38. package/dist/core/completions/command-registry.js +362 -0
  39. package/dist/core/completions/completion-provider.d.ts +60 -0
  40. package/dist/core/completions/completion-provider.js +102 -0
  41. package/dist/core/completions/factory.d.ts +51 -0
  42. package/dist/core/completions/factory.js +57 -0
  43. package/dist/core/completions/generators/zsh-generator.d.ts +58 -0
  44. package/dist/core/completions/generators/zsh-generator.js +319 -0
  45. package/dist/core/completions/installers/zsh-installer.d.ts +136 -0
  46. package/dist/core/completions/installers/zsh-installer.js +449 -0
  47. package/dist/core/completions/types.d.ts +78 -0
  48. package/dist/core/completions/types.js +2 -0
  49. package/dist/core/config-schema.d.ts +76 -0
  50. package/dist/core/config-schema.js +200 -0
  51. package/dist/core/config.d.ts +16 -0
  52. package/dist/core/config.js +29 -0
  53. package/dist/core/configurators/agents.d.ts +8 -0
  54. package/dist/core/configurators/agents.js +15 -0
  55. package/dist/core/configurators/base.d.ts +7 -0
  56. package/dist/core/configurators/base.js +2 -0
  57. package/dist/core/configurators/claude.d.ts +8 -0
  58. package/dist/core/configurators/claude.js +15 -0
  59. package/dist/core/configurators/cline.d.ts +8 -0
  60. package/dist/core/configurators/cline.js +15 -0
  61. package/dist/core/configurators/codebuddy.d.ts +8 -0
  62. package/dist/core/configurators/codebuddy.js +15 -0
  63. package/dist/core/configurators/costrict.d.ts +8 -0
  64. package/dist/core/configurators/costrict.js +15 -0
  65. package/dist/core/configurators/iflow.d.ts +8 -0
  66. package/dist/core/configurators/iflow.js +15 -0
  67. package/dist/core/configurators/qoder.d.ts +30 -0
  68. package/dist/core/configurators/qoder.js +42 -0
  69. package/dist/core/configurators/qwen.d.ts +24 -0
  70. package/dist/core/configurators/qwen.js +37 -0
  71. package/dist/core/configurators/registry.d.ts +9 -0
  72. package/dist/core/configurators/registry.js +43 -0
  73. package/dist/core/configurators/slash/amazon-q.d.ts +9 -0
  74. package/dist/core/configurators/slash/amazon-q.js +46 -0
  75. package/dist/core/configurators/slash/antigravity.d.ts +9 -0
  76. package/dist/core/configurators/slash/antigravity.js +23 -0
  77. package/dist/core/configurators/slash/auggie.d.ts +9 -0
  78. package/dist/core/configurators/slash/auggie.js +31 -0
  79. package/dist/core/configurators/slash/base.d.ts +19 -0
  80. package/dist/core/configurators/slash/base.js +69 -0
  81. package/dist/core/configurators/slash/claude.d.ts +9 -0
  82. package/dist/core/configurators/slash/claude.js +37 -0
  83. package/dist/core/configurators/slash/cline.d.ts +9 -0
  84. package/dist/core/configurators/slash/cline.js +23 -0
  85. package/dist/core/configurators/slash/codebuddy.d.ts +9 -0
  86. package/dist/core/configurators/slash/codebuddy.js +37 -0
  87. package/dist/core/configurators/slash/codex.d.ts +14 -0
  88. package/dist/core/configurators/slash/codex.js +109 -0
  89. package/dist/core/configurators/slash/costrict.d.ts +9 -0
  90. package/dist/core/configurators/slash/costrict.js +31 -0
  91. package/dist/core/configurators/slash/crush.d.ts +9 -0
  92. package/dist/core/configurators/slash/crush.js +37 -0
  93. package/dist/core/configurators/slash/cursor.d.ts +9 -0
  94. package/dist/core/configurators/slash/cursor.js +37 -0
  95. package/dist/core/configurators/slash/factory.d.ts +10 -0
  96. package/dist/core/configurators/slash/factory.js +35 -0
  97. package/dist/core/configurators/slash/gemini.d.ts +9 -0
  98. package/dist/core/configurators/slash/gemini.js +22 -0
  99. package/dist/core/configurators/slash/github-copilot.d.ts +9 -0
  100. package/dist/core/configurators/slash/github-copilot.js +34 -0
  101. package/dist/core/configurators/slash/iflow.d.ts +9 -0
  102. package/dist/core/configurators/slash/iflow.js +37 -0
  103. package/dist/core/configurators/slash/kilocode.d.ts +9 -0
  104. package/dist/core/configurators/slash/kilocode.js +17 -0
  105. package/dist/core/configurators/slash/opencode.d.ts +12 -0
  106. package/dist/core/configurators/slash/opencode.js +72 -0
  107. package/dist/core/configurators/slash/qoder.d.ts +35 -0
  108. package/dist/core/configurators/slash/qoder.js +76 -0
  109. package/dist/core/configurators/slash/qwen.d.ts +32 -0
  110. package/dist/core/configurators/slash/qwen.js +49 -0
  111. package/dist/core/configurators/slash/registry.d.ts +8 -0
  112. package/dist/core/configurators/slash/registry.js +75 -0
  113. package/dist/core/configurators/slash/roocode.d.ts +9 -0
  114. package/dist/core/configurators/slash/roocode.js +23 -0
  115. package/dist/core/configurators/slash/toml-base.d.ts +10 -0
  116. package/dist/core/configurators/slash/toml-base.js +53 -0
  117. package/dist/core/configurators/slash/windsurf.d.ts +9 -0
  118. package/dist/core/configurators/slash/windsurf.js +23 -0
  119. package/dist/core/converters/json-converter.d.ts +6 -0
  120. package/dist/core/converters/json-converter.js +51 -0
  121. package/dist/core/global-config.d.ts +39 -0
  122. package/dist/core/global-config.js +115 -0
  123. package/dist/core/index.d.ts +2 -0
  124. package/dist/core/index.js +3 -0
  125. package/dist/core/init.d.ts +60 -0
  126. package/dist/core/init.js +861 -0
  127. package/dist/core/list.d.ts +9 -0
  128. package/dist/core/list.js +171 -0
  129. package/dist/core/parsers/change-parser.d.ts +13 -0
  130. package/dist/core/parsers/change-parser.js +193 -0
  131. package/dist/core/parsers/markdown-parser.d.ts +22 -0
  132. package/dist/core/parsers/markdown-parser.js +187 -0
  133. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  134. package/dist/core/parsers/requirement-blocks.js +201 -0
  135. package/dist/core/project-config.d.ts +34 -0
  136. package/dist/core/project-config.js +79 -0
  137. package/dist/core/schemas/base.schema.d.ts +13 -0
  138. package/dist/core/schemas/base.schema.js +13 -0
  139. package/dist/core/schemas/change.schema.d.ts +73 -0
  140. package/dist/core/schemas/change.schema.js +31 -0
  141. package/dist/core/schemas/index.d.ts +4 -0
  142. package/dist/core/schemas/index.js +4 -0
  143. package/dist/core/schemas/spec.schema.d.ts +18 -0
  144. package/dist/core/schemas/spec.schema.js +15 -0
  145. package/dist/core/skill-discovery.d.ts +24 -0
  146. package/dist/core/skill-discovery.js +153 -0
  147. package/dist/core/specs-apply.d.ts +73 -0
  148. package/dist/core/specs-apply.js +384 -0
  149. package/dist/core/styles/palette.d.ts +7 -0
  150. package/dist/core/styles/palette.js +8 -0
  151. package/dist/core/templates/agents-root-stub.d.ts +2 -0
  152. package/dist/core/templates/agents-root-stub.js +17 -0
  153. package/dist/core/templates/agents-template.d.ts +2 -0
  154. package/dist/core/templates/agents-template.js +706 -0
  155. package/dist/core/templates/claude-template.d.ts +2 -0
  156. package/dist/core/templates/claude-template.js +2 -0
  157. package/dist/core/templates/cline-template.d.ts +2 -0
  158. package/dist/core/templates/cline-template.js +2 -0
  159. package/dist/core/templates/costrict-template.d.ts +2 -0
  160. package/dist/core/templates/costrict-template.js +2 -0
  161. package/dist/core/templates/index.d.ts +17 -0
  162. package/dist/core/templates/index.js +37 -0
  163. package/dist/core/templates/project-template.d.ts +8 -0
  164. package/dist/core/templates/project-template.js +32 -0
  165. package/dist/core/templates/skill-templates.d.ts +103 -0
  166. package/dist/core/templates/skill-templates.js +2131 -0
  167. package/dist/core/templates/slash-command-templates.d.ts +4 -0
  168. package/dist/core/templates/slash-command-templates.js +81 -0
  169. package/dist/core/update.d.ts +4 -0
  170. package/dist/core/update.js +88 -0
  171. package/dist/core/validation/constants.d.ts +34 -0
  172. package/dist/core/validation/constants.js +40 -0
  173. package/dist/core/validation/types.d.ts +18 -0
  174. package/dist/core/validation/types.js +2 -0
  175. package/dist/core/validation/validator.d.ts +33 -0
  176. package/dist/core/validation/validator.js +409 -0
  177. package/dist/core/view.d.ts +8 -0
  178. package/dist/core/view.js +168 -0
  179. package/dist/index.d.ts +3 -0
  180. package/dist/index.js +3 -0
  181. package/dist/utils/change-metadata.d.ts +47 -0
  182. package/dist/utils/change-metadata.js +130 -0
  183. package/dist/utils/change-utils.d.ts +51 -0
  184. package/dist/utils/change-utils.js +100 -0
  185. package/dist/utils/file-system.d.ts +19 -0
  186. package/dist/utils/file-system.js +177 -0
  187. package/dist/utils/index.d.ts +4 -0
  188. package/dist/utils/index.js +5 -0
  189. package/dist/utils/interactive.d.ts +18 -0
  190. package/dist/utils/interactive.js +21 -0
  191. package/dist/utils/item-discovery.d.ts +4 -0
  192. package/dist/utils/item-discovery.js +72 -0
  193. package/dist/utils/match.d.ts +3 -0
  194. package/dist/utils/match.js +22 -0
  195. package/dist/utils/shell-detection.d.ts +20 -0
  196. package/dist/utils/shell-detection.js +41 -0
  197. package/dist/utils/task-progress.d.ts +8 -0
  198. package/dist/utils/task-progress.js +36 -0
  199. package/package.json +81 -0
  200. package/schemas/spec-driven/schema.yaml +205 -0
  201. package/schemas/spec-driven/templates/design.md +19 -0
  202. package/schemas/spec-driven/templates/proposal.md +43 -0
  203. package/schemas/spec-driven/templates/spec.md +8 -0
  204. package/schemas/spec-driven/templates/tasks.md +25 -0
  205. package/schemas/tdd/schema.yaml +213 -0
  206. package/schemas/tdd/templates/docs.md +0 -0
  207. package/schemas/tdd/templates/implementation.md +11 -0
  208. package/schemas/tdd/templates/spec.md +11 -0
  209. package/schemas/tdd/templates/test.md +11 -0
  210. package/scripts/postinstall.js +147 -0
@@ -0,0 +1,356 @@
1
+ import { Command } from 'commander';
2
+ import { createRequire } from 'module';
3
+ import ora from 'ora';
4
+ import path from 'path';
5
+ import { promises as fs } from 'fs';
6
+ import { AI_TOOLS } from '../core/config.js';
7
+ import { UpdateCommand } from '../core/update.js';
8
+ import { ListCommand } from '../core/list.js';
9
+ import { ArchiveCommand } from '../core/archive.js';
10
+ import { ViewCommand } from '../core/view.js';
11
+ import { registerSpecCommand } from '../commands/spec.js';
12
+ import { ChangeCommand } from '../commands/change.js';
13
+ import { ValidateCommand } from '../commands/validate.js';
14
+ import { ShowCommand } from '../commands/show.js';
15
+ import { CompletionCommand } from '../commands/completion.js';
16
+ import { discoverSkills, formatSkillsList } from '../core/skill-discovery.js';
17
+ import { registerConfigCommand } from '../commands/config.js';
18
+ import { registerArtifactWorkflowCommands } from '../commands/artifact-workflow.js';
19
+ const program = new Command();
20
+ const require = createRequire(import.meta.url);
21
+ const { version } = require('../../package.json');
22
+ program
23
+ .name('zhuanspec')
24
+ .description('AI-native system for spec-driven development')
25
+ .version(version);
26
+ // Global options
27
+ program.option('--no-color', 'Disable color output');
28
+ // Apply global flags before any command runs
29
+ program.hook('preAction', (thisCommand) => {
30
+ const opts = thisCommand.opts();
31
+ if (opts.color === false) {
32
+ process.env.NO_COLOR = '1';
33
+ }
34
+ });
35
+ const availableToolIds = AI_TOOLS.filter((tool) => tool.available).map((tool) => tool.value);
36
+ const toolsOptionDescription = `Configure AI tools non-interactively. Use "all", "none", or a comma-separated list of: ${availableToolIds.join(', ')}`;
37
+ program
38
+ .command('init [path]')
39
+ .description('Initialize ZhuanSpec in your project')
40
+ .option('--tools <tools>', toolsOptionDescription)
41
+ .option('--business-direction <direction>', 'Business direction for fetching project architecture (e.g., oms, ass)')
42
+ .action(async (targetPath = '.', options) => {
43
+ try {
44
+ // Validate that the path is a valid directory
45
+ const resolvedPath = path.resolve(targetPath);
46
+ try {
47
+ const stats = await fs.stat(resolvedPath);
48
+ if (!stats.isDirectory()) {
49
+ throw new Error(`Path "${targetPath}" is not a directory`);
50
+ }
51
+ }
52
+ catch (error) {
53
+ if (error.code === 'ENOENT') {
54
+ // Directory doesn't exist, but we can create it
55
+ console.log(`Directory "${targetPath}" doesn't exist, it will be created.`);
56
+ }
57
+ else if (error.message && error.message.includes('not a directory')) {
58
+ throw error;
59
+ }
60
+ else {
61
+ throw new Error(`Cannot access path "${targetPath}": ${error.message}`);
62
+ }
63
+ }
64
+ const { InitCommand } = await import('../core/init.js');
65
+ const initCommand = new InitCommand({
66
+ tools: options?.tools,
67
+ businessDirection: options?.businessDirection,
68
+ });
69
+ await initCommand.execute(targetPath);
70
+ }
71
+ catch (error) {
72
+ console.log(); // Empty line for spacing
73
+ ora().fail(`Error: ${error.message}`);
74
+ process.exit(1);
75
+ }
76
+ });
77
+ program
78
+ .command('update [path]')
79
+ .description('Update ZhuanSpec instruction files')
80
+ .action(async (targetPath = '.') => {
81
+ try {
82
+ const resolvedPath = path.resolve(targetPath);
83
+ const updateCommand = new UpdateCommand();
84
+ await updateCommand.execute(resolvedPath);
85
+ }
86
+ catch (error) {
87
+ console.log(); // Empty line for spacing
88
+ ora().fail(`Error: ${error.message}`);
89
+ process.exit(1);
90
+ }
91
+ });
92
+ program
93
+ .command('list')
94
+ .description('List items (changes by default). Use --specs to list specs.')
95
+ .option('--specs', 'List specs instead of changes')
96
+ .option('--changes', 'List changes explicitly (default)')
97
+ .option('--sort <order>', 'Sort order: "recent" (default) or "name"', 'recent')
98
+ .option('--json', 'Output as JSON (for programmatic use)')
99
+ .action(async (options) => {
100
+ try {
101
+ const listCommand = new ListCommand();
102
+ const mode = options?.specs ? 'specs' : 'changes';
103
+ const sort = options?.sort === 'name' ? 'name' : 'recent';
104
+ await listCommand.execute('.', mode, { sort, json: options?.json });
105
+ }
106
+ catch (error) {
107
+ console.log(); // Empty line for spacing
108
+ ora().fail(`Error: ${error.message}`);
109
+ process.exit(1);
110
+ }
111
+ });
112
+ program
113
+ .command('view')
114
+ .description('Display an interactive dashboard of specs and changes')
115
+ .action(async () => {
116
+ try {
117
+ const viewCommand = new ViewCommand();
118
+ await viewCommand.execute('.');
119
+ }
120
+ catch (error) {
121
+ console.log(); // Empty line for spacing
122
+ ora().fail(`Error: ${error.message}`);
123
+ process.exit(1);
124
+ }
125
+ });
126
+ // Change command with subcommands
127
+ const changeCmd = program
128
+ .command('change')
129
+ .description('Manage ZhuanSpec change proposals');
130
+ // Deprecation notice for noun-based commands
131
+ changeCmd.hook('preAction', () => {
132
+ console.error('Warning: The "zhuanspec change ..." commands are deprecated. Prefer verb-first commands (e.g., "zhuanspec list", "zhuanspec validate --changes").');
133
+ });
134
+ changeCmd
135
+ .command('show [change-name]')
136
+ .description('Show a change proposal in JSON or markdown format')
137
+ .option('--json', 'Output as JSON')
138
+ .option('--deltas-only', 'Show only deltas (JSON only)')
139
+ .option('--requirements-only', 'Alias for --deltas-only (deprecated)')
140
+ .option('--no-interactive', 'Disable interactive prompts')
141
+ .action(async (changeName, options) => {
142
+ try {
143
+ const changeCommand = new ChangeCommand();
144
+ await changeCommand.show(changeName, options);
145
+ }
146
+ catch (error) {
147
+ console.error(`Error: ${error.message}`);
148
+ process.exitCode = 1;
149
+ }
150
+ });
151
+ changeCmd
152
+ .command('list')
153
+ .description('List all active changes (DEPRECATED: use "zhuanspec list" instead)')
154
+ .option('--json', 'Output as JSON')
155
+ .option('--long', 'Show id and title with counts')
156
+ .action(async (options) => {
157
+ try {
158
+ console.error('Warning: "zhuanspec change list" is deprecated. Use "zhuanspec list".');
159
+ const changeCommand = new ChangeCommand();
160
+ await changeCommand.list(options);
161
+ }
162
+ catch (error) {
163
+ console.error(`Error: ${error.message}`);
164
+ process.exitCode = 1;
165
+ }
166
+ });
167
+ changeCmd
168
+ .command('validate [change-name]')
169
+ .description('Validate a change proposal')
170
+ .option('--strict', 'Enable strict validation mode')
171
+ .option('--json', 'Output validation report as JSON')
172
+ .option('--no-interactive', 'Disable interactive prompts')
173
+ .action(async (changeName, options) => {
174
+ try {
175
+ const changeCommand = new ChangeCommand();
176
+ await changeCommand.validate(changeName, options);
177
+ if (typeof process.exitCode === 'number' && process.exitCode !== 0) {
178
+ process.exit(process.exitCode);
179
+ }
180
+ }
181
+ catch (error) {
182
+ console.error(`Error: ${error.message}`);
183
+ process.exitCode = 1;
184
+ }
185
+ });
186
+ program
187
+ .command('archive [change-name]')
188
+ .description('Archive a completed change and update main specs')
189
+ .option('-y, --yes', 'Skip confirmation prompts')
190
+ .option('--skip-specs', 'Skip spec update operations (useful for infrastructure, tooling, or doc-only changes)')
191
+ .option('--no-validate', 'Skip validation (not recommended, requires confirmation)')
192
+ .action(async (changeName, options) => {
193
+ try {
194
+ const archiveCommand = new ArchiveCommand();
195
+ await archiveCommand.execute(changeName, options);
196
+ }
197
+ catch (error) {
198
+ console.log(); // Empty line for spacing
199
+ ora().fail(`Error: ${error.message}`);
200
+ process.exit(1);
201
+ }
202
+ });
203
+ program
204
+ .command('bulk-archive')
205
+ .description('Archive multiple completed changes at once with conflict detection')
206
+ .option('-y, --yes', 'Skip confirmation prompts and archive all active changes')
207
+ .option('--skip-specs', 'Skip spec update operations')
208
+ .option('--no-validate', 'Skip validation (not recommended)')
209
+ .action(async (options) => {
210
+ try {
211
+ const archiveCommand = new ArchiveCommand();
212
+ await archiveCommand.bulkArchive(options);
213
+ }
214
+ catch (error) {
215
+ console.log();
216
+ ora().fail(`Error: ${error.message}`);
217
+ process.exit(1);
218
+ }
219
+ });
220
+ // Skills commands
221
+ const skillsCmd = program
222
+ .command('skills')
223
+ .description('Manage and discover skills');
224
+ skillsCmd
225
+ .command('list')
226
+ .description('Discover available skills by scanning known skill directories')
227
+ .option('--json', 'Output as JSON for programmatic use')
228
+ .action(async (options) => {
229
+ try {
230
+ const skills = discoverSkills();
231
+ console.log(formatSkillsList(skills, !!options?.json));
232
+ }
233
+ catch (error) {
234
+ console.log();
235
+ ora().fail(`Error: ${error.message}`);
236
+ process.exit(1);
237
+ }
238
+ });
239
+ registerSpecCommand(program);
240
+ registerConfigCommand(program);
241
+ // Top-level validate command
242
+ program
243
+ .command('validate [item-name]')
244
+ .description('Validate changes and specs')
245
+ .option('--all', 'Validate all changes and specs')
246
+ .option('--changes', 'Validate all changes')
247
+ .option('--specs', 'Validate all specs')
248
+ .option('--type <type>', 'Specify item type when ambiguous: change|spec')
249
+ .option('--strict', 'Enable strict validation mode')
250
+ .option('--json', 'Output validation results as JSON')
251
+ .option('--concurrency <n>', 'Max concurrent validations (defaults to env OPENSPEC_CONCURRENCY or 6)')
252
+ .option('--no-interactive', 'Disable interactive prompts')
253
+ .action(async (itemName, options) => {
254
+ try {
255
+ const validateCommand = new ValidateCommand();
256
+ await validateCommand.execute(itemName, options);
257
+ }
258
+ catch (error) {
259
+ console.log();
260
+ ora().fail(`Error: ${error.message}`);
261
+ process.exit(1);
262
+ }
263
+ });
264
+ // Top-level show command
265
+ program
266
+ .command('show [item-name]')
267
+ .description('Show a change or spec')
268
+ .option('--json', 'Output as JSON')
269
+ .option('--type <type>', 'Specify item type when ambiguous: change|spec')
270
+ .option('--no-interactive', 'Disable interactive prompts')
271
+ // change-only flags
272
+ .option('--deltas-only', 'Show only deltas (JSON only, change)')
273
+ .option('--requirements-only', 'Alias for --deltas-only (deprecated, change)')
274
+ // spec-only flags
275
+ .option('--requirements', 'JSON only: Show only requirements (exclude scenarios)')
276
+ .option('--no-scenarios', 'JSON only: Exclude scenario content')
277
+ .option('-r, --requirement <id>', 'JSON only: Show specific requirement by ID (1-based)')
278
+ // allow unknown options to pass-through to underlying command implementation
279
+ .allowUnknownOption(true)
280
+ .action(async (itemName, options) => {
281
+ try {
282
+ const showCommand = new ShowCommand();
283
+ await showCommand.execute(itemName, options ?? {});
284
+ }
285
+ catch (error) {
286
+ console.log();
287
+ ora().fail(`Error: ${error.message}`);
288
+ process.exit(1);
289
+ }
290
+ });
291
+ // Completion command with subcommands
292
+ const completionCmd = program
293
+ .command('completion')
294
+ .description('Manage shell completions for ZhuanSpec CLI');
295
+ completionCmd
296
+ .command('generate [shell]')
297
+ .description('Generate completion script for a shell (outputs to stdout)')
298
+ .action(async (shell) => {
299
+ try {
300
+ const completionCommand = new CompletionCommand();
301
+ await completionCommand.generate({ shell });
302
+ }
303
+ catch (error) {
304
+ console.log();
305
+ ora().fail(`Error: ${error.message}`);
306
+ process.exit(1);
307
+ }
308
+ });
309
+ completionCmd
310
+ .command('install [shell]')
311
+ .description('Install completion script for a shell')
312
+ .option('--verbose', 'Show detailed installation output')
313
+ .action(async (shell, options) => {
314
+ try {
315
+ const completionCommand = new CompletionCommand();
316
+ await completionCommand.install({ shell, verbose: options?.verbose });
317
+ }
318
+ catch (error) {
319
+ console.log();
320
+ ora().fail(`Error: ${error.message}`);
321
+ process.exit(1);
322
+ }
323
+ });
324
+ completionCmd
325
+ .command('uninstall [shell]')
326
+ .description('Uninstall completion script for a shell')
327
+ .option('-y, --yes', 'Skip confirmation prompts')
328
+ .action(async (shell, options) => {
329
+ try {
330
+ const completionCommand = new CompletionCommand();
331
+ await completionCommand.uninstall({ shell, yes: options?.yes });
332
+ }
333
+ catch (error) {
334
+ console.log();
335
+ ora().fail(`Error: ${error.message}`);
336
+ process.exit(1);
337
+ }
338
+ });
339
+ // Hidden command for machine-readable completion data
340
+ program
341
+ .command('__complete <type>', { hidden: true })
342
+ .description('Output completion data in machine-readable format (internal use)')
343
+ .action(async (type) => {
344
+ try {
345
+ const completionCommand = new CompletionCommand();
346
+ await completionCommand.complete({ type });
347
+ }
348
+ catch (error) {
349
+ // Silently fail for graceful shell completion experience
350
+ process.exitCode = 1;
351
+ }
352
+ });
353
+ // Register artifact workflow commands
354
+ registerArtifactWorkflowCommands(program);
355
+ program.parse();
356
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Artifact Workflow CLI Commands
3
+ *
4
+ * This file contains all artifact workflow commands.
5
+ * Commands expose the ArtifactGraph and InstructionLoader APIs to users and agents.
6
+ */
7
+ import type { Command } from 'commander';
8
+ /**
9
+ * Registers all artifact workflow commands on the given program.
10
+ * All commands are marked as experimental in their help text.
11
+ */
12
+ export declare function registerArtifactWorkflowCommands(program: Command): void;
13
+ //# sourceMappingURL=artifact-workflow.d.ts.map