@llman-sdd/core 0.10.0 → 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 (40) hide show
  1. package/package.json +7 -6
  2. package/src/archive/freeze.ts +73 -11
  3. package/src/archive/frozenCard.ts +62 -5
  4. package/src/archive/ignoreChain.ts +167 -0
  5. package/src/archive/sevenzip.ts +17 -8
  6. package/src/change/lifecycle.ts +55 -59
  7. package/src/config/schema.ts +0 -13
  8. package/src/config/surface.ts +2 -12
  9. package/src/context/sddState.ts +23 -18
  10. package/src/index.ts +15 -36
  11. package/src/init/defaultConfig.ts +2 -13
  12. package/src/init/init.ts +50 -19
  13. package/src/init/skillCheck.ts +60 -0
  14. package/src/project/migrations.ts +81 -9
  15. package/src/spec/authoring.ts +5 -1
  16. package/src/templates/skills.ts +15 -12
  17. package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +5 -5
  18. package/templates/zh-Hans/skills/llman-sdd-apply.md +8 -9
  19. package/templates/zh-Hans/skills/llman-sdd-arch-review.md +1 -1
  20. package/templates/zh-Hans/skills/llman-sdd-archive.md +13 -14
  21. package/templates/zh-Hans/skills/llman-sdd-continue.md +3 -3
  22. package/templates/zh-Hans/skills/llman-sdd-draft.md +3 -3
  23. package/templates/zh-Hans/skills/llman-sdd-explore.md +2 -3
  24. package/templates/zh-Hans/skills/llman-sdd-ff.md +3 -2
  25. package/templates/zh-Hans/skills/llman-sdd-graph.md +1 -1
  26. package/templates/zh-Hans/skills/llman-sdd-propose.md +8 -9
  27. package/templates/zh-Hans/skills/llman-sdd-quick.md +4 -5
  28. package/templates/zh-Hans/skills/llman-sdd-research.md +1 -1
  29. package/templates/zh-Hans/skills/llman-sdd-specs-compact.md +4 -3
  30. package/templates/zh-Hans/skills/llman-sdd-validate.md +2 -2
  31. package/templates/zh-Hans/skills/llman-sdd-verify.md +3 -3
  32. package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +2 -2
  33. package/templates/zh-Hans/units/skills/git-native-flow.md +8 -8
  34. package/templates/zh-Hans/units/skills/stage-guard.md +3 -3
  35. package/templates/zh-Hans/units/skills/structured-protocol.md +1 -1
  36. package/templates/zh-Hans/units/skills/validation-hints.md +3 -3
  37. package/src/context/indexStore.ts +0 -171
  38. package/src/context/retrieve.ts +0 -332
  39. package/src/context/tree.ts +0 -112
  40. package/templates/zh-Hans/units/skills/index-fallback.md +0 -1
@@ -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,7 +290,16 @@ export {
287
290
  frozenCardIdOf,
288
291
  frozenCardName,
289
292
  isFrozenCard,
293
+ unfenceFrozenCard,
290
294
  } from './archive/frozenCard.ts';
295
+ export {
296
+ IgnoreChainError,
297
+ collectFilteredEntries,
298
+ discoverIgnoreRoot,
299
+ type CollectFilteredOpts,
300
+ type FilteredCandidate,
301
+ type IgnoreChainIo,
302
+ } from './archive/ignoreChain.ts';
291
303
  export {
292
304
  buildReview,
293
305
  renderReviewHtml,
@@ -297,46 +309,13 @@ export {
297
309
  type ReviewSignal,
298
310
  } from './review/review.ts';
299
311
  export {
300
- buildTreeIndex,
301
- computeSpecHash,
302
- type HashIo,
303
- type SerializedDocNode,
304
- type SerializedScenarioNode,
305
- type SerializedReqNode,
306
- type SerializedTreeIndex,
307
- } from './context/tree.ts';
308
- export {
309
- CONTEXT_DIR_REL,
310
- PAGEINDEX_DIR_REL,
311
- REBUILD_LOCK_REL,
312
- TREE_JSON_REL,
313
- checkIndexFreshness,
314
- loadTreeWithAutoRebuild,
315
- parseLock,
316
- rebuildIndex,
317
- type AutoRefreshResult,
318
- type FreshnessResult,
319
- type IndexIo,
320
- type RebuildOpts,
321
- type RebuildResult,
322
- } from './context/indexStore.ts';
323
- export {
312
+ LEGACY_SDD_STATE_REL,
324
313
  SDD_STATE_REL,
325
314
  readSddState,
326
315
  semverLt,
327
316
  writeSddState,
328
317
  type SddState,
329
318
  } from './context/sddState.ts';
330
- export {
331
- resolveChatConfig,
332
- runContextRetrieval,
333
- unavailableResult,
334
- type ChatConfig,
335
- type ContextResult,
336
- type RetrieveDeps,
337
- type TierEntry,
338
- type TreeToolDeps,
339
- } from './context/retrieve.ts';
340
319
  export { maxUsedNumber, nextNumber } from './util/nextNumber.ts';
341
320
  export {
342
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:
package/src/init/init.ts CHANGED
@@ -15,6 +15,8 @@ import { writeSddState } from '../context/sddState.ts';
15
15
  import { DEFAULT_LOCALE, localeFallbacks, normalizeLocale } from '../locale.ts';
16
16
  import { renderTemplate } from '../templates/engine.ts';
17
17
  import {
18
+ MANUAL_INVOCATION_SKILLS,
19
+ OPENAI_EXPLICIT_POLICY,
18
20
  buildTemplateVars,
19
21
  enforceEthicsGovernance,
20
22
  loadLocaleResource,
@@ -49,7 +51,32 @@ export function updateFileWithMarkers(content: string, body: string): string {
49
51
  return `${MARKER_START}\n\n${body}\n${MARKER_END}\n\n${content}`;
50
52
  }
51
53
 
52
- /** END-boundary suffix, guaranteed blank-line-separated from following content. */
54
+ /** Drop a root AGENTS.md managed block. `null` means the file should be removed. */
55
+ export function stripManagedBlock(content: string): string | null {
56
+ const start = content.indexOf(MARKER_START);
57
+ const end = content.indexOf(MARKER_END);
58
+ if (start === -1 && end === -1) return content;
59
+ if (start === -1 || end === -1 || end < start) {
60
+ if (start !== -1 && end !== -1 && end < start) {
61
+ throw new Error('Invalid marker state: end marker appears before start marker.');
62
+ }
63
+ return content;
64
+ }
65
+ const before = content.slice(0, start);
66
+ let after = content.slice(end + MARKER_END.length);
67
+ if (before === '') after = after.replace(/^(?:\r?\n)+/u, '');
68
+ else after = after.replace(/^(?:\r?\n)/u, '');
69
+ const rest = before + after;
70
+ if (rest.trim() === '') return null;
71
+ return rest.endsWith('\n') ? rest : `${rest}\n`;
72
+ }
73
+
74
+ function stripRootAgents(io: InitIo): void {
75
+ if (!io.exists('AGENTS.md')) return;
76
+ const next = stripManagedBlock(io.readText('AGENTS.md'));
77
+ if (next === null) io.remove('AGENTS.md');
78
+ else if (next !== io.readText('AGENTS.md')) io.writeText('AGENTS.md', next);
79
+ }
53
80
  function separatorAfterEndMarker(suffix: string): string {
54
81
  const br = /^\r?\n/u.exec(suffix);
55
82
  if (br === null) return suffix === '' ? '\n' : `\n\n${suffix}`;
@@ -63,7 +90,7 @@ export const TEMPLATES_ROOT = join(import.meta.dirname, '..', '..', 'templates')
63
90
  /** Repo-root-relative filesystem effects needed by the init flow. */
64
91
  export type InitIo = Pick<
65
92
  FsPort,
66
- 'exists' | 'readText' | 'writeText' | 'mkdirp' | 'listDir' | 'removeDir'
93
+ 'exists' | 'readText' | 'writeText' | 'mkdirp' | 'listDir' | 'removeDir' | 'remove'
67
94
  >;
68
95
 
69
96
  function writeDefaultConfig(io: InitIo, locale: string): void {
@@ -124,7 +151,7 @@ export interface InitResult {
124
151
 
125
152
  const SKILLS_BASE = '.agents/skills';
126
153
 
127
- /** Managed AGENTS.md marker blocks (root + llmanspec), content-preserving. */
154
+ /** Managed llmanspec/AGENTS.md block, plus removal of a root AGENTS.md block. */
128
155
  function writeManagedBlocks(
129
156
  io: InitIo,
130
157
  templates: TemplateIo,
@@ -133,22 +160,22 @@ function writeManagedBlocks(
133
160
  ): void {
134
161
  const vars = buildTemplateVars(config, version);
135
162
  const locales = localeFallbacks(config.locale);
136
- for (const [stubPath, agentsPath] of [
137
- ['agents-root-stub.md', 'AGENTS.md'],
138
- ['llmanspec-agents-stub.md', 'llmanspec/AGENTS.md'],
139
- ] as const) {
140
- const stubRaw = loadLocaleResource(templates, TEMPLATES_ROOT, locales, stubPath);
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
- }
148
- const existing = io.exists(agentsPath) ? io.readText(agentsPath) : '';
149
- const body = renderTemplate(stubRaw, new Map(), vars);
150
- io.writeText(agentsPath, updateFileWithMarkers(existing, body));
163
+ const stubRaw = loadLocaleResource(
164
+ templates,
165
+ TEMPLATES_ROOT,
166
+ locales,
167
+ 'llmanspec-agents-stub.md',
168
+ );
169
+ if (stubRaw === null) {
170
+ throw new Error(
171
+ `template resource missing: llmanspec-agents-stub.md (locales tried: ${locales.join(', ')})`,
172
+ );
151
173
  }
174
+ const agentsPath = 'llmanspec/AGENTS.md';
175
+ const existing = io.exists(agentsPath) ? io.readText(agentsPath) : '';
176
+ const body = renderTemplate(stubRaw, new Map(), vars);
177
+ io.writeText(agentsPath, updateFileWithMarkers(existing, body));
178
+ stripRootAgents(io);
152
179
  }
153
180
 
154
181
  export function runInit(
@@ -187,7 +214,7 @@ export function runInit(
187
214
  io.writeText(`${CHANGES_DIR}/archive/.gitkeep`, '');
188
215
  }
189
216
 
190
- // 3) AGENTS.md managed blocks (root + llmanspec), preserving content.
217
+ // 3) llmanspec/AGENTS.md managed block; strip a root AGENTS.md block if present.
191
218
  writeManagedBlocks(io, templates, config, opts.version);
192
219
  const vars = buildTemplateVars(config, opts.version);
193
220
  const skillTemplates = loadSkillTemplates(templates, TEMPLATES_ROOT, config, vars);
@@ -217,6 +244,10 @@ export function runInit(
217
244
  const dirName = t.name.replace(/\.md$/u, '');
218
245
  io.mkdirp(`${SKILLS_BASE}/${dirName}`);
219
246
  io.writeText(`${SKILLS_BASE}/${dirName}/SKILL.md`, `${t.content.trimEnd()}\n`);
247
+ if (MANUAL_INVOCATION_SKILLS.includes(dirName)) {
248
+ io.mkdirp(`${SKILLS_BASE}/${dirName}/agents`);
249
+ io.writeText(`${SKILLS_BASE}/${dirName}/agents/openai.yaml`, OPENAI_EXPLICIT_POLICY);
250
+ }
220
251
  }
221
252
 
222
253
  return { skills: skillTemplates.map((t) => t.name.replace(/\.md$/u, '')), removed, configPath };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * `init --check`: installed llman-sdd skill versions must share the CLI's
3
+ * major.minor. Patch may differ. Missing or unreadable versions fail.
4
+ */
5
+
6
+ const VERSION_RE = /version:\s*["']?(\d+\.\d+(?:\.\d+)?)["']?/u;
7
+
8
+ export function readSkillVersion(markdown: string): string | null {
9
+ if (!markdown.startsWith('---')) return null;
10
+ const end = markdown.indexOf('\n---', 3);
11
+ if (end < 0) return null;
12
+ const match = VERSION_RE.exec(markdown.slice(0, end));
13
+ return match?.[1] ?? null;
14
+ }
15
+
16
+ function part(version: string, index: number): number {
17
+ return Math.trunc(Number(version.split('.')[index] ?? '0')) || 0;
18
+ }
19
+
20
+ /** Compatible when major and minor both match. */
21
+ export function skillVersionCompatible(skillVersion: string, cliVersion: string): boolean {
22
+ return (
23
+ part(skillVersion, 0) === part(cliVersion, 0) && part(skillVersion, 1) === part(cliVersion, 1)
24
+ );
25
+ }
26
+
27
+ export interface SkillVersionCheck {
28
+ ok: boolean;
29
+ message: string;
30
+ }
31
+
32
+ export function checkSkillVersions(
33
+ skills: readonly { name: string; markdown: string }[],
34
+ cliVersion: string,
35
+ ): SkillVersionCheck {
36
+ if (skills.length === 0) {
37
+ return {
38
+ ok: false,
39
+ message: `no llman-sdd skills installed; run \`llman-sdd init --update\``,
40
+ };
41
+ }
42
+ const problems: string[] = [];
43
+ for (const skill of skills) {
44
+ const found = readSkillVersion(skill.markdown);
45
+ if (found === null) {
46
+ problems.push(`${skill.name}: metadata.version missing`);
47
+ continue;
48
+ }
49
+ if (!skillVersionCompatible(found, cliVersion)) {
50
+ problems.push(`${skill.name}: ${found} is outside ${cliVersion} (same major.minor required)`);
51
+ }
52
+ }
53
+ if (problems.length > 0) {
54
+ return {
55
+ ok: false,
56
+ message: `${problems.join('\n')}\nrun \`llman-sdd init --update\``,
57
+ };
58
+ }
59
+ return { ok: true, message: `skill versions match llman-sdd ${cliVersion}` };
60
+ }
@@ -31,8 +31,7 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
31
31
  {
32
32
  title: 'Governance metadata retirement (`# reviewed-through:` stamp & `# scope:` header)',
33
33
  steps: [
34
- 'Run `llman-sdd project migrate strip-legacy-headers --dry-run` to preview the affected spec files.',
35
- 'Run `llman-sdd project migrate strip-legacy-headers` to strip legacy `# scope:` / `# reviewed-through:` / `# capability:` header comment lines (idempotent).',
34
+ 'Delete leftover `# scope:`, `# reviewed-through:`, and `# capability:` header comment lines under `llmanspec/specs/**` by hand. The one-shot command was removed and has no alias.',
36
35
  'Run `llman-sdd init --update` to refresh the managed AGENTS blocks and agent skills.',
37
36
  'Run `llman-sdd validate --all --strict` — it must pass.',
38
37
  ],
@@ -51,8 +50,7 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
51
50
  {
52
51
  title: 'Retire `# capability:` header; assign spec ids from paths (r101)',
53
52
  steps: [
54
- 'Run `llman-sdd project migrate strip-legacy-headers --dry-run` to preview spec header strips.',
55
- 'Run `llman-sdd project migrate strip-legacy-headers` to remove `# capability:` (and any remaining `# scope:` / `# reviewed-through:`) lines.',
53
+ 'Delete leftover `# capability:` (and any remaining `# scope:` / `# reviewed-through:`) lines under `llmanspec/specs/**` by hand. The one-shot command was removed and has no alias.',
56
54
  'Ensure each `功能:` / `Feature:` title equals the assigned spec id (`llman-sdd list --specs` for ids).',
57
55
  'Run `llman-sdd init --update` to refresh managed skills and feature-contract guidance.',
58
56
  'Run `llman-sdd validate --all --strict` — it must pass.',
@@ -100,12 +98,12 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
100
98
  steps: [
101
99
  'Optionally pin `locale: zh-Hans` in `llmanspec/config.yaml` — `en` and any unknown value now render Chinese.',
102
100
  '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`.',
101
+ 'Re-run `llman-sdd spec new <name>` where a skeleton dialect matters — it now emits `# language: zh-CN`.',
104
102
  'Run `llman-sdd validate --all --strict` — it must pass.',
105
103
  ],
106
104
  checks: [
107
105
  'No English-rendered managed block or skill remains after `init --update`.',
108
- '`llman-sdd spec skeleton <name>` emits `# language: zh-CN`.',
106
+ '`llman-sdd spec new <name>` emits `# language: zh-CN`.',
109
107
  'A missing template resource makes `init` fail instead of silently skipping.',
110
108
  ],
111
109
  },
@@ -116,10 +114,10 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
116
114
  'For a change that touches the contract, land and commit your `llmanspec/specs/**` edits on the bound branch before closing out.',
117
115
  'Set `needs_specs_change: false` in `proposal.md` frontmatter only when the change genuinely needs no contract edit.',
118
116
  '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.',
117
+ 'Run `llman-sdd change archive <id>` — the gate runs before any merge and writes nothing on failure.',
120
118
  ],
121
119
  checks: [
122
- '`llman-sdd change finalize <id>` on a spec-unlanded change fails with zero writes.',
120
+ '`llman-sdd change archive <id>` on a spec-unlanded change fails with zero writes.',
123
121
  'A change that landed its specs, or declared `needs_specs_change: false`, still closes out cleanly.',
124
122
  ],
125
123
  },
@@ -167,6 +165,80 @@ export const MIGRATIONS: readonly MigrationDoc[] = [
167
165
  },
168
166
  ],
169
167
  },
168
+ {
169
+ version: '0.11.0',
170
+ items: [
171
+ {
172
+ title: 'Frozen cards normalized to single-document YAML (no `---` fences)',
173
+ steps: [
174
+ 'Run `llman-sdd project migrate frozen-cards-unfence --dry-run` to preview the legacy fenced cards.',
175
+ 'Run `llman-sdd project migrate frozen-cards-unfence` to rewrite them as fence-free single-document YAML (idempotent).',
176
+ 'Drop any `check-yaml` exemption you added for `llmanspec/changes/archive/*.yaml` — stock pre-commit accepts the cards as-is.',
177
+ 'Run `llman-sdd validate --all --strict` — it must pass.',
178
+ ],
179
+ checks: [
180
+ 'No `llmanspec/changes/archive/<YYYY-MM-DD>-<id>.yaml` card opens with a bare `---` line.',
181
+ 'The stock `check-yaml` hook (no `--allow-multiple-documents`, no exclude) passes on the archive directory.',
182
+ '`llman-sdd graph --scope archived` shows the same frozen nodes and dependency edges as before.',
183
+ ],
184
+ },
185
+ {
186
+ title: 'Index and context commands removed',
187
+ steps: [
188
+ 'Stop calling `llman-sdd index` and `llman-sdd context`. Both are unknown commands and have no aliases.',
189
+ 'Unset `LLMAN_SDD_INDEX_BACKEND`, `LLMAN_SDD_INDEX_CHAT_MODEL`, `LLMAN_SDD_INDEX_CHAT_API_HOST`, `LLMAN_SDD_INDEX_CHAT_API_KEY`, `LLMAN_SDD_INDEX_OPENAI_API_HOST`, and `LLMAN_SDD_INDEX_OPENAI_API_KEY` if you exported them.',
190
+ 'Locate specs with `llman-sdd list --specs` and read the `.feature` files.',
191
+ 'Leave `llmanspec/.context/pageindex/` in place if you want; nothing reads it. Delete that directory yourself when you no longer need it.',
192
+ 'The version stamp moved to `llmanspec/.sdd-state.json`. An existing `llmanspec/.context/sdd-state.json` is still read until the next `llman-sdd init --update`, which writes only the new path and does not delete the old file.',
193
+ 'Run `llman-sdd init --update` so installed skills stop mentioning index and context.',
194
+ ],
195
+ checks: [
196
+ '`llman-sdd index` and `llman-sdd context` exit 2 as unknown commands.',
197
+ '`llmanspec/.sdd-state.json` exists after `init --update` and contains `cli_version`.',
198
+ 'If `llmanspec/.context/sdd-state.json` was present, it is still on disk after the update.',
199
+ ],
200
+ },
201
+ {
202
+ title: 'Command surface: one close-out, one bind, top-level cold backup',
203
+ steps: [
204
+ 'Replace `llman-sdd change finalize` with `llman-sdd change archive`. There is no alias. Close-out now also requires a clean tree and refuses `--force`.',
205
+ 'Replace `llman-sdd archive freeze` with `llman-sdd freeze`, and `llman-sdd archive thaw` with `llman-sdd thaw`. Flags are unchanged.',
206
+ 'Replace `llman-sdd change attach` with `llman-sdd change start`. On the default branch it creates `sdd/<id>`; on another local branch it binds the current checkout. `--force` rebinds.',
207
+ 'Replace `llman-sdd spec skeleton` with `llman-sdd spec new`.',
208
+ 'Stop calling `spec migrate-native`, `project migrate strip-legacy-headers`, `project migrate --kind`, and `--version-expr`. Those commands and flags are gone and have no aliases. Keep `project migrate prompt` and `project migrate frozen-cards-unfence`.',
209
+ 'Run `llman-sdd init --update` so installed skills name the new commands.',
210
+ ],
211
+ checks: [
212
+ '`llman-sdd change finalize`, `llman-sdd change attach`, `llman-sdd spec skeleton`, and `llman-sdd archive` exit 2 as unknown commands.',
213
+ '`llman-sdd change archive --help` lists `--no-check`, `--no-commit`, and `--dry-run`, and does not list `--force`.',
214
+ '`llman-sdd freeze --help` and `llman-sdd thaw --help` succeed.',
215
+ ],
216
+ },
217
+ {
218
+ title: 'Skill discovery no longer uses extra_skills or a root AGENTS.md block',
219
+ steps: [
220
+ 'Remove `extra_skills` from `llmanspec/config.yaml` if present. Leftover keys are ignored.',
221
+ 'Run `llman-sdd init --update`. It writes every built-in `llman-sdd-*` skill, leaves unprefixed custom skills, and strips an existing `LLMANSPEC` marker block from the repository-root `AGENTS.md` while keeping text outside the markers. It does not create a root `AGENTS.md` when none exists. `llmanspec/AGENTS.md` stays managed.',
222
+ 'Run `llman-sdd init --check`. Installed `llman-sdd-*` skills must share this CLI major and minor. On mismatch, run `llman-sdd init --update` again.',
223
+ ],
224
+ checks: [
225
+ '`llman-sdd init --check` exits 0.',
226
+ 'The repository-root `AGENTS.md` has no `LLMANSPEC` markers. `llmanspec/AGENTS.md` still has its managed block.',
227
+ ],
228
+ },
229
+ {
230
+ title: 'Binary build defines use the DEV_BUILD prefix',
231
+ steps: [
232
+ 'If a custom build script defines `process.env.LLMAN_SDD_VERSION`, `process.env.LLMAN_SDD_EMBEDDED_TEMPLATES`, or `process.env.LLMAN_SDD_EMBEDDED_7ZZ_WASM_B64`, rename those keys to `process.env.LLMAN_SDD_DEV_BUILD_VERSION`, `process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_TEMPLATES`, and `process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_7ZZ_WASM_B64`. The source literal must match the define key exactly.',
233
+ 'Leave `LLMAN_SDD_HARNESS_ACTIVE` unchanged. It is a runtime nested-run guard, not a compile define.',
234
+ ],
235
+ checks: [
236
+ 'A rebuilt binary reports this release from `llman-sdd --version`.',
237
+ '`llman-sdd init` from that binary still renders skills, and `freeze` / `thaw` still round-trip.',
238
+ ],
239
+ },
240
+ ],
241
+ },
170
242
  ];
171
243
 
172
244
  const VERSION_RE = /^\d+\.\d+\.\d+$/u;
@@ -232,6 +304,6 @@ export function migrationOverviewLines(): string[] {
232
304
  'Versioned migration playbooks (agent-readable, via `project migrate prompt`):',
233
305
  versions,
234
306
  'Usage: llman-sdd project migrate prompt --from-version <from> --to-version <to>',
235
- 'Mechanical spec-header strip: llman-sdd project migrate strip-legacy-headers [--dry-run]',
307
+ 'Legacy frozen-card unfence: llman-sdd project migrate frozen-cards-unfence [--dry-run]',
236
308
  ];
237
309
  }
@@ -165,7 +165,11 @@ export function addScenario(
165
165
  `${givenLine} ${kw.when} ${opts.when}\n ${kw.thenText} ${opts.thenText}\n`;
166
166
  // insert with a leading blank separator so the file stays readable
167
167
  lines.splice(end, 0, '', scenarioBlock.trimEnd());
168
- io.writeText(path, lines.join('\n'));
168
+ const joined = lines.join('\n');
169
+ // 末尾换行保真:插入落在文件尾时,split 产生的结尾空串不再是最后一项,
170
+ // join 会把原文件的尾换行吃掉;中段插入无此问题。缺行尾换行会让
171
+ // end-of-file-fixer 之类的钩子反复改写文件。
172
+ io.writeText(path, content.endsWith('\n') && !joined.endsWith('\n') ? `${joined}\n` : joined);
169
173
  return path;
170
174
  }
171
175
 
@@ -29,7 +29,6 @@ export const OPTIONAL_SKILL_FILES: readonly string[] = [
29
29
  ];
30
30
 
31
31
  export const UNIT_FILES: readonly string[] = [
32
- 'skills/index-fallback.md',
33
32
  'skills/validation-hints.md',
34
33
  'skills/human-readable-summary.md',
35
34
  'skills/git-native-flow.md',
@@ -50,17 +49,28 @@ export const ETHICS_KEYS: readonly string[] = [
50
49
  ];
51
50
 
52
51
  /** All-string globals (predecessor BTreeMap<String, String> semantics). */
52
+ /** Skills the model must not load on its own. Init writes the Codex policy file for these. */
53
+ export const MANUAL_INVOCATION_SKILLS: readonly string[] = [
54
+ 'llman-sdd-apply-cycle',
55
+ 'llman-sdd-wayfinder',
56
+ 'llman-sdd-specs-compact',
57
+ 'llman-sdd-ff',
58
+ ];
59
+
60
+ export const OPENAI_EXPLICIT_POLICY = `policy:\n allow_implicit_invocation: false\n`;
61
+
53
62
  export function buildTemplateVars(config: SddConfig, version: string): Record<string, string> {
54
63
  const vars: Record<string, string> = { llman_version: version };
55
64
  if (config.specs) {
56
65
  vars['specs_enabled'] = 'true';
57
66
  if (config.specs.verify_prompt) vars['specs_verify_prompt'] = config.specs.verify_prompt;
58
67
  }
59
- const extras = new Set<string>(config.extra_skills ?? []);
68
+ // Every optional skill is installed. Template conditionals that used to
69
+ // follow extra_skills therefore always see the skill as present.
60
70
  for (const name of OPTIONAL_SKILL_FILES) {
61
71
  const stem = name.replace(/\.md$/u, '');
62
72
  const key = `extra_skill_${stem.replace(/^llman-sdd-/u, '').replaceAll('-', '_')}`;
63
- if (extras.has(stem)) vars[key] = 'true';
73
+ vars[key] = 'true';
64
74
  }
65
75
  return vars;
66
76
  }
@@ -103,15 +113,8 @@ export interface SkillTemplate {
103
113
  content: string;
104
114
  }
105
115
 
106
- export function skillCandidates(config: SddConfig): string[] {
107
- const extras: readonly string[] = config.extra_skills ?? [];
108
- return [
109
- ...DEFAULT_SKILL_FILES,
110
- ...OPTIONAL_SKILL_FILES.filter((f) => {
111
- const stem = f.replace(/\.md$/u, '');
112
- return extras.includes(stem);
113
- }),
114
- ];
116
+ export function skillCandidates(_config: SddConfig): string[] {
117
+ return [...DEFAULT_SKILL_FILES, ...OPTIONAL_SKILL_FILES];
115
118
  }
116
119
 
117
120
  export function loadSkillTemplates(