@mrclrchtr/supi-code-intelligence 1.16.1 → 2.0.1

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/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/package.json +4 -31
  70. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +27 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +5 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +246 -1
  73. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +4 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +3 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +4 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +102 -0
  77. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +59 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +4 -0
  79. package/node_modules/@mrclrchtr/supi-lsp/src/index.ts +11 -0
  80. package/node_modules/@mrclrchtr/supi-lsp/src/manager/capability-index.ts +1 -1
  81. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -1
  82. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +115 -26
  83. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +177 -134
  84. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +214 -0
  85. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +320 -0
  86. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +26 -5
  87. package/node_modules/@mrclrchtr/supi-lsp/src/session/service-registry.ts +81 -4
  88. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +2 -0
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +18 -37
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  93. 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
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  98. 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
  99. 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
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +6 -1
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/LICENSE +21 -0
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +265 -0
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +4661 -0
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +7 -0
  127. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +4605 -0
  128. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +7 -0
  129. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  130. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +57 -0
  131. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +100 -0
  132. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +4063 -0
  133. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +7 -0
  134. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +1025 -0
  135. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +58 -0
  136. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1025 -0
  137. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +58 -0
  138. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +4007 -0
  139. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +7 -0
  140. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  141. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +55 -0
  142. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -12
  143. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +29 -0
  144. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +28 -0
  145. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -0
  146. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +14 -2
  147. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +157 -0
  148. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +8 -1
  149. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +86 -0
  150. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +35 -16
  151. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +1 -0
  152. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +10 -0
  153. package/package.json +14 -9
  154. package/src/{model.ts → analysis/architecture/discovery.ts} +15 -72
  155. package/src/analysis/architecture/model.ts +76 -0
  156. package/src/analysis/brief/directory.ts +324 -0
  157. package/src/analysis/brief/enrich.ts +157 -0
  158. package/src/analysis/brief/file.ts +84 -0
  159. package/src/analysis/brief/inventory.ts +177 -0
  160. package/src/analysis/brief/main.ts +176 -0
  161. package/src/analysis/brief/models.ts +75 -0
  162. package/src/{brief.ts → analysis/brief/public-brief.ts} +21 -26
  163. package/src/analysis/brief/summarize.ts +208 -0
  164. package/src/analysis/brief/types.ts +27 -0
  165. package/src/{use-case/generate-brief.ts → analysis/brief/use-case.ts} +67 -144
  166. package/src/analysis/coverage/coverage-warnings.ts +224 -0
  167. package/src/analysis/evidence.ts +91 -0
  168. package/src/{semantic-action-helpers.ts → analysis/helpers.ts} +4 -4
  169. package/src/analysis/provider.ts +186 -0
  170. package/src/analysis/read-next.ts +126 -0
  171. package/src/analysis/readiness.ts +73 -0
  172. package/src/{refactor → analysis/refactor}/safety.ts +1 -1
  173. package/src/{use-case/support/semantic-references.ts → analysis/references/semantic-refs.ts} +58 -26
  174. package/src/analysis/search/pattern.ts +345 -0
  175. package/src/analysis/search/ripgrep.ts +473 -0
  176. package/src/{git-context.ts → analysis/signals/git.ts} +20 -7
  177. package/src/{prioritization-signals.ts → analysis/signals/project.ts} +33 -19
  178. package/src/analysis/target/anchored.ts +349 -0
  179. package/src/analysis/target/bridge.ts +152 -0
  180. package/src/analysis/target/file-resolution.ts +125 -0
  181. package/src/{targeting/resolve-file.ts → analysis/target/file.ts} +40 -20
  182. package/src/{planner → analysis/target}/planner.ts +30 -20
  183. package/src/{targeting → analysis/target}/query.ts +17 -3
  184. package/src/analysis/target/resolve-common.ts +115 -0
  185. package/src/analysis/target/service.ts +229 -0
  186. package/src/analysis/target/symbol.ts +196 -0
  187. package/src/{targeting → analysis/target}/types.ts +17 -1
  188. package/src/analysis/tests/likely-tests.ts +174 -0
  189. package/src/analysis/tests/test-discovery.ts +540 -0
  190. package/src/analysis/tests/vitest.ts +87 -0
  191. package/src/api.ts +34 -41
  192. package/src/app/app.ts +125 -0
  193. package/src/app/manager.ts +65 -0
  194. package/src/extension.ts +132 -1
  195. package/src/index.ts +1 -57
  196. package/src/session/refactor-plans.ts +82 -0
  197. package/src/session/session.ts +300 -0
  198. package/src/session/target-store.ts +293 -0
  199. package/src/substrate/lsp/diagnostic-injection.ts +218 -0
  200. package/src/substrate/lsp/lifecycle.ts +66 -0
  201. package/src/substrate/lsp/overrides.ts +132 -0
  202. package/src/substrate/lsp/recovery.ts +55 -0
  203. package/src/substrate/lsp/settings.ts +286 -0
  204. package/src/substrate/lsp/state.ts +46 -0
  205. package/src/substrate/lsp/utils.ts +17 -0
  206. package/src/substrate/tree-sitter/lifecycle.ts +52 -0
  207. package/src/tool/find/execute.ts +118 -0
  208. package/src/{presentation/markdown/pattern.ts → tool/find/markdown.ts} +102 -53
  209. package/src/{use-case/generate-pattern.ts → tool/find/orchestrate.ts} +67 -33
  210. package/src/tool/find/semantic-search.ts +114 -0
  211. package/src/tool/find/tui.ts +39 -0
  212. package/src/tool/graph/callees.ts +87 -0
  213. package/src/tool/graph/calls-md.ts +54 -0
  214. package/src/tool/graph/collect-relation.ts +371 -0
  215. package/src/tool/graph/execute.ts +95 -0
  216. package/src/tool/graph/implementations-md.ts +79 -0
  217. package/src/tool/graph/implementations.ts +76 -0
  218. package/src/tool/graph/markdown-base.ts +243 -0
  219. package/src/tool/graph/orchestrate.ts +285 -0
  220. package/src/tool/graph/references-md.ts +34 -0
  221. package/src/tool/graph/references.ts +81 -0
  222. package/src/tool/graph/tui.ts +120 -0
  223. package/src/tool/graph/types.ts +97 -0
  224. package/src/tool/guidance.ts +96 -49
  225. package/src/tool/health/execute.ts +76 -0
  226. package/src/tool/health/markdown.ts +280 -0
  227. package/src/tool/health/orchestrate.ts +159 -0
  228. package/src/tool/health/sections/diagnostics.ts +182 -0
  229. package/src/tool/health/sections/recovery.ts +89 -0
  230. package/src/tool/health/sections/signals.ts +89 -0
  231. package/src/tool/health/tui.ts +137 -0
  232. package/src/tool/impact/analysis.ts +247 -0
  233. package/src/tool/impact/change-set-impact.ts +151 -0
  234. package/src/tool/impact/execute.ts +98 -0
  235. package/src/tool/impact/file-level-impact.ts +81 -0
  236. package/src/tool/impact/markdown.ts +283 -0
  237. package/src/tool/impact/orchestrate.ts +97 -0
  238. package/src/tool/impact/result.ts +21 -0
  239. package/src/tool/impact/single-impact.ts +89 -0
  240. package/src/tool/impact/tui.ts +39 -0
  241. package/src/tool/impact/types.ts +34 -0
  242. package/src/tool/infra/cross-field.ts +335 -0
  243. package/src/tool/infra/error-results.ts +199 -0
  244. package/src/tool/infra/pipeline.ts +311 -0
  245. package/src/tool/infra/progress.ts +21 -0
  246. package/src/tool/infra/readiness-message.ts +5 -0
  247. package/src/tool/infra/truncate.ts +49 -0
  248. package/src/tool/inspect/execute.ts +76 -0
  249. package/src/tool/inspect/markdown.ts +169 -0
  250. package/src/tool/inspect/orchestrate.ts +156 -0
  251. package/src/tool/inspect/tui.ts +36 -0
  252. package/src/tool/orientation/deps.ts +63 -0
  253. package/src/tool/orientation/execute.ts +50 -0
  254. package/src/tool/orientation/markdown.ts +35 -0
  255. package/src/tool/orientation/mode.ts +88 -0
  256. package/src/tool/orientation/orchestrate.ts +478 -0
  257. package/src/tool/orientation/precise-target.ts +257 -0
  258. package/src/tool/orientation/tui.ts +131 -0
  259. package/src/{refactor/apply-workspace-edit.ts → tool/refactor-apply/apply.ts} +39 -16
  260. package/src/tool/refactor-apply/execute.ts +20 -0
  261. package/src/tool/refactor-apply/markdown.ts +118 -0
  262. package/src/tool/refactor-apply/orchestrate.ts +89 -0
  263. package/src/tool/refactor-apply/tui.ts +51 -0
  264. package/src/tool/refactor-plan/execute.ts +73 -0
  265. package/src/tool/refactor-plan/markdown.ts +118 -0
  266. package/src/tool/refactor-plan/orchestrate.ts +363 -0
  267. package/src/tool/refactor-plan/tui.ts +42 -0
  268. package/src/tool/register.ts +123 -0
  269. package/src/tool/resolve/execute.ts +82 -0
  270. package/src/tool/resolve/markdown.ts +150 -0
  271. package/src/tool/resolve/orchestrate.ts +134 -0
  272. package/src/tool/resolve/tui.ts +40 -0
  273. package/src/tool/schemas.ts +337 -0
  274. package/src/tool/specs.ts +257 -0
  275. package/src/types/details.ts +188 -0
  276. package/src/types/execution.ts +60 -0
  277. package/src/types/index.ts +28 -0
  278. package/src/{intent/types.ts → types/tool-names.ts} +15 -14
  279. package/src/ui/footer.ts +52 -0
  280. package/src/ui/markdown/brief.ts +218 -0
  281. package/src/ui/markdown/gather.ts +177 -0
  282. package/src/{use-case/build-overview.ts → ui/markdown/overview-data.ts} +2 -2
  283. package/src/{presentation → ui}/markdown/overview.ts +2 -2
  284. package/src/ui/markdown/types.ts +80 -0
  285. package/{node_modules/@mrclrchtr/supi-lsp/src/ui/renderer.ts → src/ui/message-renderer.ts} +11 -10
  286. package/src/ui/status-command.ts +260 -0
  287. package/src/ui/status-overlay.ts +500 -0
  288. package/src/ui/tui/common.ts +220 -0
  289. package/src/ui/tui/index.ts +37 -0
  290. package/node_modules/@mrclrchtr/supi-lsp/src/extension.ts +0 -1
  291. package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +0 -373
  292. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/diagnostic-injection.ts +0 -182
  293. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/session-lifecycle.ts +0 -149
  294. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/status-command.ts +0 -38
  295. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/workspace-recovery.ts +0 -92
  296. package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +0 -37
  297. package/node_modules/@mrclrchtr/supi-lsp/src/session/lsp-state.ts +0 -93
  298. package/node_modules/@mrclrchtr/supi-lsp/src/session/settings-registration.ts +0 -296
  299. package/node_modules/@mrclrchtr/supi-lsp/src/session/tree-persist.ts +0 -75
  300. package/node_modules/@mrclrchtr/supi-lsp/src/tool/guidance.ts +0 -69
  301. package/node_modules/@mrclrchtr/supi-lsp/src/tool/names.ts +0 -27
  302. package/node_modules/@mrclrchtr/supi-lsp/src/tool/overrides.ts +0 -204
  303. package/node_modules/@mrclrchtr/supi-lsp/src/tool/register-tools.ts +0 -69
  304. package/node_modules/@mrclrchtr/supi-lsp/src/tool/service-actions.ts +0 -399
  305. package/node_modules/@mrclrchtr/supi-lsp/src/tool/tool-specs.ts +0 -248
  306. package/node_modules/@mrclrchtr/supi-lsp/src/ui/ui.ts +0 -360
  307. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-change.ts +0 -40
  308. package/node_modules/@mrclrchtr/supi-tree-sitter/src/extension.ts +0 -1
  309. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/formatting.ts +0 -104
  310. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/guidance.ts +0 -35
  311. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/handlers.ts +0 -196
  312. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/register-tools.ts +0 -107
  313. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/tool-specs.ts +0 -117
  314. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +0 -47
  315. package/src/brief-focused.ts +0 -563
  316. package/src/code-intelligence.ts +0 -70
  317. package/src/pattern-structured.ts +0 -194
  318. package/src/presentation/markdown/affected.ts +0 -170
  319. package/src/presentation/markdown/brief.ts +0 -174
  320. package/src/presentation/markdown/map.ts +0 -54
  321. package/src/presentation/markdown/refactor.ts +0 -27
  322. package/src/presentation/markdown/relations.ts +0 -121
  323. package/src/resolve-target.ts +0 -130
  324. package/src/search-helpers.ts +0 -303
  325. package/src/substrates/types.ts +0 -30
  326. package/src/target-resolution.ts +0 -122
  327. package/src/targeting/resolve-anchored.ts +0 -80
  328. package/src/targeting/resolve-symbol.ts +0 -110
  329. package/src/tool/execute-affected.ts +0 -71
  330. package/src/tool/execute-brief.ts +0 -59
  331. package/src/tool/execute-map.ts +0 -35
  332. package/src/tool/execute-pattern.ts +0 -29
  333. package/src/tool/execute-refactor.ts +0 -101
  334. package/src/tool/execute-relations.ts +0 -79
  335. package/src/tool/register-tools.ts +0 -32
  336. package/src/tool/tool-specs.ts +0 -190
  337. package/src/tool/validation.ts +0 -43
  338. package/src/types.ts +0 -169
  339. package/src/use-case/generate-affected.ts +0 -297
  340. package/src/use-case/generate-map.ts +0 -176
  341. package/src/use-case/generate-relations.ts +0 -438
  342. package/src/use-case/types.ts +0 -43
  343. package/src/workspace/request-context.ts +0 -139
  344. /package/src/{query-params.ts → tool/params.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Semantic caller collection — finds references for a target.
3
+ *
4
+ * Returns typed caller data with explicit evidence metadata
5
+ * ("semantic-references" since we use LSP references as caller evidence).
6
+ */
7
+
8
+ import type { CallerEvidence, CallerReference, RelationsServiceDeps } from "./types.ts";
9
+
10
+ export interface CallersResult {
11
+ kind: "callers";
12
+ targetName: string;
13
+ references: CallerReference[];
14
+ externalCount: number;
15
+ evidence: CallerEvidence;
16
+ confidence: "semantic" | "unavailable";
17
+ }
18
+
19
+ /**
20
+ * Collect callers (references) for a target file/position using semantic provider.
21
+ */
22
+ // biome-ignore lint/complexity/useMaxParams: service function with clear positional parameters matching provider contract
23
+ export async function collectCallers(
24
+ targetFile: string,
25
+ targetPosition: { line: number; character: number },
26
+ targetName: string | null,
27
+ deps: RelationsServiceDeps,
28
+ maxResults?: number,
29
+ ): Promise<CallersResult> {
30
+ if (!deps.provider?.references) {
31
+ return {
32
+ kind: "callers",
33
+ targetName: targetName ?? "symbol",
34
+ references: [],
35
+ externalCount: 0,
36
+ evidence: "semantic-references",
37
+ confidence: "unavailable",
38
+ };
39
+ }
40
+
41
+ const refs = await deps.provider.references(targetFile, targetPosition);
42
+ if (!refs) {
43
+ return {
44
+ kind: "callers",
45
+ targetName: targetName ?? "symbol",
46
+ references: [],
47
+ externalCount: 0,
48
+ evidence: "semantic-references",
49
+ confidence: "semantic",
50
+ };
51
+ }
52
+
53
+ const inProject: CallerReference[] = [];
54
+ let externalCount = 0;
55
+
56
+ for (const ref of refs) {
57
+ const uri = ref.uri ?? "";
58
+ const filePath = uri.startsWith("file://") ? uri.slice(7) : uri;
59
+ if (filePath.startsWith(deps.cwd)) {
60
+ inProject.push({
61
+ file: filePath,
62
+ line: ref.range.start.line + 1,
63
+ character: ref.range.start.character + 1,
64
+ name: targetName,
65
+ });
66
+ } else {
67
+ externalCount++;
68
+ }
69
+ }
70
+
71
+ void maxResults;
72
+
73
+ return {
74
+ kind: "callers",
75
+ targetName: targetName ?? "symbol",
76
+ references: inProject,
77
+ externalCount,
78
+ evidence: "semantic-references",
79
+ confidence: "semantic",
80
+ };
81
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * TUI renderer for code_graph — renderCall + renderResult.
3
+ *
4
+ * Dual-surface rendering: chrome built from details, markdown body
5
+ * available as a collapsible detail view.
6
+ */
7
+
8
+ import type { Theme } from "@earendil-works/pi-coding-agent";
9
+ import { Container, Spacer, Text } from "@earendil-works/pi-tui";
10
+ import {
11
+ buildSimpleCompact,
12
+ buildSimpleHeader,
13
+ type EvidenceEntry,
14
+ type ResultOptios,
15
+ renderEvidenceLines,
16
+ renderMarkdownDetail,
17
+ renderPartial,
18
+ type ToolResult,
19
+ } from "../../ui/tui/common.ts";
20
+ import type { CodeGraphToolParams, GraphRelation } from "./execute.ts";
21
+
22
+ /** ── renderCall ────────────────────────────────────────────────── */
23
+
24
+ export function renderGraphCall(args: unknown, theme: Theme, _context: unknown): Text {
25
+ const params = (args ?? {}) as CodeGraphToolParams;
26
+ const relations = params.relations ?? ["references"];
27
+ const relationLabel = formatRelations(relations);
28
+
29
+ let content = theme.fg("toolTitle", "code_graph");
30
+
31
+ if (relationLabel) {
32
+ content += ` ${theme.fg("accent", relationLabel)}`;
33
+ }
34
+
35
+ const target = formatTarget(params);
36
+ if (target) {
37
+ content += ` ${theme.fg("muted", target)}`;
38
+ }
39
+
40
+ return new Text(content, 0, 0);
41
+ }
42
+
43
+ /** ── renderResult ──────────────────────────────────────────────── */
44
+
45
+ export function renderGraphResult(
46
+ result: ToolResult,
47
+ options: ResultOptios,
48
+ theme: Theme,
49
+ _context: unknown,
50
+ ): Container | Text {
51
+ if (options.isPartial) {
52
+ return renderPartial("Collecting relations…", theme);
53
+ }
54
+
55
+ const container = new Container();
56
+ const details =
57
+ result.details?.type === "search" ? (result.details.data as Record<string, unknown>) : null;
58
+
59
+ if (result.isError) {
60
+ container.addChild(new Text(theme.fg("error", "code_graph failed"), 0, 0));
61
+ return container;
62
+ }
63
+
64
+ const omittedCount = (details?.omittedCount as number) ?? 0;
65
+
66
+ if (!options.expanded) {
67
+ container.addChild(buildSimpleCompact(details ?? undefined, theme, { omittedCount }));
68
+ return container;
69
+ }
70
+
71
+ // Expanded view
72
+ const header = buildSimpleHeader(details ?? undefined, theme, { omittedCount });
73
+ if (header) container.addChild(header);
74
+
75
+ const evidenceLists = details?.evidenceLists as EvidenceEntry[] | undefined;
76
+ if (evidenceLists && evidenceLists.length > 0) {
77
+ container.addChild(new Spacer(1));
78
+ renderEvidenceLines(container, evidenceLists, theme);
79
+ }
80
+
81
+ if (details?.tests) {
82
+ container.addChild(new Spacer(1));
83
+ container.addChild(buildTestsSection(details.tests as Record<string, unknown>, theme));
84
+ }
85
+
86
+ renderMarkdownDetail(container, result, theme);
87
+
88
+ return container;
89
+ }
90
+
91
+ /** ── Helpers ───────────────────────────────────────────────────── */
92
+
93
+ function formatRelations(relations: GraphRelation[]): string {
94
+ if (relations.length === 0) return "";
95
+ if (relations.length === 1) return `→ ${relations[0]}`;
96
+ if (relations.length <= 3) return `→ ${relations.join(", ")}`;
97
+ return `→ ${relations.slice(0, 2).join(", ")} +${relations.length - 2}`;
98
+ }
99
+
100
+ function formatTarget(params: CodeGraphToolParams): string {
101
+ if (params.symbol) return `of ${params.symbol}`;
102
+ if (params.file) {
103
+ const file = params.file.split("/").pop() ?? params.file;
104
+ if (params.line) return `at ${file}:${params.line}`;
105
+ return `of ${file}`;
106
+ }
107
+ return "";
108
+ }
109
+
110
+ function buildTestsSection(tests: Record<string, unknown>, theme: Theme): Text {
111
+ const fileCount = (tests.files as Array<unknown> | undefined)?.length ?? 0;
112
+ if (fileCount === 0) {
113
+ return new Text(theme.fg("dim", "No companion test files found"), 0, 0);
114
+ }
115
+ return new Text(
116
+ theme.fg("dim", `${fileCount} companion test file${fileCount !== 1 ? "s" : ""}`),
117
+ 0,
118
+ 0,
119
+ );
120
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Shared types for the relations analysis modules.
3
+ *
4
+ * These are the canonical entry-point types — consumers import them directly
5
+ * instead of going through thin service wrappers.
6
+ */
7
+
8
+ /** Describes how caller evidence was collected. */
9
+ export type CallerEvidence = "semantic-references" | "verified-call-sites";
10
+
11
+ /** One caller reference / usages result. */
12
+ export interface CallerReference {
13
+ file: string;
14
+ line: number;
15
+ character: number;
16
+ name: string | null;
17
+ }
18
+
19
+ /** Consumer-facing alias for reference/usages entries. */
20
+ export type ReferenceEntry = CallerReference;
21
+
22
+ /** Enclosing scope used for direct structural callee lookup. */
23
+ export interface CalleeScope {
24
+ name: string;
25
+ file: string;
26
+ startLine: number;
27
+ endLine: number;
28
+ }
29
+
30
+ /** One direct structural callee entry from an enclosing-scope lookup. */
31
+ export interface CalleeEntry {
32
+ name: string;
33
+ file: string;
34
+ line: number;
35
+ character: number;
36
+ }
37
+
38
+ /** Consumer-facing display entry for structural calls (no character). */
39
+ export type CallEntry = Omit<CalleeEntry, "character">;
40
+
41
+ /** One implementation entry from a semantic implementation lookup. */
42
+ export interface ImplementationEntry {
43
+ file: string;
44
+ line: number;
45
+ character: number;
46
+ name: string | null;
47
+ }
48
+
49
+ /** Shared provider deps for all relation kinds. */
50
+ export interface RelationsServiceDeps {
51
+ cwd: string;
52
+ provider: {
53
+ references?: (
54
+ file: string,
55
+ pos: { line: number; character: number },
56
+ ) => Promise<Array<{
57
+ uri: string;
58
+ range: {
59
+ start: { line: number; character: number };
60
+ end: { line: number; character: number };
61
+ };
62
+ }> | null>;
63
+ implementation?: (
64
+ file: string,
65
+ pos: { line: number; character: number },
66
+ ) => Promise<Array<{
67
+ uri?: string;
68
+ targetUri?: string;
69
+ range?: { start: { line: number }; end?: { line: number } };
70
+ targetRange?: { start: { line: number }; end?: { line: number } };
71
+ }> | null>;
72
+ calleesAt?: (
73
+ file: string,
74
+ line: number,
75
+ character: number,
76
+ depth?: "direct" | "deep",
77
+ ) => Promise<{
78
+ kind: string;
79
+ data?: {
80
+ enclosingScope?: {
81
+ name?: string;
82
+ startLine?: number;
83
+ endLine?: number;
84
+ };
85
+ callees: Array<{
86
+ name: string;
87
+ file?: string;
88
+ location?: string;
89
+ startLine?: number;
90
+ startCharacter?: number;
91
+ }>;
92
+ depth?: "direct" | "deep";
93
+ };
94
+ message?: string;
95
+ }>;
96
+ } | null;
97
+ }
@@ -1,10 +1,9 @@
1
1
  // Prompt guidance and tool descriptions for the focused code-intelligence tool surface.
2
2
  //
3
- // Each code_* tool owns its base prompt guidelines (describing its own surface).
4
- // Additional cross-family orchestration guidelines are appended to help the
5
- // model choose between code_*, lsp_*, and tree_sitter_* tools.
3
+ // Each code_* tool owns its complete promptGuidelines here.
4
+ // Runtime registration data (name, parameters, run) lives in specs.ts.
6
5
 
7
- import { CODE_INTELLIGENCE_TOOL_SPECS, type CodeIntelligenceToolName } from "./tool-specs.ts";
6
+ import type { CodeIntelligenceToolName } from "../types/index.ts";
8
7
 
9
8
  export interface CodeIntelligenceToolPromptSurface {
10
9
  description: string;
@@ -17,49 +16,97 @@ export type CodeIntelligenceToolPromptSurfaceMap = Record<
17
16
  CodeIntelligenceToolPromptSurface
18
17
  >;
19
18
 
20
- // ── Intent-first orchestration guidelines ─────────────────────────────
21
- //
22
- // These steer the model toward choosing tools by user intent rather than
23
- // by implementation family. Substrate tools (lsp_*, tree_sitter_*) are
24
- // described as expert follow-up surfaces, not the primary choice.
25
-
26
- const INTENT_GUIDELINES: Record<CodeIntelligenceToolName, string[]> = {
27
- code_brief: [
28
- "Use code_brief for prioritized orientation on a project, package, file, or symbol.",
29
- "The planner selects the best provider (semantic or structural) automatically.",
30
- "After code_brief, use lsp_hover/lsp_definition/lsp_references for deeper semantic detail or tree_sitter_* for quick structural context.",
31
- ],
32
- code_map: ["Use code_brief instead when you need prioritized guidance."],
33
- code_relations: [
34
- "The planner routes callers/implementations to semantic (LSP) analysis and callees to structural (tree-sitter) analysis.",
35
- "Follow caller results with lsp_references/lsp_definition for additional context; use tree_sitter_callees for structural outgoing calls as a debug surface.",
36
- ],
37
- code_affected: [
38
- "Uses semantic evidence for blast-radius assessment. Does not fall back to heuristic text search.",
39
- "Use lsp_references when you only need a plain reference list without impact analysis.",
40
- ],
41
- code_pattern: [
42
- "The only code_* tool that uses heuristic/text search behavior. For structured or semantic precision, use tree_sitter_query or lsp_hover/lsp_definition instead.",
43
- ],
44
- code_refactor: [
45
- "Uses semantic provider for precise rename/code-action operations with safety checks.",
46
- "Does not fall back to heuristic text replacement if the provider cannot produce precise edits, the tool reports unavailable.",
47
- ],
19
+ export const CODE_INTELLIGENCE_TOOL_PROMPT_SURFACES: CodeIntelligenceToolPromptSurfaceMap = {
20
+ code_resolve: {
21
+ description:
22
+ "Resolve human or code references into precise file/range/symbol targets and stable target handles. Use when a symbol, file, or code reference is ambiguous and needs precise resolution. Returns targetId and spanId handles that can be passed to code_graph, code_impact, and code_refactor_plan. Supports anchored (file + line + character), file-only, and query/symbol inputs. Anchored coordinates resolve a real symbol target from provider-backed evidence: an exact identifier coordinate resolves to a named target; a declaration-header coordinate (e.g. an `export` keyword) snaps to the symbol name anchor only when unambiguous. Whitespace/comment/non-symbol coordinates fail honestly and recommend code_inspect. Does not fall back to text search for symbol resolution; ambiguous results return ranked candidates with target IDs for every shown item. Output is truncated to 2000 lines / 50KB.",
23
+ promptSnippet: "code_resolve resolve references into precise targets and target handles",
24
+ promptGuidelines: [
25
+ "Use code_resolve when a symbol, file, or code reference is ambiguous and needs precise resolution.",
26
+ "Prefer code_resolve as the entry point before code_orientation, code_graph, code_impact, or code_refactor_plan — its targetId replaces fragile file/line/character coordinates.",
27
+ "When code_resolve returns ambiguous results with ranked candidates, pick one and use file + line + character for follow-up resolution.",
28
+ ],
29
+ },
30
+ code_inspect: {
31
+ description:
32
+ "Inspect one precise point in a file and return factual syntax, symbol, hover, definition, diagnostics, and code-action information. Use when you need to understand exactly what is at a position without choosing between provider-specific substrate tools. When some providers are unavailable, returns best-effort sections with explicit unavailable notes instead of heuristic guesses. Code action titles are advisory only — there is no tool to execute them yet. Output is truncated to 2000 lines / 50KB.",
33
+ promptSnippet: "code_inspect factual point inspection",
34
+ promptGuidelines: [
35
+ "Use code_inspect for factual point inspection at one precise file position.",
36
+ "Provide `file`, `line`, and `character` — code_inspect is intentionally point-based.",
37
+ "Prefer code_inspect over code_orientation for point-level facts when no symbol target can be resolved.",
38
+ ],
39
+ },
40
+ code_orientation: {
41
+ description:
42
+ "Primary code-orientation tool for understanding a project, discovered module, directory, file, or symbol before choosing surgical follow-up tools. Use `focus` for a workspace-relative path or discovered module name; omit `focus` for project orientation. Use `focus` + `line` + `character` for symbol orientation, or pass `targetId` from `code_resolve`; `targetId` takes precedence over focus/coordinates and stale target IDs do not fall back. Symbol orientation returns definitions, JSDoc/TSDoc docs, local diagnostics near the target, and Read Next guidance; relation evidence belongs in code_graph, impact evidence in code_impact, and health/status in code_health. Not a point-inspection tool — use code_inspect for exact position facts. `maxResults` caps each rendered list and defaults to 10. Output is truncated to 2000 lines / 50KB.",
43
+ promptSnippet: "code_orientation — project/module/file/symbol orientation",
44
+ promptGuidelines: [
45
+ "Use `code_orientation({ focus })` for first-pass project/package/directory/file orientation before `bash`/`read`.",
46
+ "Use code_resolve first for bare symbol names, then pass the resulting targetId to code_orientation.",
47
+ "Use code_graph/code_impact/code_health for relations, impact, or full health instead of asking code_orientation for those sections.",
48
+ ],
49
+ },
50
+ code_graph: {
51
+ description:
52
+ 'Unified relation-graph tool — replaces code_references, code_calls, and code_implementations. Resolves a target once and dispatches to the appropriate analysis service per requested relation. Defaults to ["references"] when `relations` is omitted. Each relation is best-effort: unavailable substrates skip with a note rather than failing the whole call. Each relation annotates its evidence source. The tests relation displays discovery provenance (semantic+conventions or conventions-only) separately from any extracted test labels. `callees` is structural/direct-scope evidence: it reports call expressions by source shape, not symbol identity, and excludes calls inside nested function/method/callback scopes — use `references` on a resolved target for identity-aware incoming callers. Pass `calleeDepth: "deep"` to include callees from nested scopes. `imports` and `exports` use file-level tree-sitter analysis; `tests` discovers companion test files and labels. Targeted graph results include Read Next guidance for source ranges worth inspecting via `read`. `scope` (not `path`) narrows by workspace-relative directory/package. Use code_resolve first to get a targetId, then pass it to code_graph. Output is truncated to 2000 lines / 50KB.',
53
+ promptSnippet: "code_graph — semantic and structural relation graph",
54
+ promptGuidelines: [
55
+ "Use code_graph to find references, direct structural calls, and implementations for a target.",
56
+ 'Default `relations` is ["references"]; use `relations: ["callees"]` or `["implements"]` for those, or `relations: ["all"]` to expand to every relation family in one call.',
57
+ "After code_graph, follow up with code_orientation on individual results for type or definition context.",
58
+ 'Pass `calleeDepth: "deep"` to include callees from nested function/method/callback scopes (default `"direct"` excludes them).',
59
+ 'Suggested relations by target kind: For functions/methods: `["references", "callees", "tests"]` — For interfaces/types/classes/enums: `["references", "implements"]` — For files/modules: `["imports", "exports"]` — For tests: `["tests"]`.',
60
+ ],
61
+ },
62
+ code_impact: {
63
+ description:
64
+ "Estimate blast radius and downstream impact for a target or user-supplied change set before making edits. `changeSetFiles` are explicit workspace-relative files to analyze as in scope for a proposed/current change; they are not inferred from git and carry no line-level diff evidence. Uses semantic evidence for target-based impact and merges semantic references for symbols defined in change-set files when available. Includes Read Next guidance for source ranges worth inspecting via `read` before editing. Does not fall back to heuristic text search. Use a resolved target for precise semantic reference-based impact. Output is truncated to 2000 lines / 50KB.",
65
+ promptSnippet: "code_impact — blast radius and impact",
66
+ promptGuidelines: [
67
+ "Use code_impact before edits to estimate blast radius and follow-up checks.",
68
+ "Use code_graph instead of code_impact when you only need a plain reference list without impact analysis.",
69
+ ],
70
+ },
71
+ code_find: {
72
+ description:
73
+ 'Unified ranked code search with strict mode dispatch: default/`mode: "text"` is literal ripgrep, `mode: "regex"` is ripgrep regex, `mode: "semantic"` is LSP workspace-symbol search, and `mode: "ast"` is tree-sitter structured search. `mode: "ast"` requires `kind` and currently supports `definition`, `import`, `export`, `call`, `type`, `interface`, `class`, `method`, `enum`, and `test`. `mode: "text"`, `mode: "regex"`, and `mode: "semantic"` do not accept `kind`. `code_find` with `mode: "semantic"` does not silently fall back to text search, and unsupported mode/kind combinations fail. AST `call` mode matches call-site identifiers by name, not by symbol identity; use `code_graph` references for identity-aware callers of a resolved target. Output is truncated to 2000 lines / 50KB.',
74
+ promptSnippet: "code_find — unified ranked code search",
75
+ promptGuidelines: [
76
+ "Use code_find as the sole code search tool for literal text, regex, semantic workspace-symbol, or AST structured search.",
77
+ 'code_find with `mode: "ast"` requires `kind` and supports `definition`, `import`, `export`, `call`, `type`, `interface`, `class`, `method`, `enum`, and `test`.',
78
+ 'code_find with `mode: "text"`, `mode: "regex"`, or `mode: "semantic"` does not accept `kind`.',
79
+ 'code_find with `mode: "semantic"` does not fall back to text search and fails when semantic capability is unavailable.',
80
+ 'AST `call` mode matches call-site identifiers by name only; use `code_graph` with `relations: ["references"]` on a resolved target for symbol-identity-aware callers.',
81
+ ],
82
+ },
83
+ code_refactor_plan: {
84
+ description:
85
+ 'Pure planner: previews a precise semantic refactor plan without mutating files and returns a planId for later use with code_refactor_apply. Supports rename_symbol plus extract_function/extract_variable when the active LSP can return precise edits. Legacy `operation: "rename"` is accepted as a compatibility alias. This tool never mutates files. Output is truncated to 2000 lines / 50KB.',
86
+ promptSnippet: "code_refactor_plan — preview a precise workflow refactor plan",
87
+ promptGuidelines: [
88
+ 'Use `operation: "rename_symbol"` with code_refactor_plan for symbol renames. Legacy `operation: "rename"` is accepted as a compatibility alias.',
89
+ 'Use `operation: "extract_function"` or `"extract_variable"` with a 1-based `range` and `newName` when the LSP advertises precise extract code actions.',
90
+ "code_refactor_plan is a pure planner — it returns a planId. Use code_refactor_apply with that planId to execute.",
91
+ ],
92
+ },
93
+ code_refactor_apply: {
94
+ description:
95
+ "Sole mutator in the refactor workflow: applies a previously stored plan by planId. Revalidates the plan and checks file fingerprints, mutating files only when the plan is still fresh. Output is truncated to 2000 lines / 50KB.",
96
+ promptSnippet: "code_refactor_apply — apply a stored refactor plan",
97
+ promptGuidelines: [
98
+ "Use code_refactor_apply to execute a plan generated by code_refactor_plan.",
99
+ "Use code_refactor_plan first to obtain a planId, then code_refactor_apply to execute it.",
100
+ ],
101
+ },
102
+ code_health: {
103
+ description:
104
+ "Summarize diagnostics, language server status, dirty workspace signals, coverage, and unused-code findings. Pass refresh: true to recover stale diagnostics before checking. Use scope to narrow to a specific file or package. Use include to request specific sections: diagnostics, servers, dirty, coverage, unused. Defaults to summary level (counts); use level: detailed for per-file listings. Output is truncated to 2000 lines / 50KB.",
105
+ promptSnippet:
106
+ "code_health — diagnostics, server status, coverage, unused-code, and workspace health",
107
+ promptGuidelines: [
108
+ "Use code_health to check for diagnostics, language server status, dirty workspace state, coverage, or unused-code signals.",
109
+ "Pass `refresh: true` to code_health to recover stale diagnostics before checking.",
110
+ ],
111
+ },
48
112
  };
49
-
50
- // ── Surface builder ────────────────────────────────────────────────────
51
-
52
- export function buildCodeIntelligenceToolPromptSurfaces(): CodeIntelligenceToolPromptSurfaceMap {
53
- return Object.fromEntries(
54
- CODE_INTELLIGENCE_TOOL_SPECS.map((spec) => [
55
- spec.name,
56
- {
57
- description: spec.description,
58
- promptSnippet: spec.promptSnippet,
59
- promptGuidelines: [...spec.basePromptGuidelines, ...INTENT_GUIDELINES[spec.name]],
60
- } satisfies CodeIntelligenceToolPromptSurface,
61
- ]),
62
- ) as CodeIntelligenceToolPromptSurfaceMap;
63
- }
64
-
65
- export const CODE_INTELLIGENCE_TOOL_PROMPT_SURFACES = buildCodeIntelligenceToolPromptSurfaces();
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Tool executor for code_health.
3
+ *
4
+ * Thin executor: validates scope, extracts provider state from the
5
+ * session, and delegates to the health use-case which handles data
6
+ * collection, rendering, and details construction.
7
+ */
8
+
9
+ import { resolveScope } from "../../analysis/search/ripgrep.ts";
10
+ import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
11
+ import { unavailableHealthDetails } from "../infra/error-results.ts";
12
+ import { emitToolProgress } from "../infra/progress.ts";
13
+ import {
14
+ executeHealth,
15
+ getLastHealthRefresh,
16
+ type HealthInput,
17
+ trackHealthRefresh,
18
+ } from "./orchestrate.ts";
19
+
20
+ export interface CodeHealthToolParams {
21
+ scope?: string;
22
+ refresh?: boolean;
23
+ include?: string[];
24
+ level?: "summary" | "detailed";
25
+ coveragePath?: string;
26
+ unusedPath?: string;
27
+ }
28
+
29
+ export async function executeHealthTool(
30
+ params: CodeHealthToolParams,
31
+ ctx: CodeIntelToolExecCtx,
32
+ ): Promise<CodeIntelResult> {
33
+ const cwd = ctx.cwd;
34
+ emitToolProgress(ctx.onUpdate, "code_health: gathering workspace health...");
35
+
36
+ const scopeResolution = resolveScope(params.scope, cwd);
37
+ if (scopeResolution.kind === "error") {
38
+ return {
39
+ content: `**Error:** ${scopeResolution.reason}`,
40
+ details: unavailableHealthDetails("scope not found"),
41
+ };
42
+ }
43
+ const scopeFilter = scopeResolution.path === cwd ? null : scopeResolution.path;
44
+
45
+ if (params.refresh) {
46
+ trackHealthRefresh(cwd);
47
+ }
48
+
49
+ const providerState = ctx.session.getProviders();
50
+ const workspaceState = ctx.session.getWorkspaceState();
51
+ const lspState =
52
+ providerState.kind === "ready"
53
+ ? providerState.lspService
54
+ : { kind: "unavailable" as const, reason: "No provider" };
55
+
56
+ const input: HealthInput = {
57
+ scope: params.scope,
58
+ refresh: params.refresh,
59
+ include: params.include,
60
+ level: params.level,
61
+ coveragePath: params.coveragePath,
62
+ unusedPath: params.unusedPath,
63
+ };
64
+
65
+ return executeHealth(input, {
66
+ cwd,
67
+ lspState,
68
+ providerAvailable: providerState.kind === "ready",
69
+ semanticStateKind: workspaceState.semantic.state.kind,
70
+ structuralState: workspaceState.structural.state,
71
+ lspController: ctx.session.lspController,
72
+ onUpdate: ctx.onUpdate,
73
+ scopeFilter,
74
+ lastRefresh: getLastHealthRefresh(cwd),
75
+ });
76
+ }