@ohos-cpf/3rdloop 0.0.7 → 0.0.9

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 (230) hide show
  1. package/README.md +44 -25
  2. package/lib/cli.js +54 -29
  3. package/lib/config-cmd.js +1 -1
  4. package/lib/config.js +32 -0
  5. package/lib/doctor.js +266 -48
  6. package/lib/mcp.js +498 -0
  7. package/lib/opencode.js +75 -29
  8. package/lib/orch.js +32 -10
  9. package/lib/runner.js +8 -5
  10. package/lib/serve.js +162 -149
  11. package/lib/step.js +15 -4
  12. package/lib/web.js +107 -265
  13. package/lib/workflow.js +18 -8
  14. package/package.json +6 -2
  15. package/vendor/Archive/data/.index/meta.json +7 -0
  16. package/vendor/Archive/data/.index/search.db +0 -0
  17. package/vendor/Archive/data/docs/experiences/arkts-check-tool-pitfalls-baseline-comparison.md +13 -0
  18. package/vendor/Archive/data/docs/experiences/arkts-deep-path-import-recognition.md +31 -0
  19. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-entry-file-case-mismatch.md +25 -0
  20. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-import-trailing-slash.md +20 -0
  21. package/vendor/Archive/data/docs/experiences/arkts-library-source-files-may-be-ts.md +18 -0
  22. package/vendor/Archive/data/docs/experiences/arkts-typedarray-buffer-interface-cast-compile-fixes.md +36 -0
  23. package/vendor/Archive/data/docs/experiences/arkts-xts-compile-error-clustering-fix.md +24 -0
  24. package/vendor/Archive/data/docs/experiences/arkts-xts-doc-expected-value-runtime-probe.md +35 -0
  25. package/vendor/Archive/data/docs/experiences/arkts-xts-fixture-rawfile-testability-injection.md +33 -0
  26. package/vendor/Archive/data/docs/experiences/code-linter-chinese-comment-false-positive.md +16 -0
  27. package/vendor/Archive/data/docs/experiences/esobject-new-expression-variable-tracking.md +33 -0
  28. package/vendor/Archive/data/docs/experiences/filesystem-case-sensitivity-module-resolution.md +31 -0
  29. package/vendor/Archive/data/docs/experiences/gitcode-clone-redirect-warning-normal.md +13 -0
  30. package/vendor/Archive/data/docs/experiences/kn_msgvq1w585ec8319.md +77 -0
  31. package/vendor/Archive/data/docs/experiences/kn_msovnm6rd46de72c.md +98 -0
  32. package/vendor/Archive/data/docs/experiences/kn_mspt8vntfe708576.md +87 -0
  33. package/vendor/Archive/data/docs/experiences/kn_mspu1ei77adbbb48.md +133 -0
  34. package/vendor/Archive/data/docs/experiences/kn_mspubgak8d30bfce.md +128 -0
  35. package/vendor/Archive/data/docs/experiences/kn_mspug2de3cb1f7c3.md +115 -0
  36. package/vendor/Archive/data/docs/experiences/kn_skill_opt_001.md +38 -0
  37. package/vendor/Archive/data/docs/experiences/loop-artifacts-verification-evidence-triangle.md +19 -0
  38. package/vendor/Archive/data/docs/experiences/macos-bash-replace-build-ps1.md +19 -0
  39. package/vendor/Archive/data/docs/experiences/macos-bsd-diff-q-illegal-option.md +15 -0
  40. package/vendor/Archive/data/docs/experiences/migrate-cjs-compatible-api-version-map-limit.md +17 -0
  41. package/vendor/Archive/data/docs/experiences/mp3agic-arkts-library-behavior-quirks.md +21 -0
  42. package/vendor/Archive/data/docs/experiences/ohos-face-detection-scan-api-mapping.md +15 -0
  43. package/vendor/Archive/data/docs/experiences/pr-metadata-and-diff-integrity-verification.md +12 -0
  44. package/vendor/Archive/data/docs/experiences/rn-coverage-index-signature-pseudo-member-false-negative.md +32 -0
  45. package/vendor/Archive/data/docs/experiences/rn-memory-check-severity-calibration.md +21 -0
  46. package/vendor/Archive/data/docs/experiences/rn-platform-specific-api-exclusion-evidence.md +24 -0
  47. package/vendor/Archive/data/docs/experiences/rn-upstream-version-diff-pitfalls.md +17 -0
  48. package/vendor/Archive/data/docs/experiences/rn-version-gap-risk-rating-rules.md +13 -0
  49. package/vendor/Archive/data/docs/experiences/rn-view-lib-native-contract-diff-fabric-spec.md +16 -0
  50. package/vendor/Archive/data/docs/experiences/rnoh-adapter-package-version-field-semantics.md +18 -0
  51. package/vendor/Archive/data/docs/experiences/rnoh-arkts-sqlite-rows-array-format.md +18 -0
  52. package/vendor/Archive/data/docs/experiences/rnoh-dependency-residue-scan-strategy.md +18 -0
  53. package/vendor/Archive/data/docs/experiences/rnoh-example-local-lib-dep-use-tgz.md +53 -0
  54. package/vendor/Archive/data/docs/experiences/rnoh-example-prereserve-rntesterlist.md +17 -0
  55. package/vendor/Archive/data/docs/experiences/rnoh-example-template-compatiblesdkversion-upgrade.md +29 -0
  56. package/vendor/Archive/data/docs/experiences/rnoh-example-turbomodule-shell-adaptation-checklist.md +41 -0
  57. package/vendor/Archive/data/docs/experiences/rnoh-mcp-build-project-tool-risk.md +18 -0
  58. package/vendor/Archive/data/docs/experiences/rnoh-npm-devdependencies-version-precheck.md +29 -0
  59. package/vendor/Archive/data/docs/experiences/rnoh-repo-baseline-version-verification.md +13 -0
  60. package/vendor/Archive/data/docs/experiences/rnoh-repo-upstream-directory-mapping.md +18 -0
  61. package/vendor/Archive/data/docs/experiences/rnoh-stateless-library-zero-leak-verification.md +31 -0
  62. package/vendor/Archive/data/docs/experiences/rnoh-template-npmrc-credential-removal.md +15 -0
  63. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-codegen-wiring-verification.md +19 -0
  64. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-cpp-methodmap-compatibility-check.md +20 -0
  65. package/vendor/Archive/data/docs/experiences/scenario-doc-vs-source-signature-diff-four-patterns.md +24 -0
  66. package/vendor/Archive/data/docs/experiences/static-analysis-grep-cross-validation.md +29 -0
  67. package/vendor/Archive/demo.js +489 -0
  68. package/vendor/Archive/index.js +43 -0
  69. package/vendor/Archive/package.json +16 -0
  70. package/vendor/Archive/src/constants.js +83 -0
  71. package/vendor/Archive/src/data/stopwords.txt +110 -0
  72. package/vendor/Archive/src/data/synonyms.json +25 -0
  73. package/vendor/Archive/src/data/terms.txt +59 -0
  74. package/vendor/Archive/src/db/sqlite-backend.js +312 -0
  75. package/vendor/Archive/src/db/sqlite-schema.js +64 -0
  76. package/vendor/Archive/src/engine.js +501 -0
  77. package/vendor/Archive/src/index/index-manager.js +203 -0
  78. package/vendor/Archive/src/index/index-state.js +94 -0
  79. package/vendor/Archive/src/index/search-text-builder.js +106 -0
  80. package/vendor/Archive/src/index.js +22 -0
  81. package/vendor/Archive/src/parser/api-identifiers.js +121 -0
  82. package/vendor/Archive/src/parser/api-suffixes.js +48 -0
  83. package/vendor/Archive/src/parser/heading-normalize.js +40 -0
  84. package/vendor/Archive/src/parser/markdown-splitter.js +215 -0
  85. package/vendor/Archive/src/search/catalog-routing.js +87 -0
  86. package/vendor/Archive/src/search/fts-search.js +289 -0
  87. package/vendor/Archive/src/search/query-normalizer.js +159 -0
  88. package/vendor/Archive/src/search/query-rewriter.js +72 -0
  89. package/vendor/Archive/src/search/search-engine.js +72 -0
  90. package/vendor/Archive/src/search/snippet.js +64 -0
  91. package/vendor/Archive/src/store/dir-store.js +103 -0
  92. package/vendor/Archive/src/store/doc-store.js +36 -0
  93. package/vendor/Archive/src/tokenizer/lexicon.js +151 -0
  94. package/vendor/Archive/src/tokenizer/tokenizer.js +167 -0
  95. package/vendor/Archive/src/types.js +86 -0
  96. package/vendor/Archive/src/utils/hash.js +16 -0
  97. package/vendor/Archive/src/utils/lock.js +73 -0
  98. package/vendor/Archive/src/utils/path-safety.js +96 -0
  99. package/vendor/Archive/src/utils/paths.js +39 -0
  100. package/vendor/BadCase/rn/INDEX.md +127 -0
  101. package/vendor/BadCase/rn/cases/KI-001-webview/350/247/206/351/242/221/346/227/240/346/263/225/346/250/252/345/261/217.md +52 -0
  102. package/vendor/BadCase/rn/cases/KI-002-fastImage/347/203/255/346/233/264/346/226/260/345/233/276/347/211/207/345/244/261/350/264/245.md +37 -0
  103. package/vendor/BadCase/rn/cases/KI-003-wechat/347/274/251/347/225/245/345/233/276/346/234/254/345/234/260/345/233/276/347/211/207.md +62 -0
  104. package/vendor/BadCase/rn/cases/KI-004-wechat/345/233/236/350/260/203/346/227/266/345/272/217.md +47 -0
  105. package/vendor/BadCase/rn/cases/KI-005-geolocation/345/257/274/345/205/245/350/267/257/345/276/204/345/220/216/347/274/200.md +31 -0
  106. package/vendor/BadCase/rn/cases/KI-006-SmartRefreshLayout/346/231/272/350/203/275/346/214/207/351/222/210/345/264/251/346/272/203.md +55 -0
  107. package/vendor/BadCase/rn/cases/KI-007-orientation-locker/344/274/240/346/204/237/345/231/250/345/210/235/345/247/213/345/214/226.md +58 -0
  108. package/vendor/BadCase/rn/cases/KI-008-orientation-locker/344/274/240/346/204/237/345/231/250/345/274/225/347/224/250/350/256/241/346/225/260.md +47 -0
  109. package/vendor/BadCase/rn/cases/KI-009-pager-view/345/265/214/345/245/227/346/273/221/345/212/250.md +38 -0
  110. package/vendor/BadCase/rn/cases/KI-010-screens/346/211/213/345/212/277/345/206/262/347/252/201.md +48 -0
  111. package/vendor/BadCase/rn/cases/KI-011-spring-scrollview/346/211/213/345/212/277/351/207/215/345/244/215/347/273/221/345/256/232.md +49 -0
  112. package/vendor/BadCase/rn/cases/KI-012-qr-camera/346/250/252/345/261/217/351/200/202/351/205/215.md +59 -0
  113. package/vendor/BadCase/rn/cases/KI-013-webview/346/267/261/350/211/262/346/250/241/345/274/217/350/203/214/346/231/257/350/211/262.md +37 -0
  114. package/vendor/BadCase/rn/cases/KI-014-amap-geolocation/345/233/236/350/260/203/347/274/272/345/244/261.md +42 -0
  115. package/vendor/BadCase/rn/cases/KI-015-reanimated/350/277/220/350/241/214/346/227/266/346/236/220/346/236/204/345/264/251/346/272/203.md +54 -0
  116. package/vendor/BadCase/rn/cases/KI-016-fs/346/226/207/344/273/266/350/257/273/345/217/226/347/274/226/347/240/201.md +58 -0
  117. package/vendor/BadCase/rn/cases/KI-017-blob-util/345/217/202/346/225/260/347/274/226/347/240/201/351/224/231/350/257/257.md +39 -0
  118. package/vendor/BadCase/rn/cases/KI-018-modal/345/274/271/347/252/227/351/227/252/347/203/201.md +53 -0
  119. package/vendor/BadCase/rn/cases/KI-019-code-push/351/207/215/345/220/257/351/200/273/350/276/221/345/244/261/346/225/210.md +79 -0
  120. package/vendor/BadCase/rn/cases/KI-020-netinfo/346/225/217/346/204/237/344/277/241/346/201/257/346/263/204/351/234/262.md +60 -0
  121. package/vendor/BadCase/rn/cases/KI-021-video/346/234/254/345/234/260/350/247/206/351/242/221/346/222/255/346/224/276/345/274/202/345/270/270.md +79 -0
  122. package/vendor/BadCase/rn/cases/KI-022-audio-recorder-player/346/236/232/344/270/276/347/274/272/345/244/261.md +38 -0
  123. package/vendor/BadCase/rn/cases/KI-023-svg/346/270/220/345/217/230/347/273/247/346/211/277/345/244/261/346/225/210.md +62 -0
  124. package/vendor/BadCase/rn/generalization-log.md +55 -0
  125. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.json +328 -0
  126. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.md +382 -0
  127. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.json +1351 -0
  128. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.md +1176 -0
  129. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.json +538 -0
  130. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.md +1488 -0
  131. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.json +211 -0
  132. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.md +35 -0
  133. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.json +2048 -0
  134. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.md +3866 -0
  135. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.json +198 -0
  136. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.md +40 -0
  137. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.json +751 -0
  138. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.md +883 -0
  139. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.json +1544 -0
  140. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.md +2598 -0
  141. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.json +246 -0
  142. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.md +554 -0
  143. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.json +211 -0
  144. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.md +54 -0
  145. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.json +1626 -0
  146. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.md +2213 -0
  147. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.json +208 -0
  148. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.md +77 -0
  149. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.json +377 -0
  150. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.md +174 -0
  151. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.json +232 -0
  152. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.md +194 -0
  153. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.json +198 -0
  154. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.md +67 -0
  155. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.json +198 -0
  156. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.md +38 -0
  157. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.json +208 -0
  158. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.md +34 -0
  159. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.json +222 -0
  160. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.md +56 -0
  161. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.json +463 -0
  162. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.md +383 -0
  163. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.json +464 -0
  164. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.md +565 -0
  165. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.json +198 -0
  166. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.md +47 -0
  167. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.json +232 -0
  168. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.md +422 -0
  169. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.json +295 -0
  170. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.md +1038 -0
  171. package/vendor/BadCase/rn/rules/R-01-/345/205/250/345/261/217/347/252/227/345/217/243/347/212/266/346/200/201/347/256/241/347/220/206/345/256/214/346/225/264/346/200/247.md +20 -0
  172. package/vendor/BadCase/rn/rules/R-02-/350/265/204/346/272/220URI/345/275/242/346/200/201/345/210/206/346/224/257/350/246/206/347/233/226.md +21 -0
  173. package/vendor/BadCase/rn/rules/R-03-/351/231/204/345/261/236/346/223/215/344/275/234/345/244/261/350/264/245/351/230/273/346/226/255/344/270/273/346/265/201/347/250/213.md +20 -0
  174. package/vendor/BadCase/rn/rules/R-04-/345/274/202/346/255/245/345/233/236/350/260/203/346/263/250/345/206/214/346/227/266/345/272/217.md +20 -0
  175. package/vendor/BadCase/rn/rules/R-05-/346/250/241/345/235/227/345/257/274/345/205/245/350/267/257/345/276/204/350/247/204/350/214/203.md +19 -0
  176. package/vendor/BadCase/rn/rules/R-06-/344/274/240/346/204/237/345/231/250/347/241/254/344/273/266/346/235/203/351/231/220/346/214/211/351/234/200/350/216/267/345/217/226.md +21 -0
  177. package/vendor/BadCase/rn/rules/R-07-/346/231/272/350/203/275/346/214/207/351/222/210/347/224/237/345/221/275/345/221/250/346/234/237/347/256/241/347/220/206.md +20 -0
  178. package/vendor/BadCase/rn/rules/R-08-/346/211/213/345/212/277/344/272/213/344/273/266/346/263/250/345/206/214/344/270/216/345/206/262/347/252/201/345/244/204/347/220/206.md +22 -0
  179. package/vendor/BadCase/rn/rules/R-09-/346/250/252/347/253/226/345/261/217/345/244/232/345/275/242/346/200/201/345/270/203/345/261/200/351/200/202/351/205/215.md +20 -0
  180. package/vendor/BadCase/rn/rules/R-10-/346/267/261/350/211/262/346/250/241/345/274/217/344/270/273/351/242/230/351/242/234/350/211/262/351/200/202/351/205/215.md +19 -0
  181. package/vendor/BadCase/rn/rules/R-11-/346/216/245/345/217/243/345/233/236/350/260/203/345/256/236/347/216/260/345/256/214/346/225/264/346/200/247.md +20 -0
  182. package/vendor/BadCase/rn/rules/R-12-/345/216/237/347/224/237/350/277/220/350/241/214/346/227/266/350/265/204/346/272/220/346/236/220/346/236/204/346/227/266/345/272/217.md +20 -0
  183. package/vendor/BadCase/rn/rules/R-13-/346/226/207/344/273/266/346/225/260/346/215/256/347/274/226/347/240/201/344/270/216/346/240/274/345/274/217/345/205/274/345/256/271.md +21 -0
  184. package/vendor/BadCase/rn/rules/R-14-/345/212/250/347/224/273/345/210/235/345/247/213/345/214/226/346/227/266/345/272/217/344/270/216/347/212/266/346/200/201/345/220/214/346/255/245.md +20 -0
  185. package/vendor/BadCase/rn/rules/R-15-/347/212/266/346/200/201/346/214/201/344/271/205/345/214/226/344/270/216/351/207/215/345/220/257/351/200/273/350/276/221/344/270/200/350/207/264/346/200/247.md +20 -0
  186. package/vendor/BadCase/rn/rules/R-16-/346/225/217/346/204/237/344/277/241/346/201/257/346/227/245/345/277/227/346/263/204/351/234/262.md +19 -0
  187. package/vendor/BadCase/rn/rules/R-17-/345/252/222/344/275/223/350/265/204/346/272/220/347/224/237/345/221/275/345/221/250/346/234/237/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206.md +21 -0
  188. package/vendor/BadCase/rn/rules/R-18-/350/203/275/345/212/233/346/236/232/344/270/276/351/205/215/347/275/256/345/256/214/346/225/264/346/200/247.md +19 -0
  189. package/vendor/BadCase/rn/rules/R-19-/345/233/276/345/275/242/346/270/262/346/237/223/345/261/236/346/200/247/347/273/247/346/211/277/344/270/216/351/207/215/347/275/256.md +19 -0
  190. package/vendor/MCP/README.md +490 -0
  191. package/vendor/MCP/config.json +29 -0
  192. package/vendor/MCP/package.json +23 -0
  193. package/vendor/MCP/scripts/analyze-demo-coverage.cjs +1203 -0
  194. package/vendor/MCP/scripts/analyze-xts-coverage.cjs +1245 -0
  195. package/vendor/MCP/scripts/deveco_docs.js +247 -0
  196. package/vendor/MCP/scripts/extract-interfaces.cjs +1487 -0
  197. package/vendor/MCP/scripts/flutter-analyze-demo-coverage.cjs +666 -0
  198. package/vendor/MCP/scripts/flutter-analyze-xts-coverage.cjs +684 -0
  199. package/vendor/MCP/scripts/flutter-extract-interfaces.cjs +1251 -0
  200. package/vendor/MCP/scripts/flutter-render-spec-doc.cjs +351 -0
  201. package/vendor/MCP/scripts/render-spec-doc.cjs +347 -0
  202. package/vendor/MCP/scripts/rn-analyze-demo-coverage.cjs +645 -0
  203. package/vendor/MCP/scripts/rn-analyze-test-coverage.cjs +614 -0
  204. package/vendor/MCP/scripts/rn-extract-interfaces.cjs +1462 -0
  205. package/vendor/MCP/scripts/rn-render-spec-doc.cjs +327 -0
  206. package/vendor/MCP/scripts/rn-scan-exports.cjs +1336 -0
  207. package/vendor/MCP/src/client/MCPClientPool.js +220 -0
  208. package/vendor/MCP/src/config/ConfigLoader.js +189 -0
  209. package/vendor/MCP/src/executor/ScriptExecutor.js +110 -0
  210. package/vendor/MCP/src/gateway/Gateway.js +451 -0
  211. package/vendor/MCP/src/index.js +87 -0
  212. package/vendor/MCP/src/library/KBToolProvider.js +229 -0
  213. package/vendor/MCP/src/library/logger.js +60 -0
  214. package/vendor/MCP/src/registry/ScriptRegistry.js +238 -0
  215. package/vendor/MCP/src/registry/ToolRegistry.js +111 -0
  216. package/vendor/MCP/src/types.js +115 -0
  217. package/vendor/Server/CLI/cli.js +3 -3
  218. package/vendor/Server/Routes/server.js +3 -3
  219. package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +4 -2
  220. package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +3 -3
  221. package/vendor/Server/Skills/knowledge-import/SKILL.md +1 -1
  222. package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +12 -4
  223. package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +5 -4
  224. package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +2 -2
  225. package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +2 -2
  226. package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +1 -2
  227. package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +1 -1
  228. package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +1 -2
  229. package/vendor/Server/package.json +5 -1
  230. package/vendor/VERSION +3 -3
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @tool flutter_render_spec_doc
4
+ * @description 将 Flutter 三方库接口规格数据渲染为 Markdown 格式的接口规格说明书文档。可直接从库源码提取接口(一步到位),或读取已有的 interface-spec.json 中间件生成文档。用于生成人类可读的 Flutter API 文档。
5
+ * @param libroot: string - 库源码根目录路径(直接从源码提取,可选,与 spec 二选一)
6
+ * @param spec: string - 已有的 interface-spec.json 路径(可选,与 libroot 二选一)
7
+ * @param output: string - 输出 Markdown 文件路径(可选,不指定则输出到 stdout)
8
+ * @hidden
9
+ * flutter-render-spec-doc.cjs — Flutter 接口规格文档渲染器
10
+ *
11
+ * 读取 flutter-extract-interfaces.cjs 生成的 interface-spec.json,
12
+ * 或直接从源码提取,渲染为 Markdown 格式的接口规格文档。
13
+ *
14
+ * 用法:
15
+ * 方式一(读 JSON 中间件):
16
+ * node flutter-render-spec-doc.cjs --spec <interface-spec.json> --output <spec.md>
17
+ * 方式二(直接从源码提取):
18
+ * node flutter-render-spec-doc.cjs --libroot <库源码目录> --output <spec.md>
19
+ *
20
+ * 使用示例:
21
+ * node flutter-render-spec-doc.cjs --libroot /path/to/advertising_id --output 01-advertising_id-接口规格说明书.md
22
+ * node flutter-render-spec-doc.cjs --spec advertising_id-interface-spec.json --output 01-advertising_id-接口规格说明书.md
23
+ */
24
+
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+ const { generateSpec } = require('./flutter-extract-interfaces.cjs');
28
+
29
+ // ── 参数解析 ──────────────────────────────────────────────
30
+
31
+ function parseArgs() {
32
+ const args = process.argv.slice(2);
33
+ // MCP Gateway 模式:第一个参数是 JSON 字符串
34
+ if (args.length > 0 && args[0].startsWith('{')) {
35
+ try { return JSON.parse(args[0]); } catch (e) { /* 降级到 CLI 模式 */ }
36
+ }
37
+ const parsed = {};
38
+ for (let i = 0; i < args.length; i++) {
39
+ if (args[i].startsWith('--')) {
40
+ parsed[args[i].substring(2)] = args[i + 1];
41
+ i++;
42
+ }
43
+ }
44
+ return parsed;
45
+ }
46
+
47
+ // ── 工具函数 ──────────────────────────────────────────────
48
+
49
+ function isEventMethod(name) {
50
+ return /^on[A-Z]/.test(name);
51
+ }
52
+
53
+ function escapeMd(text) {
54
+ if (!text || text === '-') return '-';
55
+ return text.replace(/\|/g, '\\|').replace(/\n/g, ' ');
56
+ }
57
+
58
+ function formatParams(params) {
59
+ if (!params || params.length === 0) return '';
60
+ return params.map(p => {
61
+ const opt = p.optional ? '?' : '';
62
+ return `${p.name}${opt}: ${escapeMd(p.type)}`;
63
+ }).join(', ');
64
+ }
65
+
66
+ function boolFlag(value) {
67
+ return value ? '是' : '否';
68
+ }
69
+
70
+ function typeLabel(type) {
71
+ const labels = {
72
+ 'class': '类 (class)',
73
+ 'abstract_class': '抽象类 (abstract class)',
74
+ 'mixin': '混入 (mixin)',
75
+ 'mixin_class': '混入类 (mixin class)',
76
+ 'enum': '枚举 (enum)',
77
+ 'extension': '扩展 (extension)',
78
+ 'function': '函数 (function)',
79
+ 'variable': '变量/常量 (variable)',
80
+ 'typedef': '类型别名 (typedef)',
81
+ };
82
+ return labels[type] || type;
83
+ }
84
+
85
+ // ── 分类辅助 ──────────────────────────────────────────────
86
+
87
+ function groupByClass(interfaces) {
88
+ const classMap = new Map();
89
+ for (const iface of interfaces) {
90
+ const className = iface.className || '(顶层导出)';
91
+ if (!classMap.has(className)) classMap.set(className, []);
92
+ classMap.get(className).push(iface);
93
+ }
94
+ return classMap;
95
+ }
96
+
97
+ // ── 渲染函数 ──────────────────────────────────────────────
98
+
99
+ function renderHeader(spec) {
100
+ const lines = [];
101
+ lines.push(`# ${spec.libraryName} 接口规格说明书`);
102
+ lines.push('');
103
+ lines.push('> 本文档由 `flutter-extract-interfaces.cjs` 自动生成,基于 Dart 正则解析引擎。');
104
+ lines.push('');
105
+ lines.push('## 基本信息');
106
+ lines.push('');
107
+ lines.push('| 属性 | 值 |');
108
+ lines.push('|------|----|');
109
+ lines.push(`| 库名 | \`${spec.libraryName}\` |`);
110
+ lines.push(`| 入口文件 | \`${spec.entryFile}\` |`);
111
+ lines.push(`| 生成时间 | ${spec.extractedAt} |`);
112
+ lines.push(`| 源文件数 | ${spec.sources ? spec.sources.length : '-'} |`);
113
+ lines.push('');
114
+ return lines.join('\n');
115
+ }
116
+
117
+ function renderSummary(spec) {
118
+ const s = spec.summary || {};
119
+ const lines = [];
120
+ lines.push('## 接口统计');
121
+ lines.push('');
122
+ lines.push('| 统计项 | 数量 |');
123
+ lines.push('|--------|------|');
124
+ lines.push(`| 类/接口/枚举总数 (S) | ${s.S || '-'} |`);
125
+ lines.push(`| 方法/属性/字段总数 (N) | ${s.N || '-'} |`);
126
+ lines.push(`| 方法数 | ${s.methods || 0} |`);
127
+ lines.push(`| 属性数 | ${s.properties || 0} |`);
128
+ lines.push(`| 字段数 | ${s.fields || 0} |`);
129
+ lines.push(`| 常量数 | ${s.constants || 0} |`);
130
+ lines.push('');
131
+ return lines.join('\n');
132
+ }
133
+
134
+ function renderClassSection(className, members, index) {
135
+ const lines = [];
136
+ const num = `${index}. `;
137
+ if (className === '(顶层导出)') {
138
+ lines.push(`## ${num}顶层导出`);
139
+ lines.push('');
140
+ } else {
141
+ const firstMember = members[0];
142
+ const typeStr = firstMember ? firstMember.type : 'class';
143
+ const label = typeLabel(typeStr);
144
+ lines.push(`## ${num}${className}`);
145
+ lines.push('');
146
+ if (typeStr === 'extension' && firstMember && firstMember.onType) {
147
+ lines.push(`> 类型: ${label} (on \`${firstMember.onType}\`)`);
148
+ } else {
149
+ lines.push(`> 类型: ${label}`);
150
+ }
151
+ lines.push('');
152
+ }
153
+
154
+ const methods = members.filter(m => m.kind === 'method');
155
+ const properties = members.filter(m => m.kind === 'property');
156
+ const fields = members.filter(m => m.kind === 'field');
157
+ const constants = members.filter(m => m.kind === 'constant');
158
+ const enumValues = members.filter(m => m.kind === 'enumValue');
159
+ const functions = members.filter(m => m.kind === 'function');
160
+ const variables = members.filter(m => m.kind === 'variable');
161
+ const types = members.filter(m => m.kind === 'type');
162
+ const constructors = members.filter(m => m.kind === 'constructor');
163
+
164
+ // 构造函数表格
165
+ if (constructors.length > 0) {
166
+ lines.push('### 构造函数');
167
+ lines.push('');
168
+ lines.push('| # | 构造函数 | 参数 | 说明 | 源码 |');
169
+ lines.push('|---|----------|------|------|------|');
170
+ constructors.forEach((c, i) => {
171
+ const call = `${c.memberName === 'constructor' ? className : c.memberName}(${formatParams(c.params)})`;
172
+ lines.push(`| ${i + 1} | \`${call}\` | ${escapeMd(formatParams(c.params))} | ${escapeMd(c.description)} | \`${c.source}:${c.startLine}\` |`);
173
+ });
174
+ lines.push('');
175
+ }
176
+
177
+ // 方法表格
178
+ if (methods.length > 0) {
179
+ lines.push('### 方法');
180
+ lines.push('');
181
+ lines.push('| # | 方法名 | 事件 | 静态 | 参数 | 返回类型 | 说明 |');
182
+ lines.push('|---|--------|------|------|------|----------|------|');
183
+ methods.forEach((m, i) => {
184
+ const isEvent = isEventMethod(m.memberName);
185
+ lines.push(`| ${i + 1} | \`${m.memberName}\` | ${boolFlag(isEvent)} | ${boolFlag(m.isStatic)} | ${escapeMd(formatParams(m.params))} | ${escapeMd(m.returnType)} | ${escapeMd(m.description)} |`);
186
+ });
187
+ lines.push('');
188
+ }
189
+
190
+ // 属性表格(getter)
191
+ if (properties.length > 0) {
192
+ lines.push('### 属性');
193
+ lines.push('');
194
+ lines.push('| # | 属性名 | 静态 | 只读 | 类型 | 说明 |');
195
+ lines.push('|---|--------|------|------|------|------|');
196
+ properties.forEach((p, i) => {
197
+ lines.push(`| ${i + 1} | \`${p.memberName}\` | ${boolFlag(p.isStatic)} | ${boolFlag(p.isReadonly)} | ${escapeMd(p.returnType)} | ${escapeMd(p.description)} |`);
198
+ });
199
+ lines.push('');
200
+ }
201
+
202
+ // 字段表格
203
+ if (fields.length > 0) {
204
+ lines.push('### 字段');
205
+ lines.push('');
206
+ lines.push('| # | 字段名 | 静态 | 只读 | 类型 | 说明 |');
207
+ lines.push('|---|--------|------|------|------|------|');
208
+ fields.forEach((f, i) => {
209
+ lines.push(`| ${i + 1} | \`${f.memberName}\` | ${boolFlag(f.isStatic)} | ${boolFlag(f.isReadonly)} | ${escapeMd(f.returnType)} | ${escapeMd(f.description)} |`);
210
+ });
211
+ lines.push('');
212
+ }
213
+
214
+ // 常量表格
215
+ if (constants.length > 0) {
216
+ lines.push('### 常量');
217
+ lines.push('');
218
+ lines.push('| # | 常量名 | 静态 | 类型 | 值/签名 | 说明 |');
219
+ lines.push('|---|--------|------|------|---------|------|');
220
+ constants.forEach((c, i) => {
221
+ lines.push(`| ${i + 1} | \`${c.memberName}\` | ${boolFlag(c.isStatic)} | ${escapeMd(c.returnType)} | \`${escapeMd(c.signature)}\` | ${escapeMd(c.description)} |`);
222
+ });
223
+ lines.push('');
224
+ }
225
+
226
+ // 枚举值表格
227
+ if (enumValues.length > 0) {
228
+ lines.push('### 枚举值');
229
+ lines.push('');
230
+ lines.push('| # | 枚举值 | 值 | 说明 |');
231
+ lines.push('|---|--------|----|------|');
232
+ enumValues.forEach((e, i) => {
233
+ lines.push(`| ${i + 1} | \`${e.memberName}\` | ${escapeMd(e.returnType)} | ${escapeMd(e.description)} |`);
234
+ });
235
+ lines.push('');
236
+ }
237
+
238
+ // 顶层函数表格
239
+ if (functions.length > 0) {
240
+ lines.push('### 函数');
241
+ lines.push('');
242
+ lines.push('| # | 函数名 | 参数 | 返回类型 | 说明 | 源码 |');
243
+ lines.push('|---|--------|------|----------|------|------|');
244
+ functions.forEach((f, i) => {
245
+ const funcCall = `${f.memberName}(${formatParams(f.params)})`;
246
+ lines.push(`| ${i + 1} | \`${funcCall}\` | ${escapeMd(formatParams(f.params))} | \`${escapeMd(f.returnType)}\` | ${escapeMd(f.description)} | \`${f.source}:${f.startLine}\` |`);
247
+ });
248
+ lines.push('');
249
+ }
250
+
251
+ // 顶层变量/常量表格
252
+ if (variables.length > 0) {
253
+ lines.push('### 变量/常量');
254
+ lines.push('');
255
+ lines.push('| # | 变量名 | 类型 | 只读 | 说明 |');
256
+ lines.push('|---|--------|------|------|------|');
257
+ variables.forEach((v, i) => {
258
+ lines.push(`| ${i + 1} | \`${v.memberName}\` | ${escapeMd(v.returnType)} | ${boolFlag(v.isReadonly)} | ${escapeMd(v.description)} |`);
259
+ });
260
+ lines.push('');
261
+ }
262
+
263
+ // 类型别名表格
264
+ if (types.length > 0) {
265
+ lines.push('### 类型别名');
266
+ lines.push('');
267
+ lines.push('| # | 类型名 | 定义 | 说明 |');
268
+ lines.push('|---|--------|------|------|');
269
+ types.forEach((t, i) => {
270
+ lines.push(`| ${i + 1} | \`${t.className}\` | \`${escapeMd(t.returnType)}\` | ${escapeMd(t.description)} |`);
271
+ });
272
+ lines.push('');
273
+ }
274
+
275
+ // 事件方法汇总
276
+ const eventMethods = methods.filter(m => isEventMethod(m.memberName));
277
+ if (eventMethods.length > 0) {
278
+ lines.push('### 事件方法汇总');
279
+ lines.push('');
280
+ lines.push('| # | 事件方法 | 参数 | 返回类型 |');
281
+ lines.push('|---|----------|------|----------|');
282
+ eventMethods.forEach((e, i) => {
283
+ lines.push(`| ${i + 1} | \`${e.memberName}\` | ${escapeMd(formatParams(e.params))} | \`${escapeMd(e.returnType)}\` |`);
284
+ });
285
+ lines.push('');
286
+ }
287
+
288
+ return lines.join('\n');
289
+ }
290
+
291
+ function renderSourceList(spec) {
292
+ if (!spec.sources || spec.sources.length === 0) return '';
293
+ const lines = [];
294
+ lines.push('## 源文件列表');
295
+ lines.push('');
296
+ lines.push('| # | 文件路径 |');
297
+ lines.push('|---|----------|');
298
+ spec.sources.forEach((src, i) => {
299
+ lines.push(`| ${i + 1} | \`${src}\` |`);
300
+ });
301
+ lines.push('');
302
+ return lines.join('\n');
303
+ }
304
+
305
+ // ── 入口 ──────────────────────────────────────────────────
306
+
307
+ const args = parseArgs();
308
+ const specPath = args.spec;
309
+ const outputPath = args.output;
310
+
311
+ if (!specPath && !args.libroot && !args.repoDir) {
312
+ console.error('用法: node flutter-render-spec-doc.cjs --spec <interface-spec.json> --output <spec.md>');
313
+ console.error(' 或: node flutter-render-spec-doc.cjs --libroot <库源码目录> --output <spec.md>');
314
+ process.exit(1);
315
+ }
316
+
317
+ let spec;
318
+ if (specPath) {
319
+ spec = JSON.parse(fs.readFileSync(specPath, 'utf-8'));
320
+ console.log(`读取接口规格: ${specPath} (${spec.interfaces ? spec.interfaces.length : 0} 个接口)`);
321
+ } else {
322
+ const repoDir = args.libroot || args.repoDir;
323
+ console.log(`从源码目录提取接口: ${repoDir}`);
324
+ spec = generateSpec(repoDir);
325
+ console.log(`提取完成: ${spec.interfaces ? spec.interfaces.length : 0} 个接口, 库名: ${spec.libraryName}`);
326
+ }
327
+
328
+ const interfaces = spec.interfaces || [];
329
+ const classGroups = groupByClass(interfaces);
330
+ let sectionIndex = 0;
331
+
332
+ const parts = [];
333
+ parts.push(renderHeader(spec));
334
+ parts.push(renderSummary(spec));
335
+
336
+ for (const [className, members] of classGroups) {
337
+ sectionIndex++;
338
+ parts.push(renderClassSection(className, members, sectionIndex));
339
+ }
340
+
341
+ parts.push(renderSourceList(spec));
342
+
343
+ const markdown = parts.join('\n---\n\n');
344
+
345
+ if (outputPath) {
346
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
347
+ fs.writeFileSync(outputPath, markdown, 'utf-8');
348
+ console.log(`文档渲染完成: ${outputPath}`);
349
+ } else {
350
+ console.log(markdown);
351
+ }
@@ -0,0 +1,347 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @tool arkts_render_spec_doc
4
+ * @description 将接口规格数据渲染为 Markdown 格式的接口规格说明书文档。可直接从库源码提取接口(一步到位),或读取已有的 interface-spec.json 中间件生成文档。用于生成人类可读的 API 文档。
5
+ * @param libroot: string - 库源码根目录路径(直接从源码提取,可选,与 spec 二选一)
6
+ * @param spec: string - 已有的 interface-spec.json 路径(可选,与 libroot 二选一)
7
+ * @param output: string - 输出 Markdown 文件路径(可选,不指定则输出到 stdout)
8
+ * @hidden
9
+ * render-spec-doc.cjs — 接口规格文档渲染器
10
+ *
11
+ * 读取 extract-interfaces.cjs 生成的 interface-spec.json,
12
+ * 渲染为 Markdown 格式的接口规格文档。
13
+ *
14
+ * 用法:
15
+ * 方式一(读 JSON 中间件):
16
+ * node render-spec-doc.cjs --spec <interface-spec.json> --output <spec.md>
17
+ *
18
+ * 方式二(直接从源码提取,无需 JSON 中间件):
19
+ * node render-spec-doc.cjs --libroot <库源码目录> --output <spec.md>
20
+ *
21
+ * 使用示例:
22
+ * # 方式一: 从已有 JSON 生成文档
23
+ * node render-spec-doc.cjs --spec lottie_turbo-interface-spec.json --output 01-lottie_turbo-接口规格说明书.md
24
+ *
25
+ * # 方式二: 直接从源码生成文档(跳过 JSON 中间件)
26
+ * node render-spec-doc.cjs --libroot /path/to/lottie_turbo --output 01-lottie_turbo-接口规格说明书.md
27
+ *
28
+ * # 库源码目录结构约定:
29
+ * # /path/to/lottie_turbo/
30
+ * # ├── library/ ← 库源码(Index.ets 入口)
31
+ * # │ ├── Index.ets
32
+ * # │ ├── src/main/ets/
33
+ * # │ └── src/main/cpp/types/.../Index.d.ts ← Native .so 声明
34
+ * # └── entry/src/main/ets/ ← Demo 源码
35
+ */
36
+
37
+ const fs = require('fs');
38
+ const path = require('path');
39
+ const { generateSpec } = require('./extract-interfaces.cjs');
40
+
41
+ // ── 参数解析 ──────────────────────────────────────────────
42
+
43
+ function parseArgs() {
44
+ const args = process.argv.slice(2);
45
+ // MCP Gateway 模式:第一个参数是 JSON 字符串
46
+ if (args.length > 0 && args[0].startsWith('{')) {
47
+ try { return JSON.parse(args[0]); } catch (e) { /* 降级到 CLI 模式 */ }
48
+ }
49
+ const parsed = {};
50
+ for (let i = 0; i < args.length; i++) {
51
+ if (args[i].startsWith('--')) {
52
+ parsed[args[i].substring(2)] = args[i + 1];
53
+ i++;
54
+ }
55
+ }
56
+ return parsed;
57
+ }
58
+
59
+ // ── 工具函数 ──────────────────────────────────────────────
60
+
61
+ function isEventMethod(name) {
62
+ return /^on[A-Z]/.test(name);
63
+ }
64
+
65
+ function escapeMd(text) {
66
+ if (!text || text === '-') return '-';
67
+ return text.replace(/\|/g, '\\|').replace(/\n/g, ' ');
68
+ }
69
+
70
+ function formatParams(params) {
71
+ if (!params || params.length === 0) return '';
72
+ return params.map(p => {
73
+ const opt = p.optional ? '?' : '';
74
+ return `${p.name}${opt}: ${escapeMd(p.type)}`;
75
+ }).join(', ');
76
+ }
77
+
78
+ function boolFlag(value) {
79
+ return value ? '是' : '否';
80
+ }
81
+
82
+ function typeLabel(type) {
83
+ const labels = {
84
+ 'class': '类 (class)', 'struct': '组件 (struct)', 'interface': '接口 (interface)',
85
+ 'dts-class': 'Native 声明 (declare var)', 'enum': '枚举 (enum)', 'type': '类型别名 (type)',
86
+ 'function': '函数 (function)', 'variable': '变量 (variable)',
87
+ };
88
+ return labels[type] || type;
89
+ }
90
+
91
+ // ── 分类辅助 ──────────────────────────────────────────────
92
+
93
+ /** 按类型分组接口 */
94
+ function groupByType(interfaces) {
95
+ const groups = {
96
+ 'class': [], 'struct': [], 'interface': [], 'dts-class': [],
97
+ 'enum': [], 'type': [], 'function': [], 'variable': [],
98
+ };
99
+ for (const iface of interfaces) {
100
+ const type = iface.type || 'class';
101
+ if (!groups[type]) groups[type] = [];
102
+ groups[type].push(iface);
103
+ }
104
+ return groups;
105
+ }
106
+
107
+ /** 按类名分组接口成员 */
108
+ function groupByClass(interfaces) {
109
+ const classMap = new Map();
110
+ for (const iface of interfaces) {
111
+ const className = iface.className || '(顶层导出)';
112
+ if (!classMap.has(className)) classMap.set(className, []);
113
+ classMap.get(className).push(iface);
114
+ }
115
+ return classMap;
116
+ }
117
+
118
+ // ── 渲染函数 ──────────────────────────────────────────────
119
+
120
+ function renderHeader(spec) {
121
+ const lines = [];
122
+ lines.push(`# ${spec.libraryName} 接口规格说明书`);
123
+ lines.push('');
124
+ lines.push('> 本文档由 \`extract-interfaces.cjs\` 自动生成,基于 TypeScript Compiler API 语义分析。');
125
+ lines.push('');
126
+ lines.push('## 基本信息');
127
+ lines.push('');
128
+ lines.push('| 属性 | 值 |');
129
+ lines.push('|------|----|');
130
+ lines.push(`| 库名 | \`${spec.libraryName}\` |`);
131
+ lines.push(`| 入口文件 | \`${spec.entryFile}\` |`);
132
+ if (spec.nativeDPath) {
133
+ lines.push(`| Native 声明 | \`${spec.nativeDPath}\` |`);
134
+ }
135
+ lines.push(`| 生成时间 | ${spec.extractedAt} |`);
136
+ lines.push(`| 源文件数 | ${spec.sources ? spec.sources.length : '-'} |`);
137
+ lines.push('');
138
+ return lines.join('\n');
139
+ }
140
+
141
+ function renderSummary(spec) {
142
+ const s = spec.summary || {};
143
+ const lines = [];
144
+ lines.push('## 接口统计');
145
+ lines.push('');
146
+ lines.push('| 统计项 | 数量 |');
147
+ lines.push('|--------|------|');
148
+ lines.push(`| 类/接口/枚举总数 (S) | ${s.S || '-'} |`);
149
+ lines.push(`| 方法/属性/字段总数 (N) | ${s.N || '-'} |`);
150
+ lines.push(`| 方法数 | ${s.methods || 0} |`);
151
+ lines.push(`| 属性数 | ${s.properties || 0} |`);
152
+ lines.push(`| 字段数 | ${s.fields || 0} |`);
153
+ lines.push('');
154
+ return lines.join('\n');
155
+ }
156
+
157
+ function renderClassSection(className, members, repoDir, index) {
158
+ const lines = []
159
+ const num = `${index}. `
160
+ if (className === '(顶层导出)') {
161
+ lines.push(`## ${num}顶层导出`)
162
+ lines.push('')
163
+ } else {
164
+ const firstMember = members[0]
165
+ const typeStr = firstMember ? firstMember.type : 'class'
166
+ const label = typeLabel(typeStr)
167
+ lines.push(`## ${num}${className}`)
168
+ lines.push('');
169
+ lines.push(`> 类型: ${label}`);
170
+ lines.push('');
171
+ }
172
+
173
+ // 分离方法和属性
174
+ const methods = members.filter(m => m.kind === 'method');
175
+ const properties = members.filter(m => m.kind === 'property');
176
+ const fields = members.filter(m => m.kind === 'field');
177
+ const enumValues = members.filter(m => m.kind === 'enumValue');
178
+ const functions = members.filter(m => m.kind === 'function');
179
+ const variables = members.filter(m => m.kind === 'variable');
180
+ const types = members.filter(m => m.kind === 'type');
181
+
182
+ // 方法表格
183
+ if (methods.length > 0) {
184
+ lines.push('### 方法');
185
+ lines.push('');
186
+ lines.push('| # | 方法名 | 事件 | 静态 | 参数 | 返回类型 | 说明 |')
187
+ lines.push('|---|--------|------|------|------|----------|------|')
188
+ methods.forEach((m, i) => {
189
+ const isEvent = isEventMethod(m.memberName)
190
+ lines.push(`| ${i + 1} | \`${m.memberName}\` | ${boolFlag(isEvent)} | ${boolFlag(m.isStatic)} | ${escapeMd(formatParams(m.params))} | ${escapeMd(m.returnType)} | ${escapeMd(m.description)} |`)
191
+ })
192
+ lines.push('');
193
+ }
194
+
195
+ // 属性表格
196
+ if (properties.length > 0) {
197
+ lines.push('### 属性');
198
+ lines.push('');
199
+ lines.push('| # | 属性名 | 静态 | 只读 | 类型 | 说明 |')
200
+ lines.push('|---|--------|------|------|------|------|')
201
+ properties.forEach((p, i) => {
202
+ lines.push(`| ${i + 1} | \`${p.memberName}\` | ${boolFlag(p.isStatic)} | ${boolFlag(p.isReadonly)} | ${escapeMd(p.returnType)} | ${escapeMd(p.description)} |`)
203
+ })
204
+ lines.push('');
205
+ }
206
+
207
+ // 字段表格
208
+ if (fields.length > 0) {
209
+ lines.push('### 字段');
210
+ lines.push('');
211
+ lines.push('| # | 字段名 | 可选 | 只读 | 类型 | 说明 |')
212
+ lines.push('|---|--------|------|------|------|------|')
213
+ fields.forEach((f, i) => {
214
+ lines.push(`| ${i + 1} | \`${f.memberName}\` | ${boolFlag(f.isOptional)} | ${boolFlag(f.isReadonly)} | ${escapeMd(f.returnType)} | ${escapeMd(f.description)} |`)
215
+ })
216
+ lines.push('');
217
+ }
218
+
219
+ // 枚举值表格
220
+ if (enumValues.length > 0) {
221
+ lines.push('### 枚举值');
222
+ lines.push('');
223
+ lines.push('| # | 枚举值 | 值 | 说明 |')
224
+ lines.push('|---|--------|----|------|')
225
+ enumValues.forEach((e, i) => {
226
+ lines.push(`| ${i + 1} | \`${e.memberName}\` | ${escapeMd(e.returnType)} | ${escapeMd(e.description)} |`)
227
+ })
228
+ lines.push('');
229
+ }
230
+
231
+ // 顶层函数表格
232
+ if (functions.length > 0) {
233
+ lines.push('### 函数');
234
+ lines.push('');
235
+ lines.push('| # | 函数名 | 参数 | 返回类型 | 说明 | 源码 |')
236
+ lines.push('|---|--------|------|----------|------|------|')
237
+ functions.forEach((f, i) => {
238
+ const funcCall = `${f.memberName}(${formatParams(f.params)})`
239
+ lines.push(`| ${i + 1} | \`${funcCall}\` | ${escapeMd(formatParams(f.params))} | \`${escapeMd(f.returnType)}\` | ${escapeMd(f.description)} | \`${f.source}:${f.startLine}\` |`)
240
+ })
241
+ lines.push('');
242
+ }
243
+
244
+ // 顶层变量表格
245
+ if (variables.length > 0) {
246
+ lines.push('### 变量');
247
+ lines.push('');
248
+ lines.push('| # | 变量名 | 类型 | 说明 |')
249
+ lines.push('|---|--------|------|------|')
250
+ variables.forEach((v, i) => {
251
+ lines.push(`| ${i + 1} | \`${v.memberName}\` | ${escapeMd(v.returnType)} | ${escapeMd(v.description)} |`)
252
+ })
253
+ lines.push('');
254
+ }
255
+
256
+ // 类型别名表格
257
+ if (types.length > 0) {
258
+ lines.push('### 类型别名');
259
+ lines.push('');
260
+ lines.push('| # | 类型名 | 定义 | 说明 |')
261
+ lines.push('|---|--------|------|------|')
262
+ types.forEach((t, i) => {
263
+ lines.push(`| ${i + 1} | \`${t.className}\` | \`${escapeMd(t.returnType)}\` | ${escapeMd(t.description)} |`)
264
+ })
265
+ lines.push('');
266
+ }
267
+
268
+ // 事件方法汇总表格
269
+ const eventMethods = methods.filter(m => isEventMethod(m.memberName));
270
+ if (eventMethods.length > 0) {
271
+ lines.push('### 事件方法汇总');
272
+ lines.push('');
273
+ lines.push('| # | 事件方法 | 参数 | 返回类型 |')
274
+ lines.push('|---|----------|------|----------|')
275
+ eventMethods.forEach((e, i) => {
276
+ lines.push(`| ${i + 1} | \`${e.memberName}\` | ${escapeMd(formatParams(e.params))} | \`${escapeMd(e.returnType)}\` |`)
277
+ })
278
+ lines.push('');
279
+ }
280
+
281
+ return lines.join('\n');
282
+ }
283
+
284
+ function renderSourceList(spec) {
285
+ if (!spec.sources || spec.sources.length === 0) return '';
286
+ const lines = [];
287
+ lines.push('## 源文件列表');
288
+ lines.push('');
289
+ lines.push('| # | 文件路径 |');
290
+ lines.push('|---|----------|');
291
+ spec.sources.forEach((src, i) => {
292
+ lines.push(`| ${i + 1} | \`${src}\` |`);
293
+ });
294
+ lines.push('');
295
+ return lines.join('\n');
296
+ }
297
+
298
+ // ── 入口 ──────────────────────────────────────────────────
299
+
300
+ const args = parseArgs();
301
+ const specPath = args.spec;
302
+ const outputPath = args.output;
303
+
304
+ if (!specPath && !args.libroot && !args.repoDir) {
305
+ console.error('用法: node render-spec-doc.cjs --spec <interface-spec.json> --output <spec.md>');
306
+ console.error(' 或: node render-spec-doc.cjs --libroot <库源码目录> --output <spec.md>');
307
+ process.exit(1);
308
+ }
309
+
310
+ let spec;
311
+ if (specPath) {
312
+ spec = JSON.parse(fs.readFileSync(specPath, 'utf-8'));
313
+ console.log(`读取接口规格: ${specPath} (${spec.interfaces ? spec.interfaces.length : 0} 个接口)`);
314
+ } else {
315
+ const repoDir = args.libroot || args.repoDir;
316
+ console.log(`从源码目录提取接口: ${repoDir}`);
317
+ spec = generateSpec(repoDir);
318
+ console.log(`提取完成: ${spec.interfaces ? spec.interfaces.length : 0} 个接口, 库名: ${spec.libraryName}`);
319
+ }
320
+
321
+ const interfaces = spec.interfaces || [];
322
+
323
+ // 分组
324
+ const classGroups = groupByClass(interfaces);
325
+ let sectionIndex = 0;
326
+
327
+ // 渲染
328
+ const parts = [];
329
+ parts.push(renderHeader(spec));
330
+ parts.push(renderSummary(spec));
331
+
332
+ for (const [className, members] of classGroups) {
333
+ sectionIndex++
334
+ parts.push(renderClassSection(className, members, args.repoDir, sectionIndex))
335
+ }
336
+
337
+ parts.push(renderSourceList(spec));
338
+
339
+ const markdown = parts.join('\n---\n\n');
340
+
341
+ if (outputPath) {
342
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
343
+ fs.writeFileSync(outputPath, markdown, 'utf-8');
344
+ console.log(`文档渲染完成: ${outputPath}`);
345
+ } else {
346
+ console.log(markdown);
347
+ }