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,330 @@
1
+ ---
2
+
3
+ name: a2h-spec-design
4
+ description: Generate concise SPEC_name_design.md for an input SPEC by using project_design.md, database_design.md, preferences_design.md, on-demand module_design.md, configurable engine (GitNexus, CodeGraph, or Homegraph) evidence, and directed source lookup. Only for the a2h scenario (Android-to-HarmonyOS migration); do not invoke for hmos-only or non-migration projects.
5
+ argument-hint: <target_directory> <input_file> "<ui_operation_sequence>" [--task spec|ui] [--engine gitnexus|codegraph|homegraph] [--engine-mode auto|off|required] [--database-design <database_design_file>] [--preferences-design <preferences_design_file>] [--mvvm true|false] [--output-dir <output_directory>] [--output-file <output_file>]
6
+ allowed-tools:
7
+
8
+ * Read
9
+ * Glob
10
+ * Grep
11
+ * Bash
12
+ * Write
13
+
14
+ ---
15
+
16
+ # Spec Design Skill
17
+
18
+ ## Purpose
19
+
20
+ Generate `<SPEC_name>_design.md` for an input SPEC.
21
+
22
+ Inputs are the SPEC file, the raw UI operation sequence, `<target_directory>/project_design.md`, optional `database_design.md`, optional `preferences_design.md`, selected `module_design.md`, configurable engine evidence (GitNexus, CodeGraph, **or** Homegraph — selected by `--engine`), and directed local source lookup when needed.
23
+
24
+ All generated content in `<SPEC_name>_design.md` must be in Chinese.
25
+
26
+ ## Invocation
27
+
28
+ ```text
29
+ /spec-design <target_directory> <input_file> "<ui_operation_sequence>" [--task spec|ui] [--engine gitnexus|codegraph|homegraph] [--engine-mode auto|off|required] [--database-design <database_design_file>] [--preferences-design <preferences_design_file>] [--mvvm true|false] [--output-dir <output_directory>] [--output-file <output_file>]
30
+ ```
31
+
32
+ Arguments:
33
+
34
+ * `target_directory`: project root directory.
35
+ * `input_file`: task input file. For `--task spec`, this is the SPEC file.
36
+ * `ui_operation_sequence`: original UI operation sequence. Preserve it verbatim.
37
+ * `--task`: `spec` or `ui`. Default is `spec`. `ui` is reserved and not implemented.
38
+ * `--engine`: code-analysis engine, `gitnexus`, `codegraph`, or `homegraph`. Default is `homegraph`. Selects which backend the skill invokes in Step 6.
39
+ * `--engine-mode`: how strictly engine evidence is required, `auto`, `off`, or `required`. Default is `auto`. Behavior is identical for both engines (see Step 6).
40
+ * `--database-design`: optional database design file. Default is `<target_directory>/database_design.md`.
41
+ * `--preferences-design`: optional Preferences design file. Default is `<target_directory>/preferences_design.md`.
42
+ * `--mvvm`: `true` or `false`. Default is `false`. When `true`, related UI files and related logic files must be orthogonal.
43
+ * `--output-dir`: optional output directory. Default is the input file directory.
44
+ * `--output-file`: optional exact output file path. When supplied, the design is written to this path instead of `<output-dir>/<SPEC_name>_design.md`. Useful when an orchestrator wants a fixed filename regardless of the input file's stem (e.g. `SPEC_DESIGN_<N>.md`).
45
+
46
+ ## Output
47
+
48
+ Write the design file:
49
+
50
+ ```text
51
+ <output_directory>/<SPEC_name>_design.md
52
+ ```
53
+
54
+ `SPEC_name` is the `input_file` stem. If `--output-dir` is not provided, `output_directory` is the input file directory.
55
+
56
+ If `<SPEC_name>_design.md` already exists, stop immediately and report that it already exists.
57
+
58
+ After generation, run output validation. If deterministic output issues are detected, the validation script writes:
59
+
60
+ ```text
61
+ <output_directory>/<SPEC_name>_design_issue.md
62
+ ```
63
+
64
+ Do not silently modify the generated design file.
65
+
66
+ ## Workflow
67
+
68
+ ### Step 1: Validate Inputs
69
+
70
+ Run:
71
+
72
+ ```bash
73
+ node "${CLAUDE_SKILL_DIR}/scripts/inspect_spec_design_inputs.mjs" "<target_directory>" "<input_file>" --task <task_type> --engine <engine> --engine-mode <engine_mode> --mvvm <mvvm_mode> [--database-design <database_design_file>] [--preferences-design <preferences_design_file>] [--output-dir <output_directory>] [--output-file <output_file>]
74
+ ```
75
+
76
+ Stop if validation fails.
77
+
78
+ If `database_design.md` or `preferences_design.md` is missing, report the script warning and continue.
79
+
80
+ The validation script performs deterministic checks. Its output must include:
81
+
82
+ * `path_display_root`
83
+ * `has_database_design`
84
+ * `has_preferences_design`
85
+ * `is_mvvm`
86
+ * `design_path`
87
+ * `issue_path`
88
+
89
+ ### Step 2: Read Project Semantics
90
+
91
+ Read the `project_design` path from the validation script's JSON output.
92
+
93
+ Use only:
94
+
95
+ * `## 项目结构`
96
+ * `## 模块语义`
97
+
98
+ The `模块语义` table is the source of candidate module paths, module semantic descriptions, and final module ownership.
99
+
100
+ The final module-path table must use the same module granularity as `project_design.md`. For example, if `project_design.md` defines `model`, write `model`.
101
+
102
+ ### Step 3: Read Database/Preferences Evidence
103
+
104
+ If `has_database_design=true`, read `database_design.md`.
105
+
106
+ Use it as the first source for database files, table names, table dependencies, fields, field types, primary-key/foreign-key information, constraints, and table-entity relationships.
107
+
108
+ If `has_preferences_design=true`, read `preferences_design.md`.
109
+
110
+ Use it as the first source for Preferences files, keys, value types, and Preferences-entity relationships.
111
+
112
+ If either file is missing or unrelated, continue with later evidence. If no related database table or Preferences key is found, write `不涉及`.
113
+
114
+ ### Step 4: Select Candidate Modules
115
+
116
+ Select candidate modules from the `模块语义` table in `project_design.md`.
117
+
118
+ Selection evidence includes:
119
+
120
+ * SPEC content
121
+ * original UI operation sequence
122
+ * module paths and module semantic descriptions
123
+ * database table evidence
124
+ * Preferences key evidence
125
+ * data entity evidence
126
+ * UI and logic evidence
127
+
128
+ Selected modules should cover related UI, data entity, database, Preferences, and logic evidence for the current SPEC.
129
+
130
+ Selected modules are evidence modules. The final section `当前SPEC生成的代码所从属的模块路径` should include only module paths that actually need generated or modified code for the current SPEC.
131
+
132
+ ### Step 5: Load Module Semantics on Demand
133
+
134
+ For each selected candidate module, read its `module_design.md` if it exists (try `<target_directory>/.hometrans/<candidate_module>/module_design.md` first, then `<target_directory>/<candidate_module>/module_design.md`).
135
+
136
+ Use:
137
+
138
+ * module semantic descriptions copied from `project_design.md`
139
+ * file semantic descriptions copied from the `## 文件语义` table in `module_design.md`
140
+
141
+ If `module_design.md` is missing, or no matching file row exists, use `None`.
142
+
143
+ ### Step 6: Collect Engine Evidence
144
+
145
+ Use the code-analysis engine selected by `--engine` according to `--engine-mode`. All three engines share the same mode semantics:
146
+
147
+ * `auto`: attempt the engine with timeout `120000ms`. If it times out, or starts but does not complete, retry once with timeout `300000ms`. Use the successful output as auxiliary evidence. If both attempts fail, continue with local analysis.
148
+ * `off`: skip engine evidence entirely.
149
+ * `required`: stop generation if the selected engine cannot provide usable evidence.
150
+
151
+ **Homegraph (`--engine homegraph`, default):** the CLI binary is `homegraph`; ArkTS analysis additionally requires `arkanalyzer`. Resolve the CLI first (`homegraph` locally, else `npx -y -p homegraph@latest -p arkanalyzer@latest homegraph`), then run:
152
+
153
+ ```bash
154
+ homegraph init -i "<target_directory>"
155
+ ```
156
+
157
+ Once indexed, use `mcp__homegraph__search` / `explore` / `node` / `impact` / `callers` / `callees` / `files` for evidence, each scoped with `projectPath: "<target_directory>"`.
158
+
159
+ **GitNexus (`--engine gitnexus`):** resolve the CLI first (`gitnexus` locally, else `npx -y gitnexus@latest`), inspect syntax with `gitnexus --help` if unclear, then run:
160
+
161
+ ```bash
162
+ gitnexus analyze "<target_directory>"
163
+ ```
164
+
165
+ **CodeGraph (`--engine codegraph`):** resolve the CLI first (`codegraph` locally, else `npx -y @agentllm/codegraph-arkts`), inspect syntax with `<resolved_runner> --help` if unclear, then run the resolved runner against `<target_directory>`.
166
+
167
+ Engine evidence may only locate related UI, data entity, database, Preferences, logic files, table structures, Preferences keys, and their relationships. The engine **must not** rewrite semantic descriptions copied from `project_design.md` or `module_design.md`.
168
+
169
+ ### Step 7: Directed Source Lookup
170
+
171
+ Use local source lookup only when `database_design.md`, `preferences_design.md`, engine evidence (Step 6), and selected `module_design.md` are insufficient.
172
+
173
+ Rules:
174
+
175
+ 1. Search only inside candidate module directories derived from `project_design.md`.
176
+ 2. Search only with SPEC/UI-related keywords.
177
+ 3. Search keywords may include table names, database file names, entity names, Preferences file names, Preferences key names, UI component names, UI operation keywords, ViewModel names, Service names, Repository names, and Manager names.
178
+ 4. Prefer `Grep` before `Read`.
179
+ 5. Read only specific files needed to confirm paths, table structures, Preferences keys, data entities, file roles, or relationships.
180
+ 6. Do not scan or read the whole project indiscriminately.
181
+ 7. Do not use generated documentation files as implementation evidence.
182
+
183
+ ### Step 8: Generate `<SPEC_name>_design.md`
184
+
185
+ Use this evidence order:
186
+
187
+ * database-related content: `database_design.md` → engine evidence (Step 6) → selected `module_design.md` → directed source lookup
188
+ * Preferences-related content: `preferences_design.md` → engine evidence (Step 6) → selected `module_design.md` → directed source lookup
189
+ * UI, data entity, and logic files: `project_design.md` → selected `module_design.md` → engine evidence (Step 6) → directed source lookup
190
+
191
+ All paths must use `path_display_root` returned by the validation script:
192
+
193
+ ```text
194
+ <path_display_root>/<relative/path>
195
+ ```
196
+
197
+ Do not write the full absolute `target_directory` or any literal placeholder.
198
+
199
+ When `is_mvvm=true`, related UI files and related logic files must use different file paths.
200
+ When `is_mvvm=false`, the same file may appear in both sections if it carries both UI and logic roles.
201
+
202
+ Write the fixed format below and do not add extra sections:
203
+
204
+ ```md
205
+ # XX Spec编码设计
206
+
207
+ ## 相关 UI
208
+
209
+ ### UI 操作序列
210
+
211
+ {original_ui_operation_sequence}
212
+
213
+ ### 相关 UI 及文件路径
214
+
215
+ | 相关 UI | 相关UI语义表述 | 文件路径 |
216
+ |---|---|---|
217
+ | xxx | module_design.md中的文件功能原文 | <path_display_root>/<relative/path> |
218
+
219
+ ## 相关数据
220
+
221
+ ### 数据库表
222
+
223
+ **表名:xxx** (xxx)
224
+
225
+ 关联数据实体:xxx
226
+ 表依赖关系:xxx
227
+
228
+ | 字段 | 类型 | 主键/外键 | 约束 |
229
+ |------|------|------|------|
230
+ | xxx | xxx | PK、FK(xxx)、PK/FK(xxx) 或 None | xxx |
231
+
232
+ ### Preferences 相关键
233
+
234
+ | 文件 | key | 类型 |
235
+ |---|---|---|
236
+ | xxx | xxx | xxx |
237
+
238
+ ### 相关数据实体及文件路径
239
+
240
+ | 数据实体 | 数据实体语义表述 | 文件路径 |
241
+ |---|---|---|
242
+ | xxx | module_design.md中的文件功能原文 | <path_display_root>/<relative/path> |
243
+
244
+ ## 相关逻辑
245
+
246
+ ### 相关逻辑模块及文件路径
247
+
248
+ | 逻辑模块名字 | 模块语义描述 | 逻辑文件名字 | 文件语义描述 | 文件路径 |
249
+ |---|---|---|---|---|
250
+ | xxx | project_design.md中的模块功能原文 | xxx | module_design.md中的文件功能原文 | <path_display_root>/<relative/path> |
251
+
252
+ ## 当前SPEC生成的代码所从属的模块路径
253
+
254
+ | 模块路径 |
255
+ |---|
256
+ | <path_display_root>/<relative/module/path> |
257
+ ```
258
+
259
+ If no database table is found, write:
260
+
261
+ ```text
262
+ 不涉及
263
+ ```
264
+
265
+ If no Preferences key is found, write:
266
+
267
+ ```text
268
+ 不涉及
269
+ ```
270
+
271
+ If an entire file-path table has no content, write only:
272
+
273
+ ```text
274
+ 不涉及
275
+ ```
276
+
277
+ If a table field has no value, write `None`.
278
+
279
+ For database table metadata, omit `关联数据实体` when it is `None`, and omit `表依赖关系` when it is `None`.
280
+
281
+ ### Step 9: Relocate Technical Reference Section
282
+
283
+ After writing `<SPEC_name>_design.md`, run:
284
+
285
+ ```bash
286
+ node "${CLAUDE_SKILL_DIR}/scripts/move_spec_technical_reference.mjs" "<input_file>" "<design_path>"
287
+ ```
288
+
289
+ If the input SPEC contains an exact level-2 section named `## 技术参考`, the script moves the complete section from the input SPEC to `<SPEC_name>_design.md` immediately before `## 相关 UI`.
290
+
291
+ If the section does not exist, leave both files unchanged.
292
+
293
+ ### Step 10: Validate Generated Output
294
+
295
+ After Step 9, run:
296
+
297
+ ```bash
298
+ node "${CLAUDE_SKILL_DIR}/scripts/validate_spec_design_output.mjs" "<target_directory>" "<design_path>"
299
+ ```
300
+
301
+ If the script reports issues, keep the generated design file unchanged and report the issue file path.
302
+
303
+ ## Output Rules
304
+
305
+ 1. Names must be direct identifiers only: module name, class name, component name, file name, table name, entity name, database file name, or Preferences key.
306
+ 2. Do not append Chinese explanations inside name fields.
307
+ 3. `相关 UI` must be a direct UI identifier, such as a page/component/class/function/file name. Do not write descriptive UI phrases or names with parentheses.
308
+ 4. `模块语义描述` must be copied from `project_design.md`.
309
+ 5. `文件语义描述` must be copied from `module_design.md`.
310
+ 6. Preserve the original UI operation sequence verbatim.
311
+ 7. Each row in the final module-path table must be a module path selected from the `模块语义` table in `project_design.md`.
312
+ 8. The final module-path table may contain one or more rows, depending on which modules actually require generated or modified code for the current SPEC. Related UI, data, database, Preferences, and logic evidence should not be included unless their owning modules require generated or modified code.
313
+ 9. Ownership is resolved using the module granularity from `project_design.md`.
314
+ 10. For each database table, generate one table block.
315
+ 11. `表名` is the database table name. The parentheses contain the database file name or `None`.
316
+ 12. `关联数据实体` contains the related entity name. Omit this line if no related entity is found.
317
+ 13. `表依赖关系` contains the table-level relationship. Omit this line if no table relationship is found.
318
+ 14. Database field tables use `字段`, `类型`, `主键/外键`, and `约束`.
319
+ 15. `主键/外键` may contain `PK`, `FK(target_table.target_field)`, `PK/FK(target_table.target_field)`, or `None`.
320
+ 16. `FOREIGN KEY` only represents a physical SQLite foreign-key constraint when it is explicitly declared in source or `database_design.md`.
321
+ 17. If a relationship is only inferred from naming or usage and no physical foreign-key constraint is declared, write it in `表依赖关系`; do not write `FOREIGN KEY` as a field constraint.
322
+ 18. `约束` may contain `NOT NULL`, `UNIQUE`, `INDEX`, `DEFAULT`, `CHECK`, `FOREIGN KEY`, or `None`.
323
+ 19. `Preferences 相关键` uses only `文件`, `key`, and `类型`.
324
+ 20. Preferences key relationships are used as coverage evidence.
325
+ 21. Related data entities should appear in `### 相关数据实体及文件路径` when confirmed.
326
+ 22. In file-path tables, each row must point to an existing file. If the path is missing, nonexistent, a directory, or only inferred, omit the row.
327
+ 23. File-path table rows must not contain `None`. If the related file or description cannot be confirmed, omit the row.
328
+ 24. If no database table is involved, write `不涉及` under `### 数据库表`.
329
+ 25. If no Preferences key is involved, write `不涉及` under `### Preferences 相关键`.
330
+ 26. Run the output validation script after generation. The script only reports deterministic issues and writes an issue file; it must not modify the design file.
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+ import { homedir } from 'node:os';
3
+ import { basename, dirname, extname, join, resolve } from 'node:path';
4
+ import { existsSync, statSync } from 'node:fs';
5
+
6
+ const VALUE_FLAGS = new Set([
7
+ 'task',
8
+ 'engine',
9
+ 'engine-mode',
10
+ 'database-design',
11
+ 'preferences-design',
12
+ 'mvvm',
13
+ 'output-dir',
14
+ 'output-file',
15
+ ]);
16
+
17
+ function emit(payload, code = 0) {
18
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
19
+ process.exit(code);
20
+ }
21
+
22
+ function fail(message, extra = {}) {
23
+ emit({ ok: false, error: message, ...extra }, 1);
24
+ }
25
+
26
+ function expanduser(p) {
27
+ if (p === '~') return homedir();
28
+ if (p.startsWith('~/') || p.startsWith('~\\')) return join(homedir(), p.slice(2));
29
+ return p;
30
+ }
31
+
32
+ function isDir(p) {
33
+ try {
34
+ return statSync(p).isDirectory();
35
+ } catch {
36
+ return false;
37
+ }
38
+ }
39
+
40
+ function isFile(p) {
41
+ try {
42
+ return statSync(p).isFile();
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+
48
+ function stem(p) {
49
+ return basename(p, extname(p));
50
+ }
51
+
52
+ function parseArgs(argv) {
53
+ const positionals = [];
54
+ const opts = {};
55
+
56
+ for (let i = 0; i < argv.length; i++) {
57
+ const arg = argv[i];
58
+ if (!arg.startsWith('--')) {
59
+ positionals.push(arg);
60
+ continue;
61
+ }
62
+
63
+ let key = arg.slice(2);
64
+ let inlineValue;
65
+ const eq = arg.indexOf('=');
66
+ if (eq !== -1) {
67
+ key = arg.slice(2, eq);
68
+ inlineValue = arg.slice(eq + 1);
69
+ }
70
+
71
+ if (VALUE_FLAGS.has(key)) {
72
+ let value = inlineValue;
73
+ if (value === undefined) {
74
+ value = argv[++i];
75
+ }
76
+ opts[key] = value;
77
+ } else {
78
+ opts[key] = inlineValue !== undefined ? inlineValue : true;
79
+ }
80
+ }
81
+
82
+ return { positionals, opts };
83
+ }
84
+
85
+ function main() {
86
+ const { positionals, opts } = parseArgs(process.argv.slice(2));
87
+
88
+ const targetArg = positionals[0];
89
+ const inputFileArg = positionals[1];
90
+ if (targetArg === undefined || inputFileArg === undefined) {
91
+ fail('缺少 target_directory 或 input_file 参数。');
92
+ }
93
+
94
+ const task = opts.task ?? 'spec';
95
+ if (!['spec', 'ui'].includes(task)) {
96
+ fail(`argument --task: invalid choice: '${task}' (choose from 'spec', 'ui')`);
97
+ }
98
+ const engine = opts.engine ?? 'homegraph';
99
+ if (!['gitnexus', 'codegraph', 'homegraph'].includes(engine)) {
100
+ fail(`argument --engine: invalid choice: '${engine}' (choose from 'gitnexus', 'codegraph', 'homegraph')`);
101
+ }
102
+ const engineMode = opts['engine-mode'] ?? 'auto';
103
+ if (!['auto', 'off', 'required'].includes(engineMode)) {
104
+ fail(`argument --engine-mode: invalid choice: '${engineMode}' (choose from 'auto', 'off', 'required')`);
105
+ }
106
+ const mvvm = opts.mvvm ?? 'false';
107
+ if (!['true', 'false'].includes(mvvm)) {
108
+ fail(`argument --mvvm: invalid choice: '${mvvm}' (choose from 'true', 'false')`);
109
+ }
110
+
111
+ const root = resolve(expanduser(targetArg));
112
+ const inputFile = resolve(expanduser(inputFileArg));
113
+ const hometransDir = join(root, '.hometrans');
114
+
115
+ if (!isDir(root)) {
116
+ fail('target_directory 不存在或不是目录。', { target_directory: root });
117
+ }
118
+ if (!isFile(inputFile)) {
119
+ fail('input_file 不存在。', { input_file: inputFile });
120
+ }
121
+
122
+ let projectDesign = join(hometransDir, 'project_design.md');
123
+ if (!isFile(projectDesign)) {
124
+ projectDesign = join(root, 'project_design.md');
125
+ }
126
+ if (!isFile(projectDesign)) {
127
+ fail('未找到 project_design.md(已尝试 .hometrans/ 和项目根目录)', {
128
+ project_design: projectDesign,
129
+ });
130
+ }
131
+
132
+ if (task === 'ui') {
133
+ fail('task=ui 已预留,但当前未实现输出格式。', { task });
134
+ }
135
+
136
+ const outputDir = opts['output-dir']
137
+ ? resolve(expanduser(opts['output-dir']))
138
+ : dirname(inputFile);
139
+ if (!isDir(outputDir)) {
140
+ fail('output_dir 不存在或不是目录。', { output_dir: outputDir });
141
+ }
142
+
143
+ const designPath = opts['output-file']
144
+ ? resolve(expanduser(opts['output-file']))
145
+ : join(outputDir, `${stem(inputFile)}_design.md`);
146
+
147
+ if (opts['output-file'] && !isDir(dirname(designPath))) {
148
+ fail('output_file 的父目录不存在或不是目录。', { output_file: designPath });
149
+ }
150
+ if (existsSync(designPath)) {
151
+ fail(`${basename(designPath)} 已存在,停止生成。`, { design_path: designPath });
152
+ }
153
+
154
+ const issuePath = join(dirname(designPath), `${stem(designPath)}_issue.md`);
155
+
156
+ let databaseDesign = opts['database-design']
157
+ ? resolve(expanduser(opts['database-design']))
158
+ : resolve(join(hometransDir, 'database_design.md'));
159
+ if (!isFile(databaseDesign)) {
160
+ databaseDesign = resolve(join(root, 'database_design.md'));
161
+ }
162
+
163
+ let preferencesDesign = opts['preferences-design']
164
+ ? resolve(expanduser(opts['preferences-design']))
165
+ : resolve(join(hometransDir, 'preferences_design.md'));
166
+ if (!isFile(preferencesDesign)) {
167
+ preferencesDesign = resolve(join(root, 'preferences_design.md'));
168
+ }
169
+
170
+ const hasDatabaseDesign = isFile(databaseDesign);
171
+ const hasPreferencesDesign = isFile(preferencesDesign);
172
+
173
+ const warnings = [];
174
+ if (!hasDatabaseDesign) {
175
+ warnings.push(`database_design.md 不存在(已尝试 .hometrans/ 和根目录):${databaseDesign}`);
176
+ }
177
+ if (!hasPreferencesDesign) {
178
+ warnings.push(`preferences_design.md 不存在(已尝试 .hometrans/ 和根目录):${preferencesDesign}`);
179
+ }
180
+
181
+ const docLayout = isFile(join(hometransDir, 'project_design.md')) ? 'hometrans' : 'source';
182
+
183
+ emit({
184
+ ok: true,
185
+ task,
186
+ engine,
187
+ engine_mode: engineMode,
188
+ target_directory: root,
189
+ project_root_name: basename(root),
190
+ path_display_root: `/${basename(root)}`,
191
+ doc_layout: docLayout,
192
+ input_file: inputFile,
193
+ project_design: projectDesign,
194
+ database_design: databaseDesign,
195
+ has_database_design: hasDatabaseDesign,
196
+ preferences_design: preferencesDesign,
197
+ has_preferences_design: hasPreferencesDesign,
198
+ output_directory: outputDir,
199
+ design_path: designPath,
200
+ issue_path: issuePath,
201
+ warnings,
202
+ mvvm,
203
+ is_mvvm: mvvm === 'true',
204
+ });
205
+ }
206
+
207
+ main();