@herbertgao/pi-extensions 2026.11.7 → 2026.11.9

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 (129) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +9 -9
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-subagents/README.md +2 -2
  6. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  7. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +10 -6
  8. package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +47 -4
  9. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +19 -0
  10. package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-WHRN26NJ.ts → main-tree-picker-3PXJARQW.ts} +59 -53
  11. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +7 -0
  12. package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
  13. package/node_modules/@narumitw/pi-btw/docs/main-tree-snapshots.md +39 -0
  14. package/node_modules/@narumitw/pi-btw/docs/workflows.md +1 -0
  15. package/node_modules/@narumitw/pi-btw/package.json +2 -2
  16. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +73 -63
  17. package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
  18. package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
  19. package/node_modules/pi-commandcode-provider/CHANGELOG.md +5 -0
  20. package/node_modules/pi-commandcode-provider/package.json +1 -1
  21. package/node_modules/pi-commandcode-provider/src/pricing.ts +4 -4
  22. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  23. package/node_modules/pi-lens/CHANGELOG.md +30 -0
  24. package/node_modules/pi-lens/README.md +1 -0
  25. package/node_modules/pi-lens/dist/{chunk-KDGKKK7A.js → chunk-2HWVG3IM.js} +1 -1
  26. package/node_modules/pi-lens/dist/{chunk-3QCI3V6C.js → chunk-3EIZMRXI.js} +5 -5
  27. package/node_modules/pi-lens/dist/{chunk-NWK7KKNO.js → chunk-3MHY4BQY.js} +2 -2
  28. package/node_modules/pi-lens/dist/{chunk-3NVGBFJS.js → chunk-3PMLYGJN.js} +2 -2
  29. package/node_modules/pi-lens/dist/{chunk-OP5BMZKK.js → chunk-3QMLB4TI.js} +1 -1
  30. package/node_modules/pi-lens/dist/{chunk-V7IPIAE5.js → chunk-3VWEZ6H2.js} +24 -26
  31. package/node_modules/pi-lens/dist/{chunk-NLRKB32C.js → chunk-5EEWCJG7.js} +1 -1
  32. package/node_modules/pi-lens/dist/{chunk-VDMF7Q2P.js → chunk-5FDUKJZO.js} +4 -4
  33. package/node_modules/pi-lens/dist/{chunk-KBSC5Z3G.js → chunk-5KLRCUDT.js} +2 -2
  34. package/node_modules/pi-lens/dist/{chunk-GL6J5R34.js → chunk-6EXGCXM5.js} +3 -3
  35. package/node_modules/pi-lens/dist/{chunk-OC4ZGVMH.js → chunk-6GWCYEP7.js} +5 -7
  36. package/node_modules/pi-lens/dist/{chunk-LXE7JAMV.js → chunk-6JLNZ6DP.js} +4 -4
  37. package/node_modules/pi-lens/dist/{chunk-TTGDTNSN.js → chunk-75TVYCQW.js} +3 -3
  38. package/node_modules/pi-lens/dist/{chunk-QAM2Q3VO.js → chunk-7BEADGAZ.js} +2 -2
  39. package/node_modules/pi-lens/dist/{chunk-R5BNSOIV.js → chunk-7KWI5UHL.js} +7 -8
  40. package/node_modules/pi-lens/dist/{chunk-5YTDZ5WP.js → chunk-7M64NTAK.js} +1 -1
  41. package/node_modules/pi-lens/dist/{chunk-B4K6OSLL.js → chunk-7T64QA5D.js} +25 -27
  42. package/node_modules/pi-lens/dist/{chunk-KDMJ2DJD.js → chunk-7ZVEFWOE.js} +5 -5
  43. package/node_modules/pi-lens/dist/{chunk-D5L7Q57Z.js → chunk-AAIVSSUU.js} +1 -1
  44. package/node_modules/pi-lens/dist/{chunk-LIDFFCZZ.js → chunk-AD7JDEI6.js} +9 -9
  45. package/node_modules/pi-lens/dist/{chunk-WBXCIRVI.js → chunk-AVBEPUCD.js} +1 -1
  46. package/node_modules/pi-lens/dist/{chunk-VTXJAO5R.js → chunk-AZXTLZHE.js} +9 -9
  47. package/node_modules/pi-lens/dist/{chunk-UELHWF5I.js → chunk-BEIPWPVR.js} +10 -10
  48. package/node_modules/pi-lens/dist/{chunk-SQBDX6IO.js → chunk-C6V2DSZZ.js} +6 -6
  49. package/node_modules/pi-lens/dist/{chunk-ZD4KVFXI.js → chunk-D2ZYRI7M.js} +172 -3
  50. package/node_modules/pi-lens/dist/{chunk-HIUVHRLM.js → chunk-D6ANA6YU.js} +20 -22
  51. package/node_modules/pi-lens/dist/{chunk-YUF4DRYB.js → chunk-D7OEGXDX.js} +1 -1
  52. package/node_modules/pi-lens/dist/{chunk-AOQKQWZU.js → chunk-DFAY7JUN.js} +1 -1
  53. package/node_modules/pi-lens/dist/{chunk-QUZYRDT6.js → chunk-DIIDMDZU.js} +6 -6
  54. package/node_modules/pi-lens/dist/{chunk-QBUSONNE.js → chunk-DZSQXG66.js} +45 -27
  55. package/node_modules/pi-lens/dist/{chunk-UY3WWW5R.js → chunk-E5SSUV2A.js} +3 -3
  56. package/node_modules/pi-lens/dist/{chunk-DNB4ZQGN.js → chunk-ET3DSSFZ.js} +1 -1
  57. package/node_modules/pi-lens/dist/{chunk-4WWPDMRA.js → chunk-F7AMFFVK.js} +4 -4
  58. package/node_modules/pi-lens/dist/{chunk-LHCDWFDB.js → chunk-FDLGJFAE.js} +1 -1
  59. package/node_modules/pi-lens/dist/{chunk-C4ICGFEO.js → chunk-FVQKX5KI.js} +12 -12
  60. package/node_modules/pi-lens/dist/{chunk-TRYOYWWU.js → chunk-G3LR6V6N.js} +4 -4
  61. package/node_modules/pi-lens/dist/{chunk-AVOUHMCS.js → chunk-GHATCG2A.js} +10 -10
  62. package/node_modules/pi-lens/dist/{chunk-R2UF54ON.js → chunk-HJWF7CGW.js} +9 -9
  63. package/node_modules/pi-lens/dist/chunk-HRQTYU2T.js +355 -0
  64. package/node_modules/pi-lens/dist/{chunk-NR4KQOXZ.js → chunk-HSTN27NR.js} +1 -1
  65. package/node_modules/pi-lens/dist/{chunk-YVPB5YGO.js → chunk-HWMNTQBJ.js} +1 -1
  66. package/node_modules/pi-lens/dist/{chunk-6XNVY3FW.js → chunk-HYDJUVOE.js} +1 -1
  67. package/node_modules/pi-lens/dist/{chunk-WXMUGUZV.js → chunk-HYR25MV3.js} +4 -4
  68. package/node_modules/pi-lens/dist/{chunk-AJ62EQIQ.js → chunk-IC4L65U7.js} +12 -9
  69. package/node_modules/pi-lens/dist/{chunk-R2VUZZPJ.js → chunk-ILC2B7IJ.js} +4 -4
  70. package/node_modules/pi-lens/dist/{chunk-E6Z3CJT2.js → chunk-IZ36G463.js} +5 -5
  71. package/node_modules/pi-lens/dist/{chunk-IBEYUBCM.js → chunk-JKAVKTMY.js} +6 -6
  72. package/node_modules/pi-lens/dist/{chunk-LHU6NG5Z.js → chunk-JLMS7EMD.js} +8 -8
  73. package/node_modules/pi-lens/dist/{chunk-6RXMQYNU.js → chunk-JRSS6KM4.js} +1 -1
  74. package/node_modules/pi-lens/dist/{chunk-HASJPQBC.js → chunk-K2LD6YNH.js} +4 -4
  75. package/node_modules/pi-lens/dist/{chunk-UQ6OZYTO.js → chunk-KUDUKKQE.js} +43 -45
  76. package/node_modules/pi-lens/dist/{chunk-34RXPR7M.js → chunk-KXDQD34C.js} +1 -1
  77. package/node_modules/pi-lens/dist/{chunk-QDZ3ZZMY.js → chunk-LD7SXICE.js} +3 -3
  78. package/node_modules/pi-lens/dist/{chunk-NQFXN5U7.js → chunk-MOEWCPMC.js} +1 -1
  79. package/node_modules/pi-lens/dist/{chunk-IJ55MYO6.js → chunk-MV6ST2KT.js} +4 -4
  80. package/node_modules/pi-lens/dist/{chunk-532X3OCZ.js → chunk-NCDH2JB7.js} +7 -9
  81. package/node_modules/pi-lens/dist/{chunk-ITAPXBIB.js → chunk-NRVWLTOY.js} +9 -9
  82. package/node_modules/pi-lens/dist/{chunk-DPDA3ILA.js → chunk-NZINZCHB.js} +1 -1
  83. package/node_modules/pi-lens/dist/{chunk-A4HKPAEN.js → chunk-OEPWTSUG.js} +6 -6
  84. package/node_modules/pi-lens/dist/{chunk-TBE4OLPA.js → chunk-OF2YGDUE.js} +21 -23
  85. package/node_modules/pi-lens/dist/{chunk-BLL4VYGZ.js → chunk-OHEUOWYT.js} +1 -1
  86. package/node_modules/pi-lens/dist/{chunk-PSUXESQ5.js → chunk-ORYQGVC3.js} +1 -1
  87. package/node_modules/pi-lens/dist/{chunk-FVEEEEIM.js → chunk-OVPR3GQ6.js} +4 -4
  88. package/node_modules/pi-lens/dist/{chunk-BN36MQW5.js → chunk-PCREZ4HJ.js} +20 -22
  89. package/node_modules/pi-lens/dist/{chunk-KNP4ENFT.js → chunk-PK3GDU4M.js} +1 -1
  90. package/node_modules/pi-lens/dist/{chunk-2SD2CGVH.js → chunk-PPYUBO6Y.js} +1 -1
  91. package/node_modules/pi-lens/dist/{chunk-4HNBY7S7.js → chunk-PTJXMYRY.js} +7 -9
  92. package/node_modules/pi-lens/dist/{chunk-VI3BJMZO.js → chunk-PXGVB2CY.js} +14 -18
  93. package/node_modules/pi-lens/dist/{chunk-3C6ZZAB2.js → chunk-QY6J2FTK.js} +10 -12
  94. package/node_modules/pi-lens/dist/{chunk-5RLEDUUE.js → chunk-R67WQ5RY.js} +3 -3
  95. package/node_modules/pi-lens/dist/{chunk-WMCAEP2K.js → chunk-S6ZQFPOX.js} +2 -2
  96. package/node_modules/pi-lens/dist/{chunk-LPM6NKVI.js → chunk-SF7KSXB5.js} +2 -2
  97. package/node_modules/pi-lens/dist/{chunk-ECYUBKYX.js → chunk-T6PPK3T6.js} +40 -37
  98. package/node_modules/pi-lens/dist/{chunk-RV5VX2XW.js → chunk-TM3A3K7T.js} +8 -9
  99. package/node_modules/pi-lens/dist/{chunk-AFNPNHJV.js → chunk-TOOXNL6M.js} +3 -3
  100. package/node_modules/pi-lens/dist/{chunk-BJDB7PXU.js → chunk-TS5EIWEF.js} +6 -6
  101. package/node_modules/pi-lens/dist/{chunk-UG4YLCJ5.js → chunk-VD7MQFEV.js} +21 -23
  102. package/node_modules/pi-lens/dist/{chunk-BBJXIZ3X.js → chunk-VU2PRGRI.js} +5 -34
  103. package/node_modules/pi-lens/dist/{chunk-GTNO6F6K.js → chunk-WTSQKJAR.js} +4 -4
  104. package/node_modules/pi-lens/dist/{chunk-TPMBNWHO.js → chunk-Y7XMKBFP.js} +16 -16
  105. package/node_modules/pi-lens/dist/{chunk-JSQK5DH3.js → chunk-YLHJWAQS.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-HTUG7ZFK.js → chunk-YLW26OHX.js} +3 -3
  107. package/node_modules/pi-lens/dist/{chunk-C2REOMPO.js → chunk-YTXFNCVN.js} +1 -1
  108. package/node_modules/pi-lens/dist/{chunk-F37CCZUA.js → chunk-YULIERZW.js} +8 -8
  109. package/node_modules/pi-lens/dist/{chunk-KX4DF6XX.js → chunk-Z2W5YJBW.js} +6 -6
  110. package/node_modules/pi-lens/dist/{chunk-DBAHJFBU.js → chunk-Z6WTLVUL.js} +13 -18
  111. package/node_modules/pi-lens/dist/{chunk-6K4X7IIF.js → chunk-ZWZD4TJ5.js} +23 -25
  112. package/node_modules/pi-lens/dist/index.js +1134 -618
  113. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +5 -7
  114. package/node_modules/pi-lens/dist/mcp/cli.js +25 -27
  115. package/node_modules/pi-lens/dist/mcp/server.js +101 -100
  116. package/node_modules/pi-lens/dist/mcp/worker.js +43 -45
  117. package/node_modules/pi-lens/dist/probes/installer.js +11 -11
  118. package/node_modules/pi-lens/docs/agent-tools.md +54 -12
  119. package/node_modules/pi-lens/docs/configuration.md +3 -3
  120. package/node_modules/pi-lens/docs/globalconfig.md +8 -1
  121. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +7 -0
  122. package/node_modules/pi-lens/docs/mcp.md +2 -1
  123. package/node_modules/pi-lens/docs/usage.md +1 -1
  124. package/node_modules/pi-lens/package.json +1 -1
  125. package/package.json +7 -7
  126. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WHRN26NJ.ts.map +0 -7
  127. package/node_modules/pi-lens/dist/chunk-3HZ6MNB2.js +0 -140
  128. package/node_modules/pi-lens/dist/chunk-43KD3PPM.js +0 -162
  129. package/node_modules/pi-lens/dist/chunk-CKEQFGLT.js +0 -32
@@ -0,0 +1,355 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ logExtension,
4
+ recordDegradation,
5
+ recordDegradationOnce
6
+ } from "./chunk-AGEQRJ5A.js";
7
+ import {
8
+ stagePathFor
9
+ } from "./chunk-LJDODBBZ.js";
10
+
11
+ // dist/clients/deadline-utils.js
12
+ function combineAbortSignals(...signals) {
13
+ const live = signals.filter((s) => s !== void 0);
14
+ if (live.length <= 1)
15
+ return live[0];
16
+ if (typeof AbortSignal.any === "function")
17
+ return AbortSignal.any(live);
18
+ const controller = new AbortController();
19
+ for (const s of live) {
20
+ if (s.aborted) {
21
+ controller.abort(s.reason);
22
+ break;
23
+ }
24
+ s.addEventListener("abort", () => controller.abort(s.reason), {
25
+ once: true
26
+ });
27
+ }
28
+ return controller.signal;
29
+ }
30
+ function untilAborted(work, signal, aborted) {
31
+ if (!signal)
32
+ return work;
33
+ if (signal.aborted)
34
+ return Promise.race([work, Promise.resolve(aborted)]);
35
+ let onAbort;
36
+ const abortedPromise = new Promise((resolve) => {
37
+ onAbort = () => resolve(aborted);
38
+ signal.addEventListener("abort", onAbort, { once: true });
39
+ });
40
+ return Promise.race([work, abortedPromise]).finally(() => {
41
+ if (onAbort)
42
+ signal.removeEventListener("abort", onAbort);
43
+ });
44
+ }
45
+ function withDeadline(promise, options) {
46
+ const onTimeout = options.onTimeout ?? "reject";
47
+ const onReject = options.onReject ?? "propagate";
48
+ const ms = options.ms ?? (options.deadlineAt !== void 0 ? options.deadlineAt - Date.now() : 0);
49
+ if (ms <= 0) {
50
+ promise.catch(() => {
51
+ });
52
+ return onTimeout === "undefined" ? Promise.resolve(void 0) : Promise.reject(new Error(`Timeout after ${Math.max(0, ms)}ms`));
53
+ }
54
+ const base = onReject === "undefined" ? promise.catch(() => void 0) : promise;
55
+ if (onReject === "propagate")
56
+ promise.catch(() => {
57
+ });
58
+ let timer;
59
+ const timeoutPromise = new Promise((resolve, reject) => {
60
+ timer = setTimeout(() => {
61
+ if (onTimeout === "undefined")
62
+ resolve(void 0);
63
+ else
64
+ reject(new Error(`Timeout after ${ms}ms`));
65
+ }, ms);
66
+ });
67
+ return Promise.race([base, timeoutPromise]).finally(() => {
68
+ if (timer)
69
+ clearTimeout(timer);
70
+ });
71
+ }
72
+ function withTimeout(promise, timeoutMs) {
73
+ return withDeadline(promise, { ms: timeoutMs });
74
+ }
75
+ function withBudget(promise, budgetMs) {
76
+ return withDeadline(promise, { ms: budgetMs, onTimeout: "undefined" });
77
+ }
78
+ var BOUND_ABORTED = /* @__PURE__ */ Symbol("pi-lens/bounded/aborted");
79
+ async function bounded(promise, options) {
80
+ const { signal, shutdownSignal, hook, label } = options;
81
+ const ms = Number.isFinite(options.ms) ? Math.max(0, options.ms) : 0;
82
+ const startedAt = Date.now();
83
+ const boxed = promise.then((value) => ({ value }));
84
+ void boxed.catch(() => {
85
+ });
86
+ let cause;
87
+ let timer;
88
+ let onCallerAbort;
89
+ let onShutdownAbort;
90
+ const abandoned = new Promise((resolve) => {
91
+ const fire = (reason) => {
92
+ cause ??= reason;
93
+ resolve(BOUND_ABORTED);
94
+ };
95
+ if (signal?.aborted)
96
+ return fire("caller-abort");
97
+ if (shutdownSignal?.aborted)
98
+ return fire("shutdown");
99
+ if (ms <= 0)
100
+ return fire("deadline");
101
+ timer = setTimeout(() => fire("deadline"), ms);
102
+ timer.unref?.();
103
+ onCallerAbort = () => fire("caller-abort");
104
+ signal?.addEventListener("abort", onCallerAbort, { once: true });
105
+ if (shutdownSignal) {
106
+ onShutdownAbort = () => fire("shutdown");
107
+ shutdownSignal.addEventListener("abort", onShutdownAbort, {
108
+ once: true
109
+ });
110
+ }
111
+ });
112
+ try {
113
+ const settled = await Promise.race([boxed, abandoned]);
114
+ if (settled !== BOUND_ABORTED)
115
+ return settled.value;
116
+ const elapsedMs = Date.now() - startedAt;
117
+ const fired = cause ?? "deadline";
118
+ if (fired === "deadline" || fired === "shutdown") {
119
+ recordDegradationOnce({
120
+ kind: fired === "deadline" ? "hook-await-exceeded" : "hook-await-abandoned",
121
+ subject: `${hook}:${label}`,
122
+ reason: fired === "deadline" ? `exceeded ${ms}ms budget after ${elapsedMs}ms` : `abandoned after ${elapsedMs}ms: session is shutting down (budget ${ms}ms)`,
123
+ metadata: { hook, label, budgetMs: ms, elapsedMs, cause: fired }
124
+ });
125
+ }
126
+ return void 0;
127
+ } finally {
128
+ if (timer !== void 0)
129
+ clearTimeout(timer);
130
+ if (onCallerAbort)
131
+ signal?.removeEventListener("abort", onCallerAbort);
132
+ if (onShutdownAbort) {
133
+ shutdownSignal?.removeEventListener("abort", onShutdownAbort);
134
+ }
135
+ }
136
+ }
137
+
138
+ // dist/clients/hook-budgets.js
139
+ var HOOK_WALL_BUDGET_MS = Object.freeze({
140
+ /** Visible startup work; the user is watching a progress line. */
141
+ session_start: 5e3,
142
+ /** Pure bookkeeping — nothing here may await (#2523 contract). */
143
+ turn_start: 0,
144
+ /** Measured p50 3687 ms / p90 14246 ms today. The gap IS the issue. */
145
+ turn_end: 3e3,
146
+ /** Measured p90 10043 ms today, from one unbounded pipeline re-entry. */
147
+ agent_end: 1e3,
148
+ /** The designated place for settled-time sweeps; the widest non-edit budget. */
149
+ agent_settled: 1e4,
150
+ /** Read/Grep/Glob/Bash: must never await analyzer bootstrap (AC5). */
151
+ tool_result_read_only: 500,
152
+ /** The ONLY path the contract lets block the host, and only this long. */
153
+ tool_result_edit: 1e4,
154
+ /** Replacement teardown is synchronous so its successor ordering is preserved (#3881). */
155
+ session_shutdown: 0,
156
+ /** The maintainer amendment permits quit-only sink draining before process exit (#2523). */
157
+ session_shutdown_quit: 500,
158
+ /** Synchronous message contribution; the host is blocked on the answer. */
159
+ context: 0,
160
+ /** Fork bookkeeping; the session is being replaced under it. */
161
+ session_before_fork: 0
162
+ });
163
+ var HOOK_BUDGET_KEYS = Object.keys(HOOK_WALL_BUDGET_MS);
164
+
165
+ // dist/clients/project-trust.js
166
+ var trustState = "unknown";
167
+ var installRefusalWarnings = /* @__PURE__ */ new Set();
168
+ var INSTALL_REFUSAL_WARNING_CAP = 200;
169
+ var trustGeneration = 0;
170
+ function getProjectTrustGeneration() {
171
+ return trustGeneration;
172
+ }
173
+ function latchProjectTrustState(next) {
174
+ if (next === trustState)
175
+ return;
176
+ trustState = next;
177
+ installRefusalWarnings.clear();
178
+ trustGeneration += 1;
179
+ }
180
+ function setProjectTrustState(next) {
181
+ const previous = trustState;
182
+ latchProjectTrustState(next);
183
+ if (previous !== next) {
184
+ logExtension({
185
+ subsystem: "project-trust",
186
+ level: "debug",
187
+ message: `project trust state transitioned: ${previous} -> ${next}`,
188
+ metadata: { previous, next }
189
+ });
190
+ }
191
+ }
192
+ function getProjectTrustState() {
193
+ return trustState;
194
+ }
195
+ function isToolInstallAllowedByTrust() {
196
+ return trustState !== "untrusted";
197
+ }
198
+ function assertInstallAllowed(context) {
199
+ if (isToolInstallAllowedByTrust())
200
+ return true;
201
+ recordDegradation({
202
+ kind: "trust-refusal",
203
+ subject: context,
204
+ reason: projectTrustDenialReason() ?? "project trust denied"
205
+ });
206
+ if (!installRefusalWarnings.has(context)) {
207
+ if (installRefusalWarnings.size >= INSTALL_REFUSAL_WARNING_CAP) {
208
+ installRefusalWarnings.clear();
209
+ }
210
+ installRefusalWarnings.add(context);
211
+ logExtension({
212
+ subsystem: "project-trust",
213
+ level: "warn",
214
+ message: `install/materialization blocked: ${context}`,
215
+ metadata: { context, trustState }
216
+ });
217
+ }
218
+ return false;
219
+ }
220
+ function isLspSpawnAllowedByTrust() {
221
+ return trustState !== "untrusted";
222
+ }
223
+ function projectTrustDenialReason() {
224
+ return trustState === "untrusted" ? "project is not trusted (host isProjectTrusted() === false)" : void 0;
225
+ }
226
+ var loadProjectTrustSdk;
227
+ async function readAdoptedProjectTrust(root, shutdownSignal) {
228
+ if (!loadProjectTrustSdk)
229
+ return getProjectTrustState();
230
+ try {
231
+ const sdk = await bounded(loadProjectTrustSdk(), {
232
+ ms: HOOK_WALL_BUDGET_MS.tool_result_read_only,
233
+ signal: void 0,
234
+ ...shutdownSignal ? { shutdownSignal } : {},
235
+ hook: "off_hook",
236
+ label: "adopted-project-trust-sdk"
237
+ });
238
+ if (!sdk?.ProjectTrustStore || !sdk.getAgentDir || !sdk.hasTrustRequiringProjectResources || !sdk.SettingsManager) {
239
+ throw new Error("host SDK lacks adopted project trust exports");
240
+ }
241
+ const agentDir = sdk.getAgentDir();
242
+ const saved = new sdk.ProjectTrustStore(agentDir).get(root);
243
+ const trusted = !sdk.hasTrustRequiringProjectResources(root) ? saved ?? true : saved ?? sdk.SettingsManager.create(agentDir, agentDir, {
244
+ projectTrusted: false
245
+ }).getGlobalSettings().defaultProjectTrust === "always";
246
+ return trusted ? "trusted" : "untrusted";
247
+ } catch (trustErr) {
248
+ recordDegradationOnce({
249
+ kind: "lsp-registry-decision",
250
+ subject: `adopted-trust:${root}`,
251
+ reason: `adopted project trust unavailable: ${String(trustErr)}`
252
+ });
253
+ return "untrusted";
254
+ }
255
+ }
256
+
257
+ // dist/clients/atomic-write.js
258
+ import * as fs from "node:fs";
259
+ function writeFileAtomic(targetPath, data, options) {
260
+ const bestEffort = options?.bestEffort ?? true;
261
+ const tmpPath = stagePathFor(targetPath);
262
+ try {
263
+ fs.writeFileSync(tmpPath, data, {
264
+ encoding: typeof data === "string" ? "utf-8" : void 0,
265
+ mode: options?.mode
266
+ });
267
+ fs.renameSync(tmpPath, targetPath);
268
+ } catch (err) {
269
+ try {
270
+ fs.rmSync(tmpPath, { force: true });
271
+ } catch {
272
+ }
273
+ if (!bestEffort)
274
+ throw err;
275
+ }
276
+ }
277
+ async function writeFileAtomicAsync(targetPath, data, options) {
278
+ const bestEffort = options?.bestEffort ?? true;
279
+ const tmpPath = stagePathFor(targetPath);
280
+ try {
281
+ await fs.promises.writeFile(tmpPath, data, {
282
+ encoding: typeof data === "string" ? "utf-8" : void 0,
283
+ mode: options?.mode
284
+ });
285
+ await fs.promises.rename(tmpPath, targetPath);
286
+ } catch (err) {
287
+ try {
288
+ await fs.promises.rm(tmpPath, { force: true });
289
+ } catch {
290
+ }
291
+ if (!bestEffort)
292
+ throw err;
293
+ }
294
+ }
295
+
296
+ // dist/clients/spawn-output-cap.js
297
+ var DEFAULT_MAX_OUTPUT_BYTES = 32 * 1024 * 1024;
298
+ function createBoundedOutputSink(maxBytes = DEFAULT_MAX_OUTPUT_BYTES) {
299
+ let text = "";
300
+ let retained = 0;
301
+ let truncated = false;
302
+ let observed = 0;
303
+ return {
304
+ append(chunk) {
305
+ const part = typeof chunk === "string" ? chunk : chunk.toString();
306
+ const bytes = Buffer.byteLength(part);
307
+ observed += bytes;
308
+ if (retained + bytes <= maxBytes) {
309
+ retained += bytes;
310
+ text += part;
311
+ return;
312
+ }
313
+ truncated = true;
314
+ },
315
+ get text() {
316
+ return text;
317
+ },
318
+ get truncated() {
319
+ return truncated;
320
+ },
321
+ get observedBytes() {
322
+ return observed;
323
+ }
324
+ };
325
+ }
326
+ function truncatedByOutputCap(result) {
327
+ return result.outputTruncated === true && result.failure !== "timeout" && result.failure !== "aborted";
328
+ }
329
+ function killedForOutputCap(result) {
330
+ return result.killedForOutputCap === true && result.failure !== "timeout" && result.failure !== "aborted";
331
+ }
332
+
333
+ export {
334
+ combineAbortSignals,
335
+ untilAborted,
336
+ withDeadline,
337
+ withTimeout,
338
+ withBudget,
339
+ bounded,
340
+ HOOK_WALL_BUDGET_MS,
341
+ getProjectTrustGeneration,
342
+ setProjectTrustState,
343
+ getProjectTrustState,
344
+ isToolInstallAllowedByTrust,
345
+ assertInstallAllowed,
346
+ isLspSpawnAllowedByTrust,
347
+ projectTrustDenialReason,
348
+ readAdoptedProjectTrust,
349
+ writeFileAtomic,
350
+ writeFileAtomicAsync,
351
+ DEFAULT_MAX_OUTPUT_BYTES,
352
+ createBoundedOutputSink,
353
+ truncatedByOutputCap,
354
+ killedForOutputCap
355
+ };
@@ -38,7 +38,7 @@ import {
38
38
  wordIndexKey,
39
39
  wordIndexPersistDebounceMs,
40
40
  wordIndexPostingHits
41
- } from "./chunk-LXE7JAMV.js";
41
+ } from "./chunk-6JLNZ6DP.js";
42
42
  import "./chunk-IT7MFVGP.js";
43
43
  import "./chunk-AYDE7RFV.js";
44
44
  import "./chunk-B4FAFEBP.js";
@@ -2,7 +2,7 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  DEFAULT_MAX_OUTPUT_BYTES,
4
4
  writeFileAtomic
5
- } from "./chunk-43KD3PPM.js";
5
+ } from "./chunk-HRQTYU2T.js";
6
6
  import {
7
7
  incrementDegradationCount
8
8
  } from "./chunk-AGEQRJ5A.js";
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  getProjectIgnoreMatcher,
10
10
  isExcludedDirName
11
- } from "./chunk-DNB4ZQGN.js";
11
+ } from "./chunk-ET3DSSFZ.js";
12
12
  import {
13
13
  isJstsFactFile
14
14
  } from "./chunk-SRXYSLMW.js";
@@ -2,16 +2,16 @@ import { createRequire as __pilensCreateRequire } from "node:module"; const requ
2
2
  import {
3
3
  getScratchTreeGlobPatterns,
4
4
  nestedWorktreeOffsets
5
- } from "./chunk-D5L7Q57Z.js";
5
+ } from "./chunk-AAIVSSUU.js";
6
6
  import {
7
7
  SecurityScanClient
8
- } from "./chunk-QDZ3ZZMY.js";
8
+ } from "./chunk-LD7SXICE.js";
9
9
  import {
10
10
  parseReportJson
11
- } from "./chunk-DPDA3ILA.js";
11
+ } from "./chunk-NZINZCHB.js";
12
12
  import {
13
13
  safeSpawnAsync
14
- } from "./chunk-DNB4ZQGN.js";
14
+ } from "./chunk-ET3DSSFZ.js";
15
15
  import {
16
16
  loadPiLensProjectConfig
17
17
  } from "./chunk-6EIV3H7O.js";
@@ -1,26 +1,27 @@
1
1
  import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
2
  import {
3
+ MAX_MEASURED_BYTES,
3
4
  measureFile
4
- } from "./chunk-ZD4KVFXI.js";
5
+ } from "./chunk-D2ZYRI7M.js";
6
+ import "./chunk-5W3R6LFT.js";
5
7
  import {
6
8
  isComplexityLanguageId,
7
9
  isComplexitySupportedFile,
8
10
  resolveTreeSitterLanguage,
9
11
  walk,
10
12
  withTreeSitterRoot
11
- } from "./chunk-OC4ZGVMH.js";
13
+ } from "./chunk-6GWCYEP7.js";
12
14
  import "./chunk-Z54ZSOBZ.js";
13
- import "./chunk-5YTDZ5WP.js";
15
+ import "./chunk-7M64NTAK.js";
14
16
  import "./chunk-E3PNZDPH.js";
15
17
  import "./chunk-AYDE7RFV.js";
16
- import "./chunk-3HZ6MNB2.js";
17
- import "./chunk-WBXCIRVI.js";
18
- import "./chunk-DNB4ZQGN.js";
18
+ import "./chunk-AVBEPUCD.js";
19
+ import "./chunk-ET3DSSFZ.js";
19
20
  import "./chunk-SRXYSLMW.js";
20
21
  import "./chunk-6EIV3H7O.js";
21
22
  import "./chunk-3R3Z54J7.js";
22
23
  import "./chunk-CIA7X2PZ.js";
23
- import "./chunk-43KD3PPM.js";
24
+ import "./chunk-HRQTYU2T.js";
24
25
  import {
25
26
  createSubsystemLogger
26
27
  } from "./chunk-AGEQRJ5A.js";
@@ -149,7 +150,8 @@ var ComplexityClient = class {
149
150
  }
150
151
  computeMetrics(absolutePath, content, root, languageId) {
151
152
  const { codeLines, commentLines } = countLines(content, root);
152
- const file = measureFile(root, languageId);
153
+ const keyFunctions = Buffer.byteLength(content, "utf-8") <= MAX_MEASURED_BYTES;
154
+ const file = measureFile(root, languageId, keyFunctions);
153
155
  const functions = file.functions.map((f) => ({
154
156
  name: f.name,
155
157
  line: f.line,
@@ -176,7 +178,8 @@ var ComplexityClient = class {
176
178
  aiCommentPatterns: countAICommentPatterns(content),
177
179
  singleUseFunctions: countSingleUseFunctions(functions),
178
180
  tryCatchCount: countTryCatch(root),
179
- functions
181
+ functions,
182
+ measuredFunctions: keyFunctions ? file.functions : void 0
180
183
  };
181
184
  }
182
185
  aggregateFunctionStats(functions) {
@@ -12,15 +12,15 @@ import {
12
12
  isStartupScanVerdictFresh,
13
13
  resolveStartupScanContext,
14
14
  resolveStartupScanContextAsync
15
- } from "./chunk-WMCAEP2K.js";
15
+ } from "./chunk-S6ZQFPOX.js";
16
16
  import "./chunk-IT7MFVGP.js";
17
- import "./chunk-C2REOMPO.js";
18
- import "./chunk-DNB4ZQGN.js";
17
+ import "./chunk-YTXFNCVN.js";
18
+ import "./chunk-ET3DSSFZ.js";
19
19
  import "./chunk-QYF5S6P6.js";
20
20
  import "./chunk-SRXYSLMW.js";
21
21
  import "./chunk-6EIV3H7O.js";
22
22
  import "./chunk-3R3Z54J7.js";
23
- import "./chunk-43KD3PPM.js";
23
+ import "./chunk-HRQTYU2T.js";
24
24
  import "./chunk-AGEQRJ5A.js";
25
25
  import "./chunk-S26LC76R.js";
26
26
  import "./chunk-K2GV34T2.js";
@@ -4,22 +4,22 @@ import {
4
4
  discoverManagedTool,
5
5
  getManagedToolEnvironment,
6
6
  resolveAvailableOrInstall
7
- } from "./chunk-UELHWF5I.js";
7
+ } from "./chunk-BEIPWPVR.js";
8
8
  import {
9
9
  mapWithConcurrency
10
10
  } from "./chunk-XIMYZ3JA.js";
11
11
  import {
12
12
  findNodeToolBinary
13
- } from "./chunk-FVEEEEIM.js";
13
+ } from "./chunk-OVPR3GQ6.js";
14
14
  import {
15
15
  getIsolatedNpxSpawnOptions
16
- } from "./chunk-OP5BMZKK.js";
16
+ } from "./chunk-3QMLB4TI.js";
17
17
  import {
18
18
  createAvailabilityLatch
19
- } from "./chunk-WBXCIRVI.js";
19
+ } from "./chunk-AVBEPUCD.js";
20
20
  import {
21
21
  safeSpawnAsync
22
- } from "./chunk-DNB4ZQGN.js";
22
+ } from "./chunk-ET3DSSFZ.js";
23
23
  import {
24
24
  isDeclarationFile
25
25
  } from "./chunk-6EIV3H7O.js";
@@ -4,33 +4,33 @@ import {
4
4
  } from "./chunk-7U2IDNXN.js";
5
5
  import {
6
6
  getScratchTreeFnmatchPatterns
7
- } from "./chunk-D5L7Q57Z.js";
7
+ } from "./chunk-AAIVSSUU.js";
8
8
  import {
9
9
  firstOutputLine,
10
10
  formatToolFailure,
11
11
  spawnFailedWithNoOutput
12
- } from "./chunk-LHCDWFDB.js";
12
+ } from "./chunk-FDLGJFAE.js";
13
13
  import {
14
14
  extractTomlTableSection,
15
15
  parseTomlStringArray
16
16
  } from "./chunk-SUIZOCSY.js";
17
17
  import {
18
18
  findLocalBinsAt
19
- } from "./chunk-FVEEEEIM.js";
19
+ } from "./chunk-OVPR3GQ6.js";
20
20
  import {
21
21
  probeToolAsync
22
- } from "./chunk-OP5BMZKK.js";
22
+ } from "./chunk-3QMLB4TI.js";
23
23
  import {
24
24
  classifyProbeFailure,
25
25
  createAvailabilityLatch,
26
26
  logAvailabilityDecision,
27
27
  startHostStallSampler
28
- } from "./chunk-WBXCIRVI.js";
28
+ } from "./chunk-AVBEPUCD.js";
29
29
  import {
30
30
  VENV_BIN_DIRS,
31
31
  listNestedLinkedWorktreeRoots,
32
32
  safeSpawnAsync
33
- } from "./chunk-DNB4ZQGN.js";
33
+ } from "./chunk-ET3DSSFZ.js";
34
34
  import {
35
35
  createSubsystemLogger,
36
36
  incrementDegradationCount
@@ -9,20 +9,20 @@ import {
9
9
  getDeadCodeClients,
10
10
  parseVultureOutput,
11
11
  stableFindingKey
12
- } from "./chunk-IBEYUBCM.js";
12
+ } from "./chunk-JKAVKTMY.js";
13
13
  import "./chunk-7U2IDNXN.js";
14
- import "./chunk-D5L7Q57Z.js";
15
- import "./chunk-LHCDWFDB.js";
14
+ import "./chunk-AAIVSSUU.js";
15
+ import "./chunk-FDLGJFAE.js";
16
16
  import "./chunk-SUIZOCSY.js";
17
17
  import "./chunk-W6VLB6LL.js";
18
- import "./chunk-FVEEEEIM.js";
19
- import "./chunk-OP5BMZKK.js";
20
- import "./chunk-WBXCIRVI.js";
21
- import "./chunk-DNB4ZQGN.js";
18
+ import "./chunk-OVPR3GQ6.js";
19
+ import "./chunk-3QMLB4TI.js";
20
+ import "./chunk-AVBEPUCD.js";
21
+ import "./chunk-ET3DSSFZ.js";
22
22
  import "./chunk-B4FAFEBP.js";
23
23
  import "./chunk-6EIV3H7O.js";
24
24
  import "./chunk-3R3Z54J7.js";
25
- import "./chunk-43KD3PPM.js";
25
+ import "./chunk-HRQTYU2T.js";
26
26
  import "./chunk-AGEQRJ5A.js";
27
27
  import "./chunk-S26LC76R.js";
28
28
  import "./chunk-K2GV34T2.js";
@@ -6,7 +6,7 @@ import {
6
6
  findModuleForPath,
7
7
  getDownstreamModules,
8
8
  getModuleSourceFiles
9
- } from "./chunk-6XNVY3FW.js";
9
+ } from "./chunk-HYDJUVOE.js";
10
10
  import {
11
11
  detectFileRole
12
12
  } from "./chunk-6EIV3H7O.js";
@@ -15,14 +15,14 @@ import {
15
15
  getFilterStats,
16
16
  isBuildArtifact,
17
17
  sourceTwinCandidates
18
- } from "./chunk-3NVGBFJS.js";
19
- import "./chunk-C2REOMPO.js";
20
- import "./chunk-DNB4ZQGN.js";
18
+ } from "./chunk-3PMLYGJN.js";
19
+ import "./chunk-YTXFNCVN.js";
20
+ import "./chunk-ET3DSSFZ.js";
21
21
  import "./chunk-QYF5S6P6.js";
22
22
  import "./chunk-SRXYSLMW.js";
23
23
  import "./chunk-6EIV3H7O.js";
24
24
  import "./chunk-3R3Z54J7.js";
25
- import "./chunk-43KD3PPM.js";
25
+ import "./chunk-HRQTYU2T.js";
26
26
  import "./chunk-AGEQRJ5A.js";
27
27
  import "./chunk-S26LC76R.js";
28
28
  import "./chunk-K2GV34T2.js";