@llman-sdd/core 0.9.0 → 0.10.1
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 -1
- package/src/archive/freeze.ts +45 -22
- package/src/archive/frozenCard.ts +3 -2
- package/src/archive/ignoreChain.ts +167 -0
- package/src/archive/sevenzip.ts +17 -8
- package/src/change/collect.ts +17 -14
- package/src/change/deps.ts +54 -0
- package/src/change/frontmatter.ts +36 -5
- package/src/change/lifecycle.ts +124 -20
- package/src/change/nextId.ts +14 -6
- package/src/config/changeId.ts +0 -6
- package/src/config/load.ts +2 -2
- package/src/config/schema.ts +3 -1
- package/src/context/indexStore.ts +14 -14
- package/src/context/sddState.ts +1 -13
- package/src/context/tree.ts +9 -19
- package/src/index.ts +33 -9
- package/src/init/defaultConfig.ts +14 -31
- package/src/init/init.ts +25 -27
- package/src/locale.ts +33 -0
- package/src/project/migrations.ts +79 -9
- package/src/report/graph/deps.ts +3 -38
- package/src/report/graph/nodes.ts +13 -19
- package/src/report/graph/types.ts +2 -6
- package/src/report/show.ts +16 -8
- package/src/report/specHelpers.ts +22 -28
- package/src/review/review.ts +18 -30
- package/src/self/completion.ts +206 -0
- package/src/spec/assignSpecIds.ts +9 -1
- package/src/spec/authoring.ts +11 -11
- package/src/spec/parser.ts +3 -1
- package/src/templates/skills.ts +3 -23
- package/src/util/datedId.ts +18 -0
- package/src/util/fsPort.ts +24 -0
- package/src/util/nextNumber.ts +30 -0
- package/src/util/semver.ts +21 -0
- package/src/validation/changeCheck.ts +133 -67
- package/src/validation/crossRoot.ts +86 -0
- package/src/validation/discover.ts +22 -13
- package/src/validation/roots.ts +2 -5
- package/src/validation/validate.ts +4 -9
- package/src/validation/xstateTransitions.ts +0 -32
- package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +9 -7
- package/templates/zh-Hans/skills/llman-sdd-apply.md +5 -5
- package/templates/zh-Hans/skills/llman-sdd-archive.md +11 -2
- package/templates/zh-Hans/skills/llman-sdd-continue.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-draft.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-explore.md +2 -2
- package/templates/zh-Hans/skills/llman-sdd-ff.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-propose.md +8 -6
- package/templates/zh-Hans/skills/llman-sdd-quick.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-validate.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-verify.md +2 -2
- package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +1 -1
- package/templates/zh-Hans/units/skills/git-native-flow.md +12 -6
- package/templates/zh-Hans/units/skills/index-fallback.md +1 -0
- package/templates/zh-Hans/units/skills/structured-protocol.md +1 -6
- package/templates/zh-Hans/units/spec/feature-contract.md +5 -33
- package/src/templates/locale.ts +0 -24
- package/templates/en/agents-root-stub.md +0 -9
- package/templates/en/llmanspec-agents-stub.md +0 -6
- package/templates/en/skills/llman-sdd-apply-cycle.md +0 -67
- package/templates/en/skills/llman-sdd-apply.md +0 -117
- package/templates/en/skills/llman-sdd-arch-review.md +0 -58
- package/templates/en/skills/llman-sdd-archive.md +0 -70
- package/templates/en/skills/llman-sdd-continue.md +0 -34
- package/templates/en/skills/llman-sdd-draft.md +0 -53
- package/templates/en/skills/llman-sdd-explore.md +0 -64
- package/templates/en/skills/llman-sdd-ff.md +0 -33
- package/templates/en/skills/llman-sdd-graph.md +0 -56
- package/templates/en/skills/llman-sdd-propose.md +0 -105
- package/templates/en/skills/llman-sdd-quick.md +0 -41
- package/templates/en/skills/llman-sdd-research.md +0 -35
- package/templates/en/skills/llman-sdd-specs-compact.md +0 -41
- package/templates/en/skills/llman-sdd-validate.md +0 -28
- package/templates/en/skills/llman-sdd-verify.md +0 -77
- package/templates/en/skills/llman-sdd-wayfinder.md +0 -83
- package/templates/en/units/skills/cli-footer.md +0 -2
- package/templates/en/units/skills/ethics-governance.md +0 -6
- package/templates/en/units/skills/git-native-flow-brief.md +0 -10
- package/templates/en/units/skills/git-native-flow.md +0 -50
- package/templates/en/units/skills/human-readable-summary.md +0 -9
- package/templates/en/units/skills/stage-guard.md +0 -17
- package/templates/en/units/skills/structured-protocol.md +0 -24
- package/templates/en/units/skills/validation-hints.md +0 -20
- package/templates/en/units/skills/version-drift.md +0 -3
- package/templates/en/units/spec/feature-contract.md +0 -38
- package/templates/en/units/workflow/archive-freeze-guidance.md +0 -9
- package/templates/zh-Hans/units/skills/git-native-flow-brief.md +0 -10
- package/templates/zh-Hans/units/workflow/archive-freeze-guidance.md +0 -10
package/src/init/init.ts
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
|
|
11
|
+
import { CHANGES_DIR, SPECS_DIR } from '../change/lifecycle.ts';
|
|
11
12
|
import { loadConfigDetail } from '../config/load.ts';
|
|
12
13
|
import type { SddConfig } from '../config/schema.ts';
|
|
13
14
|
import { writeSddState } from '../context/sddState.ts';
|
|
15
|
+
import { DEFAULT_LOCALE, localeFallbacks, normalizeLocale } from '../locale.ts';
|
|
14
16
|
import { renderTemplate } from '../templates/engine.ts';
|
|
15
|
-
import { localeFallbacks } from '../templates/locale.ts';
|
|
16
17
|
import {
|
|
17
18
|
buildTemplateVars,
|
|
18
19
|
enforceEthicsGovernance,
|
|
@@ -21,14 +22,8 @@ import {
|
|
|
21
22
|
skillCandidates,
|
|
22
23
|
type TemplateIo,
|
|
23
24
|
} from '../templates/skills.ts';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
DEFAULT_CONFIG_ZH_HANS,
|
|
27
|
-
LLMANSPEC_SCHEMA_URL,
|
|
28
|
-
prependSchemaHeader,
|
|
29
|
-
} from './defaultConfig.ts';
|
|
30
|
-
|
|
31
|
-
export { effectiveCheckCommand } from '../templates/skills.ts';
|
|
25
|
+
import { type FsPort } from '../util/fsPort.ts';
|
|
26
|
+
import { DEFAULT_CONFIGS, LLMANSPEC_SCHEMA_URL, prependSchemaHeader } from './defaultConfig.ts';
|
|
32
27
|
|
|
33
28
|
const MARKER_START = '<!-- LLMANSPEC:START -->';
|
|
34
29
|
const MARKER_END = '<!-- LLMANSPEC:END -->';
|
|
@@ -66,26 +61,23 @@ function separatorAfterEndMarker(suffix: string): string {
|
|
|
66
61
|
export const TEMPLATES_ROOT = join(import.meta.dirname, '..', '..', 'templates');
|
|
67
62
|
|
|
68
63
|
/** Repo-root-relative filesystem effects needed by the init flow. */
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
readText
|
|
72
|
-
|
|
73
|
-
mkdirp(path: string): void;
|
|
74
|
-
listDir(path: string): string[];
|
|
75
|
-
removeDir(path: string): void;
|
|
76
|
-
}
|
|
64
|
+
export type InitIo = Pick<
|
|
65
|
+
FsPort,
|
|
66
|
+
'exists' | 'readText' | 'writeText' | 'mkdirp' | 'listDir' | 'removeDir'
|
|
67
|
+
>;
|
|
77
68
|
|
|
78
69
|
function writeDefaultConfig(io: InitIo, locale: string): void {
|
|
79
|
-
const raw = locale
|
|
70
|
+
const raw = DEFAULT_CONFIGS[normalizeLocale(locale)] ?? DEFAULT_CONFIGS[DEFAULT_LOCALE]!;
|
|
80
71
|
io.mkdirp('llmanspec');
|
|
81
72
|
io.writeText('llmanspec/config.yaml', prependSchemaHeader(raw, LLMANSPEC_SCHEMA_URL));
|
|
82
73
|
}
|
|
83
74
|
|
|
84
75
|
/**
|
|
85
76
|
* Effective-locale precedence (init-generators r50): an explicit `locale` key
|
|
86
|
-
* in the workspace config wins; a CLI option fills a missing key; the
|
|
87
|
-
* default (
|
|
88
|
-
* Per-instance: callers resolve per workspace root, no
|
|
77
|
+
* in the workspace config wins; a CLI option fills a missing key; the built-in
|
|
78
|
+
* default (r18-normalized `zh-Hans`, already baked into config.locale here) is
|
|
79
|
+
* the floor. Per-instance: callers resolve per workspace root, no
|
|
80
|
+
* cross-instance inheritance.
|
|
89
81
|
*/
|
|
90
82
|
export function resolveEffectiveLocale(input: {
|
|
91
83
|
configLocale: string;
|
|
@@ -146,7 +138,13 @@ function writeManagedBlocks(
|
|
|
146
138
|
['llmanspec-agents-stub.md', 'llmanspec/AGENTS.md'],
|
|
147
139
|
] as const) {
|
|
148
140
|
const stubRaw = loadLocaleResource(templates, TEMPLATES_ROOT, locales, stubPath);
|
|
149
|
-
if (stubRaw === null)
|
|
141
|
+
if (stubRaw === null) {
|
|
142
|
+
// r19/r18: a missing built-in resource is a broken installation, not a
|
|
143
|
+
// no-op — silent skips shipped AGENTS.md-less workspaces before.
|
|
144
|
+
throw new Error(
|
|
145
|
+
`template resource missing: ${stubPath} (locales tried: ${locales.join(', ')})`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
150
148
|
const existing = io.exists(agentsPath) ? io.readText(agentsPath) : '';
|
|
151
149
|
const body = renderTemplate(stubRaw, new Map(), vars);
|
|
152
150
|
io.writeText(agentsPath, updateFileWithMarkers(existing, body));
|
|
@@ -169,7 +167,7 @@ export function runInit(
|
|
|
169
167
|
// 1) config: create with defaults if missing, then always load.
|
|
170
168
|
const configPath = 'llmanspec/config.yaml';
|
|
171
169
|
const configExisted = io.exists(configPath);
|
|
172
|
-
if (!configExisted) writeDefaultConfig(io, opts.locale ??
|
|
170
|
+
if (!configExisted) writeDefaultConfig(io, opts.locale ?? DEFAULT_LOCALE);
|
|
173
171
|
const config = withEffectiveLocale(
|
|
174
172
|
loadConfigDetail(io.readText(configPath)),
|
|
175
173
|
opts.locale,
|
|
@@ -182,11 +180,11 @@ export function runInit(
|
|
|
182
180
|
writeSddState(io, opts.version);
|
|
183
181
|
|
|
184
182
|
// 2) scaffold directories.
|
|
185
|
-
io.mkdirp(
|
|
186
|
-
io.mkdirp(
|
|
183
|
+
io.mkdirp(SPECS_DIR);
|
|
184
|
+
io.mkdirp(`${CHANGES_DIR}/archive`);
|
|
187
185
|
if (!io.exists('llmanspec/specs/.gitkeep')) io.writeText('llmanspec/specs/.gitkeep', '');
|
|
188
|
-
if (!io.exists(
|
|
189
|
-
io.writeText(
|
|
186
|
+
if (!io.exists(`${CHANGES_DIR}/archive/.gitkeep`)) {
|
|
187
|
+
io.writeText(`${CHANGES_DIR}/archive/.gitkeep`, '');
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
// 3) AGENTS.md managed blocks (root + llmanspec), preserving content.
|
package/src/locale.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale normalization + fallback chain (init-generators capability, r18).
|
|
3
|
+
* Single built-in locale: every recognizable prefix (zh / zh-cn / zh-hans and
|
|
4
|
+
* the en family) and every unknown value normalizes to `zh-Hans`. The branch
|
|
5
|
+
* shape is kept so an English template pack can be re-added later without
|
|
6
|
+
* touching callers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** The one built-in template locale: default value, fallback tail and CLI floor. */
|
|
10
|
+
export const DEFAULT_LOCALE = 'zh-Hans';
|
|
11
|
+
|
|
12
|
+
export function normalizeLocale(value: string): string {
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
if (trimmed === '') return DEFAULT_LOCALE;
|
|
15
|
+
const lower = trimmed.toLowerCase();
|
|
16
|
+
if (lower === 'zh' || lower.startsWith('zh-hans') || lower === 'zh-cn') return DEFAULT_LOCALE;
|
|
17
|
+
if (lower.startsWith('en')) return DEFAULT_LOCALE;
|
|
18
|
+
// Unknown values normalize instead of passing through: with no English pack,
|
|
19
|
+
// an unlisted locale would render nothing at all.
|
|
20
|
+
return DEFAULT_LOCALE;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function localeFallbacks(locale: string): string[] {
|
|
24
|
+
const normalized = normalizeLocale(locale);
|
|
25
|
+
const locales: string[] = [normalized];
|
|
26
|
+
const dash = normalized.indexOf('-');
|
|
27
|
+
if (dash !== -1) {
|
|
28
|
+
const lang = normalized.slice(0, dash);
|
|
29
|
+
if (!locales.includes(lang)) locales.push(lang);
|
|
30
|
+
}
|
|
31
|
+
if (!locales.includes(DEFAULT_LOCALE)) locales.push(DEFAULT_LOCALE);
|
|
32
|
+
return locales;
|
|
33
|
+
}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* handed to any agent verbatim — steps are executable commands, checks are
|
|
7
7
|
* user-verifiable assertions. Pure: no IO, no clock.
|
|
8
8
|
*/
|
|
9
|
+
import { compareSemver as compareVersions } from '../util/semver.ts';
|
|
10
|
+
|
|
11
|
+
export { compareVersions };
|
|
9
12
|
|
|
10
13
|
export interface MigrationItem {
|
|
11
14
|
title: string;
|
|
@@ -88,6 +91,82 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
|
|
|
88
91
|
},
|
|
89
92
|
],
|
|
90
93
|
},
|
|
94
|
+
{
|
|
95
|
+
version: '0.10.0',
|
|
96
|
+
items: [
|
|
97
|
+
{
|
|
98
|
+
title:
|
|
99
|
+
'Templates go zh-Hans single-track: the `en` tree is gone and unknown locales normalize to `zh-Hans`',
|
|
100
|
+
steps: [
|
|
101
|
+
'Optionally pin `locale: zh-Hans` in `llmanspec/config.yaml` — `en` and any unknown value now render Chinese.',
|
|
102
|
+
'Run `llman-sdd init --update` and commit the refreshed managed AGENTS blocks and `.agents/skills/**`.',
|
|
103
|
+
'Re-run `llman-sdd spec skeleton <name>` where a skeleton dialect matters — it now emits `# language: zh-CN`.',
|
|
104
|
+
'Run `llman-sdd validate --all --strict` — it must pass.',
|
|
105
|
+
],
|
|
106
|
+
checks: [
|
|
107
|
+
'No English-rendered managed block or skill remains after `init --update`.',
|
|
108
|
+
'`llman-sdd spec skeleton <name>` emits `# language: zh-CN`.',
|
|
109
|
+
'A missing template resource makes `init` fail instead of silently skipping.',
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
title:
|
|
114
|
+
'Close-out gate tightened: a change whose contract is unchanged can no longer be closed out',
|
|
115
|
+
steps: [
|
|
116
|
+
'For a change that touches the contract, land and commit your `llmanspec/specs/**` edits on the bound branch before closing out.',
|
|
117
|
+
'Set `needs_specs_change: false` in `proposal.md` frontmatter only when the change genuinely needs no contract edit.',
|
|
118
|
+
'Keep `tasks.md` fully checked whenever the file exists.',
|
|
119
|
+
'Run `llman-sdd change finalize <id>` (or `archive`) — the gate runs before any merge and writes nothing on failure.',
|
|
120
|
+
],
|
|
121
|
+
checks: [
|
|
122
|
+
'`llman-sdd change finalize <id>` on a spec-unlanded change fails with zero writes.',
|
|
123
|
+
'A change that landed its specs, or declared `needs_specs_change: false`, still closes out cleanly.',
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
title:
|
|
128
|
+
'Usage errors now exit 2 (bare parent groups, missing arguments, invalid enum values)',
|
|
129
|
+
steps: [
|
|
130
|
+
'Update scripts that keyed on exit code 1 for missing arguments or invalid enum values — those now exit 2.',
|
|
131
|
+
'Expect bare invocation of the five pure parent groups (`change`, `spec`, `project`, `archive`, `index`) to print a usage error and exit 2; `config` keeps its overview action.',
|
|
132
|
+
'Root bare invocation (`llman-sdd`) still exits 0, but help now goes to stdout.',
|
|
133
|
+
'Run `llman-sdd validate --all --strict` — it must pass.',
|
|
134
|
+
],
|
|
135
|
+
checks: [
|
|
136
|
+
'`llman-sdd change` exits 2 and `llman-sdd` exits 0 with help on stdout.',
|
|
137
|
+
'`llman-sdd list --sort bogus` exits 2 (previously 1); domain errors still exit 1.',
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
title:
|
|
142
|
+
'Read-only commands resolve the nearest instance root (`--directory` on every command)',
|
|
143
|
+
steps: [
|
|
144
|
+
'Note that `list`, `show`, `graph`, `review`, `config`, `index` and `context` now start from `--directory <path>` (default cwd) and walk up to the nearest instance root.',
|
|
145
|
+
'Re-check scripts that invoked read-only commands from a subdirectory — they no longer return empty results or leak `ENOENT`.',
|
|
146
|
+
'Use `--directory <path>` on any command to pin the root explicitly.',
|
|
147
|
+
'Run `llman-sdd validate --all --strict` — it must pass.',
|
|
148
|
+
],
|
|
149
|
+
checks: [
|
|
150
|
+
'From a subdirectory, `llman-sdd list` and `llman-sdd config` match the repo-root output.',
|
|
151
|
+
'With no instance root above, the error is `no llmanspec root at or above <path>` (never `ENOENT`).',
|
|
152
|
+
'A single-root repo keeps byte-identical output.',
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
title:
|
|
157
|
+
'`--backend` normalization: empty values, case and the `page-index` alias are accepted',
|
|
158
|
+
steps: [
|
|
159
|
+
'No action required — an empty `--backend`, an empty `LLMAN_SDD_INDEX_BACKEND`, `PAGEINDEX`, `page-index` and padded values now all select the pageindex backend.',
|
|
160
|
+
'Keep using `index rebuild --backend` / `context --backend` unchanged.',
|
|
161
|
+
'Run `llman-sdd validate --all --strict` — it must pass.',
|
|
162
|
+
],
|
|
163
|
+
checks: [
|
|
164
|
+
'`llman-sdd index rebuild --backend page-index` and an empty `--backend` succeed (previously exit 1).',
|
|
165
|
+
'A legacy `rag/` directory never satisfies pageindex freshness.',
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
91
170
|
];
|
|
92
171
|
|
|
93
172
|
const VERSION_RE = /^\d+\.\d+\.\d+$/u;
|
|
@@ -97,15 +176,6 @@ export function isValidVersion(version: string): boolean {
|
|
|
97
176
|
return VERSION_RE.test(version);
|
|
98
177
|
}
|
|
99
178
|
|
|
100
|
-
/** Numeric `x.y.z` comparison; negative when a < b, 0 when equal. */
|
|
101
|
-
export function compareVersions(a: string, b: string): number {
|
|
102
|
-
const [aMajor, aMinor, aPatch] = a.split('.').map(Number) as [number, number, number];
|
|
103
|
-
const [bMajor, bMinor, bPatch] = b.split('.').map(Number) as [number, number, number];
|
|
104
|
-
if (aMajor !== bMajor) return aMajor - bMajor;
|
|
105
|
-
if (aMinor !== bMinor) return aMinor - bMinor;
|
|
106
|
-
return aPatch - bPatch;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
179
|
/** Versions `(from, to]` that carry registered migrations, ascending. */
|
|
110
180
|
export function resolveMigrations(from: string, to: string): MigrationDoc[] {
|
|
111
181
|
return MIGRATIONS.filter(
|
package/src/report/graph/deps.ts
CHANGED
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
/** Extract depends_on entries (
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* r54 dual-format card reading: a fence-free frozen card is a plain YAML doc
|
|
6
|
-
* whose FIRST line opens with `title:`/`depends_on:` — feed the whole text to
|
|
7
|
-
* the same depends_on scan. Proposal.md bodies never open with those keys, so
|
|
8
|
-
* no misfire.
|
|
9
|
-
*/
|
|
10
|
-
function cardYamlSource(input: string): string | null {
|
|
11
|
-
const firstLine = input.trimStart().split('\n')[0] ?? '';
|
|
12
|
-
return /^(title|depends_on):/u.test(firstLine) ? input : null;
|
|
13
|
-
}
|
|
1
|
+
/** Extract depends_on entries (r30): lenient policy over the shared reader. */
|
|
2
|
+
import { readDepsLenient } from '../../change/deps.ts';
|
|
14
3
|
|
|
15
4
|
export function parseDeps(proposal: string): string[] {
|
|
16
|
-
|
|
17
|
-
const deps: string[] = [];
|
|
18
|
-
if (!fm) return deps;
|
|
19
|
-
let inDeps = false;
|
|
20
|
-
for (const line of fm.split('\n')) {
|
|
21
|
-
const flow = line.match(/^depends_on:\s*\[([^\]]*)\]\s*$/u);
|
|
22
|
-
if (flow) {
|
|
23
|
-
for (const item of flow[1]?.split(',') ?? []) {
|
|
24
|
-
const dep = item.trim().replaceAll(/^['"]|['"]$/gu, '');
|
|
25
|
-
if (dep !== '' && !/^[0-9]+$/u.test(dep)) deps.push(dep);
|
|
26
|
-
}
|
|
27
|
-
inDeps = false;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (/^depends_on:\s*$/u.test(line)) {
|
|
31
|
-
inDeps = true;
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (inDeps) {
|
|
35
|
-
const m = line.match(/^\s*-\s+(\S+)/u);
|
|
36
|
-
if (m?.[1] && !/^[0-9]+$/u.test(m[1])) deps.push(m[1]);
|
|
37
|
-
else if (line.trim() !== '') inDeps = false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return deps;
|
|
5
|
+
return readDepsLenient(proposal);
|
|
41
6
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { frozenCardIdOf, isFrozenCard } from '../../archive/frozenCard.ts';
|
|
2
|
+
import { walkActiveChangeDirs } from '../../change/collect.ts';
|
|
2
3
|
import { CHANGES_DIR } from '../../change/lifecycle.ts';
|
|
4
|
+
import { datedIdOf } from '../../util/datedId.ts';
|
|
3
5
|
import type { GraphFsIo, GraphNode, ScopeKind } from './types.ts';
|
|
4
6
|
|
|
5
7
|
function extractArchivedId(name: string): string | null {
|
|
6
|
-
|
|
7
|
-
return m ? (m[1] ?? null) : null;
|
|
8
|
+
return datedIdOf(name);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/** Active nodes: dirs (recursively, depth-limited) with a proposal.md (r58). */
|
|
@@ -13,24 +14,17 @@ export function collectActiveNodes(
|
|
|
13
14
|
root: string,
|
|
14
15
|
maxScanDepth?: number,
|
|
15
16
|
): GraphNode[] {
|
|
17
|
+
// T23: the active-change traversal is the shared walk (change/collect) —
|
|
18
|
+
// graph nodes are just its (dir, name) pairs mapped to the node shape.
|
|
16
19
|
const out: GraphNode[] = [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!io.isDirectory(child)) continue;
|
|
26
|
-
if (io.exists(`${child}/proposal.md`)) {
|
|
27
|
-
out.push({ id: name, archived: false, present: true });
|
|
28
|
-
} else if (depth < maxDepth) {
|
|
29
|
-
visit(child, depth + 1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
visit(changesDir, 1);
|
|
20
|
+
walkActiveChangeDirs(
|
|
21
|
+
io,
|
|
22
|
+
`${root}/${CHANGES_DIR}`,
|
|
23
|
+
(_dir, name) => {
|
|
24
|
+
out.push({ id: name, archived: false, present: true });
|
|
25
|
+
},
|
|
26
|
+
{ maxScanDepth },
|
|
27
|
+
);
|
|
34
28
|
return out;
|
|
35
29
|
}
|
|
36
30
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readText(path: string): string;
|
|
4
|
-
listDir(path: string): string[];
|
|
5
|
-
isDirectory(path: string): boolean;
|
|
6
|
-
}
|
|
1
|
+
import { type FsPort } from '../../util/fsPort.ts';
|
|
2
|
+
export type GraphFsIo = Pick<FsPort, 'exists' | 'readText' | 'listDir' | 'isDirectory'>;
|
|
7
3
|
|
|
8
4
|
export interface GraphNode {
|
|
9
5
|
id: string;
|
package/src/report/show.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { changeTitle, countTasks, stageFor, type ChangeFsIo } from '../change/collect.ts';
|
|
2
2
|
import {
|
|
3
3
|
extractFrontmatter,
|
|
4
4
|
readBinding,
|
|
5
5
|
readNeedsSpecsChange,
|
|
6
|
+
DEFAULT_SPECS_PREFIX,
|
|
6
7
|
specsLanded as specsLandedOf,
|
|
7
8
|
} from '../change/frontmatter.ts';
|
|
8
9
|
import { CHANGES_DIR } from '../change/lifecycle.ts';
|
|
@@ -25,6 +26,8 @@ export interface ShowDeps {
|
|
|
25
26
|
git: GitLike;
|
|
26
27
|
root: string;
|
|
27
28
|
specsDir: string;
|
|
29
|
+
/** r119: instance-relative specs prefix of this root (specs-landed gate). */
|
|
30
|
+
specsPrefix?: string;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export function showChangeJson(
|
|
@@ -62,14 +65,16 @@ export function showChangeJson(
|
|
|
62
65
|
const onBoundBranch = binding !== null && current === binding.branch;
|
|
63
66
|
|
|
64
67
|
// specs landing: bound changes must have touched llmanspec/specs/ since base
|
|
68
|
+
// (r119: judged under THIS instance's prefix, not the repo-root literal)
|
|
69
|
+
const specsPrefix = deps.specsPrefix ?? DEFAULT_SPECS_PREFIX;
|
|
65
70
|
let landedOnBranch = false;
|
|
66
71
|
if (binding !== null) {
|
|
67
|
-
landedOnBranch = specsLandedOf(git, binding);
|
|
72
|
+
landedOnBranch = specsLandedOf(git, binding, specsPrefix);
|
|
68
73
|
}
|
|
69
74
|
const needsSpecsChange = readNeedsSpecsChange(extractFrontmatter(proposal));
|
|
70
75
|
|
|
71
76
|
const tasksDone = total > 0 && completed >= total;
|
|
72
|
-
const specReport = validateAllSpecs(discoverSpecs(deps.specsDir, io)
|
|
77
|
+
const specReport = validateAllSpecs(discoverSpecs(deps.specsDir, io));
|
|
73
78
|
const validateOk = !specReport.failed && (total === 0 || tasksDone);
|
|
74
79
|
|
|
75
80
|
const stageHint = !hasDesign
|
|
@@ -79,10 +84,13 @@ export function showChangeJson(
|
|
|
79
84
|
: stage === 'planned'
|
|
80
85
|
? 'bind via `llman-sdd change start <id>` (planned → full)'
|
|
81
86
|
: '';
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
// T34: a missing tasks.md has nothing to check off — the hint says so
|
|
88
|
+
// instead of the legacy "complete or check off remaining tasks".
|
|
89
|
+
const tasksHint = hasTasks
|
|
90
|
+
? total > 0 && completed < total
|
|
84
91
|
? `${total - completed} unchecked tasks`
|
|
85
|
-
: 'complete or check off remaining tasks'
|
|
92
|
+
: 'complete or check off remaining tasks'
|
|
93
|
+
: 'no tasks.md — seal-off needs no checked tasks';
|
|
86
94
|
|
|
87
95
|
const gateChecks = [
|
|
88
96
|
{
|
|
@@ -106,7 +114,7 @@ export function showChangeJson(
|
|
|
106
114
|
hint:
|
|
107
115
|
landedOnBranch || !needsSpecsChange
|
|
108
116
|
? ''
|
|
109
|
-
:
|
|
117
|
+
: `edit live specs under ${specsPrefix} on the bound branch and commit (or set needs_specs_change to false)`,
|
|
110
118
|
},
|
|
111
119
|
{
|
|
112
120
|
name: 'tasks-done',
|
|
@@ -123,7 +131,7 @@ export function showChangeJson(
|
|
|
123
131
|
return {
|
|
124
132
|
id,
|
|
125
133
|
path: id,
|
|
126
|
-
title:
|
|
134
|
+
title: changeTitle(proposal),
|
|
127
135
|
stage,
|
|
128
136
|
artifacts,
|
|
129
137
|
readyToImplement: gateChecks.every((g) => g.pass),
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import { assignSpecIds } from '../spec/assignSpecIds.ts';
|
|
2
|
-
import { officialKeywords, officialKeywordsOrEn } from '../spec/keywords.ts';
|
|
3
|
-
import { localeToGherkinLang, parseCapability } from '../spec/parser.ts';
|
|
4
|
-
import { buildReqRegistry } from '../spec/reqRegistry.ts';
|
|
5
1
|
/**
|
|
6
2
|
* Spec authoring helpers (peripheral-commands capability, r22):
|
|
7
3
|
* skeleton generation + global next req id. Pure, IO injected.
|
|
8
4
|
*/
|
|
9
|
-
import { localeFallbacks } from '../
|
|
5
|
+
import { localeFallbacks } from '../locale.ts';
|
|
6
|
+
import { assignSpecIds } from '../spec/assignSpecIds.ts';
|
|
7
|
+
import { officialKeywords, officialKeywordsOrEn } from '../spec/keywords.ts';
|
|
8
|
+
import { localeToGherkinLang, parseCapability } from '../spec/parser.ts';
|
|
9
|
+
import { buildReqRegistry } from '../spec/reqRegistry.ts';
|
|
10
|
+
import { type FsPort } from '../util/fsPort.ts';
|
|
11
|
+
import { nextNumber } from '../util/nextNumber.ts';
|
|
12
|
+
import { discoverFeatureFiles } from '../validation/discover.ts';
|
|
10
13
|
import type { SpecEntry } from '../validation/validate.ts';
|
|
11
14
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
readText
|
|
15
|
-
|
|
16
|
-
mkdirp(path: string): void;
|
|
17
|
-
isDirectory(path: string): boolean;
|
|
18
|
-
listDir(path: string): string[];
|
|
19
|
-
}
|
|
15
|
+
export type SpecHelperIo = Pick<
|
|
16
|
+
FsPort,
|
|
17
|
+
'exists' | 'readText' | 'writeText' | 'mkdirp' | 'isDirectory' | 'listDir'
|
|
18
|
+
>;
|
|
20
19
|
|
|
21
20
|
function collectSpecEntries(io: SpecHelperIo, specsDir: string): SpecEntry[] {
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} else if (io.isDirectory(full)) {
|
|
30
|
-
walk(full);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
walk(specsDir);
|
|
35
|
-
assignSpecIds(entries, specsDir);
|
|
21
|
+
// T24: shared discovery — identical ordering/norm as the hash walk.
|
|
22
|
+
const normDir = specsDir.replace(/\\/g, '/').replace(/\/$/u, '');
|
|
23
|
+
const entries = discoverFeatureFiles(normDir, io).map((path) => ({
|
|
24
|
+
fileName: path,
|
|
25
|
+
doc: parseCapability(io.readText(path), path),
|
|
26
|
+
}));
|
|
27
|
+
assignSpecIds(entries, normDir);
|
|
36
28
|
return entries;
|
|
37
29
|
}
|
|
38
30
|
|
|
@@ -49,7 +41,9 @@ export function nextReqId(io: SpecHelperIo, specsDir: string): string {
|
|
|
49
41
|
const used = [...buildReqRegistry(entries).byId.keys()].map((reqId) =>
|
|
50
42
|
Math.trunc(Number(reqId.replace(/^r/u, ''))),
|
|
51
43
|
);
|
|
52
|
-
|
|
44
|
+
// SSOT: the numeric-id allocator primitive (unify-numeric-id-allocation) —
|
|
45
|
+
// never a second max+1 fold. Same source as change sequence numbers.
|
|
46
|
+
return `r${nextNumber(used)}`;
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
export function skeletonContent(capability: string, reqId: string, locale: string): string {
|
package/src/review/review.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ruleHasRunnableScenario, specIdOf } from '../spec/ir.ts';
|
|
2
1
|
/**
|
|
3
2
|
* Review aggregation (review-freeze capability, r23): five-signal review over
|
|
4
3
|
* spec IR + validate sweep. Port of predecessor sdd/review.rs observable contract.
|
|
5
4
|
*/
|
|
6
|
-
import {
|
|
5
|
+
import { collectUnboundRequirements } from '../report/unbound.ts';
|
|
6
|
+
import { specIdOf } from '../spec/ir.ts';
|
|
7
|
+
import { validateAllSpecs, type SpecEntry } from '../validation/validate.ts';
|
|
7
8
|
|
|
8
9
|
export type ReviewKind = 'unbound' | 'locked' | 'validate';
|
|
9
10
|
|
|
@@ -31,7 +32,7 @@ export interface ReviewResult {
|
|
|
31
32
|
exitCode: number;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
export function buildReview(input: ReviewInput
|
|
35
|
+
export function buildReview(input: ReviewInput): ReviewResult {
|
|
35
36
|
const { entries, boundChangeCount } = input;
|
|
36
37
|
const strictChangeFails = (input.activeChanges ?? []).filter(
|
|
37
38
|
(c) => c.totalTasks > 0 && c.completedTasks < c.totalTasks,
|
|
@@ -41,41 +42,29 @@ export function buildReview(input: ReviewInput, io: SpecIo): ReviewResult {
|
|
|
41
42
|
signals.push({ kind, capability, count, detail });
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
const sweep = validateAllSpecs(entries
|
|
45
|
+
const sweep = validateAllSpecs(entries);
|
|
45
46
|
const sorted = [...entries].toSorted((a, b) => a.fileName.localeCompare(b.fileName));
|
|
46
47
|
|
|
48
|
+
// T29: unbound counting is the shared collector (report/unbound) keyed by
|
|
49
|
+
// capability — one definition of "rule without runnable scenario".
|
|
50
|
+
const unboundByCap = new Map<string, number>();
|
|
51
|
+
for (const u of collectUnboundRequirements(entries)) {
|
|
52
|
+
unboundByCap.set(u.capability, (unboundByCap.get(u.capability) ?? 0) + 1);
|
|
53
|
+
}
|
|
47
54
|
for (const entry of sorted) {
|
|
48
55
|
const cap = specIdOf(entry);
|
|
49
56
|
// r33: per-capability signals honor the --capability filter; locked and
|
|
50
57
|
// validate stay global regardless.
|
|
51
58
|
if (input.capability !== undefined && cap !== input.capability) continue;
|
|
52
|
-
|
|
53
|
-
// nested scenario is unbound (not bound to real logic — 0 scenarios or
|
|
54
|
-
// all @skip/@experimental/stepless). Top-level scenarios outside any rule
|
|
55
|
-
// are plain feature-level examples with no special signal.
|
|
56
|
-
const unbound = entry.doc.rules.filter((r) => !ruleHasRunnableScenario(r)).length;
|
|
57
|
-
|
|
58
|
-
push('unbound', cap, unbound);
|
|
59
|
+
push('unbound', cap, unboundByCap.get(cap) ?? 0);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const failed = sweep.verdicts.filter((v) => !v.ok);
|
|
62
63
|
const sweepFailedCount = failed.length;
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fileName: c.name,
|
|
68
|
-
capability: c.name,
|
|
69
|
-
ok: false,
|
|
70
|
-
items: [
|
|
71
|
-
{
|
|
72
|
-
level: 'ERROR',
|
|
73
|
-
id: `${c.name}/tasks`,
|
|
74
|
-
message: `${c.totalTasks - c.completedTasks} unchecked tasks`,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
});
|
|
78
|
-
}
|
|
64
|
+
// T35: unchecked tasks are work-in-progress noise, not contract breakage —
|
|
65
|
+
// they degrade to a warningCount contribution instead of the critical count
|
|
66
|
+
// (locked/unbound signals stay untouched).
|
|
67
|
+
const taskWarnings = strictChangeFails.length;
|
|
79
68
|
// predecessor parity: `count` is the removed locked-rule-confirmation concept (always
|
|
80
69
|
// 0 now); the detail text carries the bound-change count separately.
|
|
81
70
|
push(
|
|
@@ -102,9 +91,8 @@ export function buildReview(input: ReviewInput, io: SpecIo): ReviewResult {
|
|
|
102
91
|
[sweepDetail, strictDetail].filter(Boolean).join('; ') || 'ok',
|
|
103
92
|
);
|
|
104
93
|
|
|
105
|
-
const warningCount =
|
|
106
|
-
.filter((s) => s.kind === 'unbound')
|
|
107
|
-
.reduce((acc, s) => acc + s.count, 0);
|
|
94
|
+
const warningCount =
|
|
95
|
+
signals.filter((s) => s.kind === 'unbound').reduce((acc, s) => acc + s.count, 0) + taskWarnings;
|
|
108
96
|
const criticalCount = failed.length;
|
|
109
97
|
|
|
110
98
|
const lines: string[] = [`Review: critical=${criticalCount} warning=${warningCount}`];
|