@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
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// static_check/rules/staggered_lanes.ts — GATE staggered-grid-lanes-by-index.
|
|
2
|
+
//
|
|
3
|
+
// A Compose LazyVerticalStaggeredGrid / RecyclerView StaggeredGridLayoutManager places each item into the column
|
|
4
|
+
// that is currently shortest. Splitting the data by index parity into two Columns (item 0, 2, 4 … left; 1, 3, 5 …
|
|
5
|
+
// right) keeps the item count balanced but not the height: with cards of different heights one column grows longer
|
|
6
|
+
// with every row, and the order the user reads (left-right, top-down) no longer matches the source. Neither column is
|
|
7
|
+
// lazy either, so the whole list is laid out at once inside one ListItem.
|
|
8
|
+
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import { report } from '../core/findings.ts';
|
|
11
|
+
import { lineOfIndex, markedAbove, matchBracket, splitTopLevel } from '../core/parse.ts';
|
|
12
|
+
import { androidStemsWhere, portedAndroidStem } from '../core/android.ts';
|
|
13
|
+
import { maskedOf } from '../core/scan.ts';
|
|
14
|
+
import type { FileScan } from '../core/scan.ts';
|
|
15
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
16
|
+
|
|
17
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
18
|
+
export const meta: RuleMeta[] = [
|
|
19
|
+
{
|
|
20
|
+
id: "staggered-grid-lanes-by-index",
|
|
21
|
+
levels: ["GATE", "CAND"],
|
|
22
|
+
invariant: "geometry",
|
|
23
|
+
card: "geometry",
|
|
24
|
+
needs: ["--android"],
|
|
25
|
+
summary: "Data split into two columns by index parity: `for (let i = <non-zero start>; …; i += 2)`, or `.filter((_, i) => i % 2 …)`. GATE needs `--android`, and the two-column shape visible in the .ets file whose Android source (same file name, or it cites `X.kt`) uses `LazyVerticalStaggeredGrid` / `StaggeredGridItemSpan` / `StaggeredGridLayoutManager`: the method holding the loop (member method or top-level function) is called once with lane argument `0` and once with `1` (e.g. `vm.laneItems(0)` / `laneItems(this.all, 1)`), or that file writes two `.filter` splits. Any other step-2 loop (walking key/value pairs, etc.) is CAND only.",
|
|
26
|
+
fix: "A staggered grid places each item into the currently shortest column. A parity split balances the item count, not the height: with cards of different heights the two columns drift further apart row by row, and neither column is lazy. Use `WaterFlow` + `FlowItem` (`columnsTemplate('1fr 1fr')`); full-line items (`span = FullLine`) go into a `crossCount: 1` section (`WaterFlowSections`; spacing as in waterflow-sections-no-gap). When the source really splits by parity (not a staggered grid), write `// LANES-BY-INDEX: <source evidence>` above the split to close this rule.",
|
|
27
|
+
escape: "// LANES-BY-INDEX:",
|
|
28
|
+
cases: [
|
|
29
|
+
"Measured (CoolMall home, ds-1123): Android HomeScreen.kt is a RefreshLayout(isGrid = true) LazyVerticalStaggeredGrid(Fixed(2)) with FullLine sections first; the HarmonyOS HomeRoutePage.ets puts a Row of two Columns in a List, and HomeRouteViewModel.laneItems() splits with i += 2. The conversion report recorded it as \"weight + fixed spacing\", phase5_check passed, and on device the two goods columns drifted further apart toward the bottom.",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
/** `for (let i = <start>; i < …; i += 2)` with a start other than the literal 0 (lane = 0 / 1 passed in). */
|
|
35
|
+
const LANE_LOOP: RegExp =
|
|
36
|
+
/\bfor\s*\(\s*(?:let|var)\s+([A-Za-z_$][\w$]*)\s*(?::\s*number\s*)?=\s*([^;]+?)\s*;\s*\1\s*<=?[^;]+;\s*\1\s*\+=\s*2\s*\)/g;
|
|
37
|
+
/** `.filter((x, i) => i % 2 === k)` and its variants. */
|
|
38
|
+
const LANE_FILTER: RegExp = /\.filter\s*\(\s*\(\s*[^,)]*,\s*([A-Za-z_$][\w$]*)[^)]*\)\s*(?::\s*\w+\s*)?=>[^)]*?\b\1\s*%\s*2\b/g;
|
|
39
|
+
|
|
40
|
+
/** Android files that lay out a staggered grid (cached per dir by androidStemsWhere). */
|
|
41
|
+
function staggeredStems(dir: string): Set<string> {
|
|
42
|
+
return androidStemsWhere(dir, 'staggered-grid', 'Staggered',
|
|
43
|
+
(src) => /\bLazyVerticalStaggeredGrid\s*\(|\bStaggeredGridItemSpan\b|\bLazyStaggeredGridScope\b|\bStaggeredGridLayoutManager\s*\(/.test(src));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Name of the innermost method / getter / function whose body contains pos ('' when none). */
|
|
47
|
+
function enclosingMethod(masked: string, pos: number): string {
|
|
48
|
+
const re: RegExp = /(?:\bget\s+|\bfunction\s+)?([A-Za-z_$][\w$]*)\s*\([^()]*\)\s*(?::\s*[^{;=]+?)?\s*\{/g;
|
|
49
|
+
let best: string = '';
|
|
50
|
+
let bestOpen: number = -1;
|
|
51
|
+
let m: RegExpExecArray | null;
|
|
52
|
+
while ((m = re.exec(masked)) !== null) {
|
|
53
|
+
if (m.index > pos) { break; }
|
|
54
|
+
if (/^(?:if|for|while|switch|catch|function)$/.test(m[1])) { continue; }
|
|
55
|
+
const open: number = m.index + m[0].length - 1;
|
|
56
|
+
const close: number = matchBracket(masked, open);
|
|
57
|
+
if (close > pos && open > bestOpen) { best = m[1]; bestOpen = open; }
|
|
58
|
+
}
|
|
59
|
+
return best;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether masked code calls `name(…)` once with a lane argument `0` and once with `1` (any argument position, so both
|
|
64
|
+
* `vm.laneItems(0)` and a top-level `laneItems(this.all, 1)` count). That pair — one call per sibling column — is what
|
|
65
|
+
* separates a two-column split from any other step-2 loop; a generic name such as `get` called as `map.get('a')`
|
|
66
|
+
* passes no lane literal and does not count. The declaration itself (`name(lane: number)`) is skipped.
|
|
67
|
+
*/
|
|
68
|
+
function callsBothLanes(masked: string, name: string): boolean {
|
|
69
|
+
const lanes: Set<string> = new Set();
|
|
70
|
+
const re: RegExp = new RegExp('(?<![\\w$])' + name.replace(/\$/g, '\\$') + '\\s*\\(', 'g');
|
|
71
|
+
for (const c of masked.matchAll(re)) {
|
|
72
|
+
const paren: number = (c.index ?? 0) + c[0].length - 1;
|
|
73
|
+
const close: number = matchBracket(masked, paren);
|
|
74
|
+
if (close < 0) { continue; }
|
|
75
|
+
if (/^\s*(?::[^{;]*)?\{/.test(masked.slice(close + 1, close + 80))) { continue; } // a declaration, not a call
|
|
76
|
+
for (const a of splitTopLevel(masked.slice(paren + 1, close))) {
|
|
77
|
+
const t: string = a.trim();
|
|
78
|
+
if (t === '0' || t === '1') { lanes.add(t); }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return lanes.size === 2;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `.filter((x, i) => i % 2 …)` written twice in one file: both columns of an inline split. */
|
|
85
|
+
function filtersBothLanes(masked: string): boolean {
|
|
86
|
+
return [...masked.matchAll(LANE_FILTER)].length >= 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function checkStaggeredLanes(scans: FileScan[], androidDir: string): void {
|
|
90
|
+
const stems: Set<string> = androidDir !== '' && fs.existsSync(androidDir) ? staggeredStems(androidDir) : new Set();
|
|
91
|
+
// .ets files that port an Android staggered grid, with the Android stem they port
|
|
92
|
+
const porting: { scan: FileScan; stem: string }[] = [];
|
|
93
|
+
for (const s of scans) {
|
|
94
|
+
const stem: string | null = stems.size > 0 ? portedAndroidStem(s.abs, s.src, stems) : null;
|
|
95
|
+
if (stem !== null) { porting.push({ scan: s, stem }); }
|
|
96
|
+
}
|
|
97
|
+
for (const s of scans) {
|
|
98
|
+
const masked: string = maskedOf(s);
|
|
99
|
+
if (!/\+=\s*2\b|%\s*2\b/.test(masked)) { continue; }
|
|
100
|
+
const rawLines: string[] = s.src.split(/\r?\n/);
|
|
101
|
+
const sites: { at: number; filter: boolean }[] = [];
|
|
102
|
+
for (const m of masked.matchAll(LANE_LOOP)) {
|
|
103
|
+
if (/^0+$/.test(m[2].trim())) { continue; } // chunking rows of two from 0 is not a lane split
|
|
104
|
+
sites.push({ at: m.index ?? 0, filter: false });
|
|
105
|
+
}
|
|
106
|
+
for (const m of masked.matchAll(LANE_FILTER)) { sites.push({ at: m.index ?? 0, filter: true }); }
|
|
107
|
+
for (const site of sites) {
|
|
108
|
+
const line: number = lineOfIndex(s.code, site.at);
|
|
109
|
+
if (markedAbove(rawLines, line, 'LANES-BY-INDEX')) { continue; }
|
|
110
|
+
const method: string = site.filter ? '' : enclosingMethod(masked, site.at);
|
|
111
|
+
// GATE only for the two-column shape in a file that ports the grid: a loop split called once per lane
|
|
112
|
+
// (lane 0 and lane 1), or both inline filters in that file. Any other step-2 loop stays CAND.
|
|
113
|
+
const user: { scan: FileScan; stem: string } | undefined = porting.find((p) =>
|
|
114
|
+
site.filter ? p.scan === s && filtersBothLanes(masked) : method !== '' && callsBothLanes(maskedOf(p.scan), method));
|
|
115
|
+
const where: string = method === '' ? '' : ` in ${method}()`;
|
|
116
|
+
report(user !== undefined ? 'GATE' : 'CAND', 'staggered-grid-lanes-by-index', s.rel, line,
|
|
117
|
+
`the data is split into columns by index parity${where}: items 0, 2, 4 … go left and 1, 3, 5 … right. ` +
|
|
118
|
+
(user !== undefined
|
|
119
|
+
? `${user.scan.rel} ports ${user.stem}.kt, a staggered grid, which places each item into the currently shortest ` +
|
|
120
|
+
'column: with cards of different heights the two parity columns drift further apart row by row. '
|
|
121
|
+
: 'If the Android source is a staggered grid (LazyVerticalStaggeredGrid / StaggeredGridLayoutManager), it places ' +
|
|
122
|
+
'each item into the shortest column, which parity columns do not reproduce. ') +
|
|
123
|
+
"Use WaterFlow + FlowItem (columnsTemplate('1fr 1fr')), full-line items in a crossCount: 1 section; " +
|
|
124
|
+
'when the source really splits by parity, write // LANES-BY-INDEX: <source evidence> above the split');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// static_check/rules/window_size_constant.ts — GATE window-size-frozen-constant.
|
|
2
|
+
//
|
|
3
|
+
// Compose code often bounds a region by the window: `heightIn(max = screenHeight - 380.dp)` with screenHeight read
|
|
4
|
+
// from LocalWindowInfo / LocalConfiguration. A converter that evaluates that expression on the capture device and
|
|
5
|
+
// writes the result (914.29 − 380 = 534) as a constant reproduces the reference frame exactly, and breaks on any
|
|
6
|
+
// other window height: on a shorter screen the region keeps its 534 vp and pushes whatever follows it off screen.
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import { report } from '../core/findings.ts';
|
|
10
|
+
import { lineOfIndex, markedAbove } from '../core/parse.ts';
|
|
11
|
+
import { androidStemsWhere, portedAndroidStem } from '../core/android.ts';
|
|
12
|
+
import { maskedOf } from '../core/scan.ts';
|
|
13
|
+
import type { FileScan } from '../core/scan.ts';
|
|
14
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
15
|
+
|
|
16
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
17
|
+
export const meta: RuleMeta[] = [
|
|
18
|
+
{
|
|
19
|
+
id: "window-size-frozen-constant",
|
|
20
|
+
levels: ["GATE", "CAND"],
|
|
21
|
+
invariant: "geometry",
|
|
22
|
+
card: "geometry",
|
|
23
|
+
needs: ["--android"],
|
|
24
|
+
summary: "A `constraintSize` `maxHeight` / `maxWidth` is a number literal (≥ 100) or a constant initialized to one in this file, and this file reads no runtime window size (`getDefaultDisplaySync` / `getWindowProperties` / `windowSizeChange` / `windowRect` / `mainWindowSize`; `onAreaChange` / `onSizeChange` measure a component and do not count). Judged per axis: GATE when the Android source this file ports (same file name, or it cites `X.kt`) reads the window size on the same axis (height: `.screenHeightDp` / `heightPixels` / `containerSize.height` / `bounds.height()`; width likewise); CAND when it reads only an axis-less window API (`LocalWindowInfo` / `LocalConfiguration` / `displayMetrics` / `currentWindowMetrics`); nothing when it reads only the other axis. Members are matched on their own, so a value read into a local first (`configuration.screenHeightDp`) and the Java form (`getDisplayMetrics().heightPixels`) count.",
|
|
25
|
+
fix: "A bound the Android side computes from the runtime window cannot become a constant worked out on the capture device: on a shorter screen the region keeps its height and pushes the buttons after it off screen. Read the runtime window height (`display.getDefaultDisplaySync()` / the window's `getWindowProperties().windowRect`, px to vp, minus the reserved height from the source), or make the layout flexible: the scrolling region `layoutWeight(1)` (or `flexShrink(1)`) under a parent with `constraintSize({ maxHeight })`, the fixed block (button row) after it so it is never pushed out. When the bound really has nothing to do with the window, write `// SIZE-NOT-WINDOW: <source evidence>` above the line to close this rule.",
|
|
26
|
+
escape: "// SIZE-NOT-WINDOW:",
|
|
27
|
+
cases: [
|
|
28
|
+
"Measured (CoolMall spec-selection sheet, ds-1123): SpecSelectModal.kt:269-274 reads the screen height from LocalWindowInfo and bounds the spec area by heightIn(max = screen height − 380dp); HarmonyOS wrote SPEC_AREA_MAX_VP = 534 (914.29 − 380 on the capture device), with no bound on the panel itself. Selecting a spec adds the selected-name and quantity rows, the panel outgrows the screen, and the Add to Cart / Buy Now buttons are pushed off. The static clipping check summed only the captured unselected frame (759 < 783.6) and passed.",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Android reads of the window / screen height and width, matched on the member so that a value read into a local
|
|
35
|
+
* first (`val configuration = LocalConfiguration.current; configuration.screenHeightDp`) and the Java / View form
|
|
36
|
+
* (`getResources().getDisplayMetrics().heightPixels`) count too.
|
|
37
|
+
*/
|
|
38
|
+
const ANDROID_HEIGHT_READ: RegExp =
|
|
39
|
+
/\.screenHeightDp\b|\bheightPixels\b|\bcontainerSize\.height\b|\bbounds\.height\s*\(|\bwindowHeightSizeClass\b|\bheightSizeClass\b/;
|
|
40
|
+
const ANDROID_WIDTH_READ: RegExp =
|
|
41
|
+
/\.screenWidthDp\b|\bwidthPixels\b|\bcontainerSize\.width\b|\bbounds\.width\s*\(|\bwindowWidthSizeClass\b|\bwidthSizeClass\b/;
|
|
42
|
+
/** Window-size APIs that do not name the axis on the same line (the dimension is then unknown). */
|
|
43
|
+
const ANDROID_WINDOW_ANY: RegExp =
|
|
44
|
+
/\bLocalWindowInfo\b|\bcurrentWindowMetrics\b|\bWindowMetricsCalculator\b|\bcalculateWindowSizeClass\s*\(|\bgetDisplayMetrics\s*\(|\bdisplayMetrics\b|\bLocalConfiguration\b/;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* ArkTS APIs that read the runtime window size; any of them means the file already works from the real window.
|
|
48
|
+
* onAreaChange / onSizeChange are not among them: they measure a component, and converted code uses them for
|
|
49
|
+
* sticky headers and the like with no relation to the window.
|
|
50
|
+
*/
|
|
51
|
+
const ETS_WINDOW_READ: RegExp =
|
|
52
|
+
/\bgetDefaultDisplaySync\s*\(|\bgetWindowProperties\s*\(|\bwindowSizeChange\b|\bwindowRect\b|\bmainWindowSize\b/;
|
|
53
|
+
|
|
54
|
+
type Axis = 'height' | 'width';
|
|
55
|
+
|
|
56
|
+
/** Android stems reading the window size, per axis; 'any' = reads it without naming the axis (no prefilter word). */
|
|
57
|
+
function windowStems(dir: string): { height: Set<string>; width: Set<string>; any: Set<string> } {
|
|
58
|
+
return {
|
|
59
|
+
height: androidStemsWhere(dir, 'window-size-height', '', (src) => ANDROID_HEIGHT_READ.test(src)),
|
|
60
|
+
width: androidStemsWhere(dir, 'window-size-width', '', (src) => ANDROID_WIDTH_READ.test(src)),
|
|
61
|
+
any: androidStemsWhere(dir, 'window-size-any', '',
|
|
62
|
+
(src) => ANDROID_WINDOW_ANY.test(src) && !ANDROID_HEIGHT_READ.test(src) && !ANDROID_WIDTH_READ.test(src)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function checkWindowSizeConstant(scans: FileScan[], androidDir: string): void {
|
|
67
|
+
if (androidDir === '' || !fs.existsSync(androidDir)) { return; }
|
|
68
|
+
const stems = windowStems(androidDir);
|
|
69
|
+
if (stems.height.size + stems.width.size + stems.any.size === 0) { return; }
|
|
70
|
+
for (const s of scans) {
|
|
71
|
+
const masked: string = maskedOf(s);
|
|
72
|
+
if (!/\bconstraintSize\s*\(/.test(masked)) { continue; }
|
|
73
|
+
if (ETS_WINDOW_READ.test(s.code)) { continue; }
|
|
74
|
+
const byAxis: Record<Axis, string | null> = {
|
|
75
|
+
height: portedAndroidStem(s.abs, s.src, stems.height),
|
|
76
|
+
width: portedAndroidStem(s.abs, s.src, stems.width),
|
|
77
|
+
};
|
|
78
|
+
const anyStem: string | null = portedAndroidStem(s.abs, s.src, stems.any);
|
|
79
|
+
if (byAxis.height === null && byAxis.width === null && anyStem === null) { continue; }
|
|
80
|
+
// file-level numeric constants: NAME = 534
|
|
81
|
+
const consts: Map<string, number> = new Map();
|
|
82
|
+
for (const c of masked.matchAll(/\b(?:const|readonly)\s+([A-Za-z_$][\w$]*)\s*(?::\s*number\s*)?=\s*(\d+(?:\.\d+)?)\s*[;\n]/g)) {
|
|
83
|
+
consts.set(c[1], Number(c[2]));
|
|
84
|
+
}
|
|
85
|
+
const rawLines: string[] = s.src.split(/\r?\n/);
|
|
86
|
+
for (const m of masked.matchAll(/\bconstraintSize\s*\(\s*\{([^}]*)\}/g)) {
|
|
87
|
+
for (const k of m[1].matchAll(/\b(maxHeight|maxWidth)\s*:\s*([A-Za-z_$][\w$.]*|\d+(?:\.\d+)?)\s*(?=[,}\s]|$)/g)) {
|
|
88
|
+
const ref: string = k[2].replace(/^this\./, '');
|
|
89
|
+
const value: number | undefined = /^\d/.test(ref) ? Number(ref) : consts.get(ref);
|
|
90
|
+
if (value === undefined || value < 100) { continue; }
|
|
91
|
+
const line: number = lineOfIndex(s.code, m.index ?? 0);
|
|
92
|
+
if (markedAbove(rawLines, line, 'SIZE-NOT-WINDOW')) { continue; }
|
|
93
|
+
// GATE when the Android file reads this very axis; CAND when it reads the window without naming an axis;
|
|
94
|
+
// nothing when it reads only the other axis (a screenWidthDp image width says nothing about a maxHeight).
|
|
95
|
+
const axis: Axis = k[1] === 'maxHeight' ? 'height' : 'width';
|
|
96
|
+
const stem: string | null = byAxis[axis] ?? anyStem;
|
|
97
|
+
if (stem === null) { continue; }
|
|
98
|
+
const gate: boolean = byAxis[axis] !== null;
|
|
99
|
+
report(gate ? 'GATE' : 'CAND', 'window-size-frozen-constant', s.rel, line,
|
|
100
|
+
`constraintSize ${k[1]}: ${k[2]}${ref !== String(value) ? ` (= ${value})` : ''} is a fixed number, while ` +
|
|
101
|
+
(gate
|
|
102
|
+
? `${stem}.kt reads the window ${axis} at runtime (screen${axis === 'height' ? 'Height' : 'Width'}Dp / ` +
|
|
103
|
+
`${axis}Pixels / containerSize.${axis} …)`
|
|
104
|
+
: `${stem}.kt reads the window size without naming the axis on the same line (LocalWindowInfo / ` +
|
|
105
|
+
'LocalConfiguration / displayMetrics): check whether this bound comes from it') +
|
|
106
|
+
' and this file reads no window size. A value worked out on the capture device only fits that ' +
|
|
107
|
+
'screen: on a shorter window the region keeps its size and pushes what follows it (bottom buttons) off screen. ' +
|
|
108
|
+
'Read the runtime window size, or make the region flexible (layoutWeight(1) / flexShrink(1) under a bounded ' +
|
|
109
|
+
'parent) so the fixed blocks after it stay on screen; write // SIZE-NOT-WINDOW: <source evidence> when the ' +
|
|
110
|
+
'bound does not come from the window');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -21,6 +21,7 @@ Expand only branches that the source actually implements and that affect user-ob
|
|
|
21
21
|
- When the source implements dynamic error copy, state its real source, for example: “Show an error message using the text returned by the server.”
|
|
22
22
|
- A failure without a textual message is valid. Write only the actual observable outcomes, such as loading ending, old content remaining, or another real result; for example: “When the request finishes, stop loading and retain the old content without showing an additional message.”
|
|
23
23
|
- An internal failure with no user-observable outcome does not become a UI scenario. Never invent a message, navigation, or state change just to cover a failure category.
|
|
24
|
+
- **Evidence for "what the UI shows" comes from the render branch, not from a state assignment**. A ViewModel assigning a state value (e.g. `loadMoreState = PullToLoad` on an empty list) only says the value exists, not that it is drawn. Before writing a "shows / displays / appears" step, find the UI code that renders in that state (the Compose `when (state)` / `if` branch, the View `visibility` setting, the adapter item type) and confirm that branch reads the value and draws the element. If the branch does not read it, do not write it as a visible element; when it must be recorded, write it as an invisible state fact (e.g. "the load-more state is reset to its initial value"), without "shows". The CoolMall order list: `BaseNetWorkListView`'s `Empty` branch draws only `EmptyData`, and the load-more footer exists only inside the `Success` list content. The SPEC turned the `PullToLoad` assignment on an empty list into "the tab's bottom shows the pull-to-load initial state", the review judged it PARTIAL, and after the fix every empty tab showed "pull up to load more" at the bottom.
|
|
24
25
|
|
|
25
26
|
## Atomic Scenarios
|
|
26
27
|
|
|
@@ -167,6 +168,7 @@ Timing wording follows the source: "refreshes immediately" when it takes effect
|
|
|
167
168
|
When a scenario performs a network request, its request body must be written key by key in `contracts.endpoints` — never “call the endpoint” or a bare URL; the response should also be described key by key where possible. The contracts are the fact base: the method, the complete URL, every parameter name and every response field must be merged into the consuming request step as natural sentences (see `spec-template.md` 1.4).
|
|
168
169
|
|
|
169
170
|
- For each request-body key, state its name, type, required flag, default value (what is sent when absent), nested structure, and value source (UI input, local storage, the previous response, or a fixed value); list query parameters, path parameters, and headers the same way, marking each one's `in`.
|
|
171
|
+
- **State per field whether it is sent on the wire**: mark every parameter required or not; for a non-required one, write in its `note` the send rule — when it is not sent (no selection, empty, equals its default, the control is off, and so on), or that it is always sent with its default. When the source platform's serializer omits defaults, empty strings or empty arrays, write “the request body does not contain this field while it equals its default”; never summarize as “empty when absent” or send the default as an empty value — a receiver may treat the field's presence as a filter condition; when a field really is always sent, write “always sent, uses the default value” instead of inventing an omission condition to fit the format. HarmonyOS keeps the same send semantics.
|
|
170
172
|
- Use only the keys listed in `spec-template.md`: write the default and the value source into that parameter's `default` and `source`, and write nested keys as a path (e.g. `data.list[].id`) in `name`; any other key cannot reach the steps and is rejected by G2.
|
|
171
173
|
- When the body is an object or an array, state the nesting and every child key; never write “other fields,” “etc.,” or a single sample value.
|
|
172
174
|
- For the response, try to list one field path per string in `response_fields` (e.g. `current_temperature`, `hourly.temperatures[]`), naming only the field or its path; the envelope (e.g. code/data/message), types, nullability, and how a missing or default-valued field is handled go into that endpoint's `note` and are merged into the steps — never into a `response_fields` element, because G2 requires each element to appear verbatim in the steps.
|
|
@@ -260,10 +262,11 @@ Before submission, confirm all of the following:
|
|
|
260
262
|
- The “Lifecycle and Invalidation Axis” was checked against the source for all four trigger classes, and every lifecycle-signal candidate has a terminal disposition.
|
|
261
263
|
- Every discovered exceptional path has an explicit disposition: an independent scenario, steps on the same path, or confirmation that it has no user-observable behavior.
|
|
262
264
|
- Lists and complex display areas were checked for empty and partial data.
|
|
265
|
+
- Every "shows / displays / appears" step maps to the UI branch that actually renders it in that state (`file:line`), not only to a ViewModel state assignment. Check empty, error and loading states especially: their branches usually draw a single placeholder component.
|
|
263
266
|
- Asynchronous operations were checked for in-progress, success, and the failure states implemented in source.
|
|
264
267
|
- Persistent operations were checked for write outcomes and read-back behavior.
|
|
265
268
|
- Scenarios that create, read, update, or delete data, or synchronize state or data, list every affected piece of data and how it changes, with no vague “related data updates in sync.”
|
|
266
|
-
- Network scenarios give every request-body key's name, type, required flag, default value,
|
|
269
|
+
- Network scenarios give every request-body key's name, type, required-or-not flag, default value, value source and send rule (when a non-required field is absent, or that it is always sent with its default) in `contracts.endpoints`, describe the response structure as fully as possible, and merge those facts into the request step.
|
|
267
270
|
- No vague phrase such as “handle all other errors uniformly” substitutes for concrete branches.
|
|
268
271
|
- Every scenario is independently readable, with no abbreviated cross-scenario references and no unsupported copy, branches, thresholds, or outcomes added to fill gaps.
|
|
269
272
|
- Each scenario is exactly one normal or one edge/boundary case, with no success/failure mix.
|
|
@@ -182,6 +182,35 @@ The user adds multiple songs at once from the folder detail page through multi-s
|
|
|
182
182
|
|
|
183
183
|
### Scenario Overview
|
|
184
184
|
|
|
185
|
+
When songs are added, the client submits the addition to the server; the request body carries only the required fields and the optional fields in effect for this request
|
|
186
|
+
|
|
187
|
+
### Scenario Steps
|
|
188
|
+
|
|
189
|
+
- 1. The user adds one or more songs to the target playlist from any entry point, and the page requests the submission while it refreshes the local list
|
|
190
|
+
- 2. The page sends a `POST https://api.example.com/v1/playlist/songs` request whose header content type is application/json and charset is utf-8
|
|
191
|
+
- 3. The request body's `playlistId` and `songIds` are required: `playlistId` is the target playlist's number and `songIds` is the array of song numbers added this time; both are sent on every request
|
|
192
|
+
- 4. `source` is not required: entering from the song list, album, artist or folder sends song_list, album, artist or folder respectively, while entering from the playlist detail page sends playlist_detail; when the source cannot be determined the field is not sent — no empty string either
|
|
193
|
+
- 5. `position` is not required: when the user specifies no insert position the field is not sent and the server appends under the playlist's current sort rule; it is sent only when the user explicitly drags a song to a position
|
|
194
|
+
- 6. After the response arrives `code` is 0, and the page refreshes the playlist's song count and cover from `data.addedCount`; the addition is complete
|
|
195
|
+
|
|
196
|
+
## Scenario 8
|
|
197
|
+
|
|
198
|
+
### Scenario Overview
|
|
199
|
+
|
|
200
|
+
When the server returns a business failure, the local append is undone and a failure message is shown
|
|
201
|
+
|
|
202
|
+
### Scenario Steps
|
|
203
|
+
|
|
204
|
+
- 1. The user adds one or more songs to the target playlist from any entry point, and the page requests the submission while it refreshes the local list
|
|
205
|
+
- 2. The page sends a `POST https://api.example.com/v1/playlist/songs` request whose header content type is application/json and charset is utf-8
|
|
206
|
+
- 3. The request body's `playlistId` and `songIds` are required; `source` is not required and is not sent when the source cannot be determined; `position` is not required and is not sent when no insert position is specified
|
|
207
|
+
- 4. After the response arrives `code` is not 0, so the page undoes the locally appended songs and restores the playlist's song count and cover to their values before the submission
|
|
208
|
+
- 5. The page shows the response's `message`, and the existing playlist data stays unchanged
|
|
209
|
+
|
|
210
|
+
## Scenario 9
|
|
211
|
+
|
|
212
|
+
### Scenario Overview
|
|
213
|
+
|
|
185
214
|
The user opens the playlist detail page and views the playlist name and song list
|
|
186
215
|
|
|
187
216
|
### Scenario Steps
|
|
@@ -191,7 +220,7 @@ The user opens the playlist detail page and views the playlist name and song lis
|
|
|
191
220
|
- 3. The page lower area shows the playlist's song list, with songs under the playlist's configured sort rule
|
|
192
221
|
- 4. A new playlist's default sort rule is "by time added to the playlist" (songs added later appear above)
|
|
193
222
|
|
|
194
|
-
## Scenario
|
|
223
|
+
## Scenario 10
|
|
195
224
|
|
|
196
225
|
### Scenario Overview
|
|
197
226
|
|
|
@@ -204,7 +233,7 @@ The user switches the sort rule on the playlist detail page to a rule other than
|
|
|
204
233
|
- 3. The song list re-sorts and refreshes under the selected rule
|
|
205
234
|
- 4. The rule stays in effect until the user switches again, and songs added later are inserted at their position under that rule
|
|
206
235
|
|
|
207
|
-
## Scenario
|
|
236
|
+
## Scenario 11
|
|
208
237
|
|
|
209
238
|
### Scenario Overview
|
|
210
239
|
|
|
@@ -216,7 +245,7 @@ When the user tries to add a song that is already in the target playlist, the ap
|
|
|
216
245
|
- 2. If a selected song is already in the target playlist, it is not added again, and its original added time stays unchanged
|
|
217
246
|
- 3. Songs from this operation that are not yet in the target playlist are added normally under the applicable sort rule
|
|
218
247
|
|
|
219
|
-
## Scenario
|
|
248
|
+
## Scenario 12
|
|
220
249
|
|
|
221
250
|
### Scenario Overview
|
|
222
251
|
|
|
@@ -228,7 +257,7 @@ The user cancels the add-to-playlist operation in the playlist picker
|
|
|
228
257
|
- 2. The user closes the picker by tapping outside it
|
|
229
258
|
- 3. The playlist content does not change, and the user returns to the previous page state
|
|
230
259
|
|
|
231
|
-
## Scenario
|
|
260
|
+
## Scenario 13
|
|
232
261
|
|
|
233
262
|
### Scenario Overview
|
|
234
263
|
|
|
@@ -239,7 +268,7 @@ The playlist picker must contain every existing playlist and its song informatio
|
|
|
239
268
|
- 1. The user triggers the playlist picker through an add-to-playlist action
|
|
240
269
|
- 2. The picker lists every existing playlist, and each playlist's song count is accurate
|
|
241
270
|
|
|
242
|
-
## Scenario
|
|
271
|
+
## Scenario 14
|
|
243
272
|
|
|
244
273
|
### Scenario Overview
|
|
245
274
|
|
|
@@ -258,6 +287,7 @@ After songs are added to a playlist, the playlist's song count refreshes immedia
|
|
|
258
287
|
- app/src/main/java/com/melody/musicapp/ui/dialog/AddToPlaylistDialog.java:66
|
|
259
288
|
- app/src/main/java/com/melody/musicapp/ui/fragment/PlaylistDetailFragment.java:51
|
|
260
289
|
- app/src/main/java/com/melody/musicapp/ui/helper/PlaylistSortHelper.java:33
|
|
290
|
+
- app/src/main/java/com/melody/musicapp/network/PlaylistApi.java:31
|
|
261
291
|
- app/src/main/java/com/melody/musicapp/data/repository/PlaylistRepository.java:39
|
|
262
292
|
- app/src/main/java/com/melody/musicapp/data/repository/PlaylistRepository.java:58
|
|
263
293
|
- app/src/main/java/com/melody/musicapp/data/db/dao/PlaylistSongDao.java:27
|
|
@@ -44,8 +44,8 @@ Percent encoding is **reversible** (`%` itself becomes `%25`, and the encoded re
|
|
|
44
44
|
"url": "https://api.open-meteo.com/v1/forecast",
|
|
45
45
|
"params": [
|
|
46
46
|
{"in": "query", "name": "latitude", "type": "number", "required": true, "note": "latitude of the current location"},
|
|
47
|
-
{"in": "query", "name": "temperature_unit", "type": "text", "required": false, "default": "celsius", "source": "local storage"},
|
|
48
|
-
{"in": "query", "name": "timezone", "type": "text", "required": false, "default": "Asia/Shanghai", "source": "local storage"}
|
|
47
|
+
{"in": "query", "name": "temperature_unit", "type": "text", "required": false, "default": "celsius", "source": "local storage", "note": "absent from the request while it equals its default celsius"},
|
|
48
|
+
{"in": "query", "name": "timezone", "type": "text", "required": false, "default": "Asia/Shanghai", "source": "local storage", "note": "absent from the request while it equals its default Asia/Shanghai"}
|
|
49
49
|
],
|
|
50
50
|
"response_fields": ["current_temperature", "weather_code", "hourly.temperatures[]"],
|
|
51
51
|
"note": "The envelope is code/data/message: current_temperature and weather_code are not null, and a missing weather_code is treated as 0; hourly.temperatures[] is nullable, and a missing slot is not shown",
|
|
@@ -105,12 +105,12 @@ Percent encoding is **reversible** (`%` itself becomes `%25`, and the encoded re
|
|
|
105
105
|
|
|
106
106
|
| kind | Contents | Written into the steps as |
|
|
107
107
|
|---|---|---|
|
|
108
|
-
| `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, every parameter name with its type, required flag, default and value source, every response field, and timeouts; `operation_id`, `branch`, and `state_version` are not rendered |
|
|
108
|
+
| `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, every parameter name with its type, required flag, default and value source, and for a non-required parameter the condition under which it is not sent, every response field, and timeouts; `operation_id`, `branch`, and `state_version` are not rendered |
|
|
109
109
|
| `stores` | `name` / `key` / `type` / `default` / `values[]` (strings or `{value, label}`) / `note` | The persistence step: key name, type, default, and every enum value — never "etc." |
|
|
110
110
|
| `entities` | `name` / `fields[]` (`name` / `type` / `nullable` / `unit` / `note`) / `note` | The display or computation step: the entity's business name and every field with its type, nullability, and unit |
|
|
111
111
|
| `rules` | `name` / `statement` | The step that performs the conversion or applies the boundary: an instruction that can be followed verbatim |
|
|
112
112
|
|
|
113
|
-
**Request and response keys are written key by key.** A parameter's default and value source belong in its `default` and `source` fields (`default: 0`, `source: local storage`) and are merged into the request step; a nested key keeps its path in `name` (`data.list[].id`); `response_fields[]` lists one field path per string (`current_temperature`, `hourly.temperatures[]`), while the envelope (code/data/message), types, nullability and missing-value handling go into the entry's `note` and the step text. An endpoint or parameter field outside the lists above, or a non-string `response_fields[]` item, is rejected by G2 because the fact base cannot carry it.
|
|
113
|
+
**Request and response keys are written key by key.** A parameter's default and value source belong in its `default` and `source` fields (`default: 0`, `source: local storage`) and are merged into the request step; a nested key keeps its path in `name` (`data.list[].id`); a non-required parameter also states in its `note` when it is absent from the wire (e.g. “equals its default, so the request body omits it”) or that it is always sent with its default (“always sent, uses the default value”), and the request step carries that rule too so the coder does not turn a default value into a sent key; `response_fields[]` lists one field path per string (`current_temperature`, `hourly.temperatures[]`), while the envelope (code/data/message), types, nullability and missing-value handling go into the entry's `note` and the step text. An endpoint or parameter field outside the lists above, or a non-string `response_fields[]` item, is rejected by G2 because the fact base cannot carry it.
|
|
114
114
|
|
|
115
115
|
**The body language rules apply to the merged steps.** Contract-only syntax is no longer legal anywhere: no `dp`/`sp`/`px`/`dip` (with or without a number), no `#hex`, no `key=value` (write "the code field is 1001"), no framework type names, no `file:line`. Visual values are rewritten as business descriptions ("the size is large"). Data values keep their source spelling (`maxRows`, `countryName`, `temperaturePrefs`, `kmh`) because the coder must use the same names. A value the body rules forbid verbatim (`600dp`, `#FF5733`, `timezone=auto`, a framework type) is therefore rewritten, and G2 does not require it token by token.
|
|
116
116
|
|
|
@@ -82,9 +82,11 @@ The supplied UTG workspace stays outside the run root and is always read-only; i
|
|
|
82
82
|
**Key deliverables**:
|
|
83
83
|
|
|
84
84
|
- `specs.json`: the published manifest of every SPEC in deterministic page-batch order — `<run-directory>/generation/specs/specs.json` (idx anchor root).
|
|
85
|
-
- `N × <feature>-SPEC.md`: platform-neutral HarmonyOS implementation specifications — `<run-directory>/generation/specs/<idx>/<feature>-SPEC.md`, re-published page-grouped at `<run-directory>/generation/pages/<page>/<feature>-SPEC.md` by Step 5b.
|
|
85
|
+
- `N × <feature>-SPEC.md`: platform-neutral HarmonyOS implementation specifications — `<run-directory>/generation/specs/<idx>/<feature>-SPEC.md`, re-published page-grouped at `<run-directory>/generation/pages/<page>/<feature>-SPEC.md` by Step 5b. Every SPEC carries a `## Data Contract` section: one six-key block (`Field`/`Type`/`Byte length`/`Range`/`Sample`/`Semantic source`) per external field, or the single line `No external data`. `check_spec.ts` rejects the SPEC when the section is missing, misplaced, or incomplete.
|
|
86
86
|
- `pages/`: the page-grouped re-publication of the same SPECs for page-oriented consumers (`a2h-spec-design-pipeline` groups by the spec file's parent directory) — `<run-directory>/generation/pages/<page>/<feature>-SPEC.md` plus its own `specs.json` (so-ids re-minted in page order — a fresh campaign key, never swapped in mid-pipeline).
|
|
87
87
|
|
|
88
|
+
**Migration for existing SPECs.** The data-contract section is a hard gate: a SPEC generated before it existed fails `check_spec.ts` when the run is resumed or re-published. That is intentional, not an accident. Before rerunning the gate, either regenerate the SPEC or add the single line `No external data` when it reads no external data, or add its field blocks. New runs generate the section automatically.
|
|
89
|
+
|
|
88
90
|
**Source provenance in every published SPEC.** `collect-specs` appends one `## Source locations`
|
|
89
91
|
section at the end of every SPEC. It is the only place a source path may appear: the body stays
|
|
90
92
|
platform-neutral and carries no `file:line` (`check_spec`'s `code-anchor-leak` rule), so the section
|
|
@@ -121,10 +121,13 @@ and represents an interaction or display behavior added by source review:
|
|
|
121
121
|
folded across Areas into the same sidecar entry share a name, L2 keeps the first declared one, drops the later one and records an
|
|
122
122
|
`INVALID_AGENT_OUTPUT` diagnostic — add a suffix to one of them and rerun the gate and `finalize`;
|
|
123
123
|
- write the SPEC at `specs/<stem>-SPEC.md` (H1 is `# <stem>SPEC`, `## UI Sequence` is `title` verbatim,
|
|
124
|
-
|
|
124
|
+
`## Data Contract` carries `Field`/`Type`/`Byte length`/`Range`/`Sample`/`Semantic source` for every external
|
|
125
|
+
field, or the single line `No external data`, and the body is written according to the inlined resident rules and the gate list);
|
|
125
126
|
- `owner` is a four-variant union: by default `area` (the page owner's feature SPEC; there may be several); for local bindings
|
|
126
127
|
`controlGroup` (by `controlGroupKey`), `discovery` (by `discoveryKey`) or
|
|
127
|
-
`agent-added` (carrying its own `identityAnchors`); `citations` ≥1 with verifiable line numbers.
|
|
128
|
+
`agent-added` (carrying its own `identityAnchors`); `citations` ≥1 with verifiable line numbers. When the
|
|
129
|
+
SPEC has a `## Data Contract`, `citations` must include the contract definition file (schema / proto / codec /
|
|
130
|
+
parser / date-format table); it is published under `## Source locations` and review checks it there.
|
|
128
131
|
|
|
129
132
|
The resident rules (the body of `worker-rules.md`) and the gate list (required + read-on-hit) are **embedded** into `task.md` by prepare;
|
|
130
133
|
the SPEC's mechanical validation rules are in `check_spec.ts`.
|
|
@@ -159,7 +162,16 @@ the SPEC's mechanical validation rules are in `check_spec.ts`.
|
|
|
159
162
|
**This applies even when the interaction surface is empty.** Display behaviors without a supporting citation must not be invented. The machine cannot decide R6 ("was something missed") —
|
|
160
163
|
a miss raises no error, but the task is not complete.
|
|
161
164
|
- **R6a Displayed-value derivation (required)**: every numeric/text field states its source field, time window, aggregation, rounding, sign and unit
|
|
162
|
-
conversion; writing only "shows N" or "integer difference" is not allowed.
|
|
165
|
+
conversion; writing only "shows N" or "integer difference" is not allowed. The rule must determine exactly one result: when a different order
|
|
166
|
+
gives a different number (round each operand then subtract / subtract then round), when the rounding mode changes the value (half-up,
|
|
167
|
+
truncation, negative halves), or when the time basis changes the slot (nearest slot or floor, which timezone), state that choice; give every
|
|
168
|
+
derived numeric field one worked example (concrete input → concrete output), and when you cannot, or the example disagrees with the rule,
|
|
169
|
+
reread the source and rewrite it. List the fields one by one; never summarise them as "every record" or "each value". A derivation rule shared
|
|
170
|
+
within one flow is written once and referenced by later fields.
|
|
171
|
+
- **R6b State space (required)**: a page-flow SPEC writes `## 状态清单` between `## UI序列` and the first scenario, one row per state (`- <state>: <what the user sees>`).
|
|
172
|
+
All eight states need a row: first frame, loading, success, empty data, insufficient data, failure, non-default locale, return after leaving. A state this page
|
|
173
|
+
cannot reach still gets a row — `- Loading: not applicable (why)` — never omitted and never blank. Write the visible result, or "keeps the last successful
|
|
174
|
+
data"; never "otherwise nothing updates". The first frame and the non-default locale carry the real literal.
|
|
163
175
|
- **R7 SPEC uniqueness (mechanically validated by `check-fusion`)**: there may be **several** `owner.kind:"area"` SPECs (the page owner
|
|
164
176
|
splits by user-visible flow, e.g. the eco batch for one page writes several SPECs); every `controlGroup`/`discovery` has **at most one**
|
|
165
177
|
`specRecord` (duplicates fail); `agent-added` records are unlimited in number (`stem` must still be unique). An undeclared
|
|
@@ -18,5 +18,6 @@ Read this file at Step 2.4 and run every check below against the evidence collec
|
|
|
18
18
|
12. **Transfer-contract completeness** — every contract 2.5 will state has anchored evidence (direction, endpoint or frame, field order, encoding, branch value, timeout/retry, callback payload, repeat, unregister behavior) collected under the transfer-side literals. 2.2's collection step, not `interaction`/`data_flow`, is the source of truth. Carrier details stay distinguishable from business protocol so synthesis cannot copy Binder/Parcel/Bundle mechanics as product protocol. An unanchored contract field fails.
|
|
19
19
|
13. **No view description in synthesis-bound evidence** — layout and visual attributes are collected as raw evidence, but a displayed value whose meaning rests on a size, position or color ("this column is on the right", as a value's derivation) is not evidence of what the user sees: re-derive it as a source or condition claim, or drop it. Since 2.5 emits none of these values, a claim only a layout attribute supports has no spec-side form and fails here rather than leaking downstream (Principle 10).
|
|
20
20
|
14. **Motion timing is captured** — for every transition the source implements (a page or panel entering/leaving, expand/collapse, slide-out), the evidence carries the duration the source actually fixes and the order in which concurrent animations start. A spring- or velocity-driven animation carries its feel plus the fact that it has no fixed duration — never an invented number. A duration that is only a platform default (`@android:integer/config_mediumAnimTime`, a `windowAnimationStyle` tier) is not a project fact: resolve it through `references/library-evidence.md` and mark it platform-derived, or record that the source leaves the timing to the platform and give no number. Also record whether the source pins an interpolator; a spring is an interpolator too, so "the source pins no interpolator" is itself a fact worth writing down. This evidence is published in the spec (the Principle 10 exception in `references/synthesis-rules.md`) as duration and ordering — an easing description is optional, and its absence is not a failure — so a transition whose timing was never collected cannot be filled in at synthesis and fails here.
|
|
21
|
+
15. **Data contract completeness** — every external field the SPEC reads has a `## Data Contract` block with all six keys (`Field`/`Type`/`Byte length`/`Range`/`Sample`/`Semantic source`), and each value is source-backed rather than guessed. The SPEC's `citations` must include the file that **defines** that contract (schema, proto, codec, parser or date-format table) — it is published under `## Source locations`, and must point at the definition, not only at the widget that consumes it. The `Sample` value must be one the scenario branch actually consumes. A SPEC that reads no external data carries the single line `No external data`. Missing block, missing contract-file citation, a sample that does not match the branch, or a guessed width/format fails here.
|
|
21
22
|
|
|
22
23
|
If evidence is insufficient, query again or weaken/remove the unsupported claim. Do not create a placeholder value.
|
|
@@ -13,6 +13,22 @@ Display of the card at the top of the Detail page.
|
|
|
13
13
|
|
|
14
14
|
Detail-Detail page-Detail card
|
|
15
15
|
|
|
16
|
+
## Data Contract
|
|
17
|
+
|
|
18
|
+
- Field: title
|
|
19
|
+
- Type: string
|
|
20
|
+
- Byte length: variable
|
|
21
|
+
- Range: non-empty text; falls back to the local original title when missing
|
|
22
|
+
- Sample: Nocturne
|
|
23
|
+
- Semantic source: object title field definition
|
|
24
|
+
|
|
25
|
+
- Field: coverUrl
|
|
26
|
+
- Type: string
|
|
27
|
+
- Byte length: variable
|
|
28
|
+
- Range: absolute address; empty when missing
|
|
29
|
+
- Sample: https://cdn.example.com/cover/42.jpg
|
|
30
|
+
- Semantic source: object cover field definition
|
|
31
|
+
|
|
16
32
|
## Scenario 1
|
|
17
33
|
|
|
18
34
|
### Scenario Overview
|
|
@@ -10,6 +10,22 @@ Sync the current business object to the cloud.
|
|
|
10
10
|
|
|
11
11
|
Settings-Sync-Sync now
|
|
12
12
|
|
|
13
|
+
## Data Contract
|
|
14
|
+
|
|
15
|
+
- Field: code
|
|
16
|
+
- Type: int32
|
|
17
|
+
- Byte length: 4
|
|
18
|
+
- Range: 0 means success; 1001 means business failure
|
|
19
|
+
- Sample: 0
|
|
20
|
+
- Semantic source: sync API response field definition
|
|
21
|
+
|
|
22
|
+
- Field: data.syncId
|
|
23
|
+
- Type: string
|
|
24
|
+
- Byte length: variable
|
|
25
|
+
- Range: non-empty sync identifier
|
|
26
|
+
- Sample: sync-20261112-0001
|
|
27
|
+
- Semantic source: sync API response field definition
|
|
28
|
+
|
|
13
29
|
## Scenario 1
|
|
14
30
|
|
|
15
31
|
### Scenario Overview
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Spec few-shot samples
|
|
2
2
|
|
|
3
|
-
Read this file at Step 2.5 after `references/synthesis-rules.md`. The samples illustrate **scenario decomposition granularity and wording**, and show where `## UI Sequence`
|
|
3
|
+
Read this file at Step 2.5 after `references/synthesis-rules.md`. The samples illustrate **scenario decomposition granularity and wording**, and show where `## UI Sequence` and `## Data Contract` sit: `## UI Sequence` is one line directly under the requirement description, `## Data Contract` follows it and precedes `## Scenario 1`. They are truncated for brevity — a real spec ends with its last scenario and carries no footer.
|
|
4
4
|
|
|
5
5
|
Every value below is concrete. `<...>` placeholders never appear in an emitted spec: a value that has no source evidence becomes weakened spec wording, never a bracketed stub (see the No-Vagueness Rules in `references/synthesis-rules.md`).
|
|
6
6
|
|
|
@@ -14,6 +14,10 @@ Create a new playlist
|
|
|
14
14
|
|
|
15
15
|
Playlists-Playlists page-New playlist
|
|
16
16
|
|
|
17
|
+
## Data Contract
|
|
18
|
+
|
|
19
|
+
No external data
|
|
20
|
+
|
|
17
21
|
## Scenario 1
|
|
18
22
|
|
|
19
23
|
### Scenario Overview
|
|
@@ -56,6 +56,7 @@ The spec is a contract for reimplementation. A statement that cannot be turned i
|
|
|
56
56
|
| handle accordingly / perform the necessary validation | Validate in order: trim leading/trailing whitespace → empty check → length ≤ 100 |
|
|
57
57
|
| store locally | Written to the playlist persistent storage; still in effect after re-entering the page |
|
|
58
58
|
| any sensible default | The switch is off by default; at most 20 items per page |
|
|
59
|
+
| otherwise nothing updates / all other cases leave it unchanged | Give every state its own visible result; for the first frame and a non-default locale, write the actual literal from the resources |
|
|
59
60
|
| the page refreshes | The song count of that playlist refreshes in real time on the playlist list page, the playlist detail page and the playlist picker dialog |
|
|
60
61
|
| call the cloud interface / make a network request | `POST https://...`, request-body fields `...`; the next step is decided by the response field `code` |
|
|
61
62
|
| send data / send per protocol | State the direction, frame/message fields, command/version, length, payload, field order and encoding |
|
|
@@ -71,7 +72,26 @@ The spec is a contract for reimplementation. A statement that cannot be turned i
|
|
|
71
72
|
|
|
72
73
|
**Also banned** (Principle 7): returns an error code / returns -1 / throws an exception / the interface returns / input parameters / return value — replace each with the user-visible outcome or the concrete data-transfer behavior. If a failure has no user-visible outcome at all, it does not belong in a UI spec.
|
|
73
74
|
|
|
74
|
-
**Also banned** (Principle 10): width/height/size/left-right/top-bottom/spacing/margin/alignment/z-order/corner radius/font size/font weight/line height/color/background/shadow and their concrete values (`150dp`, `14sp`, `#FF5722`, `marginStart 16dp`). State what is shown and where it comes from; the visual form is the implementer's own design decision. A layout value quoted from the source is a leakage of evidence into the spec, not extra precision.
|
|
75
|
+
**Also banned** (Principle 10): width/height/size/left-right/top-bottom/spacing/margin/alignment/z-order/corner radius/font size/font weight/line height/color/background/shadow and their concrete values (`150dp`, `14sp`, `#FF5722`, `marginStart 16dp`). State what is shown and where it comes from; the visual form is the implementer's own design decision. A layout value quoted from the source is a leakage of evidence into the spec, not extra precision. Motion duration is the one exception (see above): state it in portable terms such as "0.35 seconds"; absolute offsets, curve names and resource/property names still stay out of the body. The `Byte length` key of `## Data Contract` is the other exception: it is the byte width of an **external data field**, never a view size.
|
|
76
|
+
|
|
77
|
+
## Data Contract (required in every SPEC)
|
|
78
|
+
|
|
79
|
+
`## Data Contract` sits after `## UI Sequence` and before the first scenario, with one block per external field (API response, cache, database, file, setting, location result):
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
- Field: variable
|
|
83
|
+
- Type: uint8
|
|
84
|
+
- Byte length: 1
|
|
85
|
+
- Range: 0-255
|
|
86
|
+
- Sample: 56
|
|
87
|
+
- Semantic source: interface protocol field definition
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- Six fixed keys: `Field`, `Type`, `Byte length`, `Range`, `Sample`, `Semantic source`; a missing key, a repeated key or an empty value is an error.
|
|
91
|
+
- Type and width are source contracts, not guesses: read the interface definition, schema, serializer/deserializer or a real response sample. If they cannot be found, report the gap per Principle 15 — never guess "usually 12 digits" or "usually read as int32".
|
|
92
|
+
- `Sample` must be a real, checkable value (a source literal or a collected response) and must appear in the branch the scenario steps rely on.
|
|
93
|
+
- `Semantic source` is a neutral name (e.g. "date-time format definition", "unit enum definition"), never a platform filename, `file:line` or framework symbol. The contract definition file must be included in this SPEC's `citations` (published under `## Source locations`); review confirms that citation points at the contract definition, not only at the UI implementation.
|
|
94
|
+
- With no external data, write the single line `No external data`; never omit or empty the section.
|
|
75
95
|
|
|
76
96
|
---
|
|
77
97
|
|