@buaa_smat/hometrans 26.0.4 → 26.0.5-devecocli.1
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/agents/code-reviewer.md +2 -0
- package/agents/model-render-worker.md +1 -1
- package/devecocli-plugin/common.ts +2271 -0
- package/devecocli-plugin/content-resolver.ts +363 -0
- package/devecocli-plugin/install.ts +72 -0
- package/devecocli-plugin/uninstall.ts +26 -0
- package/devecocli-plugin/update.ts +77 -0
- package/i18n/agents/code-reviewer.md +2 -0
- package/i18n/agents/model-render-worker.md +1 -1
- package/i18n/skills/a2h-app-migrate/SKILL.md +51 -3
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +140 -32
- package/i18n/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
- package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
- package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +3 -3
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +35 -5
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +4 -4
- package/i18n/skills/a2h-spec-generate/SKILL.md +3 -1
- package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
- package/i18n/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
- package/i18n/skills/a2h-spec-generate/references/spec-samples.md +5 -1
- package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
- package/i18n/skills/a2h-spec-generate/references/worker-rules.md +25 -2
- package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +121 -6
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +2 -1
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
- package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +11 -2
- package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +35 -0
- package/index.js +1643 -0
- package/package.json +8 -8
- package/plugin.jsonc +12 -0
- package/skills/a2h-app-migrate/SKILL.md +53 -5
- package/skills/a2h-app-migrate/references/workflow.yaml +140 -32
- package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +226 -0
- package/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
- package/skills/a2h-app-migrate/scripts/dag_process_executor.mjs +199 -0
- package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +897 -0
- package/skills/a2h-app-migrate/scripts/dag_runner.mjs +1767 -0
- package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -2
- package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +8 -2
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -8
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
- package/skills/a2h-app-migrate/test/test_dag_complete.mjs +222 -0
- package/skills/a2h-app-migrate/test/test_dag_production.mjs +670 -0
- package/skills/a2h-app-migrate/test/test_dag_runner.mjs +423 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
- package/skills/a2h-app-migrate/test/test_image_probe.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +16 -1
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
- package/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
- package/skills/a2h-batch-ui-align/SKILL.md +1 -1
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
- package/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
- package/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +49 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +36 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_ds1123.test.mjs +433 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_in_linear.test.mjs +288 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +46 -0
- package/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
- package/skills/a2h-page-specgen/references/spec-example.md +35 -5
- package/skills/a2h-page-specgen/references/spec-template.md +4 -4
- package/skills/a2h-spec-generate/SKILL.md +3 -1
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
- package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
- package/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
- package/skills/a2h-spec-generate/references/spec-samples.md +5 -1
- package/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
- package/skills/a2h-spec-generate/references/worker-rules.md +25 -2
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +3 -1
- package/skills/a2h-spec-generate/scripts/check_spec.ts +262 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +12 -2
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +54 -3
- package/skills/a2h-spec-generate/test/check-spec.test.ts +247 -0
- package/README.md +0 -440
- package/dist/cli/config-store.js +0 -128
- package/dist/cli/config.js +0 -48
- package/dist/cli/editors.json +0 -114
- package/dist/cli/env-vars.js +0 -127
- package/dist/cli/index.js +0 -76
- package/dist/cli/init.js +0 -2618
- package/dist/cli/uninstall.js +0 -406
- package/dist/platform/compose.js +0 -228
- package/dist/platform/frontmatter.js +0 -151
- package/dist/platform/installer.js +0 -417
- package/dist/platform/language.js +0 -77
- package/dist/platform/registry.js +0 -337
- package/dist/platform/transform.js +0 -363
- package/dist/platform/types.js +0 -9
- package/dist/platform/validate.js +0 -152
- package/dist/utils/regex.js +0 -7
- package/env-requirements.json +0 -536
- package/resource/choose_editor.png +0 -0
- package/resource/convert_pipeline_process.svg +0 -114
- package/resource/project_architecture.svg +0 -120
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/resource/set_sdk.png +0 -0
- package/resource/title_dark.png +0 -0
|
@@ -13,7 +13,7 @@ These are the authoring rules the final spec MUST follow:
|
|
|
13
13
|
4. The spec document must include a requirement semantic description, a UI-sequence section, scenario semantic descriptions, and scenario flow descriptions.
|
|
14
14
|
5. The scenario flow description must include the trigger operation sequence and the logical execution steps: what the user does and sees when the behavior is user-facing, and what data moves, in which direction, in what business format, and how the result changes what happens next when it crosses a service/data boundary.
|
|
15
15
|
6. **The spec is an input to HarmonyOS code generation and describes only what the HarmonyOS side must implement.** It must not contain Android or UniApp implementation knowledge — no platform types, framework mechanisms/APIs, constants, file paths, package names, storage/event identifiers, transaction ids, or source log text. Source evidence stays in the exploration and is never copied into the spec. See the Platform-Neutralization Rules in `references/synthesis-rules.md`.
|
|
16
|
-
7. **The spec never defines the service interface contract** — no signatures, parameter tables, return values, or error codes. Backend behavior enters only where it has a user-visible outcome, as concrete data-transfer steps; a failure with no user-visible outcome does not belong in a UI spec.
|
|
16
|
+
7. **The spec never defines the service interface contract** — no signatures, parameter tables, return values, or error codes. `## Data Contract` is the one exception: the type, byte length, range/enum values and code values of an external field belong in that section. Scenario steps still describe only user-visible outcomes and data movement, and never restate the contract as an interface spec. Backend behavior enters only where it has a user-visible outcome, as concrete data-transfer steps; a failure with no user-visible outcome does not belong in a UI spec.
|
|
17
17
|
8. The `## UI Sequence` section is mandatory, placed **above** all scenario sections, and its body is a single line: the requirement's UI path — its title line, a hyphen-separated path such as `Settings-Lyrics-Floating window status bar lyrics` — copied verbatim. See `## UI Sequence Rules`.
|
|
18
18
|
9. The spec must contain **no vague wording**. Every value the software produces, consumes, displays, stores, sends, receives, or branches on — toast text, limits, defaults, sort rules, switch states, HTTP endpoints, protocol versions, command values, field order, encodings, callback payload fields — is stated as its concrete value once source evidence exists. See the No-Vagueness Rules in `references/synthesis-rules.md`. Platform-neutrality is never an excuse for vagueness: dropping an Android detail obliges you to define the neutral replacement concretely.
|
|
19
19
|
10. **No view description.** The spec says what is shown, from where, under which condition — never how it looks or where it sits. Sizes, dp/px, coordinates, margins, padding, alignment, stacking, spacing, radius, font, weight, line height, colors, backgrounds and shadows stay out even when the source fixes them; layout and styling come from the HarmonyOS side's own design spec. Such a value is exploration evidence only and is dropped at synthesis — not restated, not paraphrased into "per the design mockup", not stubbed. An element is named for what it is, never for where it sits. **Motion timing is the one exception**: a transition's duration and the order of concurrent animations are behavior, not styling, so they ARE stated ("0.35 seconds", "the content makes room first, the page slides in afterwards"), while its displacement, curve name and resource name stay out (see `references/synthesis-rules.md`). Read the animation resource for the number if you must, but keep the citation on the citable line that loads *or declares* it — the code that starts the animation, or a `res/navigation` `app:enterAnim` / `res/values` `windowAnimationStyle` declaration; `res/anim*/` is outside the citable census and citing it aborts finalize.
|
|
@@ -88,10 +88,33 @@ Write to `<output>/<feature>-SPEC.md` (**overwrite if it already exists**; the s
|
|
|
88
88
|
2. Identity line `Control: <controlRef>` — copied verbatim when the requirement carries a `Control:` line; **when it does not, omit the whole line**, never fabricate one;
|
|
89
89
|
3. Requirement semantic description;
|
|
90
90
|
4. `## UI Sequence` (a single line, the requirement title copied verbatim);
|
|
91
|
-
5.
|
|
91
|
+
5. `## Data Contract` (see the next section; write the single line `No external data` when the SPEC reads none);
|
|
92
|
+
6. Atomic scenarios.
|
|
92
93
|
|
|
93
94
|
The document ends with the last scenario (or the deviation H3 section); there is no footer.
|
|
94
95
|
|
|
96
|
+
## Data Contract Rules
|
|
97
|
+
|
|
98
|
+
When the SPEC consumes or reads external data (an API response, cache, database, file, setting or location result), `## Data Contract` carries **one block per external field**:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
## Data Contract
|
|
102
|
+
|
|
103
|
+
- Field: time
|
|
104
|
+
- Type: string
|
|
105
|
+
- Byte length: 12
|
|
106
|
+
- Range: yyyyMMddHHmm
|
|
107
|
+
- Sample: 202611121100
|
|
108
|
+
- Semantic source: interface time field definition
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- All six keys are required, in this order; separate multiple fields with a blank line.
|
|
112
|
+
- `Type` is the actual type (`string`, `uint8`, `float32`, `int64`, …); `Byte length` is the width in bytes under the encoding the source declares: a fixed-width field states the number, a variable-length field says `variable`. Character count is not byte count (one CJK character is usually 3 bytes in UTF-8) — never substitute one for the other.
|
|
113
|
+
- `Range` states the format, enum range or boundaries; `Sample` is one real, checkable value — never a placeholder.
|
|
114
|
+
- `Semantic source` is the neutral name of the contract definition (e.g. "interface time field definition", "unit enum definition"). Never write a platform filename or `file:line`. The contract definition file itself must be included in this SPEC's `citations` (published under `## Source locations`); review confirms that citation points at the definition, not only at the UI widget.
|
|
115
|
+
- A SPEC that reads no external data writes only `No external data` in this section. Never leave it empty and never omit the section.
|
|
116
|
+
- Width, format and enum values come from the source or a real response. If they cannot be found, report the gap per Principle 15; never guess a "common" format.
|
|
117
|
+
|
|
95
118
|
## Step 3 Reporting Duty
|
|
96
119
|
**The part it cannot decide stays with you**: name, per requirement, every unsupported claim, every requirement skipped as no-recall, and every REQ detail the source does not implement — the reporter only sees files on disk, and this report is the only place such gaps surface, since the spec carries neither placeholders nor "insufficient evidence". If HomeGraph failed, report the exact error, the stopped file/requirement, and any completed outputs — never describe the interrupted batch as complete or continue its remaining SPECs.
|
|
97
120
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Mechanical spec checker — a2h-spec-generate
|
|
4
4
|
*
|
|
5
5
|
* Turns the decidable rules of STAGE.md into a script, replacing the Agent's item-by-item visual scan:
|
|
6
|
-
* - H1, section order, single-line `## UI Sequence`, no placeholders
|
|
7
|
-
* - Principle 10 zero UI view descriptions (size/position/color/font size/alignment); motion *timing* is its one exception
|
|
6
|
+
* - H1, section order, single-line `## UI Sequence`, the six-key `## Data Contract` (or its opt-out), no placeholders
|
|
7
|
+
* - Principle 10 zero UI view descriptions (size/position/color/font size/alignment/animation); motion *timing* is its one exception
|
|
8
8
|
* - Principle 6 no platform symbols
|
|
9
9
|
* - Principle 7 no interface contracts (signatures/parameter tables/return values/error codes)
|
|
10
10
|
* - Forbidden no `file:line` anchors and no `.trace` references in the body (trace is retired)
|
|
@@ -178,11 +178,104 @@ const CONTROL_LINE = /^(?:Control:)/;
|
|
|
178
178
|
const CONTROL_VALUE = /^(?:Control: )control:/;
|
|
179
179
|
/** H2 name (with `## ` already stripped): `UI Sequence` */
|
|
180
180
|
const UI_SEQ_NAME = /^(?:UI Sequence|UI[ \t]*Sequence)/;
|
|
181
|
+
/** H2 name: the external-data contract (`Data Contract`) */
|
|
182
|
+
const DATA_CONTRACT_NAME = /^(?:Data[ \t]*Contract)$/;
|
|
183
|
+
/** The explicit "this SPEC reads no external data" body (the only opt-out) */
|
|
184
|
+
const DATA_CONTRACT_OPTOUT = /^(?:No[ \t]+external[ \t]+data)$/i;
|
|
185
|
+
/** Required keys of one contract block. `Byte length` is deliberate: the
|
|
186
|
+
* contract needs the byte width, while `width` alone is a banned view property. */
|
|
187
|
+
const DATA_CONTRACT_KEYS: ReadonlyArray<readonly [string, string]> = [
|
|
188
|
+
['Field', 'field'],
|
|
189
|
+
['Type', 'type'],
|
|
190
|
+
['Byte length', 'byte length'],
|
|
191
|
+
['Range', 'range'],
|
|
192
|
+
['Sample', 'sample'],
|
|
193
|
+
['Semantic source', 'semantic source'],
|
|
194
|
+
];
|
|
181
195
|
/** H2 name: a scenario section (`Scenario…`) */
|
|
182
196
|
const SCENARIO_NAME = /^(?:Scenario)/;
|
|
183
197
|
/** A valid scenario heading: `scenario` + Chinese or Arabic numerals; in English only `Scenario <digits>` */
|
|
184
198
|
const SCENARIO_NAME_STRICT = /^(?:Scenario[0-9]+|Scenario[ \t]+\d+)$/;
|
|
185
199
|
|
|
200
|
+
/** Resolve a contract-block label to its canonical (en, alias) pair. */
|
|
201
|
+
function contractKeyOf(raw: string): readonly [string, string] | null {
|
|
202
|
+
const key = raw.trim().toLowerCase().replace(/[ \t]+/g, ' ');
|
|
203
|
+
for (const pair of DATA_CONTRACT_KEYS) {
|
|
204
|
+
if (key === pair[1]) return pair;
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Check one `## Data Contract` body: either the explicit opt-out line, or blocks
|
|
211
|
+
* of `- <key>: <value>` carrying every required key exactly once.
|
|
212
|
+
*/
|
|
213
|
+
function checkDataContract(lines: string[], sectionIndex: number): Finding[] {
|
|
214
|
+
const out: Finding[] = [];
|
|
215
|
+
const add = (line: number, note: string, text = '') =>
|
|
216
|
+
out.push({ level: 'error', rule: 'data-contract', line, text, note });
|
|
217
|
+
|
|
218
|
+
const body: Array<{ text: string; line: number }> = [];
|
|
219
|
+
for (let i = sectionIndex + 1; i < lines.length; i++) {
|
|
220
|
+
if (/^##\s+/.test(lines[i])) break;
|
|
221
|
+
if (HTML_COMMENT_LINE.test(lines[i])) continue;
|
|
222
|
+
body.push({ text: lines[i].trim(), line: i + 1 });
|
|
223
|
+
}
|
|
224
|
+
while (body.length > 0 && body[0].text === '') body.shift();
|
|
225
|
+
while (body.length > 0 && body[body.length - 1].text === '') body.pop();
|
|
226
|
+
if (body.length === 0) {
|
|
227
|
+
add(sectionIndex + 1, 'the data contract body is empty: declare at least one field block, or write the opt-out line');
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const optOut = body.filter(({ text }) => DATA_CONTRACT_OPTOUT.test(text));
|
|
232
|
+
if (optOut.length > 0) {
|
|
233
|
+
if (body.length > 1) add(optOut[0].line, 'the opt-out line must be the only body of the data contract');
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let block: Array<{ key: readonly [string, string]; value: string; line: number }> = [];
|
|
238
|
+
const flush = () => {
|
|
239
|
+
if (block.length === 0) return;
|
|
240
|
+
for (const [label, alias] of DATA_CONTRACT_KEYS) {
|
|
241
|
+
const hits = block.filter((item) => item.key[0] === label);
|
|
242
|
+
if (hits.length === 0) add(block[0].line, `data contract block is missing the \`${label}\` (${alias}) key`);
|
|
243
|
+
if (hits.length > 1) add(hits[1].line, `data contract block repeats the \`${label}\` (${alias}) key (check for a missing blank line between field blocks)`);
|
|
244
|
+
}
|
|
245
|
+
const positions = block.map((item) => DATA_CONTRACT_KEYS.findIndex(([label]) => label === item.key[0]));
|
|
246
|
+
const complete = positions.length === DATA_CONTRACT_KEYS.length && positions.every((position) => position >= 0);
|
|
247
|
+
if (complete && new Set(positions).size === positions.length) {
|
|
248
|
+
const ordered = positions.every((position, index) => position === index);
|
|
249
|
+
if (!ordered) {
|
|
250
|
+
add(block[0].line, `data contract keys must appear in order: ${DATA_CONTRACT_KEYS.map(([label]) => label).join(' → ')}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
block = [];
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
for (const { text, line } of body) {
|
|
257
|
+
if (text === '') { flush(); continue; }
|
|
258
|
+
const match = /^-\s*([^::]{1,24})\s*[::]\s*(.*)$/.exec(text);
|
|
259
|
+
if (!match) {
|
|
260
|
+
add(line, 'the data contract only accepts `- <key>: <value>` lines (one block per external field)');
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const key = contractKeyOf(match[1]);
|
|
264
|
+
if (key === null) {
|
|
265
|
+
add(line, `unknown data contract key: "${match[1].trim()}"`);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const value = match[2].trim();
|
|
269
|
+
if (value === '') {
|
|
270
|
+
add(line, `data contract key \`${key[0]}\` (${key[1]}) has an empty value`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
block.push({ key, value, line });
|
|
274
|
+
}
|
|
275
|
+
flush();
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
|
|
186
279
|
/** H2 name: the trailing provenance section the publisher appends
|
|
187
280
|
* (`Source locations`). It is the ONE place a source path may appear, so it is
|
|
188
281
|
* also the one place `code-anchor-leak` has to stand down. */
|
|
@@ -225,13 +318,32 @@ function checkStructure(lines: string[]): Finding[] {
|
|
|
225
318
|
const h2 = lines.map((l, i) => ({ l, i })).filter(({ l }) => /^##\s+/.test(l));
|
|
226
319
|
const names = h2.map(({ l }) => l.replace(/^##\s+/, '').trim());
|
|
227
320
|
let cursor = 0;
|
|
321
|
+
let uiSeen = false;
|
|
322
|
+
let contractSeen = 0;
|
|
323
|
+
let scenarioSeen = false;
|
|
324
|
+
const contractSections: number[] = [];
|
|
325
|
+
const addContract = (line: number, note: string) => out.push({ level: 'error', rule: 'data-contract', line, text: lines[line - 1]?.slice(0, 60) ?? '', note });
|
|
228
326
|
for (let k = 0; k < names.length; k++) {
|
|
229
327
|
const n = names[k];
|
|
230
|
-
if (UI_SEQ_NAME.test(n)) {
|
|
328
|
+
if (UI_SEQ_NAME.test(n)) {
|
|
329
|
+
if (cursor > 0) add(h2[k].i + 1, `\`${UI_SEQUENCE_TOKEN}\` must come before every scenario`);
|
|
330
|
+
uiSeen = true;
|
|
331
|
+
cursor = Math.max(cursor, 1);
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (DATA_CONTRACT_NAME.test(n)) {
|
|
335
|
+
contractSeen += 1;
|
|
336
|
+
contractSections.push(h2[k].i);
|
|
337
|
+
if (cursor < 1) addContract(h2[k].i + 1, `\`## Data Contract\` must come after \`${UI_SEQUENCE_TOKEN}\``);
|
|
338
|
+
if (cursor >= 2) addContract(h2[k].i + 1, '`## Data Contract` must come before every scenario');
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
231
341
|
if (SCENARIO_NAME.test(n)) {
|
|
232
342
|
if (!SCENARIO_NAME_STRICT.test(n)) add(h2[k].i + 1, `scenario heading should be \`${"## Scenario N"}\`, got "${n}"`);
|
|
233
343
|
if (cursor === 3) add(h2[k].i + 1, 'a scenario section must come before the source-locations section');
|
|
234
|
-
|
|
344
|
+
scenarioSeen = true;
|
|
345
|
+
cursor = Math.max(cursor, 2);
|
|
346
|
+
continue;
|
|
235
347
|
}
|
|
236
348
|
if (SOURCE_SECTION_NAME.test(n)) {
|
|
237
349
|
if (cursor < 2) add(h2[k].i + 1, 'the source-locations section must come after every scenario');
|
|
@@ -239,8 +351,11 @@ function checkStructure(lines: string[]): Finding[] {
|
|
|
239
351
|
}
|
|
240
352
|
add(h2[k].i + 1, `H2 section not allowed: "${n}"`);
|
|
241
353
|
}
|
|
242
|
-
if (!
|
|
243
|
-
if (
|
|
354
|
+
if (!uiSeen) add(1, `missing \`${UI_SEQUENCE_TOKEN}\` section`);
|
|
355
|
+
if (contractSeen === 0) addContract(1, 'missing `## Data Contract` section: declare the input shape, or write the opt-out line when the SPEC reads no external data');
|
|
356
|
+
if (contractSeen > 1) addContract(h2.find(({ l }) => DATA_CONTRACT_NAME.test(l.replace(/^##\s+/, '').trim()))!.i + 1, 'the `## Data Contract` section may appear at most once');
|
|
357
|
+
if (!scenarioSeen) add(1, 'missing scenario section');
|
|
358
|
+
if (contractSections.length > 0) out.push(...checkDataContract(lines, contractSections[0]!));
|
|
244
359
|
|
|
245
360
|
// The provenance section is optional (batch mode and a lost draft have none),
|
|
246
361
|
// but when present it must actually carry the bullets it exists for.
|
|
@@ -274,6 +274,7 @@ const SPEC_RESIDENT_REQUIRED_SECTIONS = [
|
|
|
274
274
|
["## Principles"],
|
|
275
275
|
["## UI Sequence Rules", "## UI Sequence Rules"],
|
|
276
276
|
["## File Write and Body Shape", "## File Write and Body Shape"],
|
|
277
|
+
["## Data Contract Rules", "## Data Contract Rules"],
|
|
277
278
|
["## Forbidden"]
|
|
278
279
|
] as const;
|
|
279
280
|
|
|
@@ -363,7 +364,7 @@ export function residentRuleSections(
|
|
|
363
364
|
*/
|
|
364
365
|
export function fusedSpecSection(specSkillDir: string): string {
|
|
365
366
|
const { featureStem } = specCommands(specSkillDir);
|
|
366
|
-
return `### C. Produce SPECs\n\nUse the **eco-style page owner**: this Area is one page, but **one SPEC corresponds to one user-visible flow**, not one\ncard or one display surface. Flows are cut along "data acquisition → derivation → display → save/restore", e.g. "pull to refresh", "choose the temperature unit",\n"search for a place"; one flow covers the data sources across controls, the derivation rules, error/empty states and the lifecycle. One page batch usually has 1–6\nSPECs; do not mechanically split every Control into its own SPEC, and do not write one big SPEC that flattens independently testable features either.\nProduce an extra \`controlGroup\`/\`discovery\` SPEC only when a local interaction needs a standalone binding. An area-owned SPEC\ndoes not correspond to a single Control and gets no \`Control:\` line on publishing; only a locally split SPEC is bound to a single controlRef.\n\n**A \`dataFlow\` data contract ledger is required**: exactly one row per area-owned SPEC, writing out \`entry\` (the user entry point),\n\`sources\` (request address/storage key/location source/setting), \`transforms\` (window, aggregation, rounding, sign, unit conversion),\n\`displays\` (user-visible fields), and \`persistence\` when there is a write/restore. The ledger is what R8 checks mechanically; a missing row,\na dangling \`specStem\` or a duplicate \`flowKey\` all fail.\n\n**A \`pageCoverage\` coverage ledger is required**: exactly one row for every \`controlGroup\`/\`discovery\` of this Area;\na \`covered\` row must name the \`specStem\` it belongs to (that stem must exist in \`specs[]\`), an \`excluded\`\nrow must give a reason. The ledger is L1's coverage assignment table and also what R4 checks mechanically; missing items, duplicate items and pointers to a\nnonexistent stem all fail the gate. L2 projects the ledger into each area SPEC's\n\`controlRefs[]\` in \`spec-bindings.json\`, from which the publish surface restores control coverage.\n\n9. **Write the SPEC file**: write one SPEC at \`specs/<stem>-SPEC.md\` in **this task directory**; the single \`## UI Sequence\`\n line **equals** that entry's \`specs[].title\` **verbatim**. The SPEC body follows specgen's writing rules (read \`## Gate List\` as\n needed): H1 is exactly \`# <stem>SPEC\`; the identity line \`Control: <controlRef>\` of a local controlGroup/discovery SPEC\n is minted by the script (you submit anchors only, R1), and an area-owned SPEC gets no such line;\n the requirement-semantics description; \`## UI Sequence\`; then the atomic scenarios. **The SPEC body exists only in the SPEC file and is never written into\n \`output.json\`.**\n10. **title rule**: \`title\` is a feature title in the SPEC's language (with a sense of page/entry location), and **equals** that SPEC's\n \`## UI Sequence\` line **verbatim**.\n11. **stem must be minted with the CLI, never hand-sanitized**: for that entry's \`title\` run\n \`node ${JSON.stringify(featureStem)} "<title>"\`, and use the printed stem as the file name unchanged. If this task's\n \`specs/\` already has a \`<stem>-SPEC.md\` of the same name, append \`-2\`, \`-3\`… in this task's production order; \`stem\` must be unique within\n \`output.json.specs[]\`. Hand-sanitizing makes \`check-fused-spec\`'s canonical-stem\n check fail.\n12. **Cut SPECs per flow and add the \`specs[]\` records**: the shape is \`SpecRecord\` in the "Output contract". One flow\n (data acquisition → derivation → display → persistence) corresponds to one \`owner: { kind: "area" }\` SPEC; do not split one flow across several\n SPECs. Add \`controlGroup\`/\`discovery\` records only for local standalone bindings, at most one each.\n An \`agent-added\` display SPEC carries its own \`identityAnchors\` (\`control\` required) and\n \`disposition:"added"\`. This field is **required** for this task.\n13. **Write the \`dataFlow\` data contract ledger**: exactly one row per area-owned SPEC, writing out \`entry\`, ≥1\n \`sources\`, ≥1 \`transforms\`, ≥1 \`displays\`, and \`persistence\` when there is a write/restore.\n \`specStem\` must exist in \`specs[]\`. R8 goes by it; a missing row, a dangling stem or a duplicate \`flowKey\` all fail.\n14. **Write the \`pageCoverage\` ledger**: exactly one row for every \`controlGroup\`/\`discovery\` of this Area; \`covered\`\n must give a \`specStem\` (existing in \`specs[]\`), \`excluded\` must give a \`reason\`. R4 goes by it.\n15. **Displayed-value derivation (R6a)**: every numeric/text field states its source field, time window, aggregation, rounding, sign and unit conversion;\n writing only "shows N" or "integer difference" is not allowed. A shared derivation rule is written once within a flow and referenced by later fields.\n16. **Display SPEC completeness (R6) is a required step, not an option**: per R6's definition in the output contract, do one source review of the data this Area\n renders/displays; for every display behavior the source can prove, that is user-visible and not covered by any SPEC,\n add an \`owner.kind="agent-added"\` \`specRecord\` and the corresponding SPEC file (own identityAnchors,\n ≥1 verifiable citation, \`disposition:"added"\`). An empty interaction surface is no exception.\n17. **Explicitly producing no SPEC**: when a Control/discovery really should not get a standalone SPEC this round, record it in\n \`pageCoverage\` with \`disposition:"excluded"\` and a reason; the legacy\n \`renderConfirmations\` are used only when no ledger is provided.\n18. **Body boundaries**: the SPEC body must not contain framework names such as Android/UniApp/Compose, \`file:line\` anchors, source\n symbols, placeholders or vague wording (R5 applies as well), and does not describe visual details of the UI; do not promote unresolved fields to established\n facts — content that must stay but the source cannot determine is simply omitted. **Do not** hand-write a \`Control:\` line or a \`controlRef\`.\n19. A single SPEC can be self-checked with \`check_spec\` (see the SPEC commands under "Output and Checks"); the whole-task self-check command\n covers both the fused draft and all SPECs.`;
|
|
367
|
+
return `### C. Produce SPECs\n\nUse the **eco-style page owner**: this Area is one page, but **one SPEC corresponds to one user-visible flow**, not one\ncard or one display surface. Flows are cut along "data acquisition → derivation → display → save/restore", e.g. "pull to refresh", "choose the temperature unit",\n"search for a place"; one flow covers the data sources across controls, the derivation rules, error/empty states and the lifecycle. One page batch usually has 1–6\nSPECs; do not mechanically split every Control into its own SPEC, and do not write one big SPEC that flattens independently testable features either.\nProduce an extra \`controlGroup\`/\`discovery\` SPEC only when a local interaction needs a standalone binding. An area-owned SPEC\ndoes not correspond to a single Control and gets no \`Control:\` line on publishing; only a locally split SPEC is bound to a single controlRef.\n\n**A \`dataFlow\` data contract ledger is required**: exactly one row per area-owned SPEC, writing out \`entry\` (the user entry point),\n\`sources\` (request address/storage key/location source/setting), \`transforms\` (window, aggregation, rounding, sign, unit conversion),\n\`displays\` (user-visible fields), and \`persistence\` when there is a write/restore. The ledger is what R8 checks mechanically; a missing row,\na dangling \`specStem\` or a duplicate \`flowKey\` all fail.\n\n**A \`pageCoverage\` coverage ledger is required**: exactly one row for every \`controlGroup\`/\`discovery\` of this Area;\na \`covered\` row must name the \`specStem\` it belongs to (that stem must exist in \`specs[]\`), an \`excluded\`\nrow must give a reason. The ledger is L1's coverage assignment table and also what R4 checks mechanically; missing items, duplicate items and pointers to a\nnonexistent stem all fail the gate. L2 projects the ledger into each area SPEC's\n\`controlRefs[]\` in \`spec-bindings.json\`, from which the publish surface restores control coverage.\n\n9. **Write the SPEC file**: write one SPEC at \`specs/<stem>-SPEC.md\` in **this task directory**; the single \`## UI Sequence\`\n line **equals** that entry's \`specs[].title\` **verbatim**. The SPEC body follows specgen's writing rules (read \`## Gate List\` as\n needed): H1 is exactly \`# <stem>SPEC\`; the identity line \`Control: <controlRef>\` of a local controlGroup/discovery SPEC\n is minted by the script (you submit anchors only, R1), and an area-owned SPEC gets no such line;\n the requirement-semantics description; \`## UI Sequence\`; a Data Contract section (six keys per external field: Field/Type/Byte length/Range/Sample/Semantic source, or the single line No external data); then the atomic scenarios. **The SPEC body exists only in the SPEC file and is never written into\n \`output.json\`.**\n10. **title rule**: \`title\` is a feature title in the SPEC's language (with a sense of page/entry location), and **equals** that SPEC's\n \`## UI Sequence\` line **verbatim**.\n11. **stem must be minted with the CLI, never hand-sanitized**: for that entry's \`title\` run\n \`node ${JSON.stringify(featureStem)} "<title>"\`, and use the printed stem as the file name unchanged. If this task's\n \`specs/\` already has a \`<stem>-SPEC.md\` of the same name, append \`-2\`, \`-3\`… in this task's production order; \`stem\` must be unique within\n \`output.json.specs[]\`. Hand-sanitizing makes \`check-fused-spec\`'s canonical-stem\n check fail.\n12. **Cut SPECs per flow and add the \`specs[]\` records**: the shape is \`SpecRecord\` in the "Output contract". One flow\n (data acquisition → derivation → display → persistence) corresponds to one \`owner: { kind: "area" }\` SPEC; do not split one flow across several\n SPECs. Add \`controlGroup\`/\`discovery\` records only for local standalone bindings, at most one each.\n An \`agent-added\` display SPEC carries its own \`identityAnchors\` (\`control\` required) and\n \`disposition:"added"\`. This field is **required** for this task.\n13. **Write the \`dataFlow\` data contract ledger**: exactly one row per area-owned SPEC, writing out \`entry\`, ≥1\n \`sources\`, ≥1 \`transforms\`, ≥1 \`displays\`, and \`persistence\` when there is a write/restore.\n \`specStem\` must exist in \`specs[]\`. R8 goes by it; a missing row, a dangling stem or a duplicate \`flowKey\` all fail.\n14. **Write the \`pageCoverage\` ledger**: exactly one row for every \`controlGroup\`/\`discovery\` of this Area; \`covered\`\n must give a \`specStem\` (existing in \`specs[]\`), \`excluded\` must give a \`reason\`. R4 goes by it.\n15. **Displayed-value derivation (R6a)**: every numeric/text field states its source field, time window, aggregation, rounding, sign and unit conversion;\n writing only "shows N" or "integer difference" is not allowed. A shared derivation rule is written once within a flow and referenced by later fields.\n16. **Display SPEC completeness (R6) is a required step, not an option**: per R6's definition in the output contract, do one source review of the data this Area\n renders/displays; for every display behavior the source can prove, that is user-visible and not covered by any SPEC,\n add an \`owner.kind="agent-added"\` \`specRecord\` and the corresponding SPEC file (own identityAnchors,\n ≥1 verifiable citation, \`disposition:"added"\`). An empty interaction surface is no exception.\n17. **Explicitly producing no SPEC**: when a Control/discovery really should not get a standalone SPEC this round, record it in\n \`pageCoverage\` with \`disposition:"excluded"\` and a reason; the legacy\n \`renderConfirmations\` are used only when no ledger is provided.\n18. **Body boundaries**: the SPEC body must not contain framework names such as Android/UniApp/Compose, \`file:line\` anchors, source\n symbols, placeholders or vague wording (R5 applies as well), and does not describe visual details of the UI; do not promote unresolved fields to established\n facts — content that must stay but the source cannot determine is simply omitted. **Do not** hand-write a \`Control:\` line or a \`controlRef\`.\n19. A single SPEC can be self-checked with \`check_spec\` (see the SPEC commands under "Output and Checks"); the whole-task self-check command\n covers both the fused draft and all SPECs.`;
|
|
367
368
|
}
|
|
368
369
|
|
|
369
370
|
/** The specgen script paths, resolved once so task.md and tests share them. */
|
|
@@ -336,9 +336,23 @@ test("residentRuleSections accepts the English rulebook copy (i18n/terms.json he
|
|
|
336
336
|
assert.match(kept, /```\n## UI Sequence\n[\s\S]*?```/u);
|
|
337
337
|
});
|
|
338
338
|
|
|
339
|
+
test("the SPEC writing step puts the UI sequence before the data contract (gate order)", () => {
|
|
340
|
+
const md = render();
|
|
341
|
+
const start = md.indexOf("9. **Write the SPEC file**");
|
|
342
|
+
const end = md.indexOf("10. **title rule**", start);
|
|
343
|
+
assert.ok(start >= 0 && end > start, "the SPEC step must be present");
|
|
344
|
+
const step = md.slice(start, end);
|
|
345
|
+
const ui = step.indexOf("## UI Sequence");
|
|
346
|
+
const contract = step.indexOf("Data Contract");
|
|
347
|
+
assert.ok(ui >= 0, "the step must name `## UI Sequence`");
|
|
348
|
+
assert.ok(contract >= 0, "the step must name the data contract");
|
|
349
|
+
assert.ok(ui < contract, "the template must put `## UI Sequence` before the data contract; check_spec rejects the reverse order");
|
|
350
|
+
assert.ok(contract < step.indexOf("atomic scenarios"), "the data contract must precede the atomic scenarios");
|
|
351
|
+
});
|
|
352
|
+
|
|
339
353
|
test("residentRuleSections still fails closed for a zh or en rulebook missing a section", () => {
|
|
340
|
-
const zh = "## Principles\np\n## UI Sequence Rules\nu\n## File Write and Body Shape\nw\n## Forbidden\nf\n";
|
|
341
|
-
const en = "## Principles\np\n## UI Sequence Rules\nu\n## File Write and Body Shape\nw\n## Forbidden\nf\n";
|
|
354
|
+
const zh = "## Principles\np\n## UI Sequence Rules\nu\n## File Write and Body Shape\nw\n## Data Contract Rules\nc\n## Forbidden\nf\n";
|
|
355
|
+
const en = "## Principles\np\n## UI Sequence Rules\nu\n## File Write and Body Shape\nw\n## Data Contract Rules\nc\n## Forbidden\nf\n";
|
|
342
356
|
const dropOne = [["## Step Discipline", "## Step Discipline"]];
|
|
343
357
|
// A declared dropped section that is absent in both languages throws (message names the zh heading).
|
|
344
358
|
assert.throws(() => residentRuleSections(zh, dropOne), /cannot drop them: ## Step Discipline$/u);
|
|
@@ -26,6 +26,9 @@ function cleanSpec(stem, title) {
|
|
|
26
26
|
"## UI Sequence",
|
|
27
27
|
title,
|
|
28
28
|
"",
|
|
29
|
+
"## Data Contract",
|
|
30
|
+
"No external data",
|
|
31
|
+
"",
|
|
29
32
|
"## Scenario 1",
|
|
30
33
|
"- 1. The user turns on the switch and the state is saved",
|
|
31
34
|
""
|
|
@@ -40,6 +43,9 @@ function dpViolatingSpec(stem, title) {
|
|
|
40
43
|
"## UI Sequence",
|
|
41
44
|
title,
|
|
42
45
|
"",
|
|
46
|
+
"## Data Contract",
|
|
47
|
+
"No external data",
|
|
48
|
+
"",
|
|
43
49
|
"## Scenario 1",
|
|
44
50
|
"- 1. Button width 48dp",
|
|
45
51
|
""
|
|
@@ -154,7 +160,7 @@ test("a SPEC content violation (a dp size line) fails through the shared check_s
|
|
|
154
160
|
const findings = checkDraftSpecs({ specs: [record("Switch-Off-By-Default", "Switch-Off-By-Default")] }, taskDir);
|
|
155
161
|
const view = findings.find((f) => f.level === "error" && f.rule === "UI-view-description(Principle 10)");
|
|
156
162
|
assert.ok(view, "the 48dp line must be flagged by the shared check_spec rules");
|
|
157
|
-
assert.equal(view.line,
|
|
163
|
+
assert.equal(view.line, 10);
|
|
158
164
|
assert.equal(view.text, "48dp");
|
|
159
165
|
// Must not falsely report H1 / UI Sequence: this fixture has content violations only.
|
|
160
166
|
assert.deepEqual(findings.filter((f) => f.rule === "SPEC naming" || f.rule === "SPEC UI Sequence"), []);
|
|
@@ -765,6 +771,9 @@ function cleanSpecEn(stem, title) {
|
|
|
765
771
|
"## UI Sequence",
|
|
766
772
|
title,
|
|
767
773
|
"",
|
|
774
|
+
"## Data Contract",
|
|
775
|
+
"No external data",
|
|
776
|
+
"",
|
|
768
777
|
"## Scenario 1",
|
|
769
778
|
"- 1. The user turns the switch on and the state is saved",
|
|
770
779
|
""
|
|
@@ -818,7 +827,7 @@ test("en: a `### Deviations from Requirement` section is rejected like `### Devi
|
|
|
818
827
|
const deviation = findings.find((f) => f.rule === "SPEC deviation section");
|
|
819
828
|
assert.ok(deviation, "an English deviation H3 section must be flagged");
|
|
820
829
|
assert.equal(deviation.level, "error");
|
|
821
|
-
assert.equal(deviation.line,
|
|
830
|
+
assert.equal(deviation.line, 12);
|
|
822
831
|
// case / plural variants are no bypass either
|
|
823
832
|
const variant = cleanSpecEn("Switch-Off-By-Default", "Switch-Off-By-Default") + "\n## Deviations From Requirements\n- x\n";
|
|
824
833
|
writeSpec(taskDir, "Switch-Off-By-Default-SPEC.md", variant);
|
|
@@ -31,6 +31,9 @@ const VIOLATING = [
|
|
|
31
31
|
"Background color #FF0000",
|
|
32
32
|
"The button is on the right side of the list",
|
|
33
33
|
"",
|
|
34
|
+
"## Data Contract",
|
|
35
|
+
"No external data",
|
|
36
|
+
"",
|
|
34
37
|
"## Scenario 1",
|
|
35
38
|
"- 1. The user taps and content is displayed",
|
|
36
39
|
"",
|
|
@@ -42,6 +45,9 @@ const CLEAN = [
|
|
|
42
45
|
"## UI Sequence",
|
|
43
46
|
"Switch-Off-By-Default",
|
|
44
47
|
"",
|
|
48
|
+
"## Data Contract",
|
|
49
|
+
"No external data",
|
|
50
|
+
"",
|
|
45
51
|
"## Scenario 1",
|
|
46
52
|
"- 1. The user turns on the switch and the state is saved",
|
|
47
53
|
"",
|
|
@@ -54,6 +60,9 @@ const WARN_ONLY = [
|
|
|
54
60
|
"## UI Sequence",
|
|
55
61
|
"After tapping, the corresponding prompt appears",
|
|
56
62
|
"",
|
|
63
|
+
"## Data Contract",
|
|
64
|
+
"No external data",
|
|
65
|
+
"",
|
|
57
66
|
"## Scenario 1",
|
|
58
67
|
"- 1. The user taps the button and the corresponding prompt appears",
|
|
59
68
|
"",
|
|
@@ -269,6 +278,9 @@ const CLEAN_EN = [
|
|
|
269
278
|
"## UI Sequence",
|
|
270
279
|
"Switch off by default",
|
|
271
280
|
"",
|
|
281
|
+
"## Data Contract",
|
|
282
|
+
"No external data",
|
|
283
|
+
"",
|
|
272
284
|
"## Scenario 1",
|
|
273
285
|
"- 1. The user turns the switch on and the state is saved",
|
|
274
286
|
"",
|
|
@@ -413,3 +425,26 @@ test("en: a step citing `Scenario N` gets the same self-reference warning as the
|
|
|
413
425
|
assert.ok(zh.some((f) => f.rule === "step self-reference" && f.level === "warn"));
|
|
414
426
|
assert.ok(en.some((f) => f.rule === "step self-reference" && f.level === "warn"), JSON.stringify(en));
|
|
415
427
|
});
|
|
428
|
+
|
|
429
|
+
test("en: data contract keys must appear in the documented order", () => {
|
|
430
|
+
const text = [
|
|
431
|
+
"# TimeSPEC",
|
|
432
|
+
"",
|
|
433
|
+
"## UI Sequence",
|
|
434
|
+
"Home - Hourly forecast",
|
|
435
|
+
"",
|
|
436
|
+
"## Data Contract",
|
|
437
|
+
"- Type: string",
|
|
438
|
+
"- Field: time",
|
|
439
|
+
"- Byte length: 12",
|
|
440
|
+
"- Range: yyyyMMddHHmm",
|
|
441
|
+
"- Sample: 202611121100",
|
|
442
|
+
"- Semantic source: interface time field definition",
|
|
443
|
+
"",
|
|
444
|
+
"## Scenario 1",
|
|
445
|
+
"- 1. The user opens the hourly forecast",
|
|
446
|
+
"",
|
|
447
|
+
].join("\n");
|
|
448
|
+
const findings = checkSpecText(text).filter((f) => f.rule === "data-contract");
|
|
449
|
+
assert.ok(findings.some((f) => f.note.includes("order")), JSON.stringify(findings));
|
|
450
|
+
});
|