@herbertgao/pi-extensions 2026.9.0 → 2026.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/node_modules/@czottmann/pi-automode/CHANGELOG.md +13 -1
  2. package/node_modules/@czottmann/pi-automode/README.md +20 -0
  3. package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +1 -1
  4. package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +2 -1
  5. package/node_modules/@czottmann/pi-automode/docs/defaults.md +3 -2
  6. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +38 -2
  7. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +5 -3
  8. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +11 -3
  9. package/node_modules/@czottmann/pi-automode/package.json +1 -1
  10. package/node_modules/@pi-plugins/fast-mode/README.md +5 -3
  11. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
  12. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +20 -55
  13. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  14. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  15. package/node_modules/pi-lens/CHANGELOG.md +988 -0
  16. package/node_modules/pi-lens/README.md +3 -0
  17. package/node_modules/pi-lens/config/biome/core.jsonc +11 -2
  18. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +13 -1
  19. package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +2 -2
  20. package/node_modules/pi-lens/dist/clients/actionable-warnings.js +927 -80
  21. package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +13 -4
  22. package/node_modules/pi-lens/dist/clients/ast-grep-client.js +123 -3
  23. package/node_modules/pi-lens/dist/clients/ast-grep-rule-manager.js +60 -5
  24. package/node_modules/pi-lens/dist/clients/ast-grep-tool-logger.js +2 -2
  25. package/node_modules/pi-lens/dist/clients/bash-file-access.js +1 -3
  26. package/node_modules/pi-lens/dist/clients/biome-client.js +9 -2
  27. package/node_modules/pi-lens/dist/clients/blocker-freshness.js +14 -0
  28. package/node_modules/pi-lens/dist/clients/bootstrap.js +509 -73
  29. package/node_modules/pi-lens/dist/clients/bounded-cache.js +152 -12
  30. package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +59 -4
  31. package/node_modules/pi-lens/dist/clients/bundled-resource-health.js +113 -0
  32. package/node_modules/pi-lens/dist/clients/bus-events-logger.js +2 -2
  33. package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +31 -4
  34. package/node_modules/pi-lens/dist/clients/cache-manager.js +105 -6
  35. package/node_modules/pi-lens/dist/clients/cache-observability.js +44 -18
  36. package/node_modules/pi-lens/dist/clients/cargo-manifest.js +422 -0
  37. package/node_modules/pi-lens/dist/clients/cascade-logger.js +2 -2
  38. package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +13 -3
  39. package/node_modules/pi-lens/dist/clients/complexity-client.js +16 -5
  40. package/node_modules/pi-lens/dist/clients/config-core/deny.js +221 -0
  41. package/node_modules/pi-lens/dist/clients/config-core/index.js +47 -0
  42. package/node_modules/pi-lens/dist/clients/config-core/merge.js +357 -0
  43. package/node_modules/pi-lens/dist/clients/config-core/normalize.js +340 -0
  44. package/node_modules/pi-lens/dist/clients/config-core/process-spec.js +248 -0
  45. package/node_modules/pi-lens/dist/clients/config-core/provenance.js +171 -0
  46. package/node_modules/pi-lens/dist/clients/config-core/records.js +218 -0
  47. package/node_modules/pi-lens/dist/clients/config-core/resolve.js +125 -0
  48. package/node_modules/pi-lens/dist/clients/config-core/safe-object.js +78 -0
  49. package/node_modules/pi-lens/dist/clients/config-core/schema.js +167 -0
  50. package/node_modules/pi-lens/dist/clients/config-diagnostic-codes.js +281 -0
  51. package/node_modules/pi-lens/dist/clients/config-locations.js +160 -0
  52. package/node_modules/pi-lens/dist/clients/config-resolve.js +789 -0
  53. package/node_modules/pi-lens/dist/clients/config-schema.js +197 -0
  54. package/node_modules/pi-lens/dist/clients/config-warn.js +407 -0
  55. package/node_modules/pi-lens/dist/clients/dead-code-client.js +19 -14
  56. package/node_modules/pi-lens/dist/clients/dead-code-logger.js +2 -2
  57. package/node_modules/pi-lens/dist/clients/deadline-utils.js +178 -0
  58. package/node_modules/pi-lens/dist/clients/debug-handles.js +2 -2
  59. package/node_modules/pi-lens/dist/clients/debug-heap.js +3 -3
  60. package/node_modules/pi-lens/dist/clients/deferred-lsp-work.js +106 -0
  61. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +113 -7
  62. package/node_modules/pi-lens/dist/clients/dependency-checker.js +8 -19
  63. package/node_modules/pi-lens/dist/clients/diagnostic-line-freshness.js +12 -9
  64. package/node_modules/pi-lens/dist/clients/diagnostic-logger.js +14 -4
  65. package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +162 -18
  66. package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +97 -0
  67. package/node_modules/pi-lens/dist/clients/dispatch/integration.js +9 -7
  68. package/node_modules/pi-lens/dist/clients/dispatch/runners/actionlint.js +0 -1
  69. package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +380 -26
  70. package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +0 -1
  71. package/node_modules/pi-lens/dist/clients/dispatch/runners/cpp-check.js +0 -1
  72. package/node_modules/pi-lens/dist/clients/dispatch/runners/credo.js +0 -1
  73. package/node_modules/pi-lens/dist/clients/dispatch/runners/cue-vet.js +0 -1
  74. package/node_modules/pi-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -1
  75. package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +0 -1
  76. package/node_modules/pi-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -1
  77. package/node_modules/pi-lens/dist/clients/dispatch/runners/elixir-check.js +0 -1
  78. package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +0 -1
  79. package/node_modules/pi-lens/dist/clients/dispatch/runners/fact-rules.js +0 -1
  80. package/node_modules/pi-lens/dist/clients/dispatch/runners/fish-indent.js +0 -1
  81. package/node_modules/pi-lens/dist/clients/dispatch/runners/gleam-check.js +0 -1
  82. package/node_modules/pi-lens/dist/clients/dispatch/runners/go-vet.js +1 -3
  83. package/node_modules/pi-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -1
  84. package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +0 -1
  85. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +0 -1
  86. package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +0 -1
  87. package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +0 -1
  88. package/node_modules/pi-lens/dist/clients/dispatch/runners/javac.js +0 -1
  89. package/node_modules/pi-lens/dist/clients/dispatch/runners/ktlint.js +0 -1
  90. package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +0 -1
  91. package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +0 -1
  92. package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +0 -1
  93. package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +13 -18
  94. package/node_modules/pi-lens/dist/clients/dispatch/runners/php-lint.js +0 -1
  95. package/node_modules/pi-lens/dist/clients/dispatch/runners/phpstan.js +0 -1
  96. package/node_modules/pi-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -1
  97. package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -1
  98. package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +7 -4
  99. package/node_modules/pi-lens/dist/clients/dispatch/runners/rubocop.js +0 -1
  100. package/node_modules/pi-lens/dist/clients/dispatch/runners/ruff.js +0 -1
  101. package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +1 -3
  102. package/node_modules/pi-lens/dist/clients/dispatch/runners/shellcheck.js +0 -1
  103. package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +0 -1
  104. package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +0 -1
  105. package/node_modules/pi-lens/dist/clients/dispatch/runners/spotbugs.js +0 -1
  106. package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -1
  107. package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +0 -1
  108. package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +0 -1
  109. package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +0 -1
  110. package/node_modules/pi-lens/dist/clients/dispatch/runners/terragrunt.js +0 -1
  111. package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +0 -1
  112. package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -1
  113. package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +0 -1
  114. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +3 -0
  115. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +3 -4
  116. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +194 -80
  117. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +84 -15
  118. package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +0 -1
  119. package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +0 -1
  120. package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +0 -1
  121. package/node_modules/pi-lens/dist/clients/disposition-logger.js +3 -3
  122. package/node_modules/pi-lens/dist/clients/effective-config.js +403 -0
  123. package/node_modules/pi-lens/dist/clients/error-class.js +23 -0
  124. package/node_modules/pi-lens/dist/clients/event-loop-hold.js +274 -0
  125. package/node_modules/pi-lens/dist/clients/extension-log.js +2 -2
  126. package/node_modules/pi-lens/dist/clients/feature-hints.js +2 -1
  127. package/node_modules/pi-lens/dist/clients/file-time.js +6 -1
  128. package/node_modules/pi-lens/dist/clients/file-utils.js +112 -9
  129. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +50 -13
  130. package/node_modules/pi-lens/dist/clients/format-service.js +6 -1
  131. package/node_modules/pi-lens/dist/clients/formatters.js +276 -102
  132. package/node_modules/pi-lens/dist/clients/freshness-cadence.js +17 -0
  133. package/node_modules/pi-lens/dist/clients/generated-artifacts.js +114 -19
  134. package/node_modules/pi-lens/dist/clients/generation-guard.js +4 -9
  135. package/node_modules/pi-lens/dist/clients/git-guard.js +1 -1
  136. package/node_modules/pi-lens/dist/clients/go-client.js +39 -0
  137. package/node_modules/pi-lens/dist/clients/gradle-ktfmt-style.js +252 -0
  138. package/node_modules/pi-lens/dist/clients/hashline-anchor.js +424 -0
  139. package/node_modules/pi-lens/dist/clients/hook-budgets.js +76 -0
  140. package/node_modules/pi-lens/dist/clients/host-edit-normalize.js +5 -2
  141. package/node_modules/pi-lens/dist/clients/host-ports.js +1 -1
  142. package/node_modules/pi-lens/dist/clients/installer/index.js +71 -52
  143. package/node_modules/pi-lens/dist/clients/instance-reaper.js +104 -230
  144. package/node_modules/pi-lens/dist/clients/instance-registry.js +6 -3
  145. package/node_modules/pi-lens/dist/clients/language-registry.js +595 -0
  146. package/node_modules/pi-lens/dist/clients/latency-logger.js +160 -2
  147. package/node_modules/pi-lens/dist/clients/ledger-bounds.js +13 -0
  148. package/node_modules/pi-lens/dist/clients/lens-config.js +141 -30
  149. package/node_modules/pi-lens/dist/clients/lens-engine.js +30 -37
  150. package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +59 -6
  151. package/node_modules/pi-lens/dist/clients/log-cleanup.js +2 -2
  152. package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +3 -1
  153. package/node_modules/pi-lens/dist/clients/lsp/client.js +168 -30
  154. package/node_modules/pi-lens/dist/clients/lsp/config.js +483 -158
  155. package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +1 -1
  156. package/node_modules/pi-lens/dist/clients/lsp/edits.js +15 -2
  157. package/node_modules/pi-lens/dist/clients/lsp/index.js +676 -71
  158. package/node_modules/pi-lens/dist/clients/lsp/language.js +18 -169
  159. package/node_modules/pi-lens/dist/clients/lsp/launch.js +2 -1
  160. package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +5 -16
  161. package/node_modules/pi-lens/dist/clients/lsp/server.js +284 -147
  162. package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +116 -23
  163. package/node_modules/pi-lens/dist/clients/lsp/spawn-history.js +2 -7
  164. package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +9 -2
  165. package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +1 -1
  166. package/node_modules/pi-lens/dist/clients/lsp-mutation.js +163 -21
  167. package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +36 -0
  168. package/node_modules/pi-lens/dist/clients/mcp/analyze.js +33 -4
  169. package/node_modules/pi-lens/dist/clients/mcp/session.js +5 -16
  170. package/node_modules/pi-lens/dist/clients/memory-sampler.js +8 -3
  171. package/node_modules/pi-lens/dist/clients/middle-man-analysis.js +2 -4
  172. package/node_modules/pi-lens/dist/clients/module-report.js +20 -45
  173. package/node_modules/pi-lens/dist/clients/mutating-tool.js +651 -0
  174. package/node_modules/pi-lens/dist/clients/mutation-attribution.js +368 -0
  175. package/node_modules/pi-lens/dist/clients/mutation-bridge.js +240 -0
  176. package/node_modules/pi-lens/dist/clients/ndjson-logger.js +247 -20
  177. package/node_modules/pi-lens/dist/clients/observed-mutation-sources.js +101 -0
  178. package/node_modules/pi-lens/dist/clients/observed-mutation.js +1215 -0
  179. package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +68 -22
  180. package/node_modules/pi-lens/dist/clients/opengrep-config.js +4 -0
  181. package/node_modules/pi-lens/dist/clients/package-manager.js +195 -26
  182. package/node_modules/pi-lens/dist/clients/partial-edit-apply.js +359 -80
  183. package/node_modules/pi-lens/dist/clients/path-attribution-telemetry.js +23 -7
  184. package/node_modules/pi-lens/dist/clients/path-keyed-map.js +21 -2
  185. package/node_modules/pi-lens/dist/clients/path-utils.js +428 -13
  186. package/node_modules/pi-lens/dist/clients/persist-debounce.js +8 -1
  187. package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +114 -0
  188. package/node_modules/pi-lens/dist/clients/pipeline.js +77 -16
  189. package/node_modules/pi-lens/dist/clients/probe-home-state.js +228 -0
  190. package/node_modules/pi-lens/dist/clients/process-bridge.js +66 -0
  191. package/node_modules/pi-lens/dist/clients/process-snapshot.js +68 -0
  192. package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +4 -3
  193. package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +27 -3
  194. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +51 -20
  195. package/node_modules/pi-lens/dist/clients/project-lens-config.js +393 -122
  196. package/node_modules/pi-lens/dist/clients/project-snapshot.js +52 -24
  197. package/node_modules/pi-lens/dist/clients/python-environment.js +217 -0
  198. package/node_modules/pi-lens/dist/clients/python-provenance.js +639 -0
  199. package/node_modules/pi-lens/dist/clients/quiet-window.js +6 -1
  200. package/node_modules/pi-lens/dist/clients/read-bridge.js +13 -21
  201. package/node_modules/pi-lens/dist/clients/read-expansion.js +9 -46
  202. package/node_modules/pi-lens/dist/clients/read-guard-logger.js +15 -4
  203. package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +364 -212
  204. package/node_modules/pi-lens/dist/clients/read-guard.js +21 -0
  205. package/node_modules/pi-lens/dist/clients/resource-sampler.js +195 -96
  206. package/node_modules/pi-lens/dist/clients/review-graph/builder.js +152 -109
  207. package/node_modules/pi-lens/dist/clients/review-graph/service.js +55 -3
  208. package/node_modules/pi-lens/dist/clients/review-graph/shared-extraction-ir.js +7 -15
  209. package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +10 -74
  210. package/node_modules/pi-lens/dist/clients/review-graph-logger.js +9 -3
  211. package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +18 -2
  212. package/node_modules/pi-lens/dist/clients/runtime-context.js +49 -16
  213. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +25 -6
  214. package/node_modules/pi-lens/dist/clients/runtime-session.js +139 -22
  215. package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +168 -35
  216. package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +797 -243
  217. package/node_modules/pi-lens/dist/clients/runtime-turn.js +1028 -53
  218. package/node_modules/pi-lens/dist/clients/rust-client.js +31 -0
  219. package/node_modules/pi-lens/dist/clients/safe-spawn.js +33 -10
  220. package/node_modules/pi-lens/dist/clients/sanitize.js +7 -1
  221. package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +1 -3
  222. package/node_modules/pi-lens/dist/clients/security-scan-client.js +3 -0
  223. package/node_modules/pi-lens/dist/clients/session-lifecycle.js +1 -1
  224. package/node_modules/pi-lens/dist/clients/session-start-observability.js +79 -0
  225. package/node_modules/pi-lens/dist/clients/sessionstart-logger.js +12 -3
  226. package/node_modules/pi-lens/dist/clients/sgconfig.js +6 -1
  227. package/node_modules/pi-lens/dist/clients/skills-resolver.js +105 -0
  228. package/node_modules/pi-lens/dist/clients/smells-rollup.js +2 -2
  229. package/node_modules/pi-lens/dist/clients/string-utils.js +13 -0
  230. package/node_modules/pi-lens/dist/clients/subagent-mode.js +17 -4
  231. package/node_modules/pi-lens/dist/clients/test-runner-client.js +176 -39
  232. package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +239 -0
  233. package/node_modules/pi-lens/dist/clients/tool-definition.js +41 -1
  234. package/node_modules/pi-lens/dist/clients/tool-policy.js +91 -21
  235. package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +40 -40
  236. package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +86 -48
  237. package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +2 -2
  238. package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +81 -1
  239. package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +51 -46
  240. package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +28 -0
  241. package/node_modules/pi-lens/dist/clients/typos-config.js +5 -0
  242. package/node_modules/pi-lens/dist/clients/user-notify.js +6 -2
  243. package/node_modules/pi-lens/dist/clients/widget-state.js +191 -26
  244. package/node_modules/pi-lens/dist/clients/word-index-logger.js +2 -2
  245. package/node_modules/pi-lens/dist/clients/word-index-store.js +20 -5
  246. package/node_modules/pi-lens/dist/clients/word-index.js +243 -31
  247. package/node_modules/pi-lens/dist/clients/workspace-topology.js +8 -1
  248. package/node_modules/pi-lens/dist/clients/zizmor-config.js +3 -0
  249. package/node_modules/pi-lens/dist/index.js +64335 -54300
  250. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +3 -1
  251. package/node_modules/pi-lens/dist/mcp/server.js +127 -5
  252. package/node_modules/pi-lens/dist/scripts/lib/process-scan.mjs +583 -0
  253. package/node_modules/pi-lens/dist/scripts/lib/skills-predicate.mjs +129 -0
  254. package/node_modules/pi-lens/dist/tools/effective-config.js +89 -0
  255. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +95 -24
  256. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +67 -80
  257. package/node_modules/pi-lens/dist/tools/lsp-navigation.js +37 -16
  258. package/node_modules/pi-lens/dist/tools/shared.js +0 -1
  259. package/node_modules/pi-lens/docs/agent-guide.md +64 -1
  260. package/node_modules/pi-lens/docs/configuration.md +222 -0
  261. package/node_modules/pi-lens/docs/dependencies.md +3 -3
  262. package/node_modules/pi-lens/docs/features.md +44 -5
  263. package/node_modules/pi-lens/docs/language-coverage.md +2 -2
  264. package/node_modules/pi-lens/docs/pi-lens-fixer.md +25 -0
  265. package/node_modules/pi-lens/docs/pi-lens-investigator.md +25 -0
  266. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +27 -0
  267. package/node_modules/pi-lens/docs/pi-lens-subagent.md +38 -0
  268. package/node_modules/pi-lens/docs/pi-lens-warden.md +55 -0
  269. package/node_modules/pi-lens/docs/public-api-stability.md +359 -0
  270. package/node_modules/pi-lens/docs/release-qa-baseline.md +182 -0
  271. package/node_modules/pi-lens/docs/subagent-compat.md +110 -30
  272. package/node_modules/pi-lens/docs/tree-sitter_rules_catalog.md +2 -2
  273. package/node_modules/pi-lens/package.json +15 -23
  274. package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-cross-language-method.yml +3 -3
  275. package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-hallucinated-import.yml +2 -2
  276. package/node_modules/pi-lens/rules/tree-sitter-queries/python/python-sql-injection.yml +12 -2
  277. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +192 -1
  278. package/node_modules/pi-lens/scripts/install-selftest.mjs +58 -2
  279. package/node_modules/pi-lens/scripts/lib/skills-predicate.mjs +129 -0
  280. package/node_modules/pi-lens/scripts/rpc-load-check.mjs +3 -1
  281. package/node_modules/pi-web-access/CHANGELOG.md +28 -0
  282. package/node_modules/pi-web-access/README.md +62 -15
  283. package/node_modules/pi-web-access/curator-page.ts +3 -1
  284. package/node_modules/pi-web-access/curator-server.ts +5 -1
  285. package/node_modules/pi-web-access/gemini-search.ts +8 -4
  286. package/node_modules/pi-web-access/github-extract.ts +242 -1
  287. package/node_modules/pi-web-access/index.ts +118 -64
  288. package/node_modules/pi-web-access/mistral-search.ts +281 -0
  289. package/node_modules/pi-web-access/package.json +2 -2
  290. package/node_modules/pi-web-access/perplexity.ts +14 -1
  291. package/node_modules/pi-web-access/utils.ts +23 -6
  292. package/node_modules/pi-web-access/xai-search.ts +96 -33
  293. package/package.json +5 -5
@@ -0,0 +1,274 @@
1
+ /**
2
+ * #2507: hold the event loop for the lifetime of in-flight work that would
3
+ * otherwise be kept alive by NOTHING.
4
+ *
5
+ * Every handle pi-lens owns on the way to an LSP answer is deliberately
6
+ * unref'd. `clients/lsp/launch.ts#unrefLspProcessHandles` unrefs the language
7
+ * server child AND its three stdio pipes so a settled one-shot `pi --print`
8
+ * can exit without waiting for a lingering server (the #1097/#1110 class);
9
+ * `clients/child-unref.ts` does the same for every fire-and-forget probe
10
+ * spawn; `bounded()` and several LSP waits unref their timers for the same
11
+ * reason. That is correct for an IDLE process and wrong for a BUSY one: in a
12
+ * headless child (`pi --mode json -p --no-extensions`, stdin ignored, no TUI,
13
+ * no other extension holding a socket or timer) an in-flight `lsp_diagnostics`
14
+ * call reaches a point where the only thing it is waiting on is an unref'd
15
+ * timer or an unref'd pipe, libuv finds no referenced handle, and Node exits 0
16
+ * IN THE MIDDLE of the tool call — no error, no result, no `turn_end`. The
17
+ * reporter measured it against pyright; the drain site the repro lands on is
18
+ * `LSPService.ensureWarmForSweep`'s warm-up retry backoff (an explicitly
19
+ * `.unref()`'d `setTimeout`), but it is one of many: any await whose only
20
+ * pending handle is unref'd has the same shape.
21
+ *
22
+ * The fix is NOT to stop unref'ing — that would leak a lingering server into
23
+ * every settled one-shot process, which is the reason the unref exists. It is
24
+ * to hold ONE referenced handle for exactly as long as something is in
25
+ * flight: a counted keep-alive, armed while at least one hold is taken and
26
+ * disarmed the moment the last one is released. Idle behaviour is therefore
27
+ * byte-identical to before — no hold, no timer, nothing referenced.
28
+ *
29
+ * Shape 15's screen (AGENTS.md), which this follows deliberately:
30
+ * - a COUNTER of tokens, not a boolean, so overlapping tool calls each
31
+ * release independently and a throwing/aborted caller still releases
32
+ * (callers release from `finally`);
33
+ * - a bounded lifetime PER HOLD, because a leaked hold is the INVERSE defect
34
+ * (a process that can never exit). Each token gets {@link
35
+ * getEventLoopHoldMaxMs} measured from its OWN acquire — derived from the
36
+ * longest legitimate operation's ceiling (`getWorkspaceSweepMaxHoldAgeMs`,
37
+ * the full-scan wall clock plus its safety margin) rather than a second,
38
+ * independently-drifting literal. The keep-alive is armed for the SOONEST
39
+ * outstanding deadline; when it fires, only tokens that are actually stale
40
+ * are released (with a log record naming them), and it re-arms for
41
+ * whatever remains. An epoch-anchored version of this — one timer from the
42
+ * first hold, clearing every token when it fired — was #2649 review F1: a
43
+ * call issued late in a legitimate 300s `lens_diagnostics mode=full` was
44
+ * force-released seconds after starting, i.e. #2507's drain reproduced BY
45
+ * the fix.
46
+ *
47
+ * There is deliberately NO session-boundary clear here, unlike
48
+ * `clients/lsp/workspace-sweep-hold.ts`. A `session_start` can land mid-turn
49
+ * (see `clients/bootstrap.ts`), so clearing holds on a session boundary would
50
+ * un-hold a tool call that is still running and reintroduce this exact defect
51
+ * for it. The hold is scoped to one call's try/finally, not to a session.
52
+ */
53
+ import { claimPhaseOncePerSession, logLatency, releaseOncePerSessionPhase, } from "./latency-logger.js";
54
+ import { getWorkspaceSweepMaxHoldAgeMs } from "./lsp/workspace-sweep-hold.js";
55
+ import { getProcessSingleton } from "./process-singletons.js";
56
+ /** The one row per session proving the keep-alive was taken (#2649 F2). */
57
+ const EVENT_LOOP_HOLD_ARMED_PHASE = "event_loop_hold_armed";
58
+ const EVENT_LOOP_HOLD_FAMILY = "event-loop-hold";
59
+ const EVENT_LOOP_HOLD_VERSION = 1;
60
+ /**
61
+ * Process-scoped on purpose: pi evaluates the pi-lens module graph more than
62
+ * once in one process (see `clients/process-singletons.ts`), and what is being
63
+ * counted here is a property of the PROCESS's event loop, not of one module
64
+ * evaluation. Two copies would arm two timers for one loop.
65
+ */
66
+ function state() {
67
+ return getProcessSingleton(EVENT_LOOP_HOLD_FAMILY, EVENT_LOOP_HOLD_VERSION, () => ({ holds: new Map(), nextHoldId: 1, timer: undefined }));
68
+ }
69
+ /**
70
+ * Upper bound on how long ONE hold — each hold, measured from its OWN
71
+ * acquire — may keep this process alive. Derived from `lens_diagnostics
72
+ * mode=full`'s own wall-clock ceiling plus the shared
73
+ * `SWEEP_IDLE_SAFETY_MARGIN_MS` — the same derivation the workspace-sweep
74
+ * hold's max-hold-age failsafe uses, so the two cannot drift apart into a
75
+ * relationship where the longest legitimate tool call outlives the bound that
76
+ * is supposed to only catch bugs.
77
+ */
78
+ export function getEventLoopHoldMaxMs() {
79
+ return getWorkspaceSweepMaxHoldAgeMs();
80
+ }
81
+ /**
82
+ * Arm the keep-alive for the SOONEST deadline any outstanding hold has — the
83
+ * earliest moment a token can become stale — never for a fixed epoch from the
84
+ * first hold (#2649 review F1).
85
+ *
86
+ * Round 1 armed once on 0→1 and cleared every token when it fired, so a call
87
+ * that started while an older one was still running inherited whatever was
88
+ * left of the FIRST call's bound: a `lens_diagnostics mode=full` legitimately
89
+ * running to its 300s ceiling force-released a healthy `lsp_diagnostics`
90
+ * issued at t=305s, which is #2507's own drain produced by the fix. The
91
+ * reviewer reproduced it in a real child with the bound shortened: both calls
92
+ * unsettled, `active=[]`, `EXIT code=0`.
93
+ *
94
+ * Soonest-deadline, not the youngest survivor's: the youngest would let an
95
+ * older survivor overstay its own max age by the whole age gap. Each token is
96
+ * released when IT is stale and never before.
97
+ */
98
+ function armForNextDeadline(current) {
99
+ if (current.timer !== undefined)
100
+ return;
101
+ if (current.holds.size === 0)
102
+ return;
103
+ const maxMs = getEventLoopHoldMaxMs();
104
+ let soonest = Number.POSITIVE_INFINITY;
105
+ for (const entry of current.holds.values()) {
106
+ soonest = Math.min(soonest, entry.acquiredAt + maxMs);
107
+ }
108
+ // A past-due deadline is left negative on purpose: Node clamps any delay
109
+ // below 1ms to 1ms, so it fires on a later turn of the loop either way, and
110
+ // a hand-written floor here would be a guard naming a recurrence that
111
+ // cannot happen (#2649 verify F4 — probed: 5 re-arms at delay -5000
112
+ // completed in 5ms, and no test reds without the floor).
113
+ const delayMs = soonest - Date.now();
114
+ // NOT `unref()`'d — referencing the loop is this timer's entire job. It is
115
+ // also the failsafe: when it fires, whatever is stale is over either way.
116
+ current.timer = setTimeout(() => reapStaleHolds(), delayMs);
117
+ }
118
+ function disarmIfIdle(current) {
119
+ if (current.holds.size > 0)
120
+ return;
121
+ if (current.timer === undefined)
122
+ return;
123
+ clearTimeout(current.timer);
124
+ current.timer = undefined;
125
+ }
126
+ /**
127
+ * Release every hold that has outlived {@link getEventLoopHoldMaxMs} ON ITS
128
+ * OWN CLOCK, log what was released, and re-arm for whatever is still
129
+ * outstanding. Same shape as `clients/lsp/workspace-sweep-hold.ts`'s
130
+ * `reapStaleHolds` — deliberately a second, independent implementation rather
131
+ * than a shared ledger (that consolidation is tracked separately).
132
+ */
133
+ function reapStaleHolds() {
134
+ const current = state();
135
+ current.timer = undefined;
136
+ try {
137
+ const maxMs = getEventLoopHoldMaxMs();
138
+ const now = Date.now();
139
+ const released = [];
140
+ for (const [holdId, entry] of current.holds) {
141
+ if (now - entry.acquiredAt <= maxMs)
142
+ continue;
143
+ current.holds.delete(holdId);
144
+ released.push(entry);
145
+ }
146
+ if (released.length > 0) {
147
+ recordForceReleased(released, current.holds.size, maxMs, now);
148
+ }
149
+ }
150
+ finally {
151
+ // A survivor is held by nothing until this re-arms — the drain — and
152
+ // forever if it never does — the leak. In a `finally` because this runs
153
+ // inside a timer callback, where anything that escapes is an uncaught
154
+ // exception, and because the round-2 code put the log between the reap
155
+ // and the re-arm: a throwing sink stranded the survivor (#2649 verify
156
+ // F3). The map is already consistent by here — entries are deleted
157
+ // before anything is logged.
158
+ armForNextDeadline(current);
159
+ }
160
+ }
161
+ /**
162
+ * The force-release record, and its own absorption. Telemetry may not break
163
+ * the guard it observes — the house rule spelled at
164
+ * `clients/runtime-tool-call.ts`'s blocked-attribution cleanup: a guard that
165
+ * fails because its telemetry broke is worse than no guard. Nothing here has
166
+ * a fallback sink to escalate to; the keep-alive's correctness does not
167
+ * depend on the row being written.
168
+ */
169
+ function recordForceReleased(released, stillHeld, maxMs, now) {
170
+ try {
171
+ const oldestAcquiredAt = Math.min(...released.map((entry) => entry.acquiredAt));
172
+ logLatency({
173
+ type: "phase",
174
+ phase: "event_loop_hold_force_released",
175
+ filePath: "",
176
+ durationMs: now - oldestAcquiredAt,
177
+ metadata: {
178
+ maxHoldMs: maxMs,
179
+ releasedHolds: released.length,
180
+ stillHeld,
181
+ labels: [...new Set(released.map((entry) => entry.label))].slice(0, 8),
182
+ },
183
+ });
184
+ }
185
+ catch {
186
+ // see the doc comment — a broken sink must not reach the reap path
187
+ }
188
+ }
189
+ /**
190
+ * ONE row per session saying the keep-alive was actually taken (#2649 review
191
+ * F2). Without it the only record this module ever writes is the failsafe, so
192
+ * a silent log cannot distinguish "working as designed" from "never wired at
193
+ * all" — the #2526 gap shape. Claimed through the logger's own
194
+ * once-per-session mechanism rather than a private latch, so the "one row per
195
+ * session" a reader counts against is the same property `config_resolved`
196
+ * has.
197
+ */
198
+ function recordFirstArm(entry, maxMs) {
199
+ try {
200
+ if (!claimPhaseOncePerSession(EVENT_LOOP_HOLD_ARMED_PHASE, "process")) {
201
+ return;
202
+ }
203
+ logLatency({
204
+ type: "phase",
205
+ phase: EVENT_LOOP_HOLD_ARMED_PHASE,
206
+ filePath: "",
207
+ durationMs: 0,
208
+ metadata: { label: entry.label, maxHoldMs: maxMs },
209
+ });
210
+ }
211
+ catch {
212
+ // This runs on the ACQUIRE path, and `normalizeToolDefinition` takes the
213
+ // hold outside its own try — so a throw here rejected the tool call with
214
+ // the sink's error instead of returning the tool's result (#2649 verify
215
+ // F3). Same house rule as `recordForceReleased` above: the hold is
216
+ // already taken and armed by this point, so absorbing the throw loses a
217
+ // log row and nothing else.
218
+ }
219
+ }
220
+ /**
221
+ * Take one hold for the lifetime of a piece of in-flight work, and return its
222
+ * release. Callers MUST release from a `finally` block: a throw, a rejection
223
+ * or an abort has to release exactly like a normal return, or the hold leaks
224
+ * and the process stops being able to exit.
225
+ *
226
+ * The release is identity-guarded and idempotent — calling it twice, or after
227
+ * the max-age failsafe already force-released it, is a no-op and never
228
+ * disarms another caller's hold.
229
+ */
230
+ export function acquireEventLoopHold(label) {
231
+ const current = state();
232
+ const holdId = current.nextHoldId++;
233
+ const entry = { acquiredAt: Date.now(), label };
234
+ current.holds.set(holdId, entry);
235
+ const wasArmed = current.timer !== undefined;
236
+ armForNextDeadline(current);
237
+ if (!wasArmed)
238
+ recordFirstArm(entry, getEventLoopHoldMaxMs());
239
+ return () => {
240
+ const now = state();
241
+ if (!now.holds.delete(holdId))
242
+ return;
243
+ disarmIfIdle(now);
244
+ };
245
+ }
246
+ /** Test-only: how many holds are outstanding right now. */
247
+ export function _eventLoopHoldCountForTests() {
248
+ return state().holds.size;
249
+ }
250
+ /**
251
+ * Test-only: the keep-alive handle's own state. `hasRef` is the property the
252
+ * whole fix rests on — a handle that is armed but unref'd holds nothing — so
253
+ * it is read from the live `Timeout` (`hasRef()`), not asserted from the
254
+ * source text.
255
+ */
256
+ export function _eventLoopKeepAliveForTests() {
257
+ const timer = state().timer;
258
+ return {
259
+ armed: timer !== undefined,
260
+ hasRef: timer?.hasRef?.() === true,
261
+ };
262
+ }
263
+ /** Test-only: drop every hold and disarm, between tests. */
264
+ export function _resetEventLoopHoldForTests() {
265
+ // This module's own phase only — never a blanket clear of a structure other
266
+ // producers claim in (`releaseOncePerSessionPhase`'s doc comment).
267
+ releaseOncePerSessionPhase(EVENT_LOOP_HOLD_ARMED_PHASE);
268
+ const current = state();
269
+ current.holds.clear();
270
+ if (current.timer !== undefined)
271
+ clearTimeout(current.timer);
272
+ current.timer = undefined;
273
+ current.nextHoldId = 1;
274
+ }
@@ -23,10 +23,10 @@
23
23
  import { AsyncLocalStorage } from "node:async_hooks";
24
24
  import * as path from "node:path";
25
25
  import { isTestMode } from "./env-utils.js";
26
- import { getGlobalPiLensDir } from "./file-utils.js";
26
+ import { getGlobalPiLensLogDir } from "./probe-home-state.js";
27
27
  import { getMaxLogSizeMB } from "./log-cleanup.js";
28
28
  import { createNdjsonLogger } from "./ndjson-logger.js";
29
- export const EXTENSION_LOG_FILE = path.join(getGlobalPiLensDir(), "extension.log");
29
+ export const EXTENSION_LOG_FILE = path.join(getGlobalPiLensLogDir(), "extension.log");
30
30
  const writer = createNdjsonLogger({
31
31
  filePath: EXTENSION_LOG_FILE,
32
32
  maxBytes: getMaxLogSizeMB() * 1024 * 1024,
@@ -1,8 +1,9 @@
1
+ import { escapeRegExp } from "./string-utils.js";
1
2
  function normalizeHintInput(value) {
2
3
  return value.replace(/\\/g, "/");
3
4
  }
4
5
  function hasHintToken(value, tokens) {
5
- const escaped = tokens.map((token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
6
+ const escaped = tokens.map((token) => escapeRegExp(token));
6
7
  const alternatives = escaped.join("|");
7
8
  // Path/word boundaries are deliberately explicit: a token must occupy a
8
9
  // segment (or a dot/dash/underscore-separated word), never an arbitrary
@@ -95,7 +95,12 @@ export class FileTime {
95
95
  const lockPromise = fn().finally(() => {
96
96
  globalState.locks.delete(absolutePath);
97
97
  });
98
- globalState.locks.set(absolutePath, lockPromise.then(() => { }));
98
+ // The STORED lock promise must never reject unhandled: a rejecting fn
99
+ // (e.g. partial-apply's pre-write rejection, #2402) would otherwise leave
100
+ // an orphaned rejected promise on every withLock caller. Waiters awaiting
101
+ // the stored copy still resume — the finally above already deleted the
102
+ // lock entry by the time the rejection settles.
103
+ globalState.locks.set(absolutePath, lockPromise.then(() => { }, () => { }));
99
104
  return lockPromise;
100
105
  }
101
106
  /**
@@ -5,10 +5,11 @@ import * as fs from "node:fs";
5
5
  import * as os from "node:os";
6
6
  import * as path from "node:path";
7
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 { isUnderDir, 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();
@@ -493,8 +568,17 @@ export function createProjectIgnoreMatcher(rootDir, extraPatterns = [], globalPa
493
568
  return buildProjectIgnoreMatcher(resolvedRoot, patterns);
494
569
  }
495
570
  const projectIgnoreMatcherCache = new Map();
496
- /** Nested ignore sources are checked at most once per root per cadence window. */
497
- export const PROJECT_IGNORE_FRESHNESS_CADENCE_MS = 2_000;
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;
498
582
  function fileFreshnessSignature(filePath) {
499
583
  try {
500
584
  const stat = fs.statSync(filePath);
@@ -627,6 +711,25 @@ export function invalidateProjectIgnoreMatcherForPath(filePath) {
627
711
  export function isPathIgnoredByProject(filePath, rootDir, isDirectory = false) {
628
712
  return getProjectIgnoreMatcher(rootDir).isIgnored(filePath, isDirectory);
629
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
+ }
630
733
  const projectIgnoreGlobsCache = new Map();
631
734
  export function getProjectIgnoreGlobs(rootDir) {
632
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
@@ -294,6 +322,7 @@ export const DELIVERY_SURFACES = {
294
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 " +
295
323
  "accumulator is drained and cleared at the moment of injection, so the " +
296
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"),
297
326
  "project-diagnostics:persisted-snapshot": gated(LENS_DIAGNOSTICS_FILE, "Cross-session persisted project-diagnostics snapshot read.", ["reconcileProjectDiagnosticsSnapshot"], ["reconcileProjectDiagnosticsSnapshot("]),
298
327
  // ── #2028: the remaining agent-facing surfaces ──────────────────────────
299
328
  // Registered after #2028's root-cause review found the 🔴 STOP block
@@ -324,8 +353,16 @@ export const DELIVERY_SURFACES = {
324
353
  "command. Both inputs are read at decision time — the instance registry " +
325
354
  "and `git status` — so no stored finding is replayed and nothing can go " +
326
355
  "stale between detection and delivery.", "live"),
327
- "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 — " +
328
- "no cached findings are replayed, so there is no staleness window.", "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"),
329
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"),
330
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 — " +
331
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
  }