@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
@@ -0,0 +1,157 @@
1
+ // Enrichment helpers for the brief pipeline.
2
+ //
3
+ // Provides three functions:
4
+ // - enrichFileContext(provider, file, maxResults) — outline, imports, exports
5
+ // - enrichDiagnosticContext(cwd, file, maxResults) — LSP diagnostics
6
+ // - gatherBriefEnrichment(provider, cwd, file, maxResults) — orchestrates both
7
+
8
+ import type { SessionLspServiceState } from "@mrclrchtr/supi-lsp/api";
9
+ import { diagnosticMessageString } from "../../substrate/lsp/utils.ts";
10
+ import type { CodeProvider } from "../provider.ts";
11
+ import type { BriefDiagnostic, BriefEnrichment } from "./models.ts";
12
+
13
+ // ── Default caps ─────────────────────────────────────────────────────
14
+
15
+ const DEFAULT_OUTLINE_CAP = 15;
16
+ const DEFAULT_IMPORTS_CAP = 10;
17
+ const DEFAULT_EXPORTS_CAP = 10;
18
+ const DEFAULT_DIAGNOSTICS_CAP = 5;
19
+
20
+ function cap(count: number | undefined, def: number): number {
21
+ return count != null && count > 0 ? count : def;
22
+ }
23
+
24
+ // ── Structural enrichment ───────────────────────────────────────────
25
+
26
+ /**
27
+ * Enrich file context with outline, imports, and exports from a provider.
28
+ * Each section is capped at maxResults with per-section defaults.
29
+ */
30
+ export async function enrichFileContext(
31
+ provider: CodeProvider,
32
+ file: string,
33
+ maxResults?: number,
34
+ ): Promise<Pick<BriefEnrichment, "outline" | "imports" | "exports">> {
35
+ const outlineCap = cap(maxResults, DEFAULT_OUTLINE_CAP);
36
+ const importsCap = cap(maxResults, DEFAULT_IMPORTS_CAP);
37
+ const exportsCap = cap(maxResults, DEFAULT_EXPORTS_CAP);
38
+
39
+ const outline = await tryOutline(provider, file, outlineCap);
40
+ const imports = await tryImports(provider, file, importsCap);
41
+ const exports = await tryExports(provider, file, exportsCap);
42
+
43
+ return { outline, imports, exports };
44
+ }
45
+
46
+ async function tryOutline(
47
+ provider: CodeProvider,
48
+ file: string,
49
+ capN: number,
50
+ ): Promise<BriefEnrichment["outline"]> {
51
+ try {
52
+ const result = await provider.outline(file);
53
+ if (result.kind !== "success") return [];
54
+ return result.data.slice(0, capN).map((item) => ({
55
+ name: item.name,
56
+ kind: item.kind,
57
+ startLine: item.startLine,
58
+ endLine: item.endLine,
59
+ }));
60
+ } catch {
61
+ return [];
62
+ }
63
+ }
64
+
65
+ async function tryImports(
66
+ provider: CodeProvider,
67
+ file: string,
68
+ capN: number,
69
+ ): Promise<BriefEnrichment["imports"]> {
70
+ try {
71
+ const result = await provider.imports(file);
72
+ if (result.kind !== "success") return [];
73
+ return result.data.slice(0, capN).map((item) => ({
74
+ moduleSpecifier: item.moduleSpecifier,
75
+ }));
76
+ } catch {
77
+ return [];
78
+ }
79
+ }
80
+
81
+ async function tryExports(
82
+ provider: CodeProvider,
83
+ file: string,
84
+ capN: number,
85
+ ): Promise<BriefEnrichment["exports"]> {
86
+ try {
87
+ const result = await provider.exports(file);
88
+ if (result.kind !== "success") return [];
89
+ return result.data.slice(0, capN).map((item) => ({
90
+ name: item.name,
91
+ kind: item.kind,
92
+ }));
93
+ } catch {
94
+ return [];
95
+ }
96
+ }
97
+
98
+ // ── Diagnostic enrichment ───────────────────────────────────────────
99
+
100
+ /**
101
+ * Get LSP diagnostics for a file (errors + warnings).
102
+ * Returns capped diagnostic entries.
103
+ */
104
+ export async function enrichDiagnosticContext(
105
+ file: string | undefined,
106
+ maxResults: number | undefined,
107
+ lspService: SessionLspServiceState,
108
+ ): Promise<Pick<BriefEnrichment, "diagnostics">> {
109
+ if (!file) return { diagnostics: [] };
110
+
111
+ const capN = cap(maxResults, DEFAULT_DIAGNOSTICS_CAP);
112
+
113
+ try {
114
+ if (lspService.kind !== "ready") return { diagnostics: [] };
115
+
116
+ const diags = await lspService.service.fileDiagnostics(file, 2);
117
+ if (!diags || diags.length === 0) return { diagnostics: [] };
118
+
119
+ // Map to our DTO shape (1-based line for display)
120
+ const mapped: BriefDiagnostic[] = diags.map((d) => ({
121
+ line: d.range.start.line + 1,
122
+ severity: d.severity ?? 1,
123
+ message: diagnosticMessageString(d),
124
+ }));
125
+
126
+ return { diagnostics: mapped.slice(0, capN) };
127
+ } catch {
128
+ return { diagnostics: [] };
129
+ }
130
+ }
131
+
132
+ // ── Combined enrichment ─────────────────────────────────────────────
133
+
134
+ /**
135
+ * Orchestrate both structural and diagnostic enrichment for a file.
136
+ */
137
+ export async function gatherBriefEnrichment(
138
+ provider: CodeProvider | null,
139
+ file: string,
140
+ maxResults: number | undefined,
141
+ lspService: SessionLspServiceState,
142
+ ): Promise<BriefEnrichment> {
143
+ // Structural context (outline, imports, exports) needs a provider
144
+ const structural = provider
145
+ ? await enrichFileContext(provider, file, maxResults)
146
+ : { outline: [], imports: [], exports: [] };
147
+
148
+ // Diagnostics can work independently of provider (reaches LSP directly)
149
+ const diagnostic = await enrichDiagnosticContext(file, maxResults, lspService);
150
+
151
+ return {
152
+ outline: structural.outline,
153
+ imports: structural.imports,
154
+ exports: structural.exports,
155
+ diagnostics: diagnostic.diagnostics,
156
+ };
157
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * File-level brief generation with provider enrichment.
3
+ *
4
+ * Generates a brief for a single source file, enriching with outline, imports,
5
+ * exports, diagnostics, and entrypoint-detection metadata.
6
+ *
7
+ * Extracted from brief-focused.ts.
8
+ */
9
+
10
+ import * as fs from "node:fs";
11
+ import * as path from "node:path";
12
+ import { renderFileBrief } from "../../ui/markdown/brief.ts";
13
+ import type { ArchitectureModel } from "../architecture/model.ts";
14
+ import { findModuleForPath } from "../architecture/model.ts";
15
+ import { gatherBriefEnrichment } from "./enrich.ts";
16
+ import type { BriefOpts } from "./models.ts";
17
+
18
+ /** Generate a file-level brief with structural enrichment and diagnostics. */
19
+ export async function generateFileBrief(
20
+ model: ArchitectureModel,
21
+ resolvedPath: string,
22
+ opts?: BriefOpts,
23
+ ): Promise<{
24
+ content: string;
25
+ publicSurfaces: string[];
26
+ nextQueries: string[];
27
+ }> {
28
+ const mod = findModuleForPath(model, resolvedPath);
29
+ const publicSurfaces: string[] = [];
30
+ const nextQueries: string[] = [];
31
+
32
+ const fileName = path.basename(resolvedPath);
33
+ const relPath = path.relative(model.root, resolvedPath);
34
+
35
+ let lineCount = 0;
36
+ try {
37
+ const fileContent = fs.readFileSync(resolvedPath, "utf-8");
38
+ lineCount = fileContent.split("\n").length;
39
+ } catch {
40
+ // Leave 0
41
+ }
42
+
43
+ const isEntrypoint =
44
+ mod?.entrypoints.some((ep) => path.resolve(mod.root, ep) === resolvedPath) ?? false;
45
+
46
+ const lspService =
47
+ opts?.lspService ??
48
+ ({
49
+ kind: "unavailable" as const,
50
+ reason: "No LSP service",
51
+ } as import("@mrclrchtr/supi-lsp/api").SessionLspServiceState);
52
+ const enrichment = await gatherBriefEnrichment(
53
+ opts?.provider ?? null,
54
+ relPath,
55
+ opts?.maxResults,
56
+ lspService,
57
+ );
58
+
59
+ const renderedContent = renderFileBrief({
60
+ relPath: relPath || fileName,
61
+ lineCount,
62
+ isEntrypoint,
63
+ moduleName: mod ? mod.name.replace(/^@[^/]+\//, "") : null,
64
+ moduleRelativePath: mod ? mod.relativePath : null,
65
+ enrichment,
66
+ maxResults: opts?.maxResults,
67
+ });
68
+
69
+ if (isEntrypoint) {
70
+ const shortName = mod?.name.replace(/^@[^/]+\//, "") ?? "";
71
+ publicSurfaces.push(`${shortName} entrypoint`);
72
+ }
73
+
74
+ nextQueries.push(
75
+ `\`code_graph\`, \`file: "${relPath}"\`, and a line/character for reference sites`,
76
+ );
77
+ if (mod) {
78
+ nextQueries.push(
79
+ `\`code_orientation\` with \`focus: "${mod.relativePath}"\` for the containing module overview`,
80
+ );
81
+ }
82
+
83
+ return { content: renderedContent, publicSurfaces, nextQueries };
84
+ }
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Directory inventory collection — flat file counts by extension and landmark detection.
3
+ *
4
+ * Extracted from brief-focused.ts to keep the focus-generation modules
5
+ * cohesive and avoid a single 800+ line file.
6
+ */
7
+
8
+ import * as fs from "node:fs";
9
+ import * as path from "node:path";
10
+
11
+ // ── Types ─────────────────────────────────────────────────────────────
12
+
13
+ /** Flat inventory of a directory tree. */
14
+ export interface DirectoryInventory {
15
+ totalFiles: number;
16
+ byExtension: Map<string, number>;
17
+ landmarkFiles: string[];
18
+ }
19
+
20
+ // ── Public API ────────────────────────────────────────────────────────
21
+
22
+ /** Walk a directory tree collecting extension breakdown and landmark files. */
23
+ export function collectDirectoryInventory(dir: string): DirectoryInventory {
24
+ const byExtension = new Map<string, number>();
25
+ const landmarkFiles: string[] = [];
26
+ const state = { totalFiles: 0, byExtension, landmarkFiles };
27
+
28
+ function walk(currentPath: string) {
29
+ let entries: fs.Dirent[];
30
+ try {
31
+ entries = fs.readdirSync(currentPath, { withFileTypes: true });
32
+ } catch {
33
+ return;
34
+ }
35
+ for (const entry of entries) {
36
+ processInventoryEntry(entry, currentPath, walk, state);
37
+ }
38
+ }
39
+
40
+ walk(dir);
41
+ landmarkFiles.sort((a, b) => a.localeCompare(b));
42
+ return { totalFiles: state.totalFiles, byExtension, landmarkFiles };
43
+ }
44
+
45
+ /** Append inventory (extension breakdown + landmarks) to a lines array. */
46
+ export function addInventoryToLines(lines: string[], inventory: DirectoryInventory): void {
47
+ if (inventory.totalFiles === 0) return;
48
+
49
+ lines.push(`**Files:** ${inventory.totalFiles} total`);
50
+
51
+ const sortedExts = [...inventory.byExtension.entries()].sort((a, b) => b[1] - a[1]).slice(0, 10);
52
+ for (const [ext, count] of sortedExts) {
53
+ const label = EXTENSION_LABELS.get(ext) ?? (ext || "(no extension)");
54
+ lines.push(`- ${label}: ${count}`);
55
+ }
56
+ if (inventory.byExtension.size > 10) {
57
+ lines.push(`- _+${inventory.byExtension.size - 10} more extensions_`);
58
+ }
59
+
60
+ if (inventory.landmarkFiles.length > 0) {
61
+ const unique = [...new Set(inventory.landmarkFiles)].sort((a, b) => a.localeCompare(b));
62
+ lines.push("");
63
+ lines.push("**Landmark files:**");
64
+ for (const f of unique) {
65
+ lines.push(`- \`${f}\``);
66
+ }
67
+ }
68
+ }
69
+
70
+ // ── Internal helpers ──────────────────────────────────────────────────
71
+
72
+ /** Process a single directory entry during inventory collection. */
73
+ function processInventoryEntry(
74
+ entry: fs.Dirent,
75
+ currentPath: string,
76
+ walkFn: (p: string) => void,
77
+ state: {
78
+ totalFiles: number;
79
+ byExtension: Map<string, number>;
80
+ landmarkFiles: string[];
81
+ },
82
+ ): void {
83
+ if (entry.name.startsWith(".") && entry.isDirectory()) return;
84
+ if (SKIP_DIRS.has(entry.name)) return;
85
+ if (entry.isDirectory()) {
86
+ walkFn(path.join(currentPath, entry.name));
87
+ return;
88
+ }
89
+ state.totalFiles++;
90
+ const ext = path.extname(entry.name).toLowerCase();
91
+ state.byExtension.set(ext, (state.byExtension.get(ext) ?? 0) + 1);
92
+ if (LANDMARK_FILES.has(entry.name)) {
93
+ state.landmarkFiles.push(entry.name);
94
+ }
95
+ }
96
+
97
+ // ── Constants ─────────────────────────────────────────────────────────
98
+
99
+ /** Human-readable labels for common file extensions. */
100
+ const EXTENSION_LABELS: Map<string, string> = new Map([
101
+ [".ts", "TypeScript"],
102
+ [".tsx", "TSX"],
103
+ [".js", "JavaScript"],
104
+ [".jsx", "JSX"],
105
+ [".mts", "TypeScript"],
106
+ [".cts", "TypeScript"],
107
+ [".mjs", "JavaScript"],
108
+ [".cjs", "JavaScript"],
109
+ [".py", "Python"],
110
+ [".pyi", "Python"],
111
+ [".rs", "Rust"],
112
+ [".go", "Go"],
113
+ [".mod", "Go"],
114
+ [".java", "Java"],
115
+ [".kt", "Kotlin"],
116
+ [".kts", "Kotlin"],
117
+ [".rb", "Ruby"],
118
+ [".php", "PHP"],
119
+ [".swift", "Swift"],
120
+ [".cpp", "C++"],
121
+ [".hpp", "C++"],
122
+ [".cc", "C++"],
123
+ [".cxx", "C++"],
124
+ [".hxx", "C++ Header"],
125
+ [".c++", "C++"],
126
+ [".h++", "C++ Header"],
127
+ [".c", "C"],
128
+ [".h", "C Header"],
129
+ [".css", "CSS"],
130
+ [".scss", "SCSS"],
131
+ [".less", "Less"],
132
+ [".html", "HTML"],
133
+ [".htm", "HTML"],
134
+ [".xhtml", "HTML"],
135
+ [".json", "JSON"],
136
+ [".yaml", "YAML"],
137
+ [".yml", "YAML"],
138
+ [".toml", "TOML"],
139
+ [".md", "Markdown"],
140
+ [".sh", "Shell"],
141
+ [".bash", "Shell"],
142
+ [".zsh", "Shell"],
143
+ [".r", "R"],
144
+ [".sql", "SQL"],
145
+ [".cs", "C#"],
146
+ ]);
147
+
148
+ /** Landmark files — well-known project configuration files. */
149
+ const LANDMARK_FILES = new Set([
150
+ "package.json",
151
+ "tsconfig.json",
152
+ "jsconfig.json",
153
+ "vite.config.ts",
154
+ "vitest.config.ts",
155
+ "jest.config.ts",
156
+ "playwright.config.ts",
157
+ "biome.json",
158
+ "eslint.config.js",
159
+ ".eslintrc.js",
160
+ "deno.json",
161
+ "deno.jsonc",
162
+ "Cargo.toml",
163
+ "go.mod",
164
+ "pyproject.toml",
165
+ "setup.py",
166
+ "requirements.txt",
167
+ "Makefile",
168
+ "justfile",
169
+ "Taskfile.yml",
170
+ "Dockerfile",
171
+ "docker-compose.yml",
172
+ ".env.example",
173
+ ".env.local.example",
174
+ ]);
175
+
176
+ /** Skip these directories during flat inventory walks. */
177
+ const SKIP_DIRS = new Set(["node_modules", "dist", "build", ".git"]);
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Focused brief generation — dispatches to file or directory brief.
3
+ *
4
+ * This is the main entry point, extracted from the original 800+ line
5
+ * brief-focused.ts. File and directory brief logic now live in sibling
6
+ * modules under use-case/brief/.
7
+ */
8
+
9
+ import * as fs from "node:fs";
10
+ import * as path from "node:path";
11
+ import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
12
+ import type { BriefDetails } from "../../types/index.ts";
13
+ import type { ArchitectureModel } from "../architecture/model.ts";
14
+ import { findModuleForPath } from "../architecture/model.ts";
15
+ import { formatGitContext, gatherGitContext } from "../signals/git.ts";
16
+ import {
17
+ appendPrioritySignalsSection,
18
+ summarizePrioritySignalsForFiles,
19
+ } from "../signals/project.ts";
20
+ import { generateDirectoryBrief } from "./directory.ts";
21
+ import { generateFileBrief } from "./file.ts";
22
+ import type { BriefOpts } from "./models.ts";
23
+ import { summarizeDirectoryRecursively } from "./summarize.ts";
24
+
25
+ /**
26
+ * Generate a focused brief for a specific path (directory or file).
27
+ *
28
+ * When opts.provider is available, file briefs include structural
29
+ * context (outline, imports, exports) and inline diagnostics.
30
+ * Module briefs include aggregated diagnostics across source files.
31
+ */
32
+ export async function generateFocusedBrief(
33
+ model: ArchitectureModel,
34
+ focusPath: string,
35
+ opts?: BriefOpts,
36
+ ): Promise<{ content: string; details: BriefDetails }> {
37
+ const resolvedPath = path.resolve(focusPath);
38
+
39
+ if (!fs.existsSync(resolvedPath)) {
40
+ return {
41
+ content: `**Error:** Path not found: \`${focusPath}\``,
42
+ details: {
43
+ confidence: "unavailable",
44
+ focusTarget: focusPath,
45
+ startHere: [],
46
+ publicSurfaces: [],
47
+ dependencySummary: null,
48
+ omittedCount: 0,
49
+ nextQueries: [],
50
+ },
51
+ };
52
+ }
53
+
54
+ const stat = fs.statSync(resolvedPath);
55
+
56
+ if (stat.isDirectory()) {
57
+ return await generateDirectoryFocused(model, resolvedPath, focusPath, opts);
58
+ }
59
+
60
+ return await generateFileFocused(model, resolvedPath, focusPath, opts);
61
+ }
62
+
63
+ // ── Directory dispatch ────────────────────────────────────────────────
64
+
65
+ async function generateDirectoryFocused(
66
+ model: ArchitectureModel,
67
+ resolvedPath: string,
68
+ originalPath: string,
69
+ opts?: BriefOpts,
70
+ ): Promise<{ content: string; details: BriefDetails }> {
71
+ const confidence: ConfidenceMode = "structural";
72
+
73
+ const { lines, publicSurfaces, nextQueries, startHere } = await generateDirectoryBrief(
74
+ model,
75
+ resolvedPath,
76
+ originalPath,
77
+ opts,
78
+ );
79
+
80
+ // Determine module info for dependency summary
81
+ const mod = findModuleForPath(model, resolvedPath);
82
+ const isModuleRoot = mod && mod.root === resolvedPath;
83
+
84
+ // Priority signals
85
+ const lspService =
86
+ opts?.lspService ??
87
+ ({
88
+ kind: "unavailable" as const,
89
+ reason: "No LSP service",
90
+ } as import("@mrclrchtr/supi-lsp/api").SessionLspServiceState);
91
+ const prioritySignals = summarizePrioritySignalsForFiles(
92
+ model.root,
93
+ summarizeDirectoryRecursively(resolvedPath).allFiles,
94
+ lspService,
95
+ );
96
+ appendPrioritySignalsSection(lines, prioritySignals);
97
+
98
+ // Git context
99
+ if (opts?.showGitContext !== false) {
100
+ const gitCtx = gatherGitContext(model.root);
101
+ if (gitCtx) {
102
+ lines.push(formatGitContext(gitCtx));
103
+ }
104
+ }
105
+
106
+ lines.push("");
107
+
108
+ return {
109
+ content: lines.join("\n"),
110
+ details: {
111
+ confidence,
112
+ focusTarget: originalPath,
113
+ startHere: startHere.slice(0, 3),
114
+ publicSurfaces: publicSurfaces.slice(0, 5),
115
+ dependencySummary: isModuleRoot
116
+ ? { moduleCount: 1, edgeCount: mod.internalDeps.length }
117
+ : null,
118
+ omittedCount: 0,
119
+ nextQueries,
120
+ prioritySignals,
121
+ },
122
+ };
123
+ }
124
+
125
+ // ── File dispatch ─────────────────────────────────────────────────────
126
+
127
+ async function generateFileFocused(
128
+ model: ArchitectureModel,
129
+ resolvedPath: string,
130
+ originalPath: string,
131
+ opts?: BriefOpts,
132
+ ): Promise<{ content: string; details: BriefDetails }> {
133
+ const {
134
+ content: briefContent,
135
+ publicSurfaces,
136
+ nextQueries,
137
+ } = await generateFileBrief(model, resolvedPath, opts);
138
+
139
+ // Priority signals
140
+ const lspService =
141
+ opts?.lspService ??
142
+ ({
143
+ kind: "unavailable" as const,
144
+ reason: "No LSP service",
145
+ } as import("@mrclrchtr/supi-lsp/api").SessionLspServiceState);
146
+ const prioritySignals = summarizePrioritySignalsForFiles(model.root, [resolvedPath], lspService);
147
+ const extraLines: string[] = [];
148
+ if (prioritySignals) {
149
+ appendPrioritySignalsSection(extraLines, prioritySignals);
150
+ }
151
+
152
+ // Git context
153
+ if (opts?.showGitContext !== false) {
154
+ const gitCtx = gatherGitContext(model.root);
155
+ if (gitCtx) {
156
+ extraLines.push(formatGitContext(gitCtx));
157
+ }
158
+ }
159
+
160
+ const extraStr = extraLines.filter((l) => l.trim()).join("\n");
161
+ const combinedContent = extraStr ? `${briefContent.trim()}\n\n${extraStr}\n` : briefContent;
162
+
163
+ return {
164
+ content: combinedContent,
165
+ details: {
166
+ confidence: "structural",
167
+ focusTarget: originalPath,
168
+ startHere: [],
169
+ publicSurfaces,
170
+ dependencySummary: null,
171
+ omittedCount: 0,
172
+ nextQueries,
173
+ prioritySignals,
174
+ },
175
+ };
176
+ }
@@ -0,0 +1,75 @@
1
+ // Typed DTOs for brief pipeline stages.
2
+ //
3
+ // Each brief mode produces a typed model (sync, manifest + fs), then
4
+ // enrichment adds provider context (async), then renderers consume
5
+ // the enriched model to produce markdown.
6
+
7
+ // ── Brief models (build stage output) ────────────────────────────────
8
+
9
+ /** Model for a single-file brief. */
10
+ export interface FileBriefModel {
11
+ kind: "file";
12
+ file: string;
13
+ relPath: string;
14
+ lineCount: number;
15
+ isEntrypoint: boolean;
16
+ moduleName: string | null;
17
+ moduleRelativePath: string | null;
18
+ }
19
+
20
+ /** Model for a module (package) brief. */
21
+ export interface ModuleBriefModel {
22
+ kind: "module";
23
+ name: string;
24
+ shortName: string;
25
+ description: string | null;
26
+ relativePath: string;
27
+ entrypoints: string[];
28
+ sourceFiles: string[];
29
+ allFiles: string[];
30
+ }
31
+
32
+ /** Model for a non-module directory brief. */
33
+ export interface DirectoryBriefModel {
34
+ kind: "directory";
35
+ path: string;
36
+ relPath: string;
37
+ directFiles: string[];
38
+ subdirs: Array<{ name: string; fileCount: number }>;
39
+ totalSourceFiles: number;
40
+ }
41
+
42
+ // ── Enrichment (async provider context) ──────────────────────────────
43
+
44
+ /** A single file's diagnostic entry. */
45
+ export interface BriefDiagnostic {
46
+ line: number;
47
+ severity: number;
48
+ message: string;
49
+ }
50
+
51
+ /** Provider-enriched context for a file or module. */
52
+ export interface BriefEnrichment {
53
+ outline: Array<{ name: string; kind: string; startLine: number; endLine: number }>;
54
+ imports: Array<{ moduleSpecifier: string }>;
55
+ exports: Array<{ name: string; kind: string }>;
56
+ diagnostics: BriefDiagnostic[];
57
+ /** Per-file aggregated diagnostics for module briefs. */
58
+ fileDiagnostics?: Array<{ file: string; errors: number; warnings: number }>;
59
+ /** Entrypoint outlines for module briefs. */
60
+ entrypointOutlines?: Array<{
61
+ entrypoint: string;
62
+ items: Array<{ name: string; kind: string; startLine: number }>;
63
+ }>;
64
+ }
65
+
66
+ /** Options for generateFocusedBrief. */
67
+ export interface BriefOpts {
68
+ provider?: import("../provider.ts").CodeProvider | null;
69
+ maxResults?: number;
70
+ cwd: string;
71
+ /** Show git context in orientation output. Defaults to true. */
72
+ showGitContext?: boolean;
73
+ /** LSP service state for diagnostic access. */
74
+ lspService?: import("@mrclrchtr/supi-lsp/api").SessionLspServiceState;
75
+ }