@llman-sdd/core 0.11.0 → 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.
- package/package.json +6 -3
- package/src/archive/freeze.ts +0 -13
- package/src/archive/frozenCard.ts +1 -10
- package/src/archive/ignoreChain.ts +2 -6
- package/src/archive/sevenzip.ts +0 -1
- package/src/change/closeOutHarness.ts +17 -0
- package/src/change/collect.ts +0 -5
- package/src/change/frontmatter.ts +15 -7
- package/src/change/id.ts +0 -2
- package/src/change/lifecycle.ts +1 -38
- package/src/config/changeId.ts +0 -2
- package/src/config/load.ts +0 -4
- package/src/config/schema.ts +24 -0
- package/src/git/spawnGit.ts +0 -3
- package/src/hints/jitHints.ts +82 -0
- package/src/index.ts +455 -3
- package/src/init/defaultConfig.ts +2 -0
- package/src/init/init.ts +61 -20
- package/src/init/uncommentConfig.ts +909 -0
- package/src/locale.ts +0 -2
- package/src/project/migrateNotes.ts +0 -9
- package/src/project/migrations.ts +70 -0
- package/src/report/graph/analysis.ts +0 -4
- package/src/report/graph/nodes.ts +0 -6
- package/src/report/show.ts +7 -23
- package/src/report/specHelpers.ts +10 -14
- package/src/review/review.ts +0 -12
- package/src/spec/assignSpecIds.ts +0 -3
- package/src/spec/authoring.ts +14 -26
- package/src/spec/ir.ts +14 -5
- package/src/spec/keywords.ts +0 -2
- package/src/spec/machineKey.ts +49 -0
- package/src/spec/migrateNative.ts +4 -18
- package/src/spec/parser.ts +10 -19
- package/src/spec/reqRef.ts +135 -0
- package/src/studio/changeScope.ts +50 -0
- package/src/studio/changeScopeDiff.ts +195 -0
- package/src/studio/contracts.ts +493 -0
- package/src/studio/decisionTree.ts +206 -0
- package/src/studio/deeplink.ts +116 -0
- package/src/studio/demos.ts +167 -0
- package/src/studio/diff.ts +494 -0
- package/src/studio/drift.ts +738 -0
- package/src/studio/extract.ts +360 -0
- package/src/studio/featureSync.ts +592 -0
- package/src/studio/forest.ts +570 -0
- package/src/studio/index.ts +32 -0
- package/src/studio/model.ts +254 -0
- package/src/studio/revisions.ts +476 -0
- package/src/studio/search.ts +337 -0
- package/src/studio/store.ts +811 -0
- package/src/studio/sync.ts +912 -0
- package/src/studio/textfold.ts +72 -0
- package/src/studio/time.ts +107 -0
- package/src/studio/validate.ts +363 -0
- package/src/templates/embedded.ts +4 -6
- package/src/templates/engine.ts +1 -1
- package/src/templates/skills.ts +71 -49
- package/src/theorems/guard.ts +52 -0
- package/src/theorems/index.ts +56 -0
- package/src/theorems/migrate.ts +133 -0
- package/src/theorems/schema.ts +67 -0
- package/src/theorems/scope.ts +68 -0
- package/src/theorems/serialize.ts +60 -0
- package/src/theorems/transactionMachine.ts +247 -0
- package/src/theorems/validate.ts +141 -0
- package/src/util/nextNumber.ts +0 -2
- package/src/validation/changeCheck.ts +0 -24
- package/src/validation/flowAndNesting.ts +434 -0
- package/src/validation/harness.ts +108 -65
- package/src/validation/validate.ts +26 -12
- package/src/validation/xstateTransitions.ts +483 -184
- package/templates/zh-Hans/llmanspec-agents-stub.md +17 -2
- package/templates/zh-Hans/skills/llman-sdd-autopilot/SKILL.md +34 -0
- package/templates/zh-Hans/skills/llman-sdd-change/SKILL.md +44 -0
- package/templates/zh-Hans/skills/llman-sdd-change/playbooks/archive.md +15 -0
- package/templates/zh-Hans/skills/llman-sdd-change/playbooks/draft.md +9 -0
- package/templates/zh-Hans/skills/llman-sdd-review/SKILL.md +71 -0
- package/templates/zh-Hans/skills/llman-sdd-specs/SKILL.md +70 -0
- package/templates/zh-Hans/skills/llman-sdd-specs/playbooks/compact.md +12 -0
- package/templates/zh-Hans/skills/llman-sdd-specs/playbooks/doctor.md +26 -0
- package/templates/zh-Hans/skills/llman-sdd-specs/references/graph-dsl.md +33 -0
- package/templates/zh-Hans/skills/llman-sdd-studio/SKILL.md +33 -0
- package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/collab.md +20 -0
- package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/drift.md +52 -0
- package/templates/zh-Hans/skills/llman-sdd-studio/playbooks/onboard.md +33 -0
- package/templates/zh-Hans/units/skills/cli-footer.md +2 -2
- package/templates/zh-Hans/agents-root-stub.md +0 -9
- package/templates/zh-Hans/skills/llman-sdd-apply-cycle.md +0 -69
- package/templates/zh-Hans/skills/llman-sdd-apply.md +0 -116
- package/templates/zh-Hans/skills/llman-sdd-arch-review.md +0 -58
- package/templates/zh-Hans/skills/llman-sdd-archive.md +0 -78
- package/templates/zh-Hans/skills/llman-sdd-continue.md +0 -34
- package/templates/zh-Hans/skills/llman-sdd-draft.md +0 -53
- package/templates/zh-Hans/skills/llman-sdd-explore.md +0 -63
- package/templates/zh-Hans/skills/llman-sdd-ff.md +0 -34
- package/templates/zh-Hans/skills/llman-sdd-graph.md +0 -56
- package/templates/zh-Hans/skills/llman-sdd-propose.md +0 -106
- package/templates/zh-Hans/skills/llman-sdd-quick.md +0 -40
- package/templates/zh-Hans/skills/llman-sdd-research.md +0 -35
- package/templates/zh-Hans/skills/llman-sdd-specs-compact.md +0 -42
- package/templates/zh-Hans/skills/llman-sdd-validate.md +0 -28
- package/templates/zh-Hans/skills/llman-sdd-verify.md +0 -77
- package/templates/zh-Hans/skills/llman-sdd-wayfinder.md +0 -83
- package/templates/zh-Hans/units/skills/ethics-governance.md +0 -6
- package/templates/zh-Hans/units/skills/git-native-flow.md +0 -56
- package/templates/zh-Hans/units/skills/human-readable-summary.md +0 -9
- package/templates/zh-Hans/units/skills/stage-guard.md +0 -17
- package/templates/zh-Hans/units/skills/structured-protocol.md +0 -19
- package/templates/zh-Hans/units/skills/validation-hints.md +0 -20
- package/templates/zh-Hans/units/skills/version-drift.md +0 -3
- 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.
|
|
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",
|
|
@@ -29,9 +30,11 @@
|
|
|
29
30
|
"@cucumber/messages": "^35.0.0",
|
|
30
31
|
"@statelyai/graph": "^2.6.0",
|
|
31
32
|
"@toon-format/toon": "^4.4.0",
|
|
33
|
+
"diff": "^8.0.3",
|
|
32
34
|
"ignore": "^7.0.16",
|
|
33
35
|
"nunjucks": "^3.2.4",
|
|
34
|
-
"
|
|
36
|
+
"smol-toml": "^1.9.1",
|
|
37
|
+
"xstate": "6.0.0-beta.7",
|
|
35
38
|
"yaml": "^2.9.1",
|
|
36
39
|
"zod": "^4.6.7"
|
|
37
40
|
},
|
package/src/archive/freeze.ts
CHANGED
|
@@ -98,13 +98,9 @@ export async function runFreeze(
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Card = authoritative record that bodies are in the cold backup. Write
|
|
102
|
-
// cards first; on `7z add` failure roll them back and keep the original dirs.
|
|
103
101
|
const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
|
|
104
102
|
const archiveBase = join(rootAbs, ARCHIVE_DIR_REL);
|
|
105
103
|
|
|
106
|
-
// r120: layered gitignore filtering runs before any mutation — user-file
|
|
107
|
-
// existence errors and the zero-files guard must leave the tree untouched.
|
|
108
104
|
const packed: string[] = [];
|
|
109
105
|
let excludedTotal = 0;
|
|
110
106
|
for (const c of candidates) {
|
|
@@ -125,7 +121,6 @@ export async function runFreeze(
|
|
|
125
121
|
const proposalRel = `${ARCHIVE_DIR_REL}/${c}/proposal.md`;
|
|
126
122
|
const proposal = io.exists(proposalRel) ? io.readText(proposalRel) : '';
|
|
127
123
|
const frontmatter = extractFrontmatter(proposal) ?? '';
|
|
128
|
-
// r24: frontmatter `title` wins when non-empty; H1 is the legacy fallback.
|
|
129
124
|
cards.push({
|
|
130
125
|
datedId: c,
|
|
131
126
|
source: composeFrozenCard(
|
|
@@ -173,10 +168,7 @@ export async function runList(io: FreezeIo, sz: SevenZipPort, rootAbs: string):
|
|
|
173
168
|
}
|
|
174
169
|
const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
|
|
175
170
|
if (io.exists(archiveAbs)) {
|
|
176
|
-
// Legacy/unexpected entries present only inside the 7z (no card on disk).
|
|
177
171
|
const entries = (await sz.listEntries(archiveAbs)).map((n) => n.replace(/\/$/u, ''));
|
|
178
|
-
// 7z entry names always use '/' per archive contract — POSIX by contract, not
|
|
179
|
-
// platform-native; do not switch to node:path here.
|
|
180
172
|
const top = (n: string): string => n.split('/')[0] ?? n;
|
|
181
173
|
for (const e of entries.map(top).filter((n) => DATED_RE.test(n))) {
|
|
182
174
|
if (!names.has(e)) names.add(e);
|
|
@@ -242,7 +234,6 @@ export async function runThaw(
|
|
|
242
234
|
names: string[],
|
|
243
235
|
opts: { dest?: string } = {},
|
|
244
236
|
): Promise<ThawResult> {
|
|
245
|
-
// r56: restore target override (created on demand); default = changes/archive
|
|
246
237
|
const destRel = opts.dest ?? ARCHIVE_DIR_REL;
|
|
247
238
|
const archiveAbs = join(rootAbs, ARCHIVE_DIR_REL, FREEZE_ARCHIVE_NAME);
|
|
248
239
|
if (!io.exists(`${ARCHIVE_DIR_REL}/${FREEZE_ARCHIVE_NAME}`)) {
|
|
@@ -256,8 +247,6 @@ export async function runThaw(
|
|
|
256
247
|
const available = new Set(
|
|
257
248
|
io.exists(tmpRel) ? io.listDir(tmpRel).filter((n) => DATED_RE.test(n)) : [],
|
|
258
249
|
);
|
|
259
|
-
// Cards on disk also count as available (they are the authoritative record
|
|
260
|
-
// that bodies are in the cold backup, even before any extraction listing).
|
|
261
250
|
for (const name of io.exists(ARCHIVE_DIR_REL) ? io.listDir(ARCHIVE_DIR_REL) : []) {
|
|
262
251
|
if (isFrozenCard(name) && frozenCardIdOf(name) !== null) {
|
|
263
252
|
available.add(name.slice(0, -FROZEN_CARD_EXT.length));
|
|
@@ -279,8 +268,6 @@ export async function runThaw(
|
|
|
279
268
|
if (io.exists(cardRel)) io.remove(cardRel);
|
|
280
269
|
restored.push(name);
|
|
281
270
|
}
|
|
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
271
|
const unfenced = unfenceLegacyCards(io, ARCHIVE_DIR_REL);
|
|
285
272
|
const lines = [`Thawed ${restored.length} selected archived changes to ${destRel}`];
|
|
286
273
|
if (unfenced > 0) lines.push(`Unfenced ${unfenced} legacy card(s)`);
|
|
@@ -70,7 +70,6 @@ export function extractDependsOn(frontmatter: string): string {
|
|
|
70
70
|
const lines = frontmatter.split('\n');
|
|
71
71
|
const flowIdx = lines.findIndex((l) => /^depends_on\s*:\s*\[/u.test(l));
|
|
72
72
|
if (flowIdx !== -1) {
|
|
73
|
-
// Single-line flow `depends_on: [a, b]` (may span lines).
|
|
74
73
|
let acc = (lines[flowIdx] ?? '').replace(/^depends_on\s*:/u, '').trim();
|
|
75
74
|
let j = flowIdx;
|
|
76
75
|
while (!/\]\s*$/u.test(acc) && j < lines.length - 1) {
|
|
@@ -82,17 +81,14 @@ export function extractDependsOn(frontmatter: string): string {
|
|
|
82
81
|
}
|
|
83
82
|
const blockIdx = lines.findIndex((l) => /^depends_on\s*:\s*$/u.test(l));
|
|
84
83
|
if (blockIdx !== -1) {
|
|
85
|
-
// Block list `- a` lines.
|
|
86
84
|
const items: string[] = [];
|
|
87
85
|
for (const l of lines.slice(blockIdx + 1)) {
|
|
88
86
|
const m = l.match(/^\s*-\s+(\S+)/u);
|
|
89
87
|
if (m?.[1]) items.push(m[1].replaceAll(/['"]/gu, ''));
|
|
90
|
-
// multi-line flow handled below
|
|
91
88
|
else if (/^\s*\[/u.test(l)) break;
|
|
92
89
|
else if (l.trim() !== '') break;
|
|
93
90
|
}
|
|
94
91
|
if (items.length > 0) return toFlow(items);
|
|
95
|
-
// Multi-line flow `[\n a,\n b\n ]`.
|
|
96
92
|
let acc = lines
|
|
97
93
|
.slice(blockIdx + 1)
|
|
98
94
|
.join(' ')
|
|
@@ -126,14 +122,12 @@ export function composeFrozenCard(title: string, frontmatter: string): string {
|
|
|
126
122
|
*/
|
|
127
123
|
export function unfenceFrozenCard(source: string): string | null {
|
|
128
124
|
const lines = source.split('\n');
|
|
129
|
-
// Trailing newline yields a final '' element; strip it so line indexes point
|
|
130
|
-
// at real content.
|
|
131
125
|
while (lines.length > 0 && (lines[lines.length - 1] ?? '').trim() === '') lines.pop();
|
|
132
126
|
if (lines.length < 3) return null;
|
|
133
127
|
const isFence = (line: string | undefined): boolean =>
|
|
134
128
|
(line ?? '').replace(/\s+$/u, '') === '---';
|
|
135
129
|
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
|
|
130
|
+
// Normalize to LF while stripping: a lone trailing \r is not a YAML line ~keep
|
|
137
131
|
// break, so a CRLF card would otherwise fail the single-document parse.
|
|
138
132
|
const body = lines
|
|
139
133
|
.slice(1, -1)
|
|
@@ -154,9 +148,6 @@ export function unfenceFrozenCard(source: string): string | null {
|
|
|
154
148
|
if (keys.length === 0) return null;
|
|
155
149
|
const allowed = new Set(['title', 'depends_on']);
|
|
156
150
|
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
151
|
const title = record['title'];
|
|
161
152
|
if (title !== undefined && typeof title !== 'string') return null;
|
|
162
153
|
const deps = record['depends_on'];
|
|
@@ -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;
|
|
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;
|
|
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)) {
|
package/src/archive/sevenzip.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/change/collect.ts
CHANGED
|
@@ -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 (
|
|
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;
|
package/src/change/lifecycle.ts
CHANGED
|
@@ -37,8 +37,6 @@ export type FsIo = Pick<FsPort, 'exists' | 'readText' | 'writeText' | 'rename' |
|
|
|
37
37
|
|
|
38
38
|
export class LifecycleError extends Error {}
|
|
39
39
|
|
|
40
|
-
// r74: single git-gate message family shared by start/attach/finalize/archive
|
|
41
|
-
// (stable substrings for matching; no internal requirement ids in output).
|
|
42
40
|
const detachedHead = (cmd: string): string =>
|
|
43
41
|
`\`${cmd}\` refuses a detached HEAD; check out a branch first`;
|
|
44
42
|
const notOnBoundBranch = (cmd: string, bound: string, current: string | null): string =>
|
|
@@ -64,8 +62,6 @@ export function newChange(
|
|
|
64
62
|
`change proposal already exists: ./${path} (pass --force to overwrite)`,
|
|
65
63
|
);
|
|
66
64
|
}
|
|
67
|
-
// r99: skeleton carries a non-empty title placeholder so a fresh draft
|
|
68
|
-
// passes the title gate; agents rewrite it when filling the proposal.
|
|
69
65
|
io.writeText(path, `---\ndepends_on: []\ntitle: TODO\n---\n\n${DRAFT_PROPOSAL_TEMPLATE}`);
|
|
70
66
|
return { id, path };
|
|
71
67
|
}
|
|
@@ -124,7 +120,7 @@ function resolveWorktreePath(
|
|
|
124
120
|
naming: 'id' | 'hash' | undefined,
|
|
125
121
|
): string {
|
|
126
122
|
const toplevel = git.run(['rev-parse', '--show-toplevel']);
|
|
127
|
-
// git rev-parse --show-toplevel emits forward-slash paths even on win32
|
|
123
|
+
// git rev-parse --show-toplevel emits forward-slash paths even on win32 ~keep
|
|
128
124
|
// (git-for-Windows normalizes) — POSIX by contract; keep '/'-splitting.
|
|
129
125
|
const cut = toplevel.lastIndexOf('/');
|
|
130
126
|
const basename = toplevel.slice(cut + 1);
|
|
@@ -208,8 +204,6 @@ export function startChange(
|
|
|
208
204
|
assertLocalBase(git, opts.base, branch, 'new');
|
|
209
205
|
}
|
|
210
206
|
|
|
211
|
-
// A non-default checkout binds the current branch. The default branch
|
|
212
|
-
// still creates sdd/<id>. --worktree always creates a branch elsewhere.
|
|
213
207
|
if (!opts.worktree && here !== defaultBranch(git)) {
|
|
214
208
|
const bound = attachChange(git, io, id, { force: opts.force, base: opts.base });
|
|
215
209
|
return {
|
|
@@ -220,8 +214,6 @@ export function startChange(
|
|
|
220
214
|
};
|
|
221
215
|
}
|
|
222
216
|
|
|
223
|
-
// r68 fork-source resolution: --base explicit > current branch (worktree
|
|
224
|
-
// mode records the actual source) > default branch.
|
|
225
217
|
let baseBranch: string;
|
|
226
218
|
let baseSource: StartResult['baseSource'];
|
|
227
219
|
if (opts.base !== undefined) {
|
|
@@ -245,14 +237,6 @@ export function startChange(
|
|
|
245
237
|
throw new LifecycleError(`worktree path already exists: ${worktreePath}`);
|
|
246
238
|
}
|
|
247
239
|
git.run(['worktree', 'add', '-b', branch, worktreePath]);
|
|
248
|
-
// r68: the binding lands in the NEW worktree's proposal — the initiating
|
|
249
|
-
// checkout stays byte-identical (zero writes through the original io).
|
|
250
|
-
// The clean-tree gate guaranteed the proposal is committed at HEAD, so it
|
|
251
|
-
// is present in the fresh worktree; a missing one rolls everything back.
|
|
252
|
-
// r119: the io is anchored at the INSTANCE root; redirecting into the new
|
|
253
|
-
// worktree must re-attach that offset relative to its toplevel (a sub-root
|
|
254
|
-
// change's proposal lives at <wt>/<rel>/llmanspec/changes/<id>), same
|
|
255
|
-
// shape as the mergeRenameCommit holder redirect.
|
|
256
240
|
const instanceDirRel = opts.instanceDirRel ?? '';
|
|
257
241
|
const wtRoot = instanceDirRel === '' ? worktreePath : `${worktreePath}/${instanceDirRel}`;
|
|
258
242
|
const wtIo = ioAt(io, wtRoot);
|
|
@@ -296,9 +280,6 @@ export function attachChange(
|
|
|
296
280
|
if (opts.base !== undefined) {
|
|
297
281
|
assertLocalBase(git, opts.base, branch, 'bound');
|
|
298
282
|
}
|
|
299
|
-
// r95 fork-source resolution: --base explicit > probeForkSource
|
|
300
|
-
// (branch.<name>.base > local upstream) > default branch. No signal means
|
|
301
|
-
// status quo (issue #7 compatibility: "无法推导维持现状").
|
|
302
283
|
const fork =
|
|
303
284
|
opts.base !== undefined
|
|
304
285
|
? { branch: opts.base, source: 'flag' as const }
|
|
@@ -360,8 +341,6 @@ export function closeOutGate(change: {
|
|
|
360
341
|
}): { ok: boolean; reason: string | null } {
|
|
361
342
|
const { git, io, id, binding } = change;
|
|
362
343
|
const specsPrefix = change.specsPrefix ?? DEFAULT_SPECS_PREFIX;
|
|
363
|
-
// task gate first: the unchecked list is the most actionable feedback and
|
|
364
|
-
// keeps the predecessor "blocked by unchecked tasks" surface primary.
|
|
365
344
|
const tasksPath = `${CHANGES_DIR}/${id}/tasks.md`;
|
|
366
345
|
const gate = archiveTaskGate(io.exists(tasksPath) ? io.readText(tasksPath) : null);
|
|
367
346
|
if (gate.blocked) {
|
|
@@ -412,12 +391,10 @@ export function finalizeChange(
|
|
|
412
391
|
if (binding === null) {
|
|
413
392
|
throw new LifecycleError(`change \`${id}\` has no branch binding — run \`change start\` first`);
|
|
414
393
|
}
|
|
415
|
-
// T34 close-out gate before any write: specs-landed verdict + task gate.
|
|
416
394
|
const closeOut = closeOutGate({ git, io, id, binding, specsPrefix: opts.specsPrefix });
|
|
417
395
|
if (!closeOut.ok) {
|
|
418
396
|
throw new LifecycleError(closeOut.reason as string);
|
|
419
397
|
}
|
|
420
|
-
// r40 unchecked-task detail lines (D9 close-out pseudo-task hint).
|
|
421
398
|
const tasksPath = `${CHANGES_DIR}/${id}/tasks.md`;
|
|
422
399
|
const gate = archiveTaskGate(io.exists(tasksPath) ? io.readText(tasksPath) : null);
|
|
423
400
|
if (gate.blocked) {
|
|
@@ -434,8 +411,6 @@ export function finalizeChange(
|
|
|
434
411
|
].join('\n'),
|
|
435
412
|
);
|
|
436
413
|
}
|
|
437
|
-
// r15 (predecessor r94): finalize runs on the bound branch — any other branch must
|
|
438
|
-
// fail before any write (no switch, no merge, no rename).
|
|
439
414
|
const current = currentBranch(git);
|
|
440
415
|
if (current !== binding.branch) {
|
|
441
416
|
throw new LifecycleError(notOnBoundBranch('change archive', binding.branch, current));
|
|
@@ -497,9 +472,6 @@ function mergeRenameCommit(
|
|
|
497
472
|
instanceDirRel = '',
|
|
498
473
|
): FinalizeResult {
|
|
499
474
|
const warnings: string[] = [];
|
|
500
|
-
// r69: when the target branch is checked out in another worktree, `git
|
|
501
|
-
// switch` there would fail outright — run every write (switch / merge /
|
|
502
|
-
// rename / commit) inside the holding worktree instead.
|
|
503
475
|
const here = git.runOpt(['rev-parse', '--show-toplevel']);
|
|
504
476
|
const holder = holderOfWorktree(git, target);
|
|
505
477
|
let execGit = git;
|
|
@@ -518,18 +490,9 @@ function mergeRenameCommit(
|
|
|
518
490
|
);
|
|
519
491
|
}
|
|
520
492
|
execGit = gitAt(git, holder);
|
|
521
|
-
// r119/W1: the io is anchored at the INSTANCE root; redirecting onto the
|
|
522
|
-
// holding worktree must re-attach the instance offset relative to its
|
|
523
|
-
// toplevel, or a sub-root rename would target <holder>/llmanspec (the
|
|
524
|
-
// repo-root instance) and fail ENOENT mid-close-out (merge already run).
|
|
525
493
|
execIo = ioAt(io, instanceDirRel === '' ? holder : `${holder}/${instanceDirRel}`);
|
|
526
494
|
executedIn = holder;
|
|
527
495
|
}
|
|
528
|
-
// r96: in-place close-out — merging a branch into itself is always a no-op
|
|
529
|
-
// ("Already up to date."), so skip the merge and say so instead of running a
|
|
530
|
-
// silent self-merge. The switch still runs (a no-op when already there) so
|
|
531
|
-
// escape hatches like `archive --force` from a foreign branch land the
|
|
532
|
-
// rename and close-out commit on the bound branch, not the current one.
|
|
533
496
|
execGit.run(['switch', target]);
|
|
534
497
|
if (target === featureBranch) {
|
|
535
498
|
warnings.push('in-place close-out: merge target is the bound branch itself; merge skipped');
|
package/src/config/changeId.ts
CHANGED
|
@@ -37,8 +37,6 @@ export interface ChangeIdVars {
|
|
|
37
37
|
* autoescape:false — this file no longer imports the adapter directly.
|
|
38
38
|
*/
|
|
39
39
|
export function renderChangeIdTemplate(template: string, vars: ChangeIdVars): string {
|
|
40
|
-
// Named pre-check (predecessor parity): referencing an unprovided variable errors with
|
|
41
|
-
// the variable name and the preset list, instead of a generic render error.
|
|
42
40
|
const provided = new Set(
|
|
43
41
|
Object.keys(vars).filter((k) => vars[k as keyof ChangeIdVars] !== undefined),
|
|
44
42
|
);
|
package/src/config/load.ts
CHANGED
|
@@ -120,16 +120,12 @@ export function loadConfigDetail(source: string): {
|
|
|
120
120
|
});
|
|
121
121
|
throw new ConfigValidationError(issues);
|
|
122
122
|
}
|
|
123
|
-
// r59: compile change_id.pattern at load time so EVERY config-reading
|
|
124
123
|
// command path (archive/skeleton/review included) fails fast on an invalid
|
|
125
|
-
// regex instead of silently passing it through.
|
|
126
124
|
const pattern = result.data.change_id?.pattern;
|
|
127
125
|
if (pattern !== undefined && pattern !== null && pattern !== '') {
|
|
128
126
|
try {
|
|
129
127
|
compileChangeIdPattern(pattern);
|
|
130
128
|
} catch (error) {
|
|
131
|
-
// ChangeIdError message already carries the change_id.pattern path and
|
|
132
|
-
// the regex engine's original error.
|
|
133
129
|
throw new ConfigValidationError([(error as Error).message]);
|
|
134
130
|
}
|
|
135
131
|
}
|
package/src/config/schema.ts
CHANGED
|
@@ -22,6 +22,12 @@ export const specsSchema = z.object({
|
|
|
22
22
|
'Spec verification command executed by validate for spec targets (opt-in via --check; default skips). Placeholders: {feature_path}, {feature_dir}, {feature_name}; without placeholders it runs once per validate invocation (batch-once). Legacy `bdd.run_command` is elevated onto this key at load time.',
|
|
23
23
|
),
|
|
24
24
|
verify_prompt: z.string().nullish().describe('Extra prompt text injected during verify phase.'),
|
|
25
|
+
check_dangling_bdd_command: z
|
|
26
|
+
.string()
|
|
27
|
+
.nullish()
|
|
28
|
+
.describe(
|
|
29
|
+
'Optional project-owned dangling-BDD check (unused step/scenario glue). Same placeholders and batch-once as check_command. Executed by validate --check and change archive when set; unset skips with no warning. Not derived from framework.',
|
|
30
|
+
),
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
export const archiveSchema = z.object({
|
|
@@ -65,6 +71,21 @@ export const changeIdSchema = z.object({
|
|
|
65
71
|
.describe('Template rendered by `change new --from` with preset vars.'),
|
|
66
72
|
});
|
|
67
73
|
|
|
74
|
+
export const reviewSchema = z.object({
|
|
75
|
+
handoff_mode: z
|
|
76
|
+
.enum(['ask', 'inline', 'file'])
|
|
77
|
+
.default('ask')
|
|
78
|
+
.describe(
|
|
79
|
+
'Independent review prompt handoff mode when subagent dispatch is unavailable: "ask" (default), "inline", or "file".',
|
|
80
|
+
),
|
|
81
|
+
handoff_file: z
|
|
82
|
+
.string()
|
|
83
|
+
.nullish()
|
|
84
|
+
.describe(
|
|
85
|
+
'Target file path written when review.handoff_mode is "file". Default: ".llman-sdd/review-handoff.md".',
|
|
86
|
+
),
|
|
87
|
+
});
|
|
88
|
+
|
|
68
89
|
export const sddConfigSchema = z.object({
|
|
69
90
|
schema: z.literal('spec-driven').describe('Schema identifier. Must be "spec-driven".'),
|
|
70
91
|
locale: z.string().default(DEFAULT_LOCALE).describe('Locale used for SDD templates and skills.'),
|
|
@@ -82,6 +103,9 @@ export const sddConfigSchema = z.object({
|
|
|
82
103
|
change_id: changeIdSchema
|
|
83
104
|
.nullish()
|
|
84
105
|
.describe('Optional machine-readable change id naming convention.'),
|
|
106
|
+
review: reviewSchema
|
|
107
|
+
.nullish()
|
|
108
|
+
.describe('Independent review handoff preferences for single-session environments.'),
|
|
85
109
|
});
|
|
86
110
|
|
|
87
111
|
export type SddConfig = z.output<typeof sddConfigSchema>;
|
package/src/git/spawnGit.ts
CHANGED
|
@@ -66,8 +66,6 @@ export function localBranchExists(git: GitLike, name: string): boolean {
|
|
|
66
66
|
* (r16 resolution order, not a tie-breaker) — because the user explicitly
|
|
67
67
|
* configured it; anything else falls through to the chain untouched.
|
|
68
68
|
*/
|
|
69
|
-
// Local-only default-branch probe (no origin consultation) lives in callers that
|
|
70
|
-
// need it; this resolver honors explicit user config first (r16 order).
|
|
71
69
|
export function defaultBranch(git: GitLike): string {
|
|
72
70
|
const preferred = git.runOpt(['config', '--get', 'init.defaultBranch']);
|
|
73
71
|
if (preferred !== null && preferred !== '' && localBranchExists(git, preferred)) {
|
|
@@ -163,7 +161,6 @@ export function worktreeList(git: GitLike): WorktreeEntry[] {
|
|
|
163
161
|
} else if (line.startsWith('prunable')) {
|
|
164
162
|
current.prunable = true;
|
|
165
163
|
}
|
|
166
|
-
// `detached` / `bare` marker lines leave branch null on purpose.
|
|
167
164
|
}
|
|
168
165
|
if (current !== null) entries.push(current);
|
|
169
166
|
return entries;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure event-driven contextual CLI hints (Just-in-Time hints, cli r203).
|
|
3
|
+
* Zero IO: core computes single-line next/fix hints and machine-mode gating;
|
|
4
|
+
* CLI renders them to stderr in non-JSON modes so stdout remains pure.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type CliHintKind = 'next' | 'fix';
|
|
8
|
+
|
|
9
|
+
export interface CliHint {
|
|
10
|
+
readonly kind: CliHintKind;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type HintOutputMode = 'toon' | 'json' | 'compact-json' | 'human';
|
|
15
|
+
|
|
16
|
+
/** JSON and compact-json modes must stay 100% pure machine payloads. */
|
|
17
|
+
export function shouldEmitCliHint(mode: HintOutputMode): boolean {
|
|
18
|
+
return mode !== 'json' && mode !== 'compact-json';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function formatCliHint(hint: CliHint): string {
|
|
22
|
+
return `${hint.kind}: ${hint.text}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function hintForChangeNew(id: string): CliHint {
|
|
26
|
+
return {
|
|
27
|
+
kind: 'next',
|
|
28
|
+
text: `run \`llman-sdd change start ${id}\` to bind a feature branch (design.md and tasks.md are optional)`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function hintForChangeStart(id: string): CliHint {
|
|
33
|
+
return {
|
|
34
|
+
kind: 'next',
|
|
35
|
+
text: `edit llmanspec/specs/** on this branch and commit (or set needs_specs_change: false); run \`llman-sdd validate ${id} --check --strict\` when ready`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function hintForValidateCheckPass(handoffMode?: 'ask' | 'inline' | 'file'): CliHint {
|
|
40
|
+
const mode = handoffMode ?? 'ask';
|
|
41
|
+
return {
|
|
42
|
+
kind: 'next',
|
|
43
|
+
text: `for non-trivial changes, run independent read-only review via llman-sdd-review (single-session review.handoff_mode: ${mode})`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const STUDIO_DIAGNOSTIC_HINTS: Readonly<Record<string, string>> = {
|
|
48
|
+
E1: 'E1: ensure every state/flow table uses valid zh-Hans column headers and non-empty source/target cells',
|
|
49
|
+
E2: 'E2: remove duplicate transition edges or add a distinct condition/branch label',
|
|
50
|
+
E3: 'E3: fix disconnected or unreachable states/steps so all nodes connect from the initial entry',
|
|
51
|
+
E4: 'E4: ensure every terminal path reaches an explicit end state or `[结束:X]` node',
|
|
52
|
+
F3: 'F3: ensure `@flow` outlines have 0 GWT steps and use `当前步骤 | 分支 | 下一步` columns',
|
|
53
|
+
N6: 'N6: align subgraph `[结束:X]` terminal labels with the parent reference node outgoing branch names',
|
|
54
|
+
A1: 'A1: a leaf node without a 引用 pointer must carry a non-empty 人类说明 — fill it in, or add `@req:<id>[#<场景名>]` to expand a child machine',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function hintForStudioDiagnostic(code: string): CliHint | null {
|
|
58
|
+
const text = STUDIO_DIAGNOSTIC_HINTS[code];
|
|
59
|
+
return text === undefined ? null : { kind: 'fix', text };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function hintForValidationIssue(message: string): CliHint | null {
|
|
63
|
+
if (message.includes('# purpose:')) {
|
|
64
|
+
return {
|
|
65
|
+
kind: 'fix',
|
|
66
|
+
text: 'add a `# purpose: <one-line summary>` header comment at the top of the .feature file',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (message.includes('Why section') || message.includes('What Changes section')) {
|
|
70
|
+
return {
|
|
71
|
+
kind: 'fix',
|
|
72
|
+
text: 'add both `## Why` and `## What Changes` headings to proposal.md',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (message.includes('unchecked task')) {
|
|
76
|
+
return {
|
|
77
|
+
kind: 'fix',
|
|
78
|
+
text: 'complete or check off remaining tasks in tasks.md (or remove close-out pseudo-tasks)',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|