@llman-sdd/core 0.9.0 → 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.
Files changed (88) hide show
  1. package/package.json +1 -1
  2. package/src/archive/freeze.ts +15 -15
  3. package/src/archive/frozenCard.ts +3 -2
  4. package/src/change/collect.ts +17 -14
  5. package/src/change/deps.ts +54 -0
  6. package/src/change/frontmatter.ts +36 -5
  7. package/src/change/lifecycle.ts +124 -20
  8. package/src/change/nextId.ts +14 -6
  9. package/src/config/changeId.ts +0 -6
  10. package/src/config/load.ts +2 -2
  11. package/src/config/schema.ts +3 -1
  12. package/src/context/indexStore.ts +14 -14
  13. package/src/context/sddState.ts +1 -13
  14. package/src/context/tree.ts +9 -19
  15. package/src/index.ts +25 -9
  16. package/src/init/defaultConfig.ts +14 -31
  17. package/src/init/init.ts +25 -27
  18. package/src/locale.ts +33 -0
  19. package/src/project/migrations.ts +79 -9
  20. package/src/report/graph/deps.ts +3 -38
  21. package/src/report/graph/nodes.ts +13 -19
  22. package/src/report/graph/types.ts +2 -6
  23. package/src/report/show.ts +16 -8
  24. package/src/report/specHelpers.ts +22 -28
  25. package/src/review/review.ts +18 -30
  26. package/src/self/completion.ts +206 -0
  27. package/src/spec/assignSpecIds.ts +9 -1
  28. package/src/spec/authoring.ts +11 -11
  29. package/src/spec/parser.ts +3 -1
  30. package/src/templates/skills.ts +3 -23
  31. package/src/util/datedId.ts +18 -0
  32. package/src/util/fsPort.ts +24 -0
  33. package/src/util/nextNumber.ts +30 -0
  34. package/src/util/semver.ts +21 -0
  35. package/src/validation/changeCheck.ts +133 -67
  36. package/src/validation/crossRoot.ts +86 -0
  37. package/src/validation/discover.ts +22 -13
  38. package/src/validation/roots.ts +2 -5
  39. package/src/validation/validate.ts +4 -9
  40. package/src/validation/xstateTransitions.ts +0 -32
  41. package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +9 -7
  42. package/templates/zh-Hans/skills/llman-sdd-apply.md +5 -5
  43. package/templates/zh-Hans/skills/llman-sdd-archive.md +11 -2
  44. package/templates/zh-Hans/skills/llman-sdd-continue.md +1 -1
  45. package/templates/zh-Hans/skills/llman-sdd-draft.md +1 -1
  46. package/templates/zh-Hans/skills/llman-sdd-explore.md +2 -2
  47. package/templates/zh-Hans/skills/llman-sdd-ff.md +1 -1
  48. package/templates/zh-Hans/skills/llman-sdd-propose.md +8 -6
  49. package/templates/zh-Hans/skills/llman-sdd-quick.md +1 -1
  50. package/templates/zh-Hans/skills/llman-sdd-validate.md +1 -1
  51. package/templates/zh-Hans/skills/llman-sdd-verify.md +2 -2
  52. package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +1 -1
  53. package/templates/zh-Hans/units/skills/git-native-flow.md +12 -6
  54. package/templates/zh-Hans/units/skills/index-fallback.md +1 -0
  55. package/templates/zh-Hans/units/skills/structured-protocol.md +1 -6
  56. package/templates/zh-Hans/units/spec/feature-contract.md +5 -33
  57. package/src/templates/locale.ts +0 -24
  58. package/templates/en/agents-root-stub.md +0 -9
  59. package/templates/en/llmanspec-agents-stub.md +0 -6
  60. package/templates/en/skills/llman-sdd-apply-cycle.md +0 -67
  61. package/templates/en/skills/llman-sdd-apply.md +0 -117
  62. package/templates/en/skills/llman-sdd-arch-review.md +0 -58
  63. package/templates/en/skills/llman-sdd-archive.md +0 -70
  64. package/templates/en/skills/llman-sdd-continue.md +0 -34
  65. package/templates/en/skills/llman-sdd-draft.md +0 -53
  66. package/templates/en/skills/llman-sdd-explore.md +0 -64
  67. package/templates/en/skills/llman-sdd-ff.md +0 -33
  68. package/templates/en/skills/llman-sdd-graph.md +0 -56
  69. package/templates/en/skills/llman-sdd-propose.md +0 -105
  70. package/templates/en/skills/llman-sdd-quick.md +0 -41
  71. package/templates/en/skills/llman-sdd-research.md +0 -35
  72. package/templates/en/skills/llman-sdd-specs-compact.md +0 -41
  73. package/templates/en/skills/llman-sdd-validate.md +0 -28
  74. package/templates/en/skills/llman-sdd-verify.md +0 -77
  75. package/templates/en/skills/llman-sdd-wayfinder.md +0 -83
  76. package/templates/en/units/skills/cli-footer.md +0 -2
  77. package/templates/en/units/skills/ethics-governance.md +0 -6
  78. package/templates/en/units/skills/git-native-flow-brief.md +0 -10
  79. package/templates/en/units/skills/git-native-flow.md +0 -50
  80. package/templates/en/units/skills/human-readable-summary.md +0 -9
  81. package/templates/en/units/skills/stage-guard.md +0 -17
  82. package/templates/en/units/skills/structured-protocol.md +0 -24
  83. package/templates/en/units/skills/validation-hints.md +0 -20
  84. package/templates/en/units/skills/version-drift.md +0 -3
  85. package/templates/en/units/spec/feature-contract.md +0 -38
  86. package/templates/en/units/workflow/archive-freeze-guidance.md +0 -9
  87. package/templates/zh-Hans/units/skills/git-native-flow-brief.md +0 -10
  88. package/templates/zh-Hans/units/workflow/archive-freeze-guidance.md +0 -10
@@ -4,9 +4,10 @@
4
4
  * predecessor's tree.json so retrieval IDs stay comparable.
5
5
  */
6
6
  import { createHash } from 'node:crypto';
7
- import { join } from 'node:path';
8
7
 
9
8
  import { specIdOf } from '../spec/ir.ts';
9
+ import { type FsPort } from '../util/fsPort.ts';
10
+ import { discoverFeatureFiles } from '../validation/discover.ts';
10
11
  import type { SpecEntry } from '../validation/validate.ts';
11
12
 
12
13
  export const TREE_VERSION = 1;
@@ -96,27 +97,16 @@ export function buildTreeIndex(
96
97
  };
97
98
  }
98
99
 
99
- export interface HashIo {
100
- exists(p: string): boolean;
101
- isDirectory(p: string): boolean;
102
- listDir(p: string): string[];
103
- readText(p: string): string;
104
- }
100
+ export type HashIo = Pick<FsPort, 'exists' | 'isDirectory' | 'listDir' | 'readText'>;
105
101
 
106
102
  /** sha256 over all .feature files, sorted by path (r26 freshness anchor). */
107
103
  export function computeSpecHash(specsDir: string, io: HashIo): string {
108
104
  const hash = createHash('sha256');
109
- const walk = (dir: string): void => {
110
- if (!io.exists(dir) || !io.isDirectory(dir)) return;
111
- for (const name of io.listDir(dir).toSorted()) {
112
- const full = join(dir, name);
113
- if (io.isDirectory(full)) walk(full);
114
- else if (name.endsWith('.feature')) {
115
- hash.update(full);
116
- hash.update(io.readText(full));
117
- }
118
- }
119
- };
120
- walk(specsDir);
105
+ // T24: shared discovery — the hashed path set/order is exactly the parser's,
106
+ // so editing specs cannot desynchronize freshness from parse coverage.
107
+ for (const full of discoverFeatureFiles(specsDir.replace(/\\/g, '/').replace(/\/$/u, ''), io)) {
108
+ hash.update(full);
109
+ hash.update(io.readText(full));
110
+ }
121
111
  return hash.digest('hex');
122
112
  }
package/src/index.ts CHANGED
@@ -18,7 +18,6 @@ export {
18
18
  export {
19
19
  ChangeIdError,
20
20
  compileChangeIdPattern,
21
- nextUniqueNumber,
22
21
  renderChangeIdTemplate,
23
22
  } from './config/changeId.ts';
24
23
  export { renderConfigOverview, skillsJson } from './config/surface.ts';
@@ -92,7 +91,6 @@ export {
92
91
  } from './spec/authoring.ts';
93
92
  export type {
94
93
  SpecEntry,
95
- SpecIo,
96
94
  SpecVerdict,
97
95
  ValidationItem,
98
96
  ValidationLevel,
@@ -101,14 +99,9 @@ export type {
101
99
  export { validateAllSpecs, validateCapability } from './validation/validate.ts';
102
100
  export { buildDuplicatesFor, formatTotals } from './validation/validate.ts';
103
101
  export {
104
- ESCAPE_TRANSITIONS_TAG,
105
- FORCE_TRANSITIONS_TAG,
106
102
  TRANSITIONS_INTROSPECTION,
107
103
  isTransitionOutline,
108
- parseTransitionExpr,
109
- resolveTransitionDecision,
110
104
  type TransitionDecision,
111
- validateTransitionScenario,
112
105
  type TransitionEdge,
113
106
  } from './validation/xstateTransitions.ts';
114
107
  export { splitVerb } from './config/changeId.ts';
@@ -116,6 +109,7 @@ export {
116
109
  checkChangeDoc,
117
110
  validateChange,
118
111
  checkGlobalChangeIdUniqueness,
112
+ collectChangeIdValues,
119
113
  STAGE_ORDER,
120
114
  type ChangeCheckConfig,
121
115
  type ChangeCheckInput,
@@ -133,6 +127,12 @@ export {
133
127
  type RootEntry,
134
128
  type RootsIo,
135
129
  } from './validation/roots.ts';
130
+ export {
131
+ computeCrossRootCollisions,
132
+ type CrossRootCollision,
133
+ type CrossRootNamespace,
134
+ type RootNamespaceValues,
135
+ } from './validation/crossRoot.ts';
136
136
  export {
137
137
  expandRunCommand,
138
138
  runHarnessForSpecs,
@@ -148,6 +148,7 @@ export {
148
148
  extractFrontmatter,
149
149
  readFrontmatterTitle,
150
150
  readNeedsSpecsChange,
151
+ specsPrefixOfInstance,
151
152
  } from './change/frontmatter.ts';
152
153
  export {
153
154
  GitError,
@@ -192,7 +193,7 @@ export {
192
193
  archiveTaskGate,
193
194
  changeDiffInfo,
194
195
  } from './change/lifecycle.ts';
195
- export { normalizeLocale, localeFallbacks } from './templates/locale.ts';
196
+ export { normalizeLocale, localeFallbacks, DEFAULT_LOCALE } from './locale.ts';
196
197
  export {
197
198
  MAX_UNIT_NESTING_DEPTH,
198
199
  renderTemplate,
@@ -202,7 +203,6 @@ export {
202
203
  export {
203
204
  ETHICS_KEYS,
204
205
  buildTemplateVars,
205
- effectiveCheckCommand,
206
206
  enforceEthicsGovernance,
207
207
  loadLocaleResource,
208
208
  loadSkillTemplates,
@@ -227,6 +227,7 @@ export {
227
227
  type InitResult,
228
228
  } from './init/init.ts';
229
229
  export {
230
+ changeTitle,
230
231
  collectChanges,
231
232
  statusFor,
232
233
  stageFor,
@@ -336,3 +337,18 @@ export {
336
337
  type TierEntry,
337
338
  type TreeToolDeps,
338
339
  } from './context/retrieve.ts';
340
+ export { maxUsedNumber, nextNumber } from './util/nextNumber.ts';
341
+ export {
342
+ COMPLETION_BIN,
343
+ COMPLETION_MARKER_END,
344
+ COMPLETION_MARKER_START,
345
+ COMPLETION_SHELLS,
346
+ collectFlags,
347
+ completionBlock,
348
+ isCompletionShell,
349
+ renderCompletionScript,
350
+ resolveBashRc,
351
+ upsertCompletionBlock,
352
+ type CompletionCommandSpec,
353
+ type CompletionShell,
354
+ } from './self/completion.ts';
@@ -1,39 +1,13 @@
1
1
  /**
2
- * Default llmanspec/config.yaml templates, extracted verbatim from predecessor
3
- * (crates/llman-sdd/src/sdd/project/config.rs DEFAULT_CONFIG_EN/ZH_HANS).
2
+ * Default llmanspec/config.yaml body (init-generators r19/r50): one built-in
3
+ * locale (zh-Hans), ported from the predecessor (crates/llman-sdd/src/sdd/
4
+ * project/config.rs DEFAULT_CONFIG_ZH_HANS).
4
5
  */
6
+ import { DEFAULT_LOCALE } from '../locale.ts';
7
+
5
8
  export const LLMANSPEC_SCHEMA_URL =
6
9
  'https://raw.githubusercontent.com/StrayDragon/llman/main/artifacts/schema/configs/en/llmanspec-config.schema.json';
7
10
 
8
- export const DEFAULT_CONFIG_EN = `schema: spec-driven
9
- locale: en
10
-
11
- # Optional extra skills (disabled by default, uncomment to enable).
12
- # On \`llman-sdd init --update\`, managed candidates are:
13
- # default workflow skills + entries listed here (extra_skills extend).
14
- # Then \`.agents/skills/llman-sdd-*\` is scanned: anything not in that candidate
15
- # set is removed first, then candidates are written/updated. Only the
16
- # \`llman-sdd-\` prefix is touched (custom skills without that prefix are kept).
17
- # Deprecated shipped skills (e.g. removed from defaults) are cleaned this way.
18
- # extra_skills:
19
- # - llman-sdd-continue
20
- # - llman-sdd-ff
21
- # - llman-sdd-validate
22
- # - llman-sdd-arch-review
23
- # - llman-sdd-wayfinder
24
- # - llman-sdd-research
25
-
26
- # Spec verification (optional, uncomment to enable)
27
- # specs:
28
- # framework: pytest-bdd
29
- # # Filtered runners: include {feature_*} so validate --all/--specs runs per capability.
30
- # # check_command: "pytest {feature_dir} -k {feature_name} -v"
31
- # # Project-wide runners (no placeholders): validate --all/--specs runs the suite once (batch-once).
32
- # # check_command: "cargo test --features bdd"
33
- # # verify_prompt: |
34
- # # Map test failures to requirement IDs.
35
- `;
36
-
37
11
  export const DEFAULT_CONFIG_ZH_HANS = `schema: spec-driven
38
12
  locale: zh-Hans
39
13
 
@@ -67,3 +41,12 @@ export function prependSchemaHeader(content: string, schemaUrl: string): string
67
41
  if (content === '') return `${header}\n`;
68
42
  return `${header}\n${content}`;
69
43
  }
44
+
45
+ /**
46
+ * Built-in default config bodies by normalized locale. The lookup keeps the
47
+ * single-source shape of the locale chain (r18/r50): a locale is normalized
48
+ * first, then resolved; no exact-string comparison on the raw input.
49
+ */
50
+ export const DEFAULT_CONFIGS: Readonly<Record<string, string>> = {
51
+ [DEFAULT_LOCALE]: DEFAULT_CONFIG_ZH_HANS,
52
+ };
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
- DEFAULT_CONFIG_EN,
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 interface InitIo {
70
- exists(path: string): boolean;
71
- readText(path: string): string;
72
- writeText(path: string, content: string): void;
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 === 'zh-Hans' ? DEFAULT_CONFIG_ZH_HANS : DEFAULT_CONFIG_EN;
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 schema
87
- * default ('en', already baked into config.locale here) is the built-in floor.
88
- * Per-instance: callers resolve per workspace root, no cross-instance inheritance.
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) continue;
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 ?? 'en');
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('llmanspec/specs');
186
- io.mkdirp('llmanspec/changes/archive');
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('llmanspec/changes/archive/.gitkeep')) {
189
- io.writeText('llmanspec/changes/archive/.gitkeep', '');
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(
@@ -1,41 +1,6 @@
1
- /** Extract depends_on entries (flow + block styles, r30). */
2
- import { extractFrontmatter } from '../../change/frontmatter.ts';
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
- const fm = extractFrontmatter(proposal) ?? cardYamlSource(proposal);
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
- const m = name.match(/^\d{4}-\d{2}-\d{2}-(.+)$/u);
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
- const changesDir = `${root}/${CHANGES_DIR}`;
18
- if (!io.exists(changesDir) || !io.isDirectory(changesDir)) return out;
19
- const maxDepth = maxScanDepth ?? 8;
20
- const visit = (dir: string, depth: number): void => {
21
- if (depth > maxDepth) return;
22
- for (const name of io.listDir(dir).toSorted()) {
23
- if (name === 'archive' || name.startsWith('.')) continue;
24
- const child = `${dir}/${name}`;
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
- export interface GraphFsIo {
2
- exists(path: string): boolean;
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;
@@ -1,8 +1,9 @@
1
- import { countTasks, firstH1, stageFor, type ChangeFsIo } from '../change/collect.ts';
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), 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
- const tasksHint =
83
- total > 0 && completed < total
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
- : 'edit live specs on the bound branch and commit (or set needs_specs_change to false)',
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: firstH1(proposal),
134
+ title: changeTitle(proposal),
127
135
  stage,
128
136
  artifacts,
129
137
  readyToImplement: gateChecks.every((g) => g.pass),