@mrclrchtr/supi-code-intelligence 1.16.0 → 2.0.0

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 (348) hide show
  1. package/README.md +373 -63
  2. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  9. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  10. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  11. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  12. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  13. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  14. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  15. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
  16. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
  17. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
  18. package/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
  19. package/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
  20. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
  21. package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
  22. package/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  23. package/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  24. package/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  25. package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  26. package/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  27. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  28. package/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  29. package/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  30. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  31. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  32. package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  33. package/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  34. package/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/README.md +44 -56
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.d.ts +21 -2
  70. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.js +1 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.d.ts +2 -1
  72. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +1 -1
  73. package/node_modules/@mrclrchtr/supi-lsp/package.json +4 -31
  74. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +27 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +5 -0
  76. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +246 -1
  77. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +4 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +3 -0
  79. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +4 -2
  80. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +102 -0
  81. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +59 -0
  82. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +4 -0
  83. package/node_modules/@mrclrchtr/supi-lsp/src/index.ts +11 -0
  84. package/node_modules/@mrclrchtr/supi-lsp/src/manager/capability-index.ts +1 -1
  85. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -1
  86. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +115 -26
  87. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +177 -134
  88. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +214 -0
  89. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +320 -0
  90. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +26 -5
  91. package/node_modules/@mrclrchtr/supi-lsp/src/session/service-registry.ts +81 -4
  92. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +2 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +18 -37
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  127. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/LICENSE +21 -0
  128. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +265 -0
  129. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +4661 -0
  130. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +7 -0
  131. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +4605 -0
  132. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +7 -0
  133. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  134. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +57 -0
  135. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +100 -0
  136. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +4063 -0
  137. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +7 -0
  138. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +1025 -0
  139. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +58 -0
  140. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1025 -0
  141. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +58 -0
  142. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +4007 -0
  143. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +7 -0
  144. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  145. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +55 -0
  146. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -12
  147. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +29 -0
  148. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +28 -0
  149. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -0
  150. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +14 -2
  151. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +157 -0
  152. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +8 -1
  153. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +86 -0
  154. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +35 -16
  155. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +1 -0
  156. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +10 -0
  157. package/package.json +14 -9
  158. package/src/{model.ts → analysis/architecture/discovery.ts} +15 -72
  159. package/src/analysis/architecture/model.ts +76 -0
  160. package/src/analysis/brief/directory.ts +324 -0
  161. package/src/analysis/brief/enrich.ts +157 -0
  162. package/src/analysis/brief/file.ts +84 -0
  163. package/src/analysis/brief/inventory.ts +177 -0
  164. package/src/analysis/brief/main.ts +176 -0
  165. package/src/analysis/brief/models.ts +75 -0
  166. package/src/{brief.ts → analysis/brief/public-brief.ts} +21 -26
  167. package/src/analysis/brief/summarize.ts +208 -0
  168. package/src/analysis/brief/types.ts +27 -0
  169. package/src/{use-case/generate-brief.ts → analysis/brief/use-case.ts} +67 -144
  170. package/src/analysis/coverage/coverage-warnings.ts +224 -0
  171. package/src/analysis/evidence.ts +91 -0
  172. package/src/{semantic-action-helpers.ts → analysis/helpers.ts} +4 -4
  173. package/src/analysis/provider.ts +186 -0
  174. package/src/analysis/read-next.ts +126 -0
  175. package/src/analysis/readiness.ts +73 -0
  176. package/src/{refactor → analysis/refactor}/safety.ts +1 -1
  177. package/src/{use-case/support/semantic-references.ts → analysis/references/semantic-refs.ts} +58 -26
  178. package/src/analysis/search/pattern.ts +345 -0
  179. package/src/analysis/search/ripgrep.ts +473 -0
  180. package/src/{git-context.ts → analysis/signals/git.ts} +20 -7
  181. package/src/{prioritization-signals.ts → analysis/signals/project.ts} +33 -19
  182. package/src/analysis/target/anchored.ts +349 -0
  183. package/src/analysis/target/bridge.ts +152 -0
  184. package/src/analysis/target/file-resolution.ts +125 -0
  185. package/src/{targeting/resolve-file.ts → analysis/target/file.ts} +40 -20
  186. package/src/{planner → analysis/target}/planner.ts +30 -20
  187. package/src/{targeting → analysis/target}/query.ts +17 -3
  188. package/src/analysis/target/resolve-common.ts +115 -0
  189. package/src/analysis/target/service.ts +229 -0
  190. package/src/analysis/target/symbol.ts +196 -0
  191. package/src/{targeting → analysis/target}/types.ts +17 -1
  192. package/src/analysis/tests/likely-tests.ts +174 -0
  193. package/src/analysis/tests/test-discovery.ts +540 -0
  194. package/src/analysis/tests/vitest.ts +87 -0
  195. package/src/api.ts +34 -41
  196. package/src/app/app.ts +125 -0
  197. package/src/app/manager.ts +65 -0
  198. package/src/extension.ts +132 -1
  199. package/src/index.ts +1 -57
  200. package/src/session/refactor-plans.ts +82 -0
  201. package/src/session/session.ts +300 -0
  202. package/src/session/target-store.ts +293 -0
  203. package/src/substrate/lsp/diagnostic-injection.ts +218 -0
  204. package/src/substrate/lsp/lifecycle.ts +66 -0
  205. package/src/substrate/lsp/overrides.ts +132 -0
  206. package/src/substrate/lsp/recovery.ts +55 -0
  207. package/src/substrate/lsp/settings.ts +286 -0
  208. package/src/substrate/lsp/state.ts +46 -0
  209. package/src/substrate/lsp/utils.ts +17 -0
  210. package/src/substrate/tree-sitter/lifecycle.ts +52 -0
  211. package/src/tool/find/execute.ts +118 -0
  212. package/src/{presentation/markdown/pattern.ts → tool/find/markdown.ts} +102 -53
  213. package/src/{use-case/generate-pattern.ts → tool/find/orchestrate.ts} +67 -33
  214. package/src/tool/find/semantic-search.ts +114 -0
  215. package/src/tool/find/tui.ts +39 -0
  216. package/src/tool/graph/callees.ts +87 -0
  217. package/src/tool/graph/calls-md.ts +54 -0
  218. package/src/tool/graph/collect-relation.ts +371 -0
  219. package/src/tool/graph/execute.ts +95 -0
  220. package/src/tool/graph/implementations-md.ts +79 -0
  221. package/src/tool/graph/implementations.ts +76 -0
  222. package/src/tool/graph/markdown-base.ts +243 -0
  223. package/src/tool/graph/orchestrate.ts +285 -0
  224. package/src/tool/graph/references-md.ts +34 -0
  225. package/src/tool/graph/references.ts +81 -0
  226. package/src/tool/graph/tui.ts +120 -0
  227. package/src/tool/graph/types.ts +97 -0
  228. package/src/tool/guidance.ts +96 -49
  229. package/src/tool/health/execute.ts +76 -0
  230. package/src/tool/health/markdown.ts +280 -0
  231. package/src/tool/health/orchestrate.ts +159 -0
  232. package/src/tool/health/sections/diagnostics.ts +182 -0
  233. package/src/tool/health/sections/recovery.ts +89 -0
  234. package/src/tool/health/sections/signals.ts +89 -0
  235. package/src/tool/health/tui.ts +137 -0
  236. package/src/tool/impact/analysis.ts +247 -0
  237. package/src/tool/impact/change-set-impact.ts +151 -0
  238. package/src/tool/impact/execute.ts +98 -0
  239. package/src/tool/impact/file-level-impact.ts +81 -0
  240. package/src/tool/impact/markdown.ts +283 -0
  241. package/src/tool/impact/orchestrate.ts +97 -0
  242. package/src/tool/impact/result.ts +21 -0
  243. package/src/tool/impact/single-impact.ts +89 -0
  244. package/src/tool/impact/tui.ts +39 -0
  245. package/src/tool/impact/types.ts +34 -0
  246. package/src/tool/infra/cross-field.ts +335 -0
  247. package/src/tool/infra/error-results.ts +199 -0
  248. package/src/tool/infra/pipeline.ts +311 -0
  249. package/src/tool/infra/progress.ts +21 -0
  250. package/src/tool/infra/readiness-message.ts +5 -0
  251. package/src/tool/infra/truncate.ts +49 -0
  252. package/src/tool/inspect/execute.ts +76 -0
  253. package/src/tool/inspect/markdown.ts +169 -0
  254. package/src/tool/inspect/orchestrate.ts +156 -0
  255. package/src/tool/inspect/tui.ts +36 -0
  256. package/src/tool/orientation/deps.ts +63 -0
  257. package/src/tool/orientation/execute.ts +50 -0
  258. package/src/tool/orientation/markdown.ts +35 -0
  259. package/src/tool/orientation/mode.ts +88 -0
  260. package/src/tool/orientation/orchestrate.ts +478 -0
  261. package/src/tool/orientation/precise-target.ts +257 -0
  262. package/src/tool/orientation/tui.ts +131 -0
  263. package/src/{refactor/apply-workspace-edit.ts → tool/refactor-apply/apply.ts} +39 -16
  264. package/src/tool/refactor-apply/execute.ts +20 -0
  265. package/src/tool/refactor-apply/markdown.ts +118 -0
  266. package/src/tool/refactor-apply/orchestrate.ts +89 -0
  267. package/src/tool/refactor-apply/tui.ts +51 -0
  268. package/src/tool/refactor-plan/execute.ts +73 -0
  269. package/src/tool/refactor-plan/markdown.ts +118 -0
  270. package/src/tool/refactor-plan/orchestrate.ts +363 -0
  271. package/src/tool/refactor-plan/tui.ts +42 -0
  272. package/src/tool/register.ts +123 -0
  273. package/src/tool/resolve/execute.ts +82 -0
  274. package/src/tool/resolve/markdown.ts +150 -0
  275. package/src/tool/resolve/orchestrate.ts +134 -0
  276. package/src/tool/resolve/tui.ts +40 -0
  277. package/src/tool/schemas.ts +337 -0
  278. package/src/tool/specs.ts +257 -0
  279. package/src/types/details.ts +188 -0
  280. package/src/types/execution.ts +60 -0
  281. package/src/types/index.ts +28 -0
  282. package/src/{intent/types.ts → types/tool-names.ts} +15 -14
  283. package/src/ui/footer.ts +52 -0
  284. package/src/ui/markdown/brief.ts +218 -0
  285. package/src/ui/markdown/gather.ts +177 -0
  286. package/src/{use-case/build-overview.ts → ui/markdown/overview-data.ts} +2 -2
  287. package/src/{presentation → ui}/markdown/overview.ts +2 -2
  288. package/src/ui/markdown/types.ts +80 -0
  289. package/{node_modules/@mrclrchtr/supi-lsp/src/ui/renderer.ts → src/ui/message-renderer.ts} +11 -10
  290. package/src/ui/status-command.ts +260 -0
  291. package/src/ui/status-overlay.ts +500 -0
  292. package/src/ui/tui/common.ts +220 -0
  293. package/src/ui/tui/index.ts +37 -0
  294. package/node_modules/@mrclrchtr/supi-lsp/src/extension.ts +0 -1
  295. package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +0 -373
  296. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/diagnostic-injection.ts +0 -182
  297. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/session-lifecycle.ts +0 -149
  298. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/status-command.ts +0 -38
  299. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/workspace-recovery.ts +0 -92
  300. package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +0 -37
  301. package/node_modules/@mrclrchtr/supi-lsp/src/session/lsp-state.ts +0 -93
  302. package/node_modules/@mrclrchtr/supi-lsp/src/session/settings-registration.ts +0 -296
  303. package/node_modules/@mrclrchtr/supi-lsp/src/session/tree-persist.ts +0 -75
  304. package/node_modules/@mrclrchtr/supi-lsp/src/tool/guidance.ts +0 -69
  305. package/node_modules/@mrclrchtr/supi-lsp/src/tool/names.ts +0 -27
  306. package/node_modules/@mrclrchtr/supi-lsp/src/tool/overrides.ts +0 -204
  307. package/node_modules/@mrclrchtr/supi-lsp/src/tool/register-tools.ts +0 -69
  308. package/node_modules/@mrclrchtr/supi-lsp/src/tool/service-actions.ts +0 -399
  309. package/node_modules/@mrclrchtr/supi-lsp/src/tool/tool-specs.ts +0 -248
  310. package/node_modules/@mrclrchtr/supi-lsp/src/ui/ui.ts +0 -360
  311. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-change.ts +0 -40
  312. package/node_modules/@mrclrchtr/supi-tree-sitter/src/extension.ts +0 -1
  313. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/formatting.ts +0 -104
  314. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/guidance.ts +0 -35
  315. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/handlers.ts +0 -196
  316. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/register-tools.ts +0 -107
  317. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/tool-specs.ts +0 -117
  318. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +0 -47
  319. package/src/brief-focused.ts +0 -563
  320. package/src/code-intelligence.ts +0 -70
  321. package/src/pattern-structured.ts +0 -194
  322. package/src/presentation/markdown/affected.ts +0 -170
  323. package/src/presentation/markdown/brief.ts +0 -174
  324. package/src/presentation/markdown/map.ts +0 -54
  325. package/src/presentation/markdown/refactor.ts +0 -27
  326. package/src/presentation/markdown/relations.ts +0 -121
  327. package/src/resolve-target.ts +0 -130
  328. package/src/search-helpers.ts +0 -303
  329. package/src/substrates/types.ts +0 -30
  330. package/src/target-resolution.ts +0 -122
  331. package/src/targeting/resolve-anchored.ts +0 -80
  332. package/src/targeting/resolve-symbol.ts +0 -110
  333. package/src/tool/execute-affected.ts +0 -71
  334. package/src/tool/execute-brief.ts +0 -59
  335. package/src/tool/execute-map.ts +0 -35
  336. package/src/tool/execute-pattern.ts +0 -29
  337. package/src/tool/execute-refactor.ts +0 -101
  338. package/src/tool/execute-relations.ts +0 -79
  339. package/src/tool/register-tools.ts +0 -32
  340. package/src/tool/tool-specs.ts +0 -190
  341. package/src/tool/validation.ts +0 -43
  342. package/src/types.ts +0 -169
  343. package/src/use-case/generate-affected.ts +0 -297
  344. package/src/use-case/generate-map.ts +0 -176
  345. package/src/use-case/generate-relations.ts +0 -438
  346. package/src/use-case/types.ts +0 -43
  347. package/src/workspace/request-context.ts +0 -139
  348. /package/src/{query-params.ts → tool/params.ts} +0 -0
@@ -1,121 +0,0 @@
1
- // Relations markdown renderer — consumes use-case data and produces markdown content.
2
-
3
- import { isInProjectPath, uriToFile } from "../../search-helpers.ts";
4
- import type { ReferenceCollection } from "../../use-case/support/semantic-references.ts";
5
- import { formatReferenceList } from "../../use-case/support/semantic-references.ts";
6
-
7
- // ── Callers ──────────────────────────────────────────────────────────
8
-
9
- export function renderCallersResult(
10
- symbolName: string,
11
- result: ReferenceCollection,
12
- cwd: string,
13
- maxResults: number,
14
- ): string {
15
- const lines: string[] = [];
16
- lines.push(`# Callers of \`${symbolName}\``);
17
- lines.push("");
18
- lines.push(
19
- `**${result.refs.length} reference${result.refs.length !== 1 ? "s" : ""}** (${result.confidence})`,
20
- );
21
- if (result.externalCount > 0) {
22
- lines.push(
23
- `_+${result.externalCount} external reference${result.externalCount !== 1 ? "s" : ""}_`,
24
- );
25
- }
26
- lines.push("");
27
-
28
- formatReferenceList(lines, result.refs, maxResults, cwd);
29
- return lines.join("\n");
30
- }
31
-
32
- // ── Implementations ──────────────────────────────────────────────────
33
-
34
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: implementation rendering with project/external splitting and formatting is clearer as one function
35
- export function renderImplementationsResult(
36
- locations: Array<{
37
- uri?: string;
38
- targetUri?: string;
39
- range?: { start: { line: number } };
40
- targetRange?: { start: { line: number } };
41
- targetSelectionRange?: { start: { line: number } };
42
- }>,
43
- cwd: string,
44
- maxResults: number,
45
- ): string {
46
- const projectLocs = locations.filter((loc) => {
47
- const uri = loc.uri ?? loc.targetUri ?? "";
48
- const filePath = uriToFile(uri);
49
- return filePath && isInProjectPath(filePath, cwd);
50
- });
51
- const externalLocs = locations.filter((loc) => {
52
- const uri = loc.uri ?? loc.targetUri ?? "";
53
- const filePath = uriToFile(uri);
54
- return !filePath || !isInProjectPath(filePath, cwd);
55
- });
56
-
57
- const lines: string[] = [];
58
- lines.push("# Implementations (semantic)");
59
- lines.push("");
60
- if (projectLocs.length > 0) {
61
- lines.push(
62
- `**${projectLocs.length} implementation${projectLocs.length !== 1 ? "s" : ""}** in the project`,
63
- );
64
- lines.push("");
65
- for (const loc of projectLocs.slice(0, maxResults)) {
66
- const uri = loc.uri ?? loc.targetUri ?? "";
67
- const filePath = uriToFile(uri);
68
- const range = loc.targetSelectionRange ?? loc.targetRange ?? loc.range;
69
- if (filePath && range) {
70
- lines.push(`- \`${filePath}:${(range as { start: { line: number } }).start.line + 1}\``);
71
- } else if (filePath) {
72
- lines.push(`- \`${filePath}\``);
73
- }
74
- }
75
- lines.push("");
76
- }
77
-
78
- if (externalLocs.length > 0) {
79
- lines.push(
80
- `_+${externalLocs.length} external location${externalLocs.length !== 1 ? "s" : ""} (outside this project)_`,
81
- );
82
- lines.push("");
83
- }
84
-
85
- lines.push(
86
- "_Semantic analysis. Use `code_pattern` only when you explicitly want text-search hints for likely implementations._",
87
- );
88
- lines.push("");
89
-
90
- return lines.join("\n");
91
- }
92
-
93
- // ── Callees ──────────────────────────────────────────────────────────
94
-
95
- export function renderCalleesResult(
96
- data: { enclosingScope: { name: string }; callees: Array<{ name: string; startLine: number }> },
97
- relPath: string,
98
- maxResults: number,
99
- ): string {
100
- const lines: string[] = [];
101
- lines.push(`# Callees of \`${data.enclosingScope.name}\` (structural)`);
102
- lines.push("");
103
- lines.push(
104
- `**${data.callees.length} outgoing call${data.callees.length > 1 ? "s" : ""}** from \`${data.enclosingScope.name}\` in \`${relPath}\``,
105
- );
106
- lines.push("");
107
-
108
- const shown = data.callees.slice(0, maxResults);
109
- for (const c of shown) {
110
- lines.push(`- \`${c.name}\` (L${c.startLine})`);
111
- }
112
- if (data.callees.length > maxResults) {
113
- lines.push(`- _+${data.callees.length - maxResults} more_`);
114
- }
115
- lines.push("");
116
- lines.push(
117
- "_Structural analysis — may include unresolved or qualified names. Use `lsp_hover` with `file`, `line`, and `character` for precise type information._",
118
- );
119
- lines.push("");
120
- return lines.join("\n");
121
- }
@@ -1,130 +0,0 @@
1
- /**
2
- * Action-facing target resolution — routes normalized queries and
3
- * maps typed resolver outcomes to user-facing strings and legacy types.
4
- *
5
- * This is the thin orchestration layer between tool/action params and
6
- * the typed targeting pipeline. Formatting of disambiguation/error
7
- * outcomes happens here, at the action boundary.
8
- */
9
-
10
- import type { CodeQueryParams as ActionParams } from "./query-params.ts";
11
- import {
12
- type ResolvedTarget,
13
- type ResolvedTargetGroup,
14
- resolveAnchoredTarget,
15
- resolveFileTargetGroup,
16
- resolveSymbolTarget,
17
- } from "./target-resolution.ts";
18
- import { normalizeQuery } from "./targeting/query.ts";
19
- import type { ResolverDeps, TargetOutcome } from "./targeting/types.ts";
20
-
21
- /**
22
- * Resolve a target from action params.
23
- *
24
- * Returns either a {@link ResolvedTarget}, a {@link ResolvedTargetGroup},
25
- * or a user-facing error/disambiguation string.
26
- */
27
- export async function resolveTarget(
28
- params: ActionParams,
29
- cwd: string,
30
- semantic?: import("./substrates/types.ts").SemanticSubstrate,
31
- ): Promise<ResolvedTarget | ResolvedTargetGroup | string> {
32
- const query = normalizeQuery(params);
33
-
34
- switch (query.kind) {
35
- case "anchored":
36
- return resolveAnchored(query.file, query.line, query.character, cwd);
37
-
38
- case "file":
39
- return resolveByFile(query.file, cwd);
40
-
41
- case "symbol": {
42
- if (!semantic) {
43
- return "**Error:** Symbol discovery requires active LSP. Use `file` + coordinates, or enable LSP and retry.";
44
- }
45
- const deps: ResolverDeps = { cwd, semantic };
46
- return resolveBySymbol(query.symbol, deps, {
47
- path: query.path,
48
- kind: query.symbolKind,
49
- exportedOnly: query.exportedOnly,
50
- });
51
- }
52
-
53
- case "invalid":
54
- return `**Error:** ${query.reason}`;
55
- }
56
- }
57
-
58
- function resolveAnchored(
59
- file: string,
60
- line: number,
61
- character: number,
62
- cwd: string,
63
- ): ResolvedTarget | string {
64
- const result = resolveAnchoredTarget(file, line, character, cwd);
65
- if (result.kind === "error") return result.message;
66
- if (result.kind === "resolved") return result.target;
67
- return "**Error:** Unexpected resolution outcome.";
68
- }
69
-
70
- async function resolveByFile(file: string, cwd: string): Promise<ResolvedTargetGroup | string> {
71
- const result = await resolveFileTargetGroup(file, cwd);
72
- if (result.kind === "error") return result.message;
73
- return result.group;
74
- }
75
-
76
- async function resolveBySymbol(
77
- symbol: string,
78
- deps: ResolverDeps,
79
- options?: { path?: string; kind?: string; exportedOnly?: boolean },
80
- ): Promise<ResolvedTarget | string> {
81
- const outcome: TargetOutcome = await resolveSymbolTarget(
82
- symbol,
83
- deps.cwd,
84
- // biome-ignore lint/style/noNonNullAssertion: semantic is always set for symbol queries
85
- deps.semantic!,
86
- options,
87
- );
88
-
89
- if (outcome.kind === "resolved") {
90
- return outcome.target as ResolvedTarget;
91
- }
92
-
93
- if (outcome.kind === "error") {
94
- return outcome.message;
95
- }
96
-
97
- return formatDisambiguation(symbol, outcome);
98
- }
99
-
100
- function formatDisambiguation(
101
- symbol: string,
102
- result: Extract<TargetOutcome, { kind: "disambiguation" }>,
103
- ): string {
104
- const lines: string[] = [];
105
- lines.push(`# Disambiguation needed for \`${symbol}\``);
106
- lines.push("");
107
- const omitNote = result.omittedCount > 0 ? ` (+${result.omittedCount} more)` : "";
108
- lines.push(
109
- `Found ${result.candidates.length} candidates${omitNote}. Rerun with anchored coordinates:`,
110
- );
111
- lines.push("");
112
-
113
- for (const c of result.candidates) {
114
- const kind = c.kind ? ` (${c.kind})` : "";
115
- const container = c.container ? ` in ${c.container}` : "";
116
- lines.push(
117
- `${c.rank}. **${c.name}**${kind}${container} — \`${c.file}\`:${c.line}:${c.character}`,
118
- );
119
- }
120
-
121
- lines.push("");
122
- if (result.candidates.length > 0) {
123
- const first = result.candidates[0];
124
- lines.push(
125
- `Example: rerun with \`file: "${first.file}"\`, \`line: ${first.line}\`, and \`character: ${first.character}\`.`,
126
- );
127
- }
128
-
129
- return lines.join("\n");
130
- }
@@ -1,303 +0,0 @@
1
- // Shared search helpers for code-intelligence search and routing helpers.
2
-
3
- import { execFileSync } from "node:child_process";
4
- import * as path from "node:path";
5
- import { resolveToolPath, uriToFile as uriToFileShared } from "@mrclrchtr/supi-core/path";
6
-
7
- const LOW_SIGNAL_DIRS = new Set([
8
- "node_modules",
9
- ".git",
10
- ".pnpm",
11
- "dist",
12
- "build",
13
- "out",
14
- ".next",
15
- ".nuxt",
16
- "coverage",
17
- ".turbo",
18
- ".cache",
19
- "__pycache__",
20
- ".tsbuildinfo",
21
- ]);
22
-
23
- /** Check if a file path contains an obviously low-signal directory segment. */
24
- export function isLowSignalPath(filePath: string): boolean {
25
- const segments = filePath.split(path.sep);
26
- return segments.some((s) => LOW_SIGNAL_DIRS.has(s));
27
- }
28
-
29
- /** Convert a file:// URI to a file path, matching the shared SuPi normalization. */
30
- export const uriToFile = uriToFileShared;
31
-
32
- /** Check whether a resolved file path is inside the current project (within cwd, not under node_modules or .pnpm). */
33
- export function isInProjectPath(filePath: string, cwd: string): boolean {
34
- const relativePath = path.relative(cwd, path.resolve(cwd, filePath));
35
- if (relativePath.startsWith(`..${path.sep}`) || relativePath === "..") return false;
36
- const normalized = relativePath.replaceAll("\\", "/");
37
- return !(
38
- normalized.includes("/node_modules/") ||
39
- normalized.startsWith("node_modules/") ||
40
- normalized.includes("/.pnpm/") ||
41
- normalized.startsWith(".pnpm/")
42
- );
43
- }
44
-
45
- /** Escape regex special characters. */
46
- export function escapeRegex(s: string): string {
47
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48
- }
49
-
50
- /** Normalize a file/path value: strip leading @, resolve relative to cwd. */
51
- export function normalizePath(input: string, cwd: string): string {
52
- return resolveToolPath(cwd, input);
53
- }
54
-
55
- export interface RgMatch {
56
- file: string;
57
- line: number;
58
- text: string;
59
- /** Context lines surrounding this match (from -C flag). */
60
- context?: Array<{ line: number; text: string }>;
61
- }
62
-
63
- /** Result of a ripgrep invocation for callers that need both matches and execution errors. */
64
- export interface RipgrepRunResult {
65
- /** Parsed ripgrep matches, if any. */
66
- matches: RgMatch[];
67
- /** Non-no-match ripgrep execution error text, such as invalid regex syntax. */
68
- error?: string;
69
- }
70
-
71
- /**
72
- * Run ripgrep with JSON output and parse matches, filtering low-signal paths.
73
- *
74
- * This helper preserves the historical behavior used by internal
75
- * actions: any ripgrep execution failure is treated like an empty match set.
76
- * Call `runRipgrepDetailed()` when a caller needs to surface regex parse errors
77
- * or other non-no-match failures to the agent.
78
- */
79
- export function runRipgrep(
80
- pattern: string,
81
- scopePath: string,
82
- cwd: string,
83
- opts?: {
84
- maxMatches?: number;
85
- contextLines?: number;
86
- literal?: boolean;
87
- filterLowSignal?: boolean;
88
- },
89
- ): RgMatch[] {
90
- return runRipgrepDetailed(pattern, scopePath, cwd, opts).matches;
91
- }
92
-
93
- /**
94
- * Run ripgrep and preserve non-no-match execution errors for callers that need
95
- * to distinguish invalid regex syntax from a genuine empty search result.
96
- */
97
- export function runRipgrepDetailed(
98
- pattern: string,
99
- scopePath: string,
100
- cwd: string,
101
- opts?: {
102
- maxMatches?: number;
103
- contextLines?: number;
104
- literal?: boolean;
105
- filterLowSignal?: boolean;
106
- },
107
- ): RipgrepRunResult {
108
- const filter = opts?.filterLowSignal ?? true;
109
-
110
- try {
111
- const result = execFileSync("rg", buildRipgrepArgs(pattern, scopePath, opts), {
112
- encoding: "utf-8",
113
- cwd,
114
- timeout: 10000,
115
- stdio: ["pipe", "pipe", "pipe"],
116
- });
117
-
118
- return { matches: parseRgJson(result, filter) };
119
- } catch (err: unknown) {
120
- return handleRipgrepError(err, filter);
121
- }
122
- }
123
-
124
- function buildRipgrepArgs(
125
- pattern: string,
126
- scopePath: string,
127
- opts?: { maxMatches?: number; contextLines?: number; literal?: boolean },
128
- ): string[] {
129
- const args = ["--json", "-m", String(opts?.maxMatches ?? 30)];
130
- if ((opts?.contextLines ?? 0) > 0) {
131
- args.push("-C", String(opts?.contextLines ?? 0));
132
- }
133
- if (opts?.literal) {
134
- args.push("-F");
135
- }
136
- args.push("-e", pattern, scopePath);
137
- return args;
138
- }
139
-
140
- function handleRipgrepError(err: unknown, filterLowSignal: boolean): RipgrepRunResult {
141
- // ENOENT means rg is not installed — surface a clear error instead of silent empty results
142
- if (isCodeError(err, "ENOENT")) {
143
- return {
144
- matches: [],
145
- error:
146
- "ripgrep (rg) is not available. Install it (e.g., `apt install ripgrep` or `brew install ripgrep`).",
147
- };
148
- }
149
-
150
- if (!isExecError(err)) {
151
- return { matches: [] };
152
- }
153
-
154
- const stdout = typeof err.stdout === "string" ? err.stdout : "";
155
- const stderr = typeof err.stderr === "string" ? err.stderr.trim() : "";
156
- const matches = stdout ? parseRgJson(stdout, filterLowSignal) : [];
157
-
158
- if (err.status === 1) {
159
- return { matches };
160
- }
161
-
162
- return {
163
- matches,
164
- ...(stderr ? { error: stderr } : {}),
165
- };
166
- }
167
-
168
- function isExecError(err: unknown): err is { status: number; stdout?: unknown; stderr?: unknown } {
169
- return typeof err === "object" && err !== null && "status" in err;
170
- }
171
-
172
- function isCodeError(err: unknown, code: string): boolean {
173
- return (
174
- typeof err === "object" &&
175
- err !== null &&
176
- "code" in err &&
177
- (err as { code: unknown }).code === code
178
- );
179
- }
180
-
181
- interface RawRgEvent {
182
- type: string;
183
- data?: {
184
- path?: { text: string };
185
- line_number?: number;
186
- lines?: { text: string };
187
- };
188
- }
189
-
190
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: JSON ripgrep output parsing with context line collection
191
- function parseRgJson(output: string, filterLowSignal: boolean): RgMatch[] {
192
- const matches: RgMatch[] = [];
193
- // Pending context lines that precede the next match
194
- let pendingContext: Array<{ line: number; text: string }> = [];
195
-
196
- for (const line of output.split("\n")) {
197
- if (!line.trim()) continue;
198
- let parsed: RawRgEvent;
199
- try {
200
- parsed = JSON.parse(line);
201
- } catch {
202
- continue;
203
- }
204
-
205
- if (parsed.type === "context" && parsed.data) {
206
- const lineNum = parsed.data.line_number;
207
- const text = (parsed.data.lines?.text ?? "").trim();
208
- if (lineNum) pendingContext.push({ line: lineNum, text });
209
- continue;
210
- }
211
-
212
- if (parsed.type === "match" && parsed.data) {
213
- const filePath = parsed.data.path?.text;
214
- const lineNum = parsed.data.line_number;
215
- const text = (parsed.data.lines?.text ?? "").trim();
216
- if (filePath && lineNum) {
217
- // Split pendingContext: lines before this match are "before" context,
218
- // lines from before this match line that trail the previous match stay with it.
219
- const beforeCtx = pendingContext.filter((c) => c.line < lineNum);
220
- const trailingCtx = pendingContext.filter((c) => c.line >= lineNum);
221
-
222
- // Attach trailing context from previous match to the last accepted match
223
- if (beforeCtx.length > 0 && matches.length > 0) {
224
- const prev = matches[matches.length - 1];
225
- const prevTrailing = beforeCtx.filter((c) => c.line > prev.line);
226
- if (prevTrailing.length > 0) {
227
- prev.context = [...(prev.context ?? []), ...prevTrailing];
228
- }
229
- }
230
-
231
- if (filterLowSignal && isLowSignalPath(filePath)) {
232
- pendingContext = [];
233
- continue;
234
- }
235
-
236
- const match: RgMatch = { file: filePath, line: lineNum, text };
237
- // Leading context: lines just before this match
238
- const leadingCtx =
239
- matches.length > 0
240
- ? beforeCtx.filter(
241
- (c) => c.line <= lineNum && c.line > (matches[matches.length - 1]?.line ?? 0),
242
- )
243
- : beforeCtx;
244
- if (leadingCtx.length > 0) {
245
- match.context = leadingCtx;
246
- }
247
- // Also include any pending context at/after this match's line (trailing from rg ordering)
248
- pendingContext = trailingCtx;
249
- matches.push(match);
250
- } else {
251
- pendingContext = [];
252
- }
253
- }
254
- }
255
-
256
- // Attach any trailing context lines to the last match
257
- if (pendingContext.length > 0 && matches.length > 0) {
258
- const last = matches[matches.length - 1];
259
- last.context = [...(last.context ?? []), ...pendingContext];
260
- }
261
-
262
- return matches;
263
- }
264
-
265
- /**
266
- * Minimal interface for a reference-like object with a URI and range start.
267
- * Used by {@link filterOutDeclaration} to avoid coupling to a specific LspRef type.
268
- */
269
- export interface HasLspPosition {
270
- uri: string;
271
- range: { start: { line: number; character: number } };
272
- }
273
-
274
- /**
275
- * Filter out the declaration/definition location from LSP references.
276
- * LSP's `textDocument/references` includes the declaration by default;
277
- * for callers/affected analysis, the declaration is not a call site or affected reference.
278
- *
279
- * Uses {@link uriToFile} for robust URI-to-path conversion.
280
- */
281
- export function filterOutDeclaration<T extends HasLspPosition>(
282
- refs: T[],
283
- targetFile: string,
284
- targetPos: { line: number; character: number },
285
- ): T[] {
286
- return refs.filter((ref) => {
287
- const filePath = uriToFile(ref.uri);
288
- if (filePath !== targetFile) return true;
289
- const start = ref.range.start;
290
- return start.line !== targetPos.line || start.character !== targetPos.character;
291
- });
292
- }
293
-
294
- /** Group matches by file. */
295
- export function groupByFile(matches: RgMatch[]): Map<string, RgMatch[]> {
296
- const byFile = new Map<string, RgMatch[]>();
297
- for (const m of matches) {
298
- const group = byFile.get(m.file) ?? [];
299
- group.push(m);
300
- byFile.set(m.file, group);
301
- }
302
- return byFile;
303
- }
@@ -1,30 +0,0 @@
1
- // Substrate interfaces for code-intelligence's semantic (LSP) and
2
- // structural (tree-sitter) adapters.
3
- //
4
- // These are type aliases for the canonical provider contracts
5
- // now hosted in @mrclrchtr/supi-code-runtime.
6
-
7
- import type { SemanticProvider, StructuralProvider } from "@mrclrchtr/supi-code-runtime/api";
8
-
9
- export type { CodeLocation, CodePosition } from "../types.ts";
10
-
11
- // ── Provider contracts (aliases for shared provider types) ───────────
12
-
13
- /** Canonical provider alias — same as SemanticProvider. */
14
- export type SemanticSubstrate = SemanticProvider;
15
-
16
- /** Canonical provider alias — same as StructuralProvider. */
17
- export type StructuralSubstrate = StructuralProvider;
18
-
19
- // ── Value types (re-exported from shared types) ───────────────────────
20
-
21
- export type { StructuralResult } from "@mrclrchtr/supi-code-runtime/api";
22
- export type {
23
- CalleesData,
24
- CodeResult,
25
- CodeSymbol,
26
- ExportData,
27
- ImportData,
28
- NodeAtData,
29
- OutlineData,
30
- } from "../types.ts";