@llman-sdd/core 0.10.1 → 0.11.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 (38) hide show
  1. package/package.json +7 -7
  2. package/src/archive/freeze.ts +43 -4
  3. package/src/archive/frozenCard.ts +62 -5
  4. package/src/change/lifecycle.ts +55 -59
  5. package/src/config/schema.ts +0 -13
  6. package/src/config/surface.ts +2 -12
  7. package/src/context/sddState.ts +23 -18
  8. package/src/index.ts +7 -36
  9. package/src/init/defaultConfig.ts +2 -13
  10. package/src/init/init.ts +50 -19
  11. package/src/init/skillCheck.ts +60 -0
  12. package/src/project/migrations.ts +81 -9
  13. package/src/spec/authoring.ts +5 -1
  14. package/src/templates/skills.ts +15 -12
  15. package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +5 -5
  16. package/templates/zh-Hans/skills/llman-sdd-apply.md +8 -9
  17. package/templates/zh-Hans/skills/llman-sdd-arch-review.md +1 -1
  18. package/templates/zh-Hans/skills/llman-sdd-archive.md +13 -14
  19. package/templates/zh-Hans/skills/llman-sdd-continue.md +3 -3
  20. package/templates/zh-Hans/skills/llman-sdd-draft.md +3 -3
  21. package/templates/zh-Hans/skills/llman-sdd-explore.md +2 -3
  22. package/templates/zh-Hans/skills/llman-sdd-ff.md +3 -2
  23. package/templates/zh-Hans/skills/llman-sdd-graph.md +1 -1
  24. package/templates/zh-Hans/skills/llman-sdd-propose.md +8 -9
  25. package/templates/zh-Hans/skills/llman-sdd-quick.md +4 -5
  26. package/templates/zh-Hans/skills/llman-sdd-research.md +1 -1
  27. package/templates/zh-Hans/skills/llman-sdd-specs-compact.md +4 -3
  28. package/templates/zh-Hans/skills/llman-sdd-validate.md +2 -2
  29. package/templates/zh-Hans/skills/llman-sdd-verify.md +3 -3
  30. package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +2 -2
  31. package/templates/zh-Hans/units/skills/git-native-flow.md +8 -8
  32. package/templates/zh-Hans/units/skills/stage-guard.md +3 -3
  33. package/templates/zh-Hans/units/skills/structured-protocol.md +1 -1
  34. package/templates/zh-Hans/units/skills/validation-hints.md +3 -3
  35. package/src/context/indexStore.ts +0 -171
  36. package/src/context/retrieve.ts +0 -332
  37. package/src/context/tree.ts +0 -112
  38. package/templates/zh-Hans/units/skills/index-fallback.md +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llman-sdd/core",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Pure domain logic for llman-sdd (config, gherkin specs, validation, templates)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "7z-wasm": "^1.2.0",
28
- "@cucumber/gherkin": "^42.0.1",
29
- "@cucumber/messages": "^34.2.1",
28
+ "@cucumber/gherkin": "^43.0.0",
29
+ "@cucumber/messages": "^35.0.0",
30
30
  "@statelyai/graph": "^2.6.0",
31
- "@toon-format/toon": "^4.1.1",
32
- "ignore": "^7.0.12",
31
+ "@toon-format/toon": "^4.4.0",
32
+ "ignore": "^7.0.16",
33
33
  "nunjucks": "^3.2.4",
34
- "xstate": "^5.33.2",
34
+ "xstate": "^5.33.4",
35
35
  "yaml": "^2.9.1",
36
- "zod": "^4.6.5"
36
+ "zod": "^4.6.7"
37
37
  },
38
38
  "engines": {
39
39
  "bun": ">=1.4.0",
@@ -18,6 +18,7 @@ import {
18
18
  frozenCardIdOf,
19
19
  frozenCardName,
20
20
  isFrozenCard,
21
+ unfenceFrozenCard,
21
22
  } from './frozenCard.ts';
22
23
  import { collectFilteredEntries } from './ignoreChain.ts';
23
24
  import type { SevenZipPort } from './sevenzip.ts';
@@ -198,6 +199,42 @@ export interface ThawResult {
198
199
  restored: string[];
199
200
  }
200
201
 
202
+ /**
203
+ * r121: rewrite every fenced card under `archiveDirRel` into the fence-free
204
+ * single-document form. Shared by the thaw pass and the migrate action so both
205
+ * obey one definition of "legacy card". Returns how many cards changed.
206
+ * Cards that are not fenced (or not plainly fenced) are left untouched.
207
+ */
208
+ export function unfenceLegacyCards(io: FreezeIo, archiveDirRel: string): number {
209
+ let changed = 0;
210
+ for (const rel of planUnfenceLegacyCards(io, archiveDirRel)) {
211
+ const unfenced = unfenceFrozenCard(io.readText(rel));
212
+ if (unfenced === null) continue;
213
+ io.writeText(rel, unfenced);
214
+ changed++;
215
+ }
216
+ return changed;
217
+ }
218
+
219
+ /**
220
+ * r121: dry-run half of {@link unfenceLegacyCards} — the exact same scan and
221
+ * predicates, returning the card paths that WOULD change without writing.
222
+ * Sharing the predicate is what keeps `--dry-run` from drifting from the write
223
+ * path.
224
+ */
225
+ export function planUnfenceLegacyCards(io: FreezeIo, archiveDirRel: string): string[] {
226
+ if (!io.exists(archiveDirRel)) return [];
227
+ const hits: string[] = [];
228
+ for (const name of io.listDir(archiveDirRel).toSorted()) {
229
+ if (!isFrozenCard(name) || frozenCardIdOf(name) === null) continue;
230
+ const rel = `${archiveDirRel}/${name}`;
231
+ if (io.isDirectory(rel)) continue;
232
+ if (unfenceFrozenCard(io.readText(rel)) === null) continue;
233
+ hits.push(rel);
234
+ }
235
+ return hits;
236
+ }
237
+
201
238
  export async function runThaw(
202
239
  io: FreezeIo,
203
240
  sz: SevenZipPort,
@@ -242,10 +279,12 @@ export async function runThaw(
242
279
  if (io.exists(cardRel)) io.remove(cardRel);
243
280
  restored.push(name);
244
281
  }
245
- return {
246
- restored,
247
- lines: [`Thawed ${restored.length} selected archived changes to ${destRel}`],
248
- };
282
+ // r121: thaw already rewrites the archive area, so normalize any remaining
283
+ // fenced cards in the same pass. Failing here must never block the restore.
284
+ const unfenced = unfenceLegacyCards(io, ARCHIVE_DIR_REL);
285
+ const lines = [`Thawed ${restored.length} selected archived changes to ${destRel}`];
286
+ if (unfenced > 0) lines.push(`Unfenced ${unfenced} legacy card(s)`);
287
+ return { restored, lines };
249
288
  } finally {
250
289
  io.removeDir(tmpRel);
251
290
  }
@@ -13,15 +13,18 @@
13
13
  * Title source: frontmatter `title` wins when non-empty, else the proposal H1
14
14
  * (legacy archive dirs).
15
15
  *
16
- * Depends_on extraction is deliberately dependency-free (no `yaml` package):
17
- * it recognizes single-line flow `[a, b]`, block `- item` lists and multi-line
18
- * flow blocks, then normalizes to a single-line flow array so `parseDeps`
19
- * reads it unchanged. Anything unparseable degrades to `depends_on: []` (never
20
- * blocks the freeze).
16
+ * Depends_on *extraction* stays dependency-free: it recognizes single-line
17
+ * flow `[a, b]`, block `- item` lists and multi-line flow blocks, then
18
+ * normalizes to a single-line flow array so `parseDeps` reads it unchanged.
19
+ * Anything unparseable degrades to `depends_on: []` (never blocks the freeze).
20
+ * The r121 normalizer is the one place that consults the `yaml` package — it
21
+ * must prove the stripped body is a genuine single document before rewriting.
21
22
  *
22
23
  * Pure string logic — all filesystem effects live in freeze.ts (FreezeIo).
23
24
  */
24
25
 
26
+ import { parseDocument } from 'yaml';
27
+
25
28
  import { datedCardIdOf } from '../util/datedId.ts';
26
29
 
27
30
  export const FROZEN_CARD_EXT = '.yaml';
@@ -106,3 +109,57 @@ export function composeFrozenCard(title: string, frontmatter: string): string {
106
109
  const dependsOn = extractDependsOn(frontmatter);
107
110
  return [`title: "${escapeYamlScalar(title)}"`, dependsOn].join('\n') + '\n';
108
111
  }
112
+
113
+ /**
114
+ * r121: fence-stripping normalizer for legacy cards. Predecessor-era cards
115
+ * open and close with a standalone `---` line, which makes them a *multi*-
116
+ * document YAML stream — generic single-document validators (pre-commit's
117
+ * `check-yaml` by default) reject them. Returns the fence-free text, or null
118
+ * when the input is not a plain fenced card.
119
+ *
120
+ * Conservative by construction — a miss is fine, a false rewrite is not:
121
+ * - first and last non-empty lines must each be exactly `---` (a stray `---`
122
+ * inside a scalar value must never trigger a rewrite);
123
+ * - the stripped body must parse as exactly one YAML document;
124
+ * - that document's keys must be a subset of `title` / `depends_on`.
125
+ * A card already in the fence-free form returns null (idempotent by contract).
126
+ */
127
+ export function unfenceFrozenCard(source: string): string | null {
128
+ const lines = source.split('\n');
129
+ // Trailing newline yields a final '' element; strip it so line indexes point
130
+ // at real content.
131
+ while (lines.length > 0 && (lines[lines.length - 1] ?? '').trim() === '') lines.pop();
132
+ if (lines.length < 3) return null;
133
+ const isFence = (line: string | undefined): boolean =>
134
+ (line ?? '').replace(/\s+$/u, '') === '---';
135
+ if (!isFence(lines[0]) || !isFence(lines[lines.length - 1])) return null;
136
+ // Normalize to LF while stripping: a lone trailing \r is not a YAML line
137
+ // break, so a CRLF card would otherwise fail the single-document parse.
138
+ const body = lines
139
+ .slice(1, -1)
140
+ .map((line) => line.replace(/\r$/u, ''))
141
+ .join('\n');
142
+ if (body.trim() === '') return null;
143
+ let parsed: unknown;
144
+ try {
145
+ const doc = parseDocument(body);
146
+ if (doc.errors.length > 0) return null;
147
+ parsed = doc.toJS({ json: true });
148
+ } catch {
149
+ return null;
150
+ }
151
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return null;
152
+ const record = parsed as Record<string, unknown>;
153
+ const keys = Object.keys(record);
154
+ if (keys.length === 0) return null;
155
+ const allowed = new Set(['title', 'depends_on']);
156
+ if (keys.some((k) => !allowed.has(k))) return null;
157
+ // Shape check, not just key names: r121 keeps `depends_on` participating in
158
+ // dependency-edge parsing, so a scalar/object here is a card we do not
159
+ // understand — leave it for a human rather than normalizing a broken one.
160
+ const title = record['title'];
161
+ if (title !== undefined && typeof title !== 'string') return null;
162
+ const deps = record['depends_on'];
163
+ if (deps !== undefined && deps !== null && !Array.isArray(deps)) return null;
164
+ return `${body}\n`;
165
+ }
@@ -73,10 +73,10 @@ export function newChange(
73
73
  export interface StartResult {
74
74
  branch: string;
75
75
  baseBranch: string;
76
- /** Where the recorded base_branch came from (r95 deviation warning input). */
77
- baseSource: 'flag' | 'worktree' | 'default';
76
+ /** Where the recorded base_branch came from. */
77
+ baseSource: AttachBaseSource | 'worktree';
78
78
  baseSha: string;
79
- /** Absolute worktree path when started with --worktree (r68); undefined on the classic path. */
79
+ /** Absolute worktree path when started with --worktree; undefined when binding the current branch. */
80
80
  worktreePath?: string;
81
81
  }
82
82
 
@@ -177,13 +177,29 @@ export function startChange(
177
177
  worktreeNaming?: 'id' | 'hash';
178
178
  /** r119: instance dir relative to the git toplevel ('' at the repo root). */
179
179
  instanceDirRel?: string;
180
+ /** Rebind when the change is already attached to a branch. */
181
+ force?: boolean;
180
182
  } = {},
181
183
  ): StartResult {
182
184
  const path = proposalPath(id);
183
185
  if (!io.exists(path)) throw new LifecycleError(`proposal not found: ${path}`);
186
+ const here = currentBranch(git);
187
+ if (
188
+ !opts.worktree &&
189
+ here !== null &&
190
+ here !== '' &&
191
+ here !== defaultBranch(git) &&
192
+ !opts.force
193
+ ) {
194
+ const existing = readBinding(io.readText(path));
195
+ if (existing !== null) {
196
+ throw new LifecycleError(
197
+ `change \`${id}\` already attached to branch \`${existing.branch}\` (base ${existing.baseSha}); pass --force to rebind`,
198
+ );
199
+ }
200
+ }
184
201
  const dirty = dirtyCount(git);
185
202
  if (dirty > 0) throw new LifecycleError(dirtyTree('change start'));
186
- const here = currentBranch(git);
187
203
  if (here === null) throw new LifecycleError(detachedHead('change start'));
188
204
  const branchPrefix = opts.branchPrefix ?? 'sdd/';
189
205
  const branch = `${branchPrefix}${id}`;
@@ -192,9 +208,20 @@ export function startChange(
192
208
  assertLocalBase(git, opts.base, branch, 'new');
193
209
  }
194
210
 
211
+ // A non-default checkout binds the current branch. The default branch
212
+ // still creates sdd/<id>. --worktree always creates a branch elsewhere.
213
+ if (!opts.worktree && here !== defaultBranch(git)) {
214
+ const bound = attachChange(git, io, id, { force: opts.force, base: opts.base });
215
+ return {
216
+ branch: bound.branch,
217
+ baseBranch: bound.baseBranch,
218
+ baseSource: bound.baseSource,
219
+ baseSha: bound.baseSha,
220
+ };
221
+ }
222
+
195
223
  // r68 fork-source resolution: --base explicit > current branch (worktree
196
- // mode records the actual source, which may be a non-default branch) >
197
- // default branch. The classic path keeps the r14 default-branch gate.
224
+ // mode records the actual source) > default branch.
198
225
  let baseBranch: string;
199
226
  let baseSource: StartResult['baseSource'];
200
227
  if (opts.base !== undefined) {
@@ -206,11 +233,6 @@ export function startChange(
206
233
  } else {
207
234
  baseBranch = defaultBranch(git);
208
235
  baseSource = 'default';
209
- if (here !== baseBranch) {
210
- throw new LifecycleError(
211
- `already on non-default branch \`${here}\`; use \`change attach\` to bind it, or switch to the default branch before \`change start\``,
212
- );
213
- }
214
236
  }
215
237
 
216
238
  let worktreePath: string | undefined;
@@ -269,7 +291,7 @@ export function attachChange(
269
291
  }
270
292
  const branch = currentBranch(git);
271
293
  if (branch === null || branch === '') {
272
- throw new LifecycleError(detachedHead('change attach'));
294
+ throw new LifecycleError(detachedHead('change start'));
273
295
  }
274
296
  if (opts.base !== undefined) {
275
297
  assertLocalBase(git, opts.base, branch, 'bound');
@@ -286,7 +308,7 @@ export function attachChange(
286
308
  });
287
309
  if (branch === fork.branch) {
288
310
  throw new LifecycleError(
289
- `${onDefaultBranch('change attach', branch)}; create or switch to a feature branch, or use \`change start\``,
311
+ `${onDefaultBranch('change start', branch)}; create or switch to a feature branch before binding the current checkout`,
290
312
  );
291
313
  }
292
314
  const baseSha = mergeBase(git, branch, fork.branch);
@@ -388,7 +410,7 @@ export function finalizeChange(
388
410
  const path = proposalPath(id);
389
411
  const binding = readBinding(io.readText(path));
390
412
  if (binding === null) {
391
- throw new LifecycleError(`change \`${id}\` has no branch binding — run start/attach first`);
413
+ throw new LifecycleError(`change \`${id}\` has no branch binding — run \`change start\` first`);
392
414
  }
393
415
  // T34 close-out gate before any write: specs-landed verdict + task gate.
394
416
  const closeOut = closeOutGate({ git, io, id, binding, specsPrefix: opts.specsPrefix });
@@ -416,7 +438,7 @@ export function finalizeChange(
416
438
  // fail before any write (no switch, no merge, no rename).
417
439
  const current = currentBranch(git);
418
440
  if (current !== binding.branch) {
419
- throw new LifecycleError(notOnBoundBranch('change finalize', binding.branch, current));
441
+ throw new LifecycleError(notOnBoundBranch('change archive', binding.branch, current));
420
442
  }
421
443
  const method = opts.method ?? 'squash';
422
444
  const target = opts.into ?? binding.baseBranch ?? defaultBranch(git);
@@ -540,7 +562,7 @@ function mergeRenameCommit(
540
562
  return { target, archiveDir, warnings, commitSubject, executedIn };
541
563
  }
542
564
 
543
- /** `change archive`: independent seal-off with task + strict git gates (r39/r40). */
565
+ /** `change archive`: task gates, clean tree, merge, rename, optional close-out commit. */
544
566
  export function archiveChange(
545
567
  git: GitLike,
546
568
  io: FsIo,
@@ -548,68 +570,42 @@ export function archiveChange(
548
570
  opts: {
549
571
  into?: string;
550
572
  method?: 'squash' | 'ff';
551
- force?: boolean;
552
573
  /** CLI already enforced a clean tree before the acceptance command ran. */
553
574
  skipCleanTree?: boolean;
554
575
  today: string;
576
+ noCommit?: boolean;
555
577
  /** r119: instance-relative specs prefix of the change's own root. */
556
578
  specsPrefix?: string;
557
579
  },
558
580
  ): FinalizeResult {
559
581
  const path = proposalPath(id);
560
582
  const binding = readBinding(io.readText(path));
561
- if (!opts.force && binding === null) {
562
- throw new LifecycleError(`change \`${id}\` has no branch binding — run start/attach first`);
583
+ if (binding === null) {
584
+ throw new LifecycleError(`change \`${id}\` has no branch binding — run \`change start\` first`);
563
585
  }
564
- if (!opts.force) {
565
- // T34: shared close-out verdict before any write (archive honors --force).
566
- const closeOut = closeOutGate({ git, io, id, binding, specsPrefix: opts.specsPrefix });
567
- if (!closeOut.ok) throw new LifecycleError(closeOut.reason as string);
568
- const tasksPath = `${CHANGES_DIR}/${id}/tasks.md`;
569
- const gate = archiveTaskGate(io.exists(tasksPath) ? io.readText(tasksPath) : null);
570
- if (gate.blocked) {
571
- // D9: when a pending unchecked task starts with a close-out verb, append
572
- // the same remediation hint as the validate WARNING (single constant).
573
- const closeOut = closeOutTaskLines(gate.pendingLines);
574
- throw new LifecycleError(
575
- [
576
- `archive blocked by unchecked tasks (${gate.pendingLines.length} pending)`,
577
- ...gate.pendingLines,
578
- ...(closeOut.length > 0
579
- ? [
580
- `task "${closeOut[0]?.replace(/^-\s+\[ \]\s*/u, '').trim() ?? ''}" looks like a close-out step; ${CLOSE_OUT_TASK_HINT}`,
581
- ]
582
- : []),
583
- ].join('\n'),
584
- );
585
- }
586
- const current = currentBranch(git);
587
- if (current === null || current === '')
588
- throw new LifecycleError(detachedHead('change archive'));
589
- if (current !== binding?.branch) {
590
- throw new LifecycleError(
591
- notOnBoundBranch('change archive', (binding?.branch ?? '') as string, current),
592
- );
593
- }
594
- if (current === defaultBranch(git)) {
595
- throw new LifecycleError(onDefaultBranch('change archive', current));
596
- }
597
- if (!opts.skipCleanTree && !isCleanTree(git))
598
- throw new LifecycleError(dirtyTree('change archive'));
599
- } else if (binding === null) {
600
- throw new LifecycleError(`change \`${id}\` has no branch binding — cannot merge`);
586
+ const closeOut = closeOutGate({ git, io, id, binding, specsPrefix: opts.specsPrefix });
587
+ if (!closeOut.ok) throw new LifecycleError(closeOut.reason as string);
588
+ const current = currentBranch(git);
589
+ if (current === null || current === '') throw new LifecycleError(detachedHead('change archive'));
590
+ if (current !== binding.branch) {
591
+ throw new LifecycleError(notOnBoundBranch('change archive', binding.branch, current));
601
592
  }
593
+ if (current === defaultBranch(git)) {
594
+ throw new LifecycleError(onDefaultBranch('change archive', current));
595
+ }
596
+ if (!opts.skipCleanTree && !isCleanTree(git))
597
+ throw new LifecycleError(dirtyTree('change archive'));
602
598
  const method = opts.method ?? 'squash';
603
- const target = opts.into ?? binding?.baseBranch ?? defaultBranch(git);
599
+ const target = opts.into ?? binding.baseBranch ?? defaultBranch(git);
604
600
  return mergeRenameCommit(
605
601
  git,
606
602
  io,
607
603
  id,
608
- binding?.branch as string,
604
+ binding.branch,
609
605
  target,
610
606
  method,
611
607
  opts.today,
612
- undefined,
608
+ opts.noCommit,
613
609
  instanceDirRelOf(opts.specsPrefix ?? DEFAULT_SPECS_PREFIX),
614
610
  );
615
611
  }
@@ -8,15 +8,6 @@ import { z } from 'zod';
8
8
 
9
9
  import { DEFAULT_LOCALE } from '../locale.ts';
10
10
 
11
- export const EXTRA_SKILLS = [
12
- 'llman-sdd-continue',
13
- 'llman-sdd-ff',
14
- 'llman-sdd-validate',
15
- 'llman-sdd-arch-review',
16
- 'llman-sdd-wayfinder',
17
- 'llman-sdd-research',
18
- ] as const;
19
-
20
11
  export const specsSchema = z.object({
21
12
  framework: z
22
13
  .string()
@@ -77,10 +68,6 @@ export const changeIdSchema = z.object({
77
68
  export const sddConfigSchema = z.object({
78
69
  schema: z.literal('spec-driven').describe('Schema identifier. Must be "spec-driven".'),
79
70
  locale: z.string().default(DEFAULT_LOCALE).describe('Locale used for SDD templates and skills.'),
80
- extra_skills: z
81
- .array(z.enum(EXTRA_SKILLS))
82
- .nullish()
83
- .describe('Additional optional SDD skills to enable (extend candidates on init --update).'),
84
71
  archive: archiveSchema
85
72
  .nullish()
86
73
  .describe('Archive behaviour settings (defer tracking, completion gates).'),
@@ -1,29 +1,19 @@
1
1
  /**
2
- * `config` command surface (r37/r38): read-only overview rendering and the
3
- * skills listing shape (the extra_skills write path was removed with
4
- * config-command r38).
2
+ * `config` command surface: read-only overview. Skill install is `init --update`.
5
3
  */
6
4
 
7
5
  import { loadConfig } from './load.ts';
8
- import { EXTRA_SKILLS } from './schema.ts';
9
6
 
10
- /** Render the five-element overview (predecessor parity wording). */
7
+ /** Render the overview (schema, locale, specs, archive). */
11
8
  export function renderConfigOverview(source: string): string[] {
12
9
  const config = loadConfig(source);
13
- const enabled = (config.extra_skills ?? []).length;
14
10
  const archive = config.archive;
15
11
  const archiveConfigured =
16
12
  archive !== null && archive !== undefined && archive.strict_defer === true;
17
13
  return [
18
14
  `schema: ${config.schema}`,
19
15
  `locale: ${config.locale}`,
20
- `extra_skills (enabled/total): ${enabled} / ${EXTRA_SKILLS.length}`,
21
16
  `specs: ${config.specs ? 'on' : 'off'}`,
22
17
  `archive: ${archiveConfigured ? 'configured' : 'default'}`,
23
18
  ];
24
19
  }
25
-
26
- /** Shape of `config skills --json` (predecessor parity). */
27
- export function skillsJson(source: string): { enabled: string[]; available: readonly string[] } {
28
- return { enabled: [...(loadConfig(source).extra_skills ?? [])], available: EXTRA_SKILLS };
29
- }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Scaffold-state record (version-awareness capability): init stamps the CLI
3
- * version that rendered the project so later runs can detect drift. All paths
4
- * ROOT-RELATIVE through the injected IO; corrupt/missing state is silent-OK
5
- * (the notice is best-effort, never load-bearing).
2
+ * Scaffold-state record (version-awareness): init stamps the CLI version that
3
+ * rendered the project so later runs can detect drift. The stamp lives at
4
+ * `llmanspec/.sdd-state.json`. Reads fall back to the previous
5
+ * `llmanspec/.context/sdd-state.json` and never delete it. Writes only the
6
+ * new path. Corrupt or missing state is silent-OK.
6
7
  */
7
8
 
8
- import { CONTEXT_DIR_REL } from './indexStore.ts';
9
-
10
- export const SDD_STATE_REL = `${CONTEXT_DIR_REL}/sdd-state.json`;
9
+ export const SDD_STATE_REL = 'llmanspec/.sdd-state.json';
10
+ export const LEGACY_SDD_STATE_REL = 'llmanspec/.context/sdd-state.json';
11
11
 
12
12
  export interface SddState {
13
13
  /** llman-sdd version that last rendered this project (init / --update). */
@@ -21,18 +21,9 @@ type StateIo = {
21
21
  mkdirp(path: string): void;
22
22
  };
23
23
 
24
- /** Persist the scaffold version (called from runInit after config resolution). */
25
- export function writeSddState(io: StateIo, version: string): void {
26
- io.mkdirp(CONTEXT_DIR_REL);
27
- const state: SddState = { cli_version: version };
28
- io.writeText(SDD_STATE_REL, `${JSON.stringify(state, null, 2)}\n`);
29
- }
30
-
31
- /** Read the recorded version; null when absent/corrupt (silent-OK contract). */
32
- export function readSddState(io: Pick<StateIo, 'exists' | 'readText'>): SddState | null {
33
- if (!io.exists(SDD_STATE_REL)) return null;
24
+ function parseState(raw: string): SddState | null {
34
25
  try {
35
- const parsed: unknown = JSON.parse(io.readText(SDD_STATE_REL));
26
+ const parsed: unknown = JSON.parse(raw);
36
27
  if (
37
28
  typeof parsed === 'object' &&
38
29
  parsed !== null &&
@@ -46,4 +37,18 @@ export function readSddState(io: Pick<StateIo, 'exists' | 'readText'>): SddState
46
37
  }
47
38
  }
48
39
 
40
+ /** Persist the scaffold version. Does not touch the legacy path. */
41
+ export function writeSddState(io: StateIo, version: string): void {
42
+ io.mkdirp('llmanspec');
43
+ const state: SddState = { cli_version: version };
44
+ io.writeText(SDD_STATE_REL, `${JSON.stringify(state, null, 2)}\n`);
45
+ }
46
+
47
+ /** Read the recorded version: new path, then the legacy path. */
48
+ export function readSddState(io: Pick<StateIo, 'exists' | 'readText'>): SddState | null {
49
+ if (io.exists(SDD_STATE_REL)) return parseState(io.readText(SDD_STATE_REL));
50
+ if (io.exists(LEGACY_SDD_STATE_REL)) return parseState(io.readText(LEGACY_SDD_STATE_REL));
51
+ return null;
52
+ }
53
+
49
54
  export { semverLt } from '../util/semver.ts';
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export {
2
- EXTRA_SKILLS,
3
2
  archiveSchema,
4
3
  changeIdSchema,
5
4
  sddConfigSchema,
@@ -20,7 +19,7 @@ export {
20
19
  compileChangeIdPattern,
21
20
  renderChangeIdTemplate,
22
21
  } from './config/changeId.ts';
23
- export { renderConfigOverview, skillsJson } from './config/surface.ts';
22
+ export { renderConfigOverview } from './config/surface.ts';
24
23
 
25
24
  export type {
26
25
  CapabilityDoc,
@@ -222,10 +221,12 @@ export {
222
221
  refreshSubRootBlocks,
223
222
  resolveEffectiveLocale,
224
223
  runInit,
224
+ stripManagedBlock,
225
225
  updateFileWithMarkers,
226
226
  type InitIo,
227
227
  type InitResult,
228
228
  } from './init/init.ts';
229
+ export { checkSkillVersions, readSkillVersion, skillVersionCompatible } from './init/skillCheck.ts';
229
230
  export {
230
231
  changeTitle,
231
232
  collectChanges,
@@ -276,6 +277,8 @@ export {
276
277
  runFreeze,
277
278
  runList,
278
279
  runThaw,
280
+ unfenceLegacyCards,
281
+ planUnfenceLegacyCards,
279
282
  type FreezeIo,
280
283
  type FreezeOpts,
281
284
  type FreezeRunResult,
@@ -287,6 +290,7 @@ export {
287
290
  frozenCardIdOf,
288
291
  frozenCardName,
289
292
  isFrozenCard,
293
+ unfenceFrozenCard,
290
294
  } from './archive/frozenCard.ts';
291
295
  export {
292
296
  IgnoreChainError,
@@ -305,46 +309,13 @@ export {
305
309
  type ReviewSignal,
306
310
  } from './review/review.ts';
307
311
  export {
308
- buildTreeIndex,
309
- computeSpecHash,
310
- type HashIo,
311
- type SerializedDocNode,
312
- type SerializedScenarioNode,
313
- type SerializedReqNode,
314
- type SerializedTreeIndex,
315
- } from './context/tree.ts';
316
- export {
317
- CONTEXT_DIR_REL,
318
- PAGEINDEX_DIR_REL,
319
- REBUILD_LOCK_REL,
320
- TREE_JSON_REL,
321
- checkIndexFreshness,
322
- loadTreeWithAutoRebuild,
323
- parseLock,
324
- rebuildIndex,
325
- type AutoRefreshResult,
326
- type FreshnessResult,
327
- type IndexIo,
328
- type RebuildOpts,
329
- type RebuildResult,
330
- } from './context/indexStore.ts';
331
- export {
312
+ LEGACY_SDD_STATE_REL,
332
313
  SDD_STATE_REL,
333
314
  readSddState,
334
315
  semverLt,
335
316
  writeSddState,
336
317
  type SddState,
337
318
  } from './context/sddState.ts';
338
- export {
339
- resolveChatConfig,
340
- runContextRetrieval,
341
- unavailableResult,
342
- type ChatConfig,
343
- type ContextResult,
344
- type RetrieveDeps,
345
- type TierEntry,
346
- type TreeToolDeps,
347
- } from './context/retrieve.ts';
348
319
  export { maxUsedNumber, nextNumber } from './util/nextNumber.ts';
349
320
  export {
350
321
  COMPLETION_BIN,
@@ -11,19 +11,8 @@ export const LLMANSPEC_SCHEMA_URL =
11
11
  export const DEFAULT_CONFIG_ZH_HANS = `schema: spec-driven
12
12
  locale: zh-Hans
13
13
 
14
- # 可选额外技能(默认禁用,取消注释以启用)。
15
- # 运行 \`llman-sdd init --update\` 时,管理候选集为:
16
- # 默认 workflow 技能 + 本列表(extra_skills 扩展)。
17
- # 然后扫描 \`.agents/skills/llman-sdd-*\`:不在候选集中的先删除,再写入/更新候选。
18
- # 仅处理 \`llman-sdd-\` 前缀(无此前缀的自定义技能不会被删)。
19
- # 已废弃的内置技能(从默认集移除后)会因此被正确清理。
20
- # extra_skills:
21
- # - llman-sdd-continue
22
- # - llman-sdd-ff
23
- # - llman-sdd-validate
24
- # - llman-sdd-arch-review
25
- # - llman-sdd-wayfinder
26
- # - llman-sdd-research
14
+ # 内置技能由 llman-sdd init --update 全部写入 .agents/skills/。
15
+ # 无 llman-sdd- 前缀的自定义技能不会被删除。
27
16
 
28
17
  # Spec 验证(可选,取消注释以启用)
29
18
  # specs: