android2harmony 0.1.6 → 0.1.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 (227) hide show
  1. package/agents/api-analyzer.md +113 -0
  2. package/agents/app-action.md +122 -0
  3. package/agents/code-reviewer.md +191 -295
  4. package/agents/coder.md +377 -0
  5. package/agents/self-tester.md +8 -8
  6. package/agents/spec-designer.md +56 -0
  7. package/package.json +1 -1
  8. package/skills/a2h-app-req-gen/SKILL.md +174 -0
  9. package/skills/a2h-app-req-gen/references/spec-handoff.md +99 -0
  10. package/skills/a2h-app-req-gen/references/subagent-render.md +115 -0
  11. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/build.gradle.kts +41 -0
  12. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/gradle/wrapper/gradle-wrapper.jar +0 -0
  13. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/gradle/wrapper/gradle-wrapper.properties +8 -0
  14. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/gradle.properties +3 -0
  15. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/gradlew +251 -0
  16. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/gradlew.bat +94 -0
  17. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/settings.gradle.kts +17 -0
  18. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/java/dev/reqgen/analyzer/jvm/RawAnalysisDetector.java +1911 -0
  19. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/java/dev/reqgen/analyzer/jvm/RawIssueRegistry.java +37 -0
  20. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/java/dev/reqgen/analyzer/jvm/RawJson.java +146 -0
  21. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/java/dev/reqgen/analyzer/jvm/RawLocation.java +96 -0
  22. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/java/dev/reqgen/analyzer/jvm/RawRecordWriter.java +227 -0
  23. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/resources/META-INF/services/com.android.tools.lint.client.api.IssueRegistry +1 -0
  24. package/skills/a2h-app-req-gen/scripts/reqgen/analyzer-jvm/src/main/resources/dev/reqgen/analyzer/jvm/raw-record-v1.schema.json +93 -0
  25. package/skills/a2h-app-req-gen/scripts/reqgen/assets/dashboard.html +151 -0
  26. package/skills/a2h-app-req-gen/scripts/reqgen/gradle/reqgen-lint.init.gradle +60 -0
  27. package/skills/a2h-app-req-gen/scripts/reqgen/gradle/reqgen-model.init.gradle +204 -0
  28. package/skills/a2h-app-req-gen/scripts/reqgen/package.json +14 -0
  29. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/backend.js +323 -0
  30. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/cli.js +811 -0
  31. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/gap-audit-link.js +62 -0
  32. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/index.js +66 -0
  33. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/merge.js +605 -0
  34. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/name-trace.js +153 -0
  35. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/orchestrate.js +1324 -0
  36. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/output-parse.js +50 -0
  37. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/overview.js +10 -0
  38. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/pool.js +23 -0
  39. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/post-merge-fix.js +146 -0
  40. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/prompt-loader.js +51 -0
  41. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/prompt.js +967 -0
  42. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/prompts.md +301 -0
  43. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/serve.js +78 -0
  44. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/short-id.js +46 -0
  45. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/snapshot.js +267 -0
  46. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/types.js +1 -0
  47. package/skills/a2h-app-req-gen/scripts/reqgen/src/agent-render/validate.js +122 -0
  48. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/callback-call-sites.js +62 -0
  49. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/gap-audit/build.js +1291 -0
  50. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/gap-audit/index.js +1 -0
  51. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/graph/area-ownership.js +392 -0
  52. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/graph/build.js +1995 -0
  53. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/graph/callback-flow.js +277 -0
  54. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/graph/component-variants.js +725 -0
  55. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/graph/index.js +15 -0
  56. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/names/index.js +12 -0
  57. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/names/policy.js +469 -0
  58. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/names/traceability.js +468 -0
  59. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/req-model/build.js +1066 -0
  60. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/req-model/index.js +1 -0
  61. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/android-interaction-registry.js +174 -0
  62. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/android.js +1062 -0
  63. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/area-titles.js +678 -0
  64. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/builder.js +350 -0
  65. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/compose-api-registry.js +395 -0
  66. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/compose-call-sites.js +2008 -0
  67. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/compose.js +9059 -0
  68. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/dynamic-repeated-call-sites.js +529 -0
  69. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/index.js +1 -0
  70. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/interaction-effects.js +1149 -0
  71. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/jvm.js +6272 -0
  72. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/normalize.js +33 -0
  73. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/pending-intents.js +565 -0
  74. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/resource-id.js +42 -0
  75. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/route-state-variants.js +781 -0
  76. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/state.js +234 -0
  77. package/skills/a2h-app-req-gen/scripts/reqgen/src/analysis/source-facts/types.js +1 -0
  78. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/extract.js +40 -0
  79. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/index.js +6 -0
  80. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/manifest.js +513 -0
  81. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/resources.js +398 -0
  82. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/types.js +1 -0
  83. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/views.js +447 -0
  84. package/skills/a2h-app-req-gen/scripts/reqgen/src/android/xml-parser.js +175 -0
  85. package/skills/a2h-app-req-gen/scripts/reqgen/src/cli.js +398 -0
  86. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/area-graph.js +1 -0
  87. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/artifact.js +1 -0
  88. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/common.js +16 -0
  89. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/diagnostic.js +10 -0
  90. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/gap-audit.js +14 -0
  91. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/index.js +11 -0
  92. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/name-traceability.js +26 -0
  93. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/raw-fact.js +40 -0
  94. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/req-model.js +1 -0
  95. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/run.js +19 -0
  96. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/semantic-completeness.js +11 -0
  97. package/skills/a2h-app-req-gen/scripts/reqgen/src/contracts/source-facts.js +1 -0
  98. package/skills/a2h-app-req-gen/scripts/reqgen/src/core/output-guard.js +41 -0
  99. package/skills/a2h-app-req-gen/scripts/reqgen/src/core/stable-id.js +92 -0
  100. package/skills/a2h-app-req-gen/scripts/reqgen/src/dashboard-cli.js +169 -0
  101. package/skills/a2h-app-req-gen/scripts/reqgen/src/diagnostics.js +104 -0
  102. package/skills/a2h-app-req-gen/scripts/reqgen/src/dump/dump.js +1028 -0
  103. package/skills/a2h-app-req-gen/scripts/reqgen/src/dump/index.js +1 -0
  104. package/skills/a2h-app-req-gen/scripts/reqgen/src/dump-cli.js +251 -0
  105. package/skills/a2h-app-req-gen/scripts/reqgen/src/generation/artifacts.js +49 -0
  106. package/skills/a2h-app-req-gen/scripts/reqgen/src/generation/index.js +18 -0
  107. package/skills/a2h-app-req-gen/scripts/reqgen/src/generation/quality-report.js +125 -0
  108. package/skills/a2h-app-req-gen/scripts/reqgen/src/generation/render.js +353 -0
  109. package/skills/a2h-app-req-gen/scripts/reqgen/src/generation/types.js +2 -0
  110. package/skills/a2h-app-req-gen/scripts/reqgen/src/graph/paths.js +474 -0
  111. package/skills/a2h-app-req-gen/scripts/reqgen/src/jvm/index.js +15 -0
  112. package/skills/a2h-app-req-gen/scripts/reqgen/src/jvm/protocol.js +408 -0
  113. package/skills/a2h-app-req-gen/scripts/reqgen/src/jvm/runner.js +452 -0
  114. package/skills/a2h-app-req-gen/scripts/reqgen/src/pipeline/index.js +8 -0
  115. package/skills/a2h-app-req-gen/scripts/reqgen/src/pipeline/output.js +165 -0
  116. package/skills/a2h-app-req-gen/scripts/reqgen/src/pipeline/run-stage1.js +891 -0
  117. package/skills/a2h-app-req-gen/scripts/reqgen/src/project/discovery.js +299 -0
  118. package/skills/a2h-app-req-gen/scripts/reqgen/src/project/gradle-model.js +358 -0
  119. package/skills/a2h-app-req-gen/scripts/reqgen/src/project/gradle-runner.js +165 -0
  120. package/skills/a2h-app-req-gen/scripts/reqgen/src/project/resource-profile.js +60 -0
  121. package/skills/a2h-app-req-gen/scripts/reqgen/src/project/types.js +1 -0
  122. package/skills/a2h-app-req-gen/scripts/reqgen/src/spec-handoff-cli.js +151 -0
  123. package/skills/a2h-app-req-gen/scripts/reqgen/src/spec-handoff.js +1004 -0
  124. package/skills/a2h-app-req-gen/scripts/reqgen/src/stage2-cli.js +109 -0
  125. package/skills/a2h-app-req-gen/scripts/reqgen/src/stage2-input.js +419 -0
  126. package/skills/a2h-app-req-gen/scripts/reqgen/src/stage2-name-trace-input.js +95 -0
  127. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/area-graph.js +444 -0
  128. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/index.js +7 -0
  129. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/req-model.js +580 -0
  130. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/req-text.js +195 -0
  131. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/semantic-area-graph.js +1431 -0
  132. package/skills/a2h-app-req-gen/scripts/reqgen/src/validation/types.js +1 -0
  133. package/skills/a2h-app-req-gen/scripts/reqgen-audit.mjs +298 -0
  134. package/skills/a2h-app-req-gen/scripts/reqgen-selfcheck.mjs +555 -0
  135. package/skills/a2h-code-review/SKILL.md +379 -0
  136. package/skills/{hmos-integration-test → a2h-integration-test}/README.md +6 -6
  137. package/skills/{hmos-integration-test → a2h-integration-test}/SKILL.md +6 -6
  138. package/skills/{hmos-integration-test → a2h-integration-test}/scripts/report-tool.mjs +1 -1
  139. package/skills/a2h-spec-design/SKILL.md +330 -0
  140. package/skills/a2h-spec-design/scripts/inspect_spec_design_inputs.mjs +207 -0
  141. package/skills/a2h-spec-design/scripts/move_spec_technical_reference.mjs +198 -0
  142. package/skills/a2h-spec-design/scripts/validate_spec_design_output.mjs +256 -0
  143. package/skills/a2h-spec-generate/SKILL.md +696 -0
  144. package/skills/a2h-spec-generate/references/trace-template.md +115 -0
  145. package/skills/a2h-spec-generate/scripts/parse_requirements.mjs +537 -0
  146. package/skills/a2h-spec-generate/template/REQ.txt +22 -0
  147. package/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  148. package/skills/a2h-spec-implement/SKILL.md +548 -0
  149. package/skills/a2h-spec-implement/references/harmony-pitfalls.md +186 -0
  150. package/skills/a2h-spec-implement/references/l1-unit-test.md +185 -0
  151. package/skills/a2h-spec-implement/references/l3-e2e-uitest.md +167 -0
  152. package/skills/a2h-spec-implement/references/test-core.md +132 -0
  153. package/skills/a2h-spec-implement/rules/arkts/arkts-standards.md +184 -0
  154. package/skills/a2h-spec-implement/rules/arkts/conventions/coding-style.md +96 -0
  155. package/skills/a2h-spec-implement/rules/arkts/conventions/security.md +126 -0
  156. package/skills/a2h-spec-implement/rules/arkts/language/arkts-rules.md +650 -0
  157. package/skills/a2h-spec-implement/rules/arkts/language/arkui-structure-rules.md +173 -0
  158. package/skills/a2h-spec-implement/rules/arkts/language/ts-to-arkts-rewrites.md +58 -0
  159. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -0
  160. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2089 -0
  161. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -0
  162. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -0
  163. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -0
  164. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -0
  165. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -0
  166. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +903 -0
  167. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -0
  168. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -0
  169. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
  170. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +355 -0
  171. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v1//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -0
  172. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +216 -0
  173. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +442 -0
  174. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +169 -0
  175. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +763 -0
  176. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +2088 -0
  177. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1258 -0
  178. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Once/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +175 -0
  179. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Param/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +850 -0
  180. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +862 -0
  181. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +110 -0
  182. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +301 -0
  183. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1411 -0
  184. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1392 -0
  185. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/getTarget/346/216/245/345/217/243/357/274/232/350/216/267/345/217/226/347/212/266/346/200/201/347/256/241/347/220/206/346/241/206/346/236/266/344/273/243/347/220/206/345/211/215/347/232/204/345/216/237/345/247/213/345/257/271/350/261/241.md +288 -0
  186. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2/makeObserved/346/216/245/345/217/243/357/274/232/345/260/206/351/235/236/350/247/202/345/257/237/346/225/260/346/215/256/345/217/230/344/270/272/345/217/257/350/247/202/345/257/237/346/225/260/346/215/256.md +768 -0
  187. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/222/214V2/346/267/267/347/224/250/346/214/207/345/257/274/357/274/210API version 19/345/217/212/344/271/213/345/220/216/357/274/211.md" +829 -0
  188. package/skills/a2h-spec-implement/rules/arkts/official/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206/346/246/202/350/277/260.md +184 -0
  189. package/skills/a2h-spec-implement/rules/arkts/ui/component-cookbook.md +431 -0
  190. package/skills/a2h-spec-implement/rules/arkts/ui/state-management.md +152 -0
  191. package/skills/a2h-spec-implement/rules/arkts/ui/ui-quality.md +67 -0
  192. package/skills/a2h-spec-implement/rules/arkts/ui/ui-runtime-diagnosis.md +32 -0
  193. package/skills/a2h-spec-implement/rules/pipeline/build/package-set-collection.md +43 -0
  194. package/skills/a2h-spec-implement/scripts/_lib/common.mjs +97 -0
  195. package/skills/a2h-spec-implement/scripts/_lib/config.mjs +70 -0
  196. package/skills/a2h-spec-implement/scripts/_lib/lessons_cli.mjs +48 -0
  197. package/skills/a2h-spec-implement/scripts/build_lessons.mjs +24 -0
  198. package/skills/a2h-spec-implement/scripts/code_pattern_lessons.mjs +26 -0
  199. package/skills/a2h-spec-implement/scripts/device_ui.mjs +433 -0
  200. package/skills/a2h-spec-implement/scripts/device_ui_core.mjs +895 -0
  201. package/skills/a2h-spec-implement/scripts/ledger/aggregate_run.mjs +207 -0
  202. package/skills/a2h-spec-implement/scripts/manifest/emit_summary_line.mjs +37 -0
  203. package/skills/a2h-spec-implement/scripts/manifest/finalize_run.mjs +115 -0
  204. package/skills/a2h-spec-implement/scripts/manifest/render_final_summary.mjs +78 -0
  205. package/skills/a2h-spec-implement/scripts/manifest/root_mirror.mjs +137 -0
  206. package/skills/a2h-spec-implement/scripts/package.json +12 -0
  207. package/skills/a2h-spec-implement/scripts/state_propagation_check.mjs +676 -0
  208. package/skills/a2h-spec-implement/scripts/test/l2_run.mjs +244 -0
  209. package/skills/a2h-spec-implement/scripts/test/tp_coverage.mjs +231 -0
  210. package/skills/a2h-spec-implement/scripts/ui_memory.mjs +161 -0
  211. package/skills/a2h-spec-implement/scripts/utils/ensure_app.mjs +134 -0
  212. package/skills/a2h-ui-transfer/SKILL.md +20 -9
  213. package/skills/a2h-ui-transfer/scripts/arkts_static_check.js +80 -0
  214. package/skills/hmos-convert-pipeline/SKILL.md +7 -5
  215. package/skills/hmos-incremental-ui-align/README.md +7 -7
  216. package/skills/hmos-incremental-ui-align/SKILL.md +1 -1
  217. package/skills/hmos-incremental-ui-align/page_align.md +1 -1
  218. package/skills/hmos-spec-generate/SKILL.md +2 -2
  219. package/skills/hmos-spec-generate/scripts/parse_requirements.mjs +537 -0
  220. package/skills/hmos-fix-build-errors/SKILL.md +0 -266
  221. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +0 -219
  222. package/skills/hmos-fix-build-errors/references/known-patterns.md +0 -157
  223. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +0 -131
  224. package/skills/hmos-spec-generate/scripts/parse_requirements.ts +0 -515
  225. /package/skills/{hmos-integration-test → a2h-integration-test}/scripts/resolve-metadata-tool.mjs +0 -0
  226. /package/skills/{hmos-integration-test → a2h-integration-test}/scripts/self-test-runner.mjs +0 -0
  227. /package/skills/{hmos-integration-test → a2h-integration-test}/scripts/testcases-tool.mjs +0 -0
@@ -0,0 +1,184 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ets"
4
+ - "**/*.ts"
5
+ ---
6
+ # ArkTS Grammar Standards
7
+
8
+ > The ArkTS/ArkUI **authoring authority** for this repo — everything here constrains *the code you write*; anything constraining *what the pipeline does* lives in `rules/pipeline/` instead. This file is the overview + scenario router; each detail lives in exactly one sibling:
9
+ > - **`language/`** — what compiles: `arkts-rules.md`, `arkui-structure-rules.md`, `ts-to-arkts-rewrites.md`
10
+ > - **`ui/`** — building the UI: `component-cookbook.md`, `state-management.md`, `ui-quality.md`, `ui-runtime-diagnosis.md`
11
+ > - **`conventions/`** — cross-cutting code conventions: `coding-style.md`, `security.md`
12
+ > - **`official/`** — verbatim official-doc copies (read-only, never authored): `mvvm-v1/`, `mvvm-v2/`
13
+ >
14
+ > Read on demand via the routing table below.
15
+
16
+ Review the core hard constraints below before writing `.ets` code; for specific errors, component APIs, or migration questions, use the scenario routing table to find the right reference.
17
+
18
+ - Target version: **ArkTSLinter 1.1**
19
+ - Verified SDK: OpenHarmony **API 23** (6.1.0.105) — `ui/component-cookbook.md` shapes are checked against this; for an older project target, confirm availability in the SDK `.d.ts`
20
+ - Language rules are anchored to official rule tags (`arkts-*`), matching compiler/linter error messages one-to-one
21
+
22
+ ## API signature lookup (uncertain API / component / kit)
23
+
24
+ Signature truth = the **local SDK interface files** — consult them before guessing; the cookbook stays first for the ArkUI shapes it covers:
25
+
26
+ 1. Resolve the SDK root once per run: `Grep` pattern `^DEVECO` on `<plugin-path>/conf.yaml` (content mode — the only sanctioned conf.yaml access; it holds secrets) → root = `DEVECO_SDK_HOME`, else `<DEVECO_PATH>/sdk`.
27
+ 2. `Grep` the symbol (e.g. `interface AVPlayer`, `linearGradient`) with an explicit `path` under `<root>/default/openharmony/ets/api|component|kits` (glob `*.d.ts`; HMS kits: `<root>/default/hms/ets`), then `Read` the hit **bounded** (offset ≈ hit − 30, limit ≈ 100) — the declaration + its JSDoc (params, `@since`) is the answer; never read a `.d.ts` whole (`component/common.d.ts` = 33k lines, measured).
28
+ 3. Usage/concept docs (not signatures): `devecocli docs search "<keyword>" --catalog harmonyos-guides --format json` → `devecocli docs read "<documentId>"` (offline full text; hits both English API names and Chinese concept terms — measured).
29
+
30
+ This file remains the coding authority over both sources.
31
+
32
+ ## Avoid over-restriction first (common pitfalls)
33
+
34
+ The most frequently mis-banned constructs — these are **legal** in ArkTS, do not avoid them out of TypeScript instinct:
35
+
36
+ - Template literals `` `${value}` `` — fully supported, idiomatic in ArkUI
37
+ - `value as T` — `as` is the ONLY supported assertion syntax (what's banned is `<T>value`)
38
+ - `Record<K, V>` and its indexed access — the officially recommended replacement for index signatures
39
+
40
+ Full whitelist (single source of truth): [`language/arkts-rules.md` § Explicitly allowed constructs](language/arkts-rules.md#explicitly-allowed-constructs).
41
+
42
+ ## Core hard constraints
43
+
44
+ All rules below are ERROR severity (compile/linter failures) unless marked WARNING. Each entry is a one-line conclusion + rule tag — the tag is the anchor: search it in [`language/arkts-rules.md`](language/arkts-rules.md) for the full good/bad examples. Detail is not restated here.
45
+
46
+ ### Types
47
+ - No `any` / `unknown`; use explicit types; when truly undetermined, use `Object` or a union type (`arkts-no-any-unknown`)
48
+ - No structural typing: type compatibility requires explicit `extends`/`implements` (`arkts-no-structural-typing`)
49
+ - Object literals need a type context in EVERY position — declaration, call argument, callback return — `const o: MyIface = {...}` or `Record`; an outer type does not propagate inward (`arkts-no-untyped-obj-literals`)
50
+ - `Record`-typed literals additionally require quoted keys (`{ 'k': v }`, not `{ k: v }`) — same `arkts-no-untyped-obj-literals` error otherwise
51
+ - An object literal assigned to a class type must list every field; class-body defaults do not make them optional — for seed data prefer a static factory (`arkts-no-untyped-obj-literals`; cookbook § Creating instances with data)
52
+ - No inline object types `type T = {...}` / `f(p: {x: number})`; use a named `interface` (`arkts-no-obj-literals-as-types`)
53
+ - No intersection types `A & B`; use interface inheritance (`arkts-no-intersection-types`)
54
+ - No index signatures `[key: string]: T`; use `Record<K,V>` (`arkts-no-indexed-signatures`)
55
+ - Utility types: only `Partial`/`Required`/`Readonly`/`Record` are supported (`arkts-no-utility-types`)
56
+ - Generic call and function return type inference are limited; annotate explicitly (`arkts-no-inferred-generic-params`, `arkts-no-implicit-return-types`)
57
+
58
+ ### Null safety (strict-mode checks; no `arkts-*` tag, but the single largest source of check errors)
59
+ - Any value that can be `undefined` — optional fields (`x?: T`), `Map.get(...)`, `Record` indexed access, `arr[i]`, optional callback params — must be narrowed before use: `?.`, `?? fallback`, or an explicit `if (x !== undefined)` check
60
+ - `T | undefined` cannot be assigned to `T`; supply a fallback (`this.count = map.get(k) ?? 0`) instead of assigning directly
61
+ - Declare component state that starts empty as `T | undefined` (or with a real initial value) — do not fake it with non-null assertions
62
+ - Prefer `undefined` over `null`; convert external `null` with `?? undefined` (project convention)
63
+ - Error messages this prevents: `Object is possibly 'undefined'.`, `Type 'X | undefined' is not assignable to type 'X'.`
64
+
65
+ ### Functions and classes
66
+ - No function expressions `function(){}` as values; use arrow functions (`arkts-no-func-expressions`)
67
+ - No nested function declarations; use arrow-function values inside functions, or promote to class methods (`arkts-no-nested-funcs`)
68
+ - No `this` in standalone functions — and `static` methods count (reference statics via the class name); only instance methods may use `this` (`arkts-no-standalone-this`)
69
+ - No constructor parameter properties `constructor(public x: number)`; declare fields in the class body (`arkts-no-ctor-prop-decls`)
70
+ - No `#` private fields; use `private` (`arkts-no-private-identifiers`)
71
+ - `implements` only accepts interfaces; interfaces cannot extend classes (`arkts-implements-only-iface`, `arkts-extends-only-class`)
72
+ - No generators/`yield`, class expressions, or `Function.bind` (`arkts-no-generators`, `arkts-no-class-literals`, `arkts-no-func-bind`)
73
+
74
+ ### Statements and expressions
75
+ - No destructuring of any kind: declarations, assignments, parameters (`arkts-no-destruct-decls/-assignment/-params`)
76
+ - No `delete`, `in`, `for...in`, `with` (`arkts-no-delete`, `arkts-no-in`, `arkts-no-for-in`)
77
+ - No indexed access `obj['k']` on non-Record objects; use dot access (`arkts-no-props-by-index`)
78
+ - `throw` only accepts `Error` and subclasses; `catch (e)` cannot carry a type annotation (`arkts-limited-throw`, `arkts-no-types-in-catch`)
79
+ - System API error callbacks (`windowStage.loadContent`, file/media/network kits) pass a `BusinessError`, not `Error` — `Error` has no `.code`. Type the param as `BusinessError` and import it: `import { BusinessError } from '@kit.BasicServicesKit'`; in `catch (e)` blocks, cast: `(e as BusinessError).code`
80
+ - No `is` type guards; use `instanceof` + `as` (`arkts-no-is`)
81
+ - Object spread is restricted (array spread is allowed) (`arkts-no-spread`)
82
+ - No regex literals `/x/`; use `new RegExp()` (`arkts-no-regexp-literals`)
83
+ - No `@ts-ignore` or other comment-based check suppression (`arkts-strict-typing-required`)
84
+
85
+ ### Standard library and modules
86
+ - `eval`, `Object.assign/create/freeze/defineProperty`, `hasOwnProperty`, `Reflect`/`Proxy` metaprogramming, `Symbol()` (except `Symbol.iterator`), and `globalThis` are all banned (`arkts-limited-stdlib`, `arkts-no-globalthis`)
87
+ - No `import type`, side-effect-only imports, `require`, or `export =`; `import` must precede all other statements (see [`language/arkts-rules.md` § 7. Module imports and exports](language/arkts-rules.md#7-module-imports-and-exports))
88
+ - Namespaces cannot be passed as values, but calling their exported members directly is allowed (`arkts-no-ns-as-obj`)
89
+
90
+ ### ArkUI structure (build-stage failures; full rules in [`language/arkui-structure-rules.md`](language/arkui-structure-rules.md))
91
+ - `@Component` + `struct` + a mandatory `build()`; `build()` (and `@Entry` pages especially) has **exactly one root node**, which must be a container component
92
+ - Inside `build()` / `@Builder` bodies, only UI component syntax is allowed: component calls, `if/else`, `ForEach`/`LazyForEach` — no statements, local variables, or expressions
93
+ - The inverse also holds: component syntax parses ONLY inside `build()`/`@Builder` — a plain closure passed to an ordinary method cannot contain `Row() {...}`; a reusable section is a `@Builder` method passed into a `@BuilderParam` (parse-error cascade + fix shape: [`language/arkui-structure-rules.md` § 6](language/arkui-structure-rules.md))
94
+ - Struct member area holds only field declarations and methods; a stray brace or statement there cascades into `does not meet UI component syntax` errors
95
+ - One decorator family per project, never mix V1/V2 (policy + correspondences: `ui/state-management.md`; struct-level mixing is also a build error: `language/arkui-structure-rules.md` § 5); pass `@Link` values from the parent with `$var`
96
+ - Naming discipline — three collision classes, each observed repeatedly in production:
97
+ - **Member vs universal attribute**: no struct member named after a universal attribute/method (`opacity`, `scale`, `rotate`, `blur`, `translate`, `tabIndex`, …) — use a domain-specific name (`circleOpacity`, `currentTab`)
98
+ - **Struct vs import**: a struct name must not equal anything the same file imports — alias the import or name the page `XxxPage` (`arkts-unique-names`; full example: [`language/arkts-rules.md` § Rules 4/103](language/arkts-rules.md))
99
+ - **One declaration per type**: a type shared by multiple files lives in ONE model file, imported everywhere (`arkts-no-decl-merging`; full example: same § Rules 4/103, cookbook § Router params)
100
+ - Only ArkUI decorators are allowed; custom decorators are flagged (`arkts-no-decorators-except-arkui`, WARNING severity — still fix it; full list in [`language/arkts-rules.md` § 9](language/arkts-rules.md#9-decorators-and-arkui-rule-148-arkts-no-decorators-except-arkui))
101
+ - Before calling component constructors, modifiers, enums (e.g. `GradientDirection`, `BarPosition`), or callbacks you are not 100% sure of, check [`ui/component-cookbook.md`](ui/component-cookbook.md) — do not guess signatures or enum members
102
+ - Global UI APIs (`router.pushUrl`, `promptAction.showToast`, `AlertDialog.show`, `animateTo`, `vp2px`) called bare are deprecated (WARNING) — call them through `this.getUIContext()` (`.getRouter()`, `.getPromptAction()`, `.showAlertDialog()`, `.animateTo()`, `.vp2px()`); same for `CustomDialogController` → `promptAction.openCustomDialog`
103
+ - Every page listed in `main_pages.json` must contain exactly one `@Entry`-decorated struct — a missing `@Entry` fails the build with `10905402: A page configured in main_pages.json must have one and only one '@Entry' decorator`; conversely, embedded child components must NOT be listed in `main_pages.json`
104
+ - `module.json5` `requestPermissions`: every `user_grant` permission (microphone, camera, location, …) requires BOTH `reason` (a `$string:` resource that must exist) and `usedScene` — omitting them fails the build with `00303218 Configuration Error: The reason and usedScene attributes are mandatory for user_grant permissions`
105
+
106
+ ### Concurrency
107
+ - `@Sendable` classes have their own restriction set (explicit field types, sendable field types, no literal initialization, etc. — see [`language/arkts-rules.md` § 10. Sendable concurrency restrictions](language/arkts-rules.md#10-sendable-concurrency-restrictions))
108
+
109
+ ## Write workflow (self-consistency)
110
+
111
+ `Cannot find name 'X'` is the single most frequent check error — it comes from referencing types/constants before creating them, not from ArkTS rules. When generating multi-file code:
112
+
113
+ 1. **Read [`ui/component-cookbook.md`](ui/component-cookbook.md) BEFORE writing the first page** — not after a check failure. Sessions that read it pre-write produce zero guessed-API errors; sessions that skip it guess enum members and constructor signatures wrong (e.g. `GradientDirection.BottomRight` does not exist), and one wrong guess copy-pasted across pages multiplies into many errors.
114
+ 2. Create shared model/constant/enum files FIRST, then the pages that import them
115
+ 3. Before referencing a type, enum member, or helper from another file, confirm it is actually declared and exported there (re-read or grep the file if it was generated earlier in the session)
116
+ 4. **Review per file, not per batch**: immediately after writing each `.ets` file, run the Per-file gate below and fix violations before starting the next file (observed: one unreviewed mistake copied into 3 pages = 9 errors and 3 fix rounds, vs 1 edit caught per-file). All violations must be fixed BEFORE building.
117
+
118
+ ## Write-time triggers (apply at the keystroke, not in review)
119
+
120
+ Knowing these rules is not enough — they are most often violated mid-generation while attention is on business logic. Bind each trigger to its action the moment the trigger appears in the code you are emitting:
121
+
122
+ | The moment you write... | ...do this before continuing |
123
+ |---|---|
124
+ | `{` starting an object literal — anywhere: variable init, **function/constructor argument** (router params, options objects), **callback return** | Stop. Name its type: `const x: MyIface = {...}` or declare the interface first. An outer declared type does NOT propagate into nested literals. If the type is `Record`, quote every key; if it is a class, list every field. |
125
+ | `?:` in a class/interface field, or a read of `Map.get(...)`, `arr[i]`, `Record` access, optional param | Stop. Either give the field a real initial value (preferred — see cookbook § Data model template), or narrow at this read: `?.` / `?? fallback` / `if (x !== undefined)`. |
126
+ | A modifier, enum member, constructor, `$r('sys.…')` resource name, or params-passing call you have not personally verified in the cookbook this session | Stop. Look it up. Copy the cookbook shape verbatim; do not improvise (§ Router params, § Enum members, § System resource names). |
127
+ | A `@Builder` parameter typed `: string` / `: number` / `: boolean`, where the call site passes `this.<stateMember>` | Stop. A by-value `@Builder` parameter does **not** subscribe — the builder body never re-renders and the screen keeps the old value while the store holds the new one. Pass `$$this.x`, read `this.x` inside the builder, or split the fragment into `@Component` + `@Prop`/`@Link`. |
128
+ | A `ForEach` / `LazyForEach` keyGenerator (3rd arg) | Stop. The key must include **the state value the item renders**, not just the index or a static id — otherwise a change to that value does not rebuild the item. |
129
+ | `<x>Controller.<setter>()` (`caretPosition`, `scrollTo`, …) in a component whose `on<X>Change` writes the same state member | Stop. The callback fires after you and overwrites what you just set. Guard with a suppression flag, or hold a semantic anchor (line index / item id) instead of a raw offset. Symptom shape: the forward action passes, the inverse action fails. |
130
+ | A `boolean` state member whose **only** writes sit inside an engine subscription (`.on('stateChange', …)`, `.then(…)`) | Stop. If that event never arrives the control renders its initial value forever, and every test that must first drive this control dies at step 1. Add a synchronous write (optimistic update + rollback) and a timeout fallback state. |
131
+
132
+ These three categories account for nearly all recurring violations; keep them active while typing. The last four rows are **state-propagation** traps: they compile clean, pass codelinter, and fail only on device as "value stored, screen never changes" — see [`ui/state-management.md`](ui/state-management.md) § State written but never rendered, and the mechanical scan in `scripts/state_propagation_check.mjs`.
133
+
134
+ ## Per-file gate (run after EVERY .ets file, before the next one)
135
+
136
+ Re-open the file you just wrote and run three scans — scan the actual content, do not answer from memory of what you intended to write:
137
+
138
+ 1. **Triggers** — the three write-time trigger patterns above: untyped `{` literals (including call arguments and callback returns; Record keys quoted; class literals listing every field), unnarrowed possibly-`undefined` reads (`?:`, `.get(`, `[i]`, Record access), and any enum member / modifier / constructor / resource name not verified in the cookbook this session
139
+ 2. **Imports** — every type, helper, and kit this file references is imported at the top, from the correct `@kit.*`
140
+ 3. **Names** — the struct name does not collide with any import; no member is named after a universal attribute (`opacity`, `scale`, `tabIndex`, `size`, `width`, …); any interface/type other files will also need lives in a shared model file, not redeclared here
141
+
142
+ **Write the gate result down.** After each file, output one line in your response — e.g. `Index.ets: triggers✓ imports✓ names✓` — before starting the next file. A gate answered silently gets skipped under generation pressure; the written line is the evidence it ran. If a scan caught something, note the fix inline (`names✗→renamed opacity→circleOpacity`) and fix it now — caught here it costs one edit; caught after all files are written it costs a fix round across every file that copied it.
143
+
144
+ **Sequencing rule: the write call for file N+1 is not allowed until the gate line for file N appears in your response.** Two write calls back-to-back mean the gate was skipped. Batch-writing all files and reviewing once at the end is NOT a substitute, and neither is asserting from memory that the files are clean — a session that did exactly that shipped a 16-error first check that its per-file scans would have caught at files 1 and 4.
145
+
146
+ ## Scenario routing table
147
+
148
+ | Scenario | Read |
149
+ |----------|------|
150
+ | Error message contains an `arkts-xxx` rule tag | `language/arkts-rules.md` — search for the exact tag for details and good/bad examples |
151
+ | `does not meet UI component syntax` / `Only UI component syntax can be written here` / `can have only one root node` / `UI component 'X' cannot be used in this place` | `language/arkui-structure-rules.md` |
152
+ | Writing UI with Tabs, List/Grid + ForEach, forms, dialogs/toasts, DatePicker, gradients, or navigation | `ui/component-cookbook.md` — verified constructors, modifiers, enums, callbacks |
153
+ | Passing params between pages (`router.pushUrl` + `getParams`) | `ui/component-cookbook.md` § Router params — exactly one shape passes the checker; do not improvise |
154
+ | Designing a data model class / a detail page that looks up an item | `ui/component-cookbook.md` § Data model + detail page template — kills `possibly 'undefined'` at the design level |
155
+ | Creating seed/mock data, or error `is missing the following properties from type` | `ui/component-cookbook.md` § Creating instances with data — class-body defaults do not make literal fields optional |
156
+ | Before finalizing a UI change (visibility, interaction, layout quality) | `ui/ui-quality.md` |
157
+ | Diagnosing a runtime UI failure that survived a fix round (collapsed bounds, wrong pixels, dead gesture) | `ui/ui-runtime-diagnosis.md` — measure-chain walk + layer attribution, evidence before the next fix |
158
+ | Build/compile error WITHOUT an `arkts-*` tag and not UI-structural (hvigor, dependencies, signing) | `../pipeline/build/build.md` build-fix loop (match `build-lessons.jsonl` first; an uncertain official signature → § API signature lookup above) |
159
+ | State management / MVVM (choose V1 or V2, never mix; new projects prefer V2) | `ui/state-management.md` — family selection policy + V1/V2 cheat sheets, pointing to the official docs `official/mvvm-v1/` and `official/mvvm-v2/` |
160
+ | Porting plain TypeScript into ArkTS strict mode | `language/ts-to-arkts-rewrites.md` rewrite table |
161
+ | Unsure whether a construct is allowed | Check "Avoid over-restriction" above first, then [`language/arkts-rules.md` § Explicitly allowed constructs](language/arkts-rules.md#explicitly-allowed-constructs) and the Rule Index |
162
+ | Sendable / concurrency | [`language/arkts-rules.md` § 10. Sendable concurrency restrictions](language/arkts-rules.md#10-sendable-concurrency-restrictions) |
163
+ | Project style conventions (naming / formatting / file org / comments / `$r()` resources) | `conventions/coding-style.md` |
164
+ | Build / secure / test the project | build: `../pipeline/build/build.md` (pinned `devecocli build`); security: `conventions/security.md`; test: `../pipeline/testing/` (L0/L1/e2e contracts) |
165
+ | Language-level project conventions (prefer-undefined, Map→Record) | [`language/arkts-rules.md` § Project conventions](language/arkts-rules.md#project-conventions-not-official-linter-rules) |
166
+
167
+ Division of labor: this reference = language/linter rules + ArkUI structure and component APIs (everything needed to write `.ets` that compiles); build/test execution = `rules/pipeline/` (build-fix loop, testing layers); project-learned runtime pitfalls = `memory/code-pattern-lessons.jsonl` (per its ownership in `rules/pipeline/memory/memory-model.md`).
168
+
169
+ ## Source attribution
170
+
171
+ - Anything with an `arkts-*` rule tag is a linter/language rule; violations are errors
172
+ - ArkUI structural constraints (single root node, UI-syntax-only placement) are compiler rules without `arkts-*` tags; they surface at build time
173
+ - The "Project conventions" section (prefer-undefined, Map-to-Record conversion, etc.) contains team conventions; when citing them, say they are project conventions — do not present them as ArkTS language restrictions. (Quoted keys in Record literals are NOT a convention — the checker enforces them as `arkts-no-untyped-obj-literals`.)
174
+
175
+ ## Change-set checks (once over the whole change set, after the per-file gates)
176
+
177
+ Cross-file and config consistency the per-file gate cannot see — language-rule violations are already covered by the gate, do not re-audit them here:
178
+
179
+ - [ ] Every page in `main_pages.json` has exactly one `@Entry` struct; embedded child components are NOT listed there
180
+ - [ ] `user_grant` permissions in `module.json5` declare both `reason` (an existing `$string:` resource) and `usedScene`
181
+ - [ ] Every shared interface/type is declared in exactly ONE model file and imported everywhere else
182
+ - [ ] Every referenced type/enum/constant is actually declared and exported where it is imported from
183
+ - [ ] `ForEach`/`LazyForEach` has a keyGenerator (third arg) using a business ID, not the index (verified form: `ui/component-cookbook.md` § List, Grid, and ForEach)
184
+ - [ ] No bare global UI APIs (`router.*`, `promptAction.*`, `animateTo`, `vp2px`) — routed through `this.getUIContext()`; no bare global `getContext()` — use `this.getUIContext().getHostContext()`
@@ -0,0 +1,96 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ets"
4
+ - "**/*.ts"
5
+ ---
6
+ # HarmonyOS / ArkTS Coding Style
7
+
8
+ > Project **style conventions** for the coding stage (and the UI skills). The ArkTS **language/linter rules** are NOT duplicated here — see the sibling files in this directory.
9
+
10
+ ## ArkTS Language Constraints
11
+
12
+ The full ArkTS language/linter rule set (no `any`, no destructuring, no index signatures, object-literal type context, null safety, decorators, Sendable, etc.) lives in **`../language/arkts-rules.md`** (`arkts-*` tagged, with good/bad examples) and **`../language/arkui-structure-rules.md`** (build-stage structure). `../arkts-standards.md` is the overview + scenario router. This file covers only the project style conventions below.
13
+
14
+ ## Naming Conventions
15
+
16
+ - Variables / functions: `camelCase` (e.g., `getUserInfo`, `goodsList`)
17
+ - Classes / interfaces: `PascalCase` (e.g., `UserViewModel`, `IGoodsModel`)
18
+ - Constants: `UPPER_SNAKE_CASE` (e.g., `MAX_PAGE_SIZE`, `COLOR_PRIMARY`)
19
+ - File names: `PascalCase` for components (e.g., `HomePage.ets`), `camelCase` for utilities
20
+
21
+ ## Formatting
22
+
23
+ - Prefer single quotes for strings (project convention; rule-set / official-doc examples may use double quotes — new project code follows this convention)
24
+ - Semicolons at end of statements
25
+ - Never use `var` - prefer `const`, then `let`
26
+ - All methods, parameters, return values must have complete type annotations
27
+
28
+ ## File Organization
29
+
30
+ - Component files (`.ets`): one component struct per file (`@ComponentV2` for V2 projects, `@Component` for V1)
31
+ - ViewModel files: one ViewModel class per file
32
+ - Model files: related data models may share a file
33
+ - Keep files under 400 lines; extract helpers for files approaching 800 lines
34
+
35
+ ## Function Size & Nesting
36
+
37
+ - Keep functions small — under ~50 lines and doing one thing; extract a helper once a function grows past that or mixes concerns.
38
+ - Limit nesting to ~4 levels — prefer early returns / guard clauses / extracted helpers over deep `if`/`for` pyramids.
39
+
40
+ ## Comments
41
+
42
+ - File header: `@file` (file purpose) + `@author` (developer), if the project already uses file headers
43
+ - Public methods: JSDoc with `@param`, `@returns`; add `@example` for complex methods
44
+ - Match the project's existing documentation language; use English unless the repository has already standardized on Chinese comments
45
+
46
+ ## Error Handling
47
+
48
+ ```ets
49
+ // Use try/catch with proper error handling
50
+ try {
51
+ const result = await riskyOperation()
52
+ return result
53
+ } catch (error) {
54
+ hilog.error(0x0000, 'TAG', 'Operation failed: %{public}s', error)
55
+ throw new Error('User-friendly error message')
56
+ }
57
+ ```
58
+
59
+ Never silently swallow — an empty `catch {}` that drops the error is forbidden; log with context (`hilog`) or rethrow a user-facing error.
60
+
61
+ ## Immutability
62
+
63
+ Scope: non-reactive data only (params, models passed across layers). Reactive state (`@Observed`/`@Trace`-tracked objects) is mutated in place **by design** — the framework observes property mutation (`../ui/state-management.md`); do not "fix" those mutations into copies.
64
+
65
+ Follow the common immutability principles - create new objects instead of mutating:
66
+
67
+ ```ets
68
+ // BAD: mutation
69
+ function updateUser(user: UserModel, name: string): UserModel {
70
+ user.name = name // direct mutation
71
+ return user
72
+ }
73
+
74
+ // GOOD: immutable - create new instance
75
+ function updateUser(user: UserModel, name: string): UserModel {
76
+ const updated = new UserModel()
77
+ updated.id = user.id
78
+ updated.name = name
79
+ updated.email = user.email
80
+ return updated
81
+ }
82
+ ```
83
+
84
+ ## Resource References
85
+
86
+ Define UI constants as resources and reference via `$r()` — do not hardcode colors, sizes, or display strings. Scope: production UI code; cookbook / rules snippets hardcode literals to demonstrate API shape — copy the shape, not the literals:
87
+
88
+ ```ets
89
+ // BAD: hardcoded values
90
+ Text('Hello').fontSize(16).fontColor('#333333')
91
+
92
+ // GOOD: resource references
93
+ Text($r('app.string.greeting'))
94
+ .fontSize($r('app.float.font_size_body'))
95
+ .fontColor($r('app.color.text_primary'))
96
+ ```
@@ -0,0 +1,126 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ets"
4
+ - "**/*.ts"
5
+ - "**/module.json5"
6
+ ---
7
+ # HarmonyOS / ArkTS Security
8
+
9
+ > ArkTS security rules for the coding stage (and the UI skills).
10
+
11
+ ## Permission Management
12
+
13
+ Declaring `requestPermissions` in `module.json5` — with the mandatory `reason` (an existing `$string:` resource) and `usedScene` for every `user_grant` permission — is a compile-time hard constraint owned by [`../arkts-standards.md`](../arkts-standards.md) § Core hard constraints; the build fails without them. This file covers the runtime security posture around permissions, not the declaration syntax.
14
+
15
+ ### Runtime permission checklist
16
+
17
+ Before calling a permission-gated system API, verify:
18
+
19
+ - [ ] Runtime permission request implemented for sensitive permissions (camera, location, etc.)
20
+ - [ ] Permission check before the API call, with graceful fallback on denial
21
+
22
+ ### Runtime Permission Request
23
+
24
+ ```ets
25
+ import { abilityAccessCtrl, bundleManager, common, Permissions } from '@kit.AbilityKit';
26
+
27
+ // context: the caller's ability context — in a component, this.getUIContext().getHostContext()
28
+ // (never the bare global getContext(), per the change-set checks in arkts-standards.md)
29
+ async function checkAndRequestPermission(context: common.Context, permission: Permissions): Promise<boolean> {
30
+ const atManager = abilityAccessCtrl.createAtManager();
31
+ const bundleInfo = await bundleManager.getBundleInfoForSelf(
32
+ bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION
33
+ );
34
+ const tokenId = bundleInfo.appInfo.accessTokenId;
35
+ const grantStatus = await atManager.checkAccessToken(tokenId, permission);
36
+
37
+ if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
38
+ return true;
39
+ }
40
+
41
+ const result = await atManager.requestPermissionsFromUser(context, [permission]);
42
+ return result.authResults[0] === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
43
+ }
44
+ ```
45
+
46
+ ## Secret Management
47
+
48
+ - **NEVER** hardcode API keys, tokens, or passwords in `.ets`/`.ts` source files
49
+ - Use HarmonyOS Preferences API for non-sensitive configuration
50
+ - Use HarmonyOS Keystore for sensitive credentials
51
+ - Environment-specific configs should be managed via build profiles
52
+
53
+ ```ets
54
+ // BAD: hardcoded secret
55
+ const API_KEY: string = 'sk-xxxxxxxxxxxx';
56
+
57
+ // GOOD: from build profile config (non-sensitive)
58
+ import { BuildProfile } from 'BuildProfile';
59
+ const endpoint = BuildProfile.API_ENDPOINT;
60
+
61
+ // GOOD: use HUKS to encrypt/decrypt data without exposing key material
62
+ import { huks } from '@kit.UniversalKeystoreKit';
63
+ async function decryptWithKeystore(alias: string, nonce: Uint8Array, aad: Uint8Array, cipherData: Uint8Array): Promise<Uint8Array> {
64
+ const options: huks.HuksOptions = {
65
+ properties: [
66
+ { tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES },
67
+ { tag: huks.HuksTag.HUKS_TAG_PURPOSE, value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT },
68
+ { tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, value: huks.HuksCipherMode.HUKS_MODE_GCM },
69
+ { tag: huks.HuksTag.HUKS_TAG_PADDING, value: huks.HuksKeyPadding.HUKS_PADDING_NONE },
70
+ { tag: huks.HuksTag.HUKS_TAG_NONCE, value: nonce },
71
+ { tag: huks.HuksTag.HUKS_TAG_ASSOCIATED_DATA, value: aad }
72
+ ],
73
+ inData: cipherData
74
+ };
75
+ const handle = await huks.initSession(alias, options);
76
+ const result = await huks.finishSession(handle.handle, options);
77
+ return result.outData;
78
+ }
79
+ ```
80
+
81
+ ## Input Validation
82
+
83
+ - Validate all user input before processing
84
+ - Sanitize data before displaying in UI to prevent injection
85
+ - Validate deep link parameters before navigation
86
+
87
+ ```ets
88
+ import { url } from '@kit.ArkTS';
89
+ import { hilog } from '@kit.PerformanceAnalysisKit';
90
+
91
+ // Validate before navigation. navPathStack: the page's own NavPathStack
92
+ // (bound to its Navigation); no ArkTS `new URL` — parse via @kit.ArkTS url.
93
+ function handleDeepLink(uri: string, navPathStack: NavPathStack): void {
94
+ const allowedPaths: string[] = ['detail', 'settings', 'profile'];
95
+ const parsed = url.URL.parseURL(uri);
96
+ const path = parsed.pathname.replace('/', '');
97
+
98
+ if (!allowedPaths.includes(path)) {
99
+ hilog.warn(0x0000, 'DeepLink', 'Invalid deep link path: %{public}s', path);
100
+ return;
101
+ }
102
+
103
+ navPathStack.pushPath({ name: path });
104
+ }
105
+ ```
106
+
107
+ ## Network Security
108
+
109
+ - Always use HTTPS for network requests
110
+ - Validate server certificates
111
+ - Implement request timeout and retry policies
112
+ - Never log sensitive data (tokens, user credentials) in network request/response logs
113
+
114
+ ## Data Storage Security
115
+
116
+ - Use encrypted preferences for sensitive local data
117
+ - Clear sensitive data from memory when no longer needed
118
+ - Implement proper data lifecycle management
119
+ - Consider data classification (public, internal, confidential) when choosing storage mechanisms
120
+
121
+ ## Dependency Security
122
+
123
+ - Only use dependencies from trusted sources (official ohpm registry)
124
+ - Verify dependency versions in `oh-package.json5`
125
+ - Regularly check for known vulnerabilities in third-party libraries
126
+ - Pin dependency versions to avoid unexpected updates