pi-lens 4.1.2 → 4.1.4

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 (359) hide show
  1. package/CHANGELOG.md +1308 -0
  2. package/README.md +3 -0
  3. package/config/biome/core.jsonc +11 -2
  4. package/config/dependency-cruiser-eager-allowlist.json +91 -0
  5. package/dist/clients/actionable-warnings-logger.js +18 -3
  6. package/dist/clients/actionable-warnings.js +927 -80
  7. package/dist/clients/agent-behavior-client.js +13 -4
  8. package/dist/clients/ast-grep-client.js +136 -9
  9. package/dist/clients/ast-grep-rule-manager.js +60 -5
  10. package/dist/clients/ast-grep-tool-logger.js +2 -2
  11. package/dist/clients/availability-probe-flight.js +12 -0
  12. package/dist/clients/bash-file-access.js +1 -3
  13. package/dist/clients/biome-client.js +16 -2
  14. package/dist/clients/blocker-freshness.js +34 -0
  15. package/dist/clients/bootstrap.js +509 -73
  16. package/dist/clients/bounded-cache.js +152 -12
  17. package/dist/clients/bounded-telemetry.js +115 -23
  18. package/dist/clients/build-identity.js +95 -0
  19. package/dist/clients/bundled-resource-health.js +113 -0
  20. package/dist/clients/bus-events-logger.js +2 -2
  21. package/dist/clients/bus-publish.js +3 -0
  22. package/dist/clients/cache/rule-cache.js +33 -5
  23. package/dist/clients/cache-manager.js +105 -6
  24. package/dist/clients/cache-observability.js +46 -19
  25. package/dist/clients/cargo-manifest.js +422 -0
  26. package/dist/clients/cascade-logger.js +17 -3
  27. package/dist/clients/code-quality-warnings.js +13 -3
  28. package/dist/clients/complexity-client.js +16 -5
  29. package/dist/clients/config-core/deny.js +221 -0
  30. package/dist/clients/config-core/index.js +47 -0
  31. package/dist/clients/config-core/merge.js +357 -0
  32. package/dist/clients/config-core/normalize.js +340 -0
  33. package/dist/clients/config-core/process-spec.js +248 -0
  34. package/dist/clients/config-core/provenance.js +171 -0
  35. package/dist/clients/config-core/records.js +218 -0
  36. package/dist/clients/config-core/resolve.js +125 -0
  37. package/dist/clients/config-core/safe-object.js +78 -0
  38. package/dist/clients/config-core/schema.js +167 -0
  39. package/dist/clients/config-diagnostic-codes.js +281 -0
  40. package/dist/clients/config-locations.js +160 -0
  41. package/dist/clients/config-resolve.js +789 -0
  42. package/dist/clients/config-schema.js +197 -0
  43. package/dist/clients/config-warn.js +407 -0
  44. package/dist/clients/dead-code-client.js +33 -25
  45. package/dist/clients/dead-code-logger.js +2 -2
  46. package/dist/clients/deadline-utils.js +178 -0
  47. package/dist/clients/debug-handles.js +2 -2
  48. package/dist/clients/debug-heap.js +3 -3
  49. package/dist/clients/deferred-lsp-work.js +106 -0
  50. package/dist/clients/degradation-ledger.js +166 -8
  51. package/dist/clients/demoted-finding-render.js +14 -0
  52. package/dist/clients/dependency-checker.js +28 -22
  53. package/dist/clients/deps/minimatch.js +1 -1
  54. package/dist/clients/diagnostic-line-freshness.js +12 -9
  55. package/dist/clients/diagnostic-logger.js +14 -4
  56. package/dist/clients/dispatch/collect-later-tier.js +39 -0
  57. package/dist/clients/dispatch/dispatcher.js +304 -19
  58. package/dist/clients/dispatch/fact-store.js +328 -9
  59. package/dist/clients/dispatch/integration.js +214 -107
  60. package/dist/clients/dispatch/pending-runner-findings.js +87 -0
  61. package/dist/clients/dispatch/plan.js +21 -5
  62. package/dist/clients/dispatch/runners/actionlint.js +0 -1
  63. package/dist/clients/dispatch/runners/ast-grep-napi.js +550 -77
  64. package/dist/clients/dispatch/runners/biome-check.js +0 -1
  65. package/dist/clients/dispatch/runners/cpp-check.js +0 -1
  66. package/dist/clients/dispatch/runners/credo.js +0 -1
  67. package/dist/clients/dispatch/runners/cue-vet.js +0 -1
  68. package/dist/clients/dispatch/runners/dart-analyze.js +0 -1
  69. package/dist/clients/dispatch/runners/detekt.js +0 -1
  70. package/dist/clients/dispatch/runners/dotnet-build.js +0 -1
  71. package/dist/clients/dispatch/runners/elixir-check.js +0 -1
  72. package/dist/clients/dispatch/runners/eslint.js +5 -2
  73. package/dist/clients/dispatch/runners/fact-rules.js +0 -1
  74. package/dist/clients/dispatch/runners/fish-indent.js +0 -1
  75. package/dist/clients/dispatch/runners/gleam-check.js +0 -1
  76. package/dist/clients/dispatch/runners/go-vet.js +1 -3
  77. package/dist/clients/dispatch/runners/golangci-lint.js +0 -1
  78. package/dist/clients/dispatch/runners/hadolint.js +0 -1
  79. package/dist/clients/dispatch/runners/helm-lint.js +16 -4
  80. package/dist/clients/dispatch/runners/helm-render.js +54 -10
  81. package/dist/clients/dispatch/runners/htmlhint.js +0 -1
  82. package/dist/clients/dispatch/runners/index.js +1 -3
  83. package/dist/clients/dispatch/runners/javac.js +0 -1
  84. package/dist/clients/dispatch/runners/ktlint.js +0 -1
  85. package/dist/clients/dispatch/runners/lsp.js +37 -2
  86. package/dist/clients/dispatch/runners/markdownlint.js +4 -2
  87. package/dist/clients/dispatch/runners/mypy.js +0 -1
  88. package/dist/clients/dispatch/runners/oxlint.js +24 -22
  89. package/dist/clients/dispatch/runners/php-lint.js +0 -1
  90. package/dist/clients/dispatch/runners/phpstan.js +0 -1
  91. package/dist/clients/dispatch/runners/prisma-validate.js +0 -1
  92. package/dist/clients/dispatch/runners/psscriptanalyzer.js +4 -1
  93. package/dist/clients/dispatch/runners/pyright.js +7 -4
  94. package/dist/clients/dispatch/runners/rubocop.js +0 -1
  95. package/dist/clients/dispatch/runners/ruff.js +0 -1
  96. package/dist/clients/dispatch/runners/rust-clippy.js +9 -6
  97. package/dist/clients/dispatch/runners/shellcheck.js +0 -1
  98. package/dist/clients/dispatch/runners/shfmt.js +0 -1
  99. package/dist/clients/dispatch/runners/spellcheck.js +0 -1
  100. package/dist/clients/dispatch/runners/spotbugs.js +0 -1
  101. package/dist/clients/dispatch/runners/sqlfluff.js +0 -1
  102. package/dist/clients/dispatch/runners/stylelint.js +0 -1
  103. package/dist/clients/dispatch/runners/swiftlint.js +0 -1
  104. package/dist/clients/dispatch/runners/taplo.js +0 -1
  105. package/dist/clients/dispatch/runners/terragrunt.js +0 -1
  106. package/dist/clients/dispatch/runners/tflint.js +0 -1
  107. package/dist/clients/dispatch/runners/tree-sitter.js +0 -1
  108. package/dist/clients/dispatch/runners/trivy-config.js +0 -1
  109. package/dist/clients/dispatch/runners/utils/availability-policy.js +3 -0
  110. package/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +3 -4
  111. package/dist/clients/dispatch/runners/utils/runner-helpers.js +270 -105
  112. package/dist/clients/dispatch/runners/utils/spawn-outcome.js +4 -0
  113. package/dist/clients/dispatch/runners/utils/tool-failure.js +19 -7
  114. package/dist/clients/dispatch/runners/utils/toolchain-availability.js +89 -26
  115. package/dist/clients/dispatch/runners/vale.js +0 -1
  116. package/dist/clients/dispatch/runners/yaml-rule-parser.js +51 -17
  117. package/dist/clients/dispatch/runners/yamllint.js +0 -1
  118. package/dist/clients/dispatch/runners/zig-check.js +0 -1
  119. package/dist/clients/disposition-logger.js +3 -3
  120. package/dist/clients/effective-config.js +403 -0
  121. package/dist/clients/error-class.js +23 -0
  122. package/dist/clients/event-loop-hold.js +274 -0
  123. package/dist/clients/event-loop-monitor.js +66 -1
  124. package/dist/clients/extension-log.js +2 -2
  125. package/dist/clients/feature-hints.js +2 -1
  126. package/dist/clients/file-time.js +6 -1
  127. package/dist/clients/file-utils.js +266 -13
  128. package/dist/clients/finding-delivery-gate.js +55 -13
  129. package/dist/clients/format-service.js +6 -1
  130. package/dist/clients/formatters.js +303 -104
  131. package/dist/clients/freshness-cadence.js +17 -0
  132. package/dist/clients/generated-artifacts.js +114 -19
  133. package/dist/clients/generation-guard.js +4 -9
  134. package/dist/clients/git-guard.js +198 -48
  135. package/dist/clients/git-tracked-ignore.js +32 -1
  136. package/dist/clients/go-client.js +39 -0
  137. package/dist/clients/govulncheck-client.js +5 -1
  138. package/dist/clients/gradle-ktfmt-style.js +252 -0
  139. package/dist/clients/gzip-stage-write.js +7 -0
  140. package/dist/clients/hashline-anchor.js +424 -0
  141. package/dist/clients/hook-budgets.js +76 -0
  142. package/dist/clients/host-edit-normalize.js +5 -2
  143. package/dist/clients/host-ports.js +1 -1
  144. package/dist/clients/installer/index.js +200 -84
  145. package/dist/clients/installer/managed-tool-refresh.js +3 -1
  146. package/dist/clients/instance-reaper.js +108 -243
  147. package/dist/clients/instance-registry-lock.js +145 -0
  148. package/dist/clients/instance-registry.js +435 -122
  149. package/dist/clients/jscpd-client.js +6 -1
  150. package/dist/clients/language-profile.js +4 -2
  151. package/dist/clients/language-registry.js +595 -0
  152. package/dist/clients/latency-logger.js +179 -3
  153. package/dist/clients/ledger-bounds.js +13 -0
  154. package/dist/clients/lens-config.js +141 -30
  155. package/dist/clients/lens-engine.js +30 -37
  156. package/dist/clients/lens-flag-registry.js +67 -6
  157. package/dist/clients/lens-map.js +3 -1
  158. package/dist/clients/log-cleanup.js +2 -2
  159. package/dist/clients/lsp/aggregation.js +3 -1
  160. package/dist/clients/lsp/cascade-tier.js +4 -0
  161. package/dist/clients/lsp/client.js +672 -49
  162. package/dist/clients/lsp/config.js +504 -156
  163. package/dist/clients/lsp/diagnostic-binding.js +10 -5
  164. package/dist/clients/lsp/edits.js +15 -2
  165. package/dist/clients/lsp/index.js +1179 -247
  166. package/dist/clients/lsp/jvm-runtime.js +5 -0
  167. package/dist/clients/lsp/language.js +18 -169
  168. package/dist/clients/lsp/launch.js +38 -9
  169. package/dist/clients/lsp/pending-aux-coverage.js +113 -12
  170. package/dist/clients/lsp/server.js +426 -160
  171. package/dist/clients/lsp/session-roots.js +192 -0
  172. package/dist/clients/lsp/spawn-history.js +2 -7
  173. package/dist/clients/lsp/tsserver-sync.js +9 -2
  174. package/dist/clients/lsp/workspace-diagnostics-cache.js +17 -7
  175. package/dist/clients/lsp/workspace-sweep-hold.js +32 -23
  176. package/dist/clients/lsp-mutation.js +179 -23
  177. package/dist/clients/map-with-concurrency.js +36 -0
  178. package/dist/clients/mcp/analyze.js +45 -10
  179. package/dist/clients/mcp/session.js +19 -17
  180. package/dist/clients/memory-sampler.js +28 -1
  181. package/dist/clients/message-end-attribution.js +30 -0
  182. package/dist/clients/metrics-history.js +21 -4
  183. package/dist/clients/middle-man-analysis.js +2 -4
  184. package/dist/clients/module-report.js +20 -45
  185. package/dist/clients/mutating-tool.js +651 -0
  186. package/dist/clients/mutation-attribution.js +368 -0
  187. package/dist/clients/mutation-bridge.js +240 -0
  188. package/dist/clients/ndjson-logger.js +247 -20
  189. package/dist/clients/observed-mutation-sources.js +101 -0
  190. package/dist/clients/observed-mutation.js +1215 -0
  191. package/dist/clients/opaque-mutation-scan.js +300 -40
  192. package/dist/clients/opengrep-config.js +4 -0
  193. package/dist/clients/package-manager.js +201 -44
  194. package/dist/clients/partial-edit-apply.js +359 -80
  195. package/dist/clients/path-attribution-telemetry.js +23 -7
  196. package/dist/clients/path-keyed-map.js +35 -3
  197. package/dist/clients/path-utils.js +460 -13
  198. package/dist/clients/persist-debounce.js +8 -1
  199. package/dist/clients/php-cs-fixer-config.js +114 -0
  200. package/dist/clients/pipeline.js +77 -24
  201. package/dist/clients/probe-home-state.js +228 -0
  202. package/dist/clients/process-bridge.js +66 -0
  203. package/dist/clients/process-singletons.js +210 -0
  204. package/dist/clients/process-snapshot.js +68 -0
  205. package/dist/clients/project-diagnostics/fresh-fetch.js +4 -3
  206. package/dist/clients/project-diagnostics/runner-adapters/madge.js +2 -1
  207. package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +27 -3
  208. package/dist/clients/project-diagnostics/scanner.js +61 -24
  209. package/dist/clients/project-lens-config.js +393 -122
  210. package/dist/clients/project-snapshot.js +85 -35
  211. package/dist/clients/python-environment.js +217 -0
  212. package/dist/clients/python-provenance.js +639 -0
  213. package/dist/clients/quiet-window.js +6 -1
  214. package/dist/clients/read-bridge.js +13 -21
  215. package/dist/clients/read-expansion.js +9 -46
  216. package/dist/clients/read-guard-logger.js +39 -6
  217. package/dist/clients/read-guard-tool-lines.js +364 -212
  218. package/dist/clients/read-guard.js +95 -7
  219. package/dist/clients/recent-touches.js +17 -5
  220. package/dist/clients/resource-sampler.js +195 -96
  221. package/dist/clients/review-graph/builder.js +752 -132
  222. package/dist/clients/review-graph/service.js +55 -3
  223. package/dist/clients/review-graph/shared-extraction-ir.js +7 -15
  224. package/dist/clients/review-graph/tsconfig-paths.js +5 -1
  225. package/dist/clients/review-graph/workspace-modules.js +10 -74
  226. package/dist/clients/review-graph-logger.js +30 -4
  227. package/dist/clients/runtime-agent-end.js +18 -2
  228. package/dist/clients/runtime-context.js +49 -16
  229. package/dist/clients/runtime-coordinator.js +93 -6
  230. package/dist/clients/runtime-session.js +169 -34
  231. package/dist/clients/runtime-tool-call.js +183 -35
  232. package/dist/clients/runtime-tool-result.js +894 -241
  233. package/dist/clients/runtime-turn.js +1264 -74
  234. package/dist/clients/rust-client.js +31 -0
  235. package/dist/clients/safe-spawn.js +191 -28
  236. package/dist/clients/sanitize.js +7 -1
  237. package/dist/clients/scratch-tree-policy.js +1 -3
  238. package/dist/clients/security-scan-client.js +51 -17
  239. package/dist/clients/session-lifecycle.js +238 -42
  240. package/dist/clients/session-start-observability.js +79 -0
  241. package/dist/clients/sessionstart-logger.js +12 -3
  242. package/dist/clients/sg-runner.js +27 -15
  243. package/dist/clients/sgconfig.js +6 -1
  244. package/dist/clients/shared-checkout-guard.js +338 -0
  245. package/dist/clients/skills-resolver.js +105 -0
  246. package/dist/clients/smells-rollup.js +2 -2
  247. package/dist/clients/spawn-output-cap.js +37 -0
  248. package/dist/clients/spawn-timeout-cooldown.js +15 -1
  249. package/dist/clients/startup-scan.js +6 -7
  250. package/dist/clients/startup-timing.js +69 -4
  251. package/dist/clients/string-utils.js +33 -0
  252. package/dist/clients/subagent-mode.js +17 -4
  253. package/dist/clients/test-runner-client.js +586 -118
  254. package/dist/clients/test-runner-delivery.js +239 -0
  255. package/dist/clients/tool-definition.js +41 -1
  256. package/dist/clients/tool-policy.js +92 -22
  257. package/dist/clients/tree-sitter-cache.js +40 -40
  258. package/dist/clients/tree-sitter-client.js +97 -53
  259. package/dist/clients/tree-sitter-logger.js +19 -3
  260. package/dist/clients/tree-sitter-query-loader.js +81 -1
  261. package/dist/clients/tree-sitter-shared.js +51 -46
  262. package/dist/clients/tree-sitter-symbol-extractor.js +28 -0
  263. package/dist/clients/typos-config.js +5 -0
  264. package/dist/clients/user-notify.js +6 -2
  265. package/dist/clients/warm-attach.js +8 -10
  266. package/dist/clients/widget-state.js +191 -26
  267. package/dist/clients/word-index-logger.js +15 -3
  268. package/dist/clients/word-index-store.js +463 -0
  269. package/dist/clients/word-index.js +815 -125
  270. package/dist/clients/workspace-topology.js +25 -1
  271. package/dist/clients/zizmor-config.js +29 -6
  272. package/dist/index.js +68577 -53950
  273. package/dist/mcp/analyze-cli.js +3 -1
  274. package/dist/mcp/build-staleness.js +8 -7
  275. package/dist/mcp/cli.js +3 -1
  276. package/dist/mcp/server.js +133 -6
  277. package/dist/scripts/lib/process-scan.mjs +583 -0
  278. package/dist/scripts/lib/skills-predicate.mjs +129 -0
  279. package/dist/tools/effective-config.js +89 -0
  280. package/dist/tools/lens-diagnostics.js +99 -24
  281. package/dist/tools/lsp-diagnostics.js +81 -85
  282. package/dist/tools/lsp-navigation.js +40 -17
  283. package/dist/tools/shared.js +0 -1
  284. package/docs/agent-guide.md +68 -3
  285. package/docs/ast-grep_rules_catalog.md +41 -10
  286. package/docs/astplayground.md +26 -17
  287. package/docs/configuration.md +222 -0
  288. package/docs/dependencies.md +3 -3
  289. package/docs/features.md +44 -5
  290. package/docs/language-coverage.md +2 -2
  291. package/docs/pi-lens-fixer.md +25 -0
  292. package/docs/pi-lens-investigator.md +25 -0
  293. package/docs/pi-lens-reviewer.md +27 -0
  294. package/docs/pi-lens-subagent.md +38 -0
  295. package/docs/pi-lens-warden.md +55 -0
  296. package/docs/public-api-stability.md +359 -0
  297. package/docs/release-qa-baseline.md +182 -0
  298. package/docs/subagent-compat.md +110 -30
  299. package/docs/tree-sitter_rules_catalog.md +2 -2
  300. package/package.json +17 -21
  301. package/rules/ast-grep-rules/rule-tests/c-no-malloc-free-test.yml +20 -0
  302. package/rules/ast-grep-rules/rule-tests/cpp-no-malloc-free-test.yml +25 -0
  303. package/rules/ast-grep-rules/rule-tests/cpp-no-printf-test.yml +19 -0
  304. package/rules/ast-grep-rules/rule-tests/go-no-fmt-println-test.yml +19 -0
  305. package/rules/ast-grep-rules/rule-tests/go-no-panic-in-lib-test.yml +17 -0
  306. package/rules/ast-grep-rules/rule-tests/go-no-underscore-func-name-test.yml +18 -0
  307. package/rules/ast-grep-rules/rule-tests/go-prefer-errors-is-test.yml +15 -0
  308. package/rules/ast-grep-rules/rule-tests/go-prefer-string-builder-test.yml +21 -0
  309. package/rules/ast-grep-rules/rule-tests/hyphenated-svg-attribute-test.yml +11 -0
  310. package/rules/ast-grep-rules/rule-tests/kotlin-no-lateinit-test.yml +17 -0
  311. package/rules/ast-grep-rules/rule-tests/kotlin-no-nullable-boolean-test.yml +15 -0
  312. package/rules/ast-grep-rules/rule-tests/kotlin-no-println-test.yml +19 -0
  313. package/rules/ast-grep-rules/rule-tests/kotlin-no-unnecessary-let-test.yml +7 -0
  314. package/rules/ast-grep-rules/rule-tests/kotlin-no-unsafe-cast-test.yml +7 -0
  315. package/rules/ast-grep-rules/rule-tests/kotlin-no-var-test.yml +7 -0
  316. package/rules/ast-grep-rules/rule-tests/kotlin-prefer-data-class-test.yml +25 -0
  317. package/rules/ast-grep-rules/rule-tests/kotlin-prefer-is-empty-test.yml +11 -0
  318. package/rules/ast-grep-rules/rule-tests/no-important-test.yml +21 -0
  319. package/rules/ast-grep-rules/rule-tests/no-raw-types-test.yml +30 -0
  320. package/rules/ast-grep-rules/rule-tests/no-string-concat-in-loop-test.yml +100 -0
  321. package/rules/ast-grep-rules/rule-tests/no-system-out-println-test.yml +7 -0
  322. package/rules/ast-grep-rules/rule-tests/prefer-string-is-empty-test.yml +7 -0
  323. package/rules/ast-grep-rules/rule-tests/python-optional-type-test.yml +9 -0
  324. package/rules/ast-grep-rules/rule-tests/reducible-list-comprehension-test.yml +11 -0
  325. package/rules/ast-grep-rules/rule-tests/ruby-symbol-to-proc-candidate-test.yml +10 -0
  326. package/rules/ast-grep-rules/rule-tests/rust-no-chars-enumerate-test.yml +7 -0
  327. package/rules/ast-grep-rules/rules/c-no-malloc-free.yml +39 -0
  328. package/rules/ast-grep-rules/rules/cpp-no-malloc-free.yml +45 -0
  329. package/rules/ast-grep-rules/rules/cpp-no-printf.yml +41 -0
  330. package/rules/ast-grep-rules/rules/go-no-fmt-println.yml +43 -0
  331. package/rules/ast-grep-rules/rules/go-no-panic-in-lib.yml +41 -0
  332. package/rules/ast-grep-rules/rules/go-no-underscore-func-name.yml +35 -0
  333. package/rules/ast-grep-rules/rules/go-prefer-errors-is.yml +40 -0
  334. package/rules/ast-grep-rules/rules/go-prefer-string-builder.yml +43 -0
  335. package/rules/ast-grep-rules/rules/hyphenated-svg-attribute.yml +32 -0
  336. package/rules/ast-grep-rules/rules/kotlin-no-lateinit.yml +37 -0
  337. package/rules/ast-grep-rules/rules/kotlin-no-nullable-boolean.yml +33 -0
  338. package/rules/ast-grep-rules/rules/kotlin-no-println.yml +42 -0
  339. package/rules/ast-grep-rules/rules/kotlin-no-unnecessary-let.yml +28 -0
  340. package/rules/ast-grep-rules/rules/kotlin-no-unsafe-cast.yml +28 -0
  341. package/rules/ast-grep-rules/rules/kotlin-no-var.yml +35 -0
  342. package/rules/ast-grep-rules/rules/kotlin-prefer-data-class.yml +66 -0
  343. package/rules/ast-grep-rules/rules/kotlin-prefer-is-empty.yml +35 -0
  344. package/rules/ast-grep-rules/rules/no-important.yml +21 -0
  345. package/rules/ast-grep-rules/rules/no-raw-types.yml +33 -0
  346. package/rules/ast-grep-rules/rules/no-string-concat-in-loop.yml +90 -0
  347. package/rules/ast-grep-rules/rules/no-system-out-println.yml +16 -0
  348. package/rules/ast-grep-rules/rules/prefer-string-is-empty.yml +11 -0
  349. package/rules/ast-grep-rules/rules/python-optional-type.yml +22 -0
  350. package/rules/ast-grep-rules/rules/reducible-list-comprehension.yml +29 -0
  351. package/rules/ast-grep-rules/rules/ruby-symbol-to-proc-candidate.yml +25 -0
  352. package/rules/ast-grep-rules/rules/rust-no-chars-enumerate.yml +19 -0
  353. package/rules/tree-sitter-queries/python/python-cross-language-method.yml +3 -3
  354. package/rules/tree-sitter-queries/python/python-hallucinated-import.yml +2 -2
  355. package/rules/tree-sitter-queries/python/python-sql-injection.yml +12 -2
  356. package/scripts/analyze-pi-lens-logs.mjs +192 -1
  357. package/scripts/install-selftest.mjs +58 -2
  358. package/scripts/lib/skills-predicate.mjs +129 -0
  359. package/scripts/rpc-load-check.mjs +3 -1
@@ -4,11 +4,12 @@
4
4
  import * as fs from "node:fs";
5
5
  import * as os from "node:os";
6
6
  import * as path from "node:path";
7
- import { minimatch } from "./deps/minimatch.js";
7
+ import { Minimatch } from "./deps/minimatch.js";
8
+ import { FRESHNESS_CADENCE_MS } from "./freshness-cadence.js";
8
9
  import { isInSpawnTimeoutCooldown, noteSpawnTimeout, } from "./spawn-timeout-cooldown.js";
9
10
  import { collectTrackedFiles, getTrackedFilesSnapshot, } from "./git-tracked-ignore.js";
10
11
  import { getGlobalIgnorePatterns, getPiLensGlobalConfigPath, } from "./lens-config.js";
11
- import { normalizeEphemeralMapKey, normalizeFilePath } from "./path-utils.js";
12
+ import { homeRelativePath, isExternalOrVendorFile, isUnderDir, normalizeEphemeralMapKey, normalizeFilePath, toProjectRelativePath, } from "./path-utils.js";
12
13
  import { findPiLensConfigInDir, findPiLensProjectConfig, loadPiLensConfigInDir, loadPiLensProjectConfig, } from "./project-lens-config.js";
13
14
  import { safeSpawnAsync } from "./safe-spawn.js";
14
15
  /**
@@ -42,27 +43,101 @@ export function getProjectDataDir(cwd) {
42
43
  .replace(/-+$/, ""); // trim trailing dashes
43
44
  return path.join(base.trim(), slug || "default");
44
45
  }
46
+ /**
47
+ * The project-data path to SHOW an agent or a human, for a file that
48
+ * {@link getProjectDataDir} owns.
49
+ *
50
+ * #2521: the turn-end actionable-warnings advisory told the agent to read a
51
+ * hardcoded `.pi-lens/cache/actionable-warnings.json`, but that spelling is
52
+ * only correct in the LEGACY arm of `getProjectDataDir` — a project with no
53
+ * `.pi-lens/` directory (the common case) stores the report under
54
+ * `~/.pi-lens/projects/<slug>/cache/`, and a `PILENS_DATA_DIR` project stores
55
+ * it somewhere else again. Agents followed the advisory literally and got
56
+ * `cat: .pi-lens/cache/actionable-warnings.json: No such file or directory`.
57
+ *
58
+ * Any instructional string that NAMES a project-data location must be built
59
+ * here, so the displayed path and the written path can never disagree. Guarded
60
+ * by `tests/clients/data-dir-display-path-sweep.test.ts`.
61
+ *
62
+ * Two output shapes, matching `toRunnerDisplayPath`'s convention
63
+ * (`clients/dispatch/runner-context.ts`) so one advisory never mixes styles:
64
+ * - under `cwd` → a `/`-separated path relative to it
65
+ * (`.pi-lens/cache/actionable-warnings.json`), which is what the legacy
66
+ * arm produces and what an agent can paste straight into a shell.
67
+ * - anywhere else → absolute, `/`-separated, and `~`-folded via
68
+ * {@link homeRelativePath} so the default `~/.pi-lens/projects/...` store
69
+ * does not leak the account name into agent context (#2440 F5).
70
+ *
71
+ * Pure string work on top of `getProjectDataDir`'s own resolution: it never
72
+ * stats the target, so it is safe to call for a file that has not been written
73
+ * yet and cannot throw on a surface whose whole job is to render a hint.
74
+ *
75
+ * The relative-or-absolute decision reuses `toProjectRelativePath`
76
+ * (`clients/path-utils.ts`) — the same shape-aware, non-stat'ing primitive
77
+ * `toRunnerDisplayPath` (`clients/dispatch/runner-context.ts`) composes for
78
+ * the analogous "relative path if under this root, else something else"
79
+ * decision — rather than a second hand-rolled `path.relative` fold. It is NOT
80
+ * `toRunnerDisplayPath` itself: that helper routes its result through
81
+ * `normalizeMapKey`, which on win32 calls `realpathSync.native()` (or, for a
82
+ * not-yet-existing path, lowercases the unresolved tail) — exactly the
83
+ * stat-and-mutate-casing behavior this function's contract above rules out.
84
+ */
85
+ export function displayProjectDataPath(cwd, ...segments) {
86
+ const absolute = path.resolve(getProjectDataDir(cwd), ...segments);
87
+ const absolutePosix = absolute.replace(/\\/g, "/");
88
+ const relative = toProjectRelativePath(absolute, cwd);
89
+ if (relative !== absolutePosix) {
90
+ return relative;
91
+ }
92
+ // `toProjectRelativePath` fell back to the (posix-ified) absolute path —
93
+ // `absolute` is not under `cwd`. Fold `~` so the default
94
+ // `~/.pi-lens/projects/...` store does not leak the account name into
95
+ // agent context (#2440 F5). Posix-ify BEFORE the fold: `homeRelativePath`
96
+ // deliberately returns a path that is not under `$HOME` unchanged,
97
+ // separators included, so a `PILENS_DATA_DIR=D:\lens-data` store would
98
+ // otherwise render with backslashes while the legacy arm above renders
99
+ // with forward ones — `absolutePosix` is already folded, so this is a
100
+ // no-op fold, not a second one.
101
+ return homeRelativePath(absolutePosix);
102
+ }
45
103
  /**
46
104
  * Machine-global pi-lens directory: `~/.pi-lens/` by default.
47
105
  *
48
- * Used for logs (latency, cascade, read-guard, tree-sitter, actionable-warnings,
49
- * sessionstart), tool binaries (`~/.pi-lens/tools/`, `~/.pi-lens/bin/`), the
50
- * cross-process instance registry (`instances.json`, #449/#525), the
51
- * auto-install probe cache, and other state that is intentionally NOT
52
- * project-scoped — it spans every project pi-lens has touched.
106
+ * Used for tool binaries (`~/.pi-lens/tools/`, `~/.pi-lens/bin/`), the
107
+ * cross-process instance registry (`instances.json`, #449/#525) and the
108
+ * orphan-backstop lease beside it, the auto-install probe cache, the
109
+ * canonical global config (`config.json`), LSP server storage (intelephense's
110
+ * index, PSES's per-PID session dir) and JVM runtimes — state that is
111
+ * intentionally NOT project-scoped, because it spans every project pi-lens
112
+ * has touched.
53
113
  *
54
114
  * Override: set `PI_LENS_HOME=/some/path` to relocate this ENTIRE root (every
55
- * caller below routes through this one function, so one env var covers all of
115
+ * caller routes through this one function, so one env var covers all of
56
116
  * them — see #525). Tests MUST set this to a per-worker temp dir in
57
117
  * `tests/support/vitest-setup.ts` rather than mocking each caller separately;
58
118
  * otherwise a test that exercises `registerInstance`/`sweepOrphans` or any
59
119
  * logger writes into the developer's REAL `~/.pi-lens` (dogfooded live: a
60
120
  * test-fixture instance survived in the real `instances.json` for 17h).
61
121
  *
122
+ * DELIBERATELY cwd-INDEPENDENT (#2506 round 3). Its sibling
123
+ * `getGlobalPiLensLogDir()` (`probe-home-state.ts`) carries the probe-home
124
+ * redirect; this one must not, because the things resolved here are shared
125
+ * machine state a session needs to KEEP: a pi session running from an agent
126
+ * worktree or a throwaway temp project must still find the tools it already
127
+ * installed and must still register in the one `instances.json` every other
128
+ * pi-lens process on the box reads. Redirecting THIS function (as round 2 of
129
+ * #2506 did) would silently give every worktree its own empty tool tree and
130
+ * its own private registry, so the reaper could never see across them — a
131
+ * worse defect than the telemetry pollution the redirect exists to stop.
132
+ *
62
133
  * Distinct from `getProjectDataDir(cwd)`, which respects `PILENS_DATA_DIR`
63
134
  * (project-scoped) and produces per-project subdirectories. Callers writing
64
135
  * project caches, snapshots, or worklogs should use `getProjectDataDir(cwd)`
65
136
  * instead — `PI_LENS_HOME` is the MACHINE-scoped sibling of that override.
137
+ * `getProjectDataDir` composes through THIS function, not the log one: a
138
+ * probe's project caches are already isolated by its own path slug, and a
139
+ * worktree session keeping its warm caches is the same "do not break the
140
+ * session" argument as the tools above.
66
141
  */
67
142
  export function getGlobalPiLensDir() {
68
143
  const override = process.env.PI_LENS_HOME?.trim();
@@ -213,19 +288,18 @@ function expandGitignorePattern(pattern) {
213
288
  return [body];
214
289
  return [body, `**/${body}`];
215
290
  }
216
- function matchesGitignorePattern(pattern, relativePath, isDirectory) {
291
+ function matchesGitignorePattern(pattern, relativePath, isDirectory, matchExpanded) {
217
292
  const candidate = stripLeadingSlashes(normalizeIgnorePath(relativePath));
218
293
  if (!candidate)
219
294
  return false;
220
295
  const candidates = isDirectory ? [candidate, `${candidate}/`] : [candidate];
221
- const options = { dot: true, nocase: process.platform === "win32" };
222
296
  return expandGitignorePattern(pattern).some((expanded) => {
223
297
  if (isDirectory && expanded.endsWith("/**")) {
224
298
  const prefix = expanded.slice(0, -3);
225
299
  if (candidate === prefix || candidate.startsWith(`${prefix}/`))
226
300
  return true;
227
301
  }
228
- return candidates.some((value) => minimatch(value, expanded, options));
302
+ return candidates.some((value) => matchExpanded(value, expanded));
229
303
  });
230
304
  }
231
305
  export function readGitignorePatterns(rootDir, layer = "gitignore") {
@@ -252,6 +326,14 @@ function ancestorDirsBetween(rootDir, targetDir) {
252
326
  return dirs;
253
327
  }
254
328
  function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
329
+ const consumedIgnoreSources = new Map();
330
+ // `signature` lets a caller that already statted the file reuse that one
331
+ // stat (#2016's class on this seam: never re-derive a value you just
332
+ // computed). Callers with no signature in hand still pay their own stat.
333
+ const rememberIgnoreSource = (filePath, signature = fileFreshnessSignature(filePath)) => {
334
+ consumedIgnoreSources.set(filePath, { path: filePath, ...signature });
335
+ };
336
+ rememberIgnoreSource(path.join(resolvedRoot, ".gitignore"));
255
337
  const nestedCache = new Map();
256
338
  // #783: layer a NESTED `.pi-lens.json`'s `ignore` field the same way a
257
339
  // nested `.gitignore` is already layered — each ancestor directory between
@@ -266,7 +348,26 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
266
348
  const patternsForDir = (dir) => {
267
349
  if (dir === resolvedRoot)
268
350
  return patterns;
351
+ const cached = nestedCache.get(dir);
352
+ const now = Date.now();
353
+ // #2071: inside the cadence window this directory's rules are frozen, so
354
+ // no stat runs and every verdict already memoized under `dir` stays
355
+ // derivable from exactly these patterns. Before this gate the freshness
356
+ // check ran per call while `patternMemo` did not, which is what let a
357
+ // fresh path and a memoized path in the same directory return opposite
358
+ // verdicts for the same rule. Externally edited nested sources are
359
+ // therefore picked up within PROJECT_IGNORE_FRESHNESS_CADENCE_MS, the
360
+ // same bound #2159 already accepted for the root sources.
361
+ // pi-authored `.gitignore` writes keep their instant path through
362
+ // `invalidateProjectIgnoreMatcherForPath`.
363
+ if (cached !== undefined &&
364
+ now - cached.checkedAtMs < PROJECT_IGNORE_FRESHNESS_CADENCE_MS) {
365
+ return cached.patterns;
366
+ }
269
367
  const gitignoreSig = gitignoreSignature(dir);
368
+ // One stat, two consumers. `rememberIgnoreSource` used to stat the same
369
+ // file a second time on the line below this one.
370
+ rememberIgnoreSource(path.join(dir, ".gitignore"), gitignoreSig);
270
371
  // #1105: gate on size too. `findPiLensConfigInDir` returns `size` alongside
271
372
  // `mtimeMs` (both from one stat), and `gitignoreSignature` reads both for
272
373
  // the nested `.gitignore`, so an mtime-preserving, length-changing edit to
@@ -274,11 +375,13 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
274
375
  const pilensInfo = findPiLensConfigInDir(dir);
275
376
  const pilensMtime = pilensInfo?.mtimeMs ?? -1;
276
377
  const pilensSize = pilensInfo?.size ?? -1;
277
- const cached = nestedCache.get(dir);
278
378
  if (cached?.gitignoreMtimeMs === gitignoreSig.mtimeMs &&
279
379
  cached?.gitignoreSize === gitignoreSig.size &&
280
380
  cached?.pilensMtimeMs === pilensMtime &&
281
381
  cached?.pilensSize === pilensSize) {
382
+ // Unchanged: re-arm the shared clock so the next window is measured
383
+ // from this check, not from the build that first populated the entry.
384
+ cached.checkedAtMs = now;
282
385
  return cached.patterns;
283
386
  }
284
387
  const nestedConfig = loadPiLensConfigInDir(dir);
@@ -287,12 +390,19 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
287
390
  ...parseGitignoreContent(nestedConfig.ignore.join("\n"), "pilens"),
288
391
  ];
289
392
  nestedCache.set(dir, {
393
+ checkedAtMs: now,
290
394
  gitignoreMtimeMs: gitignoreSig.mtimeMs,
291
395
  gitignoreSize: gitignoreSig.size,
292
396
  pilensMtimeMs: pilensMtime,
293
397
  pilensSize: pilensSize,
294
398
  patterns: nextPatterns,
295
399
  });
400
+ // #2071: drift is the SINGLE trigger. The rules under `dir` just changed,
401
+ // so every verdict computed under the superseded rules dies in the same
402
+ // step that supersedes them. `cached === undefined` is a first build, not
403
+ // a change, and has no verdicts to drop.
404
+ if (cached !== undefined)
405
+ dropVerdictsUnder(dir);
296
406
  return nextPatterns;
297
407
  };
298
408
  // Per-matcher path → pattern-verdict memo. The matcher itself is cached by
@@ -317,6 +427,44 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
317
427
  // already flagged as ignored, so it doesn't reintroduce the per-file cost
318
428
  // this memo exists to avoid for the common (not-ignored) case.
319
429
  const patternMemo = new Map();
430
+ /**
431
+ * Drop every memoized verdict at or below `subtree`, leaving `nestedCache`
432
+ * alone. `patternsForDir` calls this the moment it rebuilds a directory's
433
+ * patterns, which is why it must NOT evict the entry that rebuild just
434
+ * wrote. `invalidateSubtree` layers the eviction on top for the write-hook
435
+ * path, where the caller knows the source changed but has not re-read it.
436
+ */
437
+ function dropVerdictsUnder(subtree) {
438
+ const resolvedSubtree = path.resolve(subtree);
439
+ for (const key of patternMemo.keys()) {
440
+ const memoPath = key.slice(2);
441
+ const relative = path.relative(resolvedSubtree, memoPath);
442
+ if (!relative ||
443
+ (!relative.startsWith("..") && !path.isAbsolute(relative))) {
444
+ patternMemo.delete(key);
445
+ }
446
+ }
447
+ }
448
+ const invalidateSubtree = (subtree) => {
449
+ dropVerdictsUnder(subtree);
450
+ nestedCache.delete(path.resolve(subtree));
451
+ };
452
+ // Compile expanded gitignore globs once per matcher instance. Relative-path
453
+ // resolution remains outside this cache, so nested ignore scopes cannot leak
454
+ // verdicts between sibling trees. The instance lifetime bounds this map.
455
+ const gitignoreGlobOptions = {
456
+ dot: true,
457
+ nocase: process.platform === "win32",
458
+ };
459
+ const compiledGlobs = new Map();
460
+ const matchExpanded = (value, expanded) => {
461
+ let compiled = compiledGlobs.get(expanded);
462
+ if (compiled === undefined) {
463
+ compiled = new Minimatch(expanded, gitignoreGlobOptions);
464
+ compiledGlobs.set(expanded, compiled);
465
+ }
466
+ return compiled.match(value);
467
+ };
320
468
  // #703 perf follow-up: `normalizeEphemeralMapKey` (cheap slash-fold +
321
469
  // Windows-lowercase, zero fs I/O), NOT `normalizeMapKey` (realpath-backed).
322
470
  // This runs on every `isIgnored` call that reaches this branch — walks
@@ -343,6 +491,13 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
343
491
  return {
344
492
  rootDir: resolvedRoot,
345
493
  patterns,
494
+ getConsumedIgnoreSources: () => [...consumedIgnoreSources.values()],
495
+ refreshConsumedIgnoreSource(filePath) {
496
+ // The freshness sweep refreshes this baseline after invalidation.
497
+ if (consumedIgnoreSources.has(filePath))
498
+ rememberIgnoreSource(filePath);
499
+ },
500
+ invalidateSubtree,
346
501
  ensureTrackedIndex() {
347
502
  return collectTrackedFiles(resolvedRoot).then(() => undefined);
348
503
  },
@@ -370,7 +525,7 @@ function buildProjectIgnoreMatcher(resolvedRoot, patterns) {
370
525
  const relative = path.relative(dir, resolved);
371
526
  const normalized = normalizeIgnorePath(relative);
372
527
  for (const pattern of dirPatterns) {
373
- if (!matchesGitignorePattern(pattern, normalized, isDirectory))
528
+ if (!matchesGitignorePattern(pattern, normalized, isDirectory, matchExpanded))
374
529
  continue;
375
530
  ignored = !pattern.negated;
376
531
  layer = pattern.layer;
@@ -413,6 +568,17 @@ export function createProjectIgnoreMatcher(rootDir, extraPatterns = [], globalPa
413
568
  return buildProjectIgnoreMatcher(resolvedRoot, patterns);
414
569
  }
415
570
  const projectIgnoreMatcherCache = new Map();
571
+ /**
572
+ * Nested ignore sources are checked at most once per root per cadence window.
573
+ * Sourced from the shared leaf (`freshness-cadence.ts`) rather than owning the
574
+ * value: `project-lens-config.ts`'s no-config discovery cache (#2483 round 2)
575
+ * needs the same cadence and cannot import it FROM here, because this module
576
+ * already imports `project-lens-config.ts` (the `clients/` acyclic-imports
577
+ * rule would reject the reverse edge). Re-exported under this name so the
578
+ * existing test imports (`tests/clients/project-ignore-freshness.test.ts` and
579
+ * siblings) are unaffected.
580
+ */
581
+ export const PROJECT_IGNORE_FRESHNESS_CADENCE_MS = FRESHNESS_CADENCE_MS;
416
582
  function fileFreshnessSignature(filePath) {
417
583
  try {
418
584
  const stat = fs.statSync(filePath);
@@ -428,6 +594,12 @@ function globalConfigSignature() {
428
594
  function gitignoreSignature(rootDir) {
429
595
  return fileFreshnessSignature(path.join(rootDir, ".gitignore"));
430
596
  }
597
+ function hasIgnoreSourceDrift(sources) {
598
+ return sources.some((source) => {
599
+ const current = fileFreshnessSignature(source.path);
600
+ return current.mtimeMs !== source.mtimeMs || current.size !== source.size;
601
+ });
602
+ }
431
603
  /**
432
604
  * The project config file found by the same upward walk as the loader. Cache
433
605
  * invalidation must track the actual file found, not only a file directly under
@@ -446,6 +618,44 @@ export function getProjectIgnoreMatcher(rootDir) {
446
618
  const lensConfig = lensConfigInfo(resolvedRoot);
447
619
  const globalSig = globalConfigSignature();
448
620
  const cached = projectIgnoreMatcherCache.get(resolvedRoot);
621
+ // A path can be discovered during the previous matcher lookup. Publish only
622
+ // previously unseen sources so a walk cannot replace a pre-edit baseline.
623
+ //
624
+ // This runs BEFORE the sweep below, and the order is load-bearing. A nested
625
+ // source can only be published on a call AFTER the one that consumed it.
626
+ // With the publish second, the sweep never saw a source during the window in
627
+ // which it was discovered, yet still reset `lastIgnoreFreshnessCheckMs`, so
628
+ // the first sweep that could see it ran a FULL cadence later. Pickup was up
629
+ // to 2x cadence, not 1x: measured stale at 2 s and 3 s, fresh at 4 s. The
630
+ // baseline is protected by the `known` set, not by the ordering, so moving
631
+ // the publish earlier cannot let a walk overwrite a pre-edit baseline.
632
+ if (cached) {
633
+ const known = new Set(cached.ignoreSources.map((source) => source.path));
634
+ for (const source of cached.matcher.getConsumedIgnoreSources()) {
635
+ if (!known.has(source.path))
636
+ cached.ignoreSources.push(source);
637
+ }
638
+ }
639
+ if (cached &&
640
+ Date.now() - cached.lastIgnoreFreshnessCheckMs >=
641
+ PROJECT_IGNORE_FRESHNESS_CADENCE_MS) {
642
+ cached.lastIgnoreFreshnessCheckMs = Date.now();
643
+ if (hasIgnoreSourceDrift(cached.ignoreSources)) {
644
+ for (const source of cached.ignoreSources) {
645
+ if (hasIgnoreSourceDrift([source])) {
646
+ const sourceIndex = cached.ignoreSources.findIndex((cachedSource) => cachedSource.path === source.path);
647
+ invalidateProjectIgnoreMatcherForPath(source.path);
648
+ cached.matcher.refreshConsumedIgnoreSource(source.path);
649
+ const refreshedSource = cached.matcher
650
+ .getConsumedIgnoreSources()
651
+ .find((current) => current.path === source.path);
652
+ if (sourceIndex !== -1 && refreshedSource !== undefined) {
653
+ cached.ignoreSources.splice(sourceIndex, 1, refreshedSource);
654
+ }
655
+ }
656
+ }
657
+ }
658
+ }
449
659
  if (cached?.gitignoreMtimeMs === gitignoreSig.mtimeMs &&
450
660
  cached?.gitignoreSize === gitignoreSig.size &&
451
661
  cached?.lensConfigPath === lensConfig.path &&
@@ -463,6 +673,8 @@ export function getProjectIgnoreMatcher(rootDir) {
463
673
  const projectConfig = loadPiLensProjectConfig(resolvedRoot, lensConfig.info);
464
674
  const matcher = createProjectIgnoreMatcher(resolvedRoot, projectConfig.ignore, getGlobalIgnorePatterns());
465
675
  projectIgnoreMatcherCache.set(resolvedRoot, {
676
+ ignoreSources: [...matcher.getConsumedIgnoreSources()],
677
+ lastIgnoreFreshnessCheckMs: Date.now(),
466
678
  gitignoreMtimeMs: gitignoreSig.mtimeMs,
467
679
  gitignoreSize: gitignoreSig.size,
468
680
  lensConfigPath: lensConfig.path,
@@ -474,9 +686,50 @@ export function getProjectIgnoreMatcher(rootDir) {
474
686
  });
475
687
  return matcher;
476
688
  }
689
+ /**
690
+ * Invalidate the cached matcher state affected by a written `.gitignore`.
691
+ *
692
+ * Root changes discard the whole matcher because they change its base pattern
693
+ * set. Nested changes evict only verdicts in that directory's subtree; the
694
+ * matcher and compiled-glob memo remain reusable for unrelated trees.
695
+ */
696
+ export function invalidateProjectIgnoreMatcherForPath(filePath) {
697
+ const resolvedPath = path.resolve(filePath);
698
+ if (path.basename(resolvedPath).toLowerCase() !== ".gitignore")
699
+ return;
700
+ for (const [cachedRoot, cached] of projectIgnoreMatcherCache) {
701
+ if (!isUnderDir(resolvedPath, cachedRoot))
702
+ continue;
703
+ if (normalizeFilePath(resolvedPath) ===
704
+ normalizeFilePath(path.join(cachedRoot, ".gitignore"))) {
705
+ projectIgnoreMatcherCache.delete(cachedRoot);
706
+ continue;
707
+ }
708
+ cached.matcher.invalidateSubtree(path.dirname(resolvedPath));
709
+ }
710
+ }
477
711
  export function isPathIgnoredByProject(filePath, rootDir, isDirectory = false) {
478
712
  return getProjectIgnoreMatcher(rootDir).isIgnored(filePath, isDirectory);
479
713
  }
714
+ /**
715
+ * "Is this a project-source path pi-lens's bookkeeping should care about" —
716
+ * the `isPathIgnoredByProject` + `isExternalOrVendorFile` pair, previously
717
+ * hand-duplicated at each of its 2 call sites (`registerReadBridge` and
718
+ * `registerMutationBridge` in `index.ts`, both #2423). Consolidated here
719
+ * (#2450 review round 2, F4) when a THIRD call site — `tools/lsp-navigation.ts`
720
+ * threading the same gate onto its directly-threaded `LspMutationContext`, so
721
+ * the direct LSP-mutation path and the mutation-bridge fallback path apply
722
+ * the identical gate instead of the fallback silently being narrower. A
723
+ * caller still layers its own `no-read-guard`-style flag check on top; that
724
+ * flag has no file path to check against, so it stays outside this helper.
725
+ */
726
+ export function isRecordableProjectPath(filePath, projectRoot) {
727
+ if (isPathIgnoredByProject(filePath, projectRoot, false))
728
+ return false;
729
+ if (isExternalOrVendorFile(filePath, projectRoot))
730
+ return false;
731
+ return true;
732
+ }
480
733
  const projectIgnoreGlobsCache = new Map();
481
734
  export function getProjectIgnoreGlobs(rootDir) {
482
735
  const resolvedRoot = path.resolve(rootDir);
@@ -87,17 +87,45 @@
87
87
  * degrade; they satisfy the same rule by dropping the authority marker
88
88
  * alongside the coordinate.
89
89
  *
90
- * ── Retirement (#1944) ────────────────────────────────────────────────────
91
- * Demote-not-drop assumes the agent CAN re-run to confirm. A past-EOF
92
- * demotion breaks that assumption: the file shrank past the cited lines, so
93
- * no re-run can ever speak to them, and the record re-served on every turn
94
- * end for the life of the session. Such a record is delivered ONCE, degraded,
95
- * then retired (`RuntimeCoordinator.retireDemotedPastEofBlocker`). The
96
- * suppression is recorded in the degradation ledger under
97
- * `demoted-finding-retired`, whose subject keeps the store and file, and the
98
- * delivered payload says so in its own words — so an empty advisory section
99
- * can only mean "nothing to say". Dependency-drift demotions keep in-bounds
100
- * coordinates the agent can act on and are NOT retired.
90
+ * ── Retirement (#1944, #1950, #2275) ──────────────────────────────────────
91
+ * Demote-not-drop assumes the agent CAN re-run to confirm. Retirement is what
92
+ * happens when re-serving a demotion forever stops being honest. Every kind
93
+ * of retirement records itself in the degradation ledger under
94
+ * `demoted-finding-retired`, whose subject keeps the store and the file
95
+ * (`inline-blocker:` / `widget-blocker:`), so an empty section can only mean
96
+ * "nothing to say". There are three, and they differ in WHY and in HOW MUCH
97
+ * they remove:
98
+ *
99
+ * 1. Past-EOF, unrecoverable (#1944). The file shrank past the cited lines,
100
+ * so no re-run can ever speak to them. Delivered ONCE, degraded, then the
101
+ * record is DROPPED (`RuntimeCoordinator.retireDemotedPastEofBlocker`).
102
+ *
103
+ * 2. Dependency-drift, inline-blocker channel (#1950). The coordinates are
104
+ * still in bounds and a re-run COULD confirm them, so this is a delivery
105
+ * cap, not a verdict: after `DEPENDENCY_DRIFT_MAX_DELIVERIES` turn-end
106
+ * deliveries with no re-run the record is dropped from
107
+ * `_pendingInlineBlockers`, and the LAST delivery carries a note saying it
108
+ * will not be shown again and can still be confirmed
109
+ * (`formatDeliveryCapNote`). Counting is deferred until the turn's content
110
+ * is known not to be suppressed, so the count is deliveries the agent
111
+ * actually received (#1950 fix round F1).
112
+ *
113
+ * 3. Dependency-drift, widget footer (#2275). The same cap number over the
114
+ * widget store, which unlike the inline-blocker map backs MORE THAN ONE
115
+ * surface — `lens_diagnostics mode=all` and `lens_diagnostic_mark` read
116
+ * the same `allDiagnostics` list the footer draws from. So this retirement
117
+ * HIDES rather than drops: the entry keeps its demotion and its place in
118
+ * the error tally, gains `WidgetDiagnostic.footerRetired`, and only the
119
+ * footer stops rendering it; mode=all carries the "capped, no longer shown
120
+ * in the footer, re-run can still confirm" note in place of the inline
121
+ * channel's last-delivery note. Its count is RENDERS, not turn ends — the
122
+ * footer serves one record per pass, so `renderWidget` marks what it drew
123
+ * and the turn-end step drains those marks. Dropping the record instead
124
+ * would have made an unconfirmed LSP error read as CLEAN on mode=all.
125
+ *
126
+ * The rule the three share: a retirement may remove a finding from the
127
+ * surface that has re-served it, never from every surface at once, unless no
128
+ * re-run could ever confirm it (case 1).
101
129
  *
102
130
  * ── Explicit lag labels (the non-gated escape hatch) ──────────────────────
103
131
  * A store that cannot afford the freshness/disposition stack — because it
@@ -240,6 +268,7 @@ export const DELIVERY_SURFACES = {
240
268
  // `late_auxiliary_findings` latency record rather than silenced.
241
269
  "runtime-turn:late-auxiliary-findings": gated(RUNTIME_TURN_FILE, "Turn-end late-auxiliary LSP findings (collect-later probe of aux " +
242
270
  "client caches whose grace window expired).", ["gateFindingsByPathFreshness"], ['store: "late-auxiliary-findings"']),
271
+ "runtime-turn:late-runner-findings": gated(RUNTIME_TURN_FILE, "Turn-end CLI runner findings collected after the post-write path.", ["gateFindingsByPathFreshness"], ['store: "late-runner-findings"'], { evidenceMin: 2 }),
243
272
  "runtime-turn:cascade-blocker": labeled(RUNTIME_TURN_FILE, "Turn-end 🧪 cascade neighbor blocker.", "Cascade results settle synchronously this turn where possible " +
244
273
  "(`settleCascadeRuns`), but an unsettled compute can carry over to a " +
245
274
  "later turn (bounded by a carry cap) — this round does not freshness-" +
@@ -293,6 +322,7 @@ export const DELIVERY_SURFACES = {
293
322
  "agent-nudge:context-message": labeled("clients/agent-nudge.ts", "Post-edit file-touch nudge injected via `context`.", "Not a scanner finding store: no severity, no cited line, no cache — the " +
294
323
  "accumulator is drained and cleared at the moment of injection, so the " +
295
324
  "content IS the current state by construction.", "live"),
325
+ "test-runner-delivery:custom-entry": labeled("clients/test-runner-delivery.ts", "Post-agent test-runner failures in a non-context custom entry.", "The cache remains authoritative for pull diagnostics and the commit guard; this surface appends only after provenance validation and an idle recheck.", "live"),
296
326
  "project-diagnostics:persisted-snapshot": gated(LENS_DIAGNOSTICS_FILE, "Cross-session persisted project-diagnostics snapshot read.", ["reconcileProjectDiagnosticsSnapshot"], ["reconcileProjectDiagnosticsSnapshot("]),
297
327
  // ── #2028: the remaining agent-facing surfaces ──────────────────────────
298
328
  // Registered after #2028's root-cause review found the 🔴 STOP block
@@ -319,8 +349,20 @@ export const DELIVERY_SURFACES = {
319
349
  "git-guard:commit-blocked": labeled("clients/git-guard.ts", "Git-guard commit/push 🔴 COMMIT BLOCKED verdict (--lens-guard).", "Synchronous preflight rejection returned inline with the failed git " +
320
350
  "command — no stored state is delivered, so nothing can go stale between " +
321
351
  "detection and delivery.", "live"),
322
- "read-guard-tool-lines:preflight-errors": labeled("clients/read-guard-tool-lines.ts", "Read-guard hashline BLOCKED / RE-READ REQUIRED preflight errors.", "Computed fresh per edit attempt and returned as that attempt's rejection — " +
323
- "no cached findings are replayed, so there is no staleness window.", "live"),
352
+ "shared-checkout-guard:worktree-mutation-blocked": labeled("clients/shared-checkout-guard.ts", "Shared-checkout 🔴 WORKING-TREE CHANGE BLOCKED verdict (--lens-checkout-guard).", "Synchronous preflight rejection returned inline with the failed git " +
353
+ "command. Both inputs are read at decision time — the instance registry " +
354
+ "and `git status` — so no stored finding is replayed and nothing can go " +
355
+ "stale between detection and delivery.", "live"),
356
+ "read-guard-tool-lines:preflight-errors": labeled("clients/read-guard-tool-lines.ts", "Read-guard hashline BLOCKED / RE-READ REQUIRED / PARTIAL APPLY / " +
357
+ "ALREADY APPLIED preflight errors (#2402).", "Computed fresh per edit attempt and returned as that attempt's rejection — " +
358
+ "no cached findings are replayed, so there is no staleness window. The " +
359
+ "PARTIAL APPLY and ALREADY APPLIED variants describe the same attempt's " +
360
+ "commit outcome; applied-edit recognition reads RuntimeCoordinator's " +
361
+ "session-scoped record, which resets with the session.", "live"),
362
+ "mutating-tool:adapter-preflight-errors": labeled("clients/mutating-tool.ts", "Shape-adapter BLOCKED preflight errors for hashline edit inputs the " +
363
+ "adapter recognized but could not resolve to a range (#2423).", "Computed fresh from the tool input on each attempt and returned as that " +
364
+ "attempt's rejection, so there is no staleness window. The adapters " +
365
+ "read only the call's own arguments; nothing cached is replayed.", "live"),
324
366
  "tool-call:duplicate-export-blocker": labeled("clients/runtime-tool-call.ts", "Duplicate-export STOP rejection returned inline with the failed edit.", "Synchronous preflight rejection computed per edit attempt; no stored state.", "live"),
325
367
  "agent-behavior:thrashing-notice": labeled("clients/agent-behavior-client.ts", "In-result thrashing/blind-write detection notice.", "Ephemeral notice computed at detection time inside the same tool result — " +
326
368
  "no persistence and no cache, so nothing can be stale.", "live"),
@@ -73,7 +73,7 @@ export class FormatService {
73
73
  // Record new file state after formatting
74
74
  this.fileTime.read(absolutePath);
75
75
  for (const [index, result] of results.entries()) {
76
- recordFormatter(absolutePath, formatters[index]?.name ?? "unknown", result.changed, result.success);
76
+ recordFormatter(absolutePath, formatters[index]?.name ?? "unknown", result.changed, result.success, result.outcome);
77
77
  }
78
78
  // Build summary
79
79
  const anyChanged = results.some((r) => r.changed);
@@ -85,6 +85,7 @@ export class FormatService {
85
85
  success: r.success,
86
86
  changed: r.changed,
87
87
  error: r.error,
88
+ outcome: r.outcome,
88
89
  })),
89
90
  anyChanged,
90
91
  allSucceeded,
@@ -114,9 +115,13 @@ export class FormatService {
114
115
  results.push(result);
115
116
  }
116
117
  catch (error) {
118
+ // A timeout or thrown error here is a real failure (#2413): the
119
+ // formatter ran and did not complete, distinct from an unavailable
120
+ // executable (which formatFile classifies before spawning).
117
121
  results.push({
118
122
  success: false,
119
123
  changed: false,
124
+ outcome: "failed",
120
125
  error: error instanceof Error ? error.message : String(error),
121
126
  });
122
127
  }