@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
@@ -10,12 +10,15 @@ import {
10
10
  defaultBranch,
11
11
  discoverRoots,
12
12
  formatTotals,
13
+ hintForValidateCheckPass,
14
+ hintForValidationIssue,
13
15
  renderMachine,
14
16
  runHarnessForSpecs,
15
17
  specIdOf,
16
18
  STAGE_ORDER,
17
19
  validateCapability,
18
20
  validateChange,
21
+ validateFlowAndNesting,
19
22
  type ChangeIssue,
20
23
  type CrossRootCollision,
21
24
  type HarnessGate,
@@ -28,6 +31,7 @@ import {
28
31
  assertCompactJsonPairing,
29
32
  CliError,
30
33
  cliMaxScanDepth,
34
+ emitCliHint,
31
35
  exitWith,
32
36
  loadCliConfig,
33
37
  loadRootSpecEntries,
@@ -40,6 +44,7 @@ import {
40
44
  } from '../cli-shared.ts';
41
45
  import { makeCliHarnessRunner } from '../harness.ts';
42
46
  import { makeIo } from '../io.ts';
47
+ import { runTheoremCheck } from './theorem.ts';
43
48
 
44
49
  interface VItem {
45
50
  id: string;
@@ -86,9 +91,16 @@ function specV1Items(
86
91
  matchedViaPrefix: false,
87
92
  });
88
93
  }
89
- // r13/r48: harness issues attach to their spec item after the structural
90
- // verdict (execution runs only for the entries actually being validated —
91
- // a single-item validate scopes the harness to that one spec).
94
+ for (const extra of validateFlowAndNesting(entries)) {
95
+ const cap = extra.id.split('/')[0] ?? '';
96
+ const target = items.find((i) => i.id === cap);
97
+ if (!target) continue;
98
+ target.issues = [
99
+ ...target.issues,
100
+ { level: extra.level, path: extra.id, message: extra.message },
101
+ ];
102
+ target.valid = target.issues.every((i) => i.level !== 'ERROR');
103
+ }
92
104
  if (opts.harness !== undefined) {
93
105
  const scoped =
94
106
  opts.harnessOnlyIds === undefined
@@ -133,7 +145,6 @@ function changeV1Items(
133
145
  stage: opts.stage as never,
134
146
  strict: opts.strict === true,
135
147
  git,
136
- // r119: specs-landing judged under this instance's prefix.
137
148
  specsPrefix: specsPrefixFor(ctx),
138
149
  },
139
150
  );
@@ -146,10 +157,6 @@ function changeV1Items(
146
157
  matchedViaPrefix: false,
147
158
  });
148
159
  }
149
- // r87: global change-id uniqueness gate. Duplicate ids attach to their
150
- // active change item when the active change is being validated; archive↔
151
- // archive / frozen-only collisions surface as synthetic items (no active
152
- // counterpart to carry the ERROR).
153
160
  const duplicates = checkGlobalChangeIdUniqueness(io, `${root}/llmanspec/changes`);
154
161
  const byId = new Map(items.map((i) => [i.id, i]));
155
162
  for (const dup of duplicates) {
@@ -283,17 +290,21 @@ let harnessBannerShown = false;
283
290
  * --check → check=true, absent → undefined.
284
291
  */
285
292
  function makeHarnessGate(ctx: CliContext, options: { check?: boolean }): HarnessGate {
286
- const runCommand = loadCliConfig(ctx.root)?.specs?.check_command ?? null;
287
- const configured = runCommand !== null && runCommand !== '';
293
+ const specs = loadCliConfig(ctx.root)?.specs;
294
+ const checkCommand = specs?.check_command?.trim() ?? '';
295
+ const danglingCommand = specs?.check_dangling_bdd_command?.trim() ?? '';
296
+ const commands = [
297
+ ...(checkCommand !== '' ? ([{ kind: 'check' as const, command: checkCommand }] as const) : []),
298
+ ...(danglingCommand !== ''
299
+ ? ([{ kind: 'dangling' as const, command: danglingCommand }] as const)
300
+ : []),
301
+ ];
302
+ const configured = commands.length > 0;
288
303
  return {
289
304
  nested: process.env.LLMAN_SDD_HARNESS_ACTIVE === '1',
290
- // Opt-in harness (2026-10 decision): absent → 'off' — structure/state gate
291
- // only; --check → 'on' (explicit full harness). The CLI never sends
292
- // 'default'; core still treats a received 'default' as
293
- // run-if-configured (its own contract).
294
305
  check: options.check === true ? 'on' : 'off',
295
306
  runner: configured ? makeCliHarnessRunner() : undefined,
296
- runCommand,
307
+ commands,
297
308
  cwd: ctx.root,
298
309
  onBeforeFirstRun: (expanded: string): void => {
299
310
  if (harnessBannerShown) return;
@@ -344,8 +355,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
344
355
  ) => {
345
356
  assertCompactJsonPairing(options);
346
357
  const outMode = resolveOutMode(options.output, options.json, options.compactJson);
347
- // r32: INFO issues are presentation noise — dropped unless opted in.
348
- // Filtering never touches `valid`, summaries, or exit codes.
349
358
  const keepInfo = options.includeInfo === true;
350
359
  const stripInfo = <T extends { issues: { level: string }[] }>(it: T): T =>
351
360
  keepInfo ? it : { ...it, issues: it.issues.filter((x) => x.level !== 'INFO') };
@@ -361,7 +370,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
361
370
  }
362
371
  const maxDepth = cliMaxScanDepth(program);
363
372
 
364
- // ---- aggregate over every discovered root (r91) ----
365
373
  if (options.allRoots === true) {
366
374
  if (item !== undefined) {
367
375
  throw new CliError('--all-roots validates every root; drop the <item> argument');
@@ -369,19 +377,12 @@ export function registerValidate(program: Command, ctx: CliContext): void {
369
377
  const start = resolve(options.directory ?? gitToplevelOrCwd(ctx));
370
378
  const roots = discoverRoots(start, ctx.io, { maxDepth });
371
379
  if (roots.length === 0) {
372
- // r91 aggregate anchor: discovery covers the start itself and
373
- // everything below it — the r109 walk-up family message form, with
374
- // the direction the aggregate operator actually searches.
375
380
  throw new CliError(`no llmanspec root at or under: ${start}`);
376
381
  }
377
382
  const reports: RootReport[] = [];
378
383
  const namespaceValues: RootNamespaceValues[] = [];
379
384
  let anyFail = false;
380
385
  for (const root of roots) {
381
- // r91/r115: the discovered rootDir follows the start's form, and a
382
- // relative one would make makeIo(rootDir) anchor twice (queries
383
- // landing in <dir>/<dir>/llmanspec) so every root failed to resolve.
384
- // Absolutize once, then label relative to the (absolute) start.
385
386
  const rootDir = resolve(root.rootDir);
386
387
  const rootCtx: CliContext = {
387
388
  ...ctx,
@@ -403,9 +404,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
403
404
  items: visible,
404
405
  summary: summarizeItems(visible),
405
406
  });
406
- // r91: the aggregate covers change-id granularity too — one set of
407
- // ids per root for the cross-root observation (spec/capability ids,
408
- // @req handles, change ids incl. archived dated entries).
409
407
  namespaceValues.push({
410
408
  root: label,
411
409
  specIds: entries.map((entry) => specIdOf(entry)),
@@ -417,8 +415,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
417
415
  }),
418
416
  });
419
417
  }
420
- // r91/r114: undefined for a lone root — the field MUST NOT be emitted
421
- // at all there (no empty array, byte-identical single-root output).
422
418
  const collisions = computeCrossRootCollisions(namespaceValues);
423
419
  if (outMode === 'human') {
424
420
  for (const report of reports) {
@@ -435,8 +431,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
435
431
  }),
436
432
  { items: 0, passed: 0, failed: 0 },
437
433
  );
438
- // Observation is data-only in machine form (r114: no hint line);
439
- // collisions never feed the exit code.
440
434
  const payload =
441
435
  collisions === undefined
442
436
  ? { roots: reports, summary: { totals }, version: '1.0' }
@@ -453,16 +447,22 @@ export function registerValidate(program: Command, ctx: CliContext): void {
453
447
  return;
454
448
  }
455
449
 
456
- // ---- instance root resolution (T21, cli r108/r109/r115): the shared
457
- // re-root operator, same as every other command — io, git and root are
458
- // all anchored at the resolved instance, so downstream discovery reads
459
- // THAT root (a root swap alone would still discover from the launch
460
- // cwd). Byte-identical when cwd already sits at the instance root. ----
461
450
  const eff: CliContext = reRootContext(ctx, options.directory);
462
451
 
463
452
  const harness = makeHarnessGate(eff, options);
464
453
 
465
- // ---- single item (auto-disambiguate: spec first, then change) ----
454
+ if (options.check === true) {
455
+ const theoremResult = runTheoremCheck(eff, { directory: undefined });
456
+ if (!theoremResult.ok) {
457
+ for (const failure of theoremResult.failures) {
458
+ console.error(`[ERROR] theorem: ${failure}`);
459
+ }
460
+ console.error('Error: theorem check failed');
461
+ exitWith(1);
462
+ return;
463
+ }
464
+ }
465
+
466
466
  if (item !== undefined) {
467
467
  const entries = loadRootSpecEntries(undefined, eff.io);
468
468
  const specEntry =
@@ -482,23 +482,43 @@ export function registerValidate(program: Command, ctx: CliContext): void {
482
482
  const shown = stripInfo(mine);
483
483
  if (outMode !== 'human') {
484
484
  renderValidateReport([shown], outMode);
485
+ if (shown.valid && options.check === true) {
486
+ emitCliHint(
487
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
488
+ outMode,
489
+ );
490
+ } else if (!shown.valid) {
491
+ const firstFix = shown.issues
492
+ .map((i) => hintForValidationIssue(i.message))
493
+ .find((h) => h !== null);
494
+ emitCliHint(firstFix, outMode);
495
+ }
485
496
  exitWith(shown.valid ? 0 : 1);
486
497
  return;
487
498
  }
488
499
  if (shown.valid) {
489
500
  console.log(`Specification '${item}' is valid`);
501
+ if (options.check === true) {
502
+ emitCliHint(
503
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
504
+ outMode,
505
+ );
506
+ }
490
507
  } else {
491
508
  console.error(`Specification '${item}' has issues`);
492
509
  for (const issue of shown.issues)
493
510
  console.error(` [${issue.level}] ${issue.path}: ${issue.message}`);
494
511
  console.error('Next steps:');
495
512
  for (const s of SPEC_NEXT_STEPS) console.error(s);
513
+ const firstFix = shown.issues
514
+ .map((i) => hintForValidationIssue(i.message))
515
+ .find((h) => h !== null);
516
+ emitCliHint(firstFix, outMode);
496
517
  }
497
518
  if (!shown.valid) console.error('Error: validation failed');
498
519
  exitWith(shown.valid ? 0 : 1);
499
520
  return;
500
521
  }
501
- // change single (r61: predecessor r112 prefix resolution on the change id)
502
522
  const { io, root } = eff;
503
523
  const resolved = resolveChangeIdOrExit(eff, program, item, {
504
524
  suppressHint: options.json === true,
@@ -516,7 +536,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
516
536
  stage: options.stage as never,
517
537
  strict: options.strict === true,
518
538
  git: eff.git,
519
- // r119: specs-landing judged under this instance's prefix.
520
539
  specsPrefix: specsPrefixFor(eff),
521
540
  },
522
541
  );
@@ -535,17 +554,38 @@ export function registerValidate(program: Command, ctx: CliContext): void {
535
554
  ],
536
555
  outMode,
537
556
  );
557
+ if (res.valid && options.check === true) {
558
+ emitCliHint(
559
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
560
+ outMode,
561
+ );
562
+ } else if (!res.valid) {
563
+ const firstFix = res.issues
564
+ .map((i) => hintForValidationIssue(i.message))
565
+ .find((h) => h !== null);
566
+ emitCliHint(firstFix, outMode);
567
+ }
538
568
  exitWith(res.valid ? 0 : 1);
539
569
  return;
540
570
  }
541
571
  if (res.valid) {
542
572
  console.log(`Change '${changeId}' is valid`);
573
+ if (options.check === true) {
574
+ emitCliHint(
575
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
576
+ outMode,
577
+ );
578
+ }
543
579
  } else {
544
580
  console.error(`Change '${changeId}' has issues`);
545
581
  for (const issue of res.issues.filter((i) => i.level !== 'INFO'))
546
582
  console.error(` [${issue.level}] ${issue.path}: ${issue.message}`);
547
583
  console.error('Next steps:');
548
584
  for (const s of CHANGE_NEXT_STEPS) console.error(s);
585
+ const firstFix = res.issues
586
+ .map((i) => hintForValidationIssue(i.message))
587
+ .find((h) => h !== null);
588
+ emitCliHint(firstFix, outMode);
549
589
  }
550
590
  if (keepInfo) {
551
591
  for (const info of infos) console.error(`[${info.level}] ${info.path}: ${info.message}`);
@@ -555,7 +595,6 @@ export function registerValidate(program: Command, ctx: CliContext): void {
555
595
  return;
556
596
  }
557
597
 
558
- // ---- bulk ----
559
598
  const specScope = options.all || !options.changes || options.specs === true;
560
599
  const changeScope = options.all || options.changes === true;
561
600
  const defaultSpecsOnly = !options.all && !options.changes;
@@ -586,22 +625,44 @@ export function registerValidate(program: Command, ctx: CliContext): void {
586
625
 
587
626
  if (outMode !== 'human') {
588
627
  renderValidateReport(items, outMode);
589
- if (items.some((i) => !i.valid)) console.error('Error: validation failed');
590
- exitWith(items.some((i) => !i.valid) ? 1 : 0);
628
+ const anyFailed = items.some((i) => !i.valid);
629
+ if (anyFailed) {
630
+ console.error('Error: validation failed');
631
+ const firstFix = items
632
+ .flatMap((it) => it.issues)
633
+ .map((i) => hintForValidationIssue(i.message))
634
+ .find((h) => h !== null);
635
+ emitCliHint(firstFix, outMode);
636
+ } else if (options.check === true) {
637
+ emitCliHint(
638
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
639
+ outMode,
640
+ );
641
+ }
642
+ exitWith(anyFailed ? 1 : 0);
591
643
  return;
592
644
  }
593
645
  renderValidateText(items);
594
- if (items.some((i) => !i.valid)) {
595
- // r47: human mode carries the Next steps guidance for every failing
596
- // item kind (bulk path; the single-item path emits per-kind steps).
646
+ const anyFailed = items.some((i) => !i.valid);
647
+ if (anyFailed) {
597
648
  const kinds = new Set(items.filter((i) => !i.valid).map((i) => i.type));
598
649
  console.error('Next steps:');
599
650
  for (const kind of kinds) {
600
651
  for (const s of kind === 'spec' ? SPEC_NEXT_STEPS : CHANGE_NEXT_STEPS) console.error(s);
601
652
  }
602
653
  console.error('Error: validation failed');
654
+ const firstFix = items
655
+ .flatMap((it) => it.issues)
656
+ .map((i) => hintForValidationIssue(i.message))
657
+ .find((h) => h !== null);
658
+ emitCliHint(firstFix, outMode);
659
+ } else if (options.check === true) {
660
+ emitCliHint(
661
+ hintForValidateCheckPass(loadCliConfig(eff.root)?.review?.handoff_mode),
662
+ outMode,
663
+ );
603
664
  }
604
- exitWith(items.some((i) => !i.valid) ? 1 : 0);
665
+ exitWith(anyFailed ? 1 : 0);
605
666
  },
606
667
  );
607
668
  }
package/src/io.ts CHANGED
@@ -74,7 +74,6 @@ export function makeIo(root: string): CliIo {
74
74
  process.kill(pid, 0);
75
75
  return true;
76
76
  } catch (error) {
77
- // EPERM = 进程存在但无权发信号;只有 ESRCH 才能判定死亡。
78
77
  return (error as NodeJS.ErrnoException).code !== 'ESRCH';
79
78
  }
80
79
  },
package/src/main.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env bun
2
- // Execution entry only (cli r107): assemble the command tree via the factory,
3
- // parse argv and render the unified error exits. Safe to import — nothing runs
4
- // unless this module is the main module (guard at the bottom).
5
2
  import { realpathSync } from 'node:fs';
6
3
 
7
4
  import { CliError, makeCliContext } from './cli-shared.ts';
8
5
  import { createProgram } from './program.ts';
9
6
 
10
7
  function commandChain(argv: string[]): string {
11
- // Re-parse argv against a fresh tree for the unknown-command/option usage line.
12
8
  const program = createProgram(makeCliContext());
13
9
  let node = program;
14
10
  let chain = '';
@@ -30,8 +26,6 @@ function commandChain(argv: string[]): string {
30
26
  }
31
27
 
32
28
  async function main(): Promise<void> {
33
- // r108: run context resolved ONCE at assembly time — command bodies take
34
- // io/git/root/cwd from here instead of reading process state ad hoc.
35
29
  const program = createProgram(makeCliContext());
36
30
  try {
37
31
  await program.parseAsync(process.argv);
@@ -43,22 +37,13 @@ async function main(): Promise<void> {
43
37
  comErr?.code === 'commander.helpDisplayed' ||
44
38
  comErr?.exitCode === 0
45
39
  ) {
46
- // version/help already rendered to stdout; exit code stays 0.
47
40
  return;
48
41
  }
49
42
 
50
- // commander strips its own `error: ` short prefix — single `Error: ` + rc=2.
51
43
  const commanderMsg = String(comErr?.message ?? '');
52
44
  const stripCommanderPrefix = (text: string): string => text.replace(/^error:\s*/u, '');
53
45
 
54
- // cli r75: every remaining commander parse failure is a usage error —
55
- // missingArgument / excessArguments / invalidArgument / invalidOption …
56
- // — rendered through the shared single-prefix exit with rc 2. Handler
57
- // level enum validation throws CliError(…, 2) itself (intentional
58
- // divergence from the predecessor's rc 1).
59
46
  if (typeof comErr?.code === 'string' && comErr.code.startsWith('commander.')) {
60
- // r75: an unknown token at root level surfaces as excessArguments (the
61
- // root action owns the bare call) — render the unknown-command shape.
62
47
  const rootExcess =
63
48
  comErr.code === 'commander.excessArguments' &&
64
49
  process.argv.length > 2 &&
@@ -95,13 +80,13 @@ async function main(): Promise<void> {
95
80
  }
96
81
  if (comErr instanceof CliError) {
97
82
  const message = stripCommanderPrefix(comErr.message);
98
- console.error(message.startsWith('Error: ') ? message : `Error: ${message}`);
83
+ if (message !== '') {
84
+ console.error(message.startsWith('Error: ') ? message : `Error: ${message}`);
85
+ }
99
86
  process.exitCode = comErr.exitCode;
100
87
  return;
101
88
  }
102
89
 
103
- // predecessor parity: expected domain errors surface as a single `Error: <message>`
104
- // line on stderr with exit code 1 (no Bun stack trace).
105
90
  const message = stripCommanderPrefix(error instanceof Error ? error.message : String(error));
106
91
  console.error(message.startsWith('Error: ') ? message : `Error: ${message}`);
107
92
  process.exitCode = 1;
package/src/program.ts CHANGED
@@ -15,9 +15,7 @@ import { CliError, versionDisplay, type CliContext } from './cli-shared.ts';
15
15
  import { registerArchive } from './commands/archive.ts';
16
16
  import { registerChange } from './commands/change.ts';
17
17
  import { registerConfig } from './commands/config.ts';
18
- import { registerContext } from './commands/context.ts';
19
18
  import { registerGraph } from './commands/graph.ts';
20
- import { registerIndex } from './commands/index.ts';
21
19
  import { registerInit } from './commands/init.ts';
22
20
  import { registerList } from './commands/list.ts';
23
21
  import { registerProject } from './commands/project.ts';
@@ -25,13 +23,13 @@ import { registerReview } from './commands/review.ts';
25
23
  import { registerSelf } from './commands/self.ts';
26
24
  import { registerShow } from './commands/show.ts';
27
25
  import { registerSpec } from './commands/spec.ts';
26
+ import { registerStudio } from './commands/studio.ts';
27
+ import { registerTheorem } from './commands/theorem.ts';
28
28
  import { registerValidate } from './commands/validate.ts';
29
29
 
30
30
  export function createProgram(ctx: CliContext): Command {
31
31
  const program = new Command();
32
32
 
33
- // Must run before subcommand registration (children copy _exitCallback at
34
- // creation time); exitOverride turns commander's process.exit into a throw.
35
33
  program.exitOverride();
36
34
  program.configureOutput({ outputError: () => {} });
37
35
 
@@ -44,8 +42,6 @@ export function createProgram(ctx: CliContext): Command {
44
42
  'max depth when scanning llmanspec/changes/ for proposal.md (min 1, default 8)',
45
43
  '8',
46
44
  );
47
- // cli r75: a bare root invocation (also with root-only options) equals
48
- // --help — help to stdout, exit 0 via the commander.help path.
49
45
  program.action(() => {
50
46
  program.help();
51
47
  });
@@ -61,22 +57,26 @@ export function createProgram(ctx: CliContext): Command {
61
57
  registerArchive(program, ctx);
62
58
  registerReview(program, ctx);
63
59
  registerConfig(program, ctx);
64
- registerIndex(program, ctx);
65
- registerContext(program, ctx);
66
60
  registerSelf(program, ctx);
61
+ registerStudio(program, ctx);
62
+ registerTheorem(program, ctx);
67
63
 
68
- // cli r75: pure parent groups (no default action of their own) reject bare
69
- // calls as usage errors — commander's missing-action help on stderr, rc 2
70
- // via missingParameter/…; `config` keeps its default action (overview, rc 0).
71
- for (const name of ['change', 'spec', 'project', 'archive', 'index', 'self']) {
72
- const group = program.commands.find((c) => c.name() === name);
73
- if (group === undefined) continue;
64
+ const attachPureParentUsage = (group: Command): void => {
74
65
  group.action(() => {
75
- // commander's configureOutput silenced outputError; render the usage
76
- // line ourselves and exit through the shared CliError path (rc 2).
77
66
  group.outputHelp({ error: true });
78
67
  throw new CliError('', 2);
79
68
  });
69
+ };
70
+ for (const name of ['change', 'spec', 'project', 'self', 'studio', 'theorem']) {
71
+ const group = program.commands.find((c) => c.name() === name);
72
+ if (group === undefined) continue;
73
+ attachPureParentUsage(group);
74
+ if (name === 'studio') {
75
+ for (const subName of ['state', 'comment']) {
76
+ const subGroup = group.commands.find((c) => c.name() === subName);
77
+ if (subGroup !== undefined) attachPureParentUsage(subGroup);
78
+ }
79
+ }
80
80
  }
81
81
 
82
82
  return program;
package/src/progress.ts CHANGED
@@ -49,9 +49,7 @@ export function detectLocale(cwd: string): Locale {
49
49
  const m = cfg.match(/^locale:\s*([A-Za-z-]+)/mu);
50
50
  const normalized = m?.[1] === undefined ? DEFAULT_LOCALE : normalizeLocale(m[1]);
51
51
  return normalized === DEFAULT_LOCALE ? 'zh' : 'en';
52
- } catch {
53
- // No config at cwd — the built-in default locale.
54
- }
52
+ } catch {}
55
53
  return 'zh';
56
54
  }
57
55