@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,294 @@
1
+ import ora from 'ora';
2
+ import path from 'path';
3
+ import { Validator } from '../core/validation/validator.js';
4
+ import { isInteractive, resolveNoInteractive } from '../utils/interactive.js';
5
+ import { getActiveChangeIds, getSpecIds } from '../utils/item-discovery.js';
6
+ import { nearestMatches } from '../utils/match.js';
7
+ export class ValidateCommand {
8
+ async execute(itemName, options = {}) {
9
+ const interactive = isInteractive(options);
10
+ // Handle bulk flags first
11
+ if (options.all || options.changes || options.specs) {
12
+ await this.runBulkValidation({
13
+ changes: !!options.all || !!options.changes,
14
+ specs: !!options.all || !!options.specs,
15
+ }, { strict: !!options.strict, json: !!options.json, concurrency: options.concurrency, noInteractive: resolveNoInteractive(options) });
16
+ return;
17
+ }
18
+ // No item and no flags
19
+ if (!itemName) {
20
+ if (interactive) {
21
+ await this.runInteractiveSelector({ strict: !!options.strict, json: !!options.json, concurrency: options.concurrency });
22
+ return;
23
+ }
24
+ this.printNonInteractiveHint();
25
+ process.exitCode = 1;
26
+ return;
27
+ }
28
+ // Direct item validation with type detection or override
29
+ const typeOverride = this.normalizeType(options.type);
30
+ await this.validateDirectItem(itemName, { typeOverride, strict: !!options.strict, json: !!options.json });
31
+ }
32
+ normalizeType(value) {
33
+ if (!value)
34
+ return undefined;
35
+ const v = value.toLowerCase();
36
+ if (v === 'change' || v === 'spec')
37
+ return v;
38
+ return undefined;
39
+ }
40
+ async runInteractiveSelector(opts) {
41
+ const { select } = await import('@inquirer/prompts');
42
+ const choice = await select({
43
+ message: '您想验证什么?',
44
+ choices: [
45
+ { name: '全部(变更 + 规范)', value: 'all' },
46
+ { name: '所有变更', value: 'changes' },
47
+ { name: '所有规范', value: 'specs' },
48
+ { name: '选择特定的变更或规范', value: 'one' },
49
+ ],
50
+ });
51
+ if (choice === 'all')
52
+ return this.runBulkValidation({ changes: true, specs: true }, opts);
53
+ if (choice === 'changes')
54
+ return this.runBulkValidation({ changes: true, specs: false }, opts);
55
+ if (choice === 'specs')
56
+ return this.runBulkValidation({ changes: false, specs: true }, opts);
57
+ // one
58
+ const [changes, specs] = await Promise.all([getActiveChangeIds(), getSpecIds()]);
59
+ const items = [];
60
+ items.push(...changes.map(id => ({ name: `change/${id}`, value: { type: 'change', id } })));
61
+ items.push(...specs.map(id => ({ name: `spec/${id}`, value: { type: 'spec', id } })));
62
+ if (items.length === 0) {
63
+ console.error('未找到要验证的项目。');
64
+ process.exitCode = 1;
65
+ return;
66
+ }
67
+ const picked = await select({ message: '选择项目', choices: items });
68
+ await this.validateByType(picked.type, picked.id, opts);
69
+ }
70
+ printNonInteractiveHint() {
71
+ console.error('没有可验证的内容。请尝试以下之一:');
72
+ console.error(' zhuanspec validate --all');
73
+ console.error(' zhuanspec validate --changes');
74
+ console.error(' zhuanspec validate --specs');
75
+ console.error(' zhuanspec validate <item-name>');
76
+ console.error('Or run in an interactive terminal.');
77
+ }
78
+ async validateDirectItem(itemName, opts) {
79
+ const [changes, specs] = await Promise.all([getActiveChangeIds(), getSpecIds()]);
80
+ const isChange = changes.includes(itemName);
81
+ const isSpec = specs.includes(itemName);
82
+ const type = opts.typeOverride ?? (isChange ? 'change' : isSpec ? 'spec' : undefined);
83
+ if (!type) {
84
+ console.error(`未知项目 '${itemName}'`);
85
+ const suggestions = nearestMatches(itemName, [...changes, ...specs]);
86
+ if (suggestions.length)
87
+ console.error(`您是指:${suggestions.join(', ')}?`);
88
+ process.exitCode = 1;
89
+ return;
90
+ }
91
+ if (!opts.typeOverride && isChange && isSpec) {
92
+ console.error(`项目 '${itemName}' 既匹配变更又匹配规范,存在歧义。`);
93
+ console.error('请传递 --type change|spec,或使用:zhuanspec change validate / zhuanspec spec validate');
94
+ process.exitCode = 1;
95
+ return;
96
+ }
97
+ await this.validateByType(type, itemName, opts);
98
+ }
99
+ async validateByType(type, id, opts) {
100
+ const validator = new Validator(opts.strict);
101
+ if (type === 'change') {
102
+ const changeDir = path.join(process.cwd(), 'zhuanspec', 'changes', id);
103
+ const start = Date.now();
104
+ const report = await validator.validateChangeDeltaSpecs(changeDir);
105
+ const durationMs = Date.now() - start;
106
+ this.printReport('change', id, report, durationMs, opts.json);
107
+ // Non-zero exit if invalid (keeps enriched output test semantics)
108
+ process.exitCode = report.valid ? 0 : 1;
109
+ return;
110
+ }
111
+ const file = path.join(process.cwd(), 'zhuanspec', 'specs', id, 'spec.md');
112
+ const start = Date.now();
113
+ const report = await validator.validateSpec(file);
114
+ const durationMs = Date.now() - start;
115
+ this.printReport('spec', id, report, durationMs, opts.json);
116
+ process.exitCode = report.valid ? 0 : 1;
117
+ }
118
+ printReport(type, id, report, durationMs, json) {
119
+ if (json) {
120
+ const out = { items: [{ id, type, valid: report.valid, issues: report.issues, durationMs }], summary: { totals: { items: 1, passed: report.valid ? 1 : 0, failed: report.valid ? 0 : 1 }, byType: { [type]: { items: 1, passed: report.valid ? 1 : 0, failed: report.valid ? 0 : 1 } } }, version: '1.0' };
121
+ console.log(JSON.stringify(out, null, 2));
122
+ return;
123
+ }
124
+ if (report.valid) {
125
+ console.log(`${type === 'change' ? 'Change' : 'Specification'} '${id}' is valid`);
126
+ }
127
+ else {
128
+ console.error(`${type === 'change' ? 'Change' : 'Specification'} '${id}' has issues`);
129
+ for (const issue of report.issues) {
130
+ const label = issue.level === 'ERROR' ? 'ERROR' : issue.level;
131
+ const prefix = issue.level === 'ERROR' ? '✗' : issue.level === 'WARNING' ? '⚠' : 'ℹ';
132
+ console.error(`${prefix} [${label}] ${issue.path}: ${issue.message}`);
133
+ }
134
+ this.printNextSteps(type);
135
+ }
136
+ }
137
+ printNextSteps(type) {
138
+ const bullets = [];
139
+ if (type === 'change') {
140
+ bullets.push('- Ensure change has deltas in specs/: use headers ## ADDED/MODIFIED/REMOVED/RENAMED Requirements');
141
+ bullets.push('- Each requirement MUST include at least one #### Scenario: block');
142
+ bullets.push('- Debug parsed deltas: zhuanspec change show <id> --json --deltas-only');
143
+ }
144
+ else {
145
+ bullets.push('- Ensure spec includes ## Purpose and ## Requirements sections');
146
+ bullets.push('- Each requirement MUST include at least one #### Scenario: block');
147
+ bullets.push('- Re-run with --json to see structured report');
148
+ }
149
+ console.error('Next steps:');
150
+ bullets.forEach(b => console.error(` ${b}`));
151
+ }
152
+ async runBulkValidation(scope, opts) {
153
+ const spinner = !opts.json && !opts.noInteractive ? ora('Validating...').start() : undefined;
154
+ const [changeIds, specIds] = await Promise.all([
155
+ scope.changes ? getActiveChangeIds() : Promise.resolve([]),
156
+ scope.specs ? getSpecIds() : Promise.resolve([]),
157
+ ]);
158
+ const DEFAULT_CONCURRENCY = 6;
159
+ const maxSuggestions = 5; // used by nearestMatches
160
+ const concurrency = normalizeConcurrency(opts.concurrency) ?? normalizeConcurrency(process.env.OPENSPEC_CONCURRENCY) ?? DEFAULT_CONCURRENCY;
161
+ const validator = new Validator(opts.strict);
162
+ const queue = [];
163
+ for (const id of changeIds) {
164
+ queue.push(async () => {
165
+ const start = Date.now();
166
+ const changeDir = path.join(process.cwd(), 'zhuanspec', 'changes', id);
167
+ const report = await validator.validateChangeDeltaSpecs(changeDir);
168
+ const durationMs = Date.now() - start;
169
+ return { id, type: 'change', valid: report.valid, issues: report.issues, durationMs };
170
+ });
171
+ }
172
+ for (const id of specIds) {
173
+ queue.push(async () => {
174
+ const start = Date.now();
175
+ const file = path.join(process.cwd(), 'zhuanspec', 'specs', id, 'spec.md');
176
+ const report = await validator.validateSpec(file);
177
+ const durationMs = Date.now() - start;
178
+ return { id, type: 'spec', valid: report.valid, issues: report.issues, durationMs };
179
+ });
180
+ }
181
+ if (queue.length === 0) {
182
+ spinner?.stop();
183
+ const summary = {
184
+ totals: { items: 0, passed: 0, failed: 0 },
185
+ byType: {
186
+ ...(scope.changes ? { change: { items: 0, passed: 0, failed: 0 } } : {}),
187
+ ...(scope.specs ? { spec: { items: 0, passed: 0, failed: 0 } } : {}),
188
+ },
189
+ };
190
+ if (opts.json) {
191
+ const out = { items: [], summary, version: '1.0' };
192
+ console.log(JSON.stringify(out, null, 2));
193
+ }
194
+ else {
195
+ console.log('No items found to validate.');
196
+ }
197
+ process.exitCode = 0;
198
+ return;
199
+ }
200
+ const results = [];
201
+ let index = 0;
202
+ let running = 0;
203
+ let passed = 0;
204
+ let failed = 0;
205
+ await new Promise((resolve) => {
206
+ const next = () => {
207
+ while (running < concurrency && index < queue.length) {
208
+ const currentIndex = index++;
209
+ const task = queue[currentIndex];
210
+ running++;
211
+ if (spinner)
212
+ spinner.text = `Validating (${currentIndex + 1}/${queue.length})...`;
213
+ task()
214
+ .then(res => {
215
+ results.push(res);
216
+ if (res.valid)
217
+ passed++;
218
+ else
219
+ failed++;
220
+ })
221
+ .catch((error) => {
222
+ const message = error?.message || 'Unknown error';
223
+ const res = { id: getPlannedId(currentIndex, changeIds, specIds) ?? 'unknown', type: getPlannedType(currentIndex, changeIds, specIds) ?? 'change', valid: false, issues: [{ level: 'ERROR', path: 'file', message }], durationMs: 0 };
224
+ results.push(res);
225
+ failed++;
226
+ })
227
+ .finally(() => {
228
+ running--;
229
+ if (index >= queue.length && running === 0)
230
+ resolve();
231
+ else
232
+ next();
233
+ });
234
+ }
235
+ };
236
+ next();
237
+ });
238
+ spinner?.stop();
239
+ results.sort((a, b) => a.id.localeCompare(b.id));
240
+ const summary = {
241
+ totals: { items: results.length, passed, failed },
242
+ byType: {
243
+ ...(scope.changes ? { change: summarizeType(results, 'change') } : {}),
244
+ ...(scope.specs ? { spec: summarizeType(results, 'spec') } : {}),
245
+ },
246
+ };
247
+ if (opts.json) {
248
+ const out = { items: results, summary, version: '1.0' };
249
+ console.log(JSON.stringify(out, null, 2));
250
+ }
251
+ else {
252
+ for (const res of results) {
253
+ if (res.valid)
254
+ console.log(`✓ ${res.type}/${res.id}`);
255
+ else
256
+ console.error(`✗ ${res.type}/${res.id}`);
257
+ }
258
+ console.log(`Totals: ${summary.totals.passed} passed, ${summary.totals.failed} failed (${summary.totals.items} items)`);
259
+ }
260
+ process.exitCode = failed > 0 ? 1 : 0;
261
+ }
262
+ }
263
+ function summarizeType(results, type) {
264
+ const filtered = results.filter(r => r.type === type);
265
+ const items = filtered.length;
266
+ const passed = filtered.filter(r => r.valid).length;
267
+ const failed = items - passed;
268
+ return { items, passed, failed };
269
+ }
270
+ function normalizeConcurrency(value) {
271
+ if (!value)
272
+ return undefined;
273
+ const n = parseInt(value, 10);
274
+ if (Number.isNaN(n) || n <= 0)
275
+ return undefined;
276
+ return n;
277
+ }
278
+ function getPlannedId(index, changeIds, specIds) {
279
+ const totalChanges = changeIds.length;
280
+ if (index < totalChanges)
281
+ return changeIds[index];
282
+ const specIndex = index - totalChanges;
283
+ return specIds[specIndex];
284
+ }
285
+ function getPlannedType(index, changeIds, specIds) {
286
+ const totalChanges = changeIds.length;
287
+ if (index < totalChanges)
288
+ return 'change';
289
+ const specIndex = index - totalChanges;
290
+ if (specIndex >= 0 && specIndex < specIds.length)
291
+ return 'spec';
292
+ return undefined;
293
+ }
294
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,30 @@
1
+ export declare class ArchiveCommand {
2
+ execute(changeName?: string, options?: {
3
+ yes?: boolean;
4
+ skipSpecs?: boolean;
5
+ noValidate?: boolean;
6
+ validate?: boolean;
7
+ }): Promise<void>;
8
+ /**
9
+ * Move a directory, falling back to copy+remove when rename fails
10
+ * (e.g., across devices, network drives, or permission issues).
11
+ */
12
+ private moveDirectory;
13
+ /**
14
+ * Recursively copy a directory.
15
+ */
16
+ private copyDirectoryRecursive;
17
+ private selectChange;
18
+ private getArchiveDate;
19
+ /**
20
+ * Bulk archive multiple completed changes at once.
21
+ * Lists all active changes, lets user select multiple, then archives them sequentially.
22
+ */
23
+ bulkArchive(options?: {
24
+ yes?: boolean;
25
+ skipSpecs?: boolean;
26
+ noValidate?: boolean;
27
+ validate?: boolean;
28
+ }): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=archive.d.ts.map