pi-lens 4.4.5 → 4.4.7

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 (159) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +37 -1
  3. package/config/biome/core.jsonc +3 -3
  4. package/dist/{chunk-6XSESGWD.js → chunk-24BILSZW.js} +2 -2
  5. package/dist/{chunk-YXDCRUKQ.js → chunk-2PHMIAKO.js} +4 -4
  6. package/dist/{chunk-EN5AM7PX.js → chunk-2TF6RXWB.js} +10 -10
  7. package/dist/{chunk-XI34NWDI.js → chunk-3F6BMY53.js} +1 -1
  8. package/dist/{chunk-VUAVE3QC.js → chunk-3FRLWYBG.js} +36 -36
  9. package/dist/{chunk-THEXI2QO.js → chunk-3K2F6UDZ.js} +42 -42
  10. package/dist/{chunk-ZPJM7DID.js → chunk-3YY7IXIL.js} +3 -3
  11. package/dist/chunk-46TNM7XZ.js +88 -0
  12. package/dist/{chunk-TL2TCJYL.js → chunk-4L36HG27.js} +14 -14
  13. package/dist/{chunk-UCVMSOXF.js → chunk-4LM3VAZH.js} +2 -2
  14. package/dist/{chunk-AI3GP74G.js → chunk-4LOE5R5P.js} +15 -15
  15. package/dist/{chunk-AHWA4AKM.js → chunk-4YHYPW2G.js} +32 -9
  16. package/dist/{chunk-VITFDI3O.js → chunk-4ZYJHQMB.js} +12 -12
  17. package/dist/{chunk-KCBRHV5E.js → chunk-6IR3ZYIB.js} +3 -3
  18. package/dist/chunk-72OKUXSD.js +31 -0
  19. package/dist/{chunk-RCHO5W7M.js → chunk-75GAYVNO.js} +13 -12
  20. package/dist/{chunk-2SDHYHHO.js → chunk-7E2563GA.js} +13 -13
  21. package/dist/chunk-7GLOLOSH.js +57 -0
  22. package/dist/{chunk-CG5V25HX.js → chunk-ABPKUVA4.js} +1 -1
  23. package/dist/chunk-AKUUMGD5.js +26 -0
  24. package/dist/chunk-ASUXV767.js +22 -0
  25. package/dist/{chunk-Q42LJANT.js → chunk-AWDSEDER.js} +2 -2
  26. package/dist/{chunk-Y2TPADJR.js → chunk-BZARLRJW.js} +9 -9
  27. package/dist/{chunk-YKVDBNPO.js → chunk-CB4WHS4H.js} +3 -3
  28. package/dist/{chunk-YXGRRORB.js → chunk-CCV2EU7T.js} +13 -13
  29. package/dist/{chunk-PJXNTPB2.js → chunk-CE6VMBCB.js} +21 -21
  30. package/dist/{chunk-KPVLQHCZ.js → chunk-CPSR3AVL.js} +2 -2
  31. package/dist/chunk-CTADOKYM.js +25 -0
  32. package/dist/{chunk-CPZ5JJW6.js → chunk-DH5JPM3K.js} +4 -4
  33. package/dist/{chunk-4FHUGDKU.js → chunk-DPGEAHZT.js} +5 -5
  34. package/dist/{chunk-SNEUMLM7.js → chunk-DQZFQSR5.js} +4 -4
  35. package/dist/{chunk-RG3MXTRI.js → chunk-E7HJ56Y7.js} +7 -7
  36. package/dist/{chunk-YSDPVDFC.js → chunk-EAOK7MIZ.js} +3 -3
  37. package/dist/{chunk-PP2A5V2T.js → chunk-EKWX4WD3.js} +7 -7
  38. package/dist/{chunk-2LDMXL2M.js → chunk-F5Z6URKM.js} +2 -2
  39. package/dist/{chunk-72J27ICO.js → chunk-F6X3YJWD.js} +2 -2
  40. package/dist/{chunk-ELZRSR5N.js → chunk-F7K5IBZG.js} +41 -39
  41. package/dist/{chunk-EX4EXBW7.js → chunk-FB5SCCPT.js} +15 -15
  42. package/dist/{chunk-SJHC3BCZ.js → chunk-FZKFVUEC.js} +518 -233
  43. package/dist/{chunk-UVY4TOJH.js → chunk-GNSIWBAT.js} +3 -3
  44. package/dist/{chunk-EXVXBSGN.js → chunk-H7OR7DFZ.js} +20 -18
  45. package/dist/{chunk-NLIVE7L6.js → chunk-HO6LWE2E.js} +1 -1
  46. package/dist/{chunk-X3UTCXAA.js → chunk-HR3OJ3TH.js} +12 -12
  47. package/dist/{chunk-HYVXA3BB.js → chunk-HWDAVBFU.js} +23 -23
  48. package/dist/{chunk-ZSUX7KEM.js → chunk-J6JP25XU.js} +2 -2
  49. package/dist/{chunk-T4NGVFYI.js → chunk-JJ2RRESP.js} +8 -5
  50. package/dist/{chunk-RU34BA4D.js → chunk-JMEKXFOL.js} +34 -34
  51. package/dist/{chunk-IL7K66ZQ.js → chunk-KDX35VXP.js} +74 -18
  52. package/dist/{chunk-EDMLIW6W.js → chunk-KKCK636N.js} +12 -12
  53. package/dist/{chunk-KJJAVH3X.js → chunk-KPPJTH44.js} +6 -5
  54. package/dist/{chunk-5LRUKYFA.js → chunk-KW5JQPO5.js} +2 -2
  55. package/dist/{chunk-N3PLNNCW.js → chunk-KXF5R4UN.js} +1 -1
  56. package/dist/{chunk-YWNO5Q4R.js → chunk-L3CMBQMH.js} +17 -17
  57. package/dist/{chunk-YWWG4AQA.js → chunk-L5JYIU47.js} +24 -25
  58. package/dist/{chunk-K2GUZ4DN.js → chunk-LBLBAFG3.js} +4 -4
  59. package/dist/{chunk-APFJKOP6.js → chunk-LLS45EWB.js} +10 -2
  60. package/dist/{chunk-MKPCELNI.js → chunk-LS3QJRUB.js} +13 -13
  61. package/dist/chunk-LSC3VADM.js +23 -0
  62. package/dist/{chunk-F7BO6FWH.js → chunk-LUBPZN36.js} +11 -11
  63. package/dist/{chunk-ASRAO7KG.js → chunk-LV4UMYVH.js} +27 -27
  64. package/dist/{chunk-COOUUC5W.js → chunk-MB6PXBUA.js} +6 -6
  65. package/dist/{chunk-3WCEHYOI.js → chunk-MNJIXFX4.js} +1 -1
  66. package/dist/{chunk-FEDWAYDS.js → chunk-MPKRJBPK.js} +35 -15
  67. package/dist/{chunk-Q4BKKOVC.js → chunk-N5WSK2K7.js} +8 -8
  68. package/dist/{chunk-K4SZB56V.js → chunk-NA7SEXHE.js} +12 -8
  69. package/dist/{chunk-UL5SXQVX.js → chunk-O4BJFESU.js} +1 -1
  70. package/dist/{chunk-LMCTHJ2H.js → chunk-OE5ZBP7F.js} +18 -18
  71. package/dist/{chunk-NFNVDDGB.js → chunk-OSTKYB55.js} +1 -1
  72. package/dist/{chunk-27VWVB23.js → chunk-OXOI55RU.js} +10 -10
  73. package/dist/{chunk-7IYC4ENJ.js → chunk-PKES3ISE.js} +2 -2
  74. package/dist/{chunk-EWXXLS26.js → chunk-PQJFG24Z.js} +82 -12
  75. package/dist/{chunk-3SNDVPOR.js → chunk-PR6PO3ES.js} +8 -8
  76. package/dist/{chunk-63NMUNYP.js → chunk-PUZ3E2J4.js} +6 -6
  77. package/dist/{chunk-DS2USX5G.js → chunk-QHSNL7B2.js} +11 -11
  78. package/dist/{chunk-UO66IMVP.js → chunk-QOE342SU.js} +2 -2
  79. package/dist/{chunk-7ZS7MC24.js → chunk-R5MOQM2H.js} +107 -40
  80. package/dist/{chunk-JWOVP5BL.js → chunk-RC2Z6K47.js} +6 -6
  81. package/dist/{chunk-GLW3YDZZ.js → chunk-RORGS5II.js} +9 -9
  82. package/dist/{chunk-Y5KTA2OB.js → chunk-RQS4QQSD.js} +2 -2
  83. package/dist/{chunk-KFXCL4OV.js → chunk-RRV3FNNM.js} +22 -23
  84. package/dist/{chunk-GYRZ72R4.js → chunk-RZOXUSPC.js} +2 -2
  85. package/dist/chunk-SHLDT3OI.js +27 -0
  86. package/dist/{chunk-IEBJF3PN.js → chunk-SNDXCFRS.js} +15 -13
  87. package/dist/{chunk-XHLK33VM.js → chunk-T7A2HK2B.js} +16 -16
  88. package/dist/{chunk-WUY4BZEP.js → chunk-TIQJPRDD.js} +106 -50
  89. package/dist/{chunk-2FYKETQJ.js → chunk-U2SDMG7C.js} +5 -5
  90. package/dist/{chunk-EIKRZ32J.js → chunk-U5HPROLA.js} +2 -2
  91. package/dist/{chunk-2Y6OJRSI.js → chunk-U6VN4NVL.js} +3 -3
  92. package/dist/{chunk-OZNCKLOX.js → chunk-U7BD2QL7.js} +12 -12
  93. package/dist/chunk-UF7RTZSO.js +27 -0
  94. package/dist/{chunk-XHDBJODR.js → chunk-URCQWAQ4.js} +21 -21
  95. package/dist/{chunk-7FLRUH6B.js → chunk-V63BC55Q.js} +1 -1
  96. package/dist/{chunk-TVZRLTG6.js → chunk-VSFLRN5Y.js} +1 -1
  97. package/dist/{chunk-OMJ3OFBJ.js → chunk-VUZWQ7UG.js} +6 -6
  98. package/dist/chunk-W4WP2ERB.js +30 -0
  99. package/dist/{chunk-G224FADB.js → chunk-WDBICWH3.js} +1 -1
  100. package/dist/{chunk-4ODSZ35Z.js → chunk-WGRJOXED.js} +121 -155
  101. package/dist/{chunk-FWZRGGGY.js → chunk-WME2OQST.js} +39 -4
  102. package/dist/{chunk-MEFLGBCS.js → chunk-XT2HTCJ5.js} +3 -3
  103. package/dist/{chunk-VIDEKABZ.js → chunk-Y7F7IEE3.js} +55 -23
  104. package/dist/chunk-YES5CACN.js +73 -0
  105. package/dist/{chunk-ZAPSUBLU.js → chunk-YHC2O2WO.js} +7 -7
  106. package/dist/{chunk-GTDSYEA2.js → chunk-YISME6ON.js} +1 -1
  107. package/dist/{chunk-TPYYEDP5.js → chunk-YVHBNSME.js} +48 -29
  108. package/dist/{chunk-XWFIHYCH.js → chunk-Z2XAOKHK.js} +2 -2
  109. package/dist/{chunk-QT66NEYN.js → chunk-ZE3KXHS7.js} +3 -3
  110. package/dist/{chunk-S55TEC7I.js → chunk-ZGSJDWQU.js} +2 -2
  111. package/dist/{chunk-4U7GDSZQ.js → chunk-ZJTT47IG.js} +2 -2
  112. package/dist/{chunk-KX56K73G.js → chunk-ZKXQKGWZ.js} +2 -2
  113. package/dist/{chunk-5DKE4HGX.js → chunk-ZMAUPOMG.js} +34 -34
  114. package/dist/index.js +2446 -1303
  115. package/dist/mcp/analyze-cli.js +10 -10
  116. package/dist/mcp/cli.js +42 -42
  117. package/dist/mcp/server.js +724 -472
  118. package/dist/mcp/worker.js +61 -61
  119. package/dist/probes/installer.js +19 -19
  120. package/docs/agent-tools.md +39 -10
  121. package/docs/configuration.md +3 -1
  122. package/docs/defect-shapes.md +752 -0
  123. package/docs/dependencies.md +1 -0
  124. package/docs/environment-variables.md +14 -0
  125. package/docs/features.md +11 -1
  126. package/docs/globalconfig.md +12 -1
  127. package/docs/invariants/caches-stores.md +30 -0
  128. package/docs/invariants/dispatch-runners.md +164 -0
  129. package/docs/invariants/git-guard-host.md +87 -0
  130. package/docs/invariants/language-config.md +31 -0
  131. package/docs/invariants/lsp-trust-exec.md +292 -0
  132. package/docs/invariants/paths-os.md +59 -0
  133. package/docs/invariants/session-telemetry.md +114 -0
  134. package/docs/lsp-capability-matrix.md +89 -45
  135. package/docs/lsp-idle-eviction.md +3 -5
  136. package/docs/pi-lens-fixer.md +10 -2
  137. package/docs/pi-lens-merge-policy.md +17 -12
  138. package/docs/pi-lens-monitor.md +2 -2
  139. package/docs/pi-lens-orchestration.md +41 -0
  140. package/docs/pi-lens-release.md +20 -0
  141. package/docs/pi-lens-retro.md +3 -2
  142. package/docs/pi-lens-reviewer.md +6 -6
  143. package/docs/pi-lens-subagent.md +9 -6
  144. package/docs/schema/pi-lens-config-v1.json +23 -0
  145. package/docs/servercapabilities.md +1 -1
  146. package/docs/settings.md +5 -0
  147. package/docs/usage.md +5 -0
  148. package/package.json +3 -2
  149. package/dist/chunk-22Y2BM7H.js +0 -23
  150. package/dist/chunk-44X7VIKR.js +0 -73
  151. package/dist/chunk-54NIOJJZ.js +0 -25
  152. package/dist/chunk-7WWQAW5P.js +0 -30
  153. package/dist/chunk-EA2ZRG44.js +0 -27
  154. package/dist/chunk-EKNWOL2I.js +0 -27
  155. package/dist/chunk-G5UCJFT7.js +0 -26
  156. package/dist/chunk-N5FBM25N.js +0 -22
  157. package/dist/chunk-P5XUGPIX.js +0 -31
  158. package/dist/chunk-PKOXJIVT.js +0 -88
  159. package/dist/chunk-RG7OODGM.js +0 -57
@@ -50,6 +50,7 @@ Auto-install behavior depends on gate type:
50
50
  | `gitleaks` | Committed-secret session scan | Auto-install | Opt-in (config / hook / dep) |
51
51
  | `govulncheck` | Go reachable-CVE session scan | `go install` | Auto (`go.mod` present) |
52
52
  | `trivy` | Dependency-CVE session scan | Auto-install | Explicit opt-in (`trivy.enabled`) |
53
+ | `fallow-lsp` | JS/TS unused-code, duplication and cycle advisories | Auto-install | Explicit opt-in (`fallow.enabled`, pinned GitHub release) |
53
54
  | `psscriptanalyzer` | PowerShell linting | Manual | — |
54
55
 
55
56
  Lean LSP is launched as `lake serve` from the detected Lake project root, so elan selects the toolchain from that project's `lean-toolchain` file and Lake supplies its project environment. pi-lens does not install or manage Lean/elan; install Lean and Lake separately and ensure `lake` is on `PATH`.
@@ -208,6 +208,20 @@ Unset or `0` preserves the prior local-LSP behavior exactly. Any transport,
208
208
  schema, freshness, deadline, or incumbent-liveness failure permanently falls
209
209
  back to a local LSP fleet for that session.
210
210
 
211
+ ## Variables pi-lens sets for its child processes
212
+
213
+ ### `GIT_OPTIONAL_LOCKS`
214
+
215
+ pi-lens starts the child processes it runs through its spawn seam (its
216
+ background `git status` reads included) with `GIT_OPTIONAL_LOCKS=0`, so a read
217
+ does not refresh the index and cannot leave `.git/index.lock` behind after a
218
+ timeout or a host exit. The value you export in your shell does not change this
219
+ for those children, and your own git commands are unaffected. A caller that
220
+ passes its own environment to a child keeps its value. Language servers are
221
+ launched separately and inherit your environment unchanged. On a checkout whose
222
+ index is stat-dirty, each status read re-hashes the dirty files until one of
223
+ your own git commands refreshes the index.
224
+
211
225
  ## Language-specific
212
226
 
213
227
  ### Ambient Python environments (`VIRTUAL_ENV`, `CONDA_PREFIX`, `UV_PROJECT_ENVIRONMENT`)
package/docs/features.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### LSP Support
4
4
 
5
- pi-lens includes **49 language server definitions** (including four cross-cutting *auxiliary* scanners that attach alongside the file's language server — Opengrep, ast-grep, zizmor, and typos — see below). LSP is **enabled by default**; use `--no-lsp` to disable it for a session. Servers are auto-discovered from PATH, project `node_modules`, and managed installs. When a server with a managed installer is not installed, pi-lens offers an interactive install prompt; toolchain-bundled servers, such as Lean's `lake`, are PATH-only, and pi-lens never installs or manages them.
5
+ pi-lens includes **50 language server definitions** (including four cross-cutting *auxiliary* scanners that attach alongside the file's language server — Opengrep, ast-grep, zizmor, and typos — and one opt-in, JS/TS-only auxiliary, fallow, off unless `fallow.enabled` is set; see below). LSP is **enabled by default**; use `--no-lsp` to disable it for a session. Servers are auto-discovered from PATH, project `node_modules`, and managed installs. When a server with a managed installer is not installed, pi-lens offers an interactive install prompt; toolchain-bundled servers, such as Lean's `lake`, are PATH-only, and pi-lens never installs or manages them.
6
6
 
7
7
  **LSP Idle Management:** LSP servers shut down after 240 seconds of inactivity (no files modified) to free resources. The timer resets when you resume editing, preventing cold-start penalties during active development.
8
8
 
@@ -22,6 +22,16 @@ pi-lens includes **49 language server definitions** (including four cross-cuttin
22
22
  LSP servers for: TypeScript, Deno, Python (pyright/basedpyright + jedi), Go, Rust, Ruby (ruby-lsp + solargraph), PHP, PowerShell, C# (omnisharp), F#, Java (JDT LS, with Lombok javaagent support when a Lombok jar is available), Kotlin, Lean, Swift, Dart, Lua, C/C++, Zig, Haskell, Elixir, Gleam, Typst (tinymist), Markdown (marksman), OCaml, Clojure, CUE (syntax and parse diagnostics; evaluation errors via the cue-vet auxiliary runner), Terraform, Nix, Bash, Shuck (zsh-aware shell language server), Fish, CMake, Docker, YAML, JSON, HTML, TOML, Prisma, Vue, Svelte, CSS.
23
23
 
24
24
 
25
+ ### TypeScript and JavaScript server
26
+
27
+ pi-lens picks the launch for JS/TS files in this order. The first two steps use only the project's own `node_modules`:
28
+
29
+ 1. **Effect language service** — when the nearest `node_modules/typescript` is version 7 or newer and the same `node_modules` holds `@effect/tsgo`, pi-lens runs the project's `effect-tsgo tsc --lsp --stdio`. Installing the package is the opt-in; there is no pi-lens setting. A malformed `@effect/tsgo` (no readable version, no `bin`) or a failure to start the process falls back to the next step; a server that starts and then fails to initialize does not fall back, and pi-lens never installs `@effect/tsgo`.
30
+ 2. **Native TypeScript 7** — the project's `node_modules/.bin/tsc --lsp --stdio`.
31
+ 3. **Classic** — `typescript-language-server` with a `tsserver.js`, when the nearest TypeScript is version 6 or older or no step above applies. This step can also use a server and TypeScript found on `PATH` or installed by pi-lens.
32
+
33
+ The nearest installed `typescript` decides: an ancestor's TypeScript 7 never replaces a nearer, older or malformed install. The project's own compiler and launcher run only when pi has marked the project trusted (see [Configuring pi-lens](configuration.md)); otherwise the launch falls through to the next step.
34
+
25
35
  ### Python: interpreter and syntax level
26
36
 
27
37
  Python carries two separate declarations, and pi-lens reads both from the project rather than from whichever interpreter happens to run a checker.
@@ -18,6 +18,10 @@ Each runtime toggle is settable from the CLI *and* from `config.json`. The two a
18
18
  | `--no-tests` | `tests.enabled` | `true` |
19
19
  | `--no-delta` | `delta.enabled` | `true` |
20
20
  | `--no-opengrep` | `opengrep.enabled` | `true` |
21
+ | `--no-ast-grep` | `astGrep.enabled` | `true` |
22
+ | `--no-zizmor` | `zizmor.enabled` | `true` |
23
+ | `--no-typos` | `typos.enabled` | `true` |
24
+ | `--lens-spotbugs` | `spotbugs.enabled` | `false` |
21
25
  | `--no-read-guard` | `readGuard.enabled` | `true` |
22
26
  | `--no-autoformat` | `format.enabled` | `true` |
23
27
  | `--no-autofix` | `autofix.enabled` | `true` |
@@ -37,6 +41,7 @@ Each runtime toggle is settable from the CLI *and* from `config.json`. The two a
37
41
  | `--lens-compact-widget` | `ui.compactWidget` | `false` |
38
42
  | `--no-lazy-tools` | `tools.lazy` | `true` |
39
43
  | `--lens-turn-end-madge` | `turnEnd.madge.enabled` | `false` |
44
+ | `--lens-fallow` | `fallow.enabled` | `false` |
40
45
  | `--no-knip` | `knip.enabled` | `true` |
41
46
  | `--no-jscpd` | `jscpd.enabled` | `true` |
42
47
  | `--no-madge` | `madge.enabled` | `true` |
@@ -147,6 +152,8 @@ Hide the diagnostics widget by default, run formatting immediately after write/e
147
152
 
148
153
  `turnEnd.madge.enabled` (default `false`) runs the per-turn-end madge circular-dependency check on import-changed files. It is off by default because that pass only writes debug output — user-facing madge diagnostics come from the session-start scan cache and the `lens_diagnostics` extractor — and its subprocess spawns dominated the turn-end latency tail (#766). Enable it with `--lens-turn-end-madge` or `turnEnd.madge.enabled: true` if you want the per-edit circular-dependency note.
149
154
 
155
+ `fallow.enabled` (default `false`, or `--lens-fallow`) runs [fallow](https://github.com/fallow-rs/fallow)'s `fallow-lsp` beside the TypeScript server on JS/TS files (`.ts .tsx .js .jsx .mjs .cjs .mts .cts`; no other file ever attaches it). It reports unused files, exports and dependencies, duplication and cycles as advisory warnings and never blocks. It overlaps knip, jscpd and madge, which keep running either way. Only the exact value `true` turns it on: an absent, misspelled or non-boolean value leaves it off, and pi-lens installs and launches nothing. On first use pi-lens downloads the pinned fallow release into `~/.pi-lens/tools/fallow-lsp` (a `fallow-lsp` already on `PATH` wins); the install is refused on a checksum mismatch. The per-edit diagnostics path runs it; the aggregate all-server checks (`lens_diagnostics source=lsp`, workspace sweeps) do not start it.
156
+
150
157
  `ignore` is an array of gitignore-style glob patterns excluded from pi-lens scans across **every** project — the global counterpart to the per-project `.pi-lens.json` `ignore` below. Precedence is lowest: a project `.gitignore` or `.pi-lens.json` (including a `!negation`) overrides it, so you can globally hide e.g. `scratch/**` and still re-include it in one repo.
151
158
 
152
159
  Turn subsystems off globally instead of retyping flags every session:
@@ -156,12 +163,16 @@ Turn subsystems off globally instead of retyping flags every session:
156
163
  "lsp": { "enabled": false },
157
164
  "tests": { "enabled": false },
158
165
  "opengrep": { "enabled": false },
166
+ "astGrep": { "enabled": false },
167
+ "zizmor": { "enabled": false },
168
+ "typos": { "enabled": false },
169
+ "spotbugs": { "enabled": true },
159
170
  "readGuard": { "enabled": false },
160
171
  "guard": { "enabled": true }
161
172
  }
162
173
  ```
163
174
 
164
- `lens.enabled: false` starts every session with pi-lens off (the `--no-lens` equivalent); `/lens-toggle` still re-enables it for one session. `lsp.enabled: false` falls back to language-specific checkers such as pyright. `tests.enabled: false` skips the on-write test runner. `delta.enabled: false` reports every diagnostic rather than only ones introduced this turn. `opengrep.enabled: false` detaches the Opengrep security scanner. `readGuard.enabled: false` turns off the read-before-edit monitor. `guard.enabled: true` opts into the experimental commit/push blocker.
175
+ `lens.enabled: false` starts every session with pi-lens off (the `--no-lens` equivalent); `/lens-toggle` still re-enables it for one session. `lsp.enabled: false` falls back to language-specific checkers such as pyright. `tests.enabled: false` skips the on-write test runner. `delta.enabled: false` reports every diagnostic rather than only ones introduced this turn. `opengrep.enabled: false` detaches the Opengrep security scanner. `astGrep.enabled: false` detaches the ast-grep auxiliary server. `zizmor.enabled: false` and `typos.enabled: false` detach the zizmor and typos auxiliary servers. `spotbugs.enabled: true` opts into SpotBugs on Java and Kotlin files (it also needs a Java build descriptor and a compiled `.class` directory). `readGuard.enabled: false` turns off the read-before-edit monitor. `guard.enabled: true` opts into the experimental commit/push blocker.
165
176
 
166
177
  The `tools.<name>.enabled` setting controls each model-facing tool. Valid names
167
178
  include `ast_grep_search`, `ast_grep_replace`, `ast_grep_outline`,
@@ -0,0 +1,30 @@
1
+ <important if="touching caches, stores, and project intelligence rules">
2
+
3
+ ### Caches, stores, and project intelligence
4
+
5
+ - Behavior-gating durable stores use `clients/durable-store.ts`: lock, re-read,
6
+ merge the caller delta, atomically publish, refresh coupled mirrors before
7
+ releasing the lock. Best-effort derived caches declare their loss policy.
8
+ - Every cache states its freshness axes, bound, eviction axis, and invalidation
9
+ source. A bounded entry count does not excuse unbounded bytes, timers, WASM
10
+ objects, or persisted evidence.
11
+ - Workspace diagnostics cache mtime-drift hashing is limited by
12
+ `CONTENT_HASH_MAX_BYTES` in `clients/content-stamp.ts`; larger entries retain
13
+ strict mtime invalidation. Persistent reverify keeps zero mtime tolerance;
14
+ session-state restore keeps its 1 ms tolerance.
15
+ - Tree-sitter's `queryBatchCache` is invalidated by `clearWasmInput` when a
16
+ trapped query heals, because an in-flight batch may have cached a result that
17
+ omitted the healed rule (#3834).
18
+ - Async publication carries a generation or epoch and checks it before and
19
+ after awaited work. Graph snapshots are immutable by replacement.
20
+ - Review-graph, snapshot, reverse-dependency, word-index, and call-graph data
21
+ use path identities and explicit partial-coverage markers. A capped walk is
22
+ lower-bound evidence, never a clean zero.
23
+ - Tree-sitter uses the shared client and file-major project passes. Grammar
24
+ crashes are blocked before load; source overrides record package/version
25
+ provenance. Real grammar and rule tests use the warmed shared client.
26
+ - `module_report` and `symbol_search` are read-only orientation surfaces.
27
+ `read_symbol` and `read_enclosing` return bodies and record pi read coverage;
28
+ outlines do not claim body coverage. MCP adapters call `lens-engine.ts` only.
29
+
30
+ </important>
@@ -0,0 +1,164 @@
1
+ <important if="touching dispatch, runners, formatters, and installers rules">
2
+
3
+ ### Dispatch, runners, formatters, and installers
4
+
5
+ - The analysed-state latch records a pipeline-owned target hash captured after
6
+ pi-lens writes and before LSP or dispatch awaits. `fileModified` also covers
7
+ side-effect files, so `postWriteStateHash` is the ownership discriminator;
8
+ an absent hash must not stamp the target with later disk bytes (#2499).
9
+ - The opaque prescan resolves its root once, through `opaquePrescanRoot`
10
+ (`clients/opaque-mutation-scan.ts`), and every consumer of that session root
11
+ asks the same owner: the baseline record and take, the head-move record and
12
+ take, and the root each held-primary send is scoped by. A
13
+ session whose cwd is not the coordinator's `projectRoot` — a concurrent
14
+ secondary session, which the host's session-start guard declines before any
15
+ `session_start` body runs — otherwise records its baseline and its HEAD under
16
+ one root and takes them under another, reporting `no-pending-snapshot` for a
17
+ command that did write. Scan evidence is scoped to the checkout it ran in: a
18
+ recognized write outside that root is kept (never cleared by a scan that
19
+ could not see it) and earns no authorship the scan cannot confirm.
20
+ - A bash command's writes are recovered from that session root AND from every
21
+ checkout the command ITSELF names — its `cd`/`pushd` target or a recognised
22
+ write operand — when that checkout is a linked worktree of the session's own
23
+ repository (`resolveOpaqueRecoveryRoots`, `sameCheckoutOtherRoot`). Both hooks
24
+ derive bounded root lists (`OPAQUE_RECOVERY_ROOT_CAP`) from the command text,
25
+ the session root, and the checkout each hook sees at its own instant, so a
26
+ worktree the command itself creates is admitted only at `tool_result` and its
27
+ missing baseline is reported as `partial-recognition-no-baseline`, while a
28
+ root both hooks admit still names one key for its record and its take; a
29
+ checkout of another repository, a checkout named past the cap, and a
30
+ git target under a non-checkout session root each leave one bounded
31
+ `opaque-recovery-root-refused` record per session. This is why a `cd` into a
32
+ sibling worktree no longer reads a clean `git status` in the wrong checkout as
33
+ "nothing changed". Relative operands resolve against the directory in effect
34
+ for their own segment (`scanShellWriteScopes`). That directory moves only for
35
+ an admitted form: `cd DIR` or `pushd DIR` whose one operand is a plain
36
+ path: bash's own word after quote removal, made only of admitted characters
37
+ (any quoted one, an escape bash also removes, an unquoted letter, digit or
38
+ `_./@%:,=+-`, and a leading `~` only as `~` or `~/`), starting with a
39
+ letter, digit, `_`, `.`, `/` or `~`; or a bare `popd` of a push the scan
40
+ admitted, entered at list start or after `&&`, `;`, a newline
41
+ or a backgrounded list, ended by `&&`, `;`, a newline or the end, and in no
42
+ pipeline or backgrounded list. A move entered after `&&` holds only to the end
43
+ of that `&&` chain, because it happened only if the left side succeeded. A
44
+ directory builtin in a pipeline or a backgrounded list leaves the directory
45
+ unchanged. Any other directory change, construct or shell-text builtin
46
+ returns the scan to the session root for the rest of the command.
47
+ - A recovered write is judged by the checkout that OWNS it, in both directions:
48
+ the ignore gate a synthetic bash-write dispatch passes asks the `.gitignore`
49
+ of the root that admitted the write (`_ownerRoot`), not the session root's, so
50
+ a linked worktree nested under a directory the session checkout ignores is
51
+ analysed instead of dropped silently (`.claude/worktrees/` in this
52
+ repository); and admission asks `analysis-root.ts`
53
+ (`canWriteAnalysisRoot(resolveAnalysisRoot(...))`) rather than re-deriving the
54
+ rule. Ownership is compared by REAL path, so a `cd` into a symlinked spelling
55
+ of a worktree keeps its authorship and its observed identity.
56
+ - `RUNNERS` declarations include file kinds. Runner selection is gated by file
57
+ kind and anchored at the file's language root, not by dispatch-root config or
58
+ declaration order. Runner children use `resolveToolCwd` with launcher markers.
59
+ - Automatic tests do not cross a Git checkout boundary, including through
60
+ filesystem aliases: `foreignGitRoot` (`clients/test-runner-client.ts`) gates
61
+ failed-first cache admission, retirement, every discovery path, and the
62
+ turn-end gate. Indeterminate ownership is not a foreign verdict, a deleted
63
+ target retires as `retired-missing`, and final rejections emit
64
+ `test-target-foreign-checkout`. Proven by
65
+ `tests/clients/test-runner-worktree-isolation.test.ts`.
66
+ - By design, a session whose cwd is a plain folder with no `.git` that holds several repositories, a submodule, or a nested linked worktree gets no automatic tests for the files inside them: any nested `.git` is a foreign checkout, and there is no per-project opt-in (maintainer decision, #3649/#3691). Run them explicitly.
67
+ - The one exception to that boundary is a linked worktree of the session's own repository (same git commondir, different top level, `resolveLinkedWorktreeOwner` in `clients/review-graph/git-identity.ts`, #3871): turn_end selects and runs its tests with that worktree's root as the project root (`clients/test-target-roots.ts`), so config, `node_modules` and the failed-first state are the worktree's own. A worktree root without its own runner install (no `node_modules/.bin`, venv or `vendor/bin`) is skipped with a counted `turn-end-test-root-skipped` row rather than run through `npx` or a bare interpreter; a reported location is rebased through `displayRoot` using the runner cwd first, then the dispatch root, only when that file exists, and otherwise remains as printed. A sibling worktree's file is still foreign to every other root. Python's ambient `VIRTUAL_ENV`, `CONDA_PREFIX`, or absolute `UV_PROJECT_ENVIRONMENT` is accepted for the session checkout, and for a linked worktree only when the environment root is inside that checkout; a skipped pytest row says that ambient environments were not borrowed when one is set. The edit worklist is the session's project worklist (#2504), so a session whose cwd is itself a linked worktree never sees an edit in the main checkout or a sibling and runs only its own tests. Each turn that edited files writes one `turn_end_test_selection` record to `latency.log` (candidates, selected, why not, and selected/candidates per owning root; first 8 roots, the rest in `rootsOmitted`; `selected` includes carried deferred targets, which no candidate bucket counts, so per-root `selected` can sum below it; one row of about 570 B per edit turn with candidates, bounded by log rotation only), so a turn with 0 tests is explained without the dbg lines the MCP route drops.
68
+ - Managed tools resolve through the registry and sanctioned availability seams.
69
+ Do not hand-roll install, PATH, or package-manager discovery. Use typed
70
+ `SpawnFailure.kind`; repair only `tool-not-found`.
71
+ - Windows LSP startup exit-code-1 failures are repairable only when the shared
72
+ command resolver finds no command or an npm shim target is absent; present
73
+ binaries that exit 1 remain runtime failures (#4263, #1199). The launch and
74
+ repair gate are pinned by `tests/clients/lsp/windows-startup-repair.test.ts`.
75
+ - Expected skips remain distinct from clean success and failure. Extend the
76
+ closed `RUNNER_SKIP_REASONS` taxonomy when policy intentionally defers work.
77
+ Preserve the skip reason through runner latency and model-facing delivery.
78
+ - `scripts/ci-verdict.mjs` ends every CLI path with `ci-verdict: exit <N> (<kind>)`;
79
+ read that final stdout line instead of `$?` after a pipe. `guard-bash` denies
80
+ the piped-status recurrence while allowing output-only pipes.
81
+ - A formatter is handed the file's identity, never the link that named it:
82
+ `realpathOrResolve` (`clients/path-utils.ts`) is the real path
83
+ of the nearest existing ancestor plus the missing tail, with no lexical `..`
84
+ collapse first. `formatFile` and `FormatService.formatFile` use it, so
85
+ `AGENTS.md -> CLAUDE.md` formats `CLAUDE.md` and Prettier's "is a symbolic
86
+ link" rejection never occurs. `FormatService.formatFile` also requires
87
+ `sessionRoot` and classifies the identity through `resolveAnalysisRoot`: an
88
+ `adopted` or `none` identity is refused, writes nothing, and records one
89
+ `adopted-root-writer-skipped` row (`writer: "format"`). The refusal is on
90
+ identity, not spelling, so a plain file outside every writable root (a
91
+ sibling package of a monorepo session cwd, say) is refused as well; a caller
92
+ that must format it passes that root as `sessionRoot`. Proven by
93
+ `tests/clients/format-service-symlink-identity.test.ts`.
94
+ - Formatter and autofix policy is config-first where the registry says so.
95
+ Formatting is strict by default. Autofix must carry per-diagnostic fixability
96
+ or a conservative capability allowlist.
97
+ - Analyzer and runner fallback filters must match the substituted surface's
98
+ contract. Empty output distinguishes clean, skipped, unavailable, errored,
99
+ inconclusive, and partial states.
100
+ - Every autonomous writer (pipeline autofix, immediate/deferred formatter, and
101
+ actionable-warning quickfix) resolves through `clients/tool-agreement.ts`.
102
+ Its declarative population assigns one evidence bucket and declines absent,
103
+ unreadable, unparseable, unsupported, or unregistered evidence; callers emit
104
+ bounded degradation records. Ktlint's standalone-CLI exception still
105
+ declines Gradle-owned projects without guessing a CLI version.
106
+ - Node tool agreement in `nodeAgreement` is established from the project's lockfile evidence in the deterministic order npm (`package-lock.json`) → pnpm (`pnpm-lock.yaml`, v9 `importers` and v6 top-level maps) → yarn (`yarn.lock`, v1 blocks and Berry `npm:` descriptors); the decision names the supplying lockfile, and missing, unreadable, unparseable, or shape-unsupported evidence declines.
107
+ - A whole-package fixer (`cargo clippy --fix`, `dart fix --apply`) rewrites
108
+ files pi's mutation queue does not hold, so it runs through
109
+ `runWithFixRestore` (`clients/fix-run-restore.ts`, #3598): hash the tool's
110
+ source files, capture agent mutations pi-lens observes during the run (the
111
+ tool_result seam and the mutation bridge), write them back after, one
112
+ degradation per run, and name any edit that cannot be restored. The restore
113
+ takes pi's queue entry for each sibling, one at a time (#3830). It starts
114
+ after the caller's scan of the tool's changes and is awaited only after the
115
+ target's hold is released, never inside it. The tool_result pipeline does not
116
+ await it (F's result must not wait on a sibling's holder; the loss notice is
117
+ queued as an advisory), the `agent_end` drain does, after the release: a queue entry is requested by something that holds no other
118
+ entry, except the multi-path LSP edit, which requests in ascending key order,
119
+ and nothing that holds an entry awaits the restore. Do not add a second
120
+ whole-package fixer without it, and do not await a queue entry while holding
121
+ another.
122
+ - A file's first write in a session blocks on the linter delta, not on every
123
+ linter error. The `tool_call` of the first classified write or edit
124
+ runs the file's inline linters (`PRE_EDIT_SEED_RUNNER_IDS`, tied to the
125
+ edit-scope census's LINTER lanes) over the bytes still on disk, under
126
+ `bounded()` with `PRE_EDIT_CAPTURE_BUDGET_MS` (500 ms), and installs their blocking
127
+ findings as `session.preEdit.<file>` beside the delta baseline. The capture
128
+ admits at most four active captures, aborts their process groups on abandonment
129
+ or session reset, and retains slots until teardown settles. It
130
+ only creates that record, and only while no baseline, tombstone or seed
131
+ exists, the bytes are the ones it read, and its session is current; each
132
+ dispatch only shrinks it (`classifyPreExisting`, identity plus line text,
133
+ one current finding per entry). A matched finding is reported as
134
+ pre-existing, never as a blocker, unless the inline record already holds
135
+ it. Language servers, type checkers, gated runners and scanners are never
136
+ seeded (maintainer scope, 2026-10-15). Collect-later linters and the MCP
137
+ route have no seed. Proven by
138
+ `tests/index-4483-first-write-seed-witness.test.ts`.
139
+ - `clients/dispatch/runners/runner-spawn-cwd-sweep.test.ts` is the population
140
+ guard for child cwd derivation. Add a reasoned migration row instead of a
141
+ pin-only update.
142
+ - Each real-bytes fixture under `tests/fixtures/runner-output/` records the
143
+ availability probe its runner sends (`availability`: the argv, the binary
144
+ that answered from its own banner, and the real exit status) and a real clean
145
+ run (`clean`; there is no prose alternative). The clean record is the
146
+ fixture's own invocation run in `tests/fixtures/runner-output-clean/<runner>`,
147
+ whose inputs are un-ignored by `.gitignore` on purpose. One gate,
148
+ `recordProblems` in `scripts/capture-runner-output.mjs`, refuses a record whose
149
+ version its own answer never printed, and a clean run whose argv is not this
150
+ fixture's; the capture and the census both call it.
151
+ `captured-real-output.test.ts` runs the REAL checker against that record
152
+ instead of mocking it, so a tool that rejects its own probe — helm 4 rejects
153
+ `--version` — reaches the replay; the clean bytes are what the matrix's clean
154
+ cell replays, in the clean workspace. `scripts/capture-runner-fixtures.mjs
155
+ --records-only` retrofits those records onto an existing fixture without
156
+ touching its work bytes, keyed on the fixture's own case.
157
+ Enforced by `tests/clients/dispatch/smoke-fixture-coverage.test.ts` and
158
+ `tests/clients/dispatch/tool-state-matrix.test.ts`.
159
+ - Every `parseToolRun` runner documents its nonzero-exit table; the documented
160
+ `ran` codes are pinned exactly so adding or removing one does not pass
161
+ silently, and each documented code needs an executable status fixture in the
162
+ runner's own test matrix (#3292).
163
+
164
+ </important>
@@ -0,0 +1,87 @@
1
+ <important if="touching git guard and host adapters rules">
2
+
3
+ ### Git guard and host adapters
4
+
5
+ - Git command classification has one lexer and one guarded-verb matcher seam.
6
+ Unknown wrappers and indirect guarded verbs fail closed. Text-consumer
7
+ allowances recurse through command substitutions and execution contexts. A
8
+ substitution's output is read both empty and opaque (shape 61).
9
+ - The commit gate reads two states: the inline-blocker map's latch
10
+ (`RuntimeCoordinator`), then the persisted `turn-end-findings` record. A
11
+ collect-later runner's blocking findings join the map through
12
+ `clients/deferred-runner-blockers.ts`, never a second store: the turn-end
13
+ late-runner lane records them before the blocker replay (so the replay is
14
+ their one delivery and the composer persists them), and the gate judges
15
+ answers that settled but no turn end has drained, then refreshes the
16
+ persisted record (`syncGitGuardRecord`) as the inline path does at
17
+ `tool_result`. Both sites call one verdict, `judgeDeferredRunnerFindings`
18
+ (freshness, then policy), and the record's `sources` and `lines` come from
19
+ `clients/inline-blocker-fields.ts`, shared with the pipeline's writer. A run
20
+ still in flight does not gate, and an edit to the file while its re-check is in
21
+ flight clears the record until that answer settles (#3814). The gate and the
22
+ record's writers in `clients/git-guard.ts` and the turn-end composer read it
23
+ at any age. Each blocker section keeps the session that wrote it (top-level
24
+ `sessionId`, other owners in `carriedBlockers`; a record without that field
25
+ is one owner's), and a writer replaces only its own session's sections.
26
+ Another session's section leaves only for a file a dispatch checked
27
+ whole and found clean (`checkedWholeFile`), or whose file is gone. Its text
28
+ no file owns (a project lane's report: CVEs, secrets, cascade) leaves only
29
+ when its owner rewrites it, or at a turn end once `DEFAULT_MAX_AGE_MS` has
30
+ passed since its owner's own write (`blockerWrittenAt`, per partition; the
31
+ record's own timestamp moves with every writer). A record written before
32
+ this version has no stamp: the first turn end of another session that
33
+ carries it (a composer write or a settled turn end) writes one, and its
34
+ window starts there. Only a write logs what it drops. The gate judges a
35
+ record alone only when this session is its sole owner. A settled turn end
36
+ drops this session's sections and another session's expired text no file
37
+ owns, and retires a record that is this session's own, claims no blocker, or
38
+ holds no structured claim (the `--lens-guard`-off writer's), with one
39
+ `record_retired` row (#4725). A dispatch that never answered
40
+ (`pipeline_crash`, `pipeline_error`) is latched per file, apart from the
41
+ record's latch, and only that file's own returning dispatch clears it.
42
+ - Inline blockers have owners (#4921). A blocker belongs to the turn session
43
+ whose write recorded it; a record with no `session` is the coordinator's.
44
+ The commit gate reads every record, whoever owns it, because the tree is
45
+ shared. A turn end reads only its own session's records: it delivers,
46
+ sweeps, re-judges and consumes those, and files its guard section under its
47
+ own id. Only a write by the coordinator's session latches
48
+ `session_mismatch`; a concurrent session's write leaves another
49
+ session's record and the latch alone.
50
+ - The commit gate is keyed by the repository being committed (#4941), not by
51
+ session. A commit/push is judged by the unresolved blockers whose files lie
52
+ in the git checkout it targets (`resolveGitCheckout`, the seam the review
53
+ graph and the analysis root use) or in a checkout nested inside it, whoever
54
+ wrote them; a linked worktree of the committed repository is a checkout of
55
+ its own, never the parent's. This covers every reader the gate has: the
56
+ inline-blocker latch memo, the stale-suppression scan, the dispatches that
57
+ never answered, and the record-failure latch, which holds one reason per
58
+ project (a failure or a write about repository B never replaces or clears
59
+ repository A's). A sub-agent committing in repository B is not refused for a
60
+ blocker in repository A; one committing where the blocker is still is. The
61
+ target comes from `resolveCommitScope` and fails closed: only plain `git`
62
+ segments (spelled `git` or a system path such as `/usr/bin/git`; global
63
+ option `-C <existing, unexpanded directory>` only) beside a short list of
64
+ neutral commands (`echo`, `tail`, ...) are placed in a tree, and only in a
65
+ process whose environment sets none of `GIT_DIR`, `GIT_WORK_TREE`,
66
+ `GIT_COMMON_DIR`. The gate never resolves PATH, so a bare `git` is trusted
67
+ whatever executable the shell finds under that name. `cd`, an assignment,
68
+ `--git-dir`, `--work-tree`, `-c`, a wrapper or any other path named `git`, a
69
+ `~` operand, a substitution that runs git, any other command in the chain,
70
+ or a directory outside a checkout leaves the command unscoped, and an unscoped command, a verdict that names no
71
+ file, and a caller that passes no command are judged by every blocker. The
72
+ persisted `turn-end-findings` record stays the committing session's
73
+ project's (`cwd`): for `git -C <other repo> commit` it is not read for the
74
+ targeted repository, so that record's blocker can be missed (a gap that
75
+ predates #4941).
76
+ - The shared-checkout guard refuses unsafe worktree mutation when another live
77
+ session and uncommitted work are both proven. It never auto-stashes.
78
+ - `mcp/server.ts` talks to pi-lens through `clients/lens-engine.ts`. A mirrored
79
+ capability is one engine method plus one route. MCP transport remains
80
+ hand-rolled and dependency-free.
81
+ - Host SDK imports are type-only, except the one lazy, caught lookup of pi's
82
+ `withFileMutationQueue` in `index.ts` (#3506), admitted by count in
83
+ `tests/host-sdk-type-only.test.ts`; `clients/file-mutation-queue.ts` detects
84
+ and records a second SDK copy. Runtime dependencies belong in
85
+ `dependencies`.
86
+
87
+ </important>
@@ -0,0 +1,31 @@
1
+ <important if="touching language and configuration rules">
2
+
3
+ ### Language and configuration
4
+
5
+ - `clients/language-registry.ts` is the identity source for language ids,
6
+ extensions, filenames, file kinds, LSP ids, and grammars. Consumers project
7
+ from it; they do not maintain parallel language tables.
8
+ - Agent-facing advisory text resolves names through `resolveLensToolName` with
9
+ the delivery host: pi uses `piName`, and MCP uses `mcpName` from
10
+ `TOOL_REGISTRY`. Known tools without a host mapping resolve to `undefined`,
11
+ so callers omit or rephrase them; pi-only rows require
12
+ `PI_ONLY_TOOL_REASONS`. Do not add a second name map or hard-code a pi tool
13
+ name in advisory output (#2535).
14
+ - `clients/config-core/` owns schema validation, normalization, merging,
15
+ provenance, deny precedence, merge strategies, trust-gated process specs,
16
+ and bounded migration records. Existing LSP, global, and project loaders
17
+ adopt it without adding another merge implementation.
18
+ - Canonical config is `.pi-lens.json` plus `~/.pi-lens/config.json`; locations,
19
+ legacy migrations, and namespaces live in the config-location/schema modules.
20
+ A new config key or environment flag needs a forcing function, stability tier,
21
+ diagnostic code, tests, and docs.
22
+ - `rules.<id>.ignorePaths` is an experimental, project-relative path denial
23
+ resolved by config-core with array-union semantics: global entries cannot be
24
+ cleared by project config. Ast-grep and tree-sitter apply it before scanning;
25
+ other runner output uses the shared rule-policy filter.
26
+ - `lens_diagnostics` has one model-facing diagnostic surface. `source` is
27
+ `session` or `lsp`; `scope` is `paths` or `workspace`; explicit paths always
28
+ win. Severity is a threshold. Retired compatibility names must not widen a
29
+ request into a workspace sweep.
30
+
31
+ </important>