@llman-sdd/core 0.10.1 → 0.12.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 (119) hide show
  1. package/package.json +11 -8
  2. package/src/archive/freeze.ts +41 -15
  3. package/src/archive/frozenCard.ts +57 -9
  4. package/src/archive/ignoreChain.ts +2 -6
  5. package/src/archive/sevenzip.ts +0 -1
  6. package/src/change/closeOutHarness.ts +17 -0
  7. package/src/change/collect.ts +0 -5
  8. package/src/change/frontmatter.ts +15 -7
  9. package/src/change/id.ts +0 -2
  10. package/src/change/lifecycle.ts +53 -94
  11. package/src/config/changeId.ts +0 -2
  12. package/src/config/load.ts +0 -4
  13. package/src/config/schema.ts +24 -13
  14. package/src/config/surface.ts +2 -12
  15. package/src/context/sddState.ts +23 -18
  16. package/src/git/spawnGit.ts +0 -3
  17. package/src/hints/jitHints.ts +82 -0
  18. package/src/index.ts +462 -39
  19. package/src/init/defaultConfig.ts +4 -13
  20. package/src/init/init.ts +108 -36
  21. package/src/init/skillCheck.ts +60 -0
  22. package/src/init/uncommentConfig.ts +909 -0
  23. package/src/locale.ts +0 -2
  24. package/src/project/migrateNotes.ts +0 -9
  25. package/src/project/migrations.ts +151 -9
  26. package/src/report/graph/analysis.ts +0 -4
  27. package/src/report/graph/nodes.ts +0 -6
  28. package/src/report/show.ts +7 -23
  29. package/src/report/specHelpers.ts +10 -14
  30. package/src/review/review.ts +0 -12
  31. package/src/spec/assignSpecIds.ts +0 -3
  32. package/src/spec/authoring.ts +16 -24
  33. package/src/spec/ir.ts +14 -5
  34. package/src/spec/keywords.ts +0 -2
  35. package/src/spec/machineKey.ts +49 -0
  36. package/src/spec/migrateNative.ts +4 -18
  37. package/src/spec/parser.ts +10 -19
  38. package/src/spec/reqRef.ts +135 -0
  39. package/src/studio/changeScope.ts +50 -0
  40. package/src/studio/changeScopeDiff.ts +195 -0
  41. package/src/studio/contracts.ts +493 -0
  42. package/src/studio/decisionTree.ts +206 -0
  43. package/src/studio/deeplink.ts +116 -0
  44. package/src/studio/demos.ts +167 -0
  45. package/src/studio/diff.ts +494 -0
  46. package/src/studio/drift.ts +738 -0
  47. package/src/studio/extract.ts +360 -0
  48. package/src/studio/featureSync.ts +592 -0
  49. package/src/studio/forest.ts +570 -0
  50. package/src/studio/index.ts +32 -0
  51. package/src/studio/model.ts +254 -0
  52. package/src/studio/revisions.ts +476 -0
  53. package/src/studio/search.ts +337 -0
  54. package/src/studio/store.ts +811 -0
  55. package/src/studio/sync.ts +912 -0
  56. package/src/studio/textfold.ts +72 -0
  57. package/src/studio/time.ts +107 -0
  58. package/src/studio/validate.ts +363 -0
  59. package/src/templates/embedded.ts +4 -6
  60. package/src/templates/engine.ts +1 -1
  61. package/src/templates/skills.ts +76 -51
  62. package/src/theorems/guard.ts +52 -0
  63. package/src/theorems/index.ts +56 -0
  64. package/src/theorems/migrate.ts +133 -0
  65. package/src/theorems/schema.ts +67 -0
  66. package/src/theorems/scope.ts +68 -0
  67. package/src/theorems/serialize.ts +60 -0
  68. package/src/theorems/transactionMachine.ts +247 -0
  69. package/src/theorems/validate.ts +141 -0
  70. package/src/util/nextNumber.ts +0 -2
  71. package/src/validation/changeCheck.ts +0 -24
  72. package/src/validation/flowAndNesting.ts +434 -0
  73. package/src/validation/harness.ts +108 -65
  74. package/src/validation/validate.ts +26 -12
  75. package/src/validation/xstateTransitions.ts +483 -184
  76. package/templates/zh-Hans/llmanspec-agents-stub.md +17 -2
  77. package/templates/zh-Hans/skills/llman-sdd-autopilot/SKILL.md +34 -0
  78. package/templates/zh-Hans/skills/llman-sdd-change/SKILL.md +44 -0
  79. package/templates/zh-Hans/skills/llman-sdd-change/playbooks/archive.md +15 -0
  80. package/templates/zh-Hans/skills/llman-sdd-change/playbooks/draft.md +9 -0
  81. package/templates/zh-Hans/skills/llman-sdd-review/SKILL.md +71 -0
  82. package/templates/zh-Hans/skills/llman-sdd-specs/SKILL.md +70 -0
  83. package/templates/zh-Hans/skills/llman-sdd-specs/playbooks/compact.md +12 -0
  84. package/templates/zh-Hans/skills/llman-sdd-specs/playbooks/doctor.md +26 -0
  85. package/templates/zh-Hans/skills/llman-sdd-specs/references/graph-dsl.md +33 -0
  86. package/templates/zh-Hans/skills/llman-sdd-studio/SKILL.md +33 -0
  87. package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/collab.md +20 -0
  88. package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/drift.md +52 -0
  89. package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/onboard.md +33 -0
  90. package/templates/zh-Hans/units/skills/cli-footer.md +2 -2
  91. package/src/context/indexStore.ts +0 -171
  92. package/src/context/retrieve.ts +0 -332
  93. package/src/context/tree.ts +0 -112
  94. package/templates/zh-Hans/agents-root-stub.md +0 -9
  95. package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +0 -69
  96. package/templates/zh-Hans/skills/llman-sdd-apply.md +0 -117
  97. package/templates/zh-Hans/skills/llman-sdd-arch-review.md +0 -58
  98. package/templates/zh-Hans/skills/llman-sdd-archive.md +0 -79
  99. package/templates/zh-Hans/skills/llman-sdd-continue.md +0 -34
  100. package/templates/zh-Hans/skills/llman-sdd-draft.md +0 -53
  101. package/templates/zh-Hans/skills/llman-sdd-explore.md +0 -64
  102. package/templates/zh-Hans/skills/llman-sdd-ff.md +0 -33
  103. package/templates/zh-Hans/skills/llman-sdd-graph.md +0 -56
  104. package/templates/zh-Hans/skills/llman-sdd-propose.md +0 -107
  105. package/templates/zh-Hans/skills/llman-sdd-quick.md +0 -41
  106. package/templates/zh-Hans/skills/llman-sdd-research.md +0 -35
  107. package/templates/zh-Hans/skills/llman-sdd-specs-compact.md +0 -41
  108. package/templates/zh-Hans/skills/llman-sdd-validate.md +0 -28
  109. package/templates/zh-Hans/skills/llman-sdd-verify.md +0 -77
  110. package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +0 -83
  111. package/templates/zh-Hans/units/skills/ethics-governance.md +0 -6
  112. package/templates/zh-Hans/units/skills/git-native-flow.md +0 -56
  113. package/templates/zh-Hans/units/skills/human-readable-summary.md +0 -9
  114. package/templates/zh-Hans/units/skills/index-fallback.md +0 -1
  115. package/templates/zh-Hans/units/skills/stage-guard.md +0 -17
  116. package/templates/zh-Hans/units/skills/structured-protocol.md +0 -19
  117. package/templates/zh-Hans/units/skills/validation-hints.md +0 -20
  118. package/templates/zh-Hans/units/skills/version-drift.md +0 -3
  119. package/templates/zh-Hans/units/spec/feature-contract.md +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llman-sdd/core",
3
- "version": "0.10.1",
3
+ "version": "0.12.0",
4
4
  "description": "Pure domain logic for llman-sdd (config, gherkin specs, validation, templates)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "type": "module",
16
16
  "exports": {
17
- ".": "./src/index.ts"
17
+ ".": "./src/index.ts",
18
+ "./studio": "./src/studio/index.ts"
18
19
  },
19
20
  "scripts": {
20
21
  "lint": "bun run --cwd ../.. lint",
@@ -25,15 +26,17 @@
25
26
  },
26
27
  "dependencies": {
27
28
  "7z-wasm": "^1.2.0",
28
- "@cucumber/gherkin": "^42.0.1",
29
- "@cucumber/messages": "^34.2.1",
29
+ "@cucumber/gherkin": "^43.0.0",
30
+ "@cucumber/messages": "^35.0.0",
30
31
  "@statelyai/graph": "^2.6.0",
31
- "@toon-format/toon": "^4.1.1",
32
- "ignore": "^7.0.12",
32
+ "@toon-format/toon": "^4.4.0",
33
+ "diff": "^8.0.3",
34
+ "ignore": "^7.0.16",
33
35
  "nunjucks": "^3.2.4",
34
- "xstate": "^5.33.2",
36
+ "smol-toml": "^1.9.1",
37
+ "xstate": "6.0.0-beta.7",
35
38
  "yaml": "^2.9.1",
36
- "zod": "^4.6.5"
39
+ "zod": "^4.6.7"
37
40
  },
38
41
  "engines": {
39
42
  "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';
@@ -97,13 +98,9 @@ export async function runFreeze(
97
98
  };
98
99
  }
99
100
 
100
- // Card = authoritative record that bodies are in the cold backup. Write
101
- // cards first; on `7z add` failure roll them back and keep the original dirs.
102
101
  const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
103
102
  const archiveBase = join(rootAbs, ARCHIVE_DIR_REL);
104
103
 
105
- // r120: layered gitignore filtering runs before any mutation — user-file
106
- // existence errors and the zero-files guard must leave the tree untouched.
107
104
  const packed: string[] = [];
108
105
  let excludedTotal = 0;
109
106
  for (const c of candidates) {
@@ -124,7 +121,6 @@ export async function runFreeze(
124
121
  const proposalRel = `${ARCHIVE_DIR_REL}/${c}/proposal.md`;
125
122
  const proposal = io.exists(proposalRel) ? io.readText(proposalRel) : '';
126
123
  const frontmatter = extractFrontmatter(proposal) ?? '';
127
- // r24: frontmatter `title` wins when non-empty; H1 is the legacy fallback.
128
124
  cards.push({
129
125
  datedId: c,
130
126
  source: composeFrozenCard(
@@ -172,10 +168,7 @@ export async function runList(io: FreezeIo, sz: SevenZipPort, rootAbs: string):
172
168
  }
173
169
  const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
174
170
  if (io.exists(archiveAbs)) {
175
- // Legacy/unexpected entries present only inside the 7z (no card on disk).
176
171
  const entries = (await sz.listEntries(archiveAbs)).map((n) => n.replace(/\/$/u, ''));
177
- // 7z entry names always use '/' per archive contract — POSIX by contract, not
178
- // platform-native; do not switch to node:path here.
179
172
  const top = (n: string): string => n.split('/')[0] ?? n;
180
173
  for (const e of entries.map(top).filter((n) => DATED_RE.test(n))) {
181
174
  if (!names.has(e)) names.add(e);
@@ -198,6 +191,42 @@ export interface ThawResult {
198
191
  restored: string[];
199
192
  }
200
193
 
194
+ /**
195
+ * r121: rewrite every fenced card under `archiveDirRel` into the fence-free
196
+ * single-document form. Shared by the thaw pass and the migrate action so both
197
+ * obey one definition of "legacy card". Returns how many cards changed.
198
+ * Cards that are not fenced (or not plainly fenced) are left untouched.
199
+ */
200
+ export function unfenceLegacyCards(io: FreezeIo, archiveDirRel: string): number {
201
+ let changed = 0;
202
+ for (const rel of planUnfenceLegacyCards(io, archiveDirRel)) {
203
+ const unfenced = unfenceFrozenCard(io.readText(rel));
204
+ if (unfenced === null) continue;
205
+ io.writeText(rel, unfenced);
206
+ changed++;
207
+ }
208
+ return changed;
209
+ }
210
+
211
+ /**
212
+ * r121: dry-run half of {@link unfenceLegacyCards} — the exact same scan and
213
+ * predicates, returning the card paths that WOULD change without writing.
214
+ * Sharing the predicate is what keeps `--dry-run` from drifting from the write
215
+ * path.
216
+ */
217
+ export function planUnfenceLegacyCards(io: FreezeIo, archiveDirRel: string): string[] {
218
+ if (!io.exists(archiveDirRel)) return [];
219
+ const hits: string[] = [];
220
+ for (const name of io.listDir(archiveDirRel).toSorted()) {
221
+ if (!isFrozenCard(name) || frozenCardIdOf(name) === null) continue;
222
+ const rel = `${archiveDirRel}/${name}`;
223
+ if (io.isDirectory(rel)) continue;
224
+ if (unfenceFrozenCard(io.readText(rel)) === null) continue;
225
+ hits.push(rel);
226
+ }
227
+ return hits;
228
+ }
229
+
201
230
  export async function runThaw(
202
231
  io: FreezeIo,
203
232
  sz: SevenZipPort,
@@ -205,7 +234,6 @@ export async function runThaw(
205
234
  names: string[],
206
235
  opts: { dest?: string } = {},
207
236
  ): Promise<ThawResult> {
208
- // r56: restore target override (created on demand); default = changes/archive
209
237
  const destRel = opts.dest ?? ARCHIVE_DIR_REL;
210
238
  const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
211
239
  if (!io.exists(`${ARCHIVE_DIR_REL}/${FREEZE_ARCHIVE_NAME}`)) {
@@ -219,8 +247,6 @@ export async function runThaw(
219
247
  const available = new Set(
220
248
  io.exists(tmpRel) ? io.listDir(tmpRel).filter((n) => DATED_RE.test(n)) : [],
221
249
  );
222
- // Cards on disk also count as available (they are the authoritative record
223
- // that bodies are in the cold backup, even before any extraction listing).
224
250
  for (const name of io.exists(ARCHIVE_DIR_REL) ? io.listDir(ARCHIVE_DIR_REL) : []) {
225
251
  if (isFrozenCard(name) && frozenCardIdOf(name) !== null) {
226
252
  available.add(name.slice(0, -FROZEN_CARD_EXT.length));
@@ -242,10 +268,10 @@ export async function runThaw(
242
268
  if (io.exists(cardRel)) io.remove(cardRel);
243
269
  restored.push(name);
244
270
  }
245
- return {
246
- restored,
247
- lines: [`Thawed ${restored.length} selected archived changes to ${destRel}`],
248
- };
271
+ const unfenced = unfenceLegacyCards(io, ARCHIVE_DIR_REL);
272
+ const lines = [`Thawed ${restored.length} selected archived changes to ${destRel}`];
273
+ if (unfenced > 0) lines.push(`Unfenced ${unfenced} legacy card(s)`);
274
+ return { restored, lines };
249
275
  } finally {
250
276
  io.removeDir(tmpRel);
251
277
  }
@@ -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';
@@ -67,7 +70,6 @@ export function extractDependsOn(frontmatter: string): string {
67
70
  const lines = frontmatter.split('\n');
68
71
  const flowIdx = lines.findIndex((l) => /^depends_on\s*:\s*\[/u.test(l));
69
72
  if (flowIdx !== -1) {
70
- // Single-line flow `depends_on: [a, b]` (may span lines).
71
73
  let acc = (lines[flowIdx] ?? '').replace(/^depends_on\s*:/u, '').trim();
72
74
  let j = flowIdx;
73
75
  while (!/\]\s*$/u.test(acc) && j < lines.length - 1) {
@@ -79,17 +81,14 @@ export function extractDependsOn(frontmatter: string): string {
79
81
  }
80
82
  const blockIdx = lines.findIndex((l) => /^depends_on\s*:\s*$/u.test(l));
81
83
  if (blockIdx !== -1) {
82
- // Block list `- a` lines.
83
84
  const items: string[] = [];
84
85
  for (const l of lines.slice(blockIdx + 1)) {
85
86
  const m = l.match(/^\s*-\s+(\S+)/u);
86
87
  if (m?.[1]) items.push(m[1].replaceAll(/['"]/gu, ''));
87
- // multi-line flow handled below
88
88
  else if (/^\s*\[/u.test(l)) break;
89
89
  else if (l.trim() !== '') break;
90
90
  }
91
91
  if (items.length > 0) return toFlow(items);
92
- // Multi-line flow `[\n a,\n b\n ]`.
93
92
  let acc = lines
94
93
  .slice(blockIdx + 1)
95
94
  .join(' ')
@@ -106,3 +105,52 @@ export function composeFrozenCard(title: string, frontmatter: string): string {
106
105
  const dependsOn = extractDependsOn(frontmatter);
107
106
  return [`title: "${escapeYamlScalar(title)}"`, dependsOn].join('\n') + '\n';
108
107
  }
108
+
109
+ /**
110
+ * r121: fence-stripping normalizer for legacy cards. Predecessor-era cards
111
+ * open and close with a standalone `---` line, which makes them a *multi*-
112
+ * document YAML stream — generic single-document validators (pre-commit's
113
+ * `check-yaml` by default) reject them. Returns the fence-free text, or null
114
+ * when the input is not a plain fenced card.
115
+ *
116
+ * Conservative by construction — a miss is fine, a false rewrite is not:
117
+ * - first and last non-empty lines must each be exactly `---` (a stray `---`
118
+ * inside a scalar value must never trigger a rewrite);
119
+ * - the stripped body must parse as exactly one YAML document;
120
+ * - that document's keys must be a subset of `title` / `depends_on`.
121
+ * A card already in the fence-free form returns null (idempotent by contract).
122
+ */
123
+ export function unfenceFrozenCard(source: string): string | null {
124
+ const lines = source.split('\n');
125
+ while (lines.length > 0 && (lines[lines.length - 1] ?? '').trim() === '') lines.pop();
126
+ if (lines.length < 3) return null;
127
+ const isFence = (line: string | undefined): boolean =>
128
+ (line ?? '').replace(/\s+$/u, '') === '---';
129
+ if (!isFence(lines[0]) || !isFence(lines[lines.length - 1])) return null;
130
+ // Normalize to LF while stripping: a lone trailing \r is not a YAML line ~keep
131
+ // break, so a CRLF card would otherwise fail the single-document parse.
132
+ const body = lines
133
+ .slice(1, -1)
134
+ .map((line) => line.replace(/\r$/u, ''))
135
+ .join('\n');
136
+ if (body.trim() === '') return null;
137
+ let parsed: unknown;
138
+ try {
139
+ const doc = parseDocument(body);
140
+ if (doc.errors.length > 0) return null;
141
+ parsed = doc.toJS({ json: true });
142
+ } catch {
143
+ return null;
144
+ }
145
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return null;
146
+ const record = parsed as Record<string, unknown>;
147
+ const keys = Object.keys(record);
148
+ if (keys.length === 0) return null;
149
+ const allowed = new Set(['title', 'depends_on']);
150
+ if (keys.some((k) => !allowed.has(k))) return null;
151
+ const title = record['title'];
152
+ if (title !== undefined && typeof title !== 'string') return null;
153
+ const deps = record['depends_on'];
154
+ if (deps !== undefined && deps !== null && !Array.isArray(deps)) return null;
155
+ return `${body}\n`;
156
+ }
@@ -89,8 +89,6 @@ function decide(
89
89
  layers.push(...ancestors);
90
90
  for (const layer of layers) {
91
91
  let rel = relPosix(layer.base, pathAbs);
92
- // A .gitignore governs only its own subtree (git semantics); layers the
93
- // path lies outside of cannot decide and must not be consulted.
94
92
  if (rel === '' || rel === '..' || rel.startsWith('../')) continue;
95
93
  if (isDir) rel = `${rel}/`;
96
94
  const verdict = layer.ig.test(rel);
@@ -131,8 +129,6 @@ export function collectFilteredEntries(
131
129
  user.push({ base: opts.candidateAbs, ig: createIgnore().add(io.readText(file)) });
132
130
  }
133
131
 
134
- // Ancestor chain: candidate dir first (highest of the fixed layers), then
135
- // each parent up to the discovered ignore root (outermost, last).
136
132
  const outer = discoverIgnoreRoot(io, opts.rootAbs);
137
133
  const ancestors: Layer[] = [];
138
134
  for (let cur = opts.candidateAbs; ; cur = dirname(cur)) {
@@ -140,7 +136,7 @@ export function collectFilteredEntries(
140
136
  if (layer) ancestors.push(layer);
141
137
  if (cur === outer) break;
142
138
  const parent = dirname(cur);
143
- if (parent === cur) break; // defensive: ignore root not an ancestor
139
+ if (parent === cur) break;
144
140
  }
145
141
 
146
142
  const walk: Layer[] = [];
@@ -150,7 +146,7 @@ export function collectFilteredEntries(
150
146
  const layer = loadLayer(io, dirAbs);
151
147
  if (layer) walk.push(layer);
152
148
  for (const name of io.listDir(dirAbs).toSorted()) {
153
- if (name === '.git') continue; // git never packs .git metadata (r120)
149
+ if (name === '.git') continue;
154
150
  const abs = join(dirAbs, name);
155
151
  const isDir = io.isDirectory(abs);
156
152
  if (decide(user, walk, ancestors, abs, isDir)) {
@@ -108,7 +108,6 @@ function parseListNames(lines: string[]): string[] {
108
108
  continue;
109
109
  }
110
110
  if (nameCol < 0 || attrCol < 0 || line.trim() === '') continue;
111
- // Attr cells are fixed-width 5 chars (e.g. `....A`, `D....`).
112
111
  const attr = line.slice(attrCol, attrCol + 5);
113
112
  const name = line.slice(nameCol).trim();
114
113
  if (name !== '' && !attr.includes('D')) names.push(name);
@@ -31,3 +31,20 @@ export function decideCloseOutHarness(input: {
31
31
  }
32
32
  return { kind: 'run', command };
33
33
  }
34
+
35
+ /** r182: optional check_dangling_bdd_command after check_command; unset is silent skip. */
36
+ export function decideCloseOutDangling(input: {
37
+ noCheck: boolean;
38
+ needsSpecsChange: boolean;
39
+ danglingCommand: string | null;
40
+ nested: boolean;
41
+ }): CloseOutHarnessDecision {
42
+ if (input.noCheck) return { kind: 'skip', announce: false };
43
+ if (!input.needsSpecsChange) return { kind: 'skip', announce: false };
44
+ const command = input.danglingCommand?.trim() ?? '';
45
+ if (command === '') return { kind: 'skip', announce: false };
46
+ if (input.nested) {
47
+ return { kind: 'abort', message: 'spec check skipped: nested invocation' };
48
+ }
49
+ return { kind: 'run', command };
50
+ }
@@ -68,8 +68,6 @@ export function stageFor(
68
68
  hasTasks: boolean,
69
69
  hasBinding: boolean,
70
70
  ): ChangeSummary['stage'] {
71
- // Monotonic predecessor parity (r34): design.md gates designed, tasks.md only
72
- // upgrades on top of design, binding only upgrades the complete set.
73
71
  if (hasDesign && hasTasks && hasBinding) return 'full';
74
72
  if (hasDesign && hasTasks) return 'planned';
75
73
  if (hasDesign) return 'designed';
@@ -116,7 +114,6 @@ export function collectChanges(
116
114
  ? countTasks(io.readText(`${dir}/tasks.md`))
117
115
  : { completed: 0, total: 0 };
118
116
 
119
- // lastModified = newest mtime across the change dir
120
117
  let latest = io.mtimeMs(proposal);
121
118
  for (const f of [hasDesign ? `${dir}/design.md` : null, hasTasks ? `${dir}/tasks.md` : null]) {
122
119
  if (f) latest = Math.max(latest, io.mtimeMs(f));
@@ -136,8 +133,6 @@ export function collectChanges(
136
133
  idleDays,
137
134
  });
138
135
  };
139
- // r58: recursive, depth-limited proposal discovery (predecessor --max-scan-depth parity)
140
136
  walkActiveChangeDirs(io, changesDir, readChangeDir, { maxScanDepth: opts.maxScanDepth });
141
- // predecessor lists newest-first
142
137
  return out.toSorted((a, b) => b.lastModified.getTime() - a.lastModified.getTime());
143
138
  }
@@ -85,9 +85,6 @@ export const DEFAULT_SPECS_PREFIX = 'llmanspec/specs/';
85
85
  * disagree about which `llmanspec/` tree a change belongs to.
86
86
  */
87
87
  export function instanceDirRelOf(specsPrefix: string): string {
88
- // `\/?` eats the separator too, so the round-trip
89
- // instanceDirRelOf(specsPrefixOfInstance(rel)) === rel holds exactly
90
- // ('a/b/llmanspec/specs/' → 'a/b', not 'a/b/').
91
88
  return specsPrefix.replace(/\/?llmanspec\/specs\/$/u, '');
92
89
  }
93
90
 
@@ -106,14 +103,25 @@ export function specsLanded(
106
103
  return touched.split('\n').some((line) => line.startsWith(specsPrefix));
107
104
  }
108
105
 
106
+ /**
107
+ * YAML types a digit-only scalar (e.g. a short commit SHA) as a number; a
108
+ * binding key is textual. Accept finite number scalars spelled back as
109
+ * decimals; booleans/null stay unbound.
110
+ */
111
+ function scalarText(value: unknown): string | null {
112
+ if (typeof value === 'string') return value;
113
+ if (typeof value === 'number' && Number.isFinite(value)) return String(value);
114
+ return null;
115
+ }
116
+
109
117
  export function readBinding(proposal: string): ChangeBinding | null {
110
118
  const { frontmatter } = splitFrontmatter(proposal);
111
119
  if (frontmatter === null) return null;
112
120
  const doc = parseDocument(frontmatter);
113
- const branch = doc.get('branch');
114
- const baseBranch = doc.get('base_branch');
115
- const baseSha = doc.get('base_sha');
116
- if (typeof branch !== 'string' || typeof baseBranch !== 'string' || typeof baseSha !== 'string') {
121
+ const branch = scalarText(doc.get('branch'));
122
+ const baseBranch = scalarText(doc.get('base_branch'));
123
+ const baseSha = scalarText(doc.get('base_sha'));
124
+ if (branch === null || baseBranch === null || baseSha === null) {
117
125
  return null;
118
126
  }
119
127
  return { branch, baseBranch, baseSha };
package/src/change/id.ts CHANGED
@@ -33,8 +33,6 @@ export function deriveChangeId(description: string): string {
33
33
  prevDash = true;
34
34
  }
35
35
  } else {
36
- // Punctuation / CJK etc.: drop (CJK intentionally dropped to keep ids
37
- // ASCII-friendly); a dropped char at a word boundary yields a `-`.
38
36
  if (!prevDash) {
39
37
  id += '-';
40
38
  prevDash = true;