@ngockhoale/ukit 1.1.6

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 (344) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/LICENSE +21 -0
  3. package/README.md +189 -0
  4. package/bin/ukit +30 -0
  5. package/manifests/platform.full.yaml +1194 -0
  6. package/package.json +71 -0
  7. package/scripts/bug/triage.mjs +37 -0
  8. package/scripts/index/build-index.mjs +35 -0
  9. package/scripts/index/query-index.mjs +92 -0
  10. package/scripts/index/refresh-index.mjs +85 -0
  11. package/scripts/release/verify-release.mjs +56 -0
  12. package/src/bug/triageBug.js +123 -0
  13. package/src/cli/adapters.js +148 -0
  14. package/src/cli/commands/diff.js +51 -0
  15. package/src/cli/commands/doctor.js +125 -0
  16. package/src/cli/commands/indexArgs.js +73 -0
  17. package/src/cli/commands/indexTools.js +509 -0
  18. package/src/cli/commands/install.js +293 -0
  19. package/src/cli/commands/memory.js +126 -0
  20. package/src/cli/commands/status.js +8 -0
  21. package/src/cli/commands/uninstall.js +51 -0
  22. package/src/cli/index.js +109 -0
  23. package/src/context/detectProjectContext.js +49 -0
  24. package/src/context/detectProviders.js +12 -0
  25. package/src/core/applyPlan.js +89 -0
  26. package/src/core/buildPlan.js +228 -0
  27. package/src/core/compact/index.js +294 -0
  28. package/src/core/compact/threshold.js +936 -0
  29. package/src/core/diffPlan.js +73 -0
  30. package/src/core/ensureGitignore.js +117 -0
  31. package/src/core/fileOps.js +188 -0
  32. package/src/core/memory/hygiene.js +160 -0
  33. package/src/core/memory/index.js +2 -0
  34. package/src/core/memory/retrieval.js +476 -0
  35. package/src/core/memory/store.js +202 -0
  36. package/src/core/metadata.js +132 -0
  37. package/src/core/migrateLegacy.js +139 -0
  38. package/src/core/output/index.js +1309 -0
  39. package/src/core/paths.js +13 -0
  40. package/src/core/report.js +17 -0
  41. package/src/core/router/advisor.js +42 -0
  42. package/src/core/router/index.js +2 -0
  43. package/src/core/router/router.js +164 -0
  44. package/src/core/runInstallPipeline.js +365 -0
  45. package/src/core/runtimeConfig.js +190 -0
  46. package/src/core/runtimePaths.js +24 -0
  47. package/src/core/status.js +186 -0
  48. package/src/core/token/index.js +328 -0
  49. package/src/core/uninstall.js +246 -0
  50. package/src/core/validation/confidence.js +89 -0
  51. package/src/core/validation/index.js +2 -0
  52. package/src/core/validation/validator.js +165 -0
  53. package/src/index/buildIndex.js +1392 -0
  54. package/src/index/gitHooks.js +109 -0
  55. package/src/index/importResolution.js +377 -0
  56. package/src/index/languageTools.js +127 -0
  57. package/src/index/paths.js +27 -0
  58. package/src/index/queryIndex.js +637 -0
  59. package/src/index/relatedTests.js +237 -0
  60. package/src/index/resolveContext.js +345 -0
  61. package/src/index/routeCatalog.js +258 -0
  62. package/src/index/taskRouting.js +677 -0
  63. package/src/index/verificationPlan.js +437 -0
  64. package/src/manifest/loadManifest.js +22 -0
  65. package/src/manifest/selectItems.js +78 -0
  66. package/src/manifest/validateManifest.js +115 -0
  67. package/src/render/buildVariables.js +39 -0
  68. package/src/render/renderTemplate.js +44 -0
  69. package/src/stack/detectStack.js +213 -0
  70. package/templates/.claude/agents/bug-debugger.md +57 -0
  71. package/templates/.claude/agents/feature-implementer.md +55 -0
  72. package/templates/.claude/config/providers.md +25 -0
  73. package/templates/.claude/hooks/auto-allow-bash.sh +155 -0
  74. package/templates/.claude/hooks/auto-prune-bash.sh +75 -0
  75. package/templates/.claude/hooks/block-dangerous.sh +54 -0
  76. package/templates/.claude/hooks/compress-output.sh +17 -0
  77. package/templates/.claude/hooks/protect-files.sh +37 -0
  78. package/templates/.claude/hooks/reinject-context.sh +28 -0
  79. package/templates/.claude/hooks/session-start.md +13 -0
  80. package/templates/.claude/hooks/skill-router.sh +1681 -0
  81. package/templates/.claude/hooks/verification-guard.sh +271 -0
  82. package/templates/.claude/settings.json +144 -0
  83. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  84. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  85. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  86. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  87. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  88. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  89. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  90. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  91. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  92. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  93. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  94. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  95. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  96. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  97. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  98. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  99. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  100. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  101. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  102. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  103. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  104. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  105. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  106. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  107. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  108. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  109. package/templates/.claude/skills/_shared/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  110. package/templates/.claude/skills/_shared/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  111. package/templates/.claude/skills/_shared/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  112. package/templates/.claude/skills/_shared/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  113. package/templates/.claude/skills/_shared/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  114. package/templates/.claude/skills/_shared/ooxml/schemas/mce/mc.xsd +75 -0
  115. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  116. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  117. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  118. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  119. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  120. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  121. package/templates/.claude/skills/_shared/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  122. package/templates/.claude/skills/_shared/ooxml/scripts/pack.py +159 -0
  123. package/templates/.claude/skills/_shared/ooxml/scripts/unpack.py +29 -0
  124. package/templates/.claude/skills/_shared/ooxml/scripts/validate.py +69 -0
  125. package/templates/.claude/skills/_shared/ooxml/scripts/validation/__init__.py +15 -0
  126. package/templates/.claude/skills/_shared/ooxml/scripts/validation/base.py +951 -0
  127. package/templates/.claude/skills/_shared/ooxml/scripts/validation/docx.py +274 -0
  128. package/templates/.claude/skills/_shared/ooxml/scripts/validation/pptx.py +315 -0
  129. package/templates/.claude/skills/_shared/ooxml/scripts/validation/redlining.py +279 -0
  130. package/templates/.claude/skills/backend-api/SKILL.md +26 -0
  131. package/templates/.claude/skills/canvas-design/LICENSE.txt +202 -0
  132. package/templates/.claude/skills/canvas-design/SKILL.md +130 -0
  133. package/templates/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  134. package/templates/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  135. package/templates/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  136. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  137. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  138. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  139. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  140. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  141. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  142. package/templates/.claude/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  143. package/templates/.claude/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  144. package/templates/.claude/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  145. package/templates/.claude/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  146. package/templates/.claude/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  147. package/templates/.claude/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  148. package/templates/.claude/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  149. package/templates/.claude/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
  150. package/templates/.claude/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  151. package/templates/.claude/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  152. package/templates/.claude/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  153. package/templates/.claude/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  154. package/templates/.claude/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
  155. package/templates/.claude/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
  156. package/templates/.claude/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  157. package/templates/.claude/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
  158. package/templates/.claude/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
  159. package/templates/.claude/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
  160. package/templates/.claude/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  161. package/templates/.claude/skills/code-review/SKILL.md +97 -0
  162. package/templates/.claude/skills/debugging-toolkit/SKILL.md +156 -0
  163. package/templates/.claude/skills/delivery/SKILL.md +92 -0
  164. package/templates/.claude/skills/discover-security/SKILL.md +86 -0
  165. package/templates/.claude/skills/docker-packaging/SKILL.md +60 -0
  166. package/templates/.claude/skills/docs-manager/SKILL.md +465 -0
  167. package/templates/.claude/skills/docs-manager/init-project-docs.sh +70 -0
  168. package/templates/.claude/skills/docs-manager/templates/README.md.template +50 -0
  169. package/templates/.claude/skills/docs-manager/templates/agent-roles.md.template +24 -0
  170. package/templates/.claude/skills/docs-manager/templates/coding-conventions.md.template +28 -0
  171. package/templates/.claude/skills/docs-manager/templates/memory.md.template +30 -0
  172. package/templates/.claude/skills/docs-manager/templates/onboarding.md.template +20 -0
  173. package/templates/.claude/skills/docs-manager/templates/project.md.template +26 -0
  174. package/templates/.claude/skills/docs-quality/SKILL.md +148 -0
  175. package/templates/.claude/skills/docx/LICENSE.txt +30 -0
  176. package/templates/.claude/skills/docx/SKILL.md +197 -0
  177. package/templates/.claude/skills/docx/docx-js.md +350 -0
  178. package/templates/.claude/skills/docx/ooxml.md +610 -0
  179. package/templates/.claude/skills/docx/scripts/__init__.py +1 -0
  180. package/templates/.claude/skills/docx/scripts/document.py +1276 -0
  181. package/templates/.claude/skills/docx/scripts/templates/comments.xml +3 -0
  182. package/templates/.claude/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  183. package/templates/.claude/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  184. package/templates/.claude/skills/docx/scripts/templates/commentsIds.xml +3 -0
  185. package/templates/.claude/skills/docx/scripts/templates/people.xml +3 -0
  186. package/templates/.claude/skills/docx/scripts/utilities.py +374 -0
  187. package/templates/.claude/skills/duraone/SKILL.md +204 -0
  188. package/templates/.claude/skills/duraone/references/backend.md +636 -0
  189. package/templates/.claude/skills/duraone/references/frontend.md +1506 -0
  190. package/templates/.claude/skills/duraone/references/sql.md +631 -0
  191. package/templates/.claude/skills/duraone/references/workflow.md +520 -0
  192. package/templates/.claude/skills/executing-plans/SKILL.md +76 -0
  193. package/templates/.claude/skills/file-organizer/SKILL.md +433 -0
  194. package/templates/.claude/skills/frontend/SKILL.md +26 -0
  195. package/templates/.claude/skills/frontend-design/LICENSE.txt +177 -0
  196. package/templates/.claude/skills/frontend-design/SKILL.md +42 -0
  197. package/templates/.claude/skills/frontend-vue/SKILL.md +127 -0
  198. package/templates/.claude/skills/frontend-vue/components/Control/Box.vue +137 -0
  199. package/templates/.claude/skills/frontend-vue/components/Control/Button.vue +93 -0
  200. package/templates/.claude/skills/frontend-vue/components/Control/ButtonBar.vue +29 -0
  201. package/templates/.claude/skills/frontend-vue/components/Control/ButtonFloat.vue +62 -0
  202. package/templates/.claude/skills/frontend-vue/components/Control/CheckButton.vue +75 -0
  203. package/templates/.claude/skills/frontend-vue/components/Control/Checkbox.vue +58 -0
  204. package/templates/.claude/skills/frontend-vue/components/Control/Datetime.vue +148 -0
  205. package/templates/.claude/skills/frontend-vue/components/Control/Dropdownlist.vue +156 -0
  206. package/templates/.claude/skills/frontend-vue/components/Control/Input.vue +106 -0
  207. package/templates/.claude/skills/frontend-vue/components/Control/Label.vue +38 -0
  208. package/templates/.claude/skills/frontend-vue/components/Control/Master/BoxColumn.vue +24 -0
  209. package/templates/.claude/skills/frontend-vue/components/Control/Popup/Confirm.vue +33 -0
  210. package/templates/.claude/skills/frontend-vue/components/Control/Popup/Info.vue +32 -0
  211. package/templates/.claude/skills/frontend-vue/components/Control/Popup/ModalInfo.vue +39 -0
  212. package/templates/.claude/skills/frontend-vue/components/Control/Popup/Reject.vue +64 -0
  213. package/templates/.claude/skills/frontend-vue/components/Control/Tag.vue +82 -0
  214. package/templates/.claude/skills/frontend-vue/components/Control/Upload.vue +61 -0
  215. package/templates/.claude/skills/frontend-vue/components/ControlMobile/Dropdownlist.vue +103 -0
  216. package/templates/.claude/skills/frontend-vue/components/ControlMobile/PagingBar.vue +108 -0
  217. package/templates/.claude/skills/frontend-vue/components/ControlMobile/UploadImage.vue +137 -0
  218. package/templates/.claude/skills/frontend-vue/components/Grid/AG.vue +806 -0
  219. package/templates/.claude/skills/frontend-vue/components/Grid/AntTable.vue +253 -0
  220. package/templates/.claude/skills/frontend-vue/components/Grid/CustomDropdownEditor.vue +43 -0
  221. package/templates/.claude/skills/frontend-vue/components/Grid/CustomDropdownEditorEnable.vue +55 -0
  222. package/templates/.claude/skills/frontend-vue/components/Grid/HtmlTable.vue +40 -0
  223. package/templates/.claude/skills/frontend-vue/components/PDFViewer.vue +25 -0
  224. package/templates/.claude/skills/frontend-vue/components/Panel/FormView.vue +309 -0
  225. package/templates/.claude/skills/frontend-vue/components/Partial/Footer.vue +23 -0
  226. package/templates/.claude/skills/frontend-vue/components/Partial/Header.vue +265 -0
  227. package/templates/.claude/skills/frontend-vue/components/Partial/Sidebar.vue +122 -0
  228. package/templates/.claude/skills/frontend-vue/components/Template.vue +16 -0
  229. package/templates/.claude/skills/frontend-vue/components/View/Form.vue +89 -0
  230. package/templates/.claude/skills/frontend-vue/composables/indexDBStore.js +140 -0
  231. package/templates/.claude/skills/frontend-vue/composables/masterApi.js +362 -0
  232. package/templates/.claude/skills/frontend-vue/composables/state.js +578 -0
  233. package/templates/.claude/skills/frontend-vue/composables/useRequest.js +221 -0
  234. package/templates/.claude/skills/frontend-vue/composables/useSession.js +179 -0
  235. package/templates/.claude/skills/frontend-vue/composables/useTranslation.js +54 -0
  236. package/templates/.claude/skills/frontend-vue/composables/useWebSocket.js +257 -0
  237. package/templates/.claude/skills/frontend-vue/composables/userObj.js +111 -0
  238. package/templates/.claude/skills/frontend-vue/composables/utils.js +322 -0
  239. package/templates/.claude/skills/frontend-vue/reference/composables-example.vue +320 -0
  240. package/templates/.claude/skills/frontend-vue/reference/form-example.vue +183 -0
  241. package/templates/.claude/skills/frontend-vue/reference/grid-example.vue +147 -0
  242. package/templates/.claude/skills/frontend-vue/reference/masterdata-example/[id].vue +106 -0
  243. package/templates/.claude/skills/frontend-vue/reference/masterdata-example/index.vue +58 -0
  244. package/templates/.claude/skills/frontend-vue/reference/popup-example.vue +159 -0
  245. package/templates/.claude/skills/pdf/LICENSE.txt +30 -0
  246. package/templates/.claude/skills/pdf/SKILL.md +294 -0
  247. package/templates/.claude/skills/pdf/forms.md +205 -0
  248. package/templates/.claude/skills/pdf/reference.md +612 -0
  249. package/templates/.claude/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  250. package/templates/.claude/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  251. package/templates/.claude/skills/pdf/scripts/check_fillable_fields.py +12 -0
  252. package/templates/.claude/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  253. package/templates/.claude/skills/pdf/scripts/create_validation_image.py +41 -0
  254. package/templates/.claude/skills/pdf/scripts/extract_form_field_info.py +152 -0
  255. package/templates/.claude/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  256. package/templates/.claude/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  257. package/templates/.claude/skills/pdf-processing/SKILL.md +107 -0
  258. package/templates/.claude/skills/pdf-processing-pro/FORMS.md +610 -0
  259. package/templates/.claude/skills/pdf-processing-pro/OCR.md +137 -0
  260. package/templates/.claude/skills/pdf-processing-pro/SKILL.md +296 -0
  261. package/templates/.claude/skills/pdf-processing-pro/TABLES.md +626 -0
  262. package/templates/.claude/skills/pdf-processing-pro/scripts/analyze_form.py +307 -0
  263. package/templates/.claude/skills/postgres/SKILL.md +69 -0
  264. package/templates/.claude/skills/postgres/reference/fn_get_examples.sql +208 -0
  265. package/templates/.claude/skills/postgres/reference/fn_rpt_examples.sql +239 -0
  266. package/templates/.claude/skills/postgres/reference/utility_functions.sql +94 -0
  267. package/templates/.claude/skills/pptx/LICENSE.txt +30 -0
  268. package/templates/.claude/skills/pptx/SKILL.md +484 -0
  269. package/templates/.claude/skills/pptx/html2pptx.md +625 -0
  270. package/templates/.claude/skills/pptx/ooxml.md +427 -0
  271. package/templates/.claude/skills/pptx/scripts/html2pptx.js +979 -0
  272. package/templates/.claude/skills/pptx/scripts/inventory.py +1020 -0
  273. package/templates/.claude/skills/pptx/scripts/rearrange.py +231 -0
  274. package/templates/.claude/skills/pptx/scripts/replace.py +385 -0
  275. package/templates/.claude/skills/pptx/scripts/thumbnail.py +450 -0
  276. package/templates/.claude/skills/repo-maintenance/SKILL.md +97 -0
  277. package/templates/.claude/skills/research/EXAMPLES.md +434 -0
  278. package/templates/.claude/skills/research/REFERENCE.md +399 -0
  279. package/templates/.claude/skills/research/SKILL.md +136 -0
  280. package/templates/.claude/skills/root-cause-tracing/SKILL.md +174 -0
  281. package/templates/.claude/skills/root-cause-tracing/find-polluter.sh +63 -0
  282. package/templates/.claude/skills/sharing-skills/SKILL.md +194 -0
  283. package/templates/.claude/skills/sql-optimization-patterns/SKILL.md +493 -0
  284. package/templates/.claude/skills/subagent-driven-development/SKILL.md +189 -0
  285. package/templates/.claude/skills/systematic-debugging/CREATION-LOG.md +119 -0
  286. package/templates/.claude/skills/systematic-debugging/SKILL.md +295 -0
  287. package/templates/.claude/skills/systematic-debugging/test-academic.md +14 -0
  288. package/templates/.claude/skills/systematic-debugging/test-pressure-1.md +58 -0
  289. package/templates/.claude/skills/systematic-debugging/test-pressure-2.md +68 -0
  290. package/templates/.claude/skills/systematic-debugging/test-pressure-3.md +69 -0
  291. package/templates/.claude/skills/test-driven-development/SKILL.md +364 -0
  292. package/templates/.claude/skills/testing-anti-patterns/SKILL.md +302 -0
  293. package/templates/.claude/skills/testing-quality/SKILL.md +97 -0
  294. package/templates/.claude/skills/verification-before-completion/SKILL.md +139 -0
  295. package/templates/.claude/skills/webapp-testing/LICENSE.txt +202 -0
  296. package/templates/.claude/skills/webapp-testing/SKILL.md +96 -0
  297. package/templates/.claude/skills/webapp-testing/examples/console_logging.py +35 -0
  298. package/templates/.claude/skills/webapp-testing/examples/element_discovery.py +40 -0
  299. package/templates/.claude/skills/webapp-testing/examples/static_html_automation.py +33 -0
  300. package/templates/.claude/skills/webapp-testing/scripts/with_server.py +106 -0
  301. package/templates/.claude/ukit/index/build-index.mjs +28 -0
  302. package/templates/.claude/ukit/index/cache-utils.mjs +140 -0
  303. package/templates/.claude/ukit/index/lib/index-core.mjs +2800 -0
  304. package/templates/.claude/ukit/index/query-index.mjs +150 -0
  305. package/templates/.claude/ukit/index/refresh-index.mjs +57 -0
  306. package/templates/.claude/ukit/index/reset-auto-permissions.mjs +76 -0
  307. package/templates/.claude/ukit/index/resolve-context.mjs +279 -0
  308. package/templates/.claude/ukit/index/route-catalog.mjs +258 -0
  309. package/templates/.claude/ukit/index/route-task.mjs +1994 -0
  310. package/templates/.claude/ukit/index/triage.mjs +133 -0
  311. package/templates/.claude/ukit/index/verify-context.mjs +689 -0
  312. package/templates/.claude/ukit/runtime/compact-threshold.mjs +1013 -0
  313. package/templates/.claude/ukit/runtime/output-compression.mjs +1340 -0
  314. package/templates/.claude/ukit/runtime/reinject-context.mjs +874 -0
  315. package/templates/.claude/ukit/runtime/token-utils.mjs +500 -0
  316. package/templates/.codex/README.md +83 -0
  317. package/templates/.codex/settings.json +187 -0
  318. package/templates/.gitignore +75 -0
  319. package/templates/AGENTS.md +116 -0
  320. package/templates/CLAUDE.md +93 -0
  321. package/templates/adapter-presets/antigravity/README.md +22 -0
  322. package/templates/adapter-presets/antigravity/rules.md +49 -0
  323. package/templates/adapter-presets/claude/settings.local.json +42 -0
  324. package/templates/adapter-presets/codex/settings.local.json +6 -0
  325. package/templates/adapter-presets/opencode/opencode.template.json +1 -0
  326. package/templates/docs/BUGFIX.md +20 -0
  327. package/templates/docs/BUG_INDEX.md +12 -0
  328. package/templates/docs/BUG_METRICS.md +7 -0
  329. package/templates/docs/BUG_TEMPLATE.md +13 -0
  330. package/templates/docs/CODE_MAP.md +35 -0
  331. package/templates/docs/INSTALL.md +113 -0
  332. package/templates/docs/MEMORY.md +49 -0
  333. package/templates/docs/PROJECT.md +50 -0
  334. package/templates/docs/UKIT_USAGE_GUIDE.md +147 -0
  335. package/templates/docs/WORKLOG.md +10 -0
  336. package/templates/ukit/README.md +14 -0
  337. package/templates/ukit/storage/cache/compact-history.json +3 -0
  338. package/templates/ukit/storage/cache/compact-pressure.json +1 -0
  339. package/templates/ukit/storage/cache/output-history.json +3 -0
  340. package/templates/ukit/storage/cache/prompt-cache.json +3 -0
  341. package/templates/ukit/storage/config.json +37 -0
  342. package/templates/ukit/storage/memory/projects/.gitkeep +2 -0
  343. package/templates/ukit/storage/memory/sessions/.gitkeep +0 -0
  344. package/templates/ukit/storage/memory/user.json +5 -0
@@ -0,0 +1,637 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ import { getArtifactPath, getIndexDir, INDEX_ARTIFACTS } from './paths.js';
5
+ import { importsNeedAliasContext, loadImportAliasContext, resolveImportSpecifier } from './importResolution.js';
6
+ import { buildSearchDescriptor } from './languageTools.js';
7
+
8
+ const ARTIFACT_CACHE = new Map();
9
+ const QUERY_SEARCH_BUNDLE_CACHE = new Map();
10
+ const QUERY_SUPPORT_BUNDLE_CACHE = new Map();
11
+ const QUERY_RESULT_CACHE = new Map();
12
+ const ANALOG_RESULT_CACHE = new Map();
13
+ const MAX_IMPORTER_HOPS = 2;
14
+
15
+ export async function queryCodeIndex({ rootDir = process.cwd(), query, limit = 5 } = {}) {
16
+ if (!query || !query.trim()) {
17
+ return [];
18
+ }
19
+ if (limit <= 0) {
20
+ return Object.freeze([]);
21
+ }
22
+
23
+ const absoluteRoot = path.resolve(rootDir);
24
+ const normalizedQuery = String(query).trim();
25
+ const queryDescriptor = buildSearchDescriptor(normalizedQuery, {
26
+ expandVietnameseAliases: true,
27
+ });
28
+ if (queryDescriptor.tokens.size === 0) {
29
+ return Object.freeze([]);
30
+ }
31
+ const queryCacheKey = JSON.stringify({
32
+ rootDir: absoluteRoot,
33
+ query: normalizedQuery,
34
+ limit,
35
+ });
36
+ if (QUERY_RESULT_CACHE.has(queryCacheKey)) {
37
+ return QUERY_RESULT_CACHE.get(queryCacheKey);
38
+ }
39
+ const queryPromise = (async () => {
40
+ const { files, searchDescriptorsByFile } = await loadQuerySearchBundle(absoluteRoot);
41
+ const preferredArchetypes = inferPreferredArchetypes(queryDescriptor.tokens);
42
+ const includeLikelyTestFiles = shouldIncludeLikelyTestFiles(queryDescriptor);
43
+
44
+ const directScores = new Map();
45
+
46
+ for (const file of files.items ?? []) {
47
+ const filePath = file.filePath;
48
+ if (isLikelyTestFilePath(filePath) && !includeLikelyTestFiles) {
49
+ continue;
50
+ }
51
+ const searchDescriptor = searchDescriptorsByFile.get(filePath) ?? createFileSearchDescriptor({ filePath, symbols: [] });
52
+ const { score, reasons } = scoreDirectFileMatch({
53
+ queryDescriptor,
54
+ filePath,
55
+ searchDescriptor,
56
+ });
57
+
58
+ if (score > 0) {
59
+ directScores.set(filePath, {
60
+ filePath,
61
+ score,
62
+ reasons: dedupe(reasons),
63
+ });
64
+ }
65
+ }
66
+
67
+ if (directScores.size === 0) {
68
+ return Object.freeze([]);
69
+ }
70
+
71
+ const {
72
+ hotspotScores,
73
+ testsMapBySource,
74
+ resolvedImportsBySource,
75
+ importersByTarget,
76
+ archetypeByFile,
77
+ } = await loadQuerySupportBundle(absoluteRoot);
78
+
79
+ const enrichedDirectScores = new Map();
80
+ for (const [filePath, entry] of directScores) {
81
+ let score = entry.score;
82
+ const reasons = [...(entry.reasons ?? [])];
83
+ const archetype = archetypeByFile.get(filePath) ?? 'other';
84
+ if (preferredArchetypes.has(archetype)) {
85
+ score += 4;
86
+ reasons.push(`archetype_hint:${archetype}`);
87
+ }
88
+
89
+ enrichedDirectScores.set(filePath, {
90
+ filePath,
91
+ score,
92
+ reasons: dedupe(reasons),
93
+ tests: testsMapBySource.get(filePath) ?? [],
94
+ });
95
+ }
96
+
97
+ const relatedScores = applyImportGraphBoosts({
98
+ directScores: enrichedDirectScores,
99
+ resolvedImportsBySource,
100
+ importersByTarget,
101
+ testsMapBySource,
102
+ });
103
+ const finalScores = applyHotspotBoosts({
104
+ scores: relatedScores,
105
+ hotspotScores,
106
+ });
107
+
108
+ return freezeQueryResults(
109
+ [...finalScores.values()]
110
+ .sort((a, b) => b.score - a.score || a.filePath.localeCompare(b.filePath))
111
+ .slice(0, limit),
112
+ );
113
+ })().catch((error) => {
114
+ QUERY_RESULT_CACHE.delete(queryCacheKey);
115
+ throw error;
116
+ });
117
+
118
+ QUERY_RESULT_CACHE.set(queryCacheKey, queryPromise);
119
+ return queryPromise;
120
+ }
121
+
122
+ async function readArtifact(rootDir, artifactName) {
123
+ const artifactPath = getArtifactPath(path.resolve(rootDir), artifactName);
124
+
125
+ if (!ARTIFACT_CACHE.has(artifactPath)) {
126
+ ARTIFACT_CACHE.set(
127
+ artifactPath,
128
+ fs.readFile(artifactPath, 'utf8')
129
+ .then((content) => {
130
+ try {
131
+ return JSON.parse(content);
132
+ } catch {
133
+ ARTIFACT_CACHE.delete(artifactPath);
134
+ return null;
135
+ }
136
+ })
137
+ .catch((error) => {
138
+ ARTIFACT_CACHE.delete(artifactPath);
139
+ return null;
140
+ }),
141
+ );
142
+ }
143
+
144
+ return ARTIFACT_CACHE.get(artifactPath);
145
+ }
146
+
147
+ async function loadQuerySearchBundle(rootDir) {
148
+ const absoluteRoot = path.resolve(rootDir);
149
+
150
+ if (!QUERY_SEARCH_BUNDLE_CACHE.has(absoluteRoot)) {
151
+ QUERY_SEARCH_BUNDLE_CACHE.set(
152
+ absoluteRoot,
153
+ Promise.all([
154
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.files),
155
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.symbols),
156
+ ])
157
+ .then(([files, symbols]) => {
158
+ const safeFiles = ensureArtifact(files);
159
+ const safeSymbols = ensureArtifact(symbols);
160
+ const symbolMap = groupBy(safeSymbols.items ?? [], (item) => item.filePath);
161
+ return {
162
+ files: safeFiles,
163
+ searchDescriptorsByFile: buildFileSearchDescriptors(safeFiles.items ?? [], symbolMap),
164
+ };
165
+ })
166
+ .catch((error) => {
167
+ QUERY_SEARCH_BUNDLE_CACHE.delete(absoluteRoot);
168
+ throw error;
169
+ }),
170
+ );
171
+ }
172
+
173
+ return QUERY_SEARCH_BUNDLE_CACHE.get(absoluteRoot);
174
+ }
175
+
176
+ async function loadQuerySupportBundle(rootDir) {
177
+ const absoluteRoot = path.resolve(rootDir);
178
+
179
+ if (!QUERY_SUPPORT_BUNDLE_CACHE.has(absoluteRoot)) {
180
+ QUERY_SUPPORT_BUNDLE_CACHE.set(
181
+ absoluteRoot,
182
+ loadQuerySearchBundle(absoluteRoot)
183
+ .then(({ files }) => Promise.all([
184
+ Promise.resolve(files),
185
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.imports),
186
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.testsMap),
187
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.hotspots),
188
+ readArtifact(absoluteRoot, INDEX_ARTIFACTS.archetypes),
189
+ ]))
190
+ .then(([files, imports, testsMap, hotspots, archetypes]) => {
191
+ const safeFiles = ensureArtifact(files);
192
+ const safeImports = ensureArtifact(imports);
193
+ const safeTestsMap = ensureArtifact(testsMap);
194
+ const safeHotspots = ensureArtifact(hotspots);
195
+ const safeArchetypes = ensureArtifact(archetypes);
196
+ const indexedFileSet = new Set((safeFiles.items ?? []).map((item) => item.filePath));
197
+ const aliasContextPromise = importsNeedAliasContext(safeImports.items ?? [])
198
+ ? loadImportAliasContext({ rootDir: absoluteRoot })
199
+ : Promise.resolve(null);
200
+ return aliasContextPromise.then((importAliasContext) => {
201
+ const { resolvedImportsBySource, importersByTarget } = buildResolvedImportGraphs(
202
+ absoluteRoot,
203
+ safeImports.items ?? [],
204
+ indexedFileSet,
205
+ importAliasContext,
206
+ );
207
+
208
+ return {
209
+ hotspotScores: new Map((safeHotspots.items ?? []).map((item) => [item.filePath, item.count])),
210
+ testsMapBySource: new Map((safeTestsMap.items ?? []).map((item) => [item.sourceFile, item.tests ?? []])),
211
+ resolvedImportsBySource,
212
+ importersByTarget,
213
+ archetypeByFile: new Map((safeArchetypes.items ?? []).map((item) => [item.filePath, item.archetype])),
214
+ };
215
+ });
216
+ })
217
+ .catch((error) => {
218
+ QUERY_SUPPORT_BUNDLE_CACHE.delete(absoluteRoot);
219
+ throw error;
220
+ }),
221
+ );
222
+ }
223
+
224
+ return QUERY_SUPPORT_BUNDLE_CACHE.get(absoluteRoot);
225
+ }
226
+
227
+ function dedupe(values) {
228
+ return [...new Set(values)];
229
+ }
230
+
231
+ function scoreDirectFileMatch({ queryDescriptor, filePath, searchDescriptor }) {
232
+ let score = 0;
233
+ const reasons = [];
234
+
235
+ if (
236
+ queryDescriptor.compact.length >= 6
237
+ && searchDescriptor.path.compact.includes(queryDescriptor.compact)
238
+ ) {
239
+ score += 6;
240
+ reasons.push(`path_compact:${queryDescriptor.compact}`);
241
+ }
242
+
243
+ for (const token of queryDescriptor.tokens) {
244
+ if (searchDescriptor.path.tokens.has(token)) {
245
+ score += 3;
246
+ reasons.push(`path_token:${token}`);
247
+ } else if (searchDescriptor.path.rawLower.includes(token)) {
248
+ score += 1;
249
+ reasons.push(`path_contains:${token}`);
250
+ }
251
+ }
252
+
253
+ for (const symbolDescriptor of searchDescriptor.symbols) {
254
+ if (
255
+ queryDescriptor.compact.length >= 4
256
+ && symbolDescriptor.descriptor.compact === queryDescriptor.compact
257
+ ) {
258
+ score += 8;
259
+ reasons.push(`symbol_exact:${symbolDescriptor.name}`);
260
+ continue;
261
+ }
262
+
263
+ if (
264
+ queryDescriptor.compact.length >= 6
265
+ && symbolDescriptor.descriptor.compact.includes(queryDescriptor.compact)
266
+ ) {
267
+ score += 5;
268
+ reasons.push(`symbol_compact:${symbolDescriptor.name}`);
269
+ }
270
+
271
+ for (const token of queryDescriptor.tokens) {
272
+ if (symbolDescriptor.descriptor.tokens.has(token)) {
273
+ score += 3;
274
+ reasons.push(`symbol_token:${symbolDescriptor.name}:${token}`);
275
+ } else if (symbolDescriptor.descriptor.rawLower.includes(token)) {
276
+ score += 1;
277
+ reasons.push(`symbol_contains:${symbolDescriptor.name}`);
278
+ }
279
+ }
280
+ }
281
+
282
+ return {
283
+ score,
284
+ reasons: dedupe(reasons),
285
+ filePath,
286
+ };
287
+ }
288
+
289
+ function groupBy(items, keyFn) {
290
+ const map = new Map();
291
+ for (const item of items) {
292
+ const key = keyFn(item);
293
+ if (!map.has(key)) {
294
+ map.set(key, []);
295
+ }
296
+ map.get(key).push(item);
297
+ }
298
+ return map;
299
+ }
300
+
301
+ function buildFileSearchDescriptors(files, symbolMap) {
302
+ const descriptors = new Map();
303
+
304
+ for (const file of files) {
305
+ const filePath = file.filePath;
306
+ descriptors.set(
307
+ filePath,
308
+ createFileSearchDescriptor({
309
+ filePath,
310
+ symbols: symbolMap.get(filePath) ?? [],
311
+ }),
312
+ );
313
+ }
314
+
315
+ return descriptors;
316
+ }
317
+
318
+ function createFileSearchDescriptor({ filePath, symbols }) {
319
+ return {
320
+ path: buildTextSearchDescriptor(filePath),
321
+ symbols: symbols.map((symbol) => ({
322
+ name: symbol.name,
323
+ descriptor: buildTextSearchDescriptor(symbol.name),
324
+ })),
325
+ };
326
+ }
327
+
328
+ function buildTextSearchDescriptor(value) {
329
+ return buildSearchDescriptor(value);
330
+ }
331
+
332
+ function inferPreferredArchetypes(tokens) {
333
+ const preferred = new Set();
334
+
335
+ const addIfAny = (signals, archetypes) => {
336
+ if (!signals.some((signal) => tokens.has(signal))) {
337
+ return;
338
+ }
339
+ for (const archetype of archetypes) {
340
+ preferred.add(archetype);
341
+ }
342
+ };
343
+
344
+ addIfAny(['page', 'screen', 'view', 'route'], ['page', 'detail-page', 'form-page', 'list-page']);
345
+ addIfAny(['list'], ['list-page', 'grid']);
346
+ addIfAny(['detail'], ['detail-page', 'page']);
347
+ addIfAny(['form', 'edit', 'create', 'add'], ['form-page']);
348
+ addIfAny(['component', 'widget', 'card', 'button'], ['component']);
349
+ addIfAny(['modal', 'dialog', 'popup'], ['modal']);
350
+ addIfAny(['grid', 'table'], ['grid']);
351
+ addIfAny(['hook', 'composable', 'use'], ['hook', 'composable']);
352
+ addIfAny(['service', 'api', 'client', 'request', 'fetch'], ['api']);
353
+ addIfAny(['store', 'state'], ['store']);
354
+ addIfAny(['util', 'helper', 'format'], ['util']);
355
+ addIfAny(['test', 'spec'], ['test']);
356
+
357
+ return preferred;
358
+ }
359
+
360
+ function shouldIncludeLikelyTestFiles(queryDescriptor) {
361
+ return queryDescriptor.tokens.has('test')
362
+ || queryDescriptor.tokens.has('tests')
363
+ || queryDescriptor.tokens.has('spec')
364
+ || queryDescriptor.tokens.has('specs')
365
+ || queryDescriptor.rawLower.includes('.test')
366
+ || queryDescriptor.rawLower.includes('.spec');
367
+ }
368
+
369
+ function applyImportGraphBoosts({
370
+ directScores,
371
+ resolvedImportsBySource,
372
+ importersByTarget,
373
+ testsMapBySource,
374
+ }) {
375
+ const scores = cloneScoreMap(directScores);
376
+
377
+ for (const [sourceFilePath] of directScores) {
378
+ for (const targetFilePath of resolvedImportsBySource.get(sourceFilePath) ?? []) {
379
+ const target = ensureScoreEntry(scores, targetFilePath, testsMapBySource);
380
+ target.score += 1;
381
+ target.reasons = dedupe([...target.reasons, `imported_by_match:${sourceFilePath}`]);
382
+ }
383
+ }
384
+
385
+ for (const [matchedFilePath] of directScores) {
386
+ propagateImporterMatches({
387
+ startFilePath: matchedFilePath,
388
+ scores,
389
+ importersByTarget,
390
+ testsMapBySource,
391
+ });
392
+ }
393
+
394
+ return scores;
395
+ }
396
+
397
+ function applyHotspotBoosts({ scores, hotspotScores }) {
398
+ const boostedScores = cloneScoreMap(scores);
399
+
400
+ for (const [filePath, entry] of boostedScores) {
401
+ const hotspotCount = hotspotScores.get(filePath) ?? 0;
402
+ if (hotspotCount <= 0) {
403
+ continue;
404
+ }
405
+
406
+ entry.score += Math.min(hotspotCount * 2, 8);
407
+ entry.reasons = dedupe([...entry.reasons, `hotspot:${hotspotCount}`]);
408
+ }
409
+
410
+ return boostedScores;
411
+ }
412
+
413
+ function cloneScoreMap(scores) {
414
+ const clone = new Map();
415
+
416
+ for (const [filePath, entry] of scores) {
417
+ clone.set(filePath, {
418
+ filePath,
419
+ score: entry.score,
420
+ reasons: [...(entry.reasons ?? [])],
421
+ tests: [...(entry.tests ?? [])],
422
+ });
423
+ }
424
+
425
+ return clone;
426
+ }
427
+
428
+ function ensureScoreEntry(scores, filePath, testsMapBySource) {
429
+ if (!scores.has(filePath)) {
430
+ scores.set(filePath, {
431
+ filePath,
432
+ score: 0,
433
+ reasons: [],
434
+ tests: testsMapBySource.get(filePath) ?? [],
435
+ });
436
+ }
437
+
438
+ return scores.get(filePath);
439
+ }
440
+
441
+ function propagateImporterMatches({
442
+ startFilePath,
443
+ scores,
444
+ importersByTarget,
445
+ testsMapBySource,
446
+ }) {
447
+ const visited = new Set([startFilePath]);
448
+ const queue = [{ filePath: startFilePath, depth: 0 }];
449
+
450
+ while (queue.length > 0) {
451
+ const current = queue.shift();
452
+
453
+ if (current.depth >= MAX_IMPORTER_HOPS) {
454
+ continue;
455
+ }
456
+
457
+ for (const importerFilePath of importersByTarget.get(current.filePath) ?? []) {
458
+ if (visited.has(importerFilePath)) {
459
+ continue;
460
+ }
461
+ visited.add(importerFilePath);
462
+
463
+ if (isLikelyTestFilePath(importerFilePath)) {
464
+ continue;
465
+ }
466
+
467
+ const importer = ensureScoreEntry(scores, importerFilePath, testsMapBySource);
468
+ const scoreDelta = current.depth === 0 ? 2 : 1;
469
+ const reason = current.depth === 0
470
+ ? `imports_match:${startFilePath}`
471
+ : `imports_match_via:${current.filePath}->${startFilePath}`;
472
+
473
+ importer.score += scoreDelta;
474
+ importer.reasons = dedupe([...importer.reasons, reason]);
475
+ queue.push({
476
+ filePath: importerFilePath,
477
+ depth: current.depth + 1,
478
+ });
479
+ }
480
+ }
481
+ }
482
+
483
+ function buildResolvedImportGraphs(rootDir, imports, indexedFileSet, importAliasContext) {
484
+ const resolvedImportsBySource = new Map();
485
+ const importersByTarget = new Map();
486
+
487
+ for (const edge of imports) {
488
+ if (!edge?.from || !edge?.to) {
489
+ continue;
490
+ }
491
+
492
+ const target = resolveImportSpecifier({
493
+ rootDir,
494
+ fromFilePath: edge.from,
495
+ specifier: edge.to,
496
+ indexedFileSet,
497
+ aliasContext: importAliasContext,
498
+ });
499
+ if (!target) {
500
+ continue;
501
+ }
502
+
503
+ if (!resolvedImportsBySource.has(edge.from)) {
504
+ resolvedImportsBySource.set(edge.from, new Set());
505
+ }
506
+ resolvedImportsBySource.get(edge.from).add(target);
507
+
508
+ if (!importersByTarget.has(target)) {
509
+ importersByTarget.set(target, new Set());
510
+ }
511
+ importersByTarget.get(target).add(edge.from);
512
+ }
513
+
514
+ return {
515
+ resolvedImportsBySource,
516
+ importersByTarget,
517
+ };
518
+ }
519
+
520
+ function isLikelyTestFilePath(filePath) {
521
+ const lower = filePath.toLowerCase();
522
+ return (
523
+ lower.startsWith('__tests__/')
524
+ || lower.startsWith('test/')
525
+ || lower.startsWith('tests/')
526
+ || lower.startsWith('spec/')
527
+ || lower.startsWith('specs/')
528
+ || lower.includes('/__tests__/')
529
+ || lower.includes('/test/')
530
+ || lower.includes('/spec/')
531
+ || lower.includes('/specs/')
532
+ || lower.endsWith('.test.js')
533
+ || lower.endsWith('.test.ts')
534
+ || lower.endsWith('.test.tsx')
535
+ || lower.endsWith('.test.jsx')
536
+ || lower.endsWith('.test.vue')
537
+ || lower.endsWith('.test.mjs')
538
+ || lower.endsWith('.test.cjs')
539
+ || lower.endsWith('.spec.js')
540
+ || lower.endsWith('.spec.ts')
541
+ || lower.endsWith('.spec.tsx')
542
+ || lower.endsWith('.spec.jsx')
543
+ || lower.endsWith('.spec.vue')
544
+ || lower.endsWith('.spec.mjs')
545
+ || lower.endsWith('.spec.cjs')
546
+ );
547
+ }
548
+
549
+ // ── Index V2: Analog Query ──
550
+
551
+ export async function queryAnalog({ rootDir = process.cwd(), filePath, limit = 5 } = {}) {
552
+ if (!filePath || !filePath.trim()) {
553
+ return [];
554
+ }
555
+
556
+ const absoluteRoot = path.resolve(rootDir);
557
+ const normalizedFilePath = String(filePath).trim();
558
+ const analogCacheKey = JSON.stringify({
559
+ rootDir: absoluteRoot,
560
+ filePath: normalizedFilePath,
561
+ limit,
562
+ });
563
+ if (ANALOG_RESULT_CACHE.has(analogCacheKey)) {
564
+ return ANALOG_RESULT_CACHE.get(analogCacheKey);
565
+ }
566
+ const analogPromise = readArtifact(absoluteRoot, INDEX_ARTIFACTS.analogs)
567
+ .then((analogs) => {
568
+ const safeAnalogs = ensureArtifact(analogs);
569
+ const entry = (safeAnalogs.items ?? []).find((item) => item.filePath === normalizedFilePath);
570
+ if (!entry) {
571
+ return Object.freeze([]);
572
+ }
573
+ return freezeAnalogResults(entry.analogs?.slice(0, limit) ?? []);
574
+ })
575
+ .catch((error) => {
576
+ ANALOG_RESULT_CACHE.delete(analogCacheKey);
577
+ throw error;
578
+ });
579
+
580
+ ANALOG_RESULT_CACHE.set(analogCacheKey, analogPromise);
581
+ return analogPromise;
582
+ }
583
+
584
+ export function clearIndexArtifactCache(rootDir = null) {
585
+ if (!rootDir) {
586
+ ARTIFACT_CACHE.clear();
587
+ QUERY_SEARCH_BUNDLE_CACHE.clear();
588
+ QUERY_SUPPORT_BUNDLE_CACHE.clear();
589
+ QUERY_RESULT_CACHE.clear();
590
+ ANALOG_RESULT_CACHE.clear();
591
+ return;
592
+ }
593
+
594
+ const absoluteRoot = path.resolve(rootDir);
595
+ const indexDir = getIndexDir(absoluteRoot);
596
+
597
+ for (const artifactPath of ARTIFACT_CACHE.keys()) {
598
+ if (artifactPath.startsWith(indexDir)) {
599
+ ARTIFACT_CACHE.delete(artifactPath);
600
+ }
601
+ }
602
+
603
+ QUERY_SEARCH_BUNDLE_CACHE.delete(absoluteRoot);
604
+ QUERY_SUPPORT_BUNDLE_CACHE.delete(absoluteRoot);
605
+ for (const cacheKey of QUERY_RESULT_CACHE.keys()) {
606
+ if (cacheKey.includes(`"rootDir":"${escapeJsonString(absoluteRoot)}"`)) {
607
+ QUERY_RESULT_CACHE.delete(cacheKey);
608
+ }
609
+ }
610
+ for (const cacheKey of ANALOG_RESULT_CACHE.keys()) {
611
+ if (cacheKey.includes(`"rootDir":"${escapeJsonString(absoluteRoot)}"`)) {
612
+ ANALOG_RESULT_CACHE.delete(cacheKey);
613
+ }
614
+ }
615
+ }
616
+
617
+ function freezeQueryResults(results) {
618
+ return Object.freeze(
619
+ results.map((item) => Object.freeze({
620
+ ...item,
621
+ reasons: Object.freeze([...(item.reasons ?? [])]),
622
+ tests: Object.freeze([...(item.tests ?? [])]),
623
+ })),
624
+ );
625
+ }
626
+
627
+ function freezeAnalogResults(results) {
628
+ return Object.freeze(results.map((item) => Object.freeze({ ...item })));
629
+ }
630
+
631
+ function ensureArtifact(artifact) {
632
+ return artifact && typeof artifact === 'object' ? artifact : { items: [] };
633
+ }
634
+
635
+ function escapeJsonString(value) {
636
+ return String(value).replaceAll('\\', '\\\\').replaceAll('"', '\\"');
637
+ }