@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/program.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T17 program factory (cli r107): builds the full command tree WITHOUT
|
|
3
|
+
* parsing argv or running any action. Importing this module (or calling
|
|
4
|
+
* `createProgram`) must never execute a command — `main.ts` is the only
|
|
5
|
+
* assembly+run entry.
|
|
6
|
+
*
|
|
7
|
+
* Assembly order is load-bearing: commander children copy _exitCallback at
|
|
8
|
+
* creation time, so exitOverride/configureOutput must run before any
|
|
9
|
+
* `registerXxx` call, and the register calls below must keep the original
|
|
10
|
+
* top-level command order (help text renders in registration order).
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
|
|
14
|
+
import { CliError, versionDisplay, type CliContext } from './cli-shared.ts';
|
|
15
|
+
import { registerArchive } from './commands/archive.ts';
|
|
16
|
+
import { registerChange } from './commands/change.ts';
|
|
17
|
+
import { registerConfig } from './commands/config.ts';
|
|
18
|
+
import { registerContext } from './commands/context.ts';
|
|
19
|
+
import { registerGraph } from './commands/graph.ts';
|
|
20
|
+
import { registerIndex } from './commands/index.ts';
|
|
21
|
+
import { registerInit } from './commands/init.ts';
|
|
22
|
+
import { registerList } from './commands/list.ts';
|
|
23
|
+
import { registerProject } from './commands/project.ts';
|
|
24
|
+
import { registerReview } from './commands/review.ts';
|
|
25
|
+
import { registerSelf } from './commands/self.ts';
|
|
26
|
+
import { registerShow } from './commands/show.ts';
|
|
27
|
+
import { registerSpec } from './commands/spec.ts';
|
|
28
|
+
import { registerValidate } from './commands/validate.ts';
|
|
29
|
+
|
|
30
|
+
export function createProgram(ctx: CliContext): Command {
|
|
31
|
+
const program = new Command();
|
|
32
|
+
|
|
33
|
+
// Must run before subcommand registration (children copy _exitCallback at
|
|
34
|
+
// creation time); exitOverride turns commander's process.exit into a throw.
|
|
35
|
+
program.exitOverride();
|
|
36
|
+
program.configureOutput({ outputError: () => {} });
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.name('llman-sdd')
|
|
40
|
+
.description('Spec-driven development workflow')
|
|
41
|
+
.version(versionDisplay());
|
|
42
|
+
program.option(
|
|
43
|
+
'--max-scan-depth <n>',
|
|
44
|
+
'max depth when scanning llmanspec/changes/ for proposal.md (min 1, default 8)',
|
|
45
|
+
'8',
|
|
46
|
+
);
|
|
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
|
+
program.action(() => {
|
|
50
|
+
program.help();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
registerInit(program, ctx);
|
|
54
|
+
registerValidate(program, ctx);
|
|
55
|
+
registerChange(program, ctx);
|
|
56
|
+
registerList(program, ctx);
|
|
57
|
+
registerShow(program, ctx);
|
|
58
|
+
registerGraph(program, ctx);
|
|
59
|
+
registerSpec(program, ctx);
|
|
60
|
+
registerProject(program, ctx);
|
|
61
|
+
registerArchive(program, ctx);
|
|
62
|
+
registerReview(program, ctx);
|
|
63
|
+
registerConfig(program, ctx);
|
|
64
|
+
registerIndex(program, ctx);
|
|
65
|
+
registerContext(program, ctx);
|
|
66
|
+
registerSelf(program, ctx);
|
|
67
|
+
|
|
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;
|
|
74
|
+
group.action(() => {
|
|
75
|
+
// commander's configureOutput silenced outputError; render the usage
|
|
76
|
+
// line ourselves and exit through the shared CliError path (rc 2).
|
|
77
|
+
group.outputHelp({ error: true });
|
|
78
|
+
throw new CliError('', 2);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return program;
|
|
83
|
+
}
|
package/src/progress.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Localized stage-progress notes (B1): genuinely long-running operations print
|
|
3
6
|
* a short one-line stderr note in the project locale (zh → zh-Hans text,
|
|
@@ -6,8 +9,7 @@
|
|
|
6
9
|
* progress on stderr); each key fires at most once per process; notes are only
|
|
7
10
|
* emitted before the long op itself, never ahead of domain errors.
|
|
8
11
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { join } from 'node:path';
|
|
12
|
+
import { DEFAULT_LOCALE, normalizeLocale } from '@llman-sdd/core';
|
|
11
13
|
|
|
12
14
|
type Locale = 'zh' | 'en';
|
|
13
15
|
|
|
@@ -35,16 +37,22 @@ export function resolveNote(key: string, locale: Locale): string | undefined {
|
|
|
35
37
|
return NOTES[key]?.[locale];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Detect the project locale from llmanspec/config.yaml. r18 normalizes every
|
|
42
|
+
* locale (including `en` and unknown values) to the built-in zh-Hans, so the
|
|
43
|
+
* Chinese note arm is always selected; the English arm stays as the i18n
|
|
44
|
+
* mechanism's other side, no longer reachable from config.
|
|
45
|
+
*/
|
|
39
46
|
export function detectLocale(cwd: string): Locale {
|
|
40
47
|
try {
|
|
41
48
|
const cfg = readFileSync(join(cwd, 'llmanspec', 'config.yaml'), 'utf8');
|
|
42
49
|
const m = cfg.match(/^locale:\s*([A-Za-z-]+)/mu);
|
|
43
|
-
|
|
50
|
+
const normalized = m?.[1] === undefined ? DEFAULT_LOCALE : normalizeLocale(m[1]);
|
|
51
|
+
return normalized === DEFAULT_LOCALE ? 'zh' : 'en';
|
|
44
52
|
} catch {
|
|
45
|
-
// No config at cwd —
|
|
53
|
+
// No config at cwd — the built-in default locale.
|
|
46
54
|
}
|
|
47
|
-
return '
|
|
55
|
+
return 'zh';
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
const shown = new Set<string>();
|