@buaa_smat/hometrans 26.0.7 → 26.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/agents/a2h-executor.md +37 -0
  2. package/env-requirements.json +15 -1
  3. package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  4. package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  5. package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  6. package/i18n/skills/a2h-app-migrate/SKILL.md +2 -2
  7. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +27 -4
  8. package/i18n/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  9. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  10. package/i18n/skills/a2h-batch-ui-align/SKILL.md +7 -7
  11. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  12. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  13. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  14. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  15. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  16. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  17. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  18. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  19. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  20. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  21. package/i18n/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  22. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  23. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  24. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  25. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  26. package/i18n/skills/a2h-page-specgen/SKILL.md +1 -1
  27. package/i18n/skills/a2h-page-specgen/references/gates.md +3 -1
  28. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +11 -11
  29. package/i18n/skills/a2h-page-specgen/references/spec-template.md +3 -3
  30. package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  31. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  32. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +144 -0
  33. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +11 -11
  34. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +11 -11
  35. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +11 -11
  36. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +11 -11
  37. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  38. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  39. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +11 -11
  40. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +11 -11
  41. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +11 -11
  42. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +11 -11
  43. package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  44. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  45. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +132 -3
  46. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  47. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  48. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  49. package/i18n/skills/a2h-utg-static/SKILL.md +2 -0
  50. package/package.json +1 -1
  51. package/platforms/atomcode/agents/a2h-executor.frontmatter.md +6 -0
  52. package/platforms/codebuddy/agents/a2h-executor.frontmatter.md +5 -0
  53. package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  54. package/platforms/deveco/agents/a2h-executor.frontmatter.md +7 -0
  55. package/platforms/deveco/agents/build-fixer.frontmatter.md +0 -2
  56. package/platforms/deveco/agents/code-reviewer.frontmatter.md +0 -2
  57. package/platforms/deveco/agents/model-render-worker.frontmatter.md +0 -2
  58. package/platforms/deveco/agents/model-worker.frontmatter.md +0 -2
  59. package/platforms/deveco/agents/specgen-worker.frontmatter.md +0 -2
  60. package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  61. package/platforms/opencode/agents/a2h-executor.frontmatter.md +7 -0
  62. package/platforms/opencode/agents/build-fixer.frontmatter.md +0 -2
  63. package/platforms/opencode/agents/code-reviewer.frontmatter.md +0 -2
  64. package/platforms/opencode/agents/model-render-worker.frontmatter.md +0 -2
  65. package/platforms/opencode/agents/model-worker.frontmatter.md +0 -2
  66. package/platforms/opencode/agents/specgen-worker.frontmatter.md +0 -2
  67. package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  68. package/skills/a2h-app-migrate/SKILL.md +29 -3
  69. package/skills/a2h-app-migrate/references/host-rules.md +33 -0
  70. package/skills/a2h-app-migrate/references/workflow.yaml +24 -4
  71. package/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  72. package/skills/a2h-app-migrate/test/test_executor_header_sync.mjs +78 -0
  73. package/skills/a2h-app-migrate/test/test_opencode_depth.mjs +312 -0
  74. package/skills/a2h-app-migrate/tools/dag.mjs +267 -0
  75. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  76. package/skills/a2h-batch-ui-align/SKILL.md +7 -7
  77. package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  78. package/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  79. package/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  80. package/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  81. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  82. package/skills/a2h-batch-ui-align/references/host-dispatch.md +5 -5
  83. package/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  84. package/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  85. package/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  86. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  87. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  88. package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +3 -2
  89. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +139 -23
  90. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +32 -8
  91. package/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  92. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  93. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  94. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  95. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +82 -0
  96. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  97. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +184 -2
  98. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +33 -0
  99. package/skills/a2h-batch-ui-align/scripts/tests/interactions.test.mjs +258 -0
  100. package/skills/a2h-page-specgen/SKILL.md +1 -1
  101. package/skills/a2h-page-specgen/references/evidence.md +15 -0
  102. package/skills/a2h-page-specgen/references/gates.md +3 -1
  103. package/skills/a2h-page-specgen/references/scenario-authoring.md +10 -10
  104. package/skills/a2h-page-specgen/references/spec-template.md +2 -2
  105. package/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  106. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  107. package/skills/a2h-page-specgen/scripts/gate.mjs +141 -0
  108. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +10 -10
  109. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +10 -10
  110. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +10 -10
  111. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +10 -10
  112. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  113. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  114. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +10 -10
  115. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +10 -10
  116. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +10 -10
  117. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +10 -10
  118. package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  119. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  120. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +104 -3
  121. package/skills/a2h-resource-convert/references/conversion-rules.md +2 -0
  122. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  123. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +42 -0
  124. package/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  125. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  126. package/skills/a2h-spec-design-pipeline/references/execution-model.md +2 -2
  127. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +5 -1
  128. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
  129. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
  130. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +2 -1
  131. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +3 -1
  132. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-cn.md +105 -0
  133. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-en.md +122 -0
  134. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +4 -4
  135. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIV2ObservationCheck.js +1862 -0
  136. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +2 -0
  137. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
  138. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +15 -2
  139. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +20 -4
  140. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_v2_observation.ts +284 -0
  141. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +32 -0
  142. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +22 -1
  143. package/skills/a2h-utg-static/SKILL.md +2 -0
  144. package/skills/a2h-utg-static/references/extractors.md +16 -0
  145. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +22 -1
  146. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +4 -0
  147. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +15 -0
  148. package/skills/a2h-utg-static/scripts/tests/test_view_attachments.mjs +330 -0
  149. package/skills/a2h-utg-static/scripts/view_attachments.mjs +465 -0
  150. package/platforms/codebuddy/agents/build-fixer.frontmatter.md +0 -5
  151. package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +0 -5
  152. package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +0 -5
  153. package/platforms/codebuddy/agents/model-worker.frontmatter.md +0 -5
  154. package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +0 -5
@@ -392,6 +392,106 @@ test("outbound resolution rejects labels, unrelated files, duplicates, and unver
392
392
  && unknown.cause === "outbound-implementation-source-unit-unavailable"));
393
393
  });
394
394
 
395
+ test("outbound resolves a target implemented in its declared_at file when no FQN is registered", () => {
396
+ writeSource("src/region.js", ["export const RegionPickerModal = () => {};"]);
397
+ const inventory = buildPages({
398
+ nodes: [
399
+ { id: "page:Source", kind: "activity", label: "Source", declared_at: "src/source.js" },
400
+ { id: "overlay:Region", kind: "sheet", label: "RegionPickerModal", declared_at: "src/region.js:55" },
401
+ ],
402
+ links: [{ source: "page:Source", target: "overlay:Region", trigger: "onClick@src/source.js:307" }],
403
+ });
404
+ const db = new DatabaseSync(":memory:");
405
+ db.exec(`
406
+ CREATE TABLE nodes (
407
+ id TEXT PRIMARY KEY, kind TEXT, name TEXT, qualified_name TEXT,
408
+ file_path TEXT, start_line INTEGER
409
+ );
410
+ CREATE TABLE edges (
411
+ id INTEGER PRIMARY KEY, source TEXT, target TEXT, kind TEXT, line INTEGER
412
+ );
413
+ `);
414
+ db.prepare("INSERT INTO nodes (id, kind, name, qualified_name, file_path, start_line) VALUES (?, ?, ?, ?, ?, ?)")
415
+ .run("region", "class", "RegionPickerModal", "example.RegionPickerModal", "src/region.js", 55);
416
+ const entries = discoverEntryEvidence({
417
+ pages: inventory.pages, db, sourceProject: root,
418
+ query: ({ command }) => ({
419
+ status: "ok",
420
+ items: command === "callees"
421
+ ? [{ name: "RegionPickerModal", qualified_name: "example.RegionPickerModal", file_path: "src/region.js", line: 307 }]
422
+ : [],
423
+ truncated: false,
424
+ reason: null,
425
+ }),
426
+ });
427
+ const out = entries.get("page:Source").outbound[0];
428
+ assert.equal(out.status, "resolved");
429
+ assert.deepEqual(out.implementation, { qualified_name: "example.RegionPickerModal", file_path: "src/region.js" });
430
+ db.close();
431
+ });
432
+
433
+ test("outbound distinguishes a missing implementation identity from an unmatched target", () => {
434
+ const inventory = buildPages({
435
+ nodes: [
436
+ { id: "page:Source", kind: "activity", label: "Source", declared_at: "src/source.js" },
437
+ { id: "overlay:Ghost", kind: "sheet", label: "Ghost", declared_at: "src/ghost.js:1" },
438
+ ],
439
+ links: [{ source: "page:Source", target: "overlay:Ghost", trigger: "onClick@src/source.js:307" }],
440
+ });
441
+ const entries = discoverEntryEvidence({
442
+ pages: inventory.pages, db: null, sourceProject: root,
443
+ query: ({ command }) => ({
444
+ status: "ok",
445
+ items: command === "callees"
446
+ ? [{ name: "Ghost", qualified_name: "example.Ghost", file_path: "src/ghost.js", line: 307 }]
447
+ : [],
448
+ truncated: false,
449
+ reason: null,
450
+ }),
451
+ });
452
+ const out = entries.get("page:Source").outbound[0];
453
+ assert.equal(out.status, "partial");
454
+ assert.equal(out.reason, "outbound-implementation-unavailable");
455
+ });
456
+
457
+ test("outbound keeps the exact FQN match when the declared_at file has a same-named node", () => {
458
+ writeSource("src/home.js", ["export const Home = () => {};"]);
459
+ const inventory = buildPages({
460
+ nodes: [
461
+ { id: "page:Source", kind: "activity", label: "Source", declared_at: "src/source.js" },
462
+ { id: "overlay:Home", kind: "sheet", label: "Home", fqn: "x.HomeScreen", declared_at: "src/home.js" },
463
+ ],
464
+ links: [{ source: "page:Source", target: "overlay:Home", trigger: "onClick@src/source.js:307" }],
465
+ });
466
+ const db = new DatabaseSync(":memory:");
467
+ db.exec(`
468
+ CREATE TABLE nodes (
469
+ id TEXT PRIMARY KEY, kind TEXT, name TEXT, qualified_name TEXT,
470
+ file_path TEXT, start_line INTEGER
471
+ );
472
+ CREATE TABLE edges (
473
+ id INTEGER PRIMARY KEY, source TEXT, target TEXT, kind TEXT, line INTEGER
474
+ );
475
+ `);
476
+ db.prepare("INSERT INTO nodes (id, kind, name, qualified_name, file_path, start_line) VALUES (?, ?, ?, ?, ?, ?)")
477
+ .run("home", "class", "Home", "x.Home", "src/home.js", 10);
478
+ const entries = discoverEntryEvidence({
479
+ pages: inventory.pages, db, sourceProject: root,
480
+ query: ({ command }) => ({
481
+ status: "ok",
482
+ items: command === "callees"
483
+ ? [{ name: "Home", qualified_name: "x.Home", file_path: "src/home.js", line: 307 }]
484
+ : [],
485
+ truncated: false,
486
+ reason: null,
487
+ }),
488
+ });
489
+ const out = entries.get("page:Source").outbound[0];
490
+ assert.equal(out.status, "partial");
491
+ assert.equal(out.reason, "outbound-target-unresolved");
492
+ db.close();
493
+ });
494
+
395
495
  function orderingInventory(reverse = false) {
396
496
  const nodes = [
397
497
  { id: "page:Source", kind: "activity", label: "Source", declared_at: "src/source.js" },
@@ -634,9 +634,10 @@ test("G2 requires a parameter's default and source in the merged steps", () => {
634
634
  response_fields: ["data.list[].id"],
635
635
  }],
636
636
  };
637
- d.scenarios[0].steps.push("使用 GET 请求 https://api.example.com/forecast,参数 lat 默认取 0,来源为本地存储,响应字段 data.list[].id 逐项展示");
637
+ d.scenarios[0].steps.push("使用 GET 请求 https://api.example.com/forecast,查询参数按下表:\n```text\n天气预报查询参数\n字段 字段名:lat 类型/编码方式:数值 默认值:0 是否传:必传\n```\n来源:lat 取本地存储;响应字段 data.list[].id 逐项展示");
638
638
  const complete = gateDraft(d, { mdText: renderDraft(d) });
639
639
  assert.deepEqual(complete.failures, []);
640
+ assert.ok(!complete.warnings.some((w) => w.gate === "G2"), JSON.stringify(complete.warnings));
640
641
 
641
642
  d.scenarios[0].steps[d.scenarios[0].steps.length - 1] =
642
643
  "使用 GET 请求 https://api.example.com/forecast,参数 lat 来源为本地存储,响应字段 data.list[].id 逐项展示";
@@ -647,6 +648,105 @@ test("G2 requires a parameter's default and source in the merged steps", () => {
647
648
  assert.doesNotMatch(failure.message, /endpoints\/source/);
648
649
  });
649
650
 
651
+ test("G2 requires the four-label field table when an endpoint declares body params", () => {
652
+ const bodyContracts = () => ({
653
+ endpoints: [{
654
+ name: "订单分页", method: "POST", url: "https://api.example.com/order/page",
655
+ params: [
656
+ { in: "body", name: "page", type: "int", required: true, default: "1", source: "当前页码" },
657
+ { in: "body", name: "size", type: "int", required: true, default: "10", source: "每页数量" },
658
+ ],
659
+ response_fields: ["data.list[].id"],
660
+ }],
661
+ });
662
+ const prose = "使用 POST 请求 https://api.example.com/order/page,page 默认取 1,来源为当前页码;size 默认取 10,来源为每页数量;响应字段 data.list[].id 逐项展示";
663
+
664
+ const withoutTable = goodDraft();
665
+ withoutTable.scenarios[0].contracts = bodyContracts();
666
+ withoutTable.scenarios[0].steps.push(prose);
667
+ const rejected = gateDraft(withoutTable, { mdText: renderDraft(withoutTable) });
668
+ const failure = rejected.failures.find((f) => f.gate === "G2" && /四段字段表/.test(f.message));
669
+ assert.ok(failure, JSON.stringify(rejected.failures));
670
+
671
+ const withTable = goodDraft();
672
+ withTable.scenarios[0].contracts = bodyContracts();
673
+ withTable.scenarios[0].steps.push(
674
+ "请求体按序列化键序写成下表:\n```text\n订单分页请求体\n字段 字段名:page 类型/编码方式:int 默认值:1 是否传:必传\n字段 字段名:size 类型/编码方式:int 默认值:10 是否传:必传\n```\n" + prose);
675
+ const accepted = gateDraft(withTable, { mdText: renderDraft(withTable) });
676
+ assert.deepEqual(accepted.failures, []);
677
+ assert.ok(!accepted.warnings.some((w) => w.gate === "G2"), JSON.stringify(accepted.warnings));
678
+ });
679
+
680
+ test("G2 requires the four-label field table for query params too", () => {
681
+ const queryContracts = () => ({
682
+ endpoints: [{
683
+ name: "天气预报", method: "GET", url: "https://api.example.com/forecast",
684
+ params: [{ in: "query", name: "lat", type: "数值", required: true, default: "0", source: "本地存储" }],
685
+ response_fields: ["temperature"],
686
+ }],
687
+ });
688
+ const prose = "使用 GET 请求 https://api.example.com/forecast,响应字段 temperature 逐项展示";
689
+
690
+ const withoutTable = goodDraft();
691
+ withoutTable.scenarios[0].contracts = queryContracts();
692
+ withoutTable.scenarios[0].steps.push(prose + ",参数 lat 默认取 0,来源为本地存储");
693
+ const rejected = gateDraft(withoutTable, { mdText: renderDraft(withoutTable) });
694
+ const failure = rejected.failures.find((f) => f.gate === "G2" && /四段字段表/.test(f.message));
695
+ assert.ok(failure, JSON.stringify(rejected.failures));
696
+
697
+ const withTable = goodDraft();
698
+ withTable.scenarios[0].contracts = queryContracts();
699
+ withTable.scenarios[0].steps.push(
700
+ "查询参数按下表:\n```text\n天气预报查询参数\n字段 字段名:lat 类型/编码方式:数值 默认值:0 是否传:必传\n```\n来源:lat 取本地存储;" + prose);
701
+ const accepted = gateDraft(withTable, { mdText: renderDraft(withTable) });
702
+ assert.deepEqual(accepted.failures, []);
703
+ assert.ok(!accepted.warnings.some((w) => w.gate === "G2"), JSON.stringify(accepted.warnings));
704
+ });
705
+
706
+ test("G2 accepts full-width colons in the field table", () => {
707
+ const d = goodDraft();
708
+ d.scenarios[0].contracts = {
709
+ endpoints: [{
710
+ name: "天气预报", method: "GET", url: "https://api.example.com/forecast",
711
+ params: [{ in: "query", name: "lat", type: "数值", required: true, default: "0", source: "本地存储" }],
712
+ response_fields: ["temperature"],
713
+ }],
714
+ };
715
+ d.scenarios[0].steps.push("使用 GET 请求 https://api.example.com/forecast,查询参数按下表:\n```text\n天气预报查询参数\n字段 字段名:lat 类型/编码方式:数值 默认值:0 是否传:必传\n```\n来源:lat 取本地存储;响应字段 temperature 逐项展示");
716
+ const r = gateDraft(d, { mdText: renderDraft(d) });
717
+ assert.deepEqual(r.failures, []);
718
+ assert.ok(!r.warnings.some((w) => w.gate === "G2"), JSON.stringify(r.warnings));
719
+ });
720
+
721
+ test("G2 warns when steps describe a body request without an endpoint declaration", () => {
722
+ const d = goodDraft();
723
+ d.scenarios[0].steps.push("使用 POST 请求 https://api.example.com/order/page,请求体字段 page 与 size");
724
+ const r = gateDraft(d, { mdText: renderDraft(d) });
725
+ assert.ok(r.warnings.some((w) => w.gate === "G2" && /请求体/.test(w.message) && /endpoints/.test(w.message)),
726
+ JSON.stringify(r.warnings));
727
+ });
728
+
729
+ test("G2 body-request warning is closed by an explicit no-body statement", () => {
730
+ const d = goodDraft();
731
+ d.scenarios[0].steps.push("使用 POST 请求 https://api.example.com/order/page,该请求不携带请求体字段");
732
+ const r = gateDraft(d, { mdText: renderDraft(d) });
733
+ assert.ok(!r.warnings.some((w) => w.gate === "G2" && /请求体/.test(w.message)), JSON.stringify(r.warnings));
734
+ });
735
+
736
+ test("G2 warns about a body field table with no endpoint declaration", () => {
737
+ const d = goodDraft();
738
+ d.scenarios[0].steps.push("请求体如下:\n```text\n订单分页请求体\n字段 字段名:page 类型/编码方式:int 默认值:1 是否传:必传\n```");
739
+ const r = gateDraft(d, { mdText: renderDraft(d) });
740
+ assert.ok(r.warnings.some((w) => w.gate === "G2" && /字段表/.test(w.message)), JSON.stringify(r.warnings));
741
+ });
742
+
743
+ test("G2 does not warn about a body-less GET request", () => {
744
+ const d = goodDraft();
745
+ d.scenarios[0].steps.push("使用 GET 请求 https://api.example.com/forecast,响应字段 temperature 逐项展示");
746
+ const r = gateDraft(d, { mdText: renderDraft(d) });
747
+ assert.ok(!r.warnings.some((w) => w.gate === "G2" && /请求体/.test(w.message)), JSON.stringify(r.warnings));
748
+ });
749
+
650
750
  test("G2 treats empty page-level contracts declarations as absent", () => {
651
751
  for (const value of [null, {}, []]) {
652
752
  const d = goodDraft();
@@ -712,16 +812,17 @@ test("G2 checks endpoint method, url, parameter names and response fields", () =
712
812
  }],
713
813
  };
714
814
  d.scenarios[0].steps.push(
715
- "使用 GET 请求 https://api.example.com/weather,参数 latitude 与 temperature_unit,响应字段 current_temperature 与 weather_code",
815
+ "使用 GET 请求 https://api.example.com/weather,查询参数按下表:\n```text\n天气查询参数\n字段 字段名:latitude 类型/编码方式:数值 默认值:0 是否传:必传\n```\n响应字段 current_temperature 与 weather_code",
716
816
  );
717
817
  const complete = gateDraft(d, { mdText: renderDraft(d) });
718
818
  assert.deepEqual(complete.failures, []);
819
+ assert.ok(!complete.warnings.some((w) => w.gate === "G2"), JSON.stringify(complete.warnings));
719
820
 
720
821
  // Identifier tokens need a boundary: `latitudeOf` must not satisfy `latitude`.
721
822
  d.scenarios[0].steps[d.scenarios[0].steps.length - 1] =
722
823
  "使用 GET 请求 https://api.example.com/weather,参数 latitudeOf 与 temperature_unit,响应字段 current_temperature 与 weather_code";
723
824
  const boundary = gateDraft(d, { mdText: renderDraft(d) });
724
- assert.ok(boundary.failures.some((f) => f.gate === "G2" && /latitude/.test(f.message)),
825
+ assert.ok(boundary.failures.some((f) => f.gate === "G2" && f.message.includes("endpoints/param: latitude")),
725
826
  JSON.stringify(boundary.failures));
726
827
  });
727
828
 
@@ -480,6 +480,8 @@ Note: The `monochrome` element has no HarmonyOS `layered-image` equivalent, so o
480
480
 
481
481
  **Common pattern**: `mipmap-anydpi-v26/` is extremely common in Android projects. The qualifier `anydpi-v26` should be parsed as `anydpi` (→ `base`) + `v26` (→ strip). The files inside are typically `<adaptive-icon>` XMLs — process them by reading the XML root element to classify the content type, not by rejecting based on the directory qualifier.
482
482
 
483
+ **Density PNG fallbacks of a vector are dropped**: when `drawable-anydpi[-vNN]/x.xml` is a `<vector>`, the same-named `drawable-<density>/x.png` files are AAPT-generated fallbacks for old devices (Android API 24+ uses the vector). HarmonyOS matches a density qualifier dir before `base/` (资源匹配: 限定词目录优先,找不到才去 base), so copying them would make the device load the PNG instead of `base/media/x.svg` and `.fillColor()` (SVG only) would stop tinting. The converter skips them and records them as unmappable (`vectorFallbacksDropped`). Only a pure density pair is dropped: the anydpi dir carries nothing but `anydpi`/`vNN` (its SVG lands in `base/`) and the PNG dir nothing but a density and `vNN`. A `night`/locale/other qualifier on either side marks a hand-made variant, which is copied as usual. `<animated-vector>` roots do not count (they are not converted to SVG, so their PNGs stay the only HarmonyOS copy).
484
+
483
485
  ### Raw files → rawfile
484
486
 
485
487
  Copy all files from Android `raw/` to HarmonyOS `rawfile/`:
@@ -676,7 +676,7 @@ class Converter {
676
676
  unmappable: 0, skippedQualifierDirs: 0, failed: 0,
677
677
  svgConverted: 0, layeredImages: 0, solidLayersGenerated: 0, safeZoneLayers: 0, uncroppedBitmapIcons: 0, systemColorsResolved: 0,
678
678
  referencesResolved: 0, systemReferencesResolved: 0, fallbacksApplied: 0,
679
- unresolvedPaint: 0, mediaTargetCollisions: 0,
679
+ unresolvedPaint: 0, mediaTargetCollisions: 0, vectorFallbacksDropped: 0,
680
680
  };
681
681
 
682
682
  constructor(resDir: string, harmonyDir: string, dryRun: boolean, uiModule = 'entry', filterSet: Set<string> | null = null) {
@@ -1178,6 +1178,29 @@ class Converter {
1178
1178
  return this.findResXml('drawable', m[1], 'gradient') ?? this.findResXml('drawable', m[1].replace(/\$/g, '_'), 'gradient');
1179
1179
  }
1180
1180
 
1181
+ /**
1182
+ * The `<type>-anydpi[-vNN]/<resName>.xml` `<vector>` whose AAPT density fallback the bitmap in `pngDir` is,
1183
+ * as a res-relative path, or null. Only a pure density pair counts: the anydpi dir may carry nothing but
1184
+ * `anydpi`/`vNN` (so its SVG lands in base/), and `pngDir` nothing but a density and `vNN`. A night/locale/…
1185
+ * qualifier on either side means a hand-made variant that HarmonyOS would otherwise lose (no base/ copy, or no
1186
+ * dark/ look). `<animated-vector>` is excluded: xmlDrawableToSvg cannot convert it, so its PNGs are the only
1187
+ * HarmonyOS copy of the resource.
1188
+ */
1189
+ anydpiVector(type: string, resName: string, pngDir: string): string | null {
1190
+ const quals = (d: string): string[] => d.split('-').slice(1);
1191
+ if (!quals(pngDir).every((q) => (q in DENSITY && DENSITY[q] !== null) || /^v\d+$/.test(q))) return null;
1192
+ for (const d of this.resTypeDirs(type)) {
1193
+ const q = quals(d);
1194
+ if (!q.includes('anydpi') || !q.every((x) => x === 'anydpi' || /^v\d+$/.test(x))) continue;
1195
+ const p = path.join(this.resDir, d, `${resName}.xml`);
1196
+ if (!fs.existsSync(p)) continue;
1197
+ try {
1198
+ if (parseXml(fs.readFileSync(p, 'utf8')).name === 'vector') return `${d}/${resName}.xml`;
1199
+ } catch { /* unparsable: keep the bitmap */ }
1200
+ }
1201
+ return null;
1202
+ }
1203
+
1181
1204
  /** `type` itself and all its qualifier directories (`drawable`, `drawable-v24`…), the unqualified directory first. */
1182
1205
  resTypeDirs(type: string): string[] {
1183
1206
  return fs.readdirSync(this.resDir)
@@ -1948,6 +1971,16 @@ class Converter {
1948
1971
 
1949
1972
  if (IMAGE_EXT.has(ext)) {
1950
1973
  const target = path.join(qdir, 'media', base);
1974
+ const vector = qdir !== 'base' ? this.anydpiVector(type, resName, path.dirname(relFile)) : null;
1975
+ if (vector) {
1976
+ // AAPT's density PNGs for a <vector>: Android (API 24+) picks the anydpi vector over them, but HarmonyOS
1977
+ // resolves a matching density dir before base/, so a copied PNG would hide the SVG (and its fillColor tint).
1978
+ this.counts.vectorFallbacksDropped++;
1979
+ record('N/A', 'unmappable', 'unmapped',
1980
+ `density fallback of res/${vector} (converted to SVG in base/media); copying it would shadow that SVG on HarmonyOS`,
1981
+ 'Image resource');
1982
+ return;
1983
+ }
1951
1984
  if (!this.claimTarget(target, relFile, androidPath, type)) return;
1952
1985
  this.write(target, fs.readFileSync(path.join(this.resDir, relFile)));
1953
1986
  this.counts.mediaCopied++;
@@ -2271,6 +2304,7 @@ class DocWriter {
2271
2304
  p(`- Fallback values applied: ${c.fallbacksApplied}`);
2272
2305
  p(`- SVG paint colors that could not be resolved: ${c.unresolvedPaint}`);
2273
2306
  p(`- HarmonyOS target collisions resolved: ${c.mediaTargetCollisions}`);
2307
+ p(`- Density PNG fallbacks of anydpi vectors dropped: ${c.vectorFallbacksDropped}`);
2274
2308
  p(`- Failed: ${c.failed}`);
2275
2309
  if (this.ctx.icons?.counts) {
2276
2310
  const ic = this.ctx.icons.counts;
@@ -2662,6 +2696,7 @@ function main(): void {
2662
2696
  console.log(` fallbacks applied : ${c.fallbacksApplied}`);
2663
2697
  console.log(` unresolved SVG colors: ${c.unresolvedPaint}`);
2664
2698
  console.log(` target collisions : ${c.mediaTargetCollisions}`);
2699
+ console.log(` vector PNG fallbacks : ${c.vectorFallbacksDropped} dropped`);
2665
2700
  console.log(` failed : ${c.failed}`);
2666
2701
  console.log(` inventory / mapping rows: ${conv.inventory.length} / ${conv.mappings.length}`);
2667
2702
  if (conv.conflicts.length > 0) console.log(` same-name overrides : ${conv.conflicts.length}`);
@@ -180,3 +180,45 @@ test('same_color_name_same_size_different_color_gets_distinct_files', () => {
180
180
  assert.match(out[`base/${a}.svg`], /fafafa/i);
181
181
  assert.match(out[`base/${b}.svg`], /ffffff/i);
182
182
  });
183
+
184
+ test('density_png_fallbacks_of_an_anydpi_vector_are_not_copied', () => {
185
+ // AAPT output for a <vector> on minSdk < 24: anydpi-v24 vector + generated density PNGs. HarmonyOS resolves a
186
+ // matching density dir before base/, so a copied PNG would hide the SVG and defeat .fillColor().
187
+ const out = convert({
188
+ 'drawable-anydpi-v24/ic_tri.xml': vector(24, 24),
189
+ 'drawable-xxhdpi/ic_tri.png': png(4, 4),
190
+ 'drawable-hdpi/ic_tri.png': png(2, 2),
191
+ 'drawable-xxhdpi/ic_photo.png': png(4, 4),
192
+ });
193
+ assert.ok(typeof out['base/ic_tri.svg'] === 'string');
194
+ assert.deepEqual(Object.keys(out).filter((k) => k.endsWith('ic_tri.png')), []);
195
+ // a bitmap with no vector twin is still copied
196
+ assert.deepEqual(out['xxldpi/ic_photo.png'], { w: 4, h: 4 });
197
+ });
198
+
199
+ test('animated_vector_keeps_its_density_pngs', () => {
200
+ // <animated-vector> is not converted to SVG, so its density PNGs are the only HarmonyOS copy of the resource.
201
+ const NS_A = 'xmlns:android="http://schemas.android.com/apk/res/android"';
202
+ const out = convert({
203
+ 'drawable-anydpi-v24/ic_loading.xml': `<animated-vector ${NS_A} android:drawable="@drawable/ic_tri"/>`,
204
+ 'drawable-xxhdpi/ic_loading.png': png(4, 4),
205
+ });
206
+ assert.deepEqual(out['xxldpi/ic_loading.png'], { w: 4, h: 4 });
207
+ });
208
+
209
+ test('only_pure_density_pairs_count_as_vector_fallbacks', () => {
210
+ const out = convert({
211
+ // night-only vector: the day bitmap is the only base-mode copy
212
+ 'drawable-night-anydpi-v24/ic_moon.xml': vector(24, 24),
213
+ 'drawable-xxhdpi/ic_moon.png': png(4, 4),
214
+ // day vector + a hand-made night bitmap: the night look must survive
215
+ 'drawable-anydpi-v24/ic_sun.xml': vector(24, 24),
216
+ 'drawable-night-xxhdpi/ic_sun.png': png(4, 4),
217
+ 'drawable-xxhdpi/ic_sun.png': png(4, 4),
218
+ });
219
+ assert.deepEqual(out['xxldpi/ic_moon.png'], { w: 4, h: 4 });
220
+ assert.ok(typeof out['dark/ic_moon.svg'] === 'string');
221
+ assert.ok(typeof out['base/ic_sun.svg'] === 'string');
222
+ assert.deepEqual(out['dark-xxldpi/ic_sun.png'], { w: 4, h: 4 });
223
+ assert.equal(out['xxldpi/ic_sun.png'], undefined);
224
+ });
@@ -53,7 +53,7 @@ Parse the arguments from the user's message (natural language is fine — no fix
53
53
  | `IMAGE_READ` | `--image-read true\|false`: whether this host's sub-agents can read image files (a2h-app-migrate probes it at bootstrap). `false` → every sub-agent prompt carries the no-image rule of I5. Never probe it by opening an image in this session | `true` |
54
54
  | `SHARED_LAYER` | `auto` (default) or `off`; persisted in `state.config.shared_layer` |
55
55
  | `SOURCE_KIND` | optional `android` (default) or `uniapp`; persisted in `state.config.source_kind`. No current caller passes it (`a2h-app-migrate` exports no `SOURCE_KIND` variable), so it defaults to `android` and only labels the F0 agent's source-evidence reading — scanning is project-neutral |
56
- | `WAIT_MODE` | `background` (default): B1 ends the turn and waits for notifications / the waker. `foreground`: this run is itself a dispatched sub-agent (e.g. under `a2h-app-migrate`) whose ended turn would return to its caller — B1 never ends the turn; it blocks in `dispatch.mjs wait` instead and arms no waker (`references/coding-loop.md` → Foreground wait mode) | `background` |
56
+ | `WAIT_MODE` | `background` (default): B1 ends the turn and waits for notifications / the waker. `foreground`: this run is itself a dispatched sub-agent (e.g. under `a2h-app-migrate`) whose ended turn would return to its caller — B1 never ends the turn; it blocks in `dispatch.mjs wait` instead (one short call, ≤ 300 s, then back to step 1; never a self-written wait script) and arms no waker (`references/coding-loop.md` → Foreground wait mode) | `background` |
57
57
 
58
58
  ### specs.json format
59
59
 
@@ -5,6 +5,10 @@ on every wakeup. `SKILL.md` carries the navigation summary; this file is the aut
5
5
  Its numbering (event-loop steps 1–10, the guard bullets) is cross-referenced by B2, the fail-soft rules,
6
6
  and `references/execution-model.md`.
7
7
 
8
+ **Running as a dispatched sub-agent (`WAIT_MODE=foreground`, e.g. `a2h-app-migrate` → `logic.spec_pipeline`)?**
9
+ Read **Foreground wait mode** below before the first wave: it replaces step 9's `end-turn` with one
10
+ short `dispatch.mjs wait` call (≤ 300 s) and forbids self-written wait scripts.
11
+
8
12
  ### B1 — Parallel coding (chunked, per-group serial, background-dispatched)
9
13
 
10
14
  Chunk sub-agents are dispatched with the `Agent` tool in **background mode** (`background: true`). Maintain
@@ -229,6 +233,18 @@ wait changes:
229
233
  waker runs). Completion notifications that still arrive are consumed in step 1 as usual.
230
234
  - The turn ends only at the legitimate stops (Finalization done, or a hard stop), with the final report.
231
235
  The "never sit in a foreground `wait`" rule above is for `background` mode only.
236
+ - **The wait only keeps the turn alive; keep every call short.** While a shell call runs, the host
237
+ queues every completion notification until the call returns, so a call's length is the delay added to
238
+ every agent that finishes during it (measured: self-written 25–27 minute waits held finished chunks
239
+ for up to 25 minutes). `dispatch.mjs wait` returns at the first evidence change, or once `--max-wait` has passed
240
+ (plus one snapshot); `--max-wait` above 300 s is clamped to 300 and `--poll` above 30 s to 30. Run **exactly** the command above. Never write
241
+ your own wait / poll / sleep script, never `sleep`, never wrap the wait in a loop inside one shell
242
+ call: each return must come back to step 1.
243
+ - **`wait` sees only ledger units.** It watches the worktrees and attempt artifacts of claimed /
244
+ dispatched / live / orphaned units. An agent dispatched without `claim` → `intent` → `confirm` is
245
+ invisible to it, and a chunk marked `done` in `spec_pipeline_state.json` ahead of its ledger unit
246
+ hides the gap. Every chunk and resolver goes through the ledger; state follows the ledger one way
247
+ (`references/state-and-resume.md` → One-way state repair), never ahead of it.
232
248
 
233
249
  **Waker arming** (`WAIT_MODE=background` only). When active units remain: `dispatch.mjs <HMOS> probe` → if `inPlace:false` or
234
250
  `runId` differs, clear a stale stop file and dispatch a general-purpose sub-agent in **background mode**
@@ -244,10 +244,10 @@ node dispatch.mjs <HMOS> group-fail <G>
244
244
  node dispatch.mjs <HMOS> queue-merge <G>
245
245
  node dispatch.mjs <HMOS> dequeue-merge <G>
246
246
  node dispatch.mjs <HMOS> reconcile [--check] [--now <iso>]
247
- node dispatch.mjs <HMOS> wait [--max-wait 120] [--poll 5] [--baseline <path>] [--event-file <path>] [--stop-file <path>] [--once] [--now <iso>]
247
+ node dispatch.mjs <HMOS> wait [--max-wait 120 (≤ 300; larger is clamped)] [--poll 5 (≤ 30; larger is clamped)] [--baseline <path>] [--event-file <path>] [--stop-file <path>] [--once] [--now <iso>]
248
248
  node dispatch.mjs <HMOS> probe
249
249
  node dispatch.mjs <HMOS> status
250
- node dispatch.mjs <HMOS> waker [--interval 30] [--poll 5]
250
+ node dispatch.mjs <HMOS> waker [--interval 30 (not capped: background only)] [--poll 5 (≤ 30; larger is clamped)]
251
251
  node dispatch.mjs <HMOS> progress
252
252
  ```
253
253
 
@@ -22,7 +22,11 @@ not modify the group/spec state machine.
22
22
  that NetStack rejects with 401), `@hometrans/api-permission-declared` (Kit import without the matching
23
23
  `module.json5` `requestPermissions` entry), `@hometrans/arkui-runtime-pitfall` (ArkUI
24
24
  runtime-contract and cross-page carrier defects; see
25
- `document/checker/hometrans/arkui-runtime-pitfall-<language>.md` in the package), and
25
+ `document/checker/hometrans/arkui-runtime-pitfall-<language>.md` in the package),
26
+ `@hometrans/arkui-v2-observation` (V2 observation-chain break points: method-indirect render
27
+ reads, shadow signals over unobserved containers, nested state classes without `@ObservedV2`,
28
+ deep writes without `@Trace`, dot-path `@Monitor` collections and `@Monitor` loops; see
29
+ `document/checker/hometrans/arkui-v2-observation-<language>.md` in the package), and
26
30
  `@hometrans/route-page-side-effect-import` (a HAR/HSP `@Entry({routeName})` page with no
27
31
  side-effect import in a consuming HAP — tree-shaken out of `ets/modules.abc`, so
28
32
  `pushNamedRoute`/`replaceNamedRoute` throws 100004; see
@@ -10,6 +10,11 @@
10
10
  "isGlobal": true,
11
11
  "fileExtensions": [".ets", ".ts"]
12
12
  },
13
+ "@hometrans/arkui-v2-observation": {
14
+ "severity": 1,
15
+ "isGlobal": true,
16
+ "fileExtensions": [".ets", ".ts"]
17
+ },
13
18
  "@hometrans/platform-api-contract": {
14
19
  "severity": 1,
15
20
  "fileExtensions": [".ets"]
@@ -8,6 +8,10 @@
8
8
  "module": "ArkUIRuntimePitfallCheck",
9
9
  "path": "checker"
10
10
  },
11
+ "@hometrans/arkui-v2-observation": {
12
+ "module": "ArkUIV2ObservationCheck",
13
+ "path": "checker"
14
+ },
11
15
  "@hometrans/platform-api-contract": {
12
16
  "module": "PlatformApiContractCheck",
13
17
  "path": "checker"
@@ -54,7 +54,8 @@
54
54
  成员、同一文件的 `@Builder` 按参数读取的字段;非 `@Param` 成员只显示组件名。接收方不可解析时仍会报,
55
55
  只降级为泛称短语。核心语义:**key 不变时 ForEach 不重跑生成器,条目接收到的值不会更新;
56
56
  `@ObservedV2`/`@Trace` 不能跨过被复用的行传值**——只改成 `@ComponentV2 + @Param` 不成立,必须同时让 key
57
- 变化,或改用 LazyForEach。静默:key 已混入多成员、`JSON.stringify(item)` / `${item}`、key 调 helper、
57
+ 变化,或改用 LazyForEach。**不要因为 key 的生成方式与 Android 相同就判定无需修改**:
58
+ 鸿蒙的 key 同时决定「复用」与「重建」,Android 的 key 只决定身份,内容刷新靠新对象重渲染。静默:key 已混入多成员、`JSON.stringify(item)` / `${item}`、key 调 helper、
58
59
  数组字面量、无 keyGenerator。`// FOREACH-KEY: <理由>` 关闭单处;内层已覆盖时外层仍会被报,按预期关闭
59
60
  (规则只读单层 key)。
60
61
  - **route-param-v2-instance / -v2-new / -v2-stringify / -unrebuilt-receive**:路由器形状调用
@@ -65,7 +65,9 @@ most kill the process or render `undefined` on the receiving page; the rest sile
65
65
  An unresolvable receiver is still reported, with a generic phrase. Core semantics: **an unchanged
66
66
  key means the row is not rebuilt, so the values it receives stay stale; `@ObservedV2`/`@Trace`
67
67
  does not cross a reused row** — "make the row `@ComponentV2 + @Param`" alone is not a fix; the
68
- key must change too, or the list must use LazyForEach. Silent and left to review: a key already
68
+ key must change too, or the list must use LazyForEach. **Do not conclude no change is needed
69
+ because the key generation matches Android**: a HarmonyOS key decides reuse and rebuild together,
70
+ while an Android key only decides identity. Silent and left to review: a key already
69
71
  mixing several members, `JSON.stringify(item)` or a bare `${item}` interpolation, a helper call
70
72
  (`(i) => this.keyOf(i)`), an array-literal source, a `ForEach` without a third argument. Close one
71
73
  site with `// FOREACH-KEY: <reason>`. Known false positive: when an inner `ForEach` already keys
@@ -0,0 +1,105 @@
1
+ # @hometrans/arkui-v2-observation
2
+
3
+ **目的**:检查 V2 状态观测链的断点(典型表现:编译通过、运行不刷新)。
4
+
5
+ 子码:
6
+
7
+ | 子码 | 级别 | 一句话 |
8
+ |---|---|---|
9
+ | `[v2-render-read-unobserved]` | WARN | `build/@Builder` 经一层方法/getter 读到 `@ObservedV2` 类的非 `@Trace` 字段,且该字段有写路径 |
10
+ | `[v2-render-shadow-state]` | ERROR / WARN | `@Trace D = 非观测容器 C.length`,渲染用 `D` 做分支条件、分支体读 `C`;分支体也读 `D` 时降为 WARN |
11
+ | `[v2-nested-class-unobserved]` | WARN | 状态树里被深层写、被 UI 读的嵌套数据类没有 `@ObservedV2` |
12
+ | `[v2-deep-write-unobserved]` | ERROR | `@Param/@Provider/@Consumer` 根对象的深层写落到没有 `@Trace` 的字段,且该字段在渲染路径被读 |
13
+ | `[v2-monitor-deep-collection]` | WARN | `@Monitor('a.b')` 的 `a.b` 是集合,类内做元素级突变 |
14
+ | `[v2-plain-object-state]` | WARN | `@Local/@Param` 的接口/type 状态节点用普通对象赋值后又深层写 |
15
+ | `[v2-monitor-cycle]` | WARN | 两个 `@Monitor` 互相写对方监听的字段,或自写自听 |
16
+
17
+ `[v2-render-shadow-state]` 在"分支体只读 C、不读 D"时是 ERROR:条件只翻转 0↔非 0,
18
+ 第二次 push 或 `replaceTop` 必然不重建分支。分支体同时读 D 时降为 WARN(push/pop 会刷新,
19
+ 只有"改 C 不改 D"的写仍失效)。`[v2-deep-write-unobserved]` 只有在被写字段确实被渲染路径
20
+ 读取时才是 ERROR;内部标记字段不报。
21
+
22
+ ## 判定原理
23
+
24
+ 一次工程扫描建立:文件 → import(相对路径、`oh-package.json5` 包名、`Index.ets` barrel、
25
+ `export { x } from` / `export * from`)→ 声明(class / struct / interface / type / const)→
26
+ `@ObservedV2`、`@Trace`、`@ComponentV2`、`@Builder`、`@Monitor` 装饰器 → 方法体 / 字段类型。
27
+ 渲染读 = `@ComponentV2` 的 `build` 与 `@Builder` 成员体;方法内联只做**一层**,且只内联
28
+ 「有非 void 返回类型、方法体无写入、不在 `.onXxx(...)` 事件回调内」的方法/getter。
29
+ `this.a.b[0].c` 这类链会逐段记录 `owner#field`(`[a, b, c]` 的属性名,索引表达式不计)。
30
+ 写证据来自 `this.<field> =`、复合赋值(`+=`/`-=`/…)、`++`/`--`、`this.<path> =` 与集合 mutator。
31
+
32
+ ## 各子码边界
33
+
34
+ ### v2-render-read-unobserved
35
+
36
+ - 补的是固定域 `observedv2-untraced-write` 的缺口:它只收 `build` 内直接的
37
+ `ArkInstanceFieldRef`,且目标类只从组件字段发现。本子码支持一层方法/getter 内联和
38
+ `export const appRouter: AppRouter = new AppRouter()` 单例。
39
+ - 直接读也会报;组件字段的直接读与固定域 `observedv2-untraced-write` 可能重复,评审时可合并。
40
+ - 沉默:`private` 字段(内部游标/句柄)、常量/只读字段、只在构造函数里赋值的字段、
41
+ 方法体有写入的「命令方法」、无返回类型的方法、`.onClick/.onChange` 等事件回调里的读、
42
+ 无法解析的接收者。消息里的来源会区分 `build` / `@Builder` / `... -> method`。
43
+ - 修复:给字段加 `@Trace`,或改为基于 `@Trace` 字段的 `@Computed` 派生。
44
+
45
+ ### v2-render-shadow-state
46
+
47
+ - 精确指纹:同类里存在 `@Trace D`、非 `@Trace` 容器 `C`,方法中有
48
+ `this.D = this.C.length`(或 `.size`);渲染上下文中同一个实例的 `D` 出现在
49
+ `if/else if` 条件里,而分支体(含 `@Builder` 展开与一层方法内联)读到 `C`。
50
+ - 分支体也读 `D` 时降为 WARN:push/pop 会改变 D,只有 `replaceTop`(pop+push、深度不变)
51
+ 这类"改 C 不改 D"的写仍会失效。条件与分支必须解析到同一个实例(`routerA.depth` 与
52
+ `routerB.currentRoute()` 不配对)。`switch` / 三元条件暂不覆盖。
53
+ - 修复:让容器可观察(`@Trace stack`),或把 `currentRoute` 改成基于 `@Trace` 字段的
54
+ `@Computed`;不要再用 `length` 影子当唯一信号。
55
+
56
+ ### v2-nested-class-unobserved
57
+
58
+ - 从 `@Local/@Param/@Provider/@Consumer` 字段或 `@ObservedV2` 字段出发,沿**属性写路径**
59
+ (不是整体替换、不是集合 mutator)走到第一个自定义数据类:它没有 `@ObservedV2`、没有行为方法
60
+ (constructor / getter / setter 不算方法;排除 service/handle)、且根字段在渲染路径被读。
61
+ `@Local` 也纳入:固定域
62
+ `local-nested-write` 报写侧,这里报"嵌套类本身未观测"。
63
+ - 容器字段的 `@Trace` 不会让元素类可观测;`@Trace items: Item[]` 且 `Item` 未装饰仍会报。
64
+ - 沉默:接口/type(不能加 `@ObservedV2`,见 `[v2-plain-object-state]`)、整体替换的数组元素、
65
+ 无可解析类型。
66
+ - 修复:给该类加 `@ObservedV2`,给 UI 读取的字段加 `@Trace`。
67
+
68
+ ### v2-deep-write-unobserved
69
+
70
+ - 只判 `@Param/@Provider/@Consumer` 根(`@Local/@State` 由固定域规则覆盖),且嵌套类
71
+ **已经是** `@ObservedV2`,只是被写字段没有 `@Trace`;同时要求该字段在渲染路径被读,
72
+ 内部标记字段不报。
73
+ - 修复:加 `@Trace`,或整体重新赋值状态对象。
74
+
75
+ ### v2-monitor-deep-collection
76
+
77
+ - 固定域 `monitor-collection` 明确豁免 dot-path,`monitor-nonobservable` 只检查末段装饰,
78
+ 所以 `@Monitor('obj.arr')` + `push/splice` 这个形态目前是空档。多参数
79
+ `@Monitor('a', 'b')` 会按顶层逗号拆开分别判断。
80
+ - 沉默:整体重赋值 `this.obj.arr = [...]`(合法刷新)、单段裸集合(固定域已覆盖)。
81
+ - 修复:整体重赋值集合,或监听元素字段。
82
+
83
+ ### v2-plain-object-state
84
+
85
+ - 只判**接口 / type 字面量**状态节点 + 直接对象字面量 / `Object.assign` / 展开赋值,且
86
+ 之后有深层写、渲染路径有读。`JSON.parse` / `structuredClone` 的 class 型赋值由固定域
87
+ `state-unactivated-observe` 覆盖,不重复报;`new`、`UIUtils.makeObserved(...)` 豁免。
88
+ - 修复:改用 `@ObservedV2` class + `new`,或 `UIUtils.makeObserved(...)` 包装后保存返回的代理。
89
+
90
+ ### v2-monitor-cycle
91
+
92
+ - 只认 `@Monitor` 方法体里的**直接**写(`this.x = ...`、复合赋值、`++`/`--`):
93
+ A 写 B 监听的字段、B 写 A 监听的字段成环(含自写自听)。经 helper 间接触发的环是已登记的 FN。
94
+ - 只有单段路径参与自环比较;`@Monitor('profile.name')` 这类多段路径跳过,避免
95
+ `this.name = this.profile.name` 被误判为自写自听。多参数 `@Monitor('a', 'b')` 分别建节点。
96
+ 带 `if (...)` 守卫的写(如 `if (this.value < 0) this.value = 0`)是幂等钳制,不参与环判定。
97
+ - 修复:只保留一个写入方向,并在回调里做新旧值幂等校验。
98
+
99
+ ## 误报 / 逃生舱
100
+
101
+ - 确认是误报时写 `// homecheck-disable-next-line @hometrans/arkui-v2-observation`,并在
102
+ `homecheck-fix-report.md` 记录 ruleId、文件、行号、原因与证据。
103
+ - 无法解析的包/类型、`any`/`Object` 断言、helper 返回值、对象展开、`oh_modules` 依赖一律沉默。
104
+ - 本规则不做运行期时序判定(`@Monitor` → `@Computed` 的更新顺序)、不做「缺 `@Event` 回写」
105
+ 的意图判定;这些留给代码评审或运行期。