pi-lens 3.8.73 → 4.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 (346) hide show
  1. package/CHANGELOG.md +2614 -12
  2. package/README.md +50 -21
  3. package/dist/clients/actionable-warnings.js +73 -18
  4. package/dist/clients/agent-behavior-client.js +21 -4
  5. package/dist/clients/ast-grep-client.js +68 -16
  6. package/dist/clients/ast-grep-types.js +0 -1
  7. package/dist/clients/ast-grep-yaml-synth.js +37 -10
  8. package/dist/clients/atomic-write-staging.js +63 -0
  9. package/dist/clients/atomic-write.js +116 -16
  10. package/dist/clients/bash-file-access.js +193 -23
  11. package/dist/clients/biome-client.js +29 -25
  12. package/dist/clients/bootstrap.js +11 -2
  13. package/dist/clients/bounded-cache.js +34 -0
  14. package/dist/clients/bounded-pid-file-lock.js +192 -0
  15. package/dist/clients/bus-events-logger.js +5 -1
  16. package/dist/clients/bus-publish.js +10 -3
  17. package/dist/clients/cache/rule-cache.js +89 -6
  18. package/dist/clients/cache-manager.js +97 -9
  19. package/dist/clients/cache-observability.js +498 -0
  20. package/dist/clients/call-graph.js +460 -108
  21. package/dist/clients/cascade-logger.js +5 -1
  22. package/dist/clients/child-unref.js +85 -0
  23. package/dist/clients/codebase-model.js +52 -23
  24. package/dist/clients/collateral-test-role.js +40 -0
  25. package/dist/clients/complexity-client.js +6 -8
  26. package/dist/clients/console-guard-install.js +14 -0
  27. package/dist/clients/cooperative-budget.js +42 -0
  28. package/dist/clients/dead-code-client.js +2 -1
  29. package/dist/clients/debug-handles.js +206 -0
  30. package/dist/clients/debug-heap.js +167 -0
  31. package/dist/clients/degradation-ledger.js +153 -0
  32. package/dist/clients/dependency-checker.js +466 -63
  33. package/dist/clients/diagnostic-dispositions.js +83 -13
  34. package/dist/clients/diagnostics-publish.js +10 -3
  35. package/dist/clients/dispatch/auxiliary-lsp.js +34 -0
  36. package/dist/clients/dispatch/dispatcher.js +71 -13
  37. package/dist/clients/dispatch/fact-store.js +11 -0
  38. package/dist/clients/dispatch/facts/function-facts.js +37 -7
  39. package/dist/clients/dispatch/facts/import-facts.js +108 -119
  40. package/dist/clients/dispatch/facts/tree-sitter-facts.js +12 -12
  41. package/dist/clients/dispatch/facts/try-catch-facts.js +13 -0
  42. package/dist/clients/dispatch/indent-detect.js +35 -0
  43. package/dist/clients/dispatch/inline-suppressions.js +17 -8
  44. package/dist/clients/dispatch/integration.js +1094 -611
  45. package/dist/clients/dispatch/lazy.js +14 -0
  46. package/dist/clients/dispatch/plan.js +11 -1
  47. package/dist/clients/dispatch/rule-id-normalize.js +50 -0
  48. package/dist/clients/dispatch/rule-policy.js +135 -0
  49. package/dist/clients/dispatch/rules/async-noise.js +1 -0
  50. package/dist/clients/dispatch/rules/unsafe-boundary.js +7 -0
  51. package/dist/clients/dispatch/runners/ast-grep-napi.js +47 -6
  52. package/dist/clients/dispatch/runners/biome-check.js +5 -9
  53. package/dist/clients/dispatch/runners/detekt.js +3 -2
  54. package/dist/clients/dispatch/runners/hadolint.js +2 -1
  55. package/dist/clients/dispatch/runners/helm-lint.js +154 -0
  56. package/dist/clients/dispatch/runners/htmlhint.js +3 -2
  57. package/dist/clients/dispatch/runners/index.js +5 -1
  58. package/dist/clients/dispatch/runners/lsp.js +14 -6
  59. package/dist/clients/dispatch/runners/markdownlint.js +4 -9
  60. package/dist/clients/dispatch/runners/psscriptanalyzer.js +10 -1
  61. package/dist/clients/dispatch/runners/pyright.js +9 -5
  62. package/dist/clients/dispatch/runners/ruff.js +4 -8
  63. package/dist/clients/dispatch/runners/shellcheck.js +2 -3
  64. package/dist/clients/dispatch/runners/shfmt.js +2 -3
  65. package/dist/clients/dispatch/runners/spotbugs.js +2 -1
  66. package/dist/clients/dispatch/runners/taplo.js +2 -1
  67. package/dist/clients/dispatch/runners/terragrunt.js +163 -0
  68. package/dist/clients/dispatch/runners/tflint.js +37 -5
  69. package/dist/clients/dispatch/runners/tree-sitter.js +155 -166
  70. package/dist/clients/dispatch/runners/trivy-config.js +13 -7
  71. package/dist/clients/dispatch/runners/utils/lazy-installer.js +3 -0
  72. package/dist/clients/dispatch/runners/utils/runner-helpers.js +284 -34
  73. package/dist/clients/dispatch/runners/utils/spawn-outcome.js +22 -0
  74. package/dist/clients/dispatch/runners/yaml-rule-parser.js +5 -4
  75. package/dist/clients/disposition-publish.js +10 -3
  76. package/dist/clients/durable-store.js +97 -0
  77. package/dist/clients/event-loop-monitor.js +94 -3
  78. package/dist/clients/extension-log.js +139 -0
  79. package/dist/clients/extension-mode.js +73 -0
  80. package/dist/clients/feature-hints.js +53 -7
  81. package/dist/clients/file-kinds.js +143 -31
  82. package/dist/clients/file-role.js +18 -3
  83. package/dist/clients/file-utils.js +56 -34
  84. package/dist/clients/fix-worklog.js +14 -2
  85. package/dist/clients/format-events-publish.js +16 -3
  86. package/dist/clients/format-service.js +24 -8
  87. package/dist/clients/formatters-lazy.js +8 -0
  88. package/dist/clients/formatters.js +358 -61
  89. package/dist/clients/generated-artifacts.js +169 -15
  90. package/dist/clients/git-guard.js +681 -11
  91. package/dist/clients/git-tracked-ignore.js +4 -0
  92. package/dist/clients/go-client.js +2 -1
  93. package/dist/clients/govulncheck-client.js +8 -0
  94. package/dist/clients/grammar-source.js +12 -4
  95. package/dist/clients/gzip-stage-write.js +102 -0
  96. package/dist/clients/host-ports.js +31 -0
  97. package/dist/clients/installer/index.js +733 -213
  98. package/dist/clients/instance-reaper.js +142 -172
  99. package/dist/clients/jscpd-client.js +31 -54
  100. package/dist/clients/knip-client.js +78 -36
  101. package/dist/clients/language-policy.js +14 -2
  102. package/dist/clients/language-profile.js +72 -77
  103. package/dist/clients/latency-logger.js +28 -16
  104. package/dist/clients/lens-config.js +140 -166
  105. package/dist/clients/lens-engine.js +124 -21
  106. package/dist/clients/lens-events.js +27 -4
  107. package/dist/clients/lens-flag-registry.js +293 -0
  108. package/dist/clients/lens-map.js +96 -26
  109. package/dist/clients/live-bus-emitter.js +30 -0
  110. package/dist/clients/log-cleanup.js +8 -18
  111. package/dist/clients/lsp/cascade-tier.js +23 -3
  112. package/dist/clients/lsp/client.js +566 -57
  113. package/dist/clients/lsp/config.js +74 -10
  114. package/dist/clients/lsp/diagnostic-binding.js +86 -0
  115. package/dist/clients/lsp/edits.js +1012 -121
  116. package/dist/clients/lsp/index.js +1840 -803
  117. package/dist/clients/lsp/language.js +4 -1
  118. package/dist/clients/lsp/launch.js +40 -32
  119. package/dist/clients/lsp/path-utils.js +1 -1
  120. package/dist/clients/lsp/ruby-drive-dirs.js +83 -0
  121. package/dist/clients/lsp/server.js +279 -60
  122. package/dist/clients/lsp/workspace-diagnostics-cache.js +28 -4
  123. package/dist/clients/lsp-document-symbols.js +112 -0
  124. package/dist/clients/lsp-lazy.js +8 -0
  125. package/dist/clients/lsp-mutation.js +248 -0
  126. package/dist/clients/mcp/analyze.js +128 -36
  127. package/dist/clients/mcp/ipc.js +157 -24
  128. package/dist/clients/mcp/review.js +36 -3
  129. package/dist/clients/mcp/session.js +216 -8
  130. package/dist/clients/memory-sampler.js +115 -0
  131. package/dist/clients/metrics-client.js +2 -1
  132. package/dist/clients/metrics-history.js +2 -1
  133. package/dist/clients/module-report-lsp.js +5 -0
  134. package/dist/clients/module-report.js +267 -82
  135. package/dist/clients/ndjson-logger.js +334 -103
  136. package/dist/clients/opengrep-client.js +1 -1
  137. package/dist/clients/partial-edit-apply.js +120 -5
  138. package/dist/clients/path-keyed-map.js +76 -0
  139. package/dist/clients/path-utils.js +141 -5
  140. package/dist/clients/performance-report.js +327 -0
  141. package/dist/clients/pipeline.js +54 -13
  142. package/dist/clients/print-mode.js +21 -0
  143. package/dist/clients/project-changes.js +117 -4
  144. package/dist/clients/project-diagnostics/cache.js +3 -2
  145. package/dist/clients/project-diagnostics/extractors.js +26 -115
  146. package/dist/clients/project-diagnostics/fresh-fetch.js +149 -19
  147. package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +117 -0
  148. package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +37 -5
  149. package/dist/clients/project-diagnostics/scanner.js +268 -128
  150. package/dist/clients/project-lens-config.js +138 -34
  151. package/dist/clients/project-report.js +64 -25
  152. package/dist/clients/project-scale.js +8 -10
  153. package/dist/clients/project-snapshot-persist-worker.js +6 -0
  154. package/dist/clients/project-snapshot.js +767 -8
  155. package/dist/clients/project-trust.js +181 -0
  156. package/dist/clients/quiet-window.js +27 -5
  157. package/dist/clients/read-bridge.js +147 -0
  158. package/dist/clients/read-expansion.js +22 -12
  159. package/dist/clients/read-guard-logger.js +159 -1
  160. package/dist/clients/read-guard-tool-lines.js +150 -29
  161. package/dist/clients/read-guard.js +262 -3
  162. package/dist/clients/redact/secrets.js +449 -0
  163. package/dist/clients/resource-sampler.js +144 -39
  164. package/dist/clients/reverse-deps.js +48 -0
  165. package/dist/clients/review-graph/builder.js +2570 -326
  166. package/dist/clients/review-graph/git-identity.js +2 -1
  167. package/dist/clients/review-graph/import-resolvers.js +21 -10
  168. package/dist/clients/review-graph/persist-worker.js +10 -0
  169. package/dist/clients/review-graph/query.js +5 -0
  170. package/dist/clients/review-graph/shared-extraction-ir.js +90 -0
  171. package/dist/clients/review-graph/symbol-id.js +46 -0
  172. package/dist/clients/review-graph/tsconfig-paths.js +57 -6
  173. package/dist/clients/review-graph/workspace-modules.js +51 -3
  174. package/dist/clients/review-graph-logger.js +53 -0
  175. package/dist/clients/ruff-client.js +27 -44
  176. package/dist/clients/runtime-agent-end.js +111 -75
  177. package/dist/clients/runtime-context.js +36 -12
  178. package/dist/clients/runtime-coordinator.js +76 -8
  179. package/dist/clients/runtime-session.js +799 -137
  180. package/dist/clients/runtime-tool-call.js +117 -62
  181. package/dist/clients/runtime-tool-result.js +218 -23
  182. package/dist/clients/runtime-turn.js +284 -40
  183. package/dist/clients/rust-client.js +2 -1
  184. package/dist/clients/safe-spawn.js +873 -71
  185. package/dist/clients/security-scan-client.js +2 -1
  186. package/dist/clients/session-start-observability.js +15 -0
  187. package/dist/clients/session-state-store.js +5 -3
  188. package/dist/clients/sessionstart-logger.js +18 -0
  189. package/dist/clients/sg-runner.js +284 -159
  190. package/dist/clients/slow-fs.js +2 -1
  191. package/dist/clients/smells-rollup.js +224 -0
  192. package/dist/clients/source-filter.js +231 -43
  193. package/dist/clients/source-walker.js +66 -10
  194. package/dist/clients/startup-scan.js +15 -16
  195. package/dist/clients/startup-timing.js +9 -0
  196. package/dist/clients/test-runner-client.js +38 -8
  197. package/dist/clients/todo-scanner.js +30 -3
  198. package/dist/clients/tool-event.js +35 -0
  199. package/dist/clients/tool-policy.js +388 -39
  200. package/dist/clients/tool-render.js +155 -0
  201. package/dist/clients/tree-sitter-cache.js +153 -140
  202. package/dist/clients/tree-sitter-client.js +1722 -80
  203. package/dist/clients/tree-sitter-logger.js +64 -1
  204. package/dist/clients/tree-sitter-query-loader.js +117 -12
  205. package/dist/clients/tree-sitter-shared.js +48 -19
  206. package/dist/clients/tree-sitter-symbol-extractor.js +115 -11
  207. package/dist/clients/user-notify.js +51 -0
  208. package/dist/clients/vanished-instance-marker.js +57 -0
  209. package/dist/clients/warm-attach.js +33 -13
  210. package/dist/clients/widget-state.js +342 -49
  211. package/dist/clients/word-index-logger.js +44 -0
  212. package/dist/clients/word-index.js +612 -68
  213. package/dist/clients/workspace-topology.js +100 -7
  214. package/dist/index.js +65923 -47161
  215. package/dist/mcp/analyze-cli.js +185 -29
  216. package/dist/mcp/cli.js +110 -0
  217. package/dist/mcp/server.js +272 -50
  218. package/dist/tools/ast-grep-search.js +93 -27
  219. package/dist/tools/lens-diagnostics.js +247 -41
  220. package/dist/tools/lsp-diagnostics.js +153 -40
  221. package/dist/tools/lsp-navigation.js +51 -31
  222. package/dist/tools/module-report.js +9 -0
  223. package/dist/tools/symbol-search.js +21 -2
  224. package/docs/agent-guide.md +247 -0
  225. package/docs/agent-tools.md +21 -10
  226. package/docs/analysisall.md +192 -0
  227. package/docs/api-ports-inventory.md +165 -0
  228. package/docs/ast-grep_rules_catalog.md +5 -2
  229. package/docs/astplayground.md +3 -4
  230. package/docs/audit1.md +5 -5
  231. package/docs/durable-store-audit-1202.md +32 -0
  232. package/docs/environment-variables.md +197 -11
  233. package/docs/fable.md +27 -0
  234. package/docs/features.md +35 -5
  235. package/docs/globalconfig.md +101 -5
  236. package/docs/language-coverage.md +6 -5
  237. package/docs/lsp-capability-matrix.md +2 -2
  238. package/docs/mcp.md +54 -20
  239. package/docs/servercapabilities.md +7 -4
  240. package/docs/settings.md +192 -0
  241. package/docs/tools.md +18 -1
  242. package/docs/tree-sitter_rules_catalog.md +11 -31
  243. package/docs/usage.md +31 -0
  244. package/package.json +139 -138
  245. package/rules/ast-grep-rules/rule-tests/hardcoded-url-js-test.yml +1 -0
  246. package/rules/ast-grep-rules/rule-tests/hardcoded-url-test.yml +2 -0
  247. package/rules/ast-grep-rules/rule-tests/no-bare-except-test.yml +49 -0
  248. package/rules/ast-grep-rules/rule-tests/no-bare-host-path-in-win32-branch-test.yml +87 -0
  249. package/rules/ast-grep-rules/rule-tests/no-case-declarations-js-test.yml +10 -0
  250. package/rules/ast-grep-rules/rule-tests/no-case-declarations-test.yml +10 -0
  251. package/rules/ast-grep-rules/rule-tests/no-javascript-url-js-test.yml +10 -0
  252. package/rules/ast-grep-rules/rule-tests/no-javascript-url-test.yml +10 -0
  253. package/rules/ast-grep-rules/rule-tests/no-nested-links-test.yml +11 -1
  254. package/rules/ast-grep-rules/rule-tests/no-raw-json-store-write-test.yml +17 -0
  255. package/rules/ast-grep-rules/rule-tests/no-win32-isabsolute-for-qualification-test.yml +16 -0
  256. package/rules/ast-grep-rules/rule-tests/strict-equality-js-test.yml +3 -0
  257. package/rules/ast-grep-rules/rule-tests/strict-equality-test.yml +3 -0
  258. package/rules/ast-grep-rules/rule-tests/strict-inequality-js-test.yml +3 -0
  259. package/rules/ast-grep-rules/rule-tests/strict-inequality-test.yml +4 -0
  260. package/rules/ast-grep-rules/rules/hardcoded-url-js.yml +22 -4
  261. package/rules/ast-grep-rules/rules/hardcoded-url.yml +22 -4
  262. package/rules/ast-grep-rules/rules/no-bare-except.yml +3 -15
  263. package/rules/ast-grep-rules/rules/no-bare-host-path-in-win32-branch.yml +25 -0
  264. package/rules/ast-grep-rules/rules/no-case-declarations-js.yml +4 -3
  265. package/rules/ast-grep-rules/rules/no-case-declarations.yml +4 -3
  266. package/rules/ast-grep-rules/rules/no-console-except-error-js.yml +10 -0
  267. package/rules/ast-grep-rules/rules/no-console-except-error.yml +10 -0
  268. package/rules/ast-grep-rules/rules/no-javascript-url-js.yml +42 -6
  269. package/rules/ast-grep-rules/rules/no-javascript-url.yml +42 -6
  270. package/rules/ast-grep-rules/rules/no-nested-links.yml +7 -0
  271. package/rules/ast-grep-rules/rules/no-raw-json-store-write.yml +30 -0
  272. package/rules/ast-grep-rules/rules/no-win32-isabsolute-for-qualification.yml +23 -0
  273. package/rules/ast-grep-rules/rules/strict-equality-js.yml +14 -1
  274. package/rules/ast-grep-rules/rules/strict-equality.yml +14 -1
  275. package/rules/ast-grep-rules/rules/strict-inequality-js.yml +14 -1
  276. package/rules/ast-grep-rules/rules/strict-inequality.yml +14 -1
  277. package/rules/tree-sitter-queries/cpp/no-memset-sensitive-data.yml +9 -3
  278. package/rules/tree-sitter-queries/cpp/no-scoped-lock-without-args.yml +6 -6
  279. package/rules/tree-sitter-queries/css/calc-spacing.yml +8 -6
  280. package/rules/tree-sitter-queries/go/go-mutex-copy.yml +21 -18
  281. package/rules/tree-sitter-queries/go/go-shared-map-write-goroutine.yml +3 -3
  282. package/rules/tree-sitter-queries/java/infinite-loop-java.yml +3 -3
  283. package/rules/tree-sitter-queries/java/junit-call-super.yml +6 -4
  284. package/rules/tree-sitter-queries/java/no-double-checked-locking.yml +10 -8
  285. package/rules/tree-sitter-queries/java/no-field-shadowing.yml +1 -1
  286. package/rules/tree-sitter-queries/java/prepared-statement-valid-indices.yml +2 -3
  287. package/rules/tree-sitter-queries/java/resources-closed.yml +2 -2
  288. package/rules/tree-sitter-queries/java/springboot-default-package.yml +6 -3
  289. package/rules/tree-sitter-queries/java/switch-fall-through.yml +6 -4
  290. package/rules/tree-sitter-queries/java/switch-non-case-labels.yml +4 -3
  291. package/rules/tree-sitter-queries/java/tests-include-assertions.yml +6 -5
  292. package/rules/tree-sitter-queries/javascript/switch-case-termination-js.yml +5 -8
  293. package/rules/tree-sitter-queries/javascript/switch-non-case-labels.yml +3 -2
  294. package/rules/tree-sitter-queries/kotlin/prepared-statement-indices.yml +9 -5
  295. package/rules/tree-sitter-queries/php/this-in-static-context.yml +5 -5
  296. package/rules/tree-sitter-queries/python/exit-signature-check.yml +2 -9
  297. package/rules/tree-sitter-queries/python/in-operator-unsupported.yml +3 -4
  298. package/rules/tree-sitter-queries/python/no-super-torchscript.yml +4 -8
  299. package/rules/tree-sitter-queries/python/notimplemented-boolean-context.yml +1 -5
  300. package/rules/tree-sitter-queries/python/python-empty-except.yml +1 -1
  301. package/rules/tree-sitter-queries/python/return-in-init.yml +0 -2
  302. package/rules/tree-sitter-queries/python/yield-return-outside-function.yml +0 -3
  303. package/rules/tree-sitter-queries/ruby/ruby-command-injection.yml +1 -12
  304. package/rules/tree-sitter-queries/ruby/ruby-eval.yml +1 -1
  305. package/rules/tree-sitter-queries/ruby/ruby-insecure-deserialization.yml +4 -4
  306. package/rules/tree-sitter-queries/ruby/ruby-insecure-random.yml +4 -11
  307. package/rules/tree-sitter-queries/ruby/ruby-open-struct.yml +1 -1
  308. package/rules/tree-sitter-queries/ruby/ruby-string-eval.yml +2 -3
  309. package/rules/tree-sitter-queries/ruby/ruby-weak-hash.yml +4 -4
  310. package/rules/tree-sitter-queries/rust/rust-lock-held-across-await.yml +4 -3
  311. package/rules/tree-sitter-queries/tsx/no-nested-links.yml +4 -6
  312. package/rules/tree-sitter-queries/typescript/console-statement.yml +11 -0
  313. package/rules/tree-sitter-queries/typescript/duplicate-function-arg.yml +4 -9
  314. package/rules/tree-sitter-queries/typescript/empty-switch-case.yml +13 -9
  315. package/rules/tree-sitter-queries/typescript/infinite-loop.yml +2 -2
  316. package/rules/tree-sitter-queries/typescript/mixed-async-styles.yml +10 -1
  317. package/rules/tree-sitter-queries/typescript/switch-case-termination.yml +5 -8
  318. package/rules/tree-sitter-queries/typescript/ts-insecure-random.yml +7 -10
  319. package/rules/tree-sitter-queries/typescript/unsafe-regex.yml +4 -2
  320. package/rules/typos/_typos.toml +17 -0
  321. package/scripts/analyze-pi-lens-logs.mjs +55 -2
  322. package/skills/pi-lens-write-tree-sitter-rule/SKILL.md +5 -0
  323. package/dist/clients/ast-grep-parser.js +0 -86
  324. package/dist/clients/config-enabled-shape.js +0 -39
  325. package/dist/clients/lsp/interactive-install.js +0 -367
  326. package/dist/clients/lsp/lsp-index.js +0 -10
  327. package/dist/clients/lsp/server-strategies.js +0 -5
  328. package/dist/clients/project-metadata.js +0 -690
  329. package/dist/clients/source-groups.js +0 -96
  330. package/dist/clients/types.js +0 -11
  331. package/docs/env_variables.md +0 -10
  332. package/rules/tree-sitter-queries/abap-disabled/delete-where.yml +0 -46
  333. package/rules/tree-sitter-queries/cpp/no-confused-move-forward.yml +0 -59
  334. package/rules/tree-sitter-queries/cpp/noexcept-functions.yml +0 -58
  335. package/rules/tree-sitter-queries/java/mockito-initialized.yml +0 -66
  336. package/rules/tree-sitter-queries/java/no-wait-notify-on-thread.yml +0 -58
  337. package/rules/tree-sitter-queries/java/short-circuit-logic.yml +0 -57
  338. package/rules/tree-sitter-queries/java/spring-session-attributes-setcomplete.yml +0 -75
  339. package/rules/tree-sitter-queries/plsql-disabled/delete-update-where.yml +0 -56
  340. package/rules/tree-sitter-queries/plsql-disabled/end-loop-semicolon.yml +0 -51
  341. package/rules/tree-sitter-queries/plsql-disabled/fetch-bulk-collect-limit.yml +0 -47
  342. package/rules/tree-sitter-queries/plsql-disabled/forallsave-exceptions.yml +0 -51
  343. package/rules/tree-sitter-queries/plsql-disabled/nchar-nvarchar2-bytes.yml +0 -54
  344. package/rules/tree-sitter-queries/plsql-disabled/not-null-initialization.yml +0 -59
  345. package/rules/tree-sitter-queries/plsql-disabled/raise-application-error-codes.yml +0 -50
  346. package/rules/tree-sitter-queries/typescript-disabled/ts-path-traversal.yml +0 -71
@@ -22,9 +22,10 @@
22
22
  * snapshot) for who-uses-this / flags / imports — never a build. Cold cache
23
23
  * → outline only.
24
24
  * `semantic.source` reflects who-uses-this provenance: "review-graph" when the
25
- * cached graph backs it, else "none" (cold). Live-LSP enrichment is re-homed to
26
- * #236, where LSP writes provenance-tagged edges INTO the graph (once, persisted)
27
- * for this path to read as "graph-lsp". That logic lives in clients/module-report-lsp.ts.
25
+ * cached graph backs it, "unavailable:file-cap" when a size verdict disabled the
26
+ * graph, else "none" (cold). Live-LSP enrichment is re-homed to #236, where LSP
27
+ * writes provenance-tagged edges INTO the graph (once, persisted) for this path
28
+ * to read as "graph-lsp". That logic lives in clients/module-report-lsp.ts.
28
29
  *
29
30
  * Guard integrity: moduleReport injects NO read records — an outline is not
30
31
  * "having seen the body". readSymbol returns the actual body lines so the host
@@ -35,17 +36,31 @@ import * as path from "node:path";
35
36
  import { detectFileKind } from "./file-kinds.js";
36
37
  import { logLatency } from "./latency-logger.js";
37
38
  import { annotateMiddleMan } from "./middle-man-analysis.js";
38
- import { normalizeMapKey } from "./path-utils.js";
39
+ import { normalizeMapKey, toProjectRelativePath } from "./path-utils.js";
40
+ import { loadCallGraph, } from "./call-graph.js";
39
41
  import { resolveImportToFiles } from "./review-graph/import-resolvers.js";
40
42
  import { buildSymbolId } from "./review-graph/symbol-id.js";
41
- import { getSharedTreeSitterClient } from "./tree-sitter-shared.js";
43
+ import { getSharedTreeSitterClient, resolveTreeSitterLanguage, } from "./tree-sitter-shared.js";
42
44
  import { TreeSitterSymbolExtractor, } from "./tree-sitter-symbol-extractor.js";
45
+ // NOTE: live-LSP enrichment is NO LONGER called on this read path (#256). Firing
46
+ // LSP per read — speculatively, on the agent's fan-out path — repeatedly OOM'd
47
+ // pi. The enrichment logic is kept as a separate module (clients/module-report-
48
+ // lsp.ts) to be re-homed in #236, where LSP writes provenance-tagged edges INTO
49
+ // the review graph (computed once, persisted) so this path just reads them.
50
+ /** Hard payload bound for the per-symbol who-uses-this section. */
51
+ export const MAX_MODULE_REPORT_REFS = 100;
52
+ function normalizeMaxRefsPerSymbol(value) {
53
+ if (value === undefined || !Number.isFinite(value))
54
+ return 10;
55
+ return Math.min(MAX_MODULE_REPORT_REFS, Math.max(1, Math.floor(value)));
56
+ }
43
57
  // kind -> tree-sitter languageId. The languageId keys BOTH the grammar map
44
58
  // (tree-sitter-client) and SYMBOL_QUERIES (tree-sitter-symbol-extractor), so it
45
- // must match a key present in both. jsts/cxx are resolved by extension below so
46
- // the JSX-aware tsx grammar and the c-vs-cpp split are honoured. Using these
47
- // gives the primary languages the same rich outline (classes/interfaces/types/
48
- // signatures) as every other language, not the functions-only FunctionSummary.
59
+ // must match a key present in both. jsts/cxx are extension-split kinds resolved
60
+ // through the SHARED ext→grammar resolver below (never a local extension map —
61
+ // #887). Using these gives the primary languages the same rich outline
62
+ // (classes/interfaces/types/signatures) as every other language, not the
63
+ // functions-only FunctionSummary.
49
64
  const KIND_TO_TS_LANG = {
50
65
  python: "python",
51
66
  go: "go",
@@ -64,15 +79,23 @@ const KIND_TO_TS_LANG = {
64
79
  shell: "bash",
65
80
  // cxx resolved by extension below (c vs cpp)
66
81
  };
67
- function tsLangForFile(filePath, kind) {
68
- const ext = path.extname(filePath).toLowerCase();
69
- if (kind === "cxx") {
70
- return ext === ".c" || ext === ".h" ? "c" : "cpp";
71
- }
82
+ export function tsLangForFile(filePath, kind) {
83
+ // jsts/cxx are extension-split kinds: resolve them through the shared
84
+ // ext→grammar authority (tree-sitter-shared.ts EXT_TO_LANG) — the SAME
85
+ // resolver the dispatch tree-sitter runner, fact providers, project scanner
86
+ // and read expansion use — so a file is parsed and TreeCache-keyed
87
+ // (`languageId:path`) under exactly one grammar process-wide. #887: this
88
+ // used to hand-roll a local map that sent .js/.mjs/.cjs to the typescript
89
+ // grammar and .jsx to tsx, so every plain-JS file was parsed and cached
90
+ // twice under two grammars and ran TS-grammar symbol queries on JS trees.
91
+ // Extensions the shared map does not cover (.svelte/.vue for jsts; the
92
+ // module-interface/Objective-C/CUDA tail for cxx) keep the historical
93
+ // kind default.
72
94
  if (kind === "jsts") {
73
- // Route JSX-bearing files to the tsx grammar (downloaded), plain TS/JS to
74
- // the typescript grammar; both share the same SYMBOL_QUERIES.
75
- return ext === ".tsx" || ext === ".jsx" ? "tsx" : "typescript";
95
+ return resolveTreeSitterLanguage(filePath) ?? "typescript";
96
+ }
97
+ if (kind === "cxx") {
98
+ return resolveTreeSitterLanguage(filePath) ?? "cpp";
76
99
  }
77
100
  return kind ? KIND_TO_TS_LANG[kind] : undefined;
78
101
  }
@@ -108,6 +131,7 @@ async function extractFile(absPath, languageId, content) {
108
131
  return {
109
132
  symbols: [],
110
133
  imports: [],
134
+ callbacks: [],
111
135
  error: "tree-sitter runtime unavailable (wasm aborted)",
112
136
  };
113
137
  }
@@ -116,29 +140,50 @@ async function extractFile(absPath, languageId, content) {
116
140
  return {
117
141
  symbols: [],
118
142
  imports: [],
143
+ callbacks: [],
119
144
  error: "tree-sitter runtime failed to initialize",
120
145
  };
121
146
  }
122
- const tree = await tsClient.parseFile(absPath, languageId);
123
- if (!tree) {
147
+ const extractor = await getExtractor(languageId);
148
+ const extracted = await tsClient.withParsedTree(absPath, languageId, content, (tree) => {
149
+ const warnings = extractor
150
+ ? []
151
+ : [`Symbol extractor not available for ${languageId}`];
152
+ const result = extractor
153
+ ? extractor.extract(tree, absPath, content)
154
+ : { symbols: [], imports: [] };
155
+ const owners = result.symbols
156
+ .filter((candidate) => !candidate.local)
157
+ .map((candidate) => ({
158
+ name: candidate.name,
159
+ startLine: candidate.line,
160
+ endLine: candidate.endLine ?? candidate.line,
161
+ }));
162
+ let callbacks = [];
163
+ let callbackError;
164
+ try {
165
+ callbacks = extractCallbacks(tree.rootNode, owners, languageId, warnings);
166
+ }
167
+ catch (error) {
168
+ callbackError = diagnosticMessage(error);
169
+ }
124
170
  return {
125
- symbols: [],
126
- imports: [],
127
- error: `tree-sitter failed to parse as ${languageId}`,
171
+ symbols: result.symbols,
172
+ imports: result.imports,
173
+ callbacks,
174
+ callbackError,
175
+ warnings,
128
176
  };
129
- }
130
- const extractor = await getExtractor(languageId);
131
- const root = tree.rootNode;
132
- if (!extractor) {
177
+ });
178
+ if (!extracted.parsed) {
133
179
  return {
134
180
  symbols: [],
135
181
  imports: [],
136
- root,
137
- warnings: [`Symbol extractor not available for ${languageId}`],
182
+ callbacks: [],
183
+ error: `tree-sitter failed to parse as ${languageId}`,
138
184
  };
139
185
  }
140
- const result = extractor.extract(tree, absPath, content);
141
- return { symbols: result.symbols, imports: result.imports, root };
186
+ return extracted.value;
142
187
  }
143
188
  catch (err) {
144
189
  const message = diagnosticMessage(err);
@@ -149,7 +194,7 @@ async function extractFile(absPath, languageId, content) {
149
194
  durationMs: 0,
150
195
  metadata: { error: message },
151
196
  });
152
- return { symbols: [], imports: [], error: message };
197
+ return { symbols: [], imports: [], callbacks: [], error: message };
153
198
  }
154
199
  }
155
200
  function readArgsFor(filePath, startLine, endLine) {
@@ -193,7 +238,9 @@ function resolveUsedBy(graph, symbolNodeId, cap, projectRoot) {
193
238
  symbol,
194
239
  line,
195
240
  relation: edge.kind,
196
- ...(edge.resolution ? { resolution: edge.resolution } : {}),
241
+ ...(edge.resolution && edge.resolution !== "unresolved"
242
+ ? { resolution: edge.resolution }
243
+ : {}),
197
244
  });
198
245
  if (out.length >= cap)
199
246
  break;
@@ -205,12 +252,7 @@ function resolveUsedBy(graph, symbolNodeId, cap, projectRoot) {
205
252
  // `read` args) keep the absolute path so the host's Read tool resolves them
206
253
  // unambiguously; only display fields (`path`, `usedBy.file`, imports) relativize.
207
254
  function toDisplayPath(p, projectRoot) {
208
- if (!path.isAbsolute(p))
209
- return p.replace(/\\/g, "/");
210
- const rel = path.relative(projectRoot, p);
211
- return rel && !rel.startsWith("..")
212
- ? rel.replace(/\\/g, "/")
213
- : p.replace(/\\/g, "/");
255
+ return toProjectRelativePath(p, projectRoot);
214
256
  }
215
257
  function collectImports(graph, normalizedPath, projectRoot) {
216
258
  const fileNodeId = graph.fileNodes.get(normalizedPath);
@@ -1116,6 +1158,120 @@ function extractCallbacks(root, entries, languageId, warnings) {
1116
1158
  }
1117
1159
  return callbacks.slice(0, callbackCap);
1118
1160
  }
1161
+ const CALL_GRAPH_DEFAULT_ENTRY_CAP = 20;
1162
+ const CALL_GRAPH_MAX_ENTRY_CAP = 100;
1163
+ function unavailableCallGraph(reason) {
1164
+ return {
1165
+ available: false,
1166
+ reason,
1167
+ callers: [],
1168
+ callees: [],
1169
+ truncated: false,
1170
+ coverage: { status: "unavailable", complete: false },
1171
+ };
1172
+ }
1173
+ function callGraphCoverage(coverage) {
1174
+ const languages = coverage.languages;
1175
+ const complete = coverage.complete && Object.values(languages ?? {}).every((status) => status === "complete");
1176
+ return {
1177
+ status: complete ? "complete" : "partial",
1178
+ complete,
1179
+ totalEvidence: coverage.totalEvidence,
1180
+ callsEvidence: coverage.callsEvidence,
1181
+ referencesEvidence: coverage.referencesEvidence,
1182
+ eligibleEvidence: coverage.eligibleEvidence,
1183
+ resolvedEvidence: coverage.resolvedEvidence,
1184
+ unresolvedEvidence: coverage.unresolvedEvidence,
1185
+ typeOnlyEvidence: coverage.typeOnlyEvidence,
1186
+ unsupportedEvidence: coverage.unsupportedEvidence,
1187
+ sameFileEvidence: coverage.sameFileEvidence,
1188
+ duplicateEvidence: coverage.duplicateEvidence,
1189
+ ...(languages ? { languages } : {}),
1190
+ };
1191
+ }
1192
+ function callGraphRelation(edge, kind, projectRoot) {
1193
+ const caller = kind === "caller";
1194
+ return {
1195
+ symbolId: caller ? edge.callerKey : edge.calleeKey,
1196
+ targetSymbolId: caller ? edge.calleeKey : edge.callerKey,
1197
+ file: toDisplayPath(caller ? edge.callerFile : edge.calleeFile, projectRoot),
1198
+ ...(caller
1199
+ ? {
1200
+ symbol: edge.callerSymbol,
1201
+ kind: edge.callerKind,
1202
+ line: edge.callerLine,
1203
+ }
1204
+ : {
1205
+ symbol: edge.calleeSymbol,
1206
+ kind: edge.calleeKind,
1207
+ line: edge.calleeLine,
1208
+ }),
1209
+ ...(edge.evidenceKind ? { evidenceKind: edge.evidenceKind } : {}),
1210
+ ...(edge.resolution ? { resolution: edge.resolution } : {}),
1211
+ ...(edge.evidenceCount && edge.evidenceCount > 1
1212
+ ? { evidenceCount: edge.evidenceCount }
1213
+ : {}),
1214
+ ...(edge.weight !== 1 ? { weight: edge.weight } : {}),
1215
+ };
1216
+ }
1217
+ /**
1218
+ * Read the separately persisted FunctionCallGraph projection. This accessor is
1219
+ * deliberately conservative: the module-report path never walks/builds the
1220
+ * review graph, and a changed source file invalidates the projection rather
1221
+ * than being reported as a clean zero-call result.
1222
+ */
1223
+ function readCallGraph(projectRoot, normalizedPath, maxEntries, graphFileCap, identity, reviewGraph) {
1224
+ if (graphFileCap !== undefined)
1225
+ return unavailableCallGraph("file-cap");
1226
+ // The canonical review graph is the only freshness authority. This path is
1227
+ // read-only: do not walk source files or compare an independent mtime map.
1228
+ if (!reviewGraph)
1229
+ return unavailableCallGraph("review-graph-missing");
1230
+ if (reviewGraph.persistCoverage?.partial || reviewGraph.persistCoverage?.inProgress) {
1231
+ return unavailableCallGraph("partial");
1232
+ }
1233
+ if (!identity)
1234
+ return unavailableCallGraph("identity-missing");
1235
+ if (!reviewGraph.fileNodes.has(normalizedPath))
1236
+ return unavailableCallGraph("stale");
1237
+ const cached = loadCallGraph(projectRoot, identity);
1238
+ if (!cached)
1239
+ return unavailableCallGraph("stale");
1240
+ const callers = [];
1241
+ const callees = [];
1242
+ for (const edge of cached.graph.edges) {
1243
+ if (normalizeMapKey(edge.calleeFile) === normalizedPath) {
1244
+ callers.push(callGraphRelation(edge, "caller", projectRoot));
1245
+ }
1246
+ if (normalizeMapKey(edge.callerFile) === normalizedPath) {
1247
+ callees.push(callGraphRelation(edge, "callee", projectRoot));
1248
+ }
1249
+ }
1250
+ const stable = (left, right) => left.targetSymbolId.localeCompare(right.targetSymbolId) ||
1251
+ (left.line ?? 0) - (right.line ?? 0) ||
1252
+ left.symbolId.localeCompare(right.symbolId);
1253
+ callers.sort(stable);
1254
+ callees.sort(stable);
1255
+ return {
1256
+ available: true,
1257
+ callers: callers.slice(0, maxEntries),
1258
+ callees: callees.slice(0, maxEntries),
1259
+ truncated: callers.length > maxEntries || callees.length > maxEntries,
1260
+ coverage: callGraphCoverage(cached.graph.coverage ?? {
1261
+ totalEvidence: cached.graph.totalRefs,
1262
+ callsEvidence: cached.graph.totalRefs,
1263
+ referencesEvidence: 0,
1264
+ eligibleEvidence: cached.graph.totalRefs,
1265
+ resolvedEvidence: cached.graph.totalRefs,
1266
+ unresolvedEvidence: cached.graph.unresolvedRefs,
1267
+ typeOnlyEvidence: 0,
1268
+ unsupportedEvidence: 0,
1269
+ sameFileEvidence: 0,
1270
+ duplicateEvidence: 0,
1271
+ complete: false,
1272
+ }),
1273
+ };
1274
+ }
1119
1275
  function unavailableReport(displayPath, error) {
1120
1276
  return {
1121
1277
  available: false,
@@ -1141,7 +1297,8 @@ function unavailableReport(displayPath, error) {
1141
1297
  */
1142
1298
  export async function moduleReport(file, cwd, options) {
1143
1299
  const startedAt = Date.now();
1144
- const maxRefs = Math.max(1, options?.maxRefsPerSymbol ?? 10);
1300
+ const maxRefs = normalizeMaxRefsPerSymbol(options?.maxRefsPerSymbol);
1301
+ const maxCallGraphEntries = Math.min(CALL_GRAPH_MAX_ENTRY_CAP, Math.max(1, Math.floor(options?.maxCallGraphEntries ?? CALL_GRAPH_DEFAULT_ENTRY_CAP)));
1145
1302
  const absPath = path.resolve(cwd, file);
1146
1303
  const normalizedPath = normalizeMapKey(absPath);
1147
1304
  let content;
@@ -1154,12 +1311,13 @@ export async function moduleReport(file, cwd, options) {
1154
1311
  const kind = detectFileKind(absPath);
1155
1312
  const languageId = tsLangForFile(absPath, kind);
1156
1313
  const lineCount = content.split(/\r?\n/).length;
1157
- const { symbols: extracted, imports: extractedImports, root, error: extractionError, warnings: extractionWarnings, } = languageId
1314
+ const { symbols: extracted, imports: extractedImports, callbacks, callbackError, error: extractionError, warnings: extractionWarnings, } = languageId
1158
1315
  ? await extractFile(absPath, languageId, content)
1159
1316
  : {
1160
1317
  symbols: [],
1161
1318
  imports: [],
1162
- root: undefined,
1319
+ callbacks: [],
1320
+ callbackError: undefined,
1163
1321
  error: undefined,
1164
1322
  warnings: undefined,
1165
1323
  };
@@ -1170,12 +1328,27 @@ export async function moduleReport(file, cwd, options) {
1170
1328
  // synchronous full build re-runs every fact provider (TS-compiler ASTs for
1171
1329
  // jsts) and two racing builds OOM'd pi (#256). Cold cache → outline-only.
1172
1330
  let graph;
1331
+ let graphFileCap;
1332
+ let callGraphIdentity;
1173
1333
  try {
1174
- const { getCachedReviewGraph } = await import("./review-graph/builder.js");
1334
+ const { getCachedReviewGraph, getReviewGraphCacheIdentity, getReviewGraphSizeSkipVerdict, } = await import("./review-graph/builder.js");
1175
1335
  graph = getCachedReviewGraph(cwd);
1336
+ graphFileCap = getReviewGraphSizeSkipVerdict(cwd)?.maxFileCount;
1337
+ callGraphIdentity = graph
1338
+ ? (() => {
1339
+ const identity = getReviewGraphCacheIdentity(cwd, graph);
1340
+ return identity
1341
+ ? {
1342
+ reviewGraphVersion: identity.version,
1343
+ reviewGraphSignature: identity.signature,
1344
+ }
1345
+ : undefined;
1346
+ })()
1347
+ : undefined;
1176
1348
  }
1177
1349
  catch {
1178
1350
  graph = undefined;
1351
+ callGraphIdentity = undefined;
1179
1352
  }
1180
1353
  // Drop function-local declarations (a nested const/arrow/function) from the
1181
1354
  // outline — they're implementation detail of a parent symbol, not navigable
@@ -1192,22 +1365,24 @@ export async function moduleReport(file, cwd, options) {
1192
1365
  annotateMiddleMan(entries, content, languageId);
1193
1366
  const api = topLevel.filter((entry) => entry.exported);
1194
1367
  const internal = topLevel.filter((entry) => !entry.exported);
1195
- let callbacks = [];
1196
1368
  const warnings = [...(extractionWarnings ?? [])];
1197
- try {
1198
- callbacks = extractCallbacks(root, entries, languageId, warnings);
1199
- }
1200
- catch (err) {
1201
- const message = diagnosticMessage(err);
1202
- warnings.push(`Failed to extract callbacks: ${message}`);
1369
+ if (callbackError) {
1370
+ warnings.push(`Failed to extract callbacks: ${callbackError}`);
1203
1371
  logLatency({
1204
1372
  type: "phase",
1205
1373
  phase: "module_report_callback_extract_error",
1206
1374
  filePath: absPath,
1207
1375
  durationMs: 0,
1208
- metadata: { error: message },
1376
+ metadata: { error: callbackError },
1209
1377
  });
1210
1378
  }
1379
+ if (graphFileCap !== undefined) {
1380
+ warnings.push(`who-uses-this is unavailable: review graph disabled because the project ` +
1381
+ `has more than ${graphFileCap} files (cap ${graphFileCap}) — raise ` +
1382
+ "maxProjectFiles in .pi-lens.json or set " +
1383
+ "PI_LENS_REVIEW_GRAPH_MAX_FILES; for CI/cron, run npx pi-lens " +
1384
+ "build-graph after configuring the cap");
1385
+ }
1211
1386
  // Imports: the warm review graph is source-of-truth; on a cold cache (or a
1212
1387
  // graph without this file's node) fall back to the language-uniform tree-sitter
1213
1388
  // resolution (#301) so a cold report no longer shows zero imports.
@@ -1245,6 +1420,9 @@ export async function moduleReport(file, cwd, options) {
1245
1420
  const blastRadius = options?.blastRadius && graph && hasGraphNode
1246
1421
  ? await computeBlastRadius(graph, normalizedPath, cwd, Math.max(1, options.blastRadiusDepth ?? 3))
1247
1422
  : undefined;
1423
+ const callGraph = options?.callGraph
1424
+ ? readCallGraph(cwd, normalizedPath, maxCallGraphEntries, graphFileCap, callGraphIdentity, graph)
1425
+ : undefined;
1248
1426
  const view = options?.view ?? "default";
1249
1427
  const summaryView = view === "summary";
1250
1428
  // "compact" computes the same full data as "default" — it's a rendering
@@ -1259,7 +1437,17 @@ export async function moduleReport(file, cwd, options) {
1259
1437
  else if (graph) {
1260
1438
  importsProvenance = "cached-review-graph";
1261
1439
  }
1262
- const blastRadiusProvenance = blastRadius ? "cached-review-graph" : "none";
1440
+ const unavailableGraphProvenance = graphFileCap !== undefined
1441
+ ? "unavailable:file-cap"
1442
+ : "none";
1443
+ const blastRadiusProvenance = blastRadius
1444
+ ? "cached-review-graph"
1445
+ : unavailableGraphProvenance;
1446
+ const callGraphProvenance = callGraph?.available
1447
+ ? "cached-call-graph"
1448
+ : callGraph?.reason === "file-cap"
1449
+ ? "unavailable:file-cap"
1450
+ : "none";
1263
1451
  const report = {
1264
1452
  available: entries.length > 0 || hasGraphNode,
1265
1453
  staleness: entries.length === 0 && !hasGraphNode ? "unavailable" : "fresh",
@@ -1281,21 +1469,25 @@ export async function moduleReport(file, cwd, options) {
1281
1469
  ...(summaryView ? { view: "summary" } : {}),
1282
1470
  ...(compactView ? { view: "compact" } : {}),
1283
1471
  ...(blastRadius && !summaryView ? { blastRadius } : {}),
1472
+ ...(callGraph ? { callGraph } : {}),
1284
1473
  ...(graph ? { graphBuiltAt: graph.builtAt } : {}),
1285
1474
  provenance: {
1286
1475
  symbols: languageId ? "syntax" : "none",
1287
1476
  imports: importsProvenance,
1288
- usedBy: hasGraphNode ? "cached-review-graph" : "none",
1477
+ usedBy: hasGraphNode
1478
+ ? "cached-review-graph"
1479
+ : unavailableGraphProvenance,
1289
1480
  callbacks: languageId && !summaryView ? "heuristic-tree-sitter" : "none",
1290
1481
  ...(options?.blastRadius
1291
1482
  ? { blastRadius: blastRadiusProvenance }
1292
1483
  : {}),
1484
+ ...(options?.callGraph ? { callGraph: callGraphProvenance } : {}),
1293
1485
  },
1294
1486
  semantic: {
1295
1487
  // Provenance of who-uses-this / references. The AST review graph is the
1296
1488
  // only source on this read path; "graph-lsp" is reserved for #236 (LSP
1297
1489
  // writes provenance edges INTO the graph). Cold cache → "none".
1298
- source: hasGraphNode ? "review-graph" : "none",
1490
+ source: hasGraphNode ? "review-graph" : unavailableGraphProvenance,
1299
1491
  references: hasGraphNode,
1300
1492
  implementations: false,
1301
1493
  },
@@ -1410,6 +1602,9 @@ export function renderCompactModuleReport(report) {
1410
1602
  `${report.path} ${report.language ?? "?"} ${report.lineCount ?? "?"}L — ` +
1411
1603
  `${report.summary.symbols} symbols, ${report.summary.exports} exported${importsSuffix}`,
1412
1604
  ];
1605
+ for (const warning of report.warnings ?? []) {
1606
+ lines.push(`WARNING: ${warning}`);
1607
+ }
1413
1608
  if (report.api.length > 0) {
1414
1609
  lines.push("API:");
1415
1610
  for (const entry of report.api) {
@@ -1430,6 +1625,18 @@ export function renderCompactModuleReport(report) {
1430
1625
  lines.push(compactCallbackLine(callback, width));
1431
1626
  }
1432
1627
  }
1628
+ if (report.callGraph) {
1629
+ const callGraph = report.callGraph;
1630
+ const suffix = callGraph.truncated ? " (truncated)" : "";
1631
+ lines.push("CALL GRAPH:");
1632
+ if (!callGraph.available) {
1633
+ lines.push(` unavailable (${callGraph.reason ?? "unknown"})`);
1634
+ }
1635
+ else {
1636
+ lines.push(` callers: ${callGraph.callers.length} · callees: ${callGraph.callees.length}` +
1637
+ ` · coverage: ${callGraph.coverage.status}${suffix}`);
1638
+ }
1639
+ }
1433
1640
  if (report.recommendedReads.length > 0) {
1434
1641
  lines.push("RECOMMENDED:");
1435
1642
  for (const r of report.recommendedReads) {
@@ -1580,7 +1787,7 @@ export async function readSymbol(file, symbolName, cwd, options = {}) {
1580
1787
  log(false);
1581
1788
  return { found: false, path: absPath, name: symbolName };
1582
1789
  }
1583
- const { symbols, root, error: extractionError, warnings: extractionWarnings, } = await extractFile(absPath, languageId, content);
1790
+ const { symbols, callbacks: allCallbacks, callbackError, error: extractionError, warnings: extractionWarnings, } = await extractFile(absPath, languageId, content);
1584
1791
  if (extractionError) {
1585
1792
  log(false);
1586
1793
  return {
@@ -1624,20 +1831,8 @@ export async function readSymbol(file, symbolName, cwd, options = {}) {
1624
1831
  ...(selection.ambiguous ? { ambiguous: selection.ambiguous } : {}),
1625
1832
  };
1626
1833
  }
1627
- const owners = symbols
1628
- .filter((candidate) => !candidate.local)
1629
- .map((candidate) => ({
1630
- name: candidate.name,
1631
- startLine: candidate.line,
1632
- endLine: candidate.endLine ?? candidate.line,
1633
- }));
1634
- let allCallbacks;
1635
- const callbackWarnings = [...(extractionWarnings ?? [])];
1636
- try {
1637
- allCallbacks = extractCallbacks(root, owners, languageId, callbackWarnings);
1638
- }
1639
- catch (err) {
1640
- const message = `Callback extraction failed: ${diagnosticMessage(err)}`;
1834
+ if (callbackError) {
1835
+ const message = `Callback extraction failed: ${callbackError}`;
1641
1836
  logLatency({
1642
1837
  type: "phase",
1643
1838
  phase: "read_symbol_callback_extract_error",
@@ -1648,6 +1843,7 @@ export async function readSymbol(file, symbolName, cwd, options = {}) {
1648
1843
  log(false);
1649
1844
  return { found: false, path: absPath, name: symbolName, error: message };
1650
1845
  }
1846
+ const callbackWarnings = [...(extractionWarnings ?? [])];
1651
1847
  const callback = allCallbacks.find((candidate) => candidate.name === symbolName);
1652
1848
  if (!callback) {
1653
1849
  log(false);
@@ -1807,7 +2003,7 @@ export async function readEnclosing(file, line, cwd, options) {
1807
2003
  log(false);
1808
2004
  return { found: false, path: absPath, line: targetLine };
1809
2005
  }
1810
- const { symbols, root, error: extractionError, warnings: extractionWarnings, } = await extractFile(absPath, languageId, content);
2006
+ const { symbols, callbacks, callbackError, error: extractionError, warnings: extractionWarnings, } = await extractFile(absPath, languageId, content);
1811
2007
  if (extractionError) {
1812
2008
  log(false);
1813
2009
  return {
@@ -1818,20 +2014,9 @@ export async function readEnclosing(file, line, cwd, options) {
1818
2014
  };
1819
2015
  }
1820
2016
  const filters = new Set((options?.kinds ?? []).map((value) => value.toLowerCase()));
1821
- const owners = symbols
1822
- .filter((candidate) => !candidate.local)
1823
- .map((candidate) => ({
1824
- name: candidate.name,
1825
- startLine: candidate.line,
1826
- endLine: candidate.endLine ?? candidate.line,
1827
- }));
1828
2017
  const warnings = [...(extractionWarnings ?? [])];
1829
- let callbacks = [];
1830
- try {
1831
- callbacks = extractCallbacks(root, owners, languageId, warnings);
1832
- }
1833
- catch (err) {
1834
- const message = `Callback extraction failed: ${diagnosticMessage(err)}`;
2018
+ if (callbackError) {
2019
+ const message = `Callback extraction failed: ${callbackError}`;
1835
2020
  warnings.push(message);
1836
2021
  logLatency({
1837
2022
  type: "phase",