@llman-sdd/cli 0.8.2 → 0.9.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llman-sdd/cli",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Spec-driven development workflow CLI (the `llman-sdd` command)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "build": "bun run ./scripts/build-binary.ts"
28
28
  },
29
29
  "dependencies": {
30
- "@llman-sdd/core": "0.8.2",
30
+ "@llman-sdd/core": "0.9.0",
31
31
  "commander": "^15.0.0"
32
32
  },
33
33
  "engines": {
package/src/cli-shared.ts CHANGED
@@ -146,10 +146,24 @@ function warnLegacyBdd(elevated: boolean): void {
146
146
  );
147
147
  }
148
148
 
149
- /** Surface the legacy-section warning from a raw config source (config command). */
149
+ /** One-time removed-key warning (config-schema r102): `specs.check_transitions`
150
+ * is stripped at load; transition validation is tag-scoped (validation r104). */
151
+ let legacyCheckTransitionsWarningShown = false;
152
+
153
+ function warnLegacyCheckTransitions(stripped: boolean): void {
154
+ if (!stripped || legacyCheckTransitionsWarningShown) return;
155
+ legacyCheckTransitionsWarningShown = true;
156
+ console.error(
157
+ '[WARNING] llmanspec/config.yaml `specs.check_transitions` was removed — transition-table validation is now tag-scoped per scenario (@transitions force / @no-transitions escape). Delete the key. See migrations/v0.8-v0.9/README.md.',
158
+ );
159
+ }
160
+
161
+ /** Surface the legacy-section warnings from a raw config source (config command). */
150
162
  export function warnLegacyBddOnce(source: string): void {
151
- if (legacyBddWarningShown) return;
152
- warnLegacyBdd(loadConfigDetail(source).legacyBddElevated);
163
+ if (legacyBddWarningShown && legacyCheckTransitionsWarningShown) return;
164
+ const detail = loadConfigDetail(source);
165
+ warnLegacyBdd(detail.legacyBddElevated);
166
+ warnLegacyCheckTransitions(detail.legacyCheckTransitionsStripped);
153
167
  }
154
168
 
155
169
  /**
@@ -177,6 +191,7 @@ export function loadCliConfig(): ReturnType<typeof loadConfig> | null {
177
191
  if (!existsSync('llmanspec/config.yaml')) return null;
178
192
  const detail = loadConfigDetail(readFileSync('llmanspec/config.yaml', 'utf8'));
179
193
  warnLegacyBdd(detail.legacyBddElevated);
194
+ warnLegacyCheckTransitions(detail.legacyCheckTransitionsStripped);
180
195
  noteVersionDriftOnce();
181
196
  return detail.config;
182
197
  }
@@ -1,7 +1,13 @@
1
1
  import { mkdirSync } from 'node:fs';
2
- import { resolve } from 'node:path';
2
+ import { join, resolve } from 'node:path';
3
3
 
4
- import { discoverRoots, refreshSubRootBlocks, runInit } from '@llman-sdd/core';
4
+ import {
5
+ discoverRoots,
6
+ isValidRoot,
7
+ refreshSubRootBlocks,
8
+ resolveInstanceRoot,
9
+ runInit,
10
+ } from '@llman-sdd/core';
5
11
  import type { Command } from 'commander';
6
12
 
7
13
  import { CliError, templateIo, version } from '../cli-shared.ts';
@@ -28,7 +34,10 @@ export function registerInit(program: Command): void {
28
34
  '--skills',
29
35
  'inject .agents/skills at a sub-root instance (repo-root instances always inject)',
30
36
  )
31
- .option('--locale <locale>', 'locale for generated templates (defaults to config or en)')
37
+ .option(
38
+ '--locale <locale>',
39
+ 'locale for generated templates (explicit config.yaml locale wins; fills a missing key; built-in default en)',
40
+ )
32
41
  .option('--lang <locale>', 'alias of --locale')
33
42
  .action(
34
43
  (
@@ -43,23 +52,44 @@ export function registerInit(program: Command): void {
43
52
  root = resolve(path);
44
53
  mkdirSync(root, { recursive: true });
45
54
  }
55
+ const io = makeIo(root);
56
+ const warn = (message: string): void => {
57
+ console.error(message);
58
+ };
59
+ // r106 new-instance notice: creating a fresh instance below an existing
60
+ // one is legal (r93 逐根构造) but usually a cwd mistake — surface both.
61
+ if (!isValidRoot(join(root, 'llmanspec'), io)) {
62
+ const ancestor = resolveInstanceRoot(root, io);
63
+ if (ancestor !== null) {
64
+ warn(
65
+ `WARNING: no llman-sdd instance at ${root}; creating a new one (nearest existing instance: ${ancestor})`,
66
+ );
67
+ }
68
+ }
46
69
  const repoRootInstance = isRepoRootInstance(root);
47
70
  // 模板生成/子根扫块可能耗时 — 进度提示防止看上去卡住(B1)
48
71
  progressNote('init.generate', root);
49
- const result = runInit(makeIo(root), templateIo, {
72
+ const result = runInit(io, templateIo, {
50
73
  update: options.update ?? false,
51
74
  locale: options.locale ?? options.lang,
52
75
  version,
53
76
  skills: options.skills === true || repoRootInstance,
77
+ onWarning: warn,
54
78
  });
55
79
  let swept = '';
56
- if ((options.update ?? false) && repoRootInstance) {
57
- // r93 --update sweep: refresh managed blocks of every discovered
58
- // sub-root (blocks only; skills stay a repo-root surface).
59
- const subRoots = discoverRoots(root, makeIo(root)).filter((r) => r.rootDir !== root);
80
+ if (options.update ?? false) {
81
+ // r93 --update sweep, per-workspace from any instance root: refresh
82
+ // managed blocks of every root discovered from the repo toplevel
83
+ // (outside a repo: from the target). Blocks only; skills stay a
84
+ // repo-root surface.
85
+ const toplevel = makeCliGit(root).runOpt(['rev-parse', '--show-toplevel']);
86
+ const sweepStart = toplevel !== null ? resolve(toplevel) : root;
87
+ const subRoots = discoverRoots(sweepStart, makeIo(sweepStart)).filter(
88
+ (r) => r.rootDir !== root,
89
+ );
60
90
  const refreshed: string[] = [];
61
91
  for (const sub of subRoots) {
62
- if (refreshSubRootBlocks(makeIo(sub.rootDir), templateIo, version)) {
92
+ if (refreshSubRootBlocks(makeIo(sub.rootDir), templateIo, version, warn)) {
63
93
  refreshed.push(sub.rootDir);
64
94
  }
65
95
  }
@@ -3,13 +3,14 @@ import { join } from 'node:path';
3
3
 
4
4
  import {
5
5
  buildReqRegistry,
6
- findMigration,
7
- isValidMigrationExpr,
6
+ compareVersions,
7
+ isValidVersion,
8
8
  migrateNoteFor,
9
9
  migrateOverviewFor,
10
10
  migrationOverviewLines,
11
11
  migrationPrompt,
12
- knownMigrationIds,
12
+ knownMigrationVersions,
13
+ parseVersionExpr,
13
14
  planDedupe,
14
15
  stripLegacyHeaderLines,
15
16
  } from '@llman-sdd/core';
@@ -17,6 +18,45 @@ import type { Command } from 'commander';
17
18
 
18
19
  import { CliError, loadCliConfig, loadSpecEntries, newIo } from '../cli-shared.ts';
19
20
 
21
+ interface MigrateOptions {
22
+ kind?: string;
23
+ fromVersion?: string;
24
+ toVersion?: string;
25
+ versionExpr?: string;
26
+ dryRun?: boolean;
27
+ }
28
+
29
+ /** Resolve the playbook range from --from-version/--to-version or the
30
+ * deprecated --version-expr (r100): conflict → ERROR, missing half → ERROR,
31
+ * malformed version → ERROR, from >= to → ERROR. Returns null when no
32
+ * selector was given at all (caller prints usage). */
33
+ function resolvePromptRange(options: MigrateOptions): {
34
+ from: string;
35
+ to: string;
36
+ viaExpr: boolean;
37
+ } | null {
38
+ const hasNew = options.fromVersion !== undefined || options.toVersion !== undefined;
39
+ if (options.versionExpr !== undefined && hasNew) {
40
+ throw new CliError(
41
+ '--version-expr is deprecated and conflicts with --from-version/--to-version; pass only the new flags',
42
+ );
43
+ }
44
+ if (options.versionExpr !== undefined) {
45
+ const parsed = parseVersionExpr(options.versionExpr);
46
+ if (parsed === null) {
47
+ throw new CliError(
48
+ `invalid --version-expr: ${options.versionExpr} (expected '<from>-><to>', e.g. '0.7.5->0.8.0')`,
49
+ );
50
+ }
51
+ return { ...parsed, viaExpr: true };
52
+ }
53
+ if (!hasNew) return null;
54
+ if (options.fromVersion === undefined || options.toVersion === undefined) {
55
+ throw new CliError('--from-version and --to-version must be given together (x.y.z)');
56
+ }
57
+ return { from: options.fromVersion, to: options.toVersion, viaExpr: false };
58
+ }
59
+
20
60
  function collectFeatureFiles(paths: string[]): string[] {
21
61
  const out: string[] = [];
22
62
  const walk = (p: string): void => {
@@ -68,82 +108,91 @@ export function registerProject(program: Command): void {
68
108
  )
69
109
  .argument('[action]', 'prompt | strip-legacy-headers')
70
110
  .option('--kind <kind>', 'legacy collaboration notes: toon2features | specs-flatten')
71
- .option('--version-expr <expr>', "migration playbook selector, e.g. '0.7.5->0.8.0'")
111
+ .option('--from-version <version>', 'migration playbook range start, exclusive (x.y.z)')
112
+ .option('--to-version <version>', 'migration playbook range end, inclusive (x.y.z)')
113
+ .option(
114
+ '--version-expr <expr>',
115
+ "deprecated — use --from-version/--to-version instead (e.g. '0.7.5->0.8.0')",
116
+ )
72
117
  .option('--dry-run', 'strip-legacy-headers: report affected files without writing')
73
- .action(
74
- (
75
- action: string | undefined,
76
- options: { kind?: string; versionExpr?: string; dryRun?: boolean },
77
- ) => {
78
- const locale = loadCliConfig()?.locale ?? 'en';
79
- if (action === 'prompt') {
80
- const expr = options.versionExpr;
81
- if (expr === undefined) {
82
- console.log(
83
- [
84
- 'Migration playbook selector is required.',
85
- `Known migrations: ${knownMigrationIds().join(', ')}`,
86
- "Usage: llman-sdd project migrate prompt --version-expr '<from>-><to>'",
87
- ].join('\n'),
88
- );
89
- return;
90
- }
91
- if (!isValidMigrationExpr(expr)) {
92
- throw new CliError(
93
- `invalid --version-expr: ${expr} (expected '<from>-><to>', e.g. '0.7.5->0.8.0')`,
94
- );
95
- }
96
- const migration = findMigration(expr);
97
- if (migration === null) {
98
- throw new CliError(
99
- `unknown migration: ${expr} (known: ${knownMigrationIds().join(', ')})`,
100
- );
101
- }
102
- console.log(migrationPrompt(migration));
103
- return;
104
- }
105
- if (action === 'strip-legacy-headers') {
106
- if (options.kind !== undefined || options.versionExpr !== undefined) {
107
- throw new CliError('strip-legacy-headers takes no --kind/--version-expr');
108
- }
109
- const targets = collectFeatureFiles(['llmanspec/specs']);
110
- let touched = 0;
111
- let removed = 0;
112
- for (const file of targets) {
113
- const source = readFileSync(file, 'utf8');
114
- const result = stripLegacyHeaderLines(source);
115
- if (result.removed === 0) continue;
116
- touched++;
117
- removed += result.removed;
118
- console.log(
119
- `[strip] ${file}: ${result.removed} line(s)${options.dryRun === true ? ' (dry-run)' : ''}`,
120
- );
121
- if (options.dryRun !== true) writeFileSync(file, result.content, 'utf8');
122
- }
123
- const mode = options.dryRun === true ? ' (dry-run)' : '';
118
+ .action((action: string | undefined, options: MigrateOptions) => {
119
+ const locale = loadCliConfig()?.locale ?? 'en';
120
+ if (action === 'prompt') {
121
+ const range = resolvePromptRange(options);
122
+ if (range === null) {
124
123
  console.log(
125
- `strip-legacy-headers: ${touched} file(s), ${removed} line(s) removed${mode}`,
124
+ [
125
+ 'Migration playbook range is required.',
126
+ `Known migrations: ${knownMigrationVersions().join(', ')}`,
127
+ 'Usage: llman-sdd project migrate prompt --from-version <from> --to-version <to>',
128
+ ].join('\n'),
126
129
  );
127
- console.log('next: re-run `llman-sdd init --update` to refresh skills and templates');
128
130
  return;
129
131
  }
130
- if (action !== undefined) {
132
+ for (const v of [range.from, range.to]) {
133
+ if (!isValidVersion(v)) {
134
+ throw new CliError(`invalid version '${v}': expected x.y.z (e.g. 0.9.0), got '${v}'`);
135
+ }
136
+ }
137
+ if (compareVersions(range.from, range.to) >= 0) {
131
138
  throw new CliError(
132
- `unknown migrate action: ${action} (expected: prompt | strip-legacy-headers)`,
139
+ `invalid range: --from-version (${range.from}) must be less than --to-version (${range.to})`,
133
140
  );
134
141
  }
135
- if (options.kind === undefined) {
136
- console.log(migrateOverviewFor(locale));
137
- console.log(migrationOverviewLines().join('\n'));
138
- return;
142
+ if (range.viaExpr) {
143
+ console.error(
144
+ '[WARNING] --version-expr is deprecated; use --from-version/--to-version instead.',
145
+ );
139
146
  }
140
- const note = migrateNoteFor(options.kind, locale);
141
- if (note === null) {
147
+ console.log(migrationPrompt(range.from, range.to));
148
+ return;
149
+ }
150
+ if (action === 'strip-legacy-headers') {
151
+ if (
152
+ options.kind !== undefined ||
153
+ options.versionExpr !== undefined ||
154
+ options.fromVersion !== undefined ||
155
+ options.toVersion !== undefined
156
+ ) {
142
157
  throw new CliError(
143
- `unknown migration kind: ${options.kind} (expected: toon2features | specs-flatten)`,
158
+ 'strip-legacy-headers takes no --kind/--version-expr/--from-version/--to-version',
144
159
  );
145
160
  }
146
- console.log(note);
147
- },
148
- );
161
+ const targets = collectFeatureFiles(['llmanspec/specs']);
162
+ let touched = 0;
163
+ let removed = 0;
164
+ for (const file of targets) {
165
+ const source = readFileSync(file, 'utf8');
166
+ const result = stripLegacyHeaderLines(source);
167
+ if (result.removed === 0) continue;
168
+ touched++;
169
+ removed += result.removed;
170
+ console.log(
171
+ `[strip] ${file}: ${result.removed} line(s)${options.dryRun === true ? ' (dry-run)' : ''}`,
172
+ );
173
+ if (options.dryRun !== true) writeFileSync(file, result.content, 'utf8');
174
+ }
175
+ const mode = options.dryRun === true ? ' (dry-run)' : '';
176
+ console.log(`strip-legacy-headers: ${touched} file(s), ${removed} line(s) removed${mode}`);
177
+ console.log('next: re-run `llman-sdd init --update` to refresh skills and templates');
178
+ return;
179
+ }
180
+ if (action !== undefined) {
181
+ throw new CliError(
182
+ `unknown migrate action: ${action} (expected: prompt | strip-legacy-headers)`,
183
+ );
184
+ }
185
+ if (options.kind === undefined) {
186
+ console.log(migrateOverviewFor(locale));
187
+ console.log(migrationOverviewLines().join('\n'));
188
+ return;
189
+ }
190
+ const note = migrateNoteFor(options.kind, locale);
191
+ if (note === null) {
192
+ throw new CliError(
193
+ `unknown migration kind: ${options.kind} (expected: toon2features | specs-flatten)`,
194
+ );
195
+ }
196
+ console.log(note);
197
+ });
149
198
  }
@@ -16,7 +16,6 @@ import {
16
16
  CliError,
17
17
  cliMaxScanDepth,
18
18
  exitWith,
19
- loadCliConfig,
20
19
  loadSpecEntries,
21
20
  newIo,
22
21
  resolveOutMode,
@@ -59,7 +58,6 @@ export function registerReview(program: Command): void {
59
58
  boundChangeCount: activeChanges.filter((c) => c.hasBinding).length,
60
59
  activeChanges,
61
60
  capability: options.capability,
62
- checkTransitions: Boolean(loadCliConfig()?.specs?.check_transitions),
63
61
  },
64
62
  io,
65
63
  );
@@ -12,6 +12,7 @@ import {
12
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';
@@ -227,6 +228,23 @@ export function registerSpec(program: Command): void {
227
228
  for (const h of resolved.harness) console.log(` - ${h}`);
228
229
  });
229
230
 
231
+ spec
232
+ .command('transitions')
233
+ .description('Show transition-table validation rules: alias families, tags, gates')
234
+ .action(() => {
235
+ const info = TRANSITIONS_INTROSPECTION;
236
+ console.log('columns:');
237
+ for (const fam of info.columnFamilies) {
238
+ const optional = 'optional' in fam && fam.optional ? ' (optional)' : '';
239
+ console.log(` ${fam.role}${optional}: ${fam.aliases.join(' | ')}`);
240
+ }
241
+ console.log(`discovery: ${info.discovery}`);
242
+ console.log('tags:');
243
+ for (const t of info.tags) console.log(` ${t.tag} — ${t.semantics}`);
244
+ console.log('gates:');
245
+ for (const g of info.gates) console.log(` - ${g}`);
246
+ });
247
+
230
248
  const unbound = spec
231
249
  .command('unbound')
232
250
  .description('List unbound requirements (no runnable nested scenario) for implementation')
@@ -51,7 +51,6 @@ function compareItems(a: VItem, b: VItem): number {
51
51
 
52
52
  function specV1Items(
53
53
  opts: {
54
- strict?: boolean;
55
54
  harness?: HarnessGate;
56
55
  harnessOnlyIds?: string[];
57
56
  },
@@ -63,10 +62,7 @@ function specV1Items(
63
62
  const items: VItem[] = [];
64
63
  for (const entry of entries) {
65
64
  const cap = specIdOf(entry);
66
- const verdict = validateCapability(entry as never, duplicatesFor, io, {
67
- strict: opts.strict === true,
68
- checkTransitions: Boolean(loadCliConfig()?.specs?.check_transitions),
69
- });
65
+ const verdict = validateCapability(entry as never, duplicatesFor, io);
70
66
  const issues: ChangeIssue[] = verdict.items.map((i) => ({
71
67
  level: i.level,
72
68
  path: i.id,
@@ -347,7 +343,6 @@ export function registerValidate(program: Command): void {
347
343
  for (const root of roots) {
348
344
  process.chdir(root.rootDir);
349
345
  const items = specV1Items({
350
- strict: options.strict,
351
346
  harness: makeHarnessGate(options),
352
347
  });
353
348
  const visible = keepInfo ? items : items.map(stripInfo);
@@ -408,7 +403,6 @@ export function registerValidate(program: Command): void {
408
403
  if (specEntry !== undefined) {
409
404
  const items = specV1Items(
410
405
  {
411
- strict: options.strict,
412
406
  harness,
413
407
  harnessOnlyIds: [item],
414
408
  },
@@ -504,7 +498,6 @@ export function registerValidate(program: Command): void {
504
498
  if (effectiveSpecs) {
505
499
  items = items.concat(
506
500
  specV1Items({
507
- strict: options.strict,
508
501
  harness,
509
502
  }),
510
503
  );