pi-lens 4.4.3 → 4.4.5

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 (185) hide show
  1. package/CHANGELOG.md +721 -0
  2. package/README.md +25 -3
  3. package/config/dependency-cruiser-eager-allowlist.json +1 -0
  4. package/dist/chunk-22Y2BM7H.js +23 -0
  5. package/dist/{chunk-WU567RSC.js → chunk-27VWVB23.js} +16 -14
  6. package/dist/{chunk-FLKWCIZH.js → chunk-2FYKETQJ.js} +10 -6
  7. package/dist/{chunk-MQLUAEOC.js → chunk-2LDMXL2M.js} +2 -2
  8. package/dist/{chunk-YSZNHOBY.js → chunk-2SDHYHHO.js} +17 -17
  9. package/dist/chunk-2Y6OJRSI.js +38 -0
  10. package/dist/chunk-3SNDVPOR.js +507 -0
  11. package/dist/{chunk-EJIUXPBX.js → chunk-3WCEHYOI.js} +1 -1
  12. package/dist/chunk-44X7VIKR.js +73 -0
  13. package/dist/{chunk-Q7DUK4LX.js → chunk-4FHUGDKU.js} +16 -14
  14. package/dist/{chunk-H6MF6EVN.js → chunk-4ODSZ35Z.js} +1498 -534
  15. package/dist/{chunk-ZGDGW2V3.js → chunk-4U7GDSZQ.js} +2 -2
  16. package/dist/chunk-54NIOJJZ.js +25 -0
  17. package/dist/{chunk-ZWFS3OEF.js → chunk-5DKE4HGX.js} +38 -37
  18. package/dist/{chunk-VRZP76YM.js → chunk-5LRUKYFA.js} +34 -4
  19. package/dist/{chunk-QOBUHWHX.js → chunk-63NMUNYP.js} +12 -16
  20. package/dist/{chunk-VWCXW2E7.js → chunk-6XSESGWD.js} +13 -6
  21. package/dist/{chunk-QGQ5CCCG.js → chunk-72J27ICO.js} +2 -3
  22. package/dist/{chunk-CSHFH5IN.js → chunk-7FLRUH6B.js} +1 -1
  23. package/dist/chunk-7IYC4ENJ.js +297 -0
  24. package/dist/chunk-7WWQAW5P.js +30 -0
  25. package/dist/{chunk-EU63SDCG.js → chunk-7ZS7MC24.js} +885 -451
  26. package/dist/{chunk-KBG47GHP.js → chunk-AHWA4AKM.js} +18 -12
  27. package/dist/{chunk-FMSO6RDZ.js → chunk-AI3GP74G.js} +17 -19
  28. package/dist/chunk-APFJKOP6.js +67 -0
  29. package/dist/{chunk-RXCOMYPY.js → chunk-ASRAO7KG.js} +31 -33
  30. package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  31. package/dist/{chunk-QILIYSJF.js → chunk-CG5V25HX.js} +1 -1
  32. package/dist/chunk-CKEQFGLT.js +32 -0
  33. package/dist/{chunk-RPLINGVB.js → chunk-COOUUC5W.js} +6 -6
  34. package/dist/{chunk-GBPP5P7X.js → chunk-CPZ5JJW6.js} +4 -4
  35. package/dist/{chunk-OCAGUNBC.js → chunk-DS2USX5G.js} +13 -15
  36. package/dist/chunk-EA2ZRG44.js +27 -0
  37. package/dist/{chunk-ZHFZWTZV.js → chunk-EDMLIW6W.js} +13 -14
  38. package/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  39. package/dist/chunk-EKNWOL2I.js +27 -0
  40. package/dist/{chunk-CMMHNUZ2.js → chunk-ELZRSR5N.js} +65 -43
  41. package/dist/{chunk-BKE7E7TC.js → chunk-EN5AM7PX.js} +11 -12
  42. package/dist/{chunk-N2H3ZPZY.js → chunk-EWXXLS26.js} +227 -24
  43. package/dist/chunk-EX4EXBW7.js +37 -0
  44. package/dist/{chunk-YYOIQFRS.js → chunk-EXVXBSGN.js} +130 -52
  45. package/dist/{chunk-6GFRNVYR.js → chunk-F7BO6FWH.js} +12 -13
  46. package/dist/chunk-FEDWAYDS.js +2485 -0
  47. package/dist/{chunk-JAU72XNY.js → chunk-FWZRGGGY.js} +73 -9
  48. package/dist/{chunk-GXW6K4YJ.js → chunk-G224FADB.js} +1 -1
  49. package/dist/chunk-G5UCJFT7.js +26 -0
  50. package/dist/{chunk-67WMNWEE.js → chunk-GLW3YDZZ.js} +22 -13
  51. package/dist/{chunk-724UL2TJ.js → chunk-GTDSYEA2.js} +72 -39
  52. package/dist/{chunk-PHDMFAKM.js → chunk-GYRZ72R4.js} +10 -4
  53. package/dist/chunk-HYVXA3BB.js +49 -0
  54. package/dist/{chunk-SAEFPSB6.js → chunk-IEBJF3PN.js} +23 -15
  55. package/dist/chunk-IJYGIDF4.js +186 -0
  56. package/dist/{chunk-ACXEQZOU.js → chunk-IL7K66ZQ.js} +101 -109
  57. package/dist/{chunk-ZXYDQ3TZ.js → chunk-JWOVP5BL.js} +50 -19
  58. package/dist/{chunk-OXXKQCSV.js → chunk-K2GUZ4DN.js} +4 -4
  59. package/dist/{chunk-AW7R2GWG.js → chunk-K4SZB56V.js} +39 -39
  60. package/dist/{chunk-WOA4LN2R.js → chunk-KCBRHV5E.js} +3 -3
  61. package/dist/{chunk-3W7IEVVL.js → chunk-KFXCL4OV.js} +47 -45
  62. package/dist/{chunk-2BBLFX75.js → chunk-KJJAVH3X.js} +81 -15
  63. package/dist/{chunk-VCHXCQFG.js → chunk-KPVLQHCZ.js} +4 -6
  64. package/dist/{chunk-P7266HLM.js → chunk-KX56K73G.js} +10 -13
  65. package/dist/{chunk-VSSBEUFT.js → chunk-LMCTHJ2H.js} +19 -19
  66. package/dist/{chunk-IBGIOBEE.js → chunk-MEFLGBCS.js} +69 -8
  67. package/dist/{chunk-TYM6OUIT.js → chunk-MKPCELNI.js} +17 -17
  68. package/dist/{chunk-XTMJ7XDT.js → chunk-N3PLNNCW.js} +1 -1
  69. package/dist/chunk-N5FBM25N.js +22 -0
  70. package/dist/{chunk-CHOW74WE.js → chunk-NFNVDDGB.js} +7 -12
  71. package/dist/{chunk-52FUZI6K.js → chunk-NLIVE7L6.js} +2 -30
  72. package/dist/{chunk-SS36ZX4J.js → chunk-OMJ3OFBJ.js} +6 -6
  73. package/dist/{chunk-4W4VLAPJ.js → chunk-OZNCKLOX.js} +13 -14
  74. package/dist/chunk-P5XUGPIX.js +31 -0
  75. package/dist/{chunk-5UCAH366.js → chunk-PJXNTPB2.js} +253 -33
  76. package/dist/chunk-PKOXJIVT.js +88 -0
  77. package/dist/{chunk-6C7JWPCP.js → chunk-PP2A5V2T.js} +27 -26
  78. package/dist/{chunk-L3BLXZG7.js → chunk-Q42LJANT.js} +31 -70
  79. package/dist/{chunk-AB3YYG6N.js → chunk-Q4BKKOVC.js} +8 -8
  80. package/dist/{chunk-3EFKIGZN.js → chunk-QT66NEYN.js} +4 -4
  81. package/dist/{chunk-3VPVG5SU.js → chunk-RCHO5W7M.js} +19 -18
  82. package/dist/{chunk-77M37OKR.js → chunk-RG3MXTRI.js} +7 -7
  83. package/dist/chunk-RG7OODGM.js +57 -0
  84. package/dist/{chunk-T6CPIZNT.js → chunk-RU34BA4D.js} +44 -39
  85. package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  86. package/dist/{chunk-5NGR67U5.js → chunk-S55TEC7I.js} +33 -5
  87. package/dist/{chunk-M6HSLBWY.js → chunk-SJHC3BCZ.js} +7956 -8047
  88. package/dist/{chunk-XCJN5IJU.js → chunk-SNEUMLM7.js} +4 -4
  89. package/dist/{chunk-UZ3TUTRV.js → chunk-T4NGVFYI.js} +2 -2
  90. package/dist/{chunk-2VUQMUMT.js → chunk-THEXI2QO.js} +49 -43
  91. package/dist/{chunk-R3PCY3YS.js → chunk-TL2TCJYL.js} +15 -16
  92. package/dist/{chunk-C34ZXZ7O.js → chunk-TPYYEDP5.js} +838 -352
  93. package/dist/{chunk-AOHZU2BM.js → chunk-TVZRLTG6.js} +8 -1
  94. package/dist/{chunk-XMSXXAHW.js → chunk-UCVMSOXF.js} +2 -2
  95. package/dist/chunk-UL5SXQVX.js +32 -0
  96. package/dist/{chunk-GAEGEPOC.js → chunk-UO66IMVP.js} +2 -2
  97. package/dist/{chunk-N3X6Q4YT.js → chunk-UVY4TOJH.js} +3 -3
  98. package/dist/{chunk-2CD5RS6M.js → chunk-VIDEKABZ.js} +23 -2
  99. package/dist/{chunk-JSQFTSC6.js → chunk-VITFDI3O.js} +13 -14
  100. package/dist/{chunk-YIUAVF7E.js → chunk-VUAVE3QC.js} +42 -42
  101. package/dist/{chunk-QOZXJ4NA.js → chunk-WUY4BZEP.js} +21 -20
  102. package/dist/{chunk-VCO24T4L.js → chunk-X3UTCXAA.js} +43 -53
  103. package/dist/chunk-XHDBJODR.js +45 -0
  104. package/dist/{chunk-MXGY6KPT.js → chunk-XHLK33VM.js} +28 -21
  105. package/dist/{chunk-RWWYJ623.js → chunk-XI34NWDI.js} +2 -2
  106. package/dist/{chunk-QQNQ7SJW.js → chunk-XWFIHYCH.js} +12 -4
  107. package/dist/{chunk-6SDEP3AJ.js → chunk-Y2TPADJR.js} +10 -11
  108. package/dist/{chunk-MRXKYPCS.js → chunk-Y5KTA2OB.js} +17 -17
  109. package/dist/{chunk-7DYBLXYA.js → chunk-YKVDBNPO.js} +11 -5
  110. package/dist/{chunk-2B73ZPOK.js → chunk-YSDPVDFC.js} +3 -3
  111. package/dist/chunk-YWNO5Q4R.js +44 -0
  112. package/dist/{chunk-QHJ6DQ2R.js → chunk-YWWG4AQA.js} +165 -32
  113. package/dist/{chunk-3JNKMP3B.js → chunk-YXDCRUKQ.js} +4 -4
  114. package/dist/{chunk-UXGETRP4.js → chunk-YXGRRORB.js} +16 -17
  115. package/dist/{chunk-SQ4TVJBR.js → chunk-ZAPSUBLU.js} +13 -7
  116. package/dist/{chunk-76MWC2K6.js → chunk-ZPJM7DID.js} +90 -97
  117. package/dist/{chunk-XVF2VVXP.js → chunk-ZSUX7KEM.js} +16 -15
  118. package/dist/index.js +31038 -20893
  119. package/dist/mcp/analyze-cli.js +11 -11
  120. package/dist/mcp/cli.js +47 -43
  121. package/dist/mcp/server.js +2188 -906
  122. package/dist/mcp/worker.js +66 -63
  123. package/dist/probes/installer.js +21 -23
  124. package/dist/workers/project-snapshot-persist-worker.js +28 -9
  125. package/dist/workers/review-graph-persist-worker.js +1 -1
  126. package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  127. package/docs/adr/README.md +1 -0
  128. package/docs/ast-grep_rules_catalog.md +5 -3
  129. package/docs/configuration.md +20 -0
  130. package/docs/engineering-principles.md +44 -0
  131. package/docs/environment-variables.md +20 -0
  132. package/docs/features.md +16 -1
  133. package/docs/globalconfig.md +37 -8
  134. package/docs/lsp-capability-matrix.md +105 -12
  135. package/docs/lsp-idle-eviction.md +44 -36
  136. package/docs/pi-lens-fixer.md +139 -14
  137. package/docs/pi-lens-investigator.md +14 -0
  138. package/docs/pi-lens-merge-policy.md +120 -17
  139. package/docs/pi-lens-monitor.md +71 -9
  140. package/docs/pi-lens-retro.md +6 -3
  141. package/docs/pi-lens-reviewer.md +160 -5
  142. package/docs/pi-lens-subagent.md +29 -14
  143. package/docs/release-qa-baseline.md +21 -7
  144. package/docs/servercapabilities.md +53 -63
  145. package/docs/settings.md +9 -5
  146. package/docs/subagent-compat.md +1 -1
  147. package/docs/usage.md +1 -0
  148. package/package.json +9 -5
  149. package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  150. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  151. package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  152. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  153. package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  154. package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  155. package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  156. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  157. package/rules/rule-catalog.json +25 -1
  158. package/scripts/analyze-pi-lens-logs.mjs +15 -5
  159. package/scripts/download-grammars.js +40 -7
  160. package/scripts/lib/is-main-module.mjs +27 -0
  161. package/scripts/lib/latency-log-phases.mjs +95 -0
  162. package/scripts/lib/scratch-home-env.mjs +21 -0
  163. package/scripts/rpc-load-check.mjs +568 -81
  164. package/scripts/warm-loader-cache.mjs +2 -5
  165. package/dist/chunk-23WOO7TX.js +0 -23
  166. package/dist/chunk-3YN6V5TV.js +0 -85
  167. package/dist/chunk-466Z26MG.js +0 -30
  168. package/dist/chunk-4UNXBNE2.js +0 -24
  169. package/dist/chunk-6STA6Z7I.js +0 -47
  170. package/dist/chunk-ABBOA7UD.js +0 -157
  171. package/dist/chunk-BRGDSBJE.js +0 -28
  172. package/dist/chunk-EC47DWFA.js +0 -56
  173. package/dist/chunk-FCSOVF55.js +0 -273
  174. package/dist/chunk-IZSHAIJ7.js +0 -26
  175. package/dist/chunk-KDERNTCQ.js +0 -28
  176. package/dist/chunk-KSX3TXSZ.js +0 -69
  177. package/dist/chunk-LOP6GRPH.js +0 -31
  178. package/dist/chunk-PNQDPDRC.js +0 -184
  179. package/dist/chunk-UOPVJQ4N.js +0 -103
  180. package/dist/chunk-XAGLWMJ4.js +0 -51
  181. package/dist/chunk-XIJZVPD5.js +0 -39
  182. package/dist/chunk-Z3CCVDUB.js +0 -76
  183. package/dist/chunk-Z527N6YQ.js +0 -28
  184. package/dist/chunk-ZANLILYD.js +0 -79
  185. /package/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
@@ -1,273 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- extractTomlTableSection,
4
- hasTomlTable,
5
- parseTomlStringArray
6
- } from "./chunk-P7266HLM.js";
7
- import {
8
- getProjectTrustState
9
- } from "./chunk-ZANLILYD.js";
10
- import {
11
- incrementDegradationCount,
12
- recordDegradationOnce
13
- } from "./chunk-JAU72XNY.js";
14
- import {
15
- logExtension
16
- } from "./chunk-XTMJ7XDT.js";
17
- import {
18
- logLatency
19
- } from "./chunk-QQNQ7SJW.js";
20
- import {
21
- UV_WORKSPACE_EXCLUDE_DIALECT,
22
- UV_WORKSPACE_MEMBERS_DIALECT,
23
- isAtOrAboveHomeDir,
24
- matchesWorkspaceMemberPattern,
25
- toPosix,
26
- walkUpDirs
27
- } from "./chunk-N2H3ZPZY.js";
28
-
29
- // dist/clients/bounded-telemetry.js
30
- var MAX_TRACKED_TURN_CAPS = 64;
31
- var turnCounts = /* @__PURE__ */ new Map();
32
- var latestCountedTurnIndex;
33
- var retiredThroughTurnIndex = Number.NEGATIVE_INFINITY;
34
- function admitBounded(phase, identity, options = {}) {
35
- try {
36
- let isRisingEdge = true;
37
- if (options.ledgerKind !== void 0) {
38
- isRisingEdge = incrementDegradationCount({
39
- kind: options.ledgerKind,
40
- subject: identity,
41
- reason: options.reason ?? phase
42
- });
43
- }
44
- if (options.risingEdgePer !== void 0 && !isRisingEdge)
45
- return false;
46
- return admitAgainstTurnCap(phase, options.capPerTurn);
47
- } catch {
48
- return true;
49
- }
50
- }
51
- function emitBounded(phase, identity, payload, options = {}) {
52
- try {
53
- if (!admitBounded(phase, identity, options))
54
- return false;
55
- logLatency({
56
- ...payload,
57
- type: payload.type ?? "phase",
58
- phase,
59
- // `filePath` is what existing latency.log queries filter on, so a site
60
- // may keep a coarser one; `metadata.identity` below always carries the
61
- // full discriminating identity. Aggregation that loses WHICH subject
62
- // is stuck is the failure AGENTS.md names.
63
- filePath: payload.filePath ?? identity,
64
- metadata: { ...payload.metadata, identity }
65
- });
66
- return true;
67
- } catch {
68
- return false;
69
- }
70
- }
71
- function admitAgainstTurnCap(phase, cap) {
72
- if (cap === void 0)
73
- return true;
74
- if (cap.turnIndex <= retiredThroughTurnIndex)
75
- return false;
76
- let counts = turnCounts.get(cap.turnIndex);
77
- if (!counts) {
78
- if (turnCounts.size >= MAX_TRACKED_TURN_CAPS) {
79
- const oldestTrackedTurn = Math.min(...turnCounts.keys());
80
- if (cap.turnIndex < oldestTrackedTurn)
81
- return false;
82
- turnCounts.delete(oldestTrackedTurn);
83
- retiredThroughTurnIndex = Math.max(retiredThroughTurnIndex, oldestTrackedTurn);
84
- }
85
- counts = /* @__PURE__ */ new Map();
86
- turnCounts.set(cap.turnIndex, counts);
87
- }
88
- latestCountedTurnIndex = Math.max(latestCountedTurnIndex ?? cap.turnIndex, cap.turnIndex);
89
- const used = counts.get(phase) ?? 0;
90
- if (used >= cap.limit)
91
- return false;
92
- counts.set(phase, used + 1);
93
- return true;
94
- }
95
- function resetBoundedTelemetry() {
96
- turnCounts = /* @__PURE__ */ new Map();
97
- latestCountedTurnIndex = void 0;
98
- retiredThroughTurnIndex = Number.NEGATIVE_INFINITY;
99
- }
100
-
101
- // dist/clients/python-environment.js
102
- import { access, readFile } from "node:fs/promises";
103
- import os from "node:os";
104
- import path from "node:path";
105
- var UV_WORKSPACE_TABLE = "tool\\.uv\\.workspace";
106
- async function findUvWorkspace(startDir, homeDir) {
107
- const resolvedStart = path.resolve(startDir);
108
- let nearestProject;
109
- for (const dir of walkUpDirs(startDir)) {
110
- if (isAtOrAboveHomeDir(dir, homeDir))
111
- break;
112
- let content;
113
- try {
114
- content = await readFile(path.join(dir, "pyproject.toml"), "utf8");
115
- } catch {
116
- continue;
117
- }
118
- if (!nearestProject)
119
- nearestProject = dir;
120
- if (hasTomlTable(content, UV_WORKSPACE_TABLE)) {
121
- const workspaceTable = extractTomlTableSection(content, UV_WORKSPACE_TABLE);
122
- return {
123
- root: dir,
124
- explicit: true,
125
- projectRoot: nearestProject,
126
- isStartDir: nearestProject === resolvedStart,
127
- members: parseTomlStringArray(workspaceTable, "members"),
128
- exclude: parseTomlStringArray(workspaceTable, "exclude")
129
- };
130
- }
131
- }
132
- return nearestProject ? {
133
- root: nearestProject,
134
- explicit: false,
135
- projectRoot: nearestProject,
136
- isStartDir: nearestProject === resolvedStart,
137
- members: [],
138
- exclude: []
139
- } : void 0;
140
- }
141
- function isUvWorkspaceMember(workspace, projectRoot) {
142
- const relative = toPosix(path.relative(workspace.root, projectRoot));
143
- if (relative.length === 0 || relative === ".." || relative.startsWith("../") || path.isAbsolute(relative)) {
144
- return false;
145
- }
146
- const matches = (dialect) => (pattern) => matchesWorkspaceMemberPattern(pattern, relative, dialect, () => recordDegradationOnce({
147
- kind: "workspace-glob-cap",
148
- subject: String(pattern.length),
149
- reason: "workspace glob matcher exceeded its memo-table cell cap"
150
- }));
151
- return !workspace.exclude.some(matches(UV_WORKSPACE_EXCLUDE_DIALECT)) && workspace.members.some(matches(UV_WORKSPACE_MEMBERS_DIALECT));
152
- }
153
- var PROJECT_SOURCED_PYTHON_SOURCES = /* @__PURE__ */ new Set([
154
- "project-dot-venv",
155
- "project-venv",
156
- "uv-workspace"
157
- ]);
158
- var AMBIENT_ENVIRONMENT_VARIABLES = {
159
- "uv-project-environment": "UV_PROJECT_ENVIRONMENT",
160
- "virtual-env": "VIRTUAL_ENV",
161
- conda: "CONDA_PREFIX"
162
- };
163
- function hasAmbientPythonEnvironment(env = process.env) {
164
- return Object.values(AMBIENT_ENVIRONMENT_VARIABLES).some((name) => Boolean(env[name]));
165
- }
166
- async function detectPythonEnvironment(projectRoot, homeDir = os.homedir(), options = {}) {
167
- const root = path.resolve(projectRoot);
168
- const uvWorkspace = await findUvWorkspace(root, homeDir);
169
- const isProjectRoot = uvWorkspace?.isStartDir === true;
170
- const memberWorkspaceRoot = isProjectRoot && uvWorkspace.explicit && isUvWorkspaceMember(uvWorkspace, root) ? uvWorkspace.root : void 0;
171
- const uvEnvironmentRoot = isProjectRoot ? memberWorkspaceRoot ?? uvWorkspace.projectRoot : void 0;
172
- const uvProjectEnvironment = process.env.UV_PROJECT_ENVIRONMENT;
173
- const allowAmbient = options.allowAmbient ?? true;
174
- const isWithinProjectRoot = (candidateRoot) => {
175
- const relative = path.relative(root, path.resolve(candidateRoot));
176
- return relative !== ".." && !relative.startsWith(`..${path.sep}`) && // #3871 V1: another Windows drive has no relative path, so
177
- // `path.relative` returns the absolute target: no `..`, not inside.
178
- !path.isAbsolute(relative);
179
- };
180
- const candidates = [
181
- ...uvEnvironmentRoot !== void 0 && uvProjectEnvironment ? [
182
- {
183
- // `path.resolve` leaves an absolute value untouched and
184
- // anchors a relative one at the project's workspace root.
185
- root: path.resolve(uvEnvironmentRoot, uvProjectEnvironment),
186
- source: "uv-project-environment"
187
- }
188
- ] : [],
189
- ...memberWorkspaceRoot !== void 0 ? [
190
- {
191
- root: path.join(memberWorkspaceRoot, ".venv"),
192
- source: "uv-workspace"
193
- }
194
- ] : [],
195
- { root: process.env.VIRTUAL_ENV, source: "virtual-env" },
196
- { root: process.env.CONDA_PREFIX, source: "conda" },
197
- { root: path.join(root, ".venv"), source: "project-dot-venv" },
198
- { root: path.join(root, "venv"), source: "project-venv" }
199
- ];
200
- for (const candidate of candidates) {
201
- if (!candidate.root)
202
- continue;
203
- if (!allowAmbient && candidate.source in AMBIENT_ENVIRONMENT_VARIABLES && !isWithinProjectRoot(candidate.root))
204
- continue;
205
- if (PROJECT_SOURCED_PYTHON_SOURCES.has(candidate.source) && getProjectTrustState() !== "trusted") {
206
- if (recordDegradationOnce({
207
- kind: "trust-refusal",
208
- subject: `python-environment:${candidate.root}`,
209
- reason: `project Python environment refused: pi project trust is ${getProjectTrustState()}`
210
- })) {
211
- logExtension({
212
- subsystem: "project-trust",
213
- level: "warn",
214
- message: "project Python environment refused: mark the project trusted in pi or upgrade pi",
215
- metadata: { source: candidate.source }
216
- });
217
- }
218
- continue;
219
- }
220
- const binDir = path.join(candidate.root, process.platform === "win32" ? "Scripts" : "bin");
221
- const pythonPath = path.join(binDir, process.platform === "win32" ? "python.exe" : "python");
222
- try {
223
- await access(pythonPath);
224
- return {
225
- root: candidate.root,
226
- binDir,
227
- pythonPath,
228
- source: candidate.source
229
- };
230
- } catch {
231
- }
232
- }
233
- return void 0;
234
- }
235
- async function detectPythonVenv(projectRoot) {
236
- return (await detectPythonEnvironment(projectRoot))?.pythonPath;
237
- }
238
- function augmentPythonEnvironment(baseEnvironment, environment) {
239
- if (!environment)
240
- return baseEnvironment;
241
- const inheritedPath = baseEnvironment.PATH ?? baseEnvironment.Path ?? baseEnvironment.path ?? "";
242
- const augmentedPath = inheritedPath ? `${environment.binDir}${path.delimiter}${inheritedPath}` : environment.binDir;
243
- const childEnvironment = {
244
- ...baseEnvironment,
245
- PATH: augmentedPath,
246
- VIRTUAL_ENV: environment.root
247
- };
248
- if (process.platform === "win32")
249
- childEnvironment.Path = augmentedPath;
250
- return childEnvironment;
251
- }
252
- function pythonEnvironmentToolCandidates(environment, command) {
253
- if (!environment)
254
- return [];
255
- if (process.platform !== "win32") {
256
- return [path.join(environment.binDir, command)];
257
- }
258
- return [
259
- path.join(environment.binDir, `${command}.exe`),
260
- path.join(environment.binDir, `${command}.cmd`),
261
- path.join(environment.binDir, command)
262
- ];
263
- }
264
-
265
- export {
266
- emitBounded,
267
- resetBoundedTelemetry,
268
- hasAmbientPythonEnvironment,
269
- detectPythonEnvironment,
270
- detectPythonVenv,
271
- augmentPythonEnvironment,
272
- pythonEnvironmentToolCandidates
273
- };
@@ -1,26 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- getSourceFiles,
4
- getSourceFilesAsync
5
- } from "./chunk-QILIYSJF.js";
6
- import "./chunk-6C7JWPCP.js";
7
- import "./chunk-5NGR67U5.js";
8
- import "./chunk-C34ZXZ7O.js";
9
- import "./chunk-QYF5S6P6.js";
10
- import "./chunk-PHDMFAKM.js";
11
- import "./chunk-2BBLFX75.js";
12
- import "./chunk-XVF2VVXP.js";
13
- import "./chunk-2EECBNC5.js";
14
- import "./chunk-JAU72XNY.js";
15
- import "./chunk-XTMJ7XDT.js";
16
- import "./chunk-JMYYOTQG.js";
17
- import "./chunk-QQNQ7SJW.js";
18
- import "./chunk-AOHZU2BM.js";
19
- import "./chunk-LJDODBBZ.js";
20
- import "./chunk-ABBOA7UD.js";
21
- import "./chunk-N2H3ZPZY.js";
22
- import "./chunk-NXL4FFQQ.js";
23
- export {
24
- getSourceFiles,
25
- getSourceFilesAsync
26
- };
@@ -1,28 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- GovulncheckClient,
4
- parseGovulncheckJson
5
- } from "./chunk-SQ4TVJBR.js";
6
- import "./chunk-UZ3TUTRV.js";
7
- import "./chunk-3EFKIGZN.js";
8
- import "./chunk-RWWYJ623.js";
9
- import "./chunk-VRZP76YM.js";
10
- import "./chunk-C34ZXZ7O.js";
11
- import "./chunk-BW5KFIQC.js";
12
- import "./chunk-2BBLFX75.js";
13
- import "./chunk-XVF2VVXP.js";
14
- import "./chunk-ZANLILYD.js";
15
- import "./chunk-2EECBNC5.js";
16
- import "./chunk-JAU72XNY.js";
17
- import "./chunk-XTMJ7XDT.js";
18
- import "./chunk-JMYYOTQG.js";
19
- import "./chunk-QQNQ7SJW.js";
20
- import "./chunk-AOHZU2BM.js";
21
- import "./chunk-LJDODBBZ.js";
22
- import "./chunk-ABBOA7UD.js";
23
- import "./chunk-N2H3ZPZY.js";
24
- import "./chunk-NXL4FFQQ.js";
25
- export {
26
- GovulncheckClient,
27
- parseGovulncheckJson
28
- };
@@ -1,69 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- adaptLspService,
4
- getLSPService,
5
- groupFilesByPrimaryServer,
6
- hasAuxiliaryLspPublishedForRoot,
7
- notifyExternalFileChange,
8
- peekLSPService,
9
- resetLSPService,
10
- resyncGitChangedFiles,
11
- runPerServerGroups
12
- } from "./chunk-M6HSLBWY.js";
13
- import "./chunk-IBGIOBEE.js";
14
- import "./chunk-XIMYZ3JA.js";
15
- import "./chunk-EU63SDCG.js";
16
- import "./chunk-VWCXW2E7.js";
17
- import "./chunk-FCSOVF55.js";
18
- import "./chunk-PNQDPDRC.js";
19
- import "./chunk-ZXYDQ3TZ.js";
20
- import "./chunk-QHJ6DQ2R.js";
21
- import "./chunk-Z54ZSOBZ.js";
22
- import "./chunk-724UL2TJ.js";
23
- import "./chunk-QOZXJ4NA.js";
24
- import "./chunk-GBPP5P7X.js";
25
- import "./chunk-P7266HLM.js";
26
- import "./chunk-MQLUAEOC.js";
27
- import "./chunk-52FUZI6K.js";
28
- import "./chunk-SAEFPSB6.js";
29
- import "./chunk-GAEGEPOC.js";
30
- import "./chunk-Z3CCVDUB.js";
31
- import "./chunk-L3BLXZG7.js";
32
- import "./chunk-2BEMIWEW.js";
33
- import "./chunk-ACXEQZOU.js";
34
- import "./chunk-Q7DUK4LX.js";
35
- import "./chunk-AW7R2GWG.js";
36
- import "./chunk-RWWYJ623.js";
37
- import "./chunk-VRZP76YM.js";
38
- import "./chunk-QOBUHWHX.js";
39
- import "./chunk-QILIYSJF.js";
40
- import "./chunk-6C7JWPCP.js";
41
- import "./chunk-5NGR67U5.js";
42
- import "./chunk-C34ZXZ7O.js";
43
- import "./chunk-BW5KFIQC.js";
44
- import "./chunk-QYF5S6P6.js";
45
- import "./chunk-PHDMFAKM.js";
46
- import "./chunk-2BBLFX75.js";
47
- import "./chunk-XVF2VVXP.js";
48
- import "./chunk-ZANLILYD.js";
49
- import "./chunk-2EECBNC5.js";
50
- import "./chunk-JAU72XNY.js";
51
- import "./chunk-XTMJ7XDT.js";
52
- import "./chunk-JMYYOTQG.js";
53
- import "./chunk-QQNQ7SJW.js";
54
- import "./chunk-AOHZU2BM.js";
55
- import "./chunk-LJDODBBZ.js";
56
- import "./chunk-ABBOA7UD.js";
57
- import "./chunk-N2H3ZPZY.js";
58
- import "./chunk-NXL4FFQQ.js";
59
- export {
60
- adaptLspService,
61
- getLSPService,
62
- groupFilesByPrimaryServer,
63
- hasAuxiliaryLspPublishedForRoot,
64
- notifyExternalFileChange,
65
- peekLSPService,
66
- resetLSPService,
67
- resyncGitChangedFiles,
68
- runPerServerGroups
69
- };
@@ -1,31 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- calcCyclomaticComplexity,
4
- functionFactProvider
5
- } from "./chunk-76MWC2K6.js";
6
- import "./chunk-GXW6K4YJ.js";
7
- import "./chunk-5W3R6LFT.js";
8
- import "./chunk-QHJ6DQ2R.js";
9
- import "./chunk-Z54ZSOBZ.js";
10
- import "./chunk-724UL2TJ.js";
11
- import "./chunk-QOZXJ4NA.js";
12
- import "./chunk-VRZP76YM.js";
13
- import "./chunk-C34ZXZ7O.js";
14
- import "./chunk-PHDMFAKM.js";
15
- import "./chunk-2BBLFX75.js";
16
- import "./chunk-XVF2VVXP.js";
17
- import "./chunk-ZANLILYD.js";
18
- import "./chunk-2EECBNC5.js";
19
- import "./chunk-JAU72XNY.js";
20
- import "./chunk-XTMJ7XDT.js";
21
- import "./chunk-JMYYOTQG.js";
22
- import "./chunk-QQNQ7SJW.js";
23
- import "./chunk-AOHZU2BM.js";
24
- import "./chunk-LJDODBBZ.js";
25
- import "./chunk-ABBOA7UD.js";
26
- import "./chunk-N2H3ZPZY.js";
27
- import "./chunk-NXL4FFQQ.js";
28
- export {
29
- calcCyclomaticComplexity,
30
- functionFactProvider
31
- };
@@ -1,184 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- isUnderDir,
4
- normalizeFilePath,
5
- pathsEqual,
6
- walkUpDirs
7
- } from "./chunk-N2H3ZPZY.js";
8
-
9
- // dist/clients/review-graph/git-identity.js
10
- import * as fs from "node:fs";
11
- import * as path from "node:path";
12
- import { dirname, join as join2, resolve as resolve2 } from "node:path";
13
- function createGitIdentityResolver() {
14
- const memo = /* @__PURE__ */ new Map();
15
- return (cwd) => {
16
- if (memo.has(cwd))
17
- return memo.get(cwd);
18
- const identity = resolveGitIdentity(cwd);
19
- memo.set(cwd, identity);
20
- return identity;
21
- };
22
- }
23
- function readCommonDir(gitDir) {
24
- try {
25
- const raw = fs.readFileSync(path.join(gitDir, "commondir"), "utf-8").trim();
26
- if (!raw)
27
- return gitDir;
28
- return path.isAbsolute(raw) ? raw : path.resolve(gitDir, raw);
29
- } catch {
30
- return gitDir;
31
- }
32
- }
33
- function resolveGitDir(cwd) {
34
- for (const dir of walkUpDirs(cwd)) {
35
- const gitPath = path.join(dir, ".git");
36
- let stat;
37
- try {
38
- stat = fs.statSync(gitPath);
39
- } catch {
40
- continue;
41
- }
42
- if (stat.isDirectory()) {
43
- return {
44
- gitDir: gitPath,
45
- commonDir: readCommonDir(gitPath),
46
- worktreeRoot: dir
47
- };
48
- }
49
- if (stat.isFile()) {
50
- try {
51
- const contents = fs.readFileSync(gitPath, "utf-8").trim();
52
- const match = contents.match(/^gitdir:\s*(.+)$/);
53
- if (!match)
54
- return null;
55
- const linkedGitDir = path.isAbsolute(match[1]) ? match[1] : path.resolve(dir, match[1]);
56
- if (!fs.statSync(linkedGitDir).isDirectory())
57
- return null;
58
- return {
59
- gitDir: linkedGitDir,
60
- commonDir: readCommonDir(linkedGitDir),
61
- worktreeRoot: dir
62
- };
63
- } catch {
64
- return null;
65
- }
66
- }
67
- return null;
68
- }
69
- return null;
70
- }
71
- function getResolvedGitDir(cwd) {
72
- let resolved;
73
- try {
74
- resolved = resolveGitDir(cwd);
75
- } catch {
76
- resolved = null;
77
- }
78
- return resolved;
79
- }
80
- function canonicalDirectory(dir) {
81
- try {
82
- return fs.realpathSync.native(dir);
83
- } catch {
84
- return dir;
85
- }
86
- }
87
- function resolveGitCheckout(startPath) {
88
- const resolved = getResolvedGitDir(startPath);
89
- return resolved ? {
90
- root: canonicalDirectory(resolved.worktreeRoot),
91
- spelledRoot: resolved.worktreeRoot,
92
- commonDir: canonicalDirectory(resolved.commonDir)
93
- } : null;
94
- }
95
- function resolveLinkedWorktreeOwner(session, absoluteFile) {
96
- const owner = resolveGitCheckout(dirname(absoluteFile));
97
- return owner !== null && !pathsEqual(owner.root, session.root) && pathsEqual(owner.commonDir, session.commonDir) ? owner : null;
98
- }
99
- function listLinkedWorktreeRoots(commonDir) {
100
- const roots = [];
101
- let names;
102
- try {
103
- names = fs.readdirSync(join2(commonDir, "worktrees"));
104
- } catch {
105
- return roots;
106
- }
107
- for (const name of names) {
108
- try {
109
- const entryDir = join2(commonDir, "worktrees", name);
110
- const gitFile = fs.readFileSync(join2(entryDir, "gitdir"), "utf-8").trim();
111
- if (gitFile) {
112
- const root = canonicalDirectory(dirname(resolve2(entryDir, gitFile)));
113
- if (fs.existsSync(join2(root, ".git")))
114
- roots.push(root);
115
- }
116
- } catch {
117
- }
118
- }
119
- return roots;
120
- }
121
- function listNestedLinkedWorktreeRoots(scanRoot) {
122
- const checkout = resolveGitCheckout(scanRoot);
123
- if (!checkout)
124
- return [];
125
- const base = canonicalDirectory(scanRoot);
126
- const nested = [];
127
- for (const root of listLinkedWorktreeRoots(checkout.commonDir)) {
128
- if (!pathsEqual(root, base) && isUnderDir(root, base))
129
- nested.push(root);
130
- }
131
- return nested;
132
- }
133
- function resolveRefToSha(commonDir, ref) {
134
- try {
135
- const loose = fs.readFileSync(path.join(commonDir, ref), "utf-8").trim();
136
- if (loose)
137
- return loose;
138
- } catch {
139
- }
140
- try {
141
- const packed = fs.readFileSync(path.join(commonDir, "packed-refs"), "utf-8");
142
- for (const line of packed.split("\n")) {
143
- if (line.startsWith("#") || line.startsWith("^") || !line.trim())
144
- continue;
145
- const [sha, packedRef] = line.trim().split(/\s+/, 2);
146
- if (packedRef === ref)
147
- return sha;
148
- }
149
- } catch {
150
- }
151
- return null;
152
- }
153
- function resolveGitIdentity(cwd) {
154
- try {
155
- const resolved = getResolvedGitDir(cwd);
156
- if (!resolved)
157
- return void 0;
158
- const headRaw = fs.readFileSync(path.join(resolved.gitDir, "HEAD"), "utf-8").trim();
159
- const refMatch = headRaw.match(/^ref:\s*(.+)$/);
160
- let headCommit;
161
- if (refMatch) {
162
- headCommit = resolveRefToSha(resolved.commonDir, refMatch[1].trim());
163
- } else {
164
- headCommit = /^[0-9a-f]{7,40}$/i.test(headRaw) ? headRaw : null;
165
- }
166
- if (!headCommit)
167
- return void 0;
168
- return {
169
- headCommit,
170
- worktreeRoot: normalizeFilePath(resolved.worktreeRoot)
171
- };
172
- } catch {
173
- return void 0;
174
- }
175
- }
176
-
177
- export {
178
- createGitIdentityResolver,
179
- canonicalDirectory,
180
- resolveGitCheckout,
181
- resolveLinkedWorktreeOwner,
182
- listNestedLinkedWorktreeRoots,
183
- resolveGitIdentity
184
- };