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
package/docs/features.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### LSP Support
4
4
 
5
- pi-lens includes **37 language server definitions** (including two cross-cutting *auxiliary* scanners that attach alongside the file's language server — Opengrep for security, and ast-grep for structural rules in projects with an `sgconfig.y[a]ml` — see below). LSP is **enabled by default** (`--lsp` or no flag). Servers are auto-discovered from PATH, project `node_modules`, and managed installs. When a server is not installed, pi-lens offers an interactive install prompt.
5
+ pi-lens includes **42 language server definitions** (including four cross-cutting *auxiliary* scanners that attach alongside the file's language server — Opengrep, ast-grep, zizmor, and typos — see below). LSP is **enabled by default**; use `--no-lsp` to disable it for a session. Servers are auto-discovered from PATH, project `node_modules`, and managed installs. When a server is not installed, pi-lens offers an interactive install prompt.
6
6
 
7
7
  **LSP Idle Management:** LSP servers shut down after 240 seconds of inactivity (no files modified) to free resources. The timer resets when you resume editing, preventing cold-start penalties during active development.
8
8
 
@@ -40,6 +40,21 @@ Repositories can disable all immediate and deferred auto-format mutations with
40
40
  keeping formatter detection, lint dispatch, LSP synchronization, and
41
41
  diagnostics available.
42
42
 
43
+ Deferred formatting (the `agent_end` default) runs with **bounded
44
+ concurrency**: at most three formatter subprocesses in flight at once, with
45
+ results applied in admission order and cooperative yields between files, so a
46
+ large batch of queued files can't stall the event loop or the turn-end pass.
47
+
48
+ ### Commit/Push Guard (Experimental)
49
+
50
+ `--lens-guard` (also `guard.enabled: true` in `~/.pi-lens/config.json`) opts
51
+ into blocking `git commit`/`git push` while unresolved pi-lens blockers exist.
52
+ Detection covers normalized wrapper launchers, shell-escaped and
53
+ keyword/combined-flag verb forms, and shell substitutions, while literal text
54
+ in non-executing contexts remains allowed. Off by default; see
55
+ [docs/agent-guide.md](agent-guide.md) and [docs/settings.md](settings.md) for
56
+ the full behavior and honest limits.
57
+
43
58
  ### Review Graph - Cascade Diagnostics
44
59
 
45
60
  pi-lens builds a review graph (`file → symbol → dependency`) during session and uses it at turn end to render an impact cascade: which files were affected by a change and how diagnostics propagated through the dependency graph. Nodes track kind, language, and export status; edges track contains/imports/calls/references.
@@ -57,7 +72,8 @@ Coverage is tracked across multiple reads: two reads of lines 1–100 and 101–
57
72
 
58
73
  Override for a single edit: `/lens-allow-edit <path>`
59
74
 
60
- Configure behavior with `--no-read-guard` to disable entirely, or set mode to `warn` instead of `block`.
75
+ Configure behavior with `--no-read-guard` to disable it entirely, or use the
76
+ read-guard configuration to select `warn` instead of `block` where supported.
61
77
 
62
78
  ### Module Report + Read Symbol (Read Substitute)
63
79
 
@@ -316,9 +332,9 @@ pi-lens ships an MCP (Model Context Protocol) server so Claude Code — or any M
316
332
  | Layer | MCP tools | What they expose |
317
333
  |---|---|---|
318
334
  | **Per-edit** | `pilens_analyze`, `pilens_lsp_diagnostics`, `pilens_lsp_navigation`, `pilens_ast_grep_search`, `pilens_ast_grep_replace`, `pilens_module_report`, `pilens_read_symbol` | The fast pipeline (format → autofix → LSP diagnostics → parallel runners) plus the structured read-substitute pair. `analyze` accepts `mode: warm \| fresh` — `warm` reuses the server's in-process LSP, `fresh` forks a worker that loads freshly-built code from disk so the result reflects the latest commit. |
319
- | **Per-turn** | `pilens_turn_end` | Drives the **real** `handleTurnEnd` (knip incremental, jscpd delta, dep-circular, cascade, tests, actionable+code-quality warnings) — not a re-implementation. Caller-supplied edited files are auto-registered into turn-state via `addModifiedRange`. |
320
- | **Per-session** | `pilens_session_start` | Drives the **real** `handleSessionStart` — full jscpd/knip/madge/govulncheck/gitleaks/trivy scans + complexity baselines + LSP warm + the **error-debt baseline** (tests/build pass-state) that powers green→red regression detection. |
321
- | **Project / observability** | `pilens_project_scan`, `pilens_diagnostics`, `pilens_health`, `pilens_latency`, `pilens_symbol_search` | Cheap project-wide scans, cached diagnostic state, latency telemetry, ranked identifier search (BM25 over the persisted word index — see [docs/word-index.md](word-index.md)). Cross-file blast radius now lives in `pilens_module_report`'s `blastRadius` option. |
335
+ | **Per-turn** | `pilens_turn_end` | Drives the **real** `handleTurnEnd` (knip incremental, dep-circular, cascade, tests, actionable+code-quality warnings) — not a re-implementation. Caller-supplied edited files are auto-registered into turn-state via `addModifiedRange`. |
336
+ | **Per-session** | `pilens_session_start` | Drives the **real** `handleSessionStart` — full jscpd/knip/madge/govulncheck/gitleaks/trivy scans + complexity baselines + LSP warm. The error-debt baseline is not currently populated by the production session-start path. |
337
+ | **Project / observability** | `pilens_project_scan`, `pilens_diagnostics`, `pilens_health`, `pilens_latency`, `pilens_symbol_search` | Cheap project-wide scans, cached diagnostic state, latency telemetry, ranked identifier search (BM25 over the persisted word index — see [docs/word-index.md](word-index.md)). Cross-file blast radius now lives in `pilens_module_report`'s `blastRadius` option. `pilens_health` (and its pi-side `/lens-health` counterpart) also reports a bounded, process-local **degradation ledger** — trust refusals, mode suppressions, LSP breaker trips, formatter skips/failures, TypeScript/word-index/review-graph/project-snapshot idle evictions, WASM aborts, and diagnostics-timeout tallies — so silently degraded behavior stays visible instead of vanishing into a log. |
322
338
  | **Lifecycle / loop** | `pilens_rebuild` | Runs `npm run build:dist` so `pilens_analyze mode=fresh` reflects the latest commit. Makes the review loop self-contained: commit → `pilens_rebuild` → `pilens_analyze mode=fresh` → `pilens_latency`. |
323
339
 
324
340
  **Honest limits** (live-tested, documented in `mcp.md`):
@@ -341,4 +357,18 @@ claude mcp add --scope user pi-lens \
341
357
  -- node <repo>/dist/mcp/server.js
342
358
  ```
343
359
 
360
+ **Hooks** (`settings.json`) close the loop: PostToolUse = per-edit, Stop = per-turn.
361
+
362
+ ```json
363
+ { "hooks": {
364
+ "PostToolUse": [
365
+ { "matcher": "Edit|Write",
366
+ "hooks": [ { "type": "command", "command": "pi-lens-analyze --hook" } ] } ],
367
+ "Stop": [
368
+ { "hooks": [ { "type": "command", "command": "pi-lens-analyze --turn-end", "timeout": 60 } ] } ]
369
+ } }
370
+ ```
371
+
372
+ The per-edit hook falls back to a cold local analysis when no server is up; the `Stop` hook is **warm-server-only** because only the server process owns the session state and pending turn work. It skips with a single stderr line when unavailable. Workspace IPC requests are ordered, so a timed-out PostToolUse client cannot let `Stop` overtake analysis still running in the server. `SubagentStop` is deliberately not registered because subagent edits already reach turn-state through PostToolUse.
373
+
344
374
  The full design + tier-by-tier progress (and known limits) lives in [`docs/mcp.md`](docs/mcp.md). Status: **experimental** — the foundation is solid (transport, warm LSP, lifecycle handlers wired), but the surface is still maturing. Use the pi extension for production agent work; reach for the MCP server for debugging, dogfooding, and direct Claude Code access.
@@ -1,6 +1,42 @@
1
1
  # Configuration
2
2
 
3
- pi-lens reads optional user preferences from `~/.pi-lens/config.json` (`%USERPROFILE%\\.pi-lens\\config.json` on Windows). Unknown keys are ignored, and missing or invalid config falls back to defaults.
3
+ pi-lens reads optional user preferences from `~/.pi-lens/config.json` (`%USERPROFILE%\\.pi-lens\\config.json` on Windows). An unrecognized top-level key is logged once (to surface a typo like `lps` for `lsp`) and then ignored; `$schema` is always allowed for editor JSON-schema association. Missing or invalid config falls back to defaults.
4
+
5
+ ## Every toggle, both ways
6
+
7
+ Each runtime toggle is settable from the CLI *and* from `config.json`. The two are driven by one declarative registry (`clients/lens-flag-registry.ts`), so neither surface can gain a toggle the other lacks.
8
+
9
+ | CLI flag | `config.json` key | Default |
10
+ | --- | --- | --- |
11
+ | `--no-lens` | `lens.enabled` | `true` |
12
+ | `--no-lsp` | `lsp.enabled` | `true` |
13
+ | `--no-tests` | `tests.enabled` | `true` |
14
+ | `--no-delta` | `delta.enabled` | `true` |
15
+ | `--no-opengrep` | `opengrep.enabled` | `true` |
16
+ | `--no-read-guard` | `readGuard.enabled` | `true` |
17
+ | `--no-autoformat` | `format.enabled` | `true` |
18
+ | `--no-autofix` | `autofix.enabled` | `true` |
19
+ | `--no-lens-context` | `contextInjection.enabled` | `true` |
20
+ | `--lens-guard` | `guard.enabled` | `false` |
21
+ | `--immediate-format` | `format.mode` (`"immediate"`) | `"deferred"` |
22
+ | `--lens-turn-summary` | `turnSummary.enabled` | `false` |
23
+ | `--lens-actionable-warnings` | `actionableWarnings.enabled` | `false` |
24
+ | `--lens-actionable-warning-actions` | `actionableWarnings.includeLspCodeActions` | `false` |
25
+ | `--lens-actionable-warning-autofix` | `actionableWarnings.autoFix.enabled` | `false` |
26
+ | `--lens-actionable-warning-all` | `actionableWarnings.deltaOnly` (`false`) | `true` |
27
+ | `--lens-compact-tool-line` | `ui.compactToolLine` | `false` |
28
+
29
+ Keys are positive (`"enabled": true` means the feature runs), so a `--no-*` flag corresponds to setting its key `false`. A `no-*` flag on the command line is a one-way switch: it can disable, never re-enable, so `--no-lsp` wins over `lsp.enabled: true` but nothing on the CLI overrides `lsp.enabled: false`. Set the key back to `true` to re-enable.
30
+
31
+ Resolution order for a single toggle, highest first:
32
+
33
+ 1. Environment variable, where one is bound (`PI_LENS_NO_CONTEXT_INJECTION=1`).
34
+ 2. The CLI flag.
35
+ 3. The nearest `.pi-lens.json` that defines the key, for the three mutation controls only (see [Mutation controls](#mutation-controls)).
36
+ 4. `~/.pi-lens/config.json`.
37
+ 5. The built-in default.
38
+
39
+ ## Examples
4
40
 
5
41
  Hide the diagnostics widget by default, run formatting immediately after write/edit tool calls instead of at `agent_end`, and enable actionable warnings with conservative autofix:
6
42
 
@@ -41,14 +77,30 @@ Hide the diagnostics widget by default, run formatting immediately after write/e
41
77
 
42
78
  `contextInjection.enabled` (default `true`) controls whether pi-lens prepends automatic findings — session-start guidance, turn-end findings, and test findings — into the next model turn. Set it to `false` (or use `--no-lens-context` / `PI_LENS_NO_CONTEXT_INJECTION=1` / `/lens-context-toggle`) to keep tools, LSP, read-guard, and formatting running while avoiding the prompt-cache invalidation that injected messages cause in long, cache-sensitive sessions. Findings are still cached, so `lens_diagnostics` and `/lens-health` keep working.
43
79
 
44
- `actionableWarnings.enabled` gates the turn_end report. `includeLspCodeActions` fetches LSP code actions for each warning (requires an active language server). `deltaOnly` (default `true`) limits the report to lines touched in the current turn. `autoFix.enabled` applies conservative LSP quickfixes at `agent_end`; `autoFix.maxFixes` caps the number applied per turn (default `5`).
80
+ `actionableWarnings.enabled` gates the turn_end report. `includeLspCodeActions` fetches LSP code actions for each warning (requires an active language server). `deltaOnly` (default `true`) limits the report to lines touched in the current turn. `autoFix.enabled` applies conservative LSP quickfixes at `agent_end`; `autoFix.maxFixes` caps the number applied per turn (default `5`, must be a non-negative whole number). `maxFixes: 0` keeps the report and applies nothing, which is a useful halfway step before enabling `autoFix` for real. Unlike the toggles in the table above there is no CLI counterpart, since it takes a number rather than being on or off.
45
81
 
46
82
  `ignore` is an array of gitignore-style glob patterns excluded from pi-lens scans across **every** project — the global counterpart to the per-project `.pi-lens.json` `ignore` below. Precedence is lowest: a project `.gitignore` or `.pi-lens.json` (including a `!negation`) overrides it, so you can globally hide e.g. `scratch/**` and still re-include it in one repo.
47
83
 
84
+ Turn subsystems off globally instead of retyping flags every session:
85
+
86
+ ```json
87
+ {
88
+ "lsp": { "enabled": false },
89
+ "tests": { "enabled": false },
90
+ "opengrep": { "enabled": false },
91
+ "readGuard": { "enabled": false },
92
+ "guard": { "enabled": true }
93
+ }
94
+ ```
95
+
96
+ `lens.enabled: false` starts every session with pi-lens off (the `--no-lens` equivalent); `/lens-toggle` still re-enables it for one session. `lsp.enabled: false` falls back to language-specific checkers such as pyright. `tests.enabled: false` skips the on-write test runner. `delta.enabled: false` reports every diagnostic rather than only ones introduced this turn. `opengrep.enabled: false` detaches the Opengrep security scanner. `readGuard.enabled: false` turns off the read-before-edit monitor. `guard.enabled: true` opts into the experimental commit/push blocker.
97
+
48
98
  ## Project Config
49
99
 
50
100
  In addition to the user-level `~/.pi-lens/config.json` above, pi-lens reads a per-project `.pi-lens.json` (or `pi-lens.json`) at the project root. Walked upward from the cwd, so a monorepo can keep the config at the repo root and have every subdir pick it up. The schema is intentionally small — only fields pi-lens actually honors:
51
101
 
102
+ Note that most toggles from the table above are **user-level only**. Of them, a project config honors just the three [mutation controls](#mutation-controls) (`format.enabled`, `autofix.enabled`, `actionableWarnings.autoFix.enabled`). Putting a user-level toggle such as `"lsp": { "enabled": false }` in a `.pi-lens.json` is **not** honored at project scope; pi-lens now logs a one-time warning saying so rather than dropping it silently, so you get a signal instead of a setting that quietly does nothing. Set it in `~/.pi-lens/config.json` or pass `--no-lsp` instead. A genuinely unrecognized key (a typo) is likewise logged once. Foreign namespaces that a shared `.pi-lens.json` legitimately carries for the LSP loader (`servers`, `serverOverrides`, `disabledServers`, `warmFiles`) and `$schema` are tolerated without warning.
103
+
52
104
  ```json
53
105
  {
54
106
  "ignore": [
@@ -116,16 +168,58 @@ Note: `maxProjectFiles` (below) is discovered differently — via an upward walk
116
168
 
117
169
  ### `rules`
118
170
 
119
- Per-rule threshold overrides. Currently honored:
171
+ Per-rule threshold overrides and policy filters. Currently honored:
120
172
 
121
173
  - `high-complexity.threshold` — cyclomatic complexity (default `15`)
122
174
  - `high-fan-out.threshold` — distinct function calls (default `20`)
175
+ - `<id>.disable` — disable diagnostics for the listed rule ids (output-only
176
+ filter). Same rule-id normalization as `pi-lens-ignore`: a user lists
177
+ `no-eval` once and the filter covers `no-eval`, `ast-grep:no-eval`, and
178
+ `no-eval-js`. Side effect: a rule whose real name genuinely ends in `-js`
179
+ (e.g. `prefer-js`) is conflated with its stem (`prefer`) — disabling or
180
+ selecting one also disables or selects the other.
181
+ - `<id>.select` — allowlist of rule ids; only the listed rule ids survive
182
+ filtering. Disable wins over select project-wide, even when the two lists
183
+ are configured under different keys.
184
+
185
+ The `<id>` key is a grouping label only — it does not scope which rules the
186
+ `disable`/`select` list underneath it can match. Matching is **project-wide**:
187
+ every `disable` list across every key is unioned into one drop list, and
188
+ every `select` list across every key is unioned into one allowlist. So
189
+ `"security": { "disable": ["no-eval"] }` disables `no-eval` regardless of
190
+ `security` being the rule's own id, and two keys can each contribute to the
191
+ same select union.
192
+
193
+ ```json
194
+ {
195
+ "rules": {
196
+ "high-complexity": { "threshold": 25 },
197
+ "high-fan-out": { "threshold": 30 },
198
+ "no-eval": { "disable": ["no-eval", "no-eval-js", "ast-grep:no-eval"] },
199
+ "my-rule-set": { "select": ["rule-a", "rule-b"] }
200
+ }
201
+ }
202
+ ```
203
+
204
+ **Warning:** because select is project-wide, a non-empty `select` list
205
+ *anywhere* in `rules` silences every rule not in that list, across the whole
206
+ project — including tsc/eslint findings, not just the rule types you're
207
+ thinking about when you write it. It's a big hammer; reach for `disable`
208
+ instead unless you actually want an allowlist over everything. Findings that
209
+ carry no rule id at all (an eslint parse error, for example) are exempt from
210
+ select, so an allowlist can never hide them.
211
+
212
+ Disable and select are output-only filters applied AFTER inline suppression,
213
+ disposition, and dedup — the project-level policy never widens the trusted
214
+ surface area (widget state, baseline, dedup cache stay authoritative). The
215
+ baseline still records the full unfiltered set so a project-config edit does
216
+ not corrupt delta baselines.
123
217
 
124
218
  ### `maxProjectFiles`
125
219
 
126
220
  Single scale knob (default `2000`) that a large-but-healthy repo can raise to scale five independent size budgets together instead of tripping each one separately: the project-diagnostics scanner (0.25×, default 500 files), the review graph (0.5× up to a point, default 1,000 files — see below), the startup scan (1×, default 2,000 source files), jscpd (3×, default 6,000 directory entries), and the word index (3×, default 6,000 files). Raising it (e.g. to `5000`) scales all five proportionally. Each subsystem's own environment-variable override (e.g. `PI_LENS_REVIEW_GRAPH_MAX_FILES`, `PI_LENS_STARTUP_SCAN_MAX_ENTRIES`) still takes precedence over this knob when set, and a separate `PI_LENS_MAX_PROJECT_FILES` environment variable sits below `maxProjectFiles` but above the built-in default. See `clients/project-scale.ts` for the full ratio table and precedence order.
127
221
 
128
- Unlike the other four, the review graph's budget stops scaling flatly at 0.5× once `maxProjectFiles` climbs past 4,000 — it tapers toward a 5,000-file ceiling instead of growing unbounded (#775). The binding constraint is the graph's disk-persist circuit-breaker (a 200,000-element cap in `review-graph/builder.ts` — above it the graph is never written to disk, so every session pays a full cold rebuild instead of the fast cached path engaging once); its higher per-file build cost than the other subsystems' walks is a secondary, independently-consistent reason. Below the 4,000 threshold (which covers every typical/default-sized project) it's the same flat 0.5× ratio as before. See `reviewGraph.maxFiles` below for an explicit opt-in past the taper.
222
+ Unlike the other four, the review graph's budget stops scaling flatly at 0.5× once `maxProjectFiles` climbs past 4,000 — it tapers toward a 5,000-file ceiling instead of growing unbounded (#775). Its higher per-file cold-build cost bounds this default file budget independently of the graph's disk-persist circuit-breaker, whose measured default is now 500,000 elements (#936; override with `PI_LENS_GRAPH_PERSIST_MAX_ELEMENTS`). An over-cap graph persists a centrality-ranked partial snapshot with explicit total-versus-persisted coverage; read-only orientation may use it, but incremental builds never reuse it as a complete base. Below the 4,000 threshold (which covers every typical/default-sized project) it's the same flat 0.5× ratio as before. See `reviewGraph.maxFiles` below for an explicit opt-in past the taper.
129
223
 
130
224
  ### `reviewGraph.maxFiles`
131
225
 
@@ -141,9 +235,11 @@ Explicit override for the review graph's own file budget (#775), for monorepos t
141
235
 
142
236
  ### Schema rules
143
237
 
144
- - Unknown top-level keys and unknown rule ids are ignored, so a forward-compat file with extra fields (e.g. an LSP `servers` block from `lsp.json`) won't break the parse.
238
+ - Unknown rule ids are ignored (forward-compat). Unrecognized **top-level** keys are logged once and then ignored — never fatal to the parse. The LSP namespaces a shared file legitimately carries (`servers`, `serverOverrides`, `disabledServers`, `warmFiles`) and `$schema` are tolerated silently; a user-level-only lens key placed here (e.g. `lsp`, `tests`, `delta`) is logged as "not honored at project scope"; anything else is logged as a likely typo. The raw parsed JSON is still exposed for forward-compat consumers regardless.
239
+ - Every toggle key in the table above must be a boolean, and its containing section must be an object. A wrong type is logged once and the key is treated as absent, so the flag falls through to its default rather than the whole file being rejected.
145
240
  - A malformed JSON file is logged once and treated as "no config" — your diagnostics never get blocked by a syntax error in your own config.
146
241
  - Rule thresholds must be positive finite numbers; invalid, zero, or negative values are logged once and ignored.
147
242
  - Mutation-control `enabled` values must be booleans; invalid values are logged once and ignored.
243
+ - `rules.<id>.disable` and `rules.<id>.select` must each be a non-empty array of non-empty strings; a non-array value, an empty array, or an all-whitespace array is logged once and the entry is dropped. A policy-only entry (no `threshold`) is honored. A policy entry with an invalid value still keeps any valid `threshold` alongside it.
148
244
  - The depth sub-threshold of `high-complexity` (default `6`) is intentionally not exposed; only the cyclomatic-complexity knob ships today to keep the schema tight.
149
245
  - The file is mtime-cached, so editing it takes effect on the next scan without restarting the agent.
@@ -15,13 +15,13 @@ Dispatch is diagnostics-oriented: automatic formatting and safe autofix happen i
15
15
  | Ruby | ✓ | lsp, rubocop, tree-sitter | rubocop, standardrb |
16
16
  | C/C++ | ✓ | lsp, cpp-check, tree-sitter | clang-format |
17
17
  | Shell | ✓ | lsp, shellcheck | shfmt |
18
- | Fish | ✓ | lsp, fish-indent | fish_indent |
18
+ | Fish | ✓ (fish-lsp) | lsp, fish-indent | fish_indent |
19
19
  | CSS/SCSS/Less | ✓ | lsp, stylelint | biome, prettier |
20
20
  | HTML | ✓ | lsp, htmlhint | prettier |
21
21
  | YAML | ✓ | lsp, yamllint, actionlint (GitHub workflows) | prettier |
22
22
  | JSON | ✓ | lsp | biome, prettier |
23
- | Svelte | ✓ | lsp | — |
24
- | Vue | ✓ | lsp | — |
23
+ | Svelte | ✓ | lsp | oxfmt (needs `svelte` pkg installed + config `svelte: true`) |
24
+ | Vue | ✓ | lsp | prettier, oxfmt |
25
25
  | SQL | — | sqlfluff | sqlfluff |
26
26
  | Markdown | — | spellcheck, markdownlint, vale | prettier |
27
27
  | Docker | ✓ | lsp, hadolint | — |
@@ -42,7 +42,8 @@ Dispatch is diagnostics-oriented: automatic formatting and safe autofix happen i
42
42
  | Gleam | ✓ | lsp, gleam-check | gleam format |
43
43
  | OCaml | ✓ | lsp | ocamlformat |
44
44
  | Clojure | ✓ | lsp | cljfmt |
45
- | Terraform | ✓ | lsp, tflint | terraform fmt |
45
+ | Terraform | ✓ | lsp, tflint, trivy-config (opt-in) | terraform fmt |
46
+ | Terragrunt | — | terragrunt | terragrunt hcl fmt |
46
47
  | Nix | ✓ | lsp | nixfmt |
47
48
  | TOML | ✓ | lsp, taplo | taplo |
48
- | CMake | ✓ | lsp | cmake-format |
49
+ | CMake | ✓ (cmake-language-server) | lsp | cmake-format |
@@ -18,7 +18,7 @@ regenerated docs — so this file self-populates from CI without manual copy-pas
18
18
 
19
19
  `probe-clean-signal.mjs` also runs a **drift check** (#529): it compares each
20
20
  probed server's observed `clean-behavior` against the hand-set `silentOnClean`
21
- marker in `clients/lsp/server-strategies.ts` and writes any mismatch to the
21
+ marker in `clients/lsp/wait-policy/strategies.ts` and writes any mismatch to the
22
22
  `## silentOnClean drift` section below. This is telemetry only — never a CI
23
23
  gate — because the probe is a timing-based negative observation; a mismatch
24
24
  just tells a human the marker may need updating. `unknown` observations are
@@ -150,7 +150,7 @@ the rest fill in as the nightly reaches them.
150
150
  ## silentOnClean drift (nightly-generated)
151
151
 
152
152
  Telemetry only — never a CI gate. Compares each probed server's observed
153
- `clean-behavior` against `clients/lsp/server-strategies.ts`'s `silentOnClean`
153
+ `clean-behavior` against `clients/lsp/wait-policy/strategies.ts`'s `silentOnClean`
154
154
  marker; a mismatch means the marker may need a human update (#529). `unknown`
155
155
  observations are never compared (a slow/absent server is not evidence either way).
156
156
 
package/docs/mcp.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pi-lens as an MCP server — implementation plan
2
2
 
3
- > Local working doc. **Not committed.** Tracks the design + progress for exposing
3
+ > Local working doc. Tracks the design + progress for exposing
4
4
  > pi-lens to Claude (Claude Code) as an MCP server, built so a *real review loop*
5
5
  > can be created (Claude commits → Claude measures the commit's actual impact,
6
6
  > not inferred from logs the user pastes).
@@ -17,7 +17,7 @@
17
17
 
18
18
  The host coupling is **thin**. Everything under `clients/` operates on
19
19
  `(filePath, content, cwd)` — the host SDK (`@earendil-works/pi-coding-agent`) is
20
- imported **only** in `index.ts` (the pi adapter), `commands/`, and tests.
20
+ imported **only** in `index.ts` (the pi adapter) and tests.
21
21
 
22
22
  Confirmed reuse points:
23
23
 
@@ -244,12 +244,12 @@ Initial assumption ("knip/jscpd are booboo-only") was **wrong**. Verified:
244
244
  |-------|---------|------|
245
245
  | per-edit | `dispatchLintWithResult` | LSP, tree-sitter, ast-grep, fact-rules, biome/ruff/eslint/oxlint |
246
246
  | per-turn | `handleTurnEnd` (`runtime-turn.ts`) | **knip** (`:298`), **jscpd** (incremental, `getFilesForJscpd`), **madge/dep circular** (`:426`), **cascade merge** (`:175`), **tests** (`:461`), actionable/code-quality warnings aggregation, project-diagnostics delta |
247
- | per-session | `handleSessionStart` (`runtime-session.ts`) | **jscpd full scan** (`:505`), knip, type-coverage, dep, govulncheck, gitleaks, todo, complexity baselines, dominant-language **LSP warm** (#203), **error-debt baseline** (tests/build pass-state) |
247
+ | per-session | `handleSessionStart` (`runtime-session.ts`) | **jscpd full scan** (`:505`), knip, type-coverage, dep, govulncheck, gitleaks, todo, complexity baselines, dominant-language **LSP warm** (#203). The production path does not currently populate the error-debt baseline. |
248
248
 
249
- The MCP server invokes **none** of the lifecycle handlers — only the per-edit
250
- layer. That is precisely why knip / jscpd / cascade / actionable+code-quality
251
- warnings / baselines are all absent, and why the first analyze (and every
252
- `fresh`) pays a cold LSP (no session-start warm ran).
249
+ The initial MCP implementation invoked **none** of the lifecycle handlers —
250
+ only the per-edit layer. The shipped server now exposes `pilens_session_start`
251
+ and `pilens_turn_end`, which drive the real handlers; `fresh` analysis still
252
+ pays a cold LSP because it starts a new worker without session-start warming.
253
253
 
254
254
  ## Revised recommendation — drive the real lifecycle, don't re-plumb
255
255
 
@@ -272,7 +272,8 @@ Rather than re-implementing knip/jscpd/cascade/warnings as bespoke MCP tools,
272
272
  **run pi's own handlers**:
273
273
 
274
274
  - `pilens_session_start` (or auto-init on first call) → `handleSessionStart` →
275
- jscpd/knip/type-cov/dep full scan + **error-debt baseline** + LSP warm (also
275
+ jscpd/knip/type-cov/dep full scan + LSP warm (the error-debt baseline is not
276
+ currently populated by the production session-start path; this also
276
277
  fixes D at the source).
277
278
  - `pilens_turn_end` → `handleTurnEnd` → knip/jscpd incremental + cascade + dep +
278
279
  tests + the actionable/code-quality aggregation.
@@ -281,12 +282,13 @@ Rather than re-implementing knip/jscpd/cascade/warnings as bespoke MCP tools,
281
282
  This reconstructs the genuine **edit → turn → session** loop and answers the
282
283
  knip/jscpd/cascade/warnings questions "for free" (same code pi runs). Cost: wire
283
284
  the `deps` bundle the handlers need — `loadBootstrapClients()` (host-neutral) +
284
- `getFlag`/`notify` stubs + a `RuntimeCoordinator`. `index.ts`'s `session_start`/
285
- `turn_end` wiring is the exact template; coupling stays thin.
285
+ `getFlag`/`notify` stubs + a `RuntimeCoordinator`. This was the original wiring
286
+ cost; `index.ts`'s `session_start`/`turn_end` wiring remains the exact template
287
+ and the shipped `clients/mcp/session.ts` keeps the coupling thin.
286
288
 
287
- The killer unlock: with the **error-debt baseline** from session_start, the MCP
288
- can report "did this change flip tests/build green→red" — the regression delta
289
- pitched as the real debug signal, currently impossible because no baseline runs.
289
+ An error-debt baseline would allow the MCP to report whether a change flipped
290
+ tests/build from green to red, but the production session-start path does not
291
+ currently populate that baseline, so this regression delta is not available.
290
292
 
291
293
  ### Plan: Tier 1 then Tier 2
292
294
 
@@ -335,9 +337,8 @@ needed for `fresh` (new process) and for files outside the warmed dominant langu
335
337
  session unit tests; live `pilens_session_start` smoke confirmed end-to-end.
336
338
  - This exposes the previously-absent layers: knip dead-code, jscpd duplication,
337
339
  dep-circular, tests, cascade, actionable/code-quality aggregation (turn_end);
338
- LSP warm + error-debt + complexity baselines + project scans (session_start).
339
- - **The green→red delta**: session_start sets `runtime.errorDebtBaseline`
340
- (tests/build pass-state); turn_end writes the pending check against it.
340
+ LSP warm + complexity baselines + project scans (session_start). The
341
+ error-debt baseline remains unpopulated by the production session-start path.
341
342
  - [ ] Tier 2 follow-ups: have warm `pilens_analyze` auto-register edited files into
342
343
  turn-state (so `turn_end` needs no explicit file list); surface the error-debt
343
344
  green→red delta directly in the turn_end result; let session_start optionally
@@ -377,13 +378,18 @@ be exercised + debugged directly through Claude Code without running pi.
377
378
  Wire it in Claude Code `settings.json`:
378
379
 
379
380
  ```json
380
- { "hooks": { "PostToolUse": [
381
- { "matcher": "Edit|Write",
382
- "hooks": [ { "type": "command", "command": "pi-lens-analyze --hook" } ] } ] } }
381
+ { "hooks": {
382
+ "PostToolUse": [
383
+ { "matcher": "Edit|Write",
384
+ "hooks": [ { "type": "command", "command": "pi-lens-analyze --hook" } ] } ],
385
+ "Stop": [
386
+ { "hooks": [ { "type": "command", "command": "pi-lens-analyze --turn-end", "timeout": 60 } ] } ]
387
+ } }
383
388
  ```
384
389
 
385
390
  (the cold-LSP fix means the type-check is honestly reported as skipped, not a
386
- false clean; the agent pulls `pilens_analyze` warm when it wants types.)
391
+ false clean; the agent pulls `pilens_analyze` warm when it wants types. The
392
+ `Stop` half is the per-turn pass — see the bullet below.)
387
393
 
388
394
  - [ ] **booboo** full-codebase review tool (`/lens-booboo` → handleBooboo:
389
395
  complexity, AI-slop, TODOs, dead-code, dupes, type-coverage).
@@ -409,6 +415,34 @@ be exercised + debugged directly through Claude Code without running pi.
409
415
  project. 5 IPC unit tests (path stability, named-pipe round-trip, no-server +
410
416
  error → undefined fallback); live-proven (server "warm analyze" log fired,
411
417
  bin returned the diagnostic). Removes the one real weakness of the push half.
418
+ - [x] **Stop hook → per-turn pass** (#538) — the `pi-lens-analyze` bin gains a
419
+ turn-end mode (`--turn-end`, or a Claude Code `Stop` payload on stdin), the
420
+ analogue of pi's `agent_end`: incremental knip/madge, dep-circular,
421
+ cascade-to-dependents, tests, actionable-warnings aggregation. PostToolUse has
422
+ already accumulated the edited files into turn-state by the time `Stop` fires,
423
+ so the hook passes no files and clears any inherited pi `sessionId` — turn-
424
+ end's stale-session eviction leaves the registered worklist alone. The request is a
425
+ tagged route (`{route:"turn-end"}`, own schema version) on the **workspace**
426
+ socket, not the PID-scoped one: a Stop hook knows its cwd, never the server's
427
+ pid. It rides in ahead of the parse, so it inherits the #535 build-staleness
428
+ gate for free, and an untagged analyze request on the same socket is byte-for-
429
+ byte unchanged. All workspace IPC requests share one server-side queue, so a
430
+ timed-out PostToolUse client cannot let `Stop` overtake analysis still running
431
+ in the server, and concurrent turn-ends cannot race the turn-state clear.
432
+ **Warm-only, no cold fallback**: only the server process owns the session state
433
+ and pending turn work, so a local pass would report a false clean — no warm
434
+ server means one stderr line, silent stdout, exit 0.
435
+ The client waits 55s so it gives up inside Claude Code's 60s hook timeout.
436
+ `SubagentStop` is deliberately NOT registered: subagent edits already fire
437
+ PostToolUse into the shared turn-state, the consume bridges are one-shot (a
438
+ subagent pass would eat the main agent's findings into a transcript nobody
439
+ reads), and the fan-out would multiply the heavy pass. Visibility, honestly:
440
+ Stop-hook stdout is user-visible in transcript mode (Ctrl-R), NOT model
441
+ context — blockers still gate commits through the retained lens-guard record,
442
+ and a `decision:"block"` render is a follow-up. Tests run fire-and-forget
443
+ inside turn-end, so the `Tests:` section you see is the *previous* turn's
444
+ failures. Unit, bin, and live-route smoke tests cover transport, ordering,
445
+ rendering, and spawned-server behavior.
412
446
 
413
447
  ## Transport decision — RESOLVED: hand-roll (zero new deps)
414
448
 
@@ -6,7 +6,7 @@ server's `initialize` handshake. Generated by `node scripts/server-capabilities.
6
6
  absent on the generating host are listed under *Unavailable* — run in a
7
7
  provisioned environment (the nightly) to capture those rows.
8
8
 
9
- _Last generated: 2026-07-28 on linux; 30 servers captured, 11 unavailable._
9
+ _Last generated: 2026-08-14 on linux; 29 servers captured, 14 unavailable._
10
10
 
11
11
  ## Diagnostic mode + navigation/edit operations
12
12
 
@@ -19,7 +19,7 @@ Legend: ✓ advertised, · not. **mode** = document diagnostics (`pull` = `textD
19
19
  | clojure | push-only | · | ✓ | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 62 |
20
20
  | csharp | pull | ✓ | ✓ | ✓ | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 0 |
21
21
  | css | pull | · | ✓ | · | · | ✓ | ✓ | · | ✓ | · | ✓ | ✓ | · | · | 0 |
22
- | dart | push-only | · | ✓ | ✓ | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 16 |
22
+ | dart | push-only | · | ✓ | ✓ | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 18 |
23
23
  | deno | pull | · | ✓ | ✓ | · | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | 2 |
24
24
  | docker | push-only | · | ✓ | · | · | · | ✓ | ✓ | ✓ | · | · | ✓ | · | · | 0 |
25
25
  | expert | push-only | · | ✓ | · | · | ✓ | ✓ | · | ✓ | ✓ | ✓ | · | · | · | 2 |
@@ -59,7 +59,7 @@ Legend: ✓ advertised, · not. **mode** = document diagnostics (`pull` = `textD
59
59
  - **docker**: codeActionProvider, completionProvider, definitionProvider, documentFormattingProvider, documentHighlightProvider, documentLinkProvider, documentOnTypeFormattingProvider, documentRangeFormattingProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, renameProvider, signatureHelpProvider, textDocumentSync
60
60
  - **expert**: codeActionProvider, codeLensProvider, completionProvider, definitionProvider, documentFormattingProvider, documentSymbolProvider, executeCommandProvider, experimental, hoverProvider, referencesProvider, textDocumentSync, workspace, workspaceSymbolProvider
61
61
  - **fsharp**: callHierarchyProvider, codeActionProvider, codeLensProvider, completionProvider, definitionProvider, documentFormattingProvider, documentHighlightProvider, documentRangeFormattingProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, implementationProvider, inlayHintProvider, inlineValueProvider, referencesProvider, renameProvider, selectionRangeProvider, semanticTokensProvider, signatureHelpProvider, textDocumentSync, typeDefinitionProvider, workspaceSymbolProvider
62
- - **gleam**: codeActionProvider, completionProvider, definitionProvider, documentFormattingProvider, documentHighlightProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, referencesProvider, renameProvider, signatureHelpProvider, textDocumentSync, typeDefinitionProvider
62
+ - **gleam**: codeActionProvider, completionProvider, definitionProvider, documentFormattingProvider, documentHighlightProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, referencesProvider, renameProvider, signatureHelpProvider, textDocumentSync, typeDefinitionProvider, workspace
63
63
  - **go**: callHierarchyProvider, codeActionProvider, codeLensProvider, completionProvider, definitionProvider, documentFormattingProvider, documentHighlightProvider, documentLinkProvider, documentSymbolProvider, executeCommandProvider, experimental, foldingRangeProvider, hoverProvider, implementationProvider, inlayHintProvider, referencesProvider, renameProvider, selectionRangeProvider, semanticTokensProvider, signatureHelpProvider, textDocumentSync, typeDefinitionProvider, typeHierarchyProvider, workspace, workspaceSymbolProvider
64
64
  - **html**: colorProvider, definitionProvider, diagnosticProvider, documentFormattingProvider, documentHighlightProvider, documentLinkProvider, documentRangeFormattingProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, linkedEditingRangeProvider, referencesProvider, renameProvider, selectionRangeProvider, signatureHelpProvider, textDocumentSync
65
65
  - **json**: codeActionProvider, colorProvider, diagnosticProvider, documentFormattingProvider, documentLinkProvider, documentRangeFormattingProvider, documentSymbolProvider, foldingRangeProvider, hoverProvider, selectionRangeProvider, textDocumentSync
@@ -89,7 +89,7 @@ surface, including providers pi-lens does not yet consume.
89
89
 
90
90
  - **ast-grep** (1): ast-grep.applyAllFixes
91
91
  - **clojure** (62): add-import-to-namespace, add-missing-import, add-missing-libspec, add-require-suggestion, as-to-refer, backward, backward-barf, backward-select, backward-slurp, change-coll, clean-ns, cond->if-refactor, create-function, create-test, cursor-info, cycle-coll, cycle-keyword-auto-resolve, cycle-privacy, demote-fn, destructure-keys, drag-backward, drag-forward, drag-param-backward, drag-param-forward, expand-let, extract-function, extract-to-def, forward, forward-barf, forward-select, forward-slurp, get-in-all, get-in-less, get-in-more, get-in-none, if->cond-refactor, inline-function, inline-symbol, introduce-let, kill-sexp, …
92
- - **dart** (16): dart.edit.codeAction.apply, dart.edit.sortMembers, dart.edit.organizeImports, dart.edit.fixAll, dart.edit.fixAllInWorkspace.preview, dart.edit.fixAllInWorkspace, dart.edit.sendWorkspaceEdit, refactor.perform, refactor.validate, dart.logAction, dart.refactor.add_constructor_name, dart.refactor.convert_all_formal_parameters_to_named, dart.refactor.convert_selected_formal_parameters_to_named, dart.refactor.move_selected_formal_parameters_left, dart.refactor.move_top_level_to_file, dart.refactor.remove_constructor_name
92
+ - **dart** (18): dart.edit.codeAction.apply, dart.edit.sortMembers, dart.edit.organizeImports, dart.edit.fixAll, dart.edit.fixAllInWorkspace.preview, dart.edit.fixAllInWorkspace, dart.edit.sendWorkspaceEdit, refactor.perform, refactor.validate, dart.logAction, dart.refactor.add_constructor_name, dart.refactor_add.import_prefix, dart.refactor.convert_all_formal_parameters_to_named, dart.refactor.convert_selected_formal_parameters_to_named, dart.refactor.move_selected_formal_parameters_left, dart.refactor.move_top_level_to_file, dart.refactor.remove_constructor_name, dart.refactor.remove_import_prefix
93
93
  - **deno** (2): deno.cache, deno.reloadImportRegistries
94
94
  - **expert** (2): Reindex, connectionDetails
95
95
  - **go** (47): gopls.add_dependency, gopls.add_import, gopls.add_telemetry_counters, gopls.add_test, gopls.apply_fix, gopls.assembly, gopls.change_signature, gopls.check_upgrades, gopls.client_open_url, gopls.diagnose_files, gopls.doc, gopls.edit_go_directive, gopls.extract_to_new_file, gopls.fetch_vulncheck_result, gopls.free_symbols, gopls.gc_details, gopls.generate, gopls.go_get_package, gopls.implement_interface, gopls.list_imports, gopls.list_known_packages, gopls.lsp, gopls.maybe_prompt_for_telemetry, gopls.mem_stats, gopls.modify_tags, gopls.modules, gopls.move_type, gopls.package_symbols, gopls.packages, gopls.regenerate_cgo, gopls.remove_dependency, gopls.reset_go_mod_diagnostics, gopls.run_go_work_command, gopls.run_govulncheck, gopls.run_tests, gopls.scan_imports, gopls.split_package, gopls.start_debugging, gopls.start_profile, gopls.stop_profile, …
@@ -105,8 +105,11 @@ surface, including providers pi-lens does not yet consume.
105
105
  Toolchain/binary not installed here, so capabilities weren't captured
106
106
  (many are the toolchain-gated family tracked in #241):
107
107
 
108
+ - @prisma/language-server
108
109
  - PowerShell Editor Services (pwsh Start-EditorServices.ps1 -Stdio)
109
110
  - clangd
111
+ - cmake-language-server
112
+ - fish-lsp
110
113
  - haskell-language-server
111
114
  - intelephense
112
115
  - jdtls