@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.
- package/package.json +11 -8
- package/src/archive/freeze.ts +41 -15
- package/src/archive/frozenCard.ts +57 -9
- 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 +53 -94
- package/src/config/changeId.ts +0 -2
- package/src/config/load.ts +0 -4
- package/src/config/schema.ts +24 -13
- package/src/config/surface.ts +2 -12
- package/src/context/sddState.ts +23 -18
- package/src/git/spawnGit.ts +0 -3
- package/src/hints/jitHints.ts +82 -0
- package/src/index.ts +462 -39
- package/src/init/defaultConfig.ts +4 -13
- package/src/init/init.ts +108 -36
- package/src/init/skillCheck.ts +60 -0
- 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 +151 -9
- 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 +16 -24
- 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 +76 -51
- 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/src/context/indexStore.ts +0 -171
- package/src/context/retrieve.ts +0 -332
- package/src/context/tree.ts +0 -112
- 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 -117
- package/templates/zh-Hans/skills/llman-sdd-arch-review.md +0 -58
- package/templates/zh-Hans/skills/llman-sdd-archive.md +0 -79
- 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 -64
- package/templates/zh-Hans/skills/llman-sdd-ff.md +0 -33
- package/templates/zh-Hans/skills/llman-sdd-graph.md +0 -56
- package/templates/zh-Hans/skills/llman-sdd-propose.md +0 -107
- package/templates/zh-Hans/skills/llman-sdd-quick.md +0 -41
- package/templates/zh-Hans/skills/llman-sdd-research.md +0 -35
- package/templates/zh-Hans/skills/llman-sdd-specs-compact.md +0 -41
- 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/index-fallback.md +0 -1
- 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/src/locale.ts
CHANGED
|
@@ -15,8 +15,6 @@ export function normalizeLocale(value: string): string {
|
|
|
15
15
|
const lower = trimmed.toLowerCase();
|
|
16
16
|
if (lower === 'zh' || lower.startsWith('zh-hans') || lower === 'zh-cn') return DEFAULT_LOCALE;
|
|
17
17
|
if (lower.startsWith('en')) return DEFAULT_LOCALE;
|
|
18
|
-
// Unknown values normalize instead of passing through: with no English pack,
|
|
19
|
-
// an unlisted locale would render nothing at all.
|
|
20
18
|
return DEFAULT_LOCALE;
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
// Collaboration notes for `project migrate` — the predecessor (Rust ≤0.0.78) shipped two
|
|
2
|
-
// one-shot migrations (toon2features / specs-flatten); this tool deliberately ships
|
|
3
|
-
// none (peripheral-commands r35: the command outputs an explanation and never
|
|
4
|
-
// migrates). Porting the implementations was surveyed on 2026-09-23 and
|
|
5
|
-
// declined: specs-flatten fights this repo's directory-style coexistence direction,
|
|
6
|
-
// and toon2features has no confirmed audience. Instead, `--kind <x>` prints
|
|
7
|
-
// the equivalent manual-migration guidance so old command forms get useful
|
|
8
|
-
// stdout instead of an unknown-option error.
|
|
9
|
-
|
|
10
1
|
export const MIGRATE_KINDS = ['toon2features', 'specs-flatten'] as const;
|
|
11
2
|
|
|
12
3
|
export type MigrateKind = (typeof MIGRATE_KINDS)[number];
|
|
@@ -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
|
-
'
|
|
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
|
-
'
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,150 @@ 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
|
+
},
|
|
242
|
+
{
|
|
243
|
+
version: '0.12.0',
|
|
244
|
+
items: [
|
|
245
|
+
{
|
|
246
|
+
title: 'Graph DSL: whitelist English tags, zh-Hans-only columns, and 0-step outlines',
|
|
247
|
+
steps: [
|
|
248
|
+
'Rewrite every graph Examples table under `llmanspec/specs/**`. Put exactly one whitelist tag on the scenario: `@state` (state machine), `@flow` (flowchart), `@nodes` (node attributes), or `@decision_table` (decision table). Untagged tables are no longer extracted.',
|
|
249
|
+
'Use zh-Hans headers only: `@state` → `当前 | 触发 | 目标` (optional `条件 | 动作 | 执行方 | 边类型 | 元信息`); `@flow` → `当前步骤 | 分支 | 下一步` (optional `条件 | 动作 | 执行方 | 边类型 | 元信息 | 验证`); `@nodes` → `节点` plus optional `类型 | 引用 | 执行方 | 人类说明 | 完成标准`. Delete Given/When/Then placeholder steps on dialect outlines.',
|
|
250
|
+
'Remove `@transitions` / `@states` / `@no-transitions` / `@ignore` / `@decision`. Replace `from/event/to/guard`, `初始状态/事件/目标状态/守卫`, `状态/子机/网关`, and remove the legacy `落地锚点` (`bind`) column on `@nodes`. Nest pointer column is `引用` with `@req:rN` or `@req:rN#<scene>`.',
|
|
251
|
+
'Run `llman-sdd spec transitions`, `llman-sdd validate --specs --strict`, and `llman-sdd studio validate --specs`.',
|
|
252
|
+
],
|
|
253
|
+
checks: [
|
|
254
|
+
'No `@transitions`, `@states`, `@no-transitions`, `@ignore`, or `落地锚点` remain under `llmanspec/specs/**`.',
|
|
255
|
+
'`llman-sdd spec transitions` prints `@flow @state @nodes @decision_table` and `当前` / `触发` / `目标`, and does not list `from` as a legal alias.',
|
|
256
|
+
'`llman-sdd validate --specs --strict` and `llman-sdd studio validate --specs` exit 0.',
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
title: '5 orthogonal domain skills and managed `llmanspec/AGENTS.md` block',
|
|
261
|
+
steps: [
|
|
262
|
+
'Run `llman-sdd init --update`. It atomically replaces legacy `llman-sdd-*` skills with the 5 orthogonal hubs (`llman-sdd-specs`, `llman-sdd-studio`, `llman-sdd-change`, `llman-sdd-review`, `llman-sdd-autopilot`), preserves custom non-`llman-sdd-` skills, and refreshes `llmanspec/AGENTS.md`.',
|
|
263
|
+
'Optionally configure `review.handoff_mode` (`ask` default | `inline` | `file`) and `review.handoff_file` in `llmanspec/config.yaml` for single-session independent-reviewer handoffs.',
|
|
264
|
+
'Run `llman-sdd init --check` to confirm skill and CLI minor-version parity.',
|
|
265
|
+
],
|
|
266
|
+
checks: [
|
|
267
|
+
'`.agents/skills/` contains the 5 `llman-sdd-*` hubs (with `playbooks/` and `references/`) and zero obsolete `llman-sdd-explore`/`propose`/`apply`/`verify`/`archive` directories.',
|
|
268
|
+
'All non-`llman-sdd-` custom skills remain untouched.',
|
|
269
|
+
'`llman-sdd init --check` exits 0.',
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
title: 'Unified requirement coordinates (`@llmanspec:req:rN[#<scene>]` and `machineKey`)',
|
|
274
|
+
steps: [
|
|
275
|
+
'Replace any legacy `@llmanspec:machine:<key>` or bare `@llmanspec:rN` source comments with `@llmanspec:req:rN`, `@llmanspec:req:rN#<scene>`, or `@llmanspec:req:rN#"<scene with spaces>"`.',
|
|
276
|
+
'Note `machineKey` in Studio now uses `rN#<scene>` (or `draft:<capability>#<scene>`). If stale local `.llman-sdd/studio/states/*.json` drafts use old 3-segment keys and have no pending edits, prune them with `llman-sdd studio state prune --all`.',
|
|
277
|
+
'Run `llman-sdd studio validate --specs` and `llman-sdd validate --specs --strict`.',
|
|
278
|
+
],
|
|
279
|
+
checks: [
|
|
280
|
+
'No `@llmanspec:machine:` or bare `@llmanspec:rN` source comments remain.',
|
|
281
|
+
'`llman-sdd studio validate --specs` exits 0.',
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
title: 'Verification gates and `.uncomment.toml` idempotent protection',
|
|
286
|
+
steps: [
|
|
287
|
+
'Note `llman-sdd validate --check` now automatically runs `llman-sdd theorem check` alongside `specs.check_command` (and optional `specs.check_dangling_bdd_command`).',
|
|
288
|
+
'Optionally set `specs.check_dangling_bdd_command` in `llmanspec/config.yaml` to enforce unused-step checks during `validate --check` and `change archive`.',
|
|
289
|
+
'If the repository already has `.uncomment.toml` (or `.uncommentrc.toml` / `uncomment.toml`), `llman-sdd init --update` idempotently adds `@llmanspec:` and `LLMANSPEC:` to `[global].preserve_patterns` and excludes `llmanspec/**`, `.llman-sdd/**`, and `.agents/skills/llman-sdd-*/**`.',
|
|
290
|
+
],
|
|
291
|
+
checks: [
|
|
292
|
+
'`llman-sdd validate --check` exits 0.',
|
|
293
|
+
'If `.uncomment.toml` is present, running `uncomment --check .` preserves `@llmanspec:` anchors and `LLMANSPEC:` markers.',
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
title:
|
|
298
|
+
'Human Theorems: single-file YAML replaces Markdown + lock manifest (0.12-dev early adopters only; v0.11.0 repos without `llmanspec/theorems/*.md` skip this)',
|
|
299
|
+
steps: [
|
|
300
|
+
'Check whether `llmanspec/theorems/*.md` or `.theorems.lock.json` exists. If absent (standard v0.11.0 repositories), skip this item completely.',
|
|
301
|
+
'If `llmanspec/theorems/*.md` exists, a human MUST run `llman-sdd theorem migrate` and `llman-sdd theorem lock` interactively in a TTY (agents must never modify or migrate theorems non-interactively).',
|
|
302
|
+
'Run `llman-sdd theorem check --strict` — it must exit 0 with `S2_LOCKED_STRONG`.',
|
|
303
|
+
],
|
|
304
|
+
checks: [
|
|
305
|
+
'`llmanspec/theorems/**` contains only `.yaml` files; no `*.md` and no `.theorems.lock.json` remain.',
|
|
306
|
+
'`llman-sdd theorem list --json` lists every migrated theorem with `severity`, `status`, `scope`, and `verify`.',
|
|
307
|
+
'`llman-sdd theorem check --strict` exits 0.',
|
|
308
|
+
],
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
},
|
|
170
312
|
];
|
|
171
313
|
|
|
172
314
|
const VERSION_RE = /^\d+\.\d+\.\d+$/u;
|
|
@@ -232,6 +374,6 @@ export function migrationOverviewLines(): string[] {
|
|
|
232
374
|
'Versioned migration playbooks (agent-readable, via `project migrate prompt`):',
|
|
233
375
|
versions,
|
|
234
376
|
'Usage: llman-sdd project migrate prompt --from-version <from> --to-version <to>',
|
|
235
|
-
'
|
|
377
|
+
'Legacy frozen-card unfence: llman-sdd project migrate frozen-cards-unfence [--dry-run]',
|
|
236
378
|
];
|
|
237
379
|
}
|
|
@@ -37,16 +37,12 @@ export function buildDefaultNodes(
|
|
|
37
37
|
maxScanDepth?: number,
|
|
38
38
|
): GraphNode[] {
|
|
39
39
|
const nodes = collectNodes(io, root, kinds, maxScanDepth);
|
|
40
|
-
// depth 0 = 仅 scope 内节点(human-readable graph):不拉取任何依赖 target。
|
|
41
40
|
if (depth <= 0) return nodes;
|
|
42
41
|
|
|
43
42
|
const nodeIds = new Set(nodes.map((n) => n.id));
|
|
44
43
|
const all = collectNodes(io, root, ['active', 'archived'], maxScanDepth);
|
|
45
44
|
const allMap = new Map(all.map((n) => [n.id, n]));
|
|
46
45
|
|
|
47
|
-
// BFS 沿 depends_on 从 scope 根展开 depth 层(depth 1 即现状的一层依赖拉取;
|
|
48
|
-
// N >= 2 递归展开)。拉入的依赖 target 若不在 scope 作为节点保留
|
|
49
|
-
// (present/archived 标记由 allMap 已知节点提供,未知 id 记为 phantom)。
|
|
50
46
|
let frontier = nodes.filter((n) => n.present).map((n) => n.id);
|
|
51
47
|
for (let level = 0; level < depth && frontier.length > 0; level++) {
|
|
52
48
|
const next: string[] = [];
|
|
@@ -14,8 +14,6 @@ export function collectActiveNodes(
|
|
|
14
14
|
root: string,
|
|
15
15
|
maxScanDepth?: number,
|
|
16
16
|
): GraphNode[] {
|
|
17
|
-
// T23: the active-change traversal is the shared walk (change/collect) —
|
|
18
|
-
// graph nodes are just its (dir, name) pairs mapped to the node shape.
|
|
19
17
|
const out: GraphNode[] = [];
|
|
20
18
|
walkActiveChangeDirs(
|
|
21
19
|
io,
|
|
@@ -83,7 +81,6 @@ export function collectNodes(
|
|
|
83
81
|
export function proposalFor(io: GraphFsIo, root: string, node: GraphNode): string {
|
|
84
82
|
if (node.archived) {
|
|
85
83
|
const archiveDir = `${root}/${CHANGES_DIR}/archive`;
|
|
86
|
-
// latest matching strategy: pick the newest date-prefixed dir
|
|
87
84
|
let best = '';
|
|
88
85
|
let bestDate = '';
|
|
89
86
|
for (const name of io.listDir(archiveDir)) {
|
|
@@ -97,8 +94,6 @@ export function proposalFor(io: GraphFsIo, root: string, node: GraphNode): strin
|
|
|
97
94
|
}
|
|
98
95
|
const p = `${archiveDir}/${best}/proposal.md`;
|
|
99
96
|
if (io.exists(p)) return io.readText(p);
|
|
100
|
-
// Frozen card fallback (r54): dir gone, body in cold backup — read the
|
|
101
|
-
// card (frontmatter incl. depends_on) so dependency edges survive freeze.
|
|
102
97
|
const card = isFrozenCard(best) ? `${archiveDir}/${best}` : `${archiveDir}/${best}.yaml`;
|
|
103
98
|
if (io.exists(card)) return io.readText(card);
|
|
104
99
|
return '';
|
|
@@ -111,7 +106,6 @@ export function proposalFor(io: GraphFsIo, root: string, node: GraphNode): strin
|
|
|
111
106
|
const child = `${dir}/${name}`;
|
|
112
107
|
if (!io.isDirectory(child)) continue;
|
|
113
108
|
if (io.exists(`${child}/proposal.md`)) {
|
|
114
|
-
// leaf change dir — do not descend further
|
|
115
109
|
if (name === node.id) found.push(`${child}/proposal.md`);
|
|
116
110
|
continue;
|
|
117
111
|
}
|
package/src/report/show.ts
CHANGED
|
@@ -53,7 +53,6 @@ export function showChangeJson(
|
|
|
53
53
|
? countTasks(io.readText(`${dir}/tasks.md`))
|
|
54
54
|
: { completed: 0, total: 0 };
|
|
55
55
|
|
|
56
|
-
// predecessor parity: show works (gracefully degraded gates) outside a git repo.
|
|
57
56
|
let cleanTree = false;
|
|
58
57
|
let current = null;
|
|
59
58
|
try {
|
|
@@ -64,8 +63,6 @@ export function showChangeJson(
|
|
|
64
63
|
}
|
|
65
64
|
const onBoundBranch = binding !== null && current === binding.branch;
|
|
66
65
|
|
|
67
|
-
// specs landing: bound changes must have touched llmanspec/specs/ since base
|
|
68
|
-
// (r119: judged under THIS instance's prefix, not the repo-root literal)
|
|
69
66
|
const specsPrefix = deps.specsPrefix ?? DEFAULT_SPECS_PREFIX;
|
|
70
67
|
let landedOnBranch = false;
|
|
71
68
|
if (binding !== null) {
|
|
@@ -73,24 +70,11 @@ export function showChangeJson(
|
|
|
73
70
|
}
|
|
74
71
|
const needsSpecsChange = readNeedsSpecsChange(extractFrontmatter(proposal));
|
|
75
72
|
|
|
76
|
-
const tasksDone = total
|
|
73
|
+
const tasksDone = !hasTasks || total === 0 || completed >= total;
|
|
77
74
|
const specReport = validateAllSpecs(discoverSpecs(deps.specsDir, io));
|
|
78
|
-
const validateOk = !specReport.failed &&
|
|
75
|
+
const validateOk = !specReport.failed && tasksDone;
|
|
79
76
|
|
|
80
|
-
const
|
|
81
|
-
? 'add design.md (current: draft → designed)'
|
|
82
|
-
: !hasTasks
|
|
83
|
-
? 'add tasks.md (current: designed → planned)'
|
|
84
|
-
: stage === 'planned'
|
|
85
|
-
? 'bind via `llman-sdd change start <id>` (planned → full)'
|
|
86
|
-
: '';
|
|
87
|
-
// T34: a missing tasks.md has nothing to check off — the hint says so
|
|
88
|
-
// instead of the legacy "complete or check off remaining tasks".
|
|
89
|
-
const tasksHint = hasTasks
|
|
90
|
-
? total > 0 && completed < total
|
|
91
|
-
? `${total - completed} unchecked tasks`
|
|
92
|
-
: 'complete or check off remaining tasks'
|
|
93
|
-
: 'no tasks.md — seal-off needs no checked tasks';
|
|
77
|
+
const tasksHint = tasksDone ? '' : `${total - completed} unchecked tasks`;
|
|
94
78
|
|
|
95
79
|
const gateChecks = [
|
|
96
80
|
{
|
|
@@ -105,8 +89,8 @@ export function showChangeJson(
|
|
|
105
89
|
},
|
|
106
90
|
{
|
|
107
91
|
name: 'stage-complete',
|
|
108
|
-
pass:
|
|
109
|
-
hint:
|
|
92
|
+
pass: true,
|
|
93
|
+
hint: '',
|
|
110
94
|
},
|
|
111
95
|
{
|
|
112
96
|
name: 'specs-landed',
|
|
@@ -118,8 +102,8 @@ export function showChangeJson(
|
|
|
118
102
|
},
|
|
119
103
|
{
|
|
120
104
|
name: 'tasks-done',
|
|
121
|
-
pass: tasksDone
|
|
122
|
-
hint:
|
|
105
|
+
pass: tasksDone,
|
|
106
|
+
hint: tasksHint,
|
|
123
107
|
},
|
|
124
108
|
{
|
|
125
109
|
name: 'validate',
|
|
@@ -6,9 +6,9 @@ import { localeFallbacks } from '../locale.ts';
|
|
|
6
6
|
import { assignSpecIds } from '../spec/assignSpecIds.ts';
|
|
7
7
|
import { officialKeywords, officialKeywordsOrEn } from '../spec/keywords.ts';
|
|
8
8
|
import { localeToGherkinLang, parseCapability } from '../spec/parser.ts';
|
|
9
|
+
import { allocateNextReqId } from '../spec/reqRef.ts';
|
|
9
10
|
import { buildReqRegistry } from '../spec/reqRegistry.ts';
|
|
10
11
|
import { type FsPort } from '../util/fsPort.ts';
|
|
11
|
-
import { nextNumber } from '../util/nextNumber.ts';
|
|
12
12
|
import { discoverFeatureFiles } from '../validation/discover.ts';
|
|
13
13
|
import type { SpecEntry } from '../validation/validate.ts';
|
|
14
14
|
|
|
@@ -18,7 +18,6 @@ export type SpecHelperIo = Pick<
|
|
|
18
18
|
>;
|
|
19
19
|
|
|
20
20
|
function collectSpecEntries(io: SpecHelperIo, specsDir: string): SpecEntry[] {
|
|
21
|
-
// T24: shared discovery — identical ordering/norm as the hash walk.
|
|
22
21
|
const normDir = specsDir.replace(/\\/g, '/').replace(/\/$/u, '');
|
|
23
22
|
const entries = discoverFeatureFiles(normDir, io).map((path) => ({
|
|
24
23
|
fileName: path,
|
|
@@ -28,6 +27,14 @@ function collectSpecEntries(io: SpecHelperIo, specsDir: string): SpecEntry[] {
|
|
|
28
27
|
return entries;
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Every `@req:` id occupied in the global registry (scan order) — the input
|
|
32
|
+
* for `allocateNextReqId` at every write-back surface.
|
|
33
|
+
*/
|
|
34
|
+
export function usedReqIds(io: SpecHelperIo, specsDir: string): string[] {
|
|
35
|
+
return [...buildReqRegistry(collectSpecEntries(io, specsDir)).byId.keys()];
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Max+1 over the requirement handles (`@req` on `规则:` headers) only — the id
|
|
33
40
|
* set comes from the global req registry fed with the parsed specs. Deliberately
|
|
@@ -37,20 +44,11 @@ function collectSpecEntries(io: SpecHelperIo, specsDir: string): SpecEntry[] {
|
|
|
37
44
|
* reused. See change `align-next-req-id-max-plus-one` design for the trade-off.
|
|
38
45
|
*/
|
|
39
46
|
export function nextReqId(io: SpecHelperIo, specsDir: string): string {
|
|
40
|
-
|
|
41
|
-
const used = [...buildReqRegistry(entries).byId.keys()].map((reqId) =>
|
|
42
|
-
Math.trunc(Number(reqId.replace(/^r/u, ''))),
|
|
43
|
-
);
|
|
44
|
-
// SSOT: the numeric-id allocator primitive (unify-numeric-id-allocation) —
|
|
45
|
-
// never a second max+1 fold. Same source as change sequence numbers.
|
|
46
|
-
return `r${nextNumber(used)}`;
|
|
47
|
+
return allocateNextReqId(usedReqIds(io, specsDir));
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export function skeletonContent(capability: string, reqId: string, locale: string): string {
|
|
50
51
|
const zh = localeFallbacks(locale)[0] === 'zh-Hans';
|
|
51
|
-
// r7: the `# language:` header derives from the locale mapping — never a
|
|
52
|
-
// second hardcoded caliber. Table-less locales fall back to en wholesale
|
|
53
|
-
// (header + keywords same-source) so the skeleton stays parseable.
|
|
54
52
|
const mapped = localeToGherkinLang(locale);
|
|
55
53
|
const language = officialKeywords(mapped) !== null ? mapped : 'en';
|
|
56
54
|
const kw = officialKeywordsOrEn(language);
|
|
@@ -58,11 +56,9 @@ export function skeletonContent(capability: string, reqId: string, locale: strin
|
|
|
58
56
|
? `# language: ${language}\n# purpose: TODO: 一句话描述该能力与其目的。`
|
|
59
57
|
: `# language: ${language}\n# purpose: TODO: Describe this capability and its purpose.`;
|
|
60
58
|
const ruleDesc = zh ? 'TODO: 需求描述(自由文本)。' : 'TODO: requirement statement (free text).';
|
|
61
|
-
// Skeleton placeholder prose is not vocabulary — the zh/en copy stays; keywords do not.
|
|
62
59
|
const steps = zh
|
|
63
60
|
? ` ${kw.given} TODO 前置\n ${kw.when} TODO 动作\n ${kw.thenText} TODO 断言`
|
|
64
61
|
: ` ${kw.given} TODO precondition\n ${kw.when} TODO action\n ${kw.thenText} TODO assertion`;
|
|
65
|
-
// native v2 skeleton: a rule block (with @req handle) + one nested example
|
|
66
62
|
return (
|
|
67
63
|
`${header}\n\n${kw.feature}: ${capability}\n\n @req:${reqId}\n ${kw.rule}: TODO-rule\n` +
|
|
68
64
|
` ${ruleDesc}\n\n ${kw.scenario}: TODO-acceptance\n${steps}\n`
|
package/src/review/review.ts
CHANGED
|
@@ -45,37 +45,25 @@ export function buildReview(input: ReviewInput): ReviewResult {
|
|
|
45
45
|
const sweep = validateAllSpecs(entries);
|
|
46
46
|
const sorted = [...entries].toSorted((a, b) => a.fileName.localeCompare(b.fileName));
|
|
47
47
|
|
|
48
|
-
// T29: unbound counting is the shared collector (report/unbound) keyed by
|
|
49
|
-
// capability — one definition of "rule without runnable scenario".
|
|
50
48
|
const unboundByCap = new Map<string, number>();
|
|
51
49
|
for (const u of collectUnboundRequirements(entries)) {
|
|
52
50
|
unboundByCap.set(u.capability, (unboundByCap.get(u.capability) ?? 0) + 1);
|
|
53
51
|
}
|
|
54
52
|
for (const entry of sorted) {
|
|
55
53
|
const cap = specIdOf(entry);
|
|
56
|
-
// r33: per-capability signals honor the --capability filter; locked and
|
|
57
|
-
// validate stay global regardless.
|
|
58
54
|
if (input.capability !== undefined && cap !== input.capability) continue;
|
|
59
55
|
push('unbound', cap, unboundByCap.get(cap) ?? 0);
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
const failed = sweep.verdicts.filter((v) => !v.ok);
|
|
63
59
|
const sweepFailedCount = failed.length;
|
|
64
|
-
// T35: unchecked tasks are work-in-progress noise, not contract breakage —
|
|
65
|
-
// they degrade to a warningCount contribution instead of the critical count
|
|
66
|
-
// (locked/unbound signals stay untouched).
|
|
67
60
|
const taskWarnings = strictChangeFails.length;
|
|
68
|
-
// predecessor parity: `count` is the removed locked-rule-confirmation concept (always
|
|
69
|
-
// 0 now); the detail text carries the bound-change count separately.
|
|
70
61
|
push(
|
|
71
62
|
'locked',
|
|
72
63
|
'-',
|
|
73
64
|
0,
|
|
74
65
|
`${boundChangeCount} bound change(s); inspect with \`llman-sdd change diff <id>\``,
|
|
75
66
|
);
|
|
76
|
-
// detail names the failing source: sweep failures point at `validate --all`;
|
|
77
|
-
// strict-only failures name the offending changes instead of a command that
|
|
78
|
-
// would report green.
|
|
79
67
|
const sweepDetail =
|
|
80
68
|
sweepFailedCount > 0 ? 'validate --all failed; run `llman-sdd validate --all` for details' : '';
|
|
81
69
|
const strictDetail =
|
|
@@ -18,9 +18,6 @@ export function featureRelPath(fileName: string, specsDir: string): string {
|
|
|
18
18
|
if (rel.startsWith(prefix)) return rel.slice(prefix.length);
|
|
19
19
|
// Path-form independence (fix-review-sweep-path): callers may load entries
|
|
20
20
|
// with absolute file names while specsDir stays root-relative (the review
|
|
21
|
-
// sweep did exactly that). Locate the LAST whole-segment occurrence of the
|
|
22
|
-
// specs root inside the file name and keep the tail — the id must depend on
|
|
23
|
-
// the position inside the specs tree, never on the caller's path shape.
|
|
24
21
|
const needle = `/${root}/`;
|
|
25
22
|
const at = rel.lastIndexOf(needle);
|
|
26
23
|
if (at >= 0) return rel.slice(at + needle.length);
|
package/src/spec/authoring.ts
CHANGED
|
@@ -124,6 +124,19 @@ export interface AddScenarioOpts {
|
|
|
124
124
|
thenText: string;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* End of the rule block that owns the @req tag: the first 2-space top-level tag
|
|
129
|
+
* or official block keyword line after the rule header. The scan starts below the
|
|
130
|
+
* header so the header itself cannot be mistaken for the boundary.
|
|
131
|
+
*/
|
|
132
|
+
function findRuleBlockEnd(lines: readonly string[], tagIdx: number): number {
|
|
133
|
+
for (let i = tagIdx + 2; i < lines.length; i++) {
|
|
134
|
+
const l = lines[i] ?? '';
|
|
135
|
+
if (l.startsWith(' @') || BLOCK_KEYWORD_LINE_RE.test(l)) return i;
|
|
136
|
+
}
|
|
137
|
+
return lines.length;
|
|
138
|
+
}
|
|
139
|
+
|
|
127
140
|
/**
|
|
128
141
|
* Insert a nested `场景:` under the target rule's block (r42). Finds the
|
|
129
142
|
* rule block boundary in the raw text (next 2-space top-level element) and
|
|
@@ -143,29 +156,16 @@ export function addScenario(
|
|
|
143
156
|
const lines = content.split('\n');
|
|
144
157
|
const tagIdx = lines.findIndex((l) => l.trim() === `@req:${opts.reqId}`);
|
|
145
158
|
if (tagIdx === -1) throw new AuthoringError(`req id not found in file: ${opts.reqId}`);
|
|
146
|
-
|
|
147
|
-
// indent that is a tag line or an official block keyword line (2-space +
|
|
148
|
-
// keyword immediately, any official dialect). The rule header directly
|
|
149
|
-
// following the tag opens the block, so the scan starts after it — otherwise
|
|
150
|
-
// the header itself is mistaken for the boundary and the scenario is
|
|
151
|
-
// inserted before the rule line (broken output).
|
|
152
|
-
let end = lines.length;
|
|
153
|
-
for (let i = tagIdx + 2; i < lines.length; i++) {
|
|
154
|
-
const l = lines[i] ?? '';
|
|
155
|
-
if (l.startsWith(' @') || BLOCK_KEYWORD_LINE_RE.test(l)) {
|
|
156
|
-
end = i;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
159
|
+
const end = findRuleBlockEnd(lines, tagIdx);
|
|
160
160
|
const kw = keywordsOf(content);
|
|
161
161
|
const givenLine =
|
|
162
162
|
opts.given !== undefined && opts.given !== '' ? ` ${kw.given} ${opts.given}\n` : '';
|
|
163
163
|
const scenarioBlock =
|
|
164
164
|
` ${kw.scenario}: ${opts.scenarioId}\n` +
|
|
165
165
|
`${givenLine} ${kw.when} ${opts.when}\n ${kw.thenText} ${opts.thenText}\n`;
|
|
166
|
-
// insert with a leading blank separator so the file stays readable
|
|
167
166
|
lines.splice(end, 0, '', scenarioBlock.trimEnd());
|
|
168
|
-
|
|
167
|
+
const joined = lines.join('\n');
|
|
168
|
+
io.writeText(path, content.endsWith('\n') && !joined.endsWith('\n') ? `${joined}\n` : joined);
|
|
169
169
|
return path;
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -235,19 +235,12 @@ export function planDedupe(
|
|
|
235
235
|
opts: { apply?: boolean } = {},
|
|
236
236
|
): DedupePlanItem[] {
|
|
237
237
|
const used = ruleReqIds(entries);
|
|
238
|
-
// Allocator primitive (unify-numeric-id-allocation): the remap sequence
|
|
239
|
-
// starts at max(used)+1 over the in-memory registry set (no second
|
|
240
|
-
// filesystem pass) and advances by one per allocation — never a
|
|
241
|
-
// smallest-free probing loop. Zero persisted state.
|
|
242
238
|
let next = nextNumber(
|
|
243
239
|
[...used].map((id) => Number(id.slice(1))).filter((n) => Number.isFinite(n)),
|
|
244
240
|
);
|
|
245
241
|
const fresh = (): string => `r${String(next++)}`;
|
|
246
242
|
const plan: DedupePlanItem[] = [];
|
|
247
243
|
for (const dup of duplicates) {
|
|
248
|
-
// occurrences are in scan order (sorted files, in-file rule order); the
|
|
249
|
-
// per-file ordinal counts every occurrence so kept ones hold their slot
|
|
250
|
-
// in the text and remapped ones target the exact `@req:` tag to rewrite.
|
|
251
244
|
const perFileOrdinal = new Map<string, number>();
|
|
252
245
|
let keepFile: string | null = null;
|
|
253
246
|
for (const occ of dup.occurrences) {
|
|
@@ -268,7 +261,6 @@ export function planDedupe(
|
|
|
268
261
|
}
|
|
269
262
|
if (opts.apply === false) return plan;
|
|
270
263
|
for (const item of plan) {
|
|
271
|
-
// registry duplicates carry bare file names; accept already-rooted paths too
|
|
272
264
|
const path = item.remapFile.startsWith(`${specsRoot}/`)
|
|
273
265
|
? item.remapFile
|
|
274
266
|
: `${specsRoot}/${item.remapFile}`;
|
package/src/spec/ir.ts
CHANGED
|
@@ -77,13 +77,22 @@ export interface CapabilityDoc {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* Whether a requirement is bound
|
|
81
|
-
* nested scenario (not `@skip`/`@experimental
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* Whether a requirement is bound in spec shape — it has at least one runnable
|
|
81
|
+
* nested scenario (not `@skip`/`@experimental`, and either carrying steps or a
|
|
82
|
+
* dialect-tagged examples table with a data row). That is not "tests executed
|
|
83
|
+
* the rows". Single authority for bound/unbound shared by review, validate INFO,
|
|
84
|
+
* list/show morphology and `spec unbound`.
|
|
84
85
|
*/
|
|
86
|
+
const DIALECT_BIND_TAGS = new Set(['flow', 'state', 'nodes', 'decision_table']);
|
|
87
|
+
|
|
85
88
|
export function ruleHasRunnableScenario(rule: RuleIR): boolean {
|
|
86
|
-
return rule.scenarios.some((s) =>
|
|
89
|
+
return rule.scenarios.some((s) => {
|
|
90
|
+
if (!s.runnable) return false;
|
|
91
|
+
if (s.stepCount > 0) return true;
|
|
92
|
+
const hasDialect = s.tags.some((t) => DIALECT_BIND_TAGS.has(t));
|
|
93
|
+
if (!hasDialect) return false;
|
|
94
|
+
return (s.examples ?? []).some((ex) => ex.rows.length >= 1);
|
|
95
|
+
});
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
/**
|
package/src/spec/keywords.ts
CHANGED
|
@@ -87,8 +87,6 @@ export function officialKeywords(language: string): GherkinKeywords | null {
|
|
|
87
87
|
if (!table) return null;
|
|
88
88
|
const locked = LOCKED_KEYWORDS[language];
|
|
89
89
|
if (locked === undefined) return keywordsFromTable(table);
|
|
90
|
-
// A locked byte that left the official table would silently drift the
|
|
91
|
-
// dialect — fall through to the table instead of emitting it.
|
|
92
90
|
const fromTable = keywordsFromTable(table);
|
|
93
91
|
if (fromTable === null) return null;
|
|
94
92
|
return TABLE_KEY_PAIRS.every(([tableKey, kwKey]) =>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single Studio machine-key coordinate system (unify-req-ref-and-clean-graph-dsl).
|
|
3
|
+
*
|
|
4
|
+
* Formal graphs key as `rN#<场景名>`; drafts without a `reqId` key as
|
|
5
|
+
* `draft:<capability>#<场景名>`. `capability` stays a structured IR field —
|
|
6
|
+
* consumers MUST NOT reverse-split it out of the key.
|
|
7
|
+
*
|
|
8
|
+
* Authority lives in `spec/` so `validation/` never imports `studio/` (r72).
|
|
9
|
+
* Pure — zero I/O, zero `node:*`, zero wall-clock calls (core-zero-io).
|
|
10
|
+
*/
|
|
11
|
+
import { REQ_ID_RE } from './reqRef.ts';
|
|
12
|
+
|
|
13
|
+
const DRAFT_PREFIX = 'draft:';
|
|
14
|
+
|
|
15
|
+
export interface ParsedMachineKey {
|
|
16
|
+
/** `r1` for a formal graph; `null` for a draft. */
|
|
17
|
+
reqId: string | null;
|
|
18
|
+
/** Capability carried by a draft key only. */
|
|
19
|
+
draftCapability?: string;
|
|
20
|
+
/** Full scenario name (may contain `/`, `#` and spaces). */
|
|
21
|
+
scenarioName: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function makeMachineKey(
|
|
25
|
+
capability: string,
|
|
26
|
+
reqId: string | null | undefined,
|
|
27
|
+
scenarioName: string,
|
|
28
|
+
): string {
|
|
29
|
+
const id = reqId?.trim();
|
|
30
|
+
if (id !== undefined && id !== '' && REQ_ID_RE.test(id)) return `${id}#${scenarioName}`;
|
|
31
|
+
return `${DRAFT_PREFIX}${capability}#${scenarioName}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Split on the first `#`: `rN` head → formal graph, `draft:<cap>` head → draft. */
|
|
35
|
+
export function splitMachineKey(machineKey: string): ParsedMachineKey | null {
|
|
36
|
+
const key = machineKey.trim();
|
|
37
|
+
const hashAt = key.indexOf('#');
|
|
38
|
+
if (hashAt <= 0) return null;
|
|
39
|
+
const head = key.slice(0, hashAt);
|
|
40
|
+
const scenarioName = key.slice(hashAt + 1);
|
|
41
|
+
if (scenarioName === '') return null;
|
|
42
|
+
if (REQ_ID_RE.test(head)) return { reqId: head, scenarioName };
|
|
43
|
+
if (head.startsWith(DRAFT_PREFIX)) {
|
|
44
|
+
const draftCapability = head.slice(DRAFT_PREFIX.length);
|
|
45
|
+
if (draftCapability === '') return null;
|
|
46
|
+
return { reqId: null, draftCapability, scenarioName };
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|