@llman-sdd/cli 0.8.2 → 0.10.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.
- package/package.json +2 -2
- package/src/cli-shared.ts +214 -45
- package/src/commands/archive.ts +61 -58
- package/src/commands/change.ts +321 -210
- package/src/commands/config.ts +35 -29
- package/src/commands/context.ts +67 -41
- package/src/commands/graph.ts +33 -21
- package/src/commands/index.ts +28 -18
- package/src/commands/init.ts +41 -11
- package/src/commands/list.ts +24 -18
- package/src/commands/project.ts +168 -78
- package/src/commands/review.ts +27 -26
- package/src/commands/self.ts +156 -0
- package/src/commands/show.ts +73 -37
- package/src/commands/spec.ts +155 -126
- package/src/commands/validate.ts +153 -89
- package/src/io.ts +7 -0
- package/src/main.ts +55 -50
- package/src/program.ts +83 -0
- package/src/progress.ts +14 -6
package/src/commands/show.ts
CHANGED
|
@@ -8,18 +8,23 @@ import {
|
|
|
8
8
|
renderMachine,
|
|
9
9
|
showChangeJson,
|
|
10
10
|
specIdOf,
|
|
11
|
+
discoverSpecs,
|
|
11
12
|
} from '@llman-sdd/core';
|
|
12
13
|
import type { Command } from 'commander';
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
addReportOutputOptions,
|
|
17
|
+
addSpecDirOption,
|
|
16
18
|
CliError,
|
|
17
19
|
cliMaxScanDepth,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
loadRootSpecEntries,
|
|
21
|
+
reRootContext,
|
|
22
|
+
specsPrefixFor,
|
|
23
|
+
resolveCommandRoot,
|
|
20
24
|
resolveChangeIdOrExit,
|
|
25
|
+
resolveRootSpecsDirTolerant,
|
|
26
|
+
type CliContext,
|
|
21
27
|
} from '../cli-shared.ts';
|
|
22
|
-
import { makeCliGit } from '../io.ts';
|
|
23
28
|
|
|
24
29
|
function hasSection(proposal: string, heading: string): boolean {
|
|
25
30
|
return (
|
|
@@ -29,7 +34,7 @@ function hasSection(proposal: string, heading: string): boolean {
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
function renderSpecJson(
|
|
32
|
-
entries: ReturnType<typeof
|
|
37
|
+
entries: ReturnType<typeof loadRootSpecEntries>,
|
|
33
38
|
item: string,
|
|
34
39
|
opts: { metaOnly: boolean; noScenarios: boolean },
|
|
35
40
|
): Record<string, unknown> {
|
|
@@ -97,13 +102,14 @@ function renderSpecJson(
|
|
|
97
102
|
};
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
export function registerShow(program: Command): void {
|
|
105
|
+
export function registerShow(program: Command, ctx: CliContext): void {
|
|
101
106
|
const show = program
|
|
102
107
|
.command('show')
|
|
103
108
|
.description('Show a change or spec')
|
|
104
109
|
.argument('<item>')
|
|
105
110
|
.option('--type <type>', 'force disambiguation: change | spec')
|
|
106
111
|
.option('-r, --requirement <n>', 'spec only: show a specific requirement by 1-based index');
|
|
112
|
+
addSpecDirOption(show);
|
|
107
113
|
addReportOutputOptions(show, {
|
|
108
114
|
outputHint: 'json | compact-json | toon | human | {json,meta-only|no-scenarios|reqs-only}',
|
|
109
115
|
});
|
|
@@ -116,6 +122,7 @@ export function registerShow(program: Command): void {
|
|
|
116
122
|
requirement?: string;
|
|
117
123
|
json?: boolean;
|
|
118
124
|
compactJson?: boolean;
|
|
125
|
+
directory?: string;
|
|
119
126
|
},
|
|
120
127
|
) => {
|
|
121
128
|
// D4 shared surface: the registered --json/--compact-json aliases feed
|
|
@@ -175,16 +182,32 @@ export function registerShow(program: Command): void {
|
|
|
175
182
|
// `.feature` 后缀的 fileName)命中;r25 spec id 精确匹配优先于 change 前缀,
|
|
176
183
|
// 不做模糊解析。
|
|
177
184
|
// Discover once per run — the spec lookup, summary and JSON render below
|
|
178
|
-
// all share these entries.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
// all share these entries. Lazy: a bare changes-only workspace has no
|
|
186
|
+
// resolvable instance root for the specs half, and the change path below
|
|
187
|
+
// must not require one (r109 root discovery gates specs, not changes).
|
|
188
|
+
type SpecEntries = ReturnType<typeof loadRootSpecEntries>;
|
|
189
|
+
let entriesCache: SpecEntries | null = null;
|
|
190
|
+
const specEntries = (): SpecEntries =>
|
|
191
|
+
(entriesCache ??= loadRootSpecEntries(undefined, ctx.io));
|
|
192
|
+
// spec discovery is attempted but a root-less workspace must not fail
|
|
193
|
+
// here — the change path below is root-independent until the spec half.
|
|
194
|
+
let specEntry: SpecEntries[number] | undefined;
|
|
195
|
+
// r115: the instance root resolved from `--directory` decides where the
|
|
196
|
+
// flat-spec probe, the spec source read and the change face below look —
|
|
197
|
+
// never the launch directory. Absent an instance the change face stays
|
|
198
|
+
// root-independent (changes-only workspace, r109).
|
|
199
|
+
let specRoot = ctx.root;
|
|
200
|
+
try {
|
|
201
|
+
specRoot = resolveCommandRoot(ctx, options.directory);
|
|
202
|
+
entriesCache ??= discoverSpecs(join(specRoot, 'llmanspec', 'specs'), ctx.io);
|
|
203
|
+
specEntry = entriesCache?.find((e) => specIdOf(e) === item);
|
|
204
|
+
} catch {
|
|
205
|
+
specEntry = undefined;
|
|
206
|
+
}
|
|
207
|
+
const flatSpecPath = join(specRoot, 'llmanspec', 'specs', `${item}.feature`);
|
|
208
|
+
const isSpec = options.type === 'spec' || existsSync(flatSpecPath) || specEntry !== undefined;
|
|
185
209
|
|
|
186
210
|
if (isSpec) {
|
|
187
|
-
const flatSpecPath = join('llmanspec', 'specs', `${item}.feature`);
|
|
188
211
|
// discoverSpecs 的 fileName 已是含 specs 目录前缀的相对路径
|
|
189
212
|
// (如 `llmanspec/specs/<cap>/<cap>.feature`),直接使用。
|
|
190
213
|
const specPath =
|
|
@@ -195,7 +218,7 @@ export function registerShow(program: Command): void {
|
|
|
195
218
|
if (asJson) {
|
|
196
219
|
console.log(
|
|
197
220
|
renderMachine(
|
|
198
|
-
renderSpecJson(
|
|
221
|
+
renderSpecJson(specEntries(), item, {
|
|
199
222
|
metaOnly,
|
|
200
223
|
noScenarios: noScenarios || reqsOnly,
|
|
201
224
|
}),
|
|
@@ -207,7 +230,7 @@ export function registerShow(program: Command): void {
|
|
|
207
230
|
// text mode: predecessor ignores all output modifiers (meta-only/no-scenarios/-r)
|
|
208
231
|
// and renders the full source + morphology.
|
|
209
232
|
const raw = readFileSync(specPath, 'utf8').trimEnd();
|
|
210
|
-
const summary = collectSpecs(
|
|
233
|
+
const summary = collectSpecs(specEntries()).find((x) => x.id === item);
|
|
211
234
|
const morphology = summary
|
|
212
235
|
? `\n\n## Morphology\nrequirements=${summary.requirementCount} bound=${summary.morphology.requirementBoundCount} unbound=${summary.morphology.requirementUnboundCount} acceptanceCount=${summary.morphology.acceptanceCount}`
|
|
213
236
|
: '';
|
|
@@ -217,10 +240,36 @@ export function registerShow(program: Command): void {
|
|
|
217
240
|
|
|
218
241
|
// ---- change ----
|
|
219
242
|
// r61: predecessor r112 prefix chain — exact > unique prefix > multiple > not found.
|
|
220
|
-
|
|
243
|
+
// r115: id resolution, the proposal read and the phase collection all use
|
|
244
|
+
// the resolved instance root; git stays repo-level (r118: branch is a
|
|
245
|
+
// git-level notion, not an instance-root one).
|
|
246
|
+
let rctx = ctx;
|
|
247
|
+
try {
|
|
248
|
+
rctx = reRootContext(ctx, options.directory);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
// changes-only workspace (no config.yaml / specs/): the change path is
|
|
251
|
+
// root-independent, but an explicitly named root must resolve (r109).
|
|
252
|
+
if (options.directory !== undefined) throw error;
|
|
253
|
+
}
|
|
254
|
+
const resolved = resolveChangeIdOrExit(rctx, program, item, { suppressHint: asJson });
|
|
221
255
|
const changeId = resolved.id;
|
|
222
256
|
const viaPrefix = resolved.viaPrefix;
|
|
223
|
-
const proposal = readFileSync(
|
|
257
|
+
const proposal = readFileSync(
|
|
258
|
+
join(rctx.root, 'llmanspec', 'changes', changeId, 'proposal.md'),
|
|
259
|
+
'utf8',
|
|
260
|
+
);
|
|
261
|
+
// r115: ONE dependency set for the change path, built from the resolved
|
|
262
|
+
// instance root — io/git/root are the re-rooted ones and the spec gate
|
|
263
|
+
// reads THAT instance's registry (derived from this very io). Both
|
|
264
|
+
// output faces share it, so they can never disagree on a gate.
|
|
265
|
+
const deps = {
|
|
266
|
+
io: rctx.io,
|
|
267
|
+
git: rctx.git,
|
|
268
|
+
root: rctx.root,
|
|
269
|
+
specsDir: resolveRootSpecsDirTolerant(rctx),
|
|
270
|
+
// r119: the specs-landed gate judges under this instance's prefix.
|
|
271
|
+
specsPrefix: specsPrefixFor(rctx),
|
|
272
|
+
};
|
|
224
273
|
if (asJson) {
|
|
225
274
|
// predecessor parse_change gates: Why first, then What Changes (json only).
|
|
226
275
|
if (!hasSection(proposal, 'Why')) {
|
|
@@ -229,21 +278,12 @@ export function registerShow(program: Command): void {
|
|
|
229
278
|
if (!hasSection(proposal, 'What Changes')) {
|
|
230
279
|
throw new CliError('Change must have a What Changes section');
|
|
231
280
|
}
|
|
232
|
-
const result = showChangeJson(
|
|
233
|
-
{
|
|
234
|
-
io: newIo(),
|
|
235
|
-
git: makeCliGit(process.cwd()),
|
|
236
|
-
root: process.cwd(),
|
|
237
|
-
specsDir: 'llmanspec/specs',
|
|
238
|
-
},
|
|
239
|
-
changeId,
|
|
240
|
-
{ matchedViaPrefix: viaPrefix },
|
|
241
|
-
);
|
|
281
|
+
const result = showChangeJson(deps, changeId, { matchedViaPrefix: viaPrefix });
|
|
242
282
|
console.log(renderMachine(result, showMode));
|
|
243
283
|
return;
|
|
244
284
|
}
|
|
245
285
|
// text: Stage / path / content / Gates trailer (no section gates).
|
|
246
|
-
const changes = collectChanges(
|
|
286
|
+
const changes = collectChanges(rctx.io, rctx.root, new Date(), {
|
|
247
287
|
maxScanDepth: cliMaxScanDepth(program),
|
|
248
288
|
});
|
|
249
289
|
const change = changes.find((c) => c.name === changeId);
|
|
@@ -251,15 +291,11 @@ export function registerShow(program: Command): void {
|
|
|
251
291
|
console.log(`path: ${changeId}`);
|
|
252
292
|
process.stdout.write(proposal);
|
|
253
293
|
if (!proposal.endsWith('\n')) console.log();
|
|
254
|
-
const gates = showChangeJson(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
specsDir: 'llmanspec/specs',
|
|
260
|
-
},
|
|
261
|
-
changeId,
|
|
262
|
-
).gateChecks as { name: string; pass: boolean; hint: string }[];
|
|
294
|
+
const gates = showChangeJson(deps, changeId).gateChecks as {
|
|
295
|
+
name: string;
|
|
296
|
+
pass: boolean;
|
|
297
|
+
hint: string;
|
|
298
|
+
}[];
|
|
263
299
|
const passCount = gates.filter((g) => g.pass).length;
|
|
264
300
|
console.log(`Gates: ${passCount}/${gates.length} pass`);
|
|
265
301
|
for (const g of gates.filter((g) => !g.pass)) console.log(`✗ ${g.name}: ${g.hint}`);
|
package/src/commands/spec.ts
CHANGED
|
@@ -3,27 +3,30 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
DEFAULT_LOCALE,
|
|
6
7
|
addReq,
|
|
7
8
|
addScenario,
|
|
8
9
|
buildUnboundFeed,
|
|
9
10
|
hasNativeRules,
|
|
10
11
|
migrateNativeSource,
|
|
11
12
|
nextReqId,
|
|
12
|
-
renderMachine,
|
|
13
13
|
resolveReq,
|
|
14
14
|
scaffoldSpec,
|
|
15
|
+
TRANSITIONS_INTROSPECTION,
|
|
15
16
|
type UnboundFeed,
|
|
16
17
|
} from '@llman-sdd/core';
|
|
17
18
|
import type { Command } from 'commander';
|
|
18
19
|
|
|
19
20
|
import {
|
|
20
21
|
addReportOutputOptions,
|
|
22
|
+
addSpecDirOption,
|
|
21
23
|
CliError,
|
|
22
24
|
loadCliConfig,
|
|
23
25
|
loadRootSpecEntries,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
emitReport,
|
|
27
|
+
resolveCommandRoot,
|
|
26
28
|
resolveRootSpecsDir,
|
|
29
|
+
type CliContext,
|
|
27
30
|
} from '../cli-shared.ts';
|
|
28
31
|
|
|
29
32
|
/** Walk paths collecting .feature files (directories recurse). */
|
|
@@ -54,80 +57,77 @@ function confirmInteractive(question: string): Promise<boolean> {
|
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
export function registerSpec(program: Command): void {
|
|
60
|
+
export function registerSpec(program: Command, ctx: CliContext): void {
|
|
58
61
|
const spec = program.command('spec').description('Spec authoring helpers');
|
|
59
62
|
|
|
60
|
-
spec
|
|
63
|
+
const skeleton = spec
|
|
61
64
|
.command('skeleton')
|
|
62
65
|
.description('Generate a single-track spec skeleton for a capability')
|
|
63
66
|
.argument('<capability>')
|
|
64
|
-
.option('--force', 'overwrite an existing spec file')
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
force: options.force,
|
|
78
|
-
});
|
|
79
|
-
console.log(`wrote ${written}`);
|
|
67
|
+
.option('--force', 'overwrite an existing spec file');
|
|
68
|
+
addSpecDirOption(skeleton);
|
|
69
|
+
skeleton.action((capability: string, options: { force?: boolean; directory?: string }) => {
|
|
70
|
+
// r109/r115: locale 属命中实例根的配置,`--directory` 指向子根时不得读启动根
|
|
71
|
+
const locale =
|
|
72
|
+
loadCliConfig(resolveCommandRoot(ctx, options.directory))?.locale ?? DEFAULT_LOCALE;
|
|
73
|
+
const specsDir = resolveRootSpecsDir(options.directory, ctx.io);
|
|
74
|
+
const path = join(specsDir, `${capability}.feature`);
|
|
75
|
+
if (!options.force && existsSync(path)) {
|
|
76
|
+
throw new CliError(`spec already exists: ${path} (use --force to overwrite)`);
|
|
77
|
+
}
|
|
78
|
+
const written = scaffoldSpec(ctx.io, specsDir, capability, locale, {
|
|
79
|
+
force: options.force,
|
|
80
80
|
});
|
|
81
|
+
console.log(`wrote ${written}`);
|
|
82
|
+
});
|
|
81
83
|
|
|
82
|
-
spec
|
|
84
|
+
const nextReq = spec
|
|
83
85
|
.command('next-req-id')
|
|
84
|
-
.description('Allocate the next global req id (max in use + 1, rN)')
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
else console.log(reqId);
|
|
94
|
-
});
|
|
86
|
+
.description('Allocate the next global req id (max in use + 1, rN)');
|
|
87
|
+
addReportOutputOptions(nextReq, { outputHint: 'json {reqId}; toon default' });
|
|
88
|
+
addSpecDirOption(nextReq);
|
|
89
|
+
nextReq.action(
|
|
90
|
+
(options: { json?: boolean; output?: string; compactJson?: boolean; directory?: string }) => {
|
|
91
|
+
const reqId = nextReqId(ctx.io, resolveRootSpecsDir(options.directory, ctx.io));
|
|
92
|
+
emitReport({ reqId }, options, () => reqId);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
95
|
|
|
96
|
-
spec
|
|
96
|
+
const addReqCmd = spec
|
|
97
97
|
.command('add-req')
|
|
98
98
|
.alias('add-requirement')
|
|
99
99
|
.description('Append a 规则: block (with @req handle) to a capability spec')
|
|
100
100
|
.argument('<capability>')
|
|
101
101
|
.argument('<req_id>')
|
|
102
102
|
.requiredOption('--title <title>', 'rule title')
|
|
103
|
-
.requiredOption(
|
|
104
|
-
|
|
105
|
-
'
|
|
106
|
-
'instance root resolution start (default: nearest llmanspec/ at or above cwd)',
|
|
107
|
-
)
|
|
108
|
-
.action(
|
|
109
|
-
(
|
|
110
|
-
capability: string,
|
|
111
|
-
reqId: string,
|
|
112
|
-
options: { title: string; statement: string; directory?: string },
|
|
113
|
-
) => {
|
|
114
|
-
const io = newIo();
|
|
115
|
-
const path = addReq(
|
|
116
|
-
io,
|
|
117
|
-
resolveRootSpecsDir(options.directory),
|
|
118
|
-
loadRootSpecEntries(options.directory),
|
|
119
|
-
{
|
|
120
|
-
capability,
|
|
121
|
-
reqId,
|
|
122
|
-
title: options.title,
|
|
123
|
-
statement: options.statement,
|
|
124
|
-
},
|
|
125
|
-
);
|
|
126
|
-
console.log(path);
|
|
127
|
-
},
|
|
103
|
+
.requiredOption(
|
|
104
|
+
'--statement <statement>',
|
|
105
|
+
'rule statement (free text; multiple lines via \\n)',
|
|
128
106
|
);
|
|
107
|
+
addSpecDirOption(addReqCmd);
|
|
108
|
+
addReqCmd.action(
|
|
109
|
+
(
|
|
110
|
+
capability: string,
|
|
111
|
+
reqId: string,
|
|
112
|
+
options: { title: string; statement: string; directory?: string },
|
|
113
|
+
) => {
|
|
114
|
+
const io = ctx.io;
|
|
115
|
+
const path = addReq(
|
|
116
|
+
io,
|
|
117
|
+
resolveRootSpecsDir(options.directory, ctx.io),
|
|
118
|
+
loadRootSpecEntries(options.directory, ctx.io),
|
|
119
|
+
{
|
|
120
|
+
capability,
|
|
121
|
+
reqId,
|
|
122
|
+
title: options.title,
|
|
123
|
+
statement: options.statement,
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
console.log(path);
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
129
|
|
|
130
|
-
spec
|
|
130
|
+
const addScenarioCmd = spec
|
|
131
131
|
.command('add-scenario')
|
|
132
132
|
.description('Insert a nested 场景: under the named rule in a spec')
|
|
133
133
|
.argument('<capability>')
|
|
@@ -135,45 +135,47 @@ export function registerSpec(program: Command): void {
|
|
|
135
135
|
.argument('<scenario_id>')
|
|
136
136
|
.option('--given <given>', 'Given step (optional)')
|
|
137
137
|
.requiredOption('--when <when>', 'When step')
|
|
138
|
-
.requiredOption('--then <then>', 'Then step')
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
console.log(path);
|
|
165
|
-
},
|
|
166
|
-
);
|
|
138
|
+
.requiredOption('--then <then>', 'Then step');
|
|
139
|
+
addSpecDirOption(addScenarioCmd);
|
|
140
|
+
addScenarioCmd.action(
|
|
141
|
+
(
|
|
142
|
+
capability: string,
|
|
143
|
+
reqId: string,
|
|
144
|
+
scenarioId: string,
|
|
145
|
+
options: { given?: string; when: string; then: string; directory?: string },
|
|
146
|
+
) => {
|
|
147
|
+
const io = ctx.io;
|
|
148
|
+
const path = addScenario(
|
|
149
|
+
io,
|
|
150
|
+
resolveRootSpecsDir(options.directory, ctx.io),
|
|
151
|
+
loadRootSpecEntries(options.directory, ctx.io),
|
|
152
|
+
{
|
|
153
|
+
capability,
|
|
154
|
+
reqId,
|
|
155
|
+
scenarioId,
|
|
156
|
+
given: options.given,
|
|
157
|
+
when: options.when,
|
|
158
|
+
thenText: options.then,
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
console.log(path);
|
|
162
|
+
},
|
|
163
|
+
);
|
|
167
164
|
|
|
168
|
-
spec
|
|
165
|
+
const migrateNative = spec
|
|
169
166
|
.command('migrate-native')
|
|
170
167
|
.description('Migrate legacy tag-based .feature files to the native 规则:/场景: layout')
|
|
171
168
|
.argument('[paths...]', 'feature files or directories (default: llmanspec/specs)')
|
|
172
169
|
.option('--dry-run', 'print the migration plan without writing')
|
|
173
|
-
.option('-y, --yes', 'proceed without per-file confirmation')
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
.option('-y, --yes', 'proceed without per-file confirmation');
|
|
171
|
+
addSpecDirOption(migrateNative);
|
|
172
|
+
migrateNative.action(
|
|
173
|
+
async (paths: string[], options: { dryRun?: boolean; yes?: boolean; directory?: string }) => {
|
|
174
|
+
// r116: 显式传入的路径按参数原义处理(豁免);缺省目标才经根发现算子
|
|
175
|
+
const targets = collectFeatureFiles(
|
|
176
|
+
paths.length > 0 ? paths : [resolveRootSpecsDir(options.directory, ctx.io)],
|
|
177
|
+
);
|
|
178
|
+
const io = ctx.io;
|
|
177
179
|
let migrated = 0;
|
|
178
180
|
let skipped = 0;
|
|
179
181
|
for (const file of targets) {
|
|
@@ -204,53 +206,80 @@ export function registerSpec(program: Command): void {
|
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
console.log(`migrate-native: ${migrated} file(s) migrated, ${skipped} already native`);
|
|
207
|
-
}
|
|
209
|
+
},
|
|
210
|
+
);
|
|
208
211
|
|
|
209
|
-
spec
|
|
212
|
+
const resolveReqCmd = spec
|
|
210
213
|
.command('resolve-req')
|
|
211
214
|
.description('Resolve an rN to its capability and statement')
|
|
212
|
-
.argument('<req_id>')
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
215
|
+
.argument('<req_id>');
|
|
216
|
+
addSpecDirOption(resolveReqCmd);
|
|
217
|
+
resolveReqCmd.action((reqId: string, options: { directory?: string }) => {
|
|
218
|
+
const resolved = resolveReq(loadRootSpecEntries(options.directory, ctx.io), reqId);
|
|
219
|
+
if (resolved === null) {
|
|
220
|
+
throw new CliError(`req id not found: ${reqId}`);
|
|
221
|
+
}
|
|
222
|
+
console.log(`reqId: ${resolved.reqId}`);
|
|
223
|
+
console.log(`capability: ${resolved.capability}`);
|
|
224
|
+
console.log(`title: ${resolved.title}`);
|
|
225
|
+
console.log(`statement: ${resolved.statement.replaceAll('\n', ' ')}`);
|
|
226
|
+
console.log('harness:');
|
|
227
|
+
for (const h of resolved.harness) console.log(` - ${h}`);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const transitions = spec
|
|
231
|
+
.command('transitions')
|
|
232
|
+
.description('Show transition-table validation rules: alias families, tags, gates');
|
|
233
|
+
addSpecDirOption(transitions);
|
|
234
|
+
transitions.action((options: { directory?: string }) => {
|
|
235
|
+
// r109: 本命令输出为静态内省,无实例根语义;仍按「豁免外全部命令声明并接受
|
|
236
|
+
// --directory」声明该选项,并仅在显式给出时经同一根发现算子校验(无实例报域错误)。
|
|
237
|
+
if (options.directory !== undefined) resolveCommandRoot(ctx, options.directory);
|
|
238
|
+
const info = TRANSITIONS_INTROSPECTION;
|
|
239
|
+
console.log('columns:');
|
|
240
|
+
for (const fam of info.columnFamilies) {
|
|
241
|
+
const optional = 'optional' in fam && fam.optional ? ' (optional)' : '';
|
|
242
|
+
console.log(` ${fam.role}${optional}: ${fam.aliases.join(' | ')}`);
|
|
243
|
+
}
|
|
244
|
+
console.log(`discovery: ${info.discovery}`);
|
|
245
|
+
console.log('tags:');
|
|
246
|
+
for (const t of info.tags) console.log(` ${t.tag} — ${t.semantics}`);
|
|
247
|
+
console.log('gates:');
|
|
248
|
+
for (const g of info.gates) console.log(` - ${g}`);
|
|
249
|
+
});
|
|
229
250
|
|
|
230
251
|
const unbound = spec
|
|
231
252
|
.command('unbound')
|
|
232
253
|
.description('List unbound requirements (no runnable nested scenario) for implementation')
|
|
233
254
|
.option('--limit <N>', 'max entries to return (default 1; 0 = all)');
|
|
234
255
|
addReportOutputOptions(unbound);
|
|
256
|
+
addSpecDirOption(unbound);
|
|
235
257
|
unbound.action(
|
|
236
|
-
(options: {
|
|
258
|
+
(options: {
|
|
259
|
+
limit?: string;
|
|
260
|
+
output?: string;
|
|
261
|
+
json?: boolean;
|
|
262
|
+
compactJson?: boolean;
|
|
263
|
+
directory?: string;
|
|
264
|
+
}) => {
|
|
237
265
|
const raw = options.limit ?? '1';
|
|
238
266
|
if (!/^\d+$/u.test(raw)) {
|
|
239
267
|
throw new CliError(`invalid --limit: ${raw} (non-negative integer)`, 2);
|
|
240
268
|
}
|
|
241
269
|
const limit = Number(raw);
|
|
242
|
-
const feed: UnboundFeed = buildUnboundFeed(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
270
|
+
const feed: UnboundFeed = buildUnboundFeed(
|
|
271
|
+
loadRootSpecEntries(options.directory, ctx.io),
|
|
272
|
+
limit,
|
|
273
|
+
);
|
|
274
|
+
emitReport(feed, options, () => {
|
|
275
|
+
const lines = [`spec unbound: ${feed.returned} shown of ${feed.total} total`];
|
|
276
|
+
for (const r of feed.requirements) {
|
|
277
|
+
lines.push(` - [${r.reqId}] ${r.featurePath} :: ${r.title}`);
|
|
278
|
+
for (const line of r.statement.split('\n')) lines.push(` ${line}`);
|
|
279
|
+
}
|
|
280
|
+
if (feed.hint !== '') lines.push(feed.hint);
|
|
281
|
+
return lines.join('\n');
|
|
282
|
+
});
|
|
254
283
|
},
|
|
255
284
|
);
|
|
256
285
|
}
|