@ohos-cpf/3rdloop 0.0.8 → 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 (219) hide show
  1. package/README.md +25 -0
  2. package/lib/cli.js +22 -5
  3. package/lib/doctor.js +111 -10
  4. package/lib/mcp.js +498 -0
  5. package/package.json +6 -2
  6. package/vendor/Archive/data/.index/meta.json +7 -0
  7. package/vendor/Archive/data/.index/search.db +0 -0
  8. package/vendor/Archive/data/docs/experiences/arkts-check-tool-pitfalls-baseline-comparison.md +13 -0
  9. package/vendor/Archive/data/docs/experiences/arkts-deep-path-import-recognition.md +31 -0
  10. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-entry-file-case-mismatch.md +25 -0
  11. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-import-trailing-slash.md +20 -0
  12. package/vendor/Archive/data/docs/experiences/arkts-library-source-files-may-be-ts.md +18 -0
  13. package/vendor/Archive/data/docs/experiences/arkts-typedarray-buffer-interface-cast-compile-fixes.md +36 -0
  14. package/vendor/Archive/data/docs/experiences/arkts-xts-compile-error-clustering-fix.md +24 -0
  15. package/vendor/Archive/data/docs/experiences/arkts-xts-doc-expected-value-runtime-probe.md +35 -0
  16. package/vendor/Archive/data/docs/experiences/arkts-xts-fixture-rawfile-testability-injection.md +33 -0
  17. package/vendor/Archive/data/docs/experiences/code-linter-chinese-comment-false-positive.md +16 -0
  18. package/vendor/Archive/data/docs/experiences/esobject-new-expression-variable-tracking.md +33 -0
  19. package/vendor/Archive/data/docs/experiences/filesystem-case-sensitivity-module-resolution.md +31 -0
  20. package/vendor/Archive/data/docs/experiences/gitcode-clone-redirect-warning-normal.md +13 -0
  21. package/vendor/Archive/data/docs/experiences/kn_msgvq1w585ec8319.md +77 -0
  22. package/vendor/Archive/data/docs/experiences/kn_msovnm6rd46de72c.md +98 -0
  23. package/vendor/Archive/data/docs/experiences/kn_mspt8vntfe708576.md +87 -0
  24. package/vendor/Archive/data/docs/experiences/kn_mspu1ei77adbbb48.md +133 -0
  25. package/vendor/Archive/data/docs/experiences/kn_mspubgak8d30bfce.md +128 -0
  26. package/vendor/Archive/data/docs/experiences/kn_mspug2de3cb1f7c3.md +115 -0
  27. package/vendor/Archive/data/docs/experiences/kn_skill_opt_001.md +38 -0
  28. package/vendor/Archive/data/docs/experiences/loop-artifacts-verification-evidence-triangle.md +19 -0
  29. package/vendor/Archive/data/docs/experiences/macos-bash-replace-build-ps1.md +19 -0
  30. package/vendor/Archive/data/docs/experiences/macos-bsd-diff-q-illegal-option.md +15 -0
  31. package/vendor/Archive/data/docs/experiences/migrate-cjs-compatible-api-version-map-limit.md +17 -0
  32. package/vendor/Archive/data/docs/experiences/mp3agic-arkts-library-behavior-quirks.md +21 -0
  33. package/vendor/Archive/data/docs/experiences/ohos-face-detection-scan-api-mapping.md +15 -0
  34. package/vendor/Archive/data/docs/experiences/pr-metadata-and-diff-integrity-verification.md +12 -0
  35. package/vendor/Archive/data/docs/experiences/rn-coverage-index-signature-pseudo-member-false-negative.md +32 -0
  36. package/vendor/Archive/data/docs/experiences/rn-memory-check-severity-calibration.md +21 -0
  37. package/vendor/Archive/data/docs/experiences/rn-platform-specific-api-exclusion-evidence.md +24 -0
  38. package/vendor/Archive/data/docs/experiences/rn-upstream-version-diff-pitfalls.md +17 -0
  39. package/vendor/Archive/data/docs/experiences/rn-version-gap-risk-rating-rules.md +13 -0
  40. package/vendor/Archive/data/docs/experiences/rn-view-lib-native-contract-diff-fabric-spec.md +16 -0
  41. package/vendor/Archive/data/docs/experiences/rnoh-adapter-package-version-field-semantics.md +18 -0
  42. package/vendor/Archive/data/docs/experiences/rnoh-arkts-sqlite-rows-array-format.md +18 -0
  43. package/vendor/Archive/data/docs/experiences/rnoh-dependency-residue-scan-strategy.md +18 -0
  44. package/vendor/Archive/data/docs/experiences/rnoh-example-local-lib-dep-use-tgz.md +53 -0
  45. package/vendor/Archive/data/docs/experiences/rnoh-example-prereserve-rntesterlist.md +17 -0
  46. package/vendor/Archive/data/docs/experiences/rnoh-example-template-compatiblesdkversion-upgrade.md +29 -0
  47. package/vendor/Archive/data/docs/experiences/rnoh-example-turbomodule-shell-adaptation-checklist.md +41 -0
  48. package/vendor/Archive/data/docs/experiences/rnoh-mcp-build-project-tool-risk.md +18 -0
  49. package/vendor/Archive/data/docs/experiences/rnoh-npm-devdependencies-version-precheck.md +29 -0
  50. package/vendor/Archive/data/docs/experiences/rnoh-repo-baseline-version-verification.md +13 -0
  51. package/vendor/Archive/data/docs/experiences/rnoh-repo-upstream-directory-mapping.md +18 -0
  52. package/vendor/Archive/data/docs/experiences/rnoh-stateless-library-zero-leak-verification.md +31 -0
  53. package/vendor/Archive/data/docs/experiences/rnoh-template-npmrc-credential-removal.md +15 -0
  54. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-codegen-wiring-verification.md +19 -0
  55. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-cpp-methodmap-compatibility-check.md +20 -0
  56. package/vendor/Archive/data/docs/experiences/scenario-doc-vs-source-signature-diff-four-patterns.md +24 -0
  57. package/vendor/Archive/data/docs/experiences/static-analysis-grep-cross-validation.md +29 -0
  58. package/vendor/Archive/demo.js +489 -0
  59. package/vendor/Archive/index.js +43 -0
  60. package/vendor/Archive/package.json +16 -0
  61. package/vendor/Archive/src/constants.js +83 -0
  62. package/vendor/Archive/src/data/stopwords.txt +110 -0
  63. package/vendor/Archive/src/data/synonyms.json +25 -0
  64. package/vendor/Archive/src/data/terms.txt +59 -0
  65. package/vendor/Archive/src/db/sqlite-backend.js +312 -0
  66. package/vendor/Archive/src/db/sqlite-schema.js +64 -0
  67. package/vendor/Archive/src/engine.js +501 -0
  68. package/vendor/Archive/src/index/index-manager.js +203 -0
  69. package/vendor/Archive/src/index/index-state.js +94 -0
  70. package/vendor/Archive/src/index/search-text-builder.js +106 -0
  71. package/vendor/Archive/src/index.js +22 -0
  72. package/vendor/Archive/src/parser/api-identifiers.js +121 -0
  73. package/vendor/Archive/src/parser/api-suffixes.js +48 -0
  74. package/vendor/Archive/src/parser/heading-normalize.js +40 -0
  75. package/vendor/Archive/src/parser/markdown-splitter.js +215 -0
  76. package/vendor/Archive/src/search/catalog-routing.js +87 -0
  77. package/vendor/Archive/src/search/fts-search.js +289 -0
  78. package/vendor/Archive/src/search/query-normalizer.js +159 -0
  79. package/vendor/Archive/src/search/query-rewriter.js +72 -0
  80. package/vendor/Archive/src/search/search-engine.js +72 -0
  81. package/vendor/Archive/src/search/snippet.js +64 -0
  82. package/vendor/Archive/src/store/dir-store.js +103 -0
  83. package/vendor/Archive/src/store/doc-store.js +36 -0
  84. package/vendor/Archive/src/tokenizer/lexicon.js +151 -0
  85. package/vendor/Archive/src/tokenizer/tokenizer.js +167 -0
  86. package/vendor/Archive/src/types.js +86 -0
  87. package/vendor/Archive/src/utils/hash.js +16 -0
  88. package/vendor/Archive/src/utils/lock.js +73 -0
  89. package/vendor/Archive/src/utils/path-safety.js +96 -0
  90. package/vendor/Archive/src/utils/paths.js +39 -0
  91. package/vendor/BadCase/rn/INDEX.md +127 -0
  92. 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
  93. 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
  94. 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
  95. package/vendor/BadCase/rn/cases/KI-004-wechat/345/233/236/350/260/203/346/227/266/345/272/217.md +47 -0
  96. 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
  97. 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
  98. 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
  99. 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
  100. package/vendor/BadCase/rn/cases/KI-009-pager-view/345/265/214/345/245/227/346/273/221/345/212/250.md +38 -0
  101. package/vendor/BadCase/rn/cases/KI-010-screens/346/211/213/345/212/277/345/206/262/347/252/201.md +48 -0
  102. 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
  103. package/vendor/BadCase/rn/cases/KI-012-qr-camera/346/250/252/345/261/217/351/200/202/351/205/215.md +59 -0
  104. 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
  105. package/vendor/BadCase/rn/cases/KI-014-amap-geolocation/345/233/236/350/260/203/347/274/272/345/244/261.md +42 -0
  106. 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
  107. 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
  108. 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
  109. package/vendor/BadCase/rn/cases/KI-018-modal/345/274/271/347/252/227/351/227/252/347/203/201.md +53 -0
  110. 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
  111. 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
  112. 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
  113. 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
  114. 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
  115. package/vendor/BadCase/rn/generalization-log.md +55 -0
  116. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.json +328 -0
  117. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.md +382 -0
  118. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.json +1351 -0
  119. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.md +1176 -0
  120. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.json +538 -0
  121. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.md +1488 -0
  122. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.json +211 -0
  123. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.md +35 -0
  124. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.json +2048 -0
  125. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.md +3866 -0
  126. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.json +198 -0
  127. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.md +40 -0
  128. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.json +751 -0
  129. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.md +883 -0
  130. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.json +1544 -0
  131. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.md +2598 -0
  132. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.json +246 -0
  133. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.md +554 -0
  134. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.json +211 -0
  135. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.md +54 -0
  136. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.json +1626 -0
  137. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.md +2213 -0
  138. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.json +208 -0
  139. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.md +77 -0
  140. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.json +377 -0
  141. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.md +174 -0
  142. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.json +232 -0
  143. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.md +194 -0
  144. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.json +198 -0
  145. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.md +67 -0
  146. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.json +198 -0
  147. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.md +38 -0
  148. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.json +208 -0
  149. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.md +34 -0
  150. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.json +222 -0
  151. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.md +56 -0
  152. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.json +463 -0
  153. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.md +383 -0
  154. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.json +464 -0
  155. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.md +565 -0
  156. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.json +198 -0
  157. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.md +47 -0
  158. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.json +232 -0
  159. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.md +422 -0
  160. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.json +295 -0
  161. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.md +1038 -0
  162. 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
  163. 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
  164. 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
  165. 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
  166. 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
  167. 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
  168. 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
  169. 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
  170. 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
  171. 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
  172. 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
  173. 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
  174. 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
  175. 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
  176. 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
  177. 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
  178. 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
  179. 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
  180. 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
  181. package/vendor/MCP/README.md +490 -0
  182. package/vendor/MCP/config.json +29 -0
  183. package/vendor/MCP/package.json +23 -0
  184. package/vendor/MCP/scripts/analyze-demo-coverage.cjs +1203 -0
  185. package/vendor/MCP/scripts/analyze-xts-coverage.cjs +1245 -0
  186. package/vendor/MCP/scripts/deveco_docs.js +247 -0
  187. package/vendor/MCP/scripts/extract-interfaces.cjs +1487 -0
  188. package/vendor/MCP/scripts/flutter-analyze-demo-coverage.cjs +666 -0
  189. package/vendor/MCP/scripts/flutter-analyze-xts-coverage.cjs +684 -0
  190. package/vendor/MCP/scripts/flutter-extract-interfaces.cjs +1251 -0
  191. package/vendor/MCP/scripts/flutter-render-spec-doc.cjs +351 -0
  192. package/vendor/MCP/scripts/render-spec-doc.cjs +347 -0
  193. package/vendor/MCP/scripts/rn-analyze-demo-coverage.cjs +645 -0
  194. package/vendor/MCP/scripts/rn-analyze-test-coverage.cjs +614 -0
  195. package/vendor/MCP/scripts/rn-extract-interfaces.cjs +1462 -0
  196. package/vendor/MCP/scripts/rn-render-spec-doc.cjs +327 -0
  197. package/vendor/MCP/scripts/rn-scan-exports.cjs +1336 -0
  198. package/vendor/MCP/src/client/MCPClientPool.js +220 -0
  199. package/vendor/MCP/src/config/ConfigLoader.js +189 -0
  200. package/vendor/MCP/src/executor/ScriptExecutor.js +110 -0
  201. package/vendor/MCP/src/gateway/Gateway.js +451 -0
  202. package/vendor/MCP/src/index.js +87 -0
  203. package/vendor/MCP/src/library/KBToolProvider.js +229 -0
  204. package/vendor/MCP/src/library/logger.js +60 -0
  205. package/vendor/MCP/src/registry/ScriptRegistry.js +238 -0
  206. package/vendor/MCP/src/registry/ToolRegistry.js +111 -0
  207. package/vendor/MCP/src/types.js +115 -0
  208. package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +4 -2
  209. package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +3 -3
  210. package/vendor/Server/Skills/knowledge-import/SKILL.md +1 -1
  211. package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +12 -4
  212. package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +5 -4
  213. package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +2 -2
  214. package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +2 -2
  215. package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +1 -2
  216. package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +1 -1
  217. package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +1 -2
  218. package/vendor/Server/package.json +5 -1
  219. package/vendor/VERSION +3 -3
@@ -0,0 +1,489 @@
1
+ /**
2
+ * demo.js — 文档检索引擎功能演示
3
+ *
4
+ * 演示内容:
5
+ * 1. 初始化引擎
6
+ * 2. 添加多个 Markdown 文档(不同 catalog)
7
+ * 3. 关键词搜索(中文 + API 符号)
8
+ * 4. 同义词扩展搜索
9
+ * 5. 获取文档记录
10
+ * 6. 删除文档
11
+ * 7. 全量重建索引
12
+ * 8. 引擎状态查看
13
+ *
14
+ * 运行方式:
15
+ * cd Archive && node demo.js
16
+ *
17
+ * 前置条件:
18
+ * npm install jieba-wasm
19
+ * (未安装时分词回退到简易模式,SQLite 使用 node:sqlite 内置模块)
20
+ *
21
+ * 数据安全:
22
+ * 数据目录默认为 Archive/data(见 src/constants.js DEFAULT_DATA_DIR)。
23
+ * 重复执行不会覆盖已有数据库——已存在的文档自动跳过,
24
+ * 删除/重建步骤仅在首次运行(数据库为空)时执行。
25
+ */
26
+
27
+ import fs from 'node:fs';
28
+ import path from 'node:path';
29
+ import { DocSearchEngine } from './src/index.js';
30
+ import { DEFAULT_DATA_DIR } from './src/constants.js';
31
+
32
+ // ─── 辅助:格式化输出 ─────────────────────────────────────────────
33
+
34
+ const BOLD = '\x1b[1m';
35
+ const DIM = '\x1b[2m';
36
+ const GREEN = '\x1b[32m';
37
+ const YELLOW = '\x1b[33m';
38
+ const CYAN = '\x1b[36m';
39
+ const RED = '\x1b[31m';
40
+ const RESET = '\x1b[0m';
41
+
42
+ function section(title) {
43
+ console.log(`\n${CYAN}${BOLD}━━━ ${title} ━━━${RESET}`);
44
+ }
45
+
46
+ function ok(msg) {
47
+ console.log(` ${GREEN}✓${RESET} ${msg}`);
48
+ }
49
+
50
+ function warn(msg) {
51
+ console.log(` ${YELLOW}⚠${RESET} ${msg}`);
52
+ }
53
+
54
+ function fail(msg) {
55
+ console.log(` ${RED}✗${RESET} ${msg}`);
56
+ }
57
+
58
+ function info(msg) {
59
+ console.log(` ${DIM}${msg}${RESET}`);
60
+ }
61
+
62
+ function printResults(results) {
63
+ if (results.length === 0) {
64
+ info('(无结果)');
65
+ return;
66
+ }
67
+ for (let i = 0; i < results.length; i++) {
68
+ const r = results[i];
69
+ console.log(
70
+ ` ${YELLOW}${i + 1}.${RESET} [${r.catalog}] ${BOLD}${r.title}${RESET}` +
71
+ (r.sectionTitle ? ` › ${DIM}${r.sectionTitle}${RESET}` : '')
72
+ );
73
+ console.log(` score: ${r.score.toFixed(2)} docId: ${r.documentId}`);
74
+ if (r.snippet) {
75
+ console.log(` snippet: ${r.snippet.replace(/\n/g, ' ').slice(0, 120)}...`);
76
+ }
77
+ }
78
+ }
79
+
80
+ // ─── 准备临时数据目录 ──────────────────────────────────────────────
81
+
82
+ // 数据目录:默认使用 src/constants.js 中的 DEFAULT_DATA_DIR(Archive/data)
83
+ // 也可通过环境变量覆盖:DATA_DIR=xxx node demo.js
84
+ const DATA_DIR = process.env.DATA_DIR || DEFAULT_DATA_DIR;
85
+
86
+ // ─── 测试文档 ──────────────────────────────────────────────────────
87
+
88
+ /** @type {Array<{documentId:string, catalog:string, content:string}>} */
89
+ const SAMPLE_DOCS = [
90
+ {
91
+ documentId: 'guides/arkts-getting-started',
92
+ catalog: 'guides',
93
+ content: `# ArkTS 开发入门
94
+
95
+ ## 概述
96
+ ArkTS 是鸿蒙应用开发的核心语言,基于 TypeScript 扩展,提供了声明式 UI 范式。
97
+
98
+ #### 基本结构
99
+ ArkTS 应用由 AbilityStage 和 UIAbility 组成。UIAbility 负责生命周期管理,
100
+ AbilityStage 是应用主入口。
101
+
102
+ \`\`\`typescript
103
+ import { AbilityStage } from '@ohos.app.ability.AbilityStage';
104
+
105
+ export default class MyAbilityStage extends AbilityStage {
106
+ onCreate() {
107
+ console.log('AbilityStage created');
108
+ }
109
+ }
110
+ \`\`\`
111
+
112
+ #### UI 组件开发
113
+ 使用 @Component 装饰器定义组件,@State 管理组件内部状态。
114
+ build() 方法描述 UI 结构。
115
+
116
+ \`\`\`typescript
117
+ @Entry
118
+ @Component
119
+ struct Index {
120
+ @State count: number = 0;
121
+
122
+ build() {
123
+ Column() {
124
+ Text(\`点击次数: \${this.count}\`)
125
+ Button('加一').onClick(() => this.count++)
126
+ }
127
+ }
128
+ }
129
+ \`\`\`
130
+
131
+ #### 路由导航
132
+ 使用 Navigation 和 NavDestination 实现页面路由。
133
+ Navigation 组件作为根容器,管理页面栈。
134
+ `,
135
+ },
136
+ {
137
+ documentId: 'guides/state-management',
138
+ catalog: 'guides',
139
+ content: `# 状态管理详解
140
+
141
+ ## 概述
142
+ ArkUI 提供多种状态管理装饰器:@State、@Prop、@Link、@Provide/@Consume。
143
+
144
+ #### @State:组件内部状态
145
+ @State 修饰的变量变化时,组件 build() 重新执行,UI 自动刷新。
146
+
147
+ #### @Prop:父到子单向同步
148
+ 父组件 @State 变化时,自动同步到子组件 @Prop。
149
+ 注意 @Builder 的参数不会随 @State 变化更新,需要用子组件替代。
150
+
151
+ #### @Link:双向同步
152
+ 父子组件共享同一个数据源,任一方修改都会同步。
153
+
154
+ #### @Provide/@Consume:跨层级传递
155
+ 祖先组件 @Provide 提供数据,后代组件 @Consume 消费数据。
156
+ 适合深层嵌套组件间的数据共享。
157
+
158
+ #### AppStorage:应用级状态
159
+ AppStorage 是应用全局状态存储,配合 @StorageLink/@StorageProp 使用。
160
+ `,
161
+ },
162
+ {
163
+ documentId: 'references/camera-manager-api',
164
+ catalog: 'references',
165
+ content: `# CameraManager API 参考
166
+
167
+ ## 概述
168
+ cameraManager 是相机管理的核心接口,提供相机打开、配置、拍照等功能。
169
+
170
+ #### cameraManager.getCameraManager()
171
+ 获取 CameraManager 实例。
172
+
173
+ \`\`\`typescript
174
+ import { camera } from '@kit.CameraKit';
175
+
176
+ const cameraManager: camera.CameraManager = camera.getCameraManager();
177
+ const cameras: Array<camera.CameraDevice> = cameraManager.getSupportedCameras();
178
+ \`\`\`
179
+
180
+ #### CameraManager.createCameraSession()
181
+ 创建相机会话,用于预览和拍照。
182
+
183
+ \`\`\`typescript
184
+ const session: camera.CameraSession = cameraManager.createCameraSession(cameras[0]);
185
+ session.beginConfig();
186
+ session.addInput(cameraInput);
187
+ session.addOutput(previewOutput);
188
+ await session.commitConfig();
189
+ await session.start();
190
+ \`\`\`
191
+
192
+ #### cameraManager.on('cameraStatus')
193
+ 监听相机状态变化事件。
194
+ `,
195
+ },
196
+ {
197
+ documentId: 'best-practices/performance-list',
198
+ catalog: 'best-practices',
199
+ content: `# 列表性能优化最佳实践
200
+
201
+ ## 概述
202
+ 长列表是性能优化的重点场景。使用 LazyForEach 替代 ForEach 实现按需加载。
203
+
204
+ #### 使用 LazyForEach
205
+ LazyForEach 只渲染可视区域的列表项,大幅减少内存占用和渲染时间。
206
+
207
+ \`\`\`typescript
208
+ LazyForEach(this.dataSource, (item: string) => {
209
+ ListItem() {
210
+ Text(item)
211
+ }
212
+ }, (item: string) => item)
213
+ \`\`\`
214
+
215
+ #### 组件复用
216
+ 使用 @Reusable 装饰器实现组件复用,减少重复创建开销。
217
+
218
+ #### 避免在 build 中做重计算
219
+ build() 方法应保持轻量,复杂计算放到 aboutToAppear 或异步方法中。
220
+ `,
221
+ },
222
+ {
223
+ documentId: 'faqs/webview-crash',
224
+ catalog: 'faqs',
225
+ content: `# WebView 崩溃问题排查
226
+
227
+ ## 问题描述
228
+ 应用中使用 WebView 加载网页时偶现崩溃,日志显示 SIGSEGV 空指针异常。
229
+
230
+ #### 原因分析
231
+ WebView 组件在页面销毁时未正确释放资源,导致空指针访问。
232
+ 常见于快速切换页面场景。
233
+
234
+ #### 解决方案
235
+ 1. 在 aboutToDisappear 中调用 webviewController 销毁方法
236
+ 2. 避免在 WebView 销毁后继续访问相关对象
237
+ 3. 使用 try-catch 包裹 WebView 操作
238
+
239
+ \`\`\`typescript
240
+ aboutToDisappear() {
241
+ try {
242
+ this.controller.destroy();
243
+ } catch (e) {
244
+ console.error('WebView destroy failed: ' + e);
245
+ }
246
+ }
247
+ \`\`\`
248
+
249
+ #### 预防措施
250
+ - 使用 Navigation 管理页面生命周期
251
+ - WebView 页面设置独立路由,避免嵌套
252
+ `,
253
+ },
254
+ {
255
+ documentId: 'releases/api12-changes',
256
+ catalog: 'releases',
257
+ content: `# API 12 变更说明
258
+
259
+ ## 新增特性
260
+ #### Navigation 组件增强
261
+ Navigation 组件新增 NavPathStack 路由栈管理,支持编程式导航。
262
+
263
+ #### 新增 cameraManager 接口
264
+ cameraManager 新增 getSupportedCameras() 和 createCameraSession() 方法。
265
+
266
+ #### 废弃接口
267
+ - @ohos.camera 模块标记为废弃,迁移至 @kit.CameraKit
268
+ - router.push 推荐替换为 Navigation + NavDestination
269
+
270
+ ## 破坏性变更
271
+ #### @State 初始化要求
272
+ @State 变量必须在声明时初始化,不支持延迟初始化。
273
+ `,
274
+ },
275
+ ];
276
+
277
+ // ─── 主流程 ────────────────────────────────────────────────────────
278
+
279
+ async function main() {
280
+ console.log(`${BOLD}${GREEN}
281
+ ╔══════════════════════════════════════════════════════╗
282
+ ║ 文档检索引擎 Demo ║
283
+ ║ FTS5 全文检索 + Rerank 重排序 + jieba 分词 ║
284
+ ╚══════════════════════════════════════════════════════╝${RESET}
285
+ `);
286
+ info(`数据目录: ${DATA_DIR}`);
287
+
288
+ const engine = new DocSearchEngine();
289
+
290
+ try {
291
+ // ── 1. 初始化 ──────────────────────────────────────────────
292
+ section('1. 初始化引擎');
293
+ try {
294
+ // 不传 dataDir 时,engine 自动使用 DEFAULT_DATA_DIR(Archive/data)
295
+ await engine.init({ dataDir: DATA_DIR });
296
+ ok('引擎初始化成功');
297
+ info(`docs 目录: ${path.join(DATA_DIR, 'docs')}`);
298
+ info(`index 目录: ${path.join(DATA_DIR, '.index')}`);
299
+ } catch (e) {
300
+ fail(`初始化失败: ${e.message}`);
301
+ warn('请确认已安装依赖: npm install jieba-wasm');
302
+ return;
303
+ }
304
+
305
+ // 检查数据库是否已有数据
306
+ let existingStatus = await engine.getStatus();
307
+ const isFirstRun = existingStatus.documentCount === 0;
308
+ if (isFirstRun) {
309
+ info('数据库为空,首次运行——将添加测试文档');
310
+ } else {
311
+ info(`数据库已有 ${existingStatus.documentCount} 个文档,跳过添加(保护已有数据)`);
312
+ }
313
+
314
+ // ── 2. 添加文档(仅首次运行时添加,已存在则跳过) ─────────
315
+ section('2. 添加测试文档');
316
+ if (isFirstRun) {
317
+ for (const doc of SAMPLE_DOCS) {
318
+ await engine.addDocument(doc);
319
+ ok(`已添加: ${doc.documentId}`);
320
+ }
321
+ } else {
322
+ // 非首次运行:检查是否有缺失的文档,仅补充缺失的
323
+ let added = 0;
324
+ for (const doc of SAMPLE_DOCS) {
325
+ const exists = await engine.hasDocument(doc.documentId);
326
+ if (!exists) {
327
+ await engine.addDocument(doc);
328
+ ok(`已补充: ${doc.documentId}`);
329
+ added++;
330
+ }
331
+ }
332
+ if (added === 0) {
333
+ info('所有测试文档已存在,无需添加');
334
+ }
335
+ }
336
+
337
+ const status = await engine.getStatus();
338
+ info(`文档数: ${status.documentCount} | 段数: ${status.segmentCount} | DB: ${(status.dbSizeBytes / 1024).toFixed(1)}KB`);
339
+
340
+ // ── 3. 中文关键词搜索 ──────────────────────────────────────
341
+ section('3. 中文关键词搜索: "状态管理"');
342
+ let results = await engine.search({ query: '状态管理', limit: 5 });
343
+ printResults(results);
344
+
345
+ // ── 4. API 符号搜索 ────────────────────────────────────────
346
+ section('4. API 符号搜索: "cameraManager"');
347
+ results = await engine.search({ query: 'cameraManager', limit: 5 });
348
+ printResults(results);
349
+
350
+ // ── 5. 多词组合搜索 ────────────────────────────────────────
351
+ section('5. 多词组合搜索: "Navigation 路由 导航"');
352
+ results = await engine.search({ query: 'Navigation 路由 导航', limit: 5 });
353
+ printResults(results);
354
+
355
+ // ── 6. 同义词扩展搜索 ──────────────────────────────────────
356
+ section('6. 同义词扩展搜索: "弹窗" (同义词: dialog/popup)');
357
+ results = await engine.search({ query: '弹窗', limit: 5 });
358
+ printResults(results);
359
+ info('(内置 synonyms.json 中 "弹窗" 与 "dialog/popup" 互为同义词)');
360
+
361
+ // ── 7. 限定目录搜索 ────────────────────────────────────────
362
+ section('7. 限定目录搜索: "生命周期" (catalog=guides)');
363
+ results = await engine.search({ query: '生命周期', limit: 5, catalog: 'guides' });
364
+ printResults(results);
365
+
366
+ // ── 8. 模糊搜索 ────────────────────────────────────────────
367
+ section('8. 模糊搜索: "列表性能优化"');
368
+ results = await engine.search({ query: '列表性能优化', limit: 3 });
369
+ printResults(results);
370
+
371
+ // ── 9. 获取文档记录 ────────────────────────────────────────
372
+ section('9. 获取文档记录: references/camera-manager-api');
373
+ const record = await engine.getDocumentRecord('references/camera-manager-api');
374
+ if (record) {
375
+ ok(`标题: ${record.title}`);
376
+ ok(`目录: ${record.catalog}`);
377
+ ok(`段数: ${record.segmentCount}`);
378
+ ok(`内容长度: ${record.content.length} 字符`);
379
+ ok(`创建时间: ${new Date(record.createdAt).toLocaleString()}`);
380
+ } else {
381
+ fail('文档记录未找到');
382
+ }
383
+
384
+ // ── 10. 获取文档原文 ───────────────────────────────────────
385
+ section('10. 获取文档原文: guides/arkts-getting-started');
386
+ const content = await engine.getDocument('guides/arkts-getting-started');
387
+ if (content) {
388
+ ok(`获取成功,前 80 字符: ${content.slice(0, 80).replace(/\n/g, ' ')}...`);
389
+ } else {
390
+ fail('文档原文未找到');
391
+ }
392
+
393
+ // ── 11. 删除文档(仅首次运行演示,不破坏已有数据) ────────
394
+ section('11. 删除文档: faqs/webview-crash');
395
+ if (isFirstRun) {
396
+ await engine.removeDocument('faqs/webview-crash');
397
+ ok('文档已删除');
398
+ } else {
399
+ // 非首次运行:检查文档是否存在,存在才删除演示
400
+ const exists = await engine.hasDocument('faqs/webview-crash');
401
+ if (exists) {
402
+ await engine.removeDocument('faqs/webview-crash');
403
+ ok('文档已删除');
404
+ } else {
405
+ info('文档 faqs/webview-crash 不存在(可能之前已删除),跳过');
406
+ }
407
+ }
408
+ const afterDel = await engine.getStatus();
409
+ info(`删除后文档数: ${afterDel.documentCount}`);
410
+
411
+ // 验证搜索不再返回已删除文档
412
+ results = await engine.search({ query: 'WebView 崩溃', limit: 5 });
413
+ const stillExists = results.some((r) => r.documentId === 'faqs/webview-crash');
414
+ if (!stillExists) {
415
+ ok('已删除文档不再出现在搜索结果中');
416
+ } else {
417
+ warn('已删除文档仍出现在搜索结果中(可能索引缓存未失效)');
418
+ }
419
+
420
+ // ── 12. 全量重建索引 ───────────────────────────────────────
421
+ section('12. 全量重建索引');
422
+ await engine.rebuildIndex();
423
+ ok('索引重建完成(基于现有文档,不丢失数据)');
424
+ const rebuilt = await engine.getStatus();
425
+ info(`重建后 — 文档数: ${rebuilt.documentCount} | 段数: ${rebuilt.segmentCount} | DB: ${(rebuilt.dbSizeBytes / 1024).toFixed(1)}KB`);
426
+ info(`最后构建时间: ${rebuilt.lastBuiltAt ? new Date(rebuilt.lastBuiltAt).toLocaleString() : 'N/A'}`);
427
+
428
+ // ── 13. 重建后搜索验证 ─────────────────────────────────────
429
+ section('13. 重建后搜索验证: "cameraManager createCameraSession"');
430
+ results = await engine.search({ query: 'cameraManager createCameraSession', limit: 3 });
431
+ printResults(results);
432
+
433
+ // ── 14. 最终状态 ───────────────────────────────────────────
434
+ section('14. 最终引擎状态');
435
+ const finalStatus = await engine.getStatus();
436
+ console.log(` ${DIM}{${RESET}`);
437
+ console.log(` ${DIM}ready:${RESET} ${finalStatus.ready}`);
438
+ console.log(` ${DIM}documentCount:${RESET} ${finalStatus.documentCount}`);
439
+ console.log(` ${DIM}segmentCount:${RESET} ${finalStatus.segmentCount}`);
440
+ console.log(` ${DIM}dbSizeBytes:${RESET} ${finalStatus.dbSizeBytes} (${(finalStatus.dbSizeBytes / 1024).toFixed(1)} KB)`);
441
+ console.log(` ${DIM}indexVersion:${RESET} ${finalStatus.indexVersion}`);
442
+ console.log(` ${DIM}lastBuiltAt:${RESET} ${finalStatus.lastBuiltAt ? new Date(finalStatus.lastBuiltAt).toISOString() : 'null'}`);
443
+ console.log(` ${DIM}}${RESET}`);
444
+
445
+ // ── 15. 文件结构 ───────────────────────────────────────────
446
+ section('15. 数据目录文件结构');
447
+ printFileTree(DATA_DIR, ' ');
448
+
449
+ console.log(`\n${GREEN}${BOLD}━━━ Demo 完成 ━━━${RESET}\n`);
450
+ } catch (error) {
451
+ fail(`运行出错: ${error.message}`);
452
+ console.error(error.stack);
453
+ } finally {
454
+ await engine.close();
455
+ info('引擎已关闭');
456
+ }
457
+ }
458
+
459
+ /**
460
+ * 递归打印目录树。
461
+ * @param {string} dir
462
+ * @param {string} prefix
463
+ */
464
+ function printFileTree(dir, prefix = '') {
465
+ let entries;
466
+ try {
467
+ entries = fs.readdirSync(dir, { withFileTypes: true });
468
+ } catch {
469
+ return;
470
+ }
471
+ for (const entry of entries) {
472
+ const fullPath = path.join(dir, entry.name);
473
+ if (entry.isDirectory()) {
474
+ console.log(`${prefix}${BOLD}${entry.name}/${RESET}`);
475
+ printFileTree(fullPath, prefix + ' ');
476
+ } else {
477
+ const stat = fs.statSync(fullPath);
478
+ const sizeStr = stat.size < 1024 ? `${stat.size}B` : `${(stat.size / 1024).toFixed(1)}KB`;
479
+ console.log(`${prefix}${entry.name} ${DIM}(${sizeStr})${RESET}`);
480
+ }
481
+ }
482
+ }
483
+
484
+ // ─── 启动 ──────────────────────────────────────────────────────────
485
+
486
+ main().catch((err) => {
487
+ console.error(`${RED}未捕获错误:${RESET}`, err);
488
+ process.exit(1);
489
+ });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * index.js — Archive 对外统一导出入口
3
+ *
4
+ * 仅导出对外有价值的公共接口,外部导入本文件即可使用全部功能。
5
+ *
6
+ * 使用示例:
7
+ *
8
+ * import { DocSearchEngine, DEFAULT_CATALOGS } from './Archive/index.js';
9
+ *
10
+ * const engine = new DocSearchEngine();
11
+ * await engine.init(); // 默认使用 Archive/data 目录
12
+ *
13
+ * await engine.addDocument({
14
+ * documentId: 'guides/intro',
15
+ * catalog: 'guides',
16
+ * content: '# 入门指南\n这是一篇入门文档。',
17
+ * });
18
+ *
19
+ * const results = await engine.search({ query: '入门', limit: 5 });
20
+ *
21
+ * const status = await engine.getStatus();
22
+ * if (status.dbSizeWarning) console.warn('数据库接近 git 提交大小阈值');
23
+ *
24
+ * await engine.close(); // 自动 checkpoint 合并 WAL
25
+ */
26
+
27
+ // ── 核心引擎(主要入口) ──
28
+ export { default as DocSearchEngine } from './src/engine.js';
29
+
30
+ // ── 常量(外部可能需要引用的配置项) ──
31
+ export {
32
+ DEFAULT_DATA_DIR,
33
+ DEFAULT_CATALOGS,
34
+ INDEX_VERSION,
35
+ GIT_WARN_BYTES,
36
+ } from './src/constants.js';
37
+
38
+ // ── 错误类型(外部需要 catch 判断) ──
39
+ export { PathSafetyError } from './src/utils/path-safety.js';
40
+
41
+ // ── Markdown 解析(独立使用场景:拆分文档/提取标题) ──
42
+ export { splitMarkdown, resolveDocTitle } from './src/parser/markdown-splitter.js';
43
+
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "doc-search-engine",
3
+ "version": "1.0.0",
4
+ "description": "本地文档检索引擎 - 基于 FTS5 全文检索与 Rerank 重排序",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "echo \"TODO: add tests\" && exit 0"
12
+ },
13
+ "dependencies": {
14
+ "jieba-wasm": "^2.4.0"
15
+ }
16
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * constants.js — 全局常量与阈值
3
+ *
4
+ * 集中管理索引数据库限制、查询参数、文档拆分规则、搜索文本预算、
5
+ * 摘要长度、Rerank 系数和默认目录配置,避免魔术数字散落各处。
6
+ */
7
+
8
+ import path from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+
11
+ /**
12
+ * 默认数据目录(知识库持久化路径)。
13
+ * 指向 Archive/data,可 git 提交到仓库,重复执行不会覆盖。
14
+ */
15
+ const _srcDir = path.dirname(fileURLToPath(import.meta.url));
16
+ export const DEFAULT_DATA_DIR = path.resolve(_srcDir, '..', 'data');
17
+
18
+ /** 索引版本号(变更后需要全量重建) */
19
+ export const INDEX_VERSION = '1.0.0';
20
+
21
+ /** 索引数据库大小上限(字节) */
22
+ export const INDEX_DB_MAX_BYTES = 48 * 1024 * 1024;
23
+
24
+ /** Git 提交警告阈值(字节),超过此值在 getStatus 中提醒 */
25
+ export const GIT_WARN_BYTES = 8 * 1024 * 1024;
26
+
27
+ /* ── 查询限制 ── */
28
+ /** 原始查询字符串最大长度 */
29
+ export const QUERY_MAX_RAW_CHARS = 200;
30
+ /** FTS5 MATCH 表达式最大 token 数 */
31
+ export const QUERY_MAX_FTS_TOKENS = 12;
32
+ /** AND 匹配策略允许的最大 token 数(超出则退化为 OR) */
33
+ export const QUERY_AND_MAX_TOKENS = 4;
34
+ /** 同义词扩展后的最大词条数 */
35
+ export const SYNONYM_EXPAND_MAX_PARTS = 8;
36
+
37
+ /* ── 文档拆分 ── */
38
+ /** 单文档最大段(segment)数 */
39
+ export const MAX_SECTIONS_PER_DOC = 28;
40
+ /** 分块最小行数(用于大段切分判断) */
41
+ export const CHUNK_MIN_LINES = 280;
42
+ /** 分块最小 H4 段数 */
43
+ export const CHUNK_MIN_H4_SECTIONS = 6;
44
+
45
+ /* ── 搜索文本预算(文档级) ── */
46
+ export const SEARCH_TEXT_MAX_CHARS = 1320;
47
+ export const BUDGET_TITLE = 120;
48
+ export const BUDGET_API_SYMBOLS = 450;
49
+ export const BUDGET_HEADINGS = 250;
50
+ export const BUDGET_BODY = 500;
51
+
52
+ /* ── 搜索文本预算(段级) ── */
53
+ export const SECTION_SEARCH_TEXT_MAX_CHARS = 480;
54
+ export const SECTION_BUDGET_TITLE = 80;
55
+ export const SECTION_BUDGET_API_SYMBOLS = 200;
56
+ export const SECTION_BUDGET_HEADINGS = 60;
57
+ export const SECTION_BUDGET_BODY = 200;
58
+
59
+ /* ── 摘要 ── */
60
+ export const SNIPPET_MAX_CHARS = 200;
61
+ export const SNIPPET_CONTEXT_CHARS = 40;
62
+ export const LEAD_TEXT_CHARS = 200;
63
+
64
+ /* ── Rerank ── */
65
+ /** 结果池放大系数:实际获取 limit × 此数再 rerank */
66
+ export const RERANK_POOL_FACTOR = 6;
67
+
68
+ /* ── 批量插入 ── */
69
+ export const INSERT_BATCH_SIZE = 500;
70
+
71
+ /* ── 默认目录配置 ── */
72
+ export const DEFAULT_CATALOGS = [
73
+ { id: 'guides', title: '开发指南', searchBoost: 1.0 },
74
+ { id: 'references', title: 'API参考', searchBoost: 1.0 },
75
+ { id: 'best-practices', title: '最佳实践', searchBoost: 1.0 },
76
+ { id: 'faqs', title: '常见问题', searchBoost: 1.0 },
77
+ { id: 'releases', title: '版本说明', searchBoost: 1.0, tailInGlobalSearch: true },
78
+ { id: 'roadmap', title: '变更预告', searchBoost: 1.0, tailInGlobalSearch: true },
79
+ ];
80
+
81
+ /* ── 文件锁 ── */
82
+ /** 锁文件 stale 时间(毫秒),超过自动释放防死锁 */
83
+ export const LOCK_STALE_MS = 30 * 60 * 1000;