lurqrun 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +23 -13
  2. package/dist/auditHandler-JCOJSUYW.js +23 -0
  3. package/dist/bin/lurq.js +3085 -17723
  4. package/dist/browserAuth-B6G27USY.js +95 -0
  5. package/dist/cache-DKI34SVS.js +12 -0
  6. package/dist/check-2FDGUOV7.js +192 -0
  7. package/dist/checkUpgrade-F2WESBPM.js +103 -0
  8. package/dist/chunk-2VMOWSRY.js +300 -0
  9. package/dist/chunk-3GHJR7XR.js +2049 -0
  10. package/dist/chunk-3N3Q3DSW.js +214 -0
  11. package/dist/chunk-4ESO33J6.js +34 -0
  12. package/dist/chunk-4F7ZESPO.js +132 -0
  13. package/dist/chunk-4KCPOMG6.js +68 -0
  14. package/dist/chunk-4ZYCIMY4.js +155 -0
  15. package/dist/chunk-63MUJNZL.js +318 -0
  16. package/dist/chunk-6AAEVQ7I.js +6336 -0
  17. package/dist/chunk-6EQ3ARXA.js +304 -0
  18. package/dist/chunk-6L3U7DZ5.js +23 -0
  19. package/dist/chunk-AHBP533R.js +220 -0
  20. package/dist/chunk-B43LCXBM.js +223 -0
  21. package/dist/chunk-BCANRN5B.js +33 -0
  22. package/dist/chunk-BUALU27S.js +123 -0
  23. package/dist/chunk-BULZAX2U.js +1554 -0
  24. package/dist/chunk-BV32UNLL.js +154 -0
  25. package/dist/chunk-C6GLE626.js +160 -0
  26. package/dist/chunk-CIDWNUAP.js +145 -0
  27. package/dist/chunk-CUP36ND3.js +2126 -0
  28. package/dist/chunk-CW5HJ3LX.js +96 -0
  29. package/dist/chunk-DB2VF5UD.js +315 -0
  30. package/dist/chunk-DWAGCNEL.js +210 -0
  31. package/dist/chunk-EA3DP5HG.js +293 -0
  32. package/dist/chunk-ELGCAM7P.js +184 -0
  33. package/dist/chunk-FW6BD2NO.js +1915 -0
  34. package/dist/chunk-GE37NVLN.js +15 -0
  35. package/dist/chunk-GPTKSNR6.js +171 -0
  36. package/dist/chunk-GRJXQBQZ.js +793 -0
  37. package/dist/chunk-HWBBVLOT.js +92 -0
  38. package/dist/chunk-I2JUKN6Z.js +24 -0
  39. package/dist/chunk-I3M2KJXB.js +56 -0
  40. package/dist/chunk-IQ4SDKKY.js +733 -0
  41. package/dist/chunk-J5FZYN4A.js +116 -0
  42. package/dist/chunk-L6N4JFW2.js +263 -0
  43. package/dist/chunk-LBFGSSF2.js +126 -0
  44. package/dist/chunk-LEGPB7DO.js +81 -0
  45. package/dist/chunk-LO35HLQZ.js +219 -0
  46. package/dist/chunk-LRD4GBYE.js +73 -0
  47. package/dist/chunk-LUAKDHLZ.js +40 -0
  48. package/dist/chunk-LYMPYETA.js +965 -0
  49. package/dist/chunk-M6NYEXCW.js +38 -0
  50. package/dist/chunk-MHUEVBVO.js +35 -0
  51. package/dist/chunk-MYGSLK44.js +37 -0
  52. package/dist/chunk-NH5I4KHH.js +201 -0
  53. package/dist/chunk-OQS4GUSI.js +1391 -0
  54. package/dist/chunk-PSX3GIAN.js +176 -0
  55. package/dist/chunk-Q5VPF4WI.js +26 -0
  56. package/dist/chunk-QKGYDMWB.js +7409 -0
  57. package/dist/chunk-QSL6QN5X.js +115 -0
  58. package/dist/chunk-SHCEBP3J.js +107 -0
  59. package/dist/chunk-SJOVFF7B.js +201 -0
  60. package/dist/chunk-ST2X2GYN.js +373 -0
  61. package/dist/chunk-TNTXWSYA.js +19 -0
  62. package/dist/chunk-U5AT3TD4.js +2128 -0
  63. package/dist/chunk-UDVNA7EA.js +483 -0
  64. package/dist/chunk-VL2E5T2A.js +109 -0
  65. package/dist/chunk-VLRHFMGJ.js +58 -0
  66. package/dist/chunk-WHX2ZFCG.js +4048 -0
  67. package/dist/chunk-WQ23REYT.js +37 -0
  68. package/dist/chunk-XBIDMHSK.js +15425 -0
  69. package/dist/chunk-Y5GI7RL3.js +66 -0
  70. package/dist/client-IRKAMDYZ.js +15 -0
  71. package/dist/commands-FIL5ET6P.js +911 -0
  72. package/dist/compat-R3UTFQ5Q.js +201 -0
  73. package/dist/dashboardIssue-WYYMBFIB.js +192 -0
  74. package/dist/diff-GZA2774U.js +13 -0
  75. package/dist/dist-4XXIXHHZ.js +12945 -0
  76. package/dist/e2b-FVPHDULZ.js +172 -0
  77. package/dist/extract-NKGKLIVT.js +444 -0
  78. package/dist/fetch-QYTUJVG2.js +22 -0
  79. package/dist/firstTouch-QQTJH4QX.js +55 -0
  80. package/dist/handlers-GEJAVZDK.js +53 -0
  81. package/dist/http-ETPYMBGD.js +5360 -0
  82. package/dist/ingestQueue-VKN4KBIF.js +35 -0
  83. package/dist/install-EK3W2COX.js +20 -0
  84. package/dist/installSkill-VQJWJVCL.js +52 -0
  85. package/dist/inventory-5AWSLJYU.js +31 -0
  86. package/dist/local-XPZMRH5R.js +13 -0
  87. package/dist/mcp-3JHD5SUZ.js +472 -0
  88. package/dist/mcpHandlers-QFN4MCFL.js +22 -0
  89. package/dist/mcpScan-QZHWENIP.js +1871 -0
  90. package/dist/mcpScanWorkflow-JPYCBGC4.js +81 -0
  91. package/dist/mcpStack-BYJCZNIV.js +20 -0
  92. package/dist/packages-THVFMWFP.js +42 -0
  93. package/dist/plan-V4OEI3J4.js +463 -0
  94. package/dist/planView-JRXGCG2N.js +79 -0
  95. package/dist/policy-3P6BGRDN.js +115 -0
  96. package/dist/references-6N7VEPHT.js +14 -0
  97. package/dist/release-4U4ABNSJ.js +128 -0
  98. package/dist/remote-YGCXYI4V.js +32 -0
  99. package/dist/reportRuns-CKQQYLY4.js +64 -0
  100. package/dist/sandbox-MEZLAODF.js +39 -0
  101. package/dist/server-KFUD5X57.js +55 -0
  102. package/dist/surface-V62GE554.js +141 -0
  103. package/dist/surface-YL6O67W3.js +36 -0
  104. package/dist/surfaceHandlers-X2IZKA3E.js +20 -0
  105. package/dist/typecheck-X7U5ELMR.js +268 -0
  106. package/dist/types-M5JP2W3D.js +10 -0
  107. package/dist/uninstall-P7RGBX6G.js +174 -0
  108. package/dist/upgrade-NQ5IWFZB.js +596 -0
  109. package/dist/upgradePlan-A4LRKLEG.js +146 -0
  110. package/dist/userConfig-Z3GQE776.js +20 -0
  111. package/dist/watch-DGFMWUDL.js +214 -0
  112. package/package.json +41 -26
  113. package/templates/agent-rules.md +4 -4
  114. package/templates/skill-instructions.md +18 -14
  115. package/dist/bin/lurq.js.map +0 -1
  116. package/dist/index.d.ts +0 -764
  117. package/dist/index.js +0 -17992
  118. package/dist/index.js.map +0 -1
  119. package/drizzle/0000_confused_fabian_cortez.sql +0 -54
  120. package/drizzle/0001_aspiring_timeslip.sql +0 -15
  121. package/drizzle/0002_lyrical_lila_cheney.sql +0 -14
  122. package/drizzle/0003_violet_giant_girl.sql +0 -14
  123. package/drizzle/0004_slim_valeria_richards.sql +0 -15
  124. package/drizzle/0005_petite_luke_cage.sql +0 -12
  125. package/drizzle/0006_calm_nighthawk.sql +0 -3
  126. package/drizzle/0007_slimy_naoko.sql +0 -1
  127. package/drizzle/0008_peaceful_tigra.sql +0 -1
  128. package/drizzle/0009_smooth_harrier.sql +0 -10
  129. package/drizzle/0010_curved_amphibian.sql +0 -2
  130. package/drizzle/0011_compat_provenance_closures.sql +0 -11
  131. package/drizzle/0012_api_surfaces.sql +0 -9
  132. package/drizzle/0013_nice_thanos.sql +0 -1
  133. package/drizzle/0014_luxuriant_malcolm_colcord.sql +0 -10
  134. package/drizzle/0015_past_fat_cobra.sql +0 -11
  135. package/drizzle/0016_futuristic_junta.sql +0 -50
  136. package/drizzle/0017_absent_grandmaster.sql +0 -20
  137. package/drizzle/0018_rainy_proemial_gods.sql +0 -1
  138. package/drizzle/0019_dashing_korvac.sql +0 -11
  139. package/drizzle/0020_normal_vulture.sql +0 -3
  140. package/drizzle/0021_dazzling_blue_shield.sql +0 -17
  141. package/drizzle/0022_massive_ghost_rider.sql +0 -24
  142. package/drizzle/0023_next_shatterstar.sql +0 -1
  143. package/drizzle/0024_dusty_maelstrom.sql +0 -15
  144. package/drizzle/0025_gifted_harpoon.sql +0 -5
  145. package/drizzle/0026_awesome_mordo.sql +0 -1
  146. package/drizzle/0027_charming_ulik.sql +0 -2
  147. package/drizzle/0028_romantic_loners.sql +0 -2
  148. package/drizzle/0029_busy_korvac.sql +0 -16
  149. package/drizzle/0030_steady_mathemanic.sql +0 -6
  150. package/drizzle/0031_redundant_maginty.sql +0 -2
  151. package/drizzle/0032_stack_resolutions.sql +0 -14
  152. package/drizzle/0033_graceful_tyger_tiger.sql +0 -3
  153. package/drizzle/0034_api_key_scopes.sql +0 -1
  154. package/drizzle/0035_policy_audit.sql +0 -21
  155. package/drizzle/meta/0000_snapshot.json +0 -370
  156. package/drizzle/meta/0001_snapshot.json +0 -482
  157. package/drizzle/meta/0002_snapshot.json +0 -575
  158. package/drizzle/meta/0003_snapshot.json +0 -667
  159. package/drizzle/meta/0004_snapshot.json +0 -769
  160. package/drizzle/meta/0005_snapshot.json +0 -864
  161. package/drizzle/meta/0006_snapshot.json +0 -882
  162. package/drizzle/meta/0007_snapshot.json +0 -876
  163. package/drizzle/meta/0008_snapshot.json +0 -882
  164. package/drizzle/meta/0009_snapshot.json +0 -948
  165. package/drizzle/meta/0010_snapshot.json +0 -969
  166. package/drizzle/meta/0011_snapshot.json +0 -1049
  167. package/drizzle/meta/0012_snapshot.json +0 -1115
  168. package/drizzle/meta/0013_snapshot.json +0 -1121
  169. package/drizzle/meta/0014_snapshot.json +0 -1190
  170. package/drizzle/meta/0015_snapshot.json +0 -1280
  171. package/drizzle/meta/0016_snapshot.json +0 -1683
  172. package/drizzle/meta/0017_snapshot.json +0 -1834
  173. package/drizzle/meta/0018_snapshot.json +0 -1834
  174. package/drizzle/meta/0019_snapshot.json +0 -1909
  175. package/drizzle/meta/0020_snapshot.json +0 -1921
  176. package/drizzle/meta/0021_snapshot.json +0 -2045
  177. package/drizzle/meta/0022_snapshot.json +0 -2246
  178. package/drizzle/meta/0023_snapshot.json +0 -2252
  179. package/drizzle/meta/0024_snapshot.json +0 -2375
  180. package/drizzle/meta/0025_snapshot.json +0 -2407
  181. package/drizzle/meta/0026_snapshot.json +0 -2413
  182. package/drizzle/meta/0027_snapshot.json +0 -2425
  183. package/drizzle/meta/0028_snapshot.json +0 -2438
  184. package/drizzle/meta/0029_snapshot.json +0 -2546
  185. package/drizzle/meta/0030_snapshot.json +0 -2586
  186. package/drizzle/meta/0031_snapshot.json +0 -2598
  187. package/drizzle/meta/0032_snapshot.json +0 -2699
  188. package/drizzle/meta/0033_snapshot.json +0 -2712
  189. package/drizzle/meta/0034_snapshot.json +0 -2719
  190. package/drizzle/meta/0035_snapshot.json +0 -2869
  191. package/drizzle/meta/_journal.json +0 -258
  192. package/src/data/seed.json +0 -253
@@ -0,0 +1,596 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ SURFACE_CLAIM_KINDS
4
+ } from "./chunk-ST2X2GYN.js";
5
+ import {
6
+ diffSurfaces,
7
+ runtimeSymbols,
8
+ starReExports
9
+ } from "./chunk-SHCEBP3J.js";
10
+ import {
11
+ readManifest,
12
+ requireTarget,
13
+ resolveEntryCandidates,
14
+ subpathWithdrawn
15
+ } from "./chunk-ELGCAM7P.js";
16
+ import {
17
+ extractUnpacked,
18
+ fetchManifest,
19
+ unpackPackage
20
+ } from "./chunk-BV32UNLL.js";
21
+ import {
22
+ resolveRuntimeEngineConflicts
23
+ } from "./chunk-BUALU27S.js";
24
+ import "./chunk-AHBP533R.js";
25
+ import "./chunk-SJOVFF7B.js";
26
+ import {
27
+ require_semver
28
+ } from "./chunk-3GHJR7XR.js";
29
+ import "./chunk-MYGSLK44.js";
30
+ import "./chunk-GPTKSNR6.js";
31
+ import {
32
+ __toESM,
33
+ init_esm_shims
34
+ } from "./chunk-I3M2KJXB.js";
35
+
36
+ // src/surface/upgrade.ts
37
+ init_esm_shims();
38
+ var import_semver2 = __toESM(require_semver(), 1);
39
+
40
+ // src/surface/requirements.ts
41
+ init_esm_shims();
42
+ var import_semver = __toESM(require_semver(), 1);
43
+ import { existsSync, readFileSync } from "fs";
44
+ import { dirname, join, resolve } from "path";
45
+ var REQUIRE_ESM_NODE = "^20.19.0 || >=22.12.0";
46
+ function readRepoRuntime(rootDir) {
47
+ const runtime = { root: rootDir };
48
+ try {
49
+ const manifest = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
50
+ if (typeof manifest.engines?.node === "string") runtime.engines = manifest.engines.node;
51
+ } catch {
52
+ }
53
+ for (const name of [".nvmrc", ".node-version"]) {
54
+ try {
55
+ const value = readFileSync(join(rootDir, name), "utf8").trim();
56
+ if (value) {
57
+ runtime.nodeVersionFile = { name, value };
58
+ break;
59
+ }
60
+ } catch {
61
+ }
62
+ }
63
+ return runtime;
64
+ }
65
+ function requireEsmGuaranteed(runtime) {
66
+ if (!runtime.engines || !import_semver.default.validRange(runtime.engines)) return false;
67
+ try {
68
+ return import_semver.default.subset(runtime.engines, REQUIRE_ESM_NODE);
69
+ } catch {
70
+ return false;
71
+ }
72
+ }
73
+ function judgeRequires(from, to, refs, ctx) {
74
+ if (from !== "cjs" || to === null || to === "cjs") return null;
75
+ const required = refs.filter((r) => r.loader === "require");
76
+ if (!required.length) return null;
77
+ const bindingFiles = new Set(required.filter((r) => r.via !== "namespace").map((r) => r.file));
78
+ const requireSites = required.filter((r) => r.via !== "namespace" || !bindingFiles.has(r.file));
79
+ const broken = /* @__PURE__ */ new Map();
80
+ const add = (file, line, why) => {
81
+ if (!broken.has(`${file}:${line}`)) broken.set(`${file}:${line}`, { file, line, why });
82
+ };
83
+ if (to === "unexported") {
84
+ for (const r of requireSites) add(r.file, r.line, "the exports map no longer offers anything to require()");
85
+ } else if (ctx.asyncModule) {
86
+ for (const r of requireSites) {
87
+ add(r.file, r.line, "the ES module uses top-level await, so require() throws ERR_REQUIRE_ASYNC_MODULE on every Node");
88
+ }
89
+ } else {
90
+ for (const r of required) {
91
+ if (r.via === "default") {
92
+ for (const c of r.calls ?? []) {
93
+ if (c.args !== null) add(r.file, c.line, "require() now returns the module namespace, which cannot be called");
94
+ }
95
+ } else if ((r.via === "namespace" || r.via === "destructured") && ctx.fromExports && ctx.toExports && !ctx.fromExports.has(r.symbol) && !ctx.toExports.has(r.symbol)) {
96
+ add(r.file, r.line, `\`${r.symbol}\` is not an export of the ES module, so it reads as undefined`);
97
+ }
98
+ }
99
+ }
100
+ const olderNode = to === "esm" && !ctx.asyncModule && !requireEsmGuaranteed(ctx.runtime) ? [...new Map(requireSites.map((r) => [`${r.file}:${r.line}`, { file: r.file, line: r.line }])).values()] : [];
101
+ if (!broken.size && !olderNode.length) return null;
102
+ return { from, to, broken: [...broken.values()], olderNode };
103
+ }
104
+ function subsetOf(inner, outer) {
105
+ try {
106
+ return import_semver.default.subset(inner, outer);
107
+ } catch {
108
+ return null;
109
+ }
110
+ }
111
+ function judgeRequirements(from, to, runtime) {
112
+ if (!to) return [];
113
+ return [...engineRequirements(from, to, runtime), ...peerRequirements(from, to, runtime)];
114
+ }
115
+ function engineRequirements(from, to, runtime) {
116
+ const needs = to.engines?.node;
117
+ const before = from?.engines?.node;
118
+ if (!needs || !import_semver.default.validRange(needs) || needs === before) return [];
119
+ const out = [];
120
+ const declared = runtime.engines;
121
+ if (declared && import_semver.default.validRange(declared) && subsetOf(declared, needs) === false) {
122
+ const alreadyOut = before && import_semver.default.validRange(before) && subsetOf(declared, before) === false;
123
+ if (!alreadyOut) out.push({ kind: "engines", name: "node", needs, has: `${declared} (package.json engines)` });
124
+ }
125
+ const pinned = runtime.nodeVersionFile;
126
+ if (pinned) {
127
+ const conflicts = (range) => Boolean(range) && resolveRuntimeEngineConflicts(
128
+ [{ name: to.name ?? "package", version: null, peerDependencies: null, peerDependenciesMeta: null, engines: { node: range } }],
129
+ pinned.value
130
+ ).length > 0;
131
+ if (conflicts(needs) && !conflicts(before)) {
132
+ out.push({ kind: "engines", name: "node", needs, has: `${pinned.value} (${pinned.name})` });
133
+ }
134
+ }
135
+ return out;
136
+ }
137
+ function peerRequirements(from, to, runtime) {
138
+ if (!runtime.root) return [];
139
+ const out = [];
140
+ for (const [peer, needs] of Object.entries(to.peerDependencies ?? {})) {
141
+ if (to.peerDependenciesMeta?.[peer]?.optional || !import_semver.default.validRange(needs)) continue;
142
+ const before = from?.peerDependencies?.[peer];
143
+ if (needs === before) continue;
144
+ const has = projectVersionOf(runtime.root, peer);
145
+ if (!has) continue;
146
+ const fits = (range) => {
147
+ try {
148
+ return has.exact ? import_semver.default.satisfies(has.version, range) : import_semver.default.intersects(has.version, range);
149
+ } catch {
150
+ return true;
151
+ }
152
+ };
153
+ if (fits(needs)) continue;
154
+ if (before && import_semver.default.validRange(before) && !fits(before)) continue;
155
+ out.push({ kind: "peer", name: peer, needs, has: `${has.version} (${has.source})` });
156
+ }
157
+ return out;
158
+ }
159
+ function projectVersionOf(root, name) {
160
+ for (let dir = resolve(root); ; dir = dirname(dir)) {
161
+ try {
162
+ const { version } = JSON.parse(readFileSync(join(dir, "node_modules", name, "package.json"), "utf8"));
163
+ if (version && import_semver.default.valid(version)) return { version, exact: true, source: "installed" };
164
+ } catch {
165
+ }
166
+ if (existsSync(join(dir, ".git")) || dirname(dir) === dir) break;
167
+ }
168
+ try {
169
+ const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
170
+ const declared = manifest.dependencies?.[name] ?? manifest.devDependencies?.[name];
171
+ if (declared && import_semver.default.validRange(declared)) return { version: declared, exact: false, source: "package.json" };
172
+ } catch {
173
+ }
174
+ return null;
175
+ }
176
+
177
+ // src/surface/upgrade.ts
178
+ var NEW_EXPORT_CAP = 40;
179
+ function groupByEntry(refs, pkg) {
180
+ const byEntry = /* @__PURE__ */ new Map();
181
+ for (const [sym, uses] of refs.symbols) {
182
+ for (const use of uses) {
183
+ if (use.specifier !== pkg && !use.specifier.startsWith(`${pkg}/`)) continue;
184
+ const sub = use.specifier === pkg ? "" : use.specifier.slice(pkg.length + 1);
185
+ let symbols = byEntry.get(sub);
186
+ if (!symbols) byEntry.set(sub, symbols = /* @__PURE__ */ new Map());
187
+ const list = symbols.get(sym);
188
+ if (list) list.push(use);
189
+ else symbols.set(sym, [use]);
190
+ }
191
+ }
192
+ return byEntry;
193
+ }
194
+ function objectPaths(surface) {
195
+ return new Set(
196
+ runtimeSymbols(surface).filter((s) => s.kind === "object").map((s) => s.path)
197
+ );
198
+ }
199
+ function isNamespaceMemberClaim(ref, fromObjects, toObjects) {
200
+ if (ref.via !== "named-member" || ref.parent === void 0) return false;
201
+ return fromObjects.has(ref.parent) && toObjects.has(ref.parent);
202
+ }
203
+ function accepts(args, required, max) {
204
+ return (required === null || args >= required) && (max === null || max === void 0 || args <= max);
205
+ }
206
+ function judgeCalls(change, refs) {
207
+ const valueRefs = refs.filter((r) => r.via !== "type-only");
208
+ if (!valueRefs.length || valueRefs.some((r) => r.calls === void 0)) return null;
209
+ const broken = [];
210
+ const unmeasured = [];
211
+ for (const r of valueRefs) {
212
+ for (const c of r.calls) {
213
+ if (c.args === null) unmeasured.push({ file: r.file, line: c.line });
214
+ else if (accepts(c.args, change.from, change.fromMax) && !accepts(c.args, change.to, change.toMax)) {
215
+ broken.push({ file: r.file, line: c.line, args: c.args });
216
+ }
217
+ }
218
+ }
219
+ return { broken, unmeasured };
220
+ }
221
+ function compareEntry(from, to, symbols, specifier, isRoot) {
222
+ if (!from || !to) return { unverified: "entry point not extracted" };
223
+ if (from.undeclaredReason || to.undeclaredReason) {
224
+ return { unverified: `no readable surface (${from.undeclaredReason ?? to.undeclaredReason})` };
225
+ }
226
+ const diff = diffSurfaces(from, to);
227
+ if (diff.inconclusive) return { unverified: diff.inconclusive };
228
+ const toSurface = new Set(runtimeSymbols(to).map((s) => s.path));
229
+ const bareValue = toSurface.size <= 1 && toSurface.has("default");
230
+ const objectExports = objectPaths(from);
231
+ const toObjects = objectPaths(to);
232
+ const throughNamespaceObject = (r) => isNamespaceMemberClaim(r, objectExports, toObjects);
233
+ const referenced = new Set(
234
+ [...symbols.entries()].filter(
235
+ ([sym, uses]) => sym !== "default" && uses.some(
236
+ (r) => SURFACE_CLAIM_KINDS.includes(r.via) && !(bareValue && r.via === "namespace") || throughNamespaceObject(r)
237
+ )
238
+ ).map(([sym]) => sym)
239
+ );
240
+ const tag = isRoot ? {} : { specifier };
241
+ const renames = new Map(diff.renamed.map((r) => [r.path, r.to]));
242
+ const symbolsRemoved = diff.removed.filter((s) => referenced.has(s.path) && !toSurface.has(s.path)).map((s) => {
243
+ const renamedTo = renames.get(s.path);
244
+ return { symbol: s.path, ...tag, ...renamedTo ? { renamedTo } : {}, refs: symbols.get(s.path) ?? [] };
245
+ });
246
+ const stars = starReExports(to);
247
+ if (symbolsRemoved.length && stars.length) {
248
+ return {
249
+ unverified: `re-exports everything from ${stars.join(", ")}, which may still export ${symbolsRemoved.map((s) => s.symbol).join(", ")}`
250
+ };
251
+ }
252
+ return {
253
+ symbolsRemoved,
254
+ arityChanged: diff.arityChanged.filter((a) => referenced.has(a.path)).flatMap((a) => {
255
+ const refs = symbols.get(a.path) ?? [];
256
+ const judged = judgeCalls(a, refs);
257
+ if (judged && !judged.broken.length && !judged.unmeasured.length) return [];
258
+ const { path, ...counts } = a;
259
+ return [
260
+ {
261
+ symbol: path,
262
+ ...tag,
263
+ ...counts,
264
+ refs,
265
+ ...judged ? { callsBroken: judged.broken, unmeasured: judged.unmeasured } : {}
266
+ }
267
+ ];
268
+ }),
269
+ // The target's whole surface, not just what it added: a rename that shipped
270
+ // the new name a major early leaves `diff.added` empty. `default` is never a
271
+ // useful candidate, and the caller drops anything it just reported removed.
272
+ candidates: runtimeSymbols(to).filter((s) => s.path !== "default").map((s) => ({ symbol: s.path, kind: s.kind, arity: s.arity })),
273
+ lostKinds: new Set(diff.removed.filter((s) => referenced.has(s.path)).map((s) => s.kind))
274
+ };
275
+ }
276
+ async function checkUpgradeOne(target, refs, opts = {}) {
277
+ if (!refs || refs.symbols.size === 0) return requirementsOnly(target, opts.runtime);
278
+ const byEntry = groupByEntry(refs, target.package);
279
+ if (byEntry.size === 0) return requirementsOnly(target, opts.runtime);
280
+ const loose = [target.fromVersion, target.toVersion].filter((v) => import_semver2.default.validRange(v) && !import_semver2.default.valid(v));
281
+ if (loose.length) {
282
+ return { unverified: `expected exact versions, got ${target.fromVersion}..${target.toVersion}` };
283
+ }
284
+ const settled = await Promise.allSettled([
285
+ unpackPackage(target.package, target.fromVersion),
286
+ unpackPackage(target.package, target.toVersion)
287
+ ]);
288
+ try {
289
+ const failure = settled.find((s) => s.status === "rejected");
290
+ if (failure) throw failure.reason;
291
+ const [fromPkg, toPkg] = settled.map((s) => s.value);
292
+ if (!fromPkg || !toPkg) {
293
+ const missing = [fromPkg ? null : target.fromVersion, toPkg ? null : target.toVersion].filter(Boolean);
294
+ return { unverified: `not published on npm: ${missing.map((v) => `${target.package}@${v}`).join(", ")}` };
295
+ }
296
+ return await compareVersions(target, refs, byEntry, fromPkg, toPkg, opts);
297
+ } finally {
298
+ await Promise.all(
299
+ settled.map((s) => s.status === "fulfilled" && s.value ? s.value.cleanup() : void 0)
300
+ );
301
+ }
302
+ }
303
+ async function requirementsOnly(target, runtime) {
304
+ if (!runtime?.root) return {};
305
+ try {
306
+ const [from, to] = await Promise.all([
307
+ fetchManifest(target.package, target.fromVersion),
308
+ fetchManifest(target.package, target.toVersion)
309
+ ]);
310
+ const requirements = judgeRequirements(from, to, runtime);
311
+ if (!requirements.length) return {};
312
+ return {
313
+ finding: {
314
+ package: target.package,
315
+ fromVersion: target.fromVersion,
316
+ toVersion: target.toVersion,
317
+ severity: "warning",
318
+ symbolsRemoved: [],
319
+ arityChanged: [],
320
+ newExports: [],
321
+ requirements
322
+ }
323
+ };
324
+ } catch {
325
+ return {};
326
+ }
327
+ }
328
+ function importingFiles(refs, pkg) {
329
+ const files = /* @__PURE__ */ new Set();
330
+ for (const uses of refs.symbols.values()) {
331
+ for (const r of uses) {
332
+ if (r.specifier === pkg || r.specifier.startsWith(`${pkg}/`)) files.add(r.file);
333
+ }
334
+ }
335
+ return [...files];
336
+ }
337
+ function runTypeCheck(typeCheck, pkg, fromDir, toDir, files) {
338
+ if (!typeCheck) return void 0;
339
+ try {
340
+ return typeCheck(pkg, fromDir, toDir, files);
341
+ } catch (err) {
342
+ return { checked: false, reason: `type check failed: ${String(err).slice(0, 160)}` };
343
+ }
344
+ }
345
+ function withdrawn(fromDir, toDir, sub) {
346
+ const fromManifest = readManifest(fromDir);
347
+ if (!fromManifest || !resolveEntryCandidates(fromDir, fromManifest, sub).length) return false;
348
+ return subpathWithdrawn(toDir, null, sub);
349
+ }
350
+ async function compareVersions(target, refs, byEntry, fromPkg, toPkg, opts) {
351
+ const subpaths = [...byEntry.keys()].filter(Boolean);
352
+ const [from, to] = await Promise.all([
353
+ extractUnpacked(target.package, fromPkg, subpaths),
354
+ extractUnpacked(target.package, toPkg, subpaths)
355
+ ]);
356
+ const types = runTypeCheck(
357
+ opts.typeCheck,
358
+ target.package,
359
+ fromPkg.pkgDir,
360
+ toPkg.pkgDir,
361
+ importingFiles(refs, target.package)
362
+ );
363
+ const symbolsRemoved = [];
364
+ const arityChanged = [];
365
+ const candidates = [];
366
+ const lostKinds = /* @__PURE__ */ new Set();
367
+ const blind = [];
368
+ const entriesRemoved = [];
369
+ for (const [sub, symbols] of byEntry) {
370
+ const specifier = sub ? `${target.package}/${sub}` : target.package;
371
+ if (sub && withdrawn(fromPkg.pkgDir, toPkg.pkgDir, sub)) {
372
+ const runtimeRefs = [...symbols.values()].flat().filter((r) => r.via !== "type-only");
373
+ if (runtimeRefs.length) {
374
+ entriesRemoved.push({ specifier, refs: runtimeRefs });
375
+ continue;
376
+ }
377
+ }
378
+ if ([...symbols.values()].flat().every((r) => r.via === "side-effect")) continue;
379
+ const res = compareEntry(
380
+ sub ? from.subpathSurfaces?.[sub] : from.surface,
381
+ sub ? to.subpathSurfaces?.[sub] : to.surface,
382
+ symbols,
383
+ specifier,
384
+ !sub
385
+ );
386
+ if ("unverified" in res) {
387
+ blind.push(byEntry.size === 1 ? res.unverified : `${specifier}: ${res.unverified}`);
388
+ continue;
389
+ }
390
+ symbolsRemoved.push(...res.symbolsRemoved);
391
+ arityChanged.push(...res.arityChanged);
392
+ candidates.push(...res.candidates);
393
+ for (const k of res.lostKinds) lostKinds.add(k);
394
+ }
395
+ const exportNames = (s) => s.undeclaredReason || starReExports(s).length ? null : new Set(s.symbols.filter((x) => x.kind !== "type_only").map((x) => x.path));
396
+ const fromTarget = requireTarget(fromPkg.pkgDir);
397
+ const toTarget = requireTarget(toPkg.pkgDir);
398
+ const asyncModule = fromTarget?.format === "cjs" && toTarget?.format === "esm" && toTarget.file ? (await import("./extract-NKGKLIVT.js")).usesTopLevelAwait(toPkg.pkgDir, toTarget.file) : false;
399
+ const moduleFormat = judgeRequires(
400
+ fromTarget?.format ?? null,
401
+ toTarget?.format ?? null,
402
+ [...byEntry.get("")?.values() ?? []].flat(),
403
+ {
404
+ fromExports: exportNames(from.surface),
405
+ toExports: exportNames(to.surface),
406
+ runtime: opts.runtime ?? {},
407
+ asyncModule
408
+ }
409
+ );
410
+ const requirements = judgeRequirements(
411
+ readManifest(fromPkg.pkgDir),
412
+ readManifest(toPkg.pkgDir),
413
+ opts.runtime ?? {}
414
+ );
415
+ const unverified = blind.length ? blind.join("; ") : void 0;
416
+ const typeErrors = types?.checked ? types.introduced : [];
417
+ const extras = { ...unverified ? { unverified } : {}, ...types ? { types } : {} };
418
+ if (!symbolsRemoved.length && !arityChanged.length && !typeErrors.length && !entriesRemoved.length && !moduleFormat && !requirements.length) {
419
+ return extras;
420
+ }
421
+ const removedNames = new Set(symbolsRemoved.map((s) => s.symbol));
422
+ const seen = /* @__PURE__ */ new Set();
423
+ const newExports = candidates.filter((c) => !removedNames.has(c.symbol) && !seen.has(c.symbol) && seen.add(c.symbol)).sort(
424
+ (a, b) => Number(lostKinds.has(b.kind)) - Number(lostKinds.has(a.kind)) || a.symbol.localeCompare(b.symbol)
425
+ ).slice(0, NEW_EXPORT_CAP);
426
+ return {
427
+ finding: {
428
+ package: target.package,
429
+ fromVersion: target.fromVersion,
430
+ toVersion: target.toVersion,
431
+ severity: symbolsRemoved.length || entriesRemoved.length || moduleFormat?.broken.length ? "blocking" : "warning",
432
+ symbolsRemoved,
433
+ arityChanged,
434
+ newExports,
435
+ ...typeErrors.length ? { typeErrors } : {},
436
+ ...entriesRemoved.length ? { entriesRemoved } : {},
437
+ ...moduleFormat ? { moduleFormat } : {},
438
+ ...requirements.length ? { requirements } : {}
439
+ },
440
+ ...extras
441
+ };
442
+ }
443
+ async function checkUpgrade(targets, references, opts = {}) {
444
+ const byPkg = new Map(references.map((r) => [r.package, r]));
445
+ const breaking = [];
446
+ const ok = [];
447
+ const unverified = [];
448
+ const types = [];
449
+ const runtime = opts.rootDir ? readRepoRuntime(opts.rootDir) : {};
450
+ for (const t of targets) {
451
+ try {
452
+ const res = await checkUpgradeOne(t, byPkg.get(t.package), { typeCheck: opts.typeCheck, runtime });
453
+ if (res.types) {
454
+ types.push(
455
+ res.types.checked ? { package: t.package, checked: true, files: res.types.files } : { package: t.package, checked: false, reason: res.types.reason }
456
+ );
457
+ }
458
+ if (res.finding) breaking.push(res.finding);
459
+ if (res.unverified) unverified.push({ package: t.package, reason: res.unverified });
460
+ if (!res.finding && !res.unverified) ok.push(t.package);
461
+ } catch (err) {
462
+ unverified.push({ package: t.package, reason: String(err).slice(0, 160) });
463
+ }
464
+ }
465
+ return {
466
+ // `safe` requires that nothing broke AND nothing was left unchecked.
467
+ safe: breaking.length === 0 && unverified.length === 0,
468
+ breaking,
469
+ ok,
470
+ unverified,
471
+ ...opts.typeCheck ? { types } : {}
472
+ };
473
+ }
474
+ var REPORT_CANDIDATE_CAP = 8;
475
+ var REPORT_LOCATION_CAP = 6;
476
+ function capped(items, cap = REPORT_LOCATION_CAP) {
477
+ const shown = items.slice(0, cap).join(", ");
478
+ return items.length > cap ? `${shown} (+${items.length - cap} more)` : shown;
479
+ }
480
+ function locations(refs) {
481
+ const all = refs.flatMap((r) => [`${r.file}:${r.line}`, ...(r.calls ?? []).map((c) => `${r.file}:${c.line}`)]);
482
+ return capped([...new Set(all)]) || "(no location)";
483
+ }
484
+ function params(required, max) {
485
+ if (max === void 0 || max === required) return `${required}`;
486
+ return max === null ? `${required}+` : `${required}\u2013${max}`;
487
+ }
488
+ function formatUpgradeReport(report, title = "upgrade check") {
489
+ const out = [`lurq, ${title}`, ""];
490
+ for (const b of report.breaking.sort((a, z) => a.severity === "blocking" ? -1 : 1)) {
491
+ const label = b.severity === "blocking" ? "BLOCKING" : "WARNING ";
492
+ out.push(`${label} ${b.package} ${b.fromVersion} \u2192 ${b.toVersion}`);
493
+ if (b.symbolsRemoved.length) {
494
+ out.push(` Removes ${b.symbolsRemoved.length} symbol(s) your code references:`);
495
+ for (const s of b.symbolsRemoved) {
496
+ const where = locations(s.refs);
497
+ const rename = s.renamedTo ? ` \u2192 ${s.renamedTo.join(" | ")}` : "";
498
+ out.push(` \xB7 ${s.specifier ?? b.package}.${s.symbol}${rename} ${where}`);
499
+ }
500
+ if (b.symbolsRemoved.some((s) => s.renamedTo)) {
501
+ out.push(` \u2192 is a proven rename: both names were the same function at ${b.fromVersion}.`);
502
+ }
503
+ }
504
+ for (const e of b.entriesRemoved ?? []) {
505
+ out.push(` Removes entry point ${e.specifier}, which your code imports:`);
506
+ out.push(` \xB7 ${locations(e.refs)}`);
507
+ }
508
+ if (b.moduleFormat) {
509
+ const m = b.moduleFormat;
510
+ out.push(
511
+ m.to === "esm" ? ` require('${b.package}') now loads an ES module (was CommonJS)` : ` require('${b.package}') no longer resolves: its exports map offers require() nothing`
512
+ );
513
+ for (const x of m.broken.slice(0, REPORT_LOCATION_CAP)) out.push(` \xB7 ${x.file}:${x.line} ${x.why}`);
514
+ if (m.broken.length > REPORT_LOCATION_CAP) out.push(` \xB7 (+${m.broken.length - REPORT_LOCATION_CAP} more)`);
515
+ if (m.olderNode.length) {
516
+ out.push(
517
+ ` \xB7 throws ERR_REQUIRE_ESM on Node before 20.19 / 22.12: ${capped(m.olderNode.map((s) => `${s.file}:${s.line}`))}`
518
+ );
519
+ }
520
+ }
521
+ for (const r of b.requirements ?? []) {
522
+ out.push(` Requires ${r.name} ${r.needs}; this project has ${r.has}`);
523
+ }
524
+ for (const a of b.arityChanged) {
525
+ out.push(
526
+ ` Arity change: ${a.specifier ?? b.package}.${a.symbol} ${params(a.from, a.fromMax)} \u2192 ${params(a.to, a.toMax)} params`
527
+ );
528
+ if (!a.callsBroken) {
529
+ out.push(` \xB7 ${locations(a.refs)}`);
530
+ continue;
531
+ }
532
+ for (const c of a.callsBroken.slice(0, REPORT_LOCATION_CAP)) {
533
+ out.push(` \xB7 ${c.file}:${c.line} passes ${c.args}`);
534
+ }
535
+ if (a.callsBroken.length > REPORT_LOCATION_CAP) {
536
+ out.push(` \xB7 (+${a.callsBroken.length - REPORT_LOCATION_CAP} more calls)`);
537
+ }
538
+ if (a.unmeasured?.length) {
539
+ out.push(
540
+ ` \xB7 not countable (spread, or passed as a value): ${capped(a.unmeasured.map((u) => `${u.file}:${u.line}`))}`
541
+ );
542
+ }
543
+ }
544
+ if (b.typeErrors?.length) {
545
+ out.push(` Type errors this upgrade introduces (${b.typeErrors.length}):`);
546
+ for (const e of b.typeErrors.slice(0, REPORT_LOCATION_CAP)) {
547
+ const message = e.message.length > 140 ? `${e.message.slice(0, 139)}\u2026` : e.message;
548
+ out.push(` \xB7 ${e.file}:${e.line} TS${e.code} ${message}`);
549
+ }
550
+ if (b.typeErrors.length > REPORT_LOCATION_CAP) {
551
+ out.push(` \xB7 (+${b.typeErrors.length - REPORT_LOCATION_CAP} more)`);
552
+ }
553
+ }
554
+ if (b.symbolsRemoved.some((s) => !s.renamedTo) && b.newExports.length) {
555
+ const shown = b.newExports.slice(0, REPORT_CANDIDATE_CAP);
556
+ const more = b.newExports.length - shown.length;
557
+ out.push(
558
+ ` New at ${b.toVersion}, candidate replacements: ${shown.map((n) => n.symbol).join(", ")}${more > 0 ? ` (+${more} more)` : ""}`
559
+ );
560
+ }
561
+ out.push("");
562
+ }
563
+ if (report.unverified.length) {
564
+ out.push(`UNVERIFIED ${report.unverified.length} package(s), not checked, NOT declared safe:`);
565
+ for (const u of report.unverified) out.push(` \xB7 ${u.package}: ${u.reason}`);
566
+ out.push("");
567
+ }
568
+ const typed = report.types ?? [];
569
+ const unchecked = typed.filter(
570
+ (t) => !t.checked
571
+ );
572
+ if (typed.length > unchecked.length) {
573
+ out.push(`TYPES checked ${typed.length - unchecked.length} package(s) in the files that import them`);
574
+ }
575
+ if (unchecked.length) {
576
+ out.push(`TYPES not checked for ${unchecked.length} package(s):`);
577
+ const byReason = /* @__PURE__ */ new Map();
578
+ for (const t of unchecked) byReason.set(t.reason, [...byReason.get(t.reason) ?? [], t.package]);
579
+ for (const [reason, names] of byReason) out.push(` \xB7 ${names.join(", ")}: ${reason}`);
580
+ }
581
+ if (typed.length) out.push("");
582
+ if (report.ok.length) {
583
+ out.push(`OK ${report.ok.length} package(s), no referenced symbols removed`);
584
+ }
585
+ if (!report.breaking.length && !report.unverified.length) {
586
+ out.push("", "No referenced symbols are removed by these upgrades.");
587
+ }
588
+ return out.join("\n");
589
+ }
590
+ export {
591
+ checkUpgrade,
592
+ checkUpgradeOne,
593
+ formatUpgradeReport,
594
+ isNamespaceMemberClaim,
595
+ judgeCalls
596
+ };