@llman-sdd/cli 0.10.1 → 0.12.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 (48) hide show
  1. package/package.json +13 -5
  2. package/src/cli-shared.ts +87 -62
  3. package/src/commands/archive.ts +4 -19
  4. package/src/commands/change.ts +132 -172
  5. package/src/commands/config.ts +1 -29
  6. package/src/commands/init.ts +39 -11
  7. package/src/commands/list.ts +0 -2
  8. package/src/commands/project.ts +25 -115
  9. package/src/commands/review.ts +0 -1
  10. package/src/commands/self.ts +3 -1
  11. package/src/commands/show.ts +8 -46
  12. package/src/commands/spec.ts +6 -86
  13. package/src/commands/studio.ts +1315 -0
  14. package/src/commands/studioMcp.ts +862 -0
  15. package/src/commands/studioShared.ts +87 -0
  16. package/src/commands/theorem-write.ts +608 -0
  17. package/src/commands/theorem.ts +479 -0
  18. package/src/commands/validate.ts +108 -47
  19. package/src/io.ts +0 -1
  20. package/src/main.ts +3 -18
  21. package/src/program.ts +16 -16
  22. package/src/progress.ts +1 -3
  23. package/src/studio-server/changeScope.ts +295 -0
  24. package/src/studio-server/hub.ts +98 -0
  25. package/src/studio-server/negotiate.ts +60 -0
  26. package/src/studio-server/security.ts +71 -0
  27. package/src/studio-server/server.ts +1694 -0
  28. package/src/studio-server/static.ts +184 -0
  29. package/src/studio-server/syncDisk.ts +116 -0
  30. package/src/theorems/base.ts +53 -0
  31. package/src/theorems/diagnose.ts +90 -0
  32. package/src/theorems/draft.ts +252 -0
  33. package/src/theorems/os-lock.ts +364 -0
  34. package/src/theorems/paths.ts +11 -0
  35. package/src/theorems/prompts.ts +79 -0
  36. package/src/theorems/quiet.ts +21 -0
  37. package/src/theorems/runner.ts +48 -0
  38. package/src/theorems/transaction.ts +272 -0
  39. package/src/theorems/workspace.ts +103 -0
  40. package/studio-dist/index.html +14 -0
  41. package/studio-dist/static/css/index.00cf48cf.css +1 -0
  42. package/studio-dist/static/js/610.51883f69.js +218 -0
  43. package/studio-dist/static/js/610.51883f69.js.LICENSE.txt +26 -0
  44. package/studio-dist/static/js/index.c5f7c530.js +13 -0
  45. package/studio-dist/static/js/lib-react.a4b07007.js +2 -0
  46. package/studio-dist/static/js/lib-react.a4b07007.js.LICENSE.txt +49 -0
  47. package/src/commands/context.ts +0 -88
  48. package/src/commands/index.ts +0 -53
@@ -1,19 +1,16 @@
1
- import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
1
  import {
2
+ ARCHIVE_DIR_REL,
5
3
  DEFAULT_LOCALE,
6
4
  buildReqRegistry,
7
5
  compareVersions,
8
6
  isValidVersion,
9
- migrateNoteFor,
10
7
  migrateOverviewFor,
11
8
  migrationOverviewLines,
12
9
  migrationPrompt,
13
10
  knownMigrationVersions,
14
- parseVersionExpr,
15
11
  planDedupe,
16
- stripLegacyHeaderLines,
12
+ planUnfenceLegacyCards,
13
+ unfenceLegacyCards,
17
14
  } from '@llman-sdd/core';
18
15
  import type { Command } from 'commander';
19
16
 
@@ -22,64 +19,26 @@ import {
22
19
  addSpecDirOption,
23
20
  loadCliConfig,
24
21
  loadRootSpecEntries,
22
+ reRootContext,
25
23
  type CliContext,
26
24
  resolveRootSpecsDir,
27
25
  } from '../cli-shared.ts';
28
26
 
29
27
  interface MigrateOptions {
30
- kind?: string;
31
28
  fromVersion?: string;
32
29
  toVersion?: string;
33
- versionExpr?: string;
34
30
  dryRun?: boolean;
35
31
  directory?: string;
36
32
  }
37
33
 
38
- /** Resolve the playbook range from --from-version/--to-version or the
39
- * deprecated --version-expr (r100): conflict → ERROR, missing half → ERROR,
40
- * malformed version → ERROR, from >= to → ERROR. Returns null when no
41
- * selector was given at all (caller prints usage). */
42
- function resolvePromptRange(options: MigrateOptions): {
43
- from: string;
44
- to: string;
45
- viaExpr: boolean;
46
- } | null {
34
+ /** Resolve the playbook range from --from-version/--to-version. */
35
+ function resolvePromptRange(options: MigrateOptions): { from: string; to: string } | null {
47
36
  const hasNew = options.fromVersion !== undefined || options.toVersion !== undefined;
48
- if (options.versionExpr !== undefined && hasNew) {
49
- throw new CliError(
50
- '--version-expr is deprecated and conflicts with --from-version/--to-version; pass only the new flags',
51
- 2,
52
- );
53
- }
54
- if (options.versionExpr !== undefined) {
55
- const parsed = parseVersionExpr(options.versionExpr);
56
- if (parsed === null) {
57
- throw new CliError(
58
- `invalid --version-expr: ${options.versionExpr} (expected '<from>-><to>', e.g. '0.7.5->0.8.0')`,
59
- 2,
60
- );
61
- }
62
- return { ...parsed, viaExpr: true };
63
- }
64
37
  if (!hasNew) return null;
65
38
  if (options.fromVersion === undefined || options.toVersion === undefined) {
66
39
  throw new CliError('--from-version and --to-version must be given together (x.y.z)', 2);
67
40
  }
68
- return { from: options.fromVersion, to: options.toVersion, viaExpr: false };
69
- }
70
-
71
- function collectFeatureFiles(paths: string[]): string[] {
72
- const out: string[] = [];
73
- const walk = (p: string): void => {
74
- const st = statSync(p);
75
- if (st.isDirectory()) {
76
- for (const e of readdirSync(p)) walk(join(p, e));
77
- } else if (p.endsWith('.feature')) out.push(p);
78
- };
79
- for (const p of paths) {
80
- if (existsSync(p)) walk(p);
81
- }
82
- return out;
41
+ return { from: options.fromVersion, to: options.toVersion };
83
42
  }
84
43
 
85
44
  export function registerProject(program: Command, ctx: CliContext): void {
@@ -90,10 +49,6 @@ export function registerProject(program: Command, ctx: CliContext): void {
90
49
  .description('Remap globally duplicated req ids (report with --dry-run)')
91
50
  .option('--dry-run', 'report the remap plan without writing')
92
51
  .action((options: { dryRun?: boolean; directory?: string }) => {
93
- // dedupe registry covers requirement handles (`@req` on 规则: headers) only;
94
- // duplicates follow the occurrence model (同文件内共用或跨文件均算)
95
- // r115: the instance root (--directory, else the nearest at or above cwd)
96
- // scopes the registry AND the write plan — never the launch dir alone.
97
52
  const entries = loadRootSpecEntries(options.directory, ctx.io);
98
53
  const { duplicates } = buildReqRegistry(entries);
99
54
  if (duplicates.length === 0) {
@@ -101,7 +56,6 @@ export function registerProject(program: Command, ctx: CliContext): void {
101
56
  return;
102
57
  }
103
58
  const io = ctx.io;
104
- // r43: --dry-run is zero-side-effect — plan only, never write.
105
59
  const plan = planDedupe(
106
60
  entries,
107
61
  io,
@@ -111,7 +65,6 @@ export function registerProject(program: Command, ctx: CliContext): void {
111
65
  apply: !options.dryRun,
112
66
  },
113
67
  );
114
- // predecessor output: `{cap}: {from} → {to}` per remap (prefix in dry-run) + count line.
115
68
  for (const item of plan) {
116
69
  const cap = item.remapFile.replace(/^.*specs\//u, '').replace(/\.feature$/u, '');
117
70
  const prefix = options.dryRun ? '[dry-run] ' : '';
@@ -123,27 +76,15 @@ export function registerProject(program: Command, ctx: CliContext): void {
123
76
 
124
77
  const migrate = project
125
78
  .command('migrate')
126
- .description(
127
- 'Migration hub: legacy collaboration notes, versioned agent playbooks, spec-header strip',
128
- )
129
- .argument('[action]', 'prompt | strip-legacy-headers')
130
- .option('--kind <kind>', 'legacy collaboration notes: toon2features | specs-flatten')
79
+ .description('Migration hub: versioned agent playbooks and frozen-card unfence')
80
+ .argument('[action]', 'prompt | frozen-cards-unfence')
131
81
  .option('--from-version <version>', 'migration playbook range start, exclusive (x.y.z)')
132
82
  .option('--to-version <version>', 'migration playbook range end, inclusive (x.y.z)')
133
- .option(
134
- '--version-expr <expr>',
135
- "deprecated — use --from-version/--to-version instead (e.g. '0.7.5->0.8.0')",
136
- )
137
- .option('--dry-run', 'strip-legacy-headers: report affected files without writing')
83
+ .option('--dry-run', 'frozen-cards-unfence: report without writing')
138
84
  .action((action: string | undefined, options: MigrateOptions) => {
139
- // T36: version-range flags without an action are a usage error (rc 2),
140
- // not a silent no-op — the error names the action that consumes them.
141
- // `--kind` alone stays the legacy no-action form (overview / kind note).
142
85
  if (
143
86
  action === undefined &&
144
- (options.versionExpr !== undefined ||
145
- options.fromVersion !== undefined ||
146
- options.toVersion !== undefined)
87
+ (options.fromVersion !== undefined || options.toVersion !== undefined)
147
88
  ) {
148
89
  throw new CliError(
149
90
  'project migrate range flags require the prompt action (llman-sdd project migrate prompt)',
@@ -177,63 +118,32 @@ export function registerProject(program: Command, ctx: CliContext): void {
177
118
  2,
178
119
  );
179
120
  }
180
- if (range.viaExpr) {
181
- console.error(
182
- '[WARNING] --version-expr is deprecated; use --from-version/--to-version instead.',
183
- );
184
- }
185
121
  console.log(migrationPrompt(range.from, range.to));
186
122
  return;
187
123
  }
188
- if (action === 'strip-legacy-headers') {
189
- if (
190
- options.kind !== undefined ||
191
- options.versionExpr !== undefined ||
192
- options.fromVersion !== undefined ||
193
- options.toVersion !== undefined
194
- ) {
195
- throw new CliError(
196
- 'strip-legacy-headers takes no --kind/--version-expr/--from-version/--to-version',
197
- );
124
+ if (action === 'frozen-cards-unfence') {
125
+ if (options.fromVersion !== undefined || options.toVersion !== undefined) {
126
+ throw new CliError('frozen-cards-unfence takes no --from-version/--to-version');
198
127
  }
199
- const targets = collectFeatureFiles([resolveRootSpecsDir(options.directory, ctx.io)]);
200
- let touched = 0;
201
- let removed = 0;
202
- for (const file of targets) {
203
- const source = readFileSync(file, 'utf8');
204
- const result = stripLegacyHeaderLines(source);
205
- if (result.removed === 0) continue;
206
- touched++;
207
- removed += result.removed;
208
- console.log(
209
- `[strip] ${file}: ${result.removed} line(s)${options.dryRun === true ? ' (dry-run)' : ''}`,
210
- );
211
- if (options.dryRun !== true) writeFileSync(file, result.content, 'utf8');
128
+ const rctx = reRootContext(ctx, options.directory);
129
+ if (options.dryRun === true) {
130
+ const hits = planUnfenceLegacyCards(rctx.io, ARCHIVE_DIR_REL);
131
+ for (const rel of hits) console.log(`[unfence] ${rel} (dry-run)`);
132
+ console.log(`frozen-cards-unfence: ${hits.length} card(s) would change (dry-run)`);
133
+ return;
212
134
  }
213
- const mode = options.dryRun === true ? ' (dry-run)' : '';
214
- console.log(`strip-legacy-headers: ${touched} file(s), ${removed} line(s) removed${mode}`);
215
- console.log('next: re-run `llman-sdd init --update` to refresh skills and templates');
135
+ const changed = unfenceLegacyCards(rctx.io, ARCHIVE_DIR_REL);
136
+ console.log(`frozen-cards-unfence: ${changed} card(s) normalized to single-document YAML`);
216
137
  return;
217
138
  }
218
139
  if (action !== undefined) {
219
140
  throw new CliError(
220
- `unknown migrate action: ${action} (expected: prompt | strip-legacy-headers)`,
221
- 2,
222
- );
223
- }
224
- if (options.kind === undefined) {
225
- console.log(migrateOverviewFor(locale));
226
- console.log(migrationOverviewLines().join('\n'));
227
- return;
228
- }
229
- const note = migrateNoteFor(options.kind, locale);
230
- if (note === null) {
231
- throw new CliError(
232
- `unknown migration kind: ${options.kind} (expected: toon2features | specs-flatten)`,
141
+ `unknown migrate action: ${action} (expected: prompt | frozen-cards-unfence)`,
233
142
  2,
234
143
  );
235
144
  }
236
- console.log(note);
145
+ console.log(migrateOverviewFor(locale));
146
+ console.log(migrationOverviewLines().join('\n'));
237
147
  });
238
148
  addSpecDirOption(migrate);
239
149
  }
@@ -59,7 +59,6 @@ export function registerReview(program: Command, ctx: CliContext): void {
59
59
  maxScanDepth: cliMaxScanDepth(program),
60
60
  },
61
61
  );
62
- // B17: 墙钟由 CLI 注入,core 不直读 new Date()
63
62
  const now = new Date();
64
63
  const result = buildReview({
65
64
  entries,
@@ -106,6 +106,8 @@ export interface InstallDeps {
106
106
  home?: string;
107
107
  isInteractive?: () => boolean;
108
108
  prompt?: (text: string) => Promise<string>;
109
+ /** Diagnostic printer (tests inject a no-op); defaults to console.log. */
110
+ out?: (text: string) => void;
109
111
  }
110
112
 
111
113
  export async function runInstall(
@@ -127,7 +129,7 @@ export async function runInstall(
127
129
  const { content } = upsertCompletionBlock(existing, snippet);
128
130
  mkdirSync(dirname(rcPath), { recursive: true });
129
131
  writeFileSync(rcPath, content);
130
- console.log(completionBlock(snippet));
132
+ (deps.out ?? console.log)(completionBlock(snippet));
131
133
  }
132
134
 
133
135
  export function registerSelf(program: Command, _ctx: CliContext): void {
@@ -17,6 +17,7 @@ import {
17
17
  addSpecDirOption,
18
18
  CliError,
19
19
  cliMaxScanDepth,
20
+ formatNotFound,
20
21
  loadRootSpecEntries,
21
22
  reRootContext,
22
23
  specsPrefixFor,
@@ -125,8 +126,6 @@ export function registerShow(program: Command, ctx: CliContext): void {
125
126
  directory?: string;
126
127
  },
127
128
  ) => {
128
- // D4 shared surface: the registered --json/--compact-json aliases feed
129
- // the same token set as --output so show honors them uniformly.
130
129
  const outTokens = new Set(
131
130
  [
132
131
  ...(options.output ?? '').split(','),
@@ -154,20 +153,11 @@ export function registerShow(program: Command, ctx: CliContext): void {
154
153
  );
155
154
  }
156
155
  }
157
- // B10/Q1: `compact-json` is a real machine mode (single-line JSON), not a
158
- // text fallback; legacy `compact` token aliases it.
159
156
  const asCompact = outTokens.has('compact') || outTokens.has('compact-json');
160
157
  const metaOnly = outTokens.has('meta-only');
161
158
  const noScenarios = outTokens.has('no-scenarios');
162
159
  const reqsOnly = outTokens.has('reqs-only');
163
- // toon-default-output: no --output → toon; machine modes share the json
164
- // gates (Why/What validation) and suppress the prefix hint; `human` is the
165
- // sole predecessor text form. Legacy modifiers (meta-only/no-scenarios/reqs-only/
166
- // -r) belong to the text face — they route to human (predecessor no-op render
167
- // semantics preserved). The predecessor delta modifier was removed: unknown
168
- // tokens are rejected like other report commands.
169
160
  const wantsMachine = outTokens.has('json') || outTokens.has('toon') || asCompact;
170
- // no --output at all → toon; explicit legacy-only modifiers → human text
171
161
  const isHuman = options.output !== undefined && (outTokens.has('human') || !wantsMachine);
172
162
  const asJson = !isHuman;
173
163
  const showMode: 'json' | 'compact-json' | 'toon' = asCompact
@@ -175,27 +165,11 @@ export function registerShow(program: Command, ctx: CliContext): void {
175
165
  : outTokens.has('json')
176
166
  ? 'json'
177
167
  : 'toon';
178
- // predecessor: unknown output tokens are rejected by clap; script consumers rely on
179
- // the deprecation being a no-op render rather than an error.
180
- // Spec 判定与 collectSpecs/discoverSpecs 同口径:扁平文件与目录式
181
- // `specs/<cap>/<cap>.feature` 均按 entry 精确 id(specIdOf:capability ?? 去
182
- // `.feature` 后缀的 fileName)命中;r25 spec id 精确匹配优先于 change 前缀,
183
- // 不做模糊解析。
184
- // Discover once per run — the spec lookup, summary and JSON render below
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
168
  type SpecEntries = ReturnType<typeof loadRootSpecEntries>;
189
169
  let entriesCache: SpecEntries | null = null;
190
170
  const specEntries = (): SpecEntries =>
191
171
  (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
172
  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
173
  let specRoot = ctx.root;
200
174
  try {
201
175
  specRoot = resolveCommandRoot(ctx, options.directory);
@@ -208,12 +182,16 @@ export function registerShow(program: Command, ctx: CliContext): void {
208
182
  const isSpec = options.type === 'spec' || existsSync(flatSpecPath) || specEntry !== undefined;
209
183
 
210
184
  if (isSpec) {
211
- // discoverSpecs 的 fileName 已是含 specs 目录前缀的相对路径
212
- // (如 `llmanspec/specs/<cap>/<cap>.feature`),直接使用。
213
185
  const specPath =
214
186
  specEntry !== undefined && !existsSync(flatSpecPath) ? specEntry.fileName : flatSpecPath;
215
187
  if (!existsSync(specPath)) {
216
- throw new CliError(`spec not found: ${item}`);
188
+ throw new CliError(
189
+ formatNotFound(
190
+ 'spec',
191
+ item,
192
+ specEntries().map((e) => specIdOf(e)),
193
+ ),
194
+ );
217
195
  }
218
196
  if (asJson) {
219
197
  console.log(
@@ -227,8 +205,6 @@ export function registerShow(program: Command, ctx: CliContext): void {
227
205
  );
228
206
  return;
229
207
  }
230
- // text mode: predecessor ignores all output modifiers (meta-only/no-scenarios/-r)
231
- // and renders the full source + morphology.
232
208
  const raw = readFileSync(specPath, 'utf8').trimEnd();
233
209
  const summary = collectSpecs(specEntries()).find((x) => x.id === item);
234
210
  const morphology = summary
@@ -238,17 +214,10 @@ export function registerShow(program: Command, ctx: CliContext): void {
238
214
  return;
239
215
  }
240
216
 
241
- // ---- change ----
242
- // r61: predecessor r112 prefix chain — exact > unique prefix > multiple > not found.
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
217
  let rctx = ctx;
247
218
  try {
248
219
  rctx = reRootContext(ctx, options.directory);
249
220
  } 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
221
  if (options.directory !== undefined) throw error;
253
222
  }
254
223
  const resolved = resolveChangeIdOrExit(rctx, program, item, { suppressHint: asJson });
@@ -258,20 +227,14 @@ export function registerShow(program: Command, ctx: CliContext): void {
258
227
  join(rctx.root, 'llmanspec', 'changes', changeId, 'proposal.md'),
259
228
  'utf8',
260
229
  );
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
230
  const deps = {
266
231
  io: rctx.io,
267
232
  git: rctx.git,
268
233
  root: rctx.root,
269
234
  specsDir: resolveRootSpecsDirTolerant(rctx),
270
- // r119: the specs-landed gate judges under this instance's prefix.
271
235
  specsPrefix: specsPrefixFor(rctx),
272
236
  };
273
237
  if (asJson) {
274
- // predecessor parse_change gates: Why first, then What Changes (json only).
275
238
  if (!hasSection(proposal, 'Why')) {
276
239
  throw new CliError('Change must have a Why section');
277
240
  }
@@ -282,7 +245,6 @@ export function registerShow(program: Command, ctx: CliContext): void {
282
245
  console.log(renderMachine(result, showMode));
283
246
  return;
284
247
  }
285
- // text: Stage / path / content / Gates trailer (no section gates).
286
248
  const changes = collectChanges(rctx.io, rctx.root, new Date(), {
287
249
  maxScanDepth: cliMaxScanDepth(program),
288
250
  });
@@ -1,14 +1,11 @@
1
- import { existsSync, readdirSync, statSync, writeFileSync } from 'node:fs';
1
+ import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { createInterface } from 'node:readline';
4
3
 
5
4
  import {
6
5
  DEFAULT_LOCALE,
7
6
  addReq,
8
7
  addScenario,
9
8
  buildUnboundFeed,
10
- hasNativeRules,
11
- migrateNativeSource,
12
9
  nextReqId,
13
10
  resolveReq,
14
11
  scaffoldSpec,
@@ -29,45 +26,16 @@ import {
29
26
  type CliContext,
30
27
  } from '../cli-shared.ts';
31
28
 
32
- /** Walk paths collecting .feature files (directories recurse). */
33
- function collectFeatureFiles(paths: string[]): string[] {
34
- const files: string[] = [];
35
- const walk = (dir: string): void => {
36
- for (const name of readdirSync(dir).toSorted()) {
37
- const full = join(dir, name);
38
- if (statSync(full).isDirectory()) walk(full);
39
- else if (name.endsWith('.feature')) files.push(full);
40
- }
41
- };
42
- for (const p of paths) {
43
- if (!existsSync(p)) throw new CliError(`path not found: ${p}`);
44
- if (statSync(p).isDirectory()) walk(p);
45
- else files.push(p);
46
- }
47
- return files;
48
- }
49
-
50
- function confirmInteractive(question: string): Promise<boolean> {
51
- const rl = createInterface({ input: process.stdin, output: process.stdout });
52
- return new Promise((resolve) => {
53
- rl.question(question, (answer) => {
54
- rl.close();
55
- resolve(answer.trim().toLowerCase() === 'y');
56
- });
57
- });
58
- }
59
-
60
29
  export function registerSpec(program: Command, ctx: CliContext): void {
61
30
  const spec = program.command('spec').description('Spec authoring helpers');
62
31
 
63
32
  const skeleton = spec
64
- .command('skeleton')
33
+ .command('new')
65
34
  .description('Generate a single-track spec skeleton for a capability')
66
35
  .argument('<capability>')
67
36
  .option('--force', 'overwrite an existing spec file');
68
37
  addSpecDirOption(skeleton);
69
38
  skeleton.action((capability: string, options: { force?: boolean; directory?: string }) => {
70
- // r109/r115: locale 属命中实例根的配置,`--directory` 指向子根时不得读启动根
71
39
  const locale =
72
40
  loadCliConfig(resolveCommandRoot(ctx, options.directory))?.locale ?? DEFAULT_LOCALE;
73
41
  const specsDir = resolveRootSpecsDir(options.directory, ctx.io);
@@ -162,53 +130,6 @@ export function registerSpec(program: Command, ctx: CliContext): void {
162
130
  },
163
131
  );
164
132
 
165
- const migrateNative = spec
166
- .command('migrate-native')
167
- .description('Migrate legacy tag-based .feature files to the native 规则:/场景: layout')
168
- .argument('[paths...]', 'feature files or directories (default: llmanspec/specs)')
169
- .option('--dry-run', 'print the migration plan without writing')
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;
179
- let migrated = 0;
180
- let skipped = 0;
181
- for (const file of targets) {
182
- const source = io.readText(file);
183
- // already native? layout detection via the official parser
184
- if (hasNativeRules(source)) {
185
- skipped++;
186
- if (options.dryRun) console.log(`[skip] ${file} (already native)`);
187
- continue;
188
- }
189
- const result = migrateNativeSource(source);
190
- if (!result.ok) {
191
- console.error(`[error] ${file}: ${result.message}`);
192
- continue;
193
- }
194
- const line = `[migrate] ${file}: ${result.rules} rule(s), ${result.scenarios} scenario(s)`;
195
- if (options.dryRun) {
196
- console.log(`${line} (dry-run)`);
197
- migrated++;
198
- continue;
199
- }
200
- if (options.yes || (await confirmInteractive(`${line}. Write? (y/N) `))) {
201
- writeFileSync(file, result.content, 'utf8');
202
- console.log(line);
203
- migrated++;
204
- } else {
205
- console.log(`[skip] ${file} (declined)`);
206
- }
207
- }
208
- console.log(`migrate-native: ${migrated} file(s) migrated, ${skipped} already native`);
209
- },
210
- );
211
-
212
133
  const resolveReqCmd = spec
213
134
  .command('resolve-req')
214
135
  .description('Resolve an rN to its capability and statement')
@@ -232,14 +153,13 @@ export function registerSpec(program: Command, ctx: CliContext): void {
232
153
  .description('Show transition-table validation rules: alias families, tags, gates');
233
154
  addSpecDirOption(transitions);
234
155
  transitions.action((options: { directory?: string }) => {
235
- // r109: 本命令输出为静态内省,无实例根语义;仍按「豁免外全部命令声明并接受
236
- // --directory」声明该选项,并仅在显式给出时经同一根发现算子校验(无实例报域错误)。
237
156
  if (options.directory !== undefined) resolveCommandRoot(ctx, options.directory);
238
157
  const info = TRANSITIONS_INTROSPECTION;
158
+ console.log(info.note);
239
159
  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(' | ')}`);
160
+ for (const [role, fam] of Object.entries(info.columnFamilies)) {
161
+ console.log(` ${role}: ${fam.required.join(' | ')}`);
162
+ if (fam.optional.length > 0) console.log(` optional: ${fam.optional.join(' | ')}`);
243
163
  }
244
164
  console.log(`discovery: ${info.discovery}`);
245
165
  console.log('tags:');