pi-lens 4.4.4 → 4.4.6
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.
- package/CHANGELOG.md +477 -0
- package/README.md +45 -3
- package/config/biome/core.jsonc +3 -3
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/{chunk-UBOQLVT2.js → chunk-2DDDCJDL.js} +4 -4
- package/dist/{chunk-RKKOYPRA.js → chunk-2DMLM3ZO.js} +13 -15
- package/dist/chunk-2F47TQOA.js +73 -0
- package/dist/{chunk-O4NWQT6I.js → chunk-2PHMIAKO.js} +4 -4
- package/dist/{chunk-DGUKIYSI.js → chunk-2RLWJO5K.js} +8 -10
- package/dist/{chunk-S67KYG37.js → chunk-2X4VLOCC.js} +2 -2
- package/dist/{chunk-TIQ2PKDW.js → chunk-3MYEA7QD.js} +4 -4
- package/dist/{chunk-3DA2JDOL.js → chunk-3WEPUD2V.js} +551 -203
- package/dist/{chunk-AMERCH6V.js → chunk-4AVZ3TG7.js} +15 -16
- package/dist/{chunk-IYNJ6YPZ.js → chunk-4PCQCU47.js} +4 -4
- package/dist/chunk-4WX4CTUE.js +57 -0
- package/dist/{chunk-P63GXC37.js → chunk-5APMQ2IJ.js} +31 -4
- package/dist/{chunk-ZIVJBOO3.js → chunk-5CV5ITZF.js} +2 -2
- package/dist/{chunk-6DLWKFEX.js → chunk-5ZR3APIM.js} +41 -42
- package/dist/{chunk-XTBDCR27.js → chunk-63RIVFQI.js} +4 -4
- package/dist/{chunk-GSLNCYGG.js → chunk-75SY4F24.js} +13 -14
- package/dist/{chunk-U44DJXQP.js → chunk-7RQXA5GG.js} +15 -18
- package/dist/chunk-A3YNG5KP.js +45 -0
- package/dist/{chunk-5OFV52AM.js → chunk-AE37FEGH.js} +1 -1
- package/dist/{chunk-BWD5EPKO.js → chunk-AMXIUN2R.js} +4 -6
- package/dist/{chunk-3KAZU3VR.js → chunk-ARD426WI.js} +2 -2
- package/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
- package/dist/{chunk-YH5MVY2U.js → chunk-BHUWL2Y3.js} +7 -7
- package/dist/{chunk-CT4MN5IU.js → chunk-BI5LAQ3Y.js} +353 -359
- package/dist/{chunk-KAPJINKN.js → chunk-BM5GS6ZH.js} +2 -2
- package/dist/{chunk-TLX72JTG.js → chunk-BWYQUPOS.js} +1 -1
- package/dist/chunk-CFRQMBGP.js +49 -0
- package/dist/{chunk-RMLC67LF.js → chunk-CJYKEW2L.js} +2 -30
- package/dist/chunk-CKEQFGLT.js +32 -0
- package/dist/{chunk-IWDLU6K3.js → chunk-DC4CFXM5.js} +4 -6
- package/dist/{chunk-ZVUL7QYY.js → chunk-DMSLNKF7.js} +29 -32
- package/dist/{chunk-KN35K52N.js → chunk-DQXSPYRI.js} +3 -3
- package/dist/{chunk-HYGZEMX6.js → chunk-EVDGNG4F.js} +11 -5
- package/dist/{chunk-SRYEJNES.js → chunk-F5Z6URKM.js} +2 -2
- package/dist/{chunk-UMS2MFPZ.js → chunk-F6X3YJWD.js} +2 -3
- package/dist/{chunk-XYURS6EN.js → chunk-FA5LDARD.js} +15 -17
- package/dist/{chunk-24AKHFGP.js → chunk-FFL3A2VP.js} +6 -6
- package/dist/chunk-FJIVKLPH.js +31 -0
- package/dist/chunk-G2B7F6ZU.js +88 -0
- package/dist/{chunk-US7ECLD7.js → chunk-GAACZY6R.js} +131 -41
- package/dist/{chunk-MZGQNL3Y.js → chunk-GMTFDAOK.js} +12 -13
- package/dist/{chunk-VOOAPROD.js → chunk-GNSIWBAT.js} +3 -3
- package/dist/chunk-GTAI2J6U.js +27 -0
- package/dist/{chunk-RVK72CZX.js → chunk-GZE7WOI4.js} +1362 -459
- package/dist/{chunk-IUE7SSKV.js → chunk-H7HTEQUZ.js} +13 -7
- package/dist/{chunk-EUXZEFTV.js → chunk-HK6JVFZC.js} +3 -3
- package/dist/chunk-IPDG45G5.js +26 -0
- package/dist/{chunk-5HSRT26B.js → chunk-J6JP25XU.js} +16 -15
- package/dist/{chunk-HWCCCQNX.js → chunk-JL6CXUMW.js} +13 -6
- package/dist/{chunk-EBC36LNN.js → chunk-K2YGBXOA.js} +17 -17
- package/dist/{chunk-WMYE35PX.js → chunk-KLQVC3XC.js} +7 -5
- package/dist/{chunk-ATKJFDQN.js → chunk-KSR7RGQY.js} +12 -14
- package/dist/{chunk-POMLXPMY.js → chunk-KXF5R4UN.js} +1 -1
- package/dist/{chunk-LLJNQKQW.js → chunk-LEJOJDXL.js} +20 -13
- package/dist/{chunk-JUKMK5Y4.js → chunk-MA77RSFN.js} +10 -11
- package/dist/{chunk-GAQ7OQG6.js → chunk-MKVZQUEG.js} +85 -96
- package/dist/{chunk-2EECBNC5.js → chunk-MN7MHUXQ.js} +75 -0
- package/dist/{chunk-DEL2U6CM.js → chunk-MT6BVNFW.js} +16 -14
- package/dist/chunk-NDMCVUYK.js +507 -0
- package/dist/{chunk-HRNHZA3N.js → chunk-NIU2IPC5.js} +12 -16
- package/dist/{chunk-AGSS7277.js → chunk-NNKXDXXS.js} +7 -24
- package/dist/{chunk-V35JG4JB.js → chunk-OJLTLYHB.js} +152 -334
- package/dist/{chunk-J6MPGQTS.js → chunk-OLAWH5UQ.js} +81 -15
- package/dist/{chunk-T57LYLZT.js → chunk-OOU2WZZE.js} +1 -1
- package/dist/{chunk-CYRKQRPM.js → chunk-OSTKYB55.js} +2 -4
- package/dist/chunk-P4QNXS6I.js +27 -0
- package/dist/chunk-PKES3ISE.js +297 -0
- package/dist/{chunk-ROYSX2S5.js → chunk-PO45POGF.js} +2 -2
- package/dist/{chunk-T7FEBKXN.js → chunk-PPIBVH4R.js} +7 -9
- package/dist/{chunk-3RKP3FMS.js → chunk-PQJFG24Z.js} +295 -23
- package/dist/{chunk-KUA4OJ5Y.js → chunk-Q3UZHW6N.js} +846 -350
- package/dist/{chunk-N5FLEO7W.js → chunk-Q4EMRFNA.js} +37 -37
- package/dist/{chunk-5IUSNGOC.js → chunk-Q4FCYCRE.js} +28 -21
- package/dist/chunk-Q6D6VMI4.js +22 -0
- package/dist/{chunk-UZ2XCLYS.js → chunk-QGSTQH4D.js} +8 -8
- package/dist/{chunk-DUO2TU77.js → chunk-RZOXUSPC.js} +10 -4
- package/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
- package/dist/{chunk-GMX5OS7B.js → chunk-S67UJDGQ.js} +11 -12
- package/dist/chunk-SCIUNBPF.js +44 -0
- package/dist/{chunk-RKBXZN3A.js → chunk-SJJYRZB4.js} +2 -2
- package/dist/chunk-SXGD4ANG.js +25 -0
- package/dist/{chunk-YCWYO6TQ.js → chunk-T7FTXGS3.js} +48 -45
- package/dist/{chunk-FM4RDMKT.js → chunk-TIQJPRDD.js} +115 -61
- package/dist/{chunk-XHJBS436.js → chunk-TIYGSODX.js} +25 -25
- package/dist/{chunk-S2HEXIWI.js → chunk-U2SDMG7C.js} +10 -6
- package/dist/{chunk-2KXTHF3M.js → chunk-U6OC3QEM.js} +253 -33
- package/dist/{chunk-AWSCPCN2.js → chunk-UCGQT677.js} +19 -19
- package/dist/chunk-UHGF5UT5.js +32 -0
- package/dist/{chunk-JW3YWBVB.js → chunk-UN4TEBWN.js} +17 -19
- package/dist/{chunk-ZHH37KZL.js → chunk-V3APN3DY.js} +17 -17
- package/dist/{chunk-ED36RF6Y.js → chunk-V63BC55Q.js} +1 -1
- package/dist/{chunk-XBJVAEEO.js → chunk-VG5JS5SW.js} +3 -2
- package/dist/{chunk-W66O5E25.js → chunk-VPBIMOAQ.js} +13 -15
- package/dist/chunk-VQH24FIP.js +37 -0
- package/dist/{chunk-YNE3RP52.js → chunk-VSFLRN5Y.js} +8 -1
- package/dist/{chunk-7D6L4MTX.js → chunk-W2V54OCL.js} +3 -3
- package/dist/{chunk-2FN63LPV.js → chunk-W5LGKNET.js} +13 -14
- package/dist/{chunk-IQWN5JCP.js → chunk-W5R5SABV.js} +13 -14
- package/dist/{chunk-R3T7CLQ2.js → chunk-WIZWZR4C.js} +41 -41
- package/dist/{chunk-TOY6QKOH.js → chunk-WQOIR3QY.js} +17 -17
- package/dist/{chunk-Y6GZHWSJ.js → chunk-XAIT2YGS.js} +6 -6
- package/dist/chunk-XCUHKYCQ.js +23 -0
- package/dist/{chunk-GSM5UU7A.js → chunk-XQCSWV2G.js} +44 -35
- package/dist/{chunk-OHKJ7PQF.js → chunk-YBSONGSZ.js} +43 -39
- package/dist/{chunk-GXFV6MYU.js → chunk-YISME6ON.js} +72 -39
- package/dist/chunk-YRD4ISED.js +30 -0
- package/dist/{chunk-SD4I7ZO4.js → chunk-YSBHPOY6.js} +43 -53
- package/dist/{chunk-QBFBRV2B.js → chunk-Z2XAOKHK.js} +4 -2
- package/dist/{chunk-5VSF4UUQ.js → chunk-Z7IGUAXL.js} +34 -39
- package/dist/{chunk-MPNJLASA.js → chunk-ZKXQKGWZ.js} +10 -13
- package/dist/{chunk-J64T55EI.js → chunk-ZQ6NZZTB.js} +75 -9
- package/dist/chunk-ZUUI3ZSA.js +38 -0
- package/dist/{chunk-7HXE67BN.js → chunk-ZYNI26MI.js} +2 -2
- package/dist/index.js +32674 -27567
- package/dist/mcp/analyze-cli.js +11 -12
- package/dist/mcp/cli.js +46 -45
- package/dist/mcp/server.js +1210 -574
- package/dist/mcp/worker.js +65 -65
- package/dist/probes/installer.js +21 -23
- package/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
- package/docs/adr/README.md +1 -0
- package/docs/agent-tools.md +28 -7
- package/docs/ast-grep_rules_catalog.md +5 -3
- package/docs/configuration.md +12 -1
- package/docs/defect-shapes.md +738 -0
- package/docs/engineering-principles.md +12 -0
- package/docs/environment-variables.md +20 -0
- package/docs/features.md +16 -1
- package/docs/globalconfig.md +37 -8
- package/docs/invariants/caches-stores.md +30 -0
- package/docs/invariants/dispatch-runners.md +164 -0
- package/docs/invariants/git-guard-host.md +53 -0
- package/docs/invariants/language-config.md +31 -0
- package/docs/invariants/lsp-trust-exec.md +286 -0
- package/docs/invariants/paths-os.md +59 -0
- package/docs/invariants/session-telemetry.md +74 -0
- package/docs/lsp-capability-matrix.md +105 -12
- package/docs/lsp-idle-eviction.md +37 -18
- package/docs/pi-lens-fixer.md +24 -2
- package/docs/pi-lens-investigator.md +14 -0
- package/docs/pi-lens-merge-policy.md +32 -17
- package/docs/pi-lens-monitor.md +66 -10
- package/docs/pi-lens-orchestration.md +41 -0
- package/docs/pi-lens-release.md +20 -0
- package/docs/pi-lens-retro.md +5 -4
- package/docs/pi-lens-reviewer.md +54 -7
- package/docs/pi-lens-subagent.md +10 -3
- package/docs/release-qa-baseline.md +19 -7
- package/docs/servercapabilities.md +47 -47
- package/docs/settings.md +9 -5
- package/docs/subagent-compat.md +1 -1
- package/docs/usage.md +1 -0
- package/package.json +8 -5
- package/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
- package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
- package/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
- package/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
- package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
- package/rules/rule-catalog.json +25 -1
- package/scripts/analyze-pi-lens-logs.mjs +15 -5
- package/scripts/lib/is-main-module.mjs +27 -0
- package/scripts/lib/scratch-home-env.mjs +21 -0
- package/scripts/rpc-load-check.mjs +4 -6
- package/scripts/warm-loader-cache.mjs +2 -5
- package/dist/chunk-3PTHXJXR.js +0 -28
- package/dist/chunk-3QED2P4V.js +0 -31
- package/dist/chunk-5WRPDP2A.js +0 -47
- package/dist/chunk-ABBOA7UD.js +0 -157
- package/dist/chunk-CUHSHSB6.js +0 -273
- package/dist/chunk-GL5LUMZE.js +0 -51
- package/dist/chunk-HAD7QRQI.js +0 -30
- package/dist/chunk-JORED7EX.js +0 -44
- package/dist/chunk-KYUB6QDC.js +0 -72
- package/dist/chunk-LZSEQW6A.js +0 -57
- package/dist/chunk-M2IFVFWU.js +0 -79
- package/dist/chunk-M2UD3LPU.js +0 -88
- package/dist/chunk-MBKQHGA7.js +0 -39
- package/dist/chunk-R7YOCSNV.js +0 -23
- package/dist/chunk-SKAMFC7A.js +0 -28
- package/dist/chunk-SYE6T2EB.js +0 -28
- package/dist/chunk-TRETHTQO.js +0 -26
- package/dist/chunk-UA7ZXYDR.js +0 -184
- package/dist/chunk-XTFDJI3T.js +0 -24
- package/dist/chunk-Z3CCVDUB.js +0 -76
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
parseJsonc
|
|
4
|
+
} from "./chunk-PKES3ISE.js";
|
|
5
|
+
import {
|
|
6
|
+
extractTomlTableSection,
|
|
7
|
+
hasTomlTable,
|
|
8
|
+
parseTomlScalarString,
|
|
9
|
+
parseTomlStringArray
|
|
10
|
+
} from "./chunk-ZKXQKGWZ.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveLanguage
|
|
13
|
+
} from "./chunk-YISME6ON.js";
|
|
14
|
+
import {
|
|
15
|
+
getProjectTrustState
|
|
16
|
+
} from "./chunk-MN7MHUXQ.js";
|
|
17
|
+
import {
|
|
18
|
+
incrementDegradationCount,
|
|
19
|
+
recordDegradationOnce
|
|
20
|
+
} from "./chunk-ZQ6NZZTB.js";
|
|
21
|
+
import {
|
|
22
|
+
logExtension
|
|
23
|
+
} from "./chunk-KXF5R4UN.js";
|
|
24
|
+
import {
|
|
25
|
+
logLatency
|
|
26
|
+
} from "./chunk-Z2XAOKHK.js";
|
|
27
|
+
import {
|
|
28
|
+
UV_WORKSPACE_EXCLUDE_DIALECT,
|
|
29
|
+
UV_WORKSPACE_MEMBERS_DIALECT,
|
|
30
|
+
matchesWorkspaceMemberPattern,
|
|
31
|
+
realpathOrResolve,
|
|
32
|
+
toPosix,
|
|
33
|
+
walkUpDirs
|
|
34
|
+
} from "./chunk-PQJFG24Z.js";
|
|
35
|
+
|
|
36
|
+
// dist/clients/bounded-telemetry.js
|
|
37
|
+
var MAX_TRACKED_TURN_CAPS = 64;
|
|
38
|
+
var turnCounts = /* @__PURE__ */ new Map();
|
|
39
|
+
var latestCountedTurnIndex;
|
|
40
|
+
var retiredThroughTurnIndex = Number.NEGATIVE_INFINITY;
|
|
41
|
+
function admitBounded(phase, identity, options = {}) {
|
|
42
|
+
try {
|
|
43
|
+
let isRisingEdge = true;
|
|
44
|
+
if (options.ledgerKind !== void 0) {
|
|
45
|
+
isRisingEdge = incrementDegradationCount({
|
|
46
|
+
kind: options.ledgerKind,
|
|
47
|
+
subject: identity,
|
|
48
|
+
reason: options.reason ?? phase
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (options.risingEdgePer !== void 0 && !isRisingEdge)
|
|
52
|
+
return false;
|
|
53
|
+
return admitAgainstTurnCap(phase, options.capPerTurn);
|
|
54
|
+
} catch {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function emitBounded(phase, identity, payload, options = {}) {
|
|
59
|
+
try {
|
|
60
|
+
if (!admitBounded(phase, identity, options))
|
|
61
|
+
return false;
|
|
62
|
+
logLatency({
|
|
63
|
+
...payload,
|
|
64
|
+
type: payload.type ?? "phase",
|
|
65
|
+
phase,
|
|
66
|
+
// `filePath` is what existing latency.log queries filter on, so a site
|
|
67
|
+
// may keep a coarser one; `metadata.identity` below always carries the
|
|
68
|
+
// full discriminating identity. Aggregation that loses WHICH subject
|
|
69
|
+
// is stuck is the failure AGENTS.md names.
|
|
70
|
+
filePath: payload.filePath ?? identity,
|
|
71
|
+
metadata: { ...payload.metadata, identity }
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function admitAgainstTurnCap(phase, cap) {
|
|
79
|
+
if (cap === void 0)
|
|
80
|
+
return true;
|
|
81
|
+
if (cap.turnIndex <= retiredThroughTurnIndex)
|
|
82
|
+
return false;
|
|
83
|
+
let counts = turnCounts.get(cap.turnIndex);
|
|
84
|
+
if (!counts) {
|
|
85
|
+
if (turnCounts.size >= MAX_TRACKED_TURN_CAPS) {
|
|
86
|
+
const oldestTrackedTurn = Math.min(...turnCounts.keys());
|
|
87
|
+
if (cap.turnIndex < oldestTrackedTurn)
|
|
88
|
+
return false;
|
|
89
|
+
turnCounts.delete(oldestTrackedTurn);
|
|
90
|
+
retiredThroughTurnIndex = Math.max(retiredThroughTurnIndex, oldestTrackedTurn);
|
|
91
|
+
}
|
|
92
|
+
counts = /* @__PURE__ */ new Map();
|
|
93
|
+
turnCounts.set(cap.turnIndex, counts);
|
|
94
|
+
}
|
|
95
|
+
latestCountedTurnIndex = Math.max(latestCountedTurnIndex ?? cap.turnIndex, cap.turnIndex);
|
|
96
|
+
const used = counts.get(phase) ?? 0;
|
|
97
|
+
if (used >= cap.limit)
|
|
98
|
+
return false;
|
|
99
|
+
counts.set(phase, used + 1);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function resetBoundedTelemetry() {
|
|
103
|
+
turnCounts = /* @__PURE__ */ new Map();
|
|
104
|
+
latestCountedTurnIndex = void 0;
|
|
105
|
+
retiredThroughTurnIndex = Number.NEGATIVE_INFINITY;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// dist/clients/python-environment.js
|
|
109
|
+
import { access, readFile } from "node:fs/promises";
|
|
110
|
+
import os from "node:os";
|
|
111
|
+
import path, { dirname, join } from "node:path";
|
|
112
|
+
var UV_WORKSPACE_TABLE = "tool\\.uv\\.workspace";
|
|
113
|
+
async function findUvWorkspace(startDir, homeDir) {
|
|
114
|
+
let walkStart;
|
|
115
|
+
let nearestProject;
|
|
116
|
+
for (const dir of walkUpDirs(startDir, { homeDir })) {
|
|
117
|
+
walkStart ??= dir;
|
|
118
|
+
let content;
|
|
119
|
+
try {
|
|
120
|
+
content = await readFile(path.join(dir, "pyproject.toml"), "utf8");
|
|
121
|
+
} catch {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!nearestProject)
|
|
125
|
+
nearestProject = dir;
|
|
126
|
+
if (hasTomlTable(content, UV_WORKSPACE_TABLE)) {
|
|
127
|
+
const workspaceTable = extractTomlTableSection(content, UV_WORKSPACE_TABLE);
|
|
128
|
+
return {
|
|
129
|
+
root: dir,
|
|
130
|
+
explicit: true,
|
|
131
|
+
projectRoot: nearestProject,
|
|
132
|
+
isStartDir: nearestProject === walkStart,
|
|
133
|
+
members: parseTomlStringArray(workspaceTable, "members"),
|
|
134
|
+
exclude: parseTomlStringArray(workspaceTable, "exclude")
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return nearestProject ? {
|
|
139
|
+
root: nearestProject,
|
|
140
|
+
explicit: false,
|
|
141
|
+
projectRoot: nearestProject,
|
|
142
|
+
isStartDir: nearestProject === walkStart,
|
|
143
|
+
members: [],
|
|
144
|
+
exclude: []
|
|
145
|
+
} : void 0;
|
|
146
|
+
}
|
|
147
|
+
function isUvWorkspaceMember(workspace, projectRoot) {
|
|
148
|
+
const relative = toPosix(path.relative(workspace.root, projectRoot));
|
|
149
|
+
if (relative.length === 0 || relative === ".." || relative.startsWith("../") || path.isAbsolute(relative)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const matches = (dialect) => (pattern) => matchesWorkspaceMemberPattern(pattern, relative, dialect, () => recordDegradationOnce({
|
|
153
|
+
kind: "workspace-glob-cap",
|
|
154
|
+
subject: String(pattern.length),
|
|
155
|
+
reason: "workspace glob matcher exceeded its memo-table cell cap"
|
|
156
|
+
}));
|
|
157
|
+
return !workspace.exclude.some(matches(UV_WORKSPACE_EXCLUDE_DIALECT)) && workspace.members.some(matches(UV_WORKSPACE_MEMBERS_DIALECT));
|
|
158
|
+
}
|
|
159
|
+
var PROJECT_SOURCED_PYTHON_SOURCES = /* @__PURE__ */ new Set([
|
|
160
|
+
"project-dot-venv",
|
|
161
|
+
"project-venv",
|
|
162
|
+
"uv-workspace"
|
|
163
|
+
]);
|
|
164
|
+
var AMBIENT_ENVIRONMENT_VARIABLES = {
|
|
165
|
+
"uv-project-environment": "UV_PROJECT_ENVIRONMENT",
|
|
166
|
+
"virtual-env": "VIRTUAL_ENV",
|
|
167
|
+
conda: "CONDA_PREFIX"
|
|
168
|
+
};
|
|
169
|
+
function hasAmbientPythonEnvironment(env = process.env) {
|
|
170
|
+
return Object.values(AMBIENT_ENVIRONMENT_VARIABLES).some((name) => Boolean(env[name]));
|
|
171
|
+
}
|
|
172
|
+
async function detectPythonEnvironment(projectRoot, homeDir = os.homedir(), options = {}) {
|
|
173
|
+
const root = realpathOrResolve(projectRoot);
|
|
174
|
+
const uvWorkspace = await findUvWorkspace(root, homeDir);
|
|
175
|
+
const isProjectRoot = uvWorkspace?.isStartDir === true;
|
|
176
|
+
const memberWorkspaceRoot = isProjectRoot && uvWorkspace.explicit && isUvWorkspaceMember(uvWorkspace, root) ? uvWorkspace.root : void 0;
|
|
177
|
+
const uvEnvironmentRoot = isProjectRoot ? memberWorkspaceRoot ?? uvWorkspace.projectRoot : void 0;
|
|
178
|
+
const uvProjectEnvironment = process.env.UV_PROJECT_ENVIRONMENT;
|
|
179
|
+
const allowAmbient = options.allowAmbient ?? true;
|
|
180
|
+
const isWithinProjectRoot = (candidateRoot) => {
|
|
181
|
+
const relative = path.relative(root, realpathOrResolve(candidateRoot));
|
|
182
|
+
return relative !== ".." && !relative.startsWith(`..${path.sep}`) && // #3871 V1: another Windows drive has no relative path, so
|
|
183
|
+
// `path.relative` returns the absolute target: no `..`, not inside.
|
|
184
|
+
!path.isAbsolute(relative);
|
|
185
|
+
};
|
|
186
|
+
const candidates = [
|
|
187
|
+
...uvEnvironmentRoot !== void 0 && uvProjectEnvironment ? [
|
|
188
|
+
{
|
|
189
|
+
// `path.resolve` leaves an absolute value untouched and
|
|
190
|
+
// anchors a relative one at the project's workspace root.
|
|
191
|
+
root: path.resolve(uvEnvironmentRoot, uvProjectEnvironment),
|
|
192
|
+
source: "uv-project-environment"
|
|
193
|
+
}
|
|
194
|
+
] : [],
|
|
195
|
+
...memberWorkspaceRoot !== void 0 ? [
|
|
196
|
+
{
|
|
197
|
+
root: path.join(memberWorkspaceRoot, ".venv"),
|
|
198
|
+
source: "uv-workspace"
|
|
199
|
+
}
|
|
200
|
+
] : [],
|
|
201
|
+
{ root: process.env.VIRTUAL_ENV, source: "virtual-env" },
|
|
202
|
+
{ root: process.env.CONDA_PREFIX, source: "conda" },
|
|
203
|
+
{ root: path.join(root, ".venv"), source: "project-dot-venv" },
|
|
204
|
+
{ root: path.join(root, "venv"), source: "project-venv" }
|
|
205
|
+
];
|
|
206
|
+
for (const candidate of candidates) {
|
|
207
|
+
if (!candidate.root)
|
|
208
|
+
continue;
|
|
209
|
+
if (!allowAmbient && candidate.source in AMBIENT_ENVIRONMENT_VARIABLES && !isWithinProjectRoot(candidate.root))
|
|
210
|
+
continue;
|
|
211
|
+
if (PROJECT_SOURCED_PYTHON_SOURCES.has(candidate.source) && getProjectTrustState() !== "trusted") {
|
|
212
|
+
if (recordDegradationOnce({
|
|
213
|
+
kind: "trust-refusal",
|
|
214
|
+
subject: `python-environment:${candidate.root}`,
|
|
215
|
+
reason: `project Python environment refused: pi project trust is ${getProjectTrustState()}`
|
|
216
|
+
})) {
|
|
217
|
+
logExtension({
|
|
218
|
+
subsystem: "project-trust",
|
|
219
|
+
level: "warn",
|
|
220
|
+
message: "project Python environment refused: mark the project trusted in pi or upgrade pi",
|
|
221
|
+
metadata: { source: candidate.source }
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const binDir = path.join(candidate.root, process.platform === "win32" ? "Scripts" : "bin");
|
|
227
|
+
const pythonPath = path.join(binDir, process.platform === "win32" ? "python.exe" : "python");
|
|
228
|
+
try {
|
|
229
|
+
await access(pythonPath);
|
|
230
|
+
return {
|
|
231
|
+
root: candidate.root,
|
|
232
|
+
binDir,
|
|
233
|
+
pythonPath,
|
|
234
|
+
source: candidate.source
|
|
235
|
+
};
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return void 0;
|
|
240
|
+
}
|
|
241
|
+
function augmentPythonEnvironment(baseEnvironment, environment) {
|
|
242
|
+
if (!environment)
|
|
243
|
+
return baseEnvironment;
|
|
244
|
+
const inheritedPath = baseEnvironment.PATH ?? baseEnvironment.Path ?? baseEnvironment.path ?? "";
|
|
245
|
+
const augmentedPath = inheritedPath ? `${environment.binDir}${path.delimiter}${inheritedPath}` : environment.binDir;
|
|
246
|
+
const childEnvironment = {
|
|
247
|
+
...baseEnvironment,
|
|
248
|
+
PATH: augmentedPath,
|
|
249
|
+
VIRTUAL_ENV: environment.root
|
|
250
|
+
};
|
|
251
|
+
if (process.platform === "win32")
|
|
252
|
+
childEnvironment.Path = augmentedPath;
|
|
253
|
+
return childEnvironment;
|
|
254
|
+
}
|
|
255
|
+
function pythonEnvironmentToolCandidates(environment, command) {
|
|
256
|
+
if (!environment)
|
|
257
|
+
return [];
|
|
258
|
+
if (process.platform !== "win32") {
|
|
259
|
+
return [path.join(environment.binDir, command)];
|
|
260
|
+
}
|
|
261
|
+
return [
|
|
262
|
+
path.join(environment.binDir, `${command}.exe`),
|
|
263
|
+
path.join(environment.binDir, `${command}.cmd`),
|
|
264
|
+
path.join(environment.binDir, command)
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
var PYTHON_DECLARATION_CONCURRENCY = 8;
|
|
268
|
+
var PYTHON_COMPILE_VERDICT_SERVER_ID = "python-jedi";
|
|
269
|
+
var PYTHON_COMPILE_VERDICT_FLOOR = { major: 3, minor: 14 };
|
|
270
|
+
function isJediCompileVerdict(diagnostic) {
|
|
271
|
+
const server = diagnostic.serverId ?? diagnostic.tool;
|
|
272
|
+
const source = diagnostic.source ?? diagnostic.rule?.split(":")[0];
|
|
273
|
+
return server === PYTHON_COMPILE_VERDICT_SERVER_ID && source === "compile";
|
|
274
|
+
}
|
|
275
|
+
function isJediCompileVerdictOutranked(diagnostic, declared) {
|
|
276
|
+
if (declared === void 0)
|
|
277
|
+
return false;
|
|
278
|
+
if (!isJediCompileVerdict(diagnostic))
|
|
279
|
+
return false;
|
|
280
|
+
return declared.major > PYTHON_COMPILE_VERDICT_FLOOR.major || declared.major === PYTHON_COMPILE_VERDICT_FLOOR.major && declared.minor >= PYTHON_COMPILE_VERDICT_FLOOR.minor;
|
|
281
|
+
}
|
|
282
|
+
function partitionOutrankedPythonCompileVerdicts(diagnostics, declared) {
|
|
283
|
+
const kept = [];
|
|
284
|
+
let dropped = 0;
|
|
285
|
+
for (const diagnostic of diagnostics) {
|
|
286
|
+
if (isJediCompileVerdictOutranked(diagnostic, declared))
|
|
287
|
+
dropped += 1;
|
|
288
|
+
else
|
|
289
|
+
kept.push(diagnostic);
|
|
290
|
+
}
|
|
291
|
+
return { kept, dropped };
|
|
292
|
+
}
|
|
293
|
+
function recordPythonCompileVerdictDrop(file, declared, dropped) {
|
|
294
|
+
recordDegradationOnce({
|
|
295
|
+
kind: "python-compile-target-mismatch",
|
|
296
|
+
subject: file,
|
|
297
|
+
reason: `${dropped} jedi compile ${dropped === 1 ? "finding" : "findings"} dropped: declared Python ${declared.major}.${declared.minor} (${declared.source}) in ${declared.file}`,
|
|
298
|
+
metadata: {
|
|
299
|
+
declared: `${declared.major}.${declared.minor}`,
|
|
300
|
+
source: declared.source,
|
|
301
|
+
declarationFile: declared.file,
|
|
302
|
+
dropped
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function describePythonCompileWithheld(count, declared) {
|
|
307
|
+
return `${count} python-jedi compile finding${count === 1 ? "" : "s"} withheld: the project declares Python ${declared.major}.${declared.minor} (${declared.source}) in ${declared.file}`;
|
|
308
|
+
}
|
|
309
|
+
var BARE_VERSION_PREFIX = /^v?(\d+)\.(\d+)/i;
|
|
310
|
+
var VERSION_SUFFIX = /^[-+._a-z0-9]*$/i;
|
|
311
|
+
var SPECIFIER_LOWER_BOUND = /^(?:>=|==|~=)\s*v?(\d+)\.(\d+)/;
|
|
312
|
+
var RUFF_LEVEL = /^py(\d)(\d+)$/i;
|
|
313
|
+
function reducePythonVersion(match) {
|
|
314
|
+
if (!match)
|
|
315
|
+
return void 0;
|
|
316
|
+
return { major: Number(match[1]), minor: Number(match[2]) };
|
|
317
|
+
}
|
|
318
|
+
function reduceBarePythonVersion(text) {
|
|
319
|
+
const trimmed = text.trim();
|
|
320
|
+
const prefix = BARE_VERSION_PREFIX.exec(trimmed);
|
|
321
|
+
if (!prefix)
|
|
322
|
+
return void 0;
|
|
323
|
+
if (!VERSION_SUFFIX.test(trimmed.slice(prefix[0].length)))
|
|
324
|
+
return void 0;
|
|
325
|
+
return reducePythonVersion(prefix);
|
|
326
|
+
}
|
|
327
|
+
function reducePythonSpecifier(text) {
|
|
328
|
+
let strongest;
|
|
329
|
+
for (const clause of text.split(",")) {
|
|
330
|
+
const lowerBound = reducePythonVersion(SPECIFIER_LOWER_BOUND.exec(clause.trim()));
|
|
331
|
+
if (!lowerBound)
|
|
332
|
+
continue;
|
|
333
|
+
if (!strongest || lowerBound.major > strongest.major || lowerBound.major === strongest.major && lowerBound.minor > strongest.minor) {
|
|
334
|
+
strongest = lowerBound;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return strongest ?? reduceBarePythonVersion(text);
|
|
338
|
+
}
|
|
339
|
+
function reduceRuffTargetVersion(text) {
|
|
340
|
+
return reducePythonVersion(RUFF_LEVEL.exec(text.trim()));
|
|
341
|
+
}
|
|
342
|
+
function withSource(level, source, file) {
|
|
343
|
+
return level ? { ...level, source, file } : void 0;
|
|
344
|
+
}
|
|
345
|
+
async function readDeclarationFile(filePath) {
|
|
346
|
+
try {
|
|
347
|
+
return await readFile(filePath, "utf-8");
|
|
348
|
+
} catch (err) {
|
|
349
|
+
const code = err.code;
|
|
350
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
recordDegradationOnce({
|
|
354
|
+
kind: "python-target-version-unreadable",
|
|
355
|
+
subject: filePath,
|
|
356
|
+
reason: `Python syntax-level declaration could not be read: ${err instanceof Error ? err.message : String(err)}`
|
|
357
|
+
});
|
|
358
|
+
return void 0;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function parsePyrightJsonVersion(content) {
|
|
362
|
+
let parsed;
|
|
363
|
+
try {
|
|
364
|
+
parsed = parseJsonc(content);
|
|
365
|
+
} catch {
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
369
|
+
return void 0;
|
|
370
|
+
}
|
|
371
|
+
const value = parsed.pythonVersion;
|
|
372
|
+
return typeof value === "string" ? reduceBarePythonVersion(value) : void 0;
|
|
373
|
+
}
|
|
374
|
+
async function readRuffTier(dir, pyproject, pyprojectPath) {
|
|
375
|
+
let configPath;
|
|
376
|
+
let config;
|
|
377
|
+
for (const name of [".ruff.toml", "ruff.toml"]) {
|
|
378
|
+
const candidatePath = join(dir, name);
|
|
379
|
+
config = await readDeclarationFile(candidatePath);
|
|
380
|
+
if (config !== void 0) {
|
|
381
|
+
configPath = candidatePath;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (config === void 0) {
|
|
386
|
+
if (pyproject === void 0 || !hasTomlTable(pyproject, String.raw`tool\.ruff`)) {
|
|
387
|
+
return { declaration: void 0, owned: false };
|
|
388
|
+
}
|
|
389
|
+
configPath = pyprojectPath;
|
|
390
|
+
config = extractTomlTableSection(pyproject, String.raw`tool\.ruff`);
|
|
391
|
+
}
|
|
392
|
+
if (configPath === void 0 || config === void 0) {
|
|
393
|
+
return { declaration: void 0, owned: false };
|
|
394
|
+
}
|
|
395
|
+
const target = parseTomlScalarString(config, "target-version");
|
|
396
|
+
return {
|
|
397
|
+
declaration: withSource(target ? reduceRuffTargetVersion(target) : void 0, "ruff-target-version", configPath),
|
|
398
|
+
owned: true
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
async function readPyrightTier(dir, pyproject, pyprojectPath) {
|
|
402
|
+
const configPath = join(dir, "pyrightconfig.json");
|
|
403
|
+
const config = await readDeclarationFile(configPath);
|
|
404
|
+
if (config !== void 0) {
|
|
405
|
+
return {
|
|
406
|
+
declaration: withSource(parsePyrightJsonVersion(config), "pyright-python-version", configPath),
|
|
407
|
+
owned: true
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (pyproject === void 0)
|
|
411
|
+
return { declaration: void 0, owned: false };
|
|
412
|
+
const section = extractTomlTableSection(pyproject, String.raw`tool\.pyright`);
|
|
413
|
+
if (section === void 0)
|
|
414
|
+
return { declaration: void 0, owned: false };
|
|
415
|
+
const raw = parseTomlScalarString(section, "pythonVersion");
|
|
416
|
+
return {
|
|
417
|
+
declaration: withSource(raw ? reduceBarePythonVersion(raw) : void 0, "pyright-python-version", pyprojectPath),
|
|
418
|
+
owned: true
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function readRequiresPythonTier(pyproject, pyprojectPath) {
|
|
422
|
+
if (pyproject === void 0)
|
|
423
|
+
return { declaration: void 0, owned: false };
|
|
424
|
+
const projectSection = extractTomlTableSection(pyproject, "project");
|
|
425
|
+
const raw = projectSection !== void 0 ? parseTomlScalarString(projectSection, "requires-python") : void 0;
|
|
426
|
+
return {
|
|
427
|
+
declaration: withSource(raw ? reducePythonSpecifier(raw) : void 0, "requires-python", pyprojectPath),
|
|
428
|
+
owned: raw !== void 0
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
async function readVersionFileTier(dir) {
|
|
432
|
+
const levelFilePath = join(dir, ".python-version");
|
|
433
|
+
const content = await readDeclarationFile(levelFilePath);
|
|
434
|
+
if (content === void 0)
|
|
435
|
+
return { declaration: void 0, owned: false };
|
|
436
|
+
const firstLine = (content.split(/\r?\n/, 1)[0] ?? "").trim();
|
|
437
|
+
return {
|
|
438
|
+
declaration: withSource(reduceBarePythonVersion(firstLine), "python-version-file", levelFilePath),
|
|
439
|
+
owned: true
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
var PYTHON_DECLARATION_SOURCES = [
|
|
443
|
+
"ruff-target-version",
|
|
444
|
+
"pyright-python-version",
|
|
445
|
+
"requires-python",
|
|
446
|
+
"python-version-file"
|
|
447
|
+
];
|
|
448
|
+
async function readPythonDeclarationInDirectory(dir, open) {
|
|
449
|
+
const pyprojectPath = join(dir, "pyproject.toml");
|
|
450
|
+
const pyproject = await readDeclarationFile(pyprojectPath);
|
|
451
|
+
const tiers = [
|
|
452
|
+
["ruff-target-version", () => readRuffTier(dir, pyproject, pyprojectPath)],
|
|
453
|
+
[
|
|
454
|
+
"pyright-python-version",
|
|
455
|
+
() => readPyrightTier(dir, pyproject, pyprojectPath)
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
"requires-python",
|
|
459
|
+
async () => readRequiresPythonTier(pyproject, pyprojectPath)
|
|
460
|
+
],
|
|
461
|
+
["python-version-file", () => readVersionFileTier(dir)]
|
|
462
|
+
];
|
|
463
|
+
const closed = [];
|
|
464
|
+
for (const [source, read] of tiers) {
|
|
465
|
+
if (!open.has(source))
|
|
466
|
+
continue;
|
|
467
|
+
const { declaration, owned } = await read();
|
|
468
|
+
if (declaration)
|
|
469
|
+
return { declaration, closed: [] };
|
|
470
|
+
if (owned)
|
|
471
|
+
closed.push(source);
|
|
472
|
+
}
|
|
473
|
+
return { declaration: void 0, closed };
|
|
474
|
+
}
|
|
475
|
+
async function detectPythonTargetVersion(filePath, homeDir = os.homedir()) {
|
|
476
|
+
if (resolveLanguage(filePath)?.id !== "python")
|
|
477
|
+
return void 0;
|
|
478
|
+
const open = new Set(PYTHON_DECLARATION_SOURCES);
|
|
479
|
+
for (const dir of walkUpDirs(dirname(realpathOrResolve(filePath)), {
|
|
480
|
+
homeDir
|
|
481
|
+
})) {
|
|
482
|
+
const { declaration, closed } = await readPythonDeclarationInDirectory(dir, open);
|
|
483
|
+
if (declaration)
|
|
484
|
+
return declaration;
|
|
485
|
+
for (const source of closed)
|
|
486
|
+
open.delete(source);
|
|
487
|
+
if (open.size === 0)
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
return void 0;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export {
|
|
494
|
+
emitBounded,
|
|
495
|
+
resetBoundedTelemetry,
|
|
496
|
+
hasAmbientPythonEnvironment,
|
|
497
|
+
detectPythonEnvironment,
|
|
498
|
+
augmentPythonEnvironment,
|
|
499
|
+
pythonEnvironmentToolCandidates,
|
|
500
|
+
PYTHON_DECLARATION_CONCURRENCY,
|
|
501
|
+
PYTHON_COMPILE_VERDICT_SERVER_ID,
|
|
502
|
+
isJediCompileVerdict,
|
|
503
|
+
partitionOutrankedPythonCompileVerdicts,
|
|
504
|
+
recordPythonCompileVerdictDrop,
|
|
505
|
+
describePythonCompileWithheld,
|
|
506
|
+
detectPythonTargetVersion
|
|
507
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getSourceFiles
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BWYQUPOS.js";
|
|
5
5
|
import {
|
|
6
6
|
readDirEntriesSafe,
|
|
7
7
|
shouldRecurseIntoDir
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VG5JS5SW.js";
|
|
9
9
|
import {
|
|
10
10
|
getProjectIgnoreMatcher
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-Q3UZHW6N.js";
|
|
12
12
|
import {
|
|
13
13
|
CODE_KINDS,
|
|
14
14
|
DOTNET_CSHARP_ROOT_MARKERS,
|
|
@@ -17,18 +17,18 @@ import {
|
|
|
17
17
|
LEAN_ROOT_MARKERS,
|
|
18
18
|
TERRAGRUNT_FILENAMES,
|
|
19
19
|
detectFileKind
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RZOXUSPC.js";
|
|
21
21
|
import {
|
|
22
22
|
findNearestDirWithAnyBasename,
|
|
23
23
|
registerWorkspaceTopologyReset
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import {
|
|
26
|
-
BoundedLruCache
|
|
27
|
-
} from "./chunk-ABBOA7UD.js";
|
|
24
|
+
} from "./chunk-J6JP25XU.js";
|
|
28
25
|
import {
|
|
26
|
+
BoundedLruCache,
|
|
29
27
|
direntsHaveMarkerGlobMatch,
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
isUnderDir,
|
|
29
|
+
normalizeMapKey,
|
|
30
|
+
realpathOrResolve
|
|
31
|
+
} from "./chunk-PQJFG24Z.js";
|
|
32
32
|
|
|
33
33
|
// dist/clients/language-profile.js
|
|
34
34
|
import * as fs from "node:fs";
|
|
@@ -473,7 +473,7 @@ function getDefaultStartupTools(profile) {
|
|
|
473
473
|
}
|
|
474
474
|
function resolveLanguageRootForFile(filePath, workspaceRoot) {
|
|
475
475
|
const absoluteFilePath = path.resolve(filePath);
|
|
476
|
-
const startDir = path.dirname(absoluteFilePath);
|
|
476
|
+
const startDir = path.dirname(realpathOrResolve(absoluteFilePath));
|
|
477
477
|
const kind = detectFileKind(absoluteFilePath);
|
|
478
478
|
if (!kind)
|
|
479
479
|
return path.resolve(workspaceRoot);
|
|
@@ -485,11 +485,7 @@ function resolveLanguageRootForFile(filePath, workspaceRoot) {
|
|
|
485
485
|
if (!found)
|
|
486
486
|
return path.resolve(workspaceRoot);
|
|
487
487
|
const workspace = path.resolve(workspaceRoot);
|
|
488
|
-
|
|
489
|
-
if (relative2.startsWith("..") || path.isAbsolute(relative2)) {
|
|
490
|
-
return workspace;
|
|
491
|
-
}
|
|
492
|
-
return found;
|
|
488
|
+
return isUnderDir(found, workspace) ? found : workspace;
|
|
493
489
|
}
|
|
494
490
|
var WARMUP_SOURCE_EXTS = new Set(SUPPORTED_FILE_KINDS.flatMap((kind) => KIND_EXTENSIONS[kind]));
|
|
495
491
|
var WARMUP_CODE_EXTS = new Set(SUPPORTED_FILE_KINDS.filter((kind) => CODE_KINDS.has(kind)).flatMap((kind) => KIND_EXTENSIONS[kind]));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
normalizeHostToolPath,
|
|
4
|
-
normalizeMapKey
|
|
5
|
-
|
|
4
|
+
normalizeMapKey,
|
|
5
|
+
walkUpDirs
|
|
6
|
+
} from "./chunk-PQJFG24Z.js";
|
|
6
7
|
|
|
7
8
|
// dist/clients/content-stamp.js
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
@@ -21,7 +22,7 @@ import * as path from "node:path";
|
|
|
21
22
|
function resolveAgainstAncestors(cwd, filePath) {
|
|
22
23
|
filePath = normalizeHostToolPath(filePath);
|
|
23
24
|
if (path.isAbsolute(filePath)) {
|
|
24
|
-
return
|
|
25
|
+
return filePath;
|
|
25
26
|
}
|
|
26
27
|
const normalizedRelative = filePath.replace(/\\/g, "/");
|
|
27
28
|
const cwdBaseName = path.basename(path.resolve(cwd)).replace(/\\/g, "/");
|
|
@@ -36,17 +37,11 @@ function resolveAgainstAncestors(cwd, filePath) {
|
|
|
36
37
|
if (fs2.existsSync(directCandidate)) {
|
|
37
38
|
return directCandidate;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
while (current !== root) {
|
|
42
|
-
const parent = path.dirname(current);
|
|
43
|
-
if (parent === current)
|
|
44
|
-
break;
|
|
45
|
-
const candidate = path.resolve(parent, filePath);
|
|
40
|
+
for (const dir of walkUpDirs(cwd)) {
|
|
41
|
+
const candidate = path.resolve(dir, filePath);
|
|
46
42
|
if (fs2.existsSync(candidate)) {
|
|
47
43
|
return candidate;
|
|
48
44
|
}
|
|
49
|
-
current = parent;
|
|
50
45
|
}
|
|
51
46
|
return directCandidate;
|
|
52
47
|
}
|
|
@@ -63,22 +58,10 @@ function toRunnerDisplayPath(cwd, filePath) {
|
|
|
63
58
|
return fileKey;
|
|
64
59
|
}
|
|
65
60
|
|
|
66
|
-
// dist/clients/freshness.js
|
|
67
|
-
var MTIME_DRIFT_TOLERANCE_MS = 50;
|
|
68
|
-
function freshnessFromMtime(input) {
|
|
69
|
-
const tolerance = input.toleranceMs ?? MTIME_DRIFT_TOLERANCE_MS;
|
|
70
|
-
if (input.mtimeMs === void 0) {
|
|
71
|
-
return { verdict: "indeterminate", reason: "no-mtime-evidence" };
|
|
72
|
-
}
|
|
73
|
-
return input.mtimeMs > input.referenceMs + tolerance ? { verdict: "stale", reason: "modified-after-reference" } : { verdict: "fresh" };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
61
|
export {
|
|
77
62
|
CONTENT_HASH_MAX_BYTES,
|
|
78
63
|
hashContentBytes,
|
|
79
64
|
hashFileBytes,
|
|
80
65
|
resolveRunnerPath,
|
|
81
|
-
toRunnerDisplayPath
|
|
82
|
-
MTIME_DRIFT_TOLERANCE_MS,
|
|
83
|
-
freshnessFromMtime
|
|
66
|
+
toRunnerDisplayPath
|
|
84
67
|
};
|