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.
- package/README.md +23 -13
- package/dist/auditHandler-JCOJSUYW.js +23 -0
- package/dist/bin/lurq.js +3085 -17723
- package/dist/browserAuth-B6G27USY.js +95 -0
- package/dist/cache-DKI34SVS.js +12 -0
- package/dist/check-2FDGUOV7.js +192 -0
- package/dist/checkUpgrade-F2WESBPM.js +103 -0
- package/dist/chunk-2VMOWSRY.js +300 -0
- package/dist/chunk-3GHJR7XR.js +2049 -0
- package/dist/chunk-3N3Q3DSW.js +214 -0
- package/dist/chunk-4ESO33J6.js +34 -0
- package/dist/chunk-4F7ZESPO.js +132 -0
- package/dist/chunk-4KCPOMG6.js +68 -0
- package/dist/chunk-4ZYCIMY4.js +155 -0
- package/dist/chunk-63MUJNZL.js +318 -0
- package/dist/chunk-6AAEVQ7I.js +6336 -0
- package/dist/chunk-6EQ3ARXA.js +304 -0
- package/dist/chunk-6L3U7DZ5.js +23 -0
- package/dist/chunk-AHBP533R.js +220 -0
- package/dist/chunk-B43LCXBM.js +223 -0
- package/dist/chunk-BCANRN5B.js +33 -0
- package/dist/chunk-BUALU27S.js +123 -0
- package/dist/chunk-BULZAX2U.js +1554 -0
- package/dist/chunk-BV32UNLL.js +154 -0
- package/dist/chunk-C6GLE626.js +160 -0
- package/dist/chunk-CIDWNUAP.js +145 -0
- package/dist/chunk-CUP36ND3.js +2126 -0
- package/dist/chunk-CW5HJ3LX.js +96 -0
- package/dist/chunk-DB2VF5UD.js +315 -0
- package/dist/chunk-DWAGCNEL.js +210 -0
- package/dist/chunk-EA3DP5HG.js +293 -0
- package/dist/chunk-ELGCAM7P.js +184 -0
- package/dist/chunk-FW6BD2NO.js +1915 -0
- package/dist/chunk-GE37NVLN.js +15 -0
- package/dist/chunk-GPTKSNR6.js +171 -0
- package/dist/chunk-GRJXQBQZ.js +793 -0
- package/dist/chunk-HWBBVLOT.js +92 -0
- package/dist/chunk-I2JUKN6Z.js +24 -0
- package/dist/chunk-I3M2KJXB.js +56 -0
- package/dist/chunk-IQ4SDKKY.js +733 -0
- package/dist/chunk-J5FZYN4A.js +116 -0
- package/dist/chunk-L6N4JFW2.js +263 -0
- package/dist/chunk-LBFGSSF2.js +126 -0
- package/dist/chunk-LEGPB7DO.js +81 -0
- package/dist/chunk-LO35HLQZ.js +219 -0
- package/dist/chunk-LRD4GBYE.js +73 -0
- package/dist/chunk-LUAKDHLZ.js +40 -0
- package/dist/chunk-LYMPYETA.js +965 -0
- package/dist/chunk-M6NYEXCW.js +38 -0
- package/dist/chunk-MHUEVBVO.js +35 -0
- package/dist/chunk-MYGSLK44.js +37 -0
- package/dist/chunk-NH5I4KHH.js +201 -0
- package/dist/chunk-OQS4GUSI.js +1391 -0
- package/dist/chunk-PSX3GIAN.js +176 -0
- package/dist/chunk-Q5VPF4WI.js +26 -0
- package/dist/chunk-QKGYDMWB.js +7409 -0
- package/dist/chunk-QSL6QN5X.js +115 -0
- package/dist/chunk-SHCEBP3J.js +107 -0
- package/dist/chunk-SJOVFF7B.js +201 -0
- package/dist/chunk-ST2X2GYN.js +373 -0
- package/dist/chunk-TNTXWSYA.js +19 -0
- package/dist/chunk-U5AT3TD4.js +2128 -0
- package/dist/chunk-UDVNA7EA.js +483 -0
- package/dist/chunk-VL2E5T2A.js +109 -0
- package/dist/chunk-VLRHFMGJ.js +58 -0
- package/dist/chunk-WHX2ZFCG.js +4048 -0
- package/dist/chunk-WQ23REYT.js +37 -0
- package/dist/chunk-XBIDMHSK.js +15425 -0
- package/dist/chunk-Y5GI7RL3.js +66 -0
- package/dist/client-IRKAMDYZ.js +15 -0
- package/dist/commands-FIL5ET6P.js +911 -0
- package/dist/compat-R3UTFQ5Q.js +201 -0
- package/dist/dashboardIssue-WYYMBFIB.js +192 -0
- package/dist/diff-GZA2774U.js +13 -0
- package/dist/dist-4XXIXHHZ.js +12945 -0
- package/dist/e2b-FVPHDULZ.js +172 -0
- package/dist/extract-NKGKLIVT.js +444 -0
- package/dist/fetch-QYTUJVG2.js +22 -0
- package/dist/firstTouch-QQTJH4QX.js +55 -0
- package/dist/handlers-GEJAVZDK.js +53 -0
- package/dist/http-ETPYMBGD.js +5360 -0
- package/dist/ingestQueue-VKN4KBIF.js +35 -0
- package/dist/install-EK3W2COX.js +20 -0
- package/dist/installSkill-VQJWJVCL.js +52 -0
- package/dist/inventory-5AWSLJYU.js +31 -0
- package/dist/local-XPZMRH5R.js +13 -0
- package/dist/mcp-3JHD5SUZ.js +472 -0
- package/dist/mcpHandlers-QFN4MCFL.js +22 -0
- package/dist/mcpScan-QZHWENIP.js +1871 -0
- package/dist/mcpScanWorkflow-JPYCBGC4.js +81 -0
- package/dist/mcpStack-BYJCZNIV.js +20 -0
- package/dist/packages-THVFMWFP.js +42 -0
- package/dist/plan-V4OEI3J4.js +463 -0
- package/dist/planView-JRXGCG2N.js +79 -0
- package/dist/policy-3P6BGRDN.js +115 -0
- package/dist/references-6N7VEPHT.js +14 -0
- package/dist/release-4U4ABNSJ.js +128 -0
- package/dist/remote-YGCXYI4V.js +32 -0
- package/dist/reportRuns-CKQQYLY4.js +64 -0
- package/dist/sandbox-MEZLAODF.js +39 -0
- package/dist/server-KFUD5X57.js +55 -0
- package/dist/surface-V62GE554.js +141 -0
- package/dist/surface-YL6O67W3.js +36 -0
- package/dist/surfaceHandlers-X2IZKA3E.js +20 -0
- package/dist/typecheck-X7U5ELMR.js +268 -0
- package/dist/types-M5JP2W3D.js +10 -0
- package/dist/uninstall-P7RGBX6G.js +174 -0
- package/dist/upgrade-NQ5IWFZB.js +596 -0
- package/dist/upgradePlan-A4LRKLEG.js +146 -0
- package/dist/userConfig-Z3GQE776.js +20 -0
- package/dist/watch-DGFMWUDL.js +214 -0
- package/package.json +41 -26
- package/templates/agent-rules.md +4 -4
- package/templates/skill-instructions.md +18 -14
- package/dist/bin/lurq.js.map +0 -1
- package/dist/index.d.ts +0 -764
- package/dist/index.js +0 -17992
- package/dist/index.js.map +0 -1
- package/drizzle/0000_confused_fabian_cortez.sql +0 -54
- package/drizzle/0001_aspiring_timeslip.sql +0 -15
- package/drizzle/0002_lyrical_lila_cheney.sql +0 -14
- package/drizzle/0003_violet_giant_girl.sql +0 -14
- package/drizzle/0004_slim_valeria_richards.sql +0 -15
- package/drizzle/0005_petite_luke_cage.sql +0 -12
- package/drizzle/0006_calm_nighthawk.sql +0 -3
- package/drizzle/0007_slimy_naoko.sql +0 -1
- package/drizzle/0008_peaceful_tigra.sql +0 -1
- package/drizzle/0009_smooth_harrier.sql +0 -10
- package/drizzle/0010_curved_amphibian.sql +0 -2
- package/drizzle/0011_compat_provenance_closures.sql +0 -11
- package/drizzle/0012_api_surfaces.sql +0 -9
- package/drizzle/0013_nice_thanos.sql +0 -1
- package/drizzle/0014_luxuriant_malcolm_colcord.sql +0 -10
- package/drizzle/0015_past_fat_cobra.sql +0 -11
- package/drizzle/0016_futuristic_junta.sql +0 -50
- package/drizzle/0017_absent_grandmaster.sql +0 -20
- package/drizzle/0018_rainy_proemial_gods.sql +0 -1
- package/drizzle/0019_dashing_korvac.sql +0 -11
- package/drizzle/0020_normal_vulture.sql +0 -3
- package/drizzle/0021_dazzling_blue_shield.sql +0 -17
- package/drizzle/0022_massive_ghost_rider.sql +0 -24
- package/drizzle/0023_next_shatterstar.sql +0 -1
- package/drizzle/0024_dusty_maelstrom.sql +0 -15
- package/drizzle/0025_gifted_harpoon.sql +0 -5
- package/drizzle/0026_awesome_mordo.sql +0 -1
- package/drizzle/0027_charming_ulik.sql +0 -2
- package/drizzle/0028_romantic_loners.sql +0 -2
- package/drizzle/0029_busy_korvac.sql +0 -16
- package/drizzle/0030_steady_mathemanic.sql +0 -6
- package/drizzle/0031_redundant_maginty.sql +0 -2
- package/drizzle/0032_stack_resolutions.sql +0 -14
- package/drizzle/0033_graceful_tyger_tiger.sql +0 -3
- package/drizzle/0034_api_key_scopes.sql +0 -1
- package/drizzle/0035_policy_audit.sql +0 -21
- package/drizzle/meta/0000_snapshot.json +0 -370
- package/drizzle/meta/0001_snapshot.json +0 -482
- package/drizzle/meta/0002_snapshot.json +0 -575
- package/drizzle/meta/0003_snapshot.json +0 -667
- package/drizzle/meta/0004_snapshot.json +0 -769
- package/drizzle/meta/0005_snapshot.json +0 -864
- package/drizzle/meta/0006_snapshot.json +0 -882
- package/drizzle/meta/0007_snapshot.json +0 -876
- package/drizzle/meta/0008_snapshot.json +0 -882
- package/drizzle/meta/0009_snapshot.json +0 -948
- package/drizzle/meta/0010_snapshot.json +0 -969
- package/drizzle/meta/0011_snapshot.json +0 -1049
- package/drizzle/meta/0012_snapshot.json +0 -1115
- package/drizzle/meta/0013_snapshot.json +0 -1121
- package/drizzle/meta/0014_snapshot.json +0 -1190
- package/drizzle/meta/0015_snapshot.json +0 -1280
- package/drizzle/meta/0016_snapshot.json +0 -1683
- package/drizzle/meta/0017_snapshot.json +0 -1834
- package/drizzle/meta/0018_snapshot.json +0 -1834
- package/drizzle/meta/0019_snapshot.json +0 -1909
- package/drizzle/meta/0020_snapshot.json +0 -1921
- package/drizzle/meta/0021_snapshot.json +0 -2045
- package/drizzle/meta/0022_snapshot.json +0 -2246
- package/drizzle/meta/0023_snapshot.json +0 -2252
- package/drizzle/meta/0024_snapshot.json +0 -2375
- package/drizzle/meta/0025_snapshot.json +0 -2407
- package/drizzle/meta/0026_snapshot.json +0 -2413
- package/drizzle/meta/0027_snapshot.json +0 -2425
- package/drizzle/meta/0028_snapshot.json +0 -2438
- package/drizzle/meta/0029_snapshot.json +0 -2546
- package/drizzle/meta/0030_snapshot.json +0 -2586
- package/drizzle/meta/0031_snapshot.json +0 -2598
- package/drizzle/meta/0032_snapshot.json +0 -2699
- package/drizzle/meta/0033_snapshot.json +0 -2712
- package/drizzle/meta/0034_snapshot.json +0 -2719
- package/drizzle/meta/0035_snapshot.json +0 -2869
- package/drizzle/meta/_journal.json +0 -258
- package/src/data/seed.json +0 -253
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
MissingKeyError
|
|
4
|
+
} from "./chunk-4ZYCIMY4.js";
|
|
5
|
+
import {
|
|
6
|
+
openInBrowser
|
|
7
|
+
} from "./chunk-TNTXWSYA.js";
|
|
8
|
+
import {
|
|
9
|
+
bold,
|
|
10
|
+
dim,
|
|
11
|
+
green,
|
|
12
|
+
yellow
|
|
13
|
+
} from "./chunk-4KCPOMG6.js";
|
|
14
|
+
import {
|
|
15
|
+
agentSpecs,
|
|
16
|
+
installAgent,
|
|
17
|
+
installInstructionsFile,
|
|
18
|
+
lurqInvocation,
|
|
19
|
+
printInstallReport,
|
|
20
|
+
resolveAgents
|
|
21
|
+
} from "./chunk-UDVNA7EA.js";
|
|
22
|
+
import {
|
|
23
|
+
readUserConfig,
|
|
24
|
+
resolveApiKey,
|
|
25
|
+
resolveEndpoint,
|
|
26
|
+
writeUserConfig
|
|
27
|
+
} from "./chunk-Y5GI7RL3.js";
|
|
28
|
+
import {
|
|
29
|
+
DEFAULT_ENDPOINT,
|
|
30
|
+
KEYS_URL,
|
|
31
|
+
PACKAGE_NAME
|
|
32
|
+
} from "./chunk-GPTKSNR6.js";
|
|
33
|
+
import {
|
|
34
|
+
init_esm_shims
|
|
35
|
+
} from "./chunk-I3M2KJXB.js";
|
|
36
|
+
|
|
37
|
+
// src/cli/install.ts
|
|
38
|
+
init_esm_shims();
|
|
39
|
+
import { spawnSync } from "child_process";
|
|
40
|
+
async function withSetupOnMissingKey(run, ask = askToConnect, setup = () => runSetup({})) {
|
|
41
|
+
try {
|
|
42
|
+
await run();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (!(err instanceof MissingKeyError) || !await ask()) throw err;
|
|
45
|
+
await setup();
|
|
46
|
+
await run();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function askToConnect() {
|
|
50
|
+
const interactive = process.stdin.isTTY && process.stdout.isTTY && !process.env.CI && !process.argv.includes("--json");
|
|
51
|
+
if (!interactive) return false;
|
|
52
|
+
const { confirm } = await import("./dist-4XXIXHHZ.js");
|
|
53
|
+
return confirm({ message: "This machine has no lurq API key yet. Connect it now?", default: true });
|
|
54
|
+
}
|
|
55
|
+
async function validateKey(url, apiKey) {
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetch(url, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
Accept: "application/json, text/event-stream",
|
|
62
|
+
Authorization: `Bearer ${apiKey}`
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" }),
|
|
65
|
+
// A black-holed endpoint must not hang setup; it reads as unreachable.
|
|
66
|
+
signal: AbortSignal.timeout(15e3)
|
|
67
|
+
});
|
|
68
|
+
if (res.ok) return "valid";
|
|
69
|
+
if (res.status === 401 || res.status === 403) return "invalid";
|
|
70
|
+
return "unreachable";
|
|
71
|
+
} catch {
|
|
72
|
+
return "unreachable";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function runningFromNpx(moduleUrl = import.meta.url) {
|
|
76
|
+
return moduleUrl.includes("/_npx/");
|
|
77
|
+
}
|
|
78
|
+
function installGlobally() {
|
|
79
|
+
process.stdout.write(` Installing ${PACKAGE_NAME} globally (npm install -g, a few seconds)\u2026 `);
|
|
80
|
+
const res = spawnSync("npm", ["install", "--global", `${PACKAGE_NAME}@latest`], {
|
|
81
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
82
|
+
encoding: "utf8",
|
|
83
|
+
// npm is a .cmd shim on Windows, which is not directly executable.
|
|
84
|
+
shell: process.platform === "win32"
|
|
85
|
+
});
|
|
86
|
+
if (res.status === 0) {
|
|
87
|
+
console.log(green("ok"));
|
|
88
|
+
console.log(dim(" `lurq` now works in any terminal, no npx needed."));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
console.log(yellow("skipped"));
|
|
92
|
+
const reason = (res.stderr || res.error?.message || "").trim().split("\n").pop();
|
|
93
|
+
if (reason) console.log(dim(` ${reason}`));
|
|
94
|
+
console.log(dim(` Setup continues. Run \`npm install -g ${PACKAGE_NAME}\` later if you want it.`));
|
|
95
|
+
}
|
|
96
|
+
async function runSetup(opts) {
|
|
97
|
+
const interactive = !opts.yes;
|
|
98
|
+
if (interactive && !(process.stdin.isTTY && process.stdout.isTTY)) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`lurq setup asks questions, and this is not an interactive terminal (CI, a pipe, or an agent shell).
|
|
101
|
+
Run it non-interactively: npx ${PACKAGE_NAME} setup --yes --api-key <key>
|
|
102
|
+
Get a key at ${KEYS_URL}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const url = resolveEndpoint(opts.url) ?? DEFAULT_ENDPOINT;
|
|
106
|
+
let apiKey = resolveApiKey(opts.apiKey);
|
|
107
|
+
const selfHosted = url !== DEFAULT_ENDPOINT;
|
|
108
|
+
if (interactive) {
|
|
109
|
+
const { input, checkbox, confirm, select } = await import("./dist-4XXIXHHZ.js");
|
|
110
|
+
console.log(`
|
|
111
|
+
${bold("lurq setup")}: connect this machine to the package index.
|
|
112
|
+
`);
|
|
113
|
+
console.log(` Endpoint: ${url}${selfHosted ? dim(" (your own server)") : ""}
|
|
114
|
+
`);
|
|
115
|
+
if (runningFromNpx()) {
|
|
116
|
+
const goGlobal = await confirm({
|
|
117
|
+
message: `Install ${PACKAGE_NAME} globally, so \`lurq\` works without npx?`,
|
|
118
|
+
default: true
|
|
119
|
+
});
|
|
120
|
+
if (goGlobal) installGlobally();
|
|
121
|
+
console.log("");
|
|
122
|
+
}
|
|
123
|
+
if (apiKey && !opts.apiKey) {
|
|
124
|
+
const stored = readUserConfig().apiKey === apiKey;
|
|
125
|
+
const reuse = await confirm({
|
|
126
|
+
message: `Use the API key already configured${stored ? " on this machine" : " in your environment"}?`,
|
|
127
|
+
default: true
|
|
128
|
+
});
|
|
129
|
+
if (!reuse) apiKey = void 0;
|
|
130
|
+
}
|
|
131
|
+
if (!apiKey && !selfHosted) {
|
|
132
|
+
const { keyViaBrowser } = await import("./browserAuth-B6G27USY.js");
|
|
133
|
+
console.log(" Sign in and this machine gets its key. Nothing to copy.\n");
|
|
134
|
+
process.stdout.write(" Waiting for the browser\u2026 ");
|
|
135
|
+
const skip = new AbortController();
|
|
136
|
+
const onEnter = () => skip.abort();
|
|
137
|
+
process.stdin.once("data", onEnter);
|
|
138
|
+
const handoff = await keyViaBrowser({
|
|
139
|
+
noOpen: opts.noOpen,
|
|
140
|
+
signal: skip.signal,
|
|
141
|
+
// Printed rather than only opened: the browser may not have launched,
|
|
142
|
+
// and a spinner pointing at a URL nobody can see is a hung flow.
|
|
143
|
+
onUrl: (link) => console.log(`
|
|
144
|
+
|
|
145
|
+
${dim(link)}
|
|
146
|
+
${dim("Press Enter to paste a key instead.")}
|
|
147
|
+
`)
|
|
148
|
+
});
|
|
149
|
+
process.stdin.off("data", onEnter);
|
|
150
|
+
process.stdin.pause();
|
|
151
|
+
if (handoff) {
|
|
152
|
+
apiKey = handoff.key;
|
|
153
|
+
console.log(green(` \u2713 key received${handoff.label ? dim(` (${handoff.label})`) : ""}
|
|
154
|
+
`));
|
|
155
|
+
} else {
|
|
156
|
+
console.log(yellow(skip.signal.aborted ? " skipped" : " no response"));
|
|
157
|
+
console.log(dim(" Falling back to pasting it in.\n"));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (!apiKey) {
|
|
161
|
+
if (selfHosted) {
|
|
162
|
+
console.log(` Issue a key on the machine running ${url}:
|
|
163
|
+
`);
|
|
164
|
+
console.log(` ${bold("lurq keys create --label my-laptop")}
|
|
165
|
+
`);
|
|
166
|
+
console.log(" Then paste it below.\n");
|
|
167
|
+
} else {
|
|
168
|
+
if (!opts.noOpen) {
|
|
169
|
+
console.log(` Opening ${KEYS_URL}
|
|
170
|
+
`);
|
|
171
|
+
openInBrowser(KEYS_URL);
|
|
172
|
+
} else {
|
|
173
|
+
console.log(` Open ${KEYS_URL}
|
|
174
|
+
`);
|
|
175
|
+
}
|
|
176
|
+
console.log(" 1. Sign in, or create an account. It takes a moment.");
|
|
177
|
+
console.log(" 2. Create an API key and copy it.");
|
|
178
|
+
console.log(" 3. Paste it below.\n");
|
|
179
|
+
}
|
|
180
|
+
apiKey = (await input({
|
|
181
|
+
message: "Paste your lurq API key",
|
|
182
|
+
validate: (v) => v.trim().startsWith("lurq_") ? true : "Keys look like lurq_live_\u2026 "
|
|
183
|
+
})).trim();
|
|
184
|
+
}
|
|
185
|
+
process.stdout.write(" Validating key\u2026 ");
|
|
186
|
+
const check2 = await validateKey(url, apiKey);
|
|
187
|
+
console.log(
|
|
188
|
+
check2 === "valid" ? green("ok") : check2 === "invalid" ? yellow("rejected") : yellow("could not reach endpoint")
|
|
189
|
+
);
|
|
190
|
+
if (check2 !== "valid") {
|
|
191
|
+
const proceed = await confirm({
|
|
192
|
+
message: check2 === "invalid" ? `That key was rejected (401) by ${url}. Continue anyway?` : `Couldn't reach ${url} to validate the key. Continue anyway?`,
|
|
193
|
+
default: false
|
|
194
|
+
});
|
|
195
|
+
if (!proceed) {
|
|
196
|
+
console.log("Aborted. No config was changed.");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (opts.agent) {
|
|
201
|
+
await finish(resolveAgents(opts.agent), { url, apiKey });
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const specs = agentSpecs();
|
|
205
|
+
const detected = specs.filter((s) => s.detected);
|
|
206
|
+
const primary = detected.find((s) => s.id === "claude-code") ?? detected[0];
|
|
207
|
+
if (primary) {
|
|
208
|
+
const others = detected.length - 1;
|
|
209
|
+
const choice = await select({
|
|
210
|
+
message: others > 0 ? `Looks like you have ${detected.map((s) => s.label).join(", ")}. Connect lurq to them?` : `Looks like you have ${primary.label}. Connect lurq to it?`,
|
|
211
|
+
default: "yes",
|
|
212
|
+
choices: [
|
|
213
|
+
{
|
|
214
|
+
name: others > 0 ? `Yes, set up all ${detected.length} detected agents` : `Yes, set up ${primary.label} for me`,
|
|
215
|
+
value: "yes"
|
|
216
|
+
},
|
|
217
|
+
{ name: "No, let me choose which agent(s)", value: "other" },
|
|
218
|
+
{ name: "Cancel, change nothing", value: "cancel" }
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
if (choice === "cancel") {
|
|
222
|
+
console.log("No problem. Nothing was changed; run `lurq setup` again anytime.");
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (choice === "yes") {
|
|
226
|
+
await finish(detected, { url, apiKey });
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const ids = await checkbox({
|
|
231
|
+
message: "Which assistant(s) should I configure?",
|
|
232
|
+
choices: specs.map((s) => ({
|
|
233
|
+
name: `${s.label}${s.detected ? " (detected)" : ""}`,
|
|
234
|
+
value: s.id,
|
|
235
|
+
checked: s.detected
|
|
236
|
+
}))
|
|
237
|
+
});
|
|
238
|
+
await finish(specs.filter((s) => ids.includes(s.id)), { url, apiKey });
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!apiKey) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`No API key. Pass --api-key <key> or set LURQ_API_KEY (or drop --yes to be prompted). Get a key at ${KEYS_URL}`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
const check = await validateKey(url, apiKey);
|
|
247
|
+
if (check === "invalid") {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`${url} rejected that API key (401). Nothing was written. ` + (selfHosted ? `Issue one on the server with \`lurq keys create\`.` : `Check it, or create a new one at ${KEYS_URL}`)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (check === "unreachable") {
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Could not reach ${url} to validate the API key. Nothing was written. Check the URL and your connection, then re-run.`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const selected = opts.agent ? resolveAgents(opts.agent) : agentSpecs().filter((s) => s.detected);
|
|
258
|
+
await finish(selected, { url, apiKey });
|
|
259
|
+
}
|
|
260
|
+
async function finish(selected, remote) {
|
|
261
|
+
const configPath = writeUserConfig({
|
|
262
|
+
apiKey: remote.apiKey,
|
|
263
|
+
// Only persist a non-default endpoint. Storing the default would pin this
|
|
264
|
+
// machine to today's URL and quietly ignore a later change to the built-in.
|
|
265
|
+
endpoint: remote.url === DEFAULT_ENDPOINT ? void 0 : remote.url
|
|
266
|
+
});
|
|
267
|
+
console.log(`
|
|
268
|
+
${green("\u2713")} API key saved to ${configPath} ${dim("(mode 0600)")}`);
|
|
269
|
+
console.log(
|
|
270
|
+
`${green("\u2713")} Pointed at ${remote.url}${remote.url === DEFAULT_ENDPOINT ? "" : dim(" (your own server)")}`
|
|
271
|
+
);
|
|
272
|
+
const { command } = lurqInvocation();
|
|
273
|
+
console.log(
|
|
274
|
+
dim(` \`${command} verify <package>\`, \`evaluate\`, \`compare\`, \`usage\` now work anywhere.`)
|
|
275
|
+
);
|
|
276
|
+
if (selected.length === 0) {
|
|
277
|
+
console.log(
|
|
278
|
+
"\nNo agents selected or detected. Re-run `lurq setup --agent <id>` once your assistant is installed."
|
|
279
|
+
);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const mode = { kind: "remote", ...remote };
|
|
283
|
+
const results = selected.map((s) => installAgent(s, mode));
|
|
284
|
+
const instructionsPath = installInstructionsFile();
|
|
285
|
+
console.log("");
|
|
286
|
+
printInstallReport(results, instructionsPath, mode);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export {
|
|
290
|
+
withSetupOnMissingKey,
|
|
291
|
+
runningFromNpx,
|
|
292
|
+
runSetup
|
|
293
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_esm_shims
|
|
4
|
+
} from "./chunk-I3M2KJXB.js";
|
|
5
|
+
|
|
6
|
+
// src/surface/resolve.ts
|
|
7
|
+
init_esm_shims();
|
|
8
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
9
|
+
import { dirname, join, resolve as resolvePath, sep } from "path";
|
|
10
|
+
var EXTENSIONS = [".js", ".cjs", ".mjs", ".json"];
|
|
11
|
+
function readManifest(pkgDir) {
|
|
12
|
+
const p = join(pkgDir, "package.json");
|
|
13
|
+
if (!existsSync(p)) return null;
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(readFileSync(p, "utf8"));
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var CONDITIONS = ["require", "node", "default", "import", "module"];
|
|
21
|
+
function isSubpathMap(o) {
|
|
22
|
+
return Object.keys(o).some((k) => k.startsWith("."));
|
|
23
|
+
}
|
|
24
|
+
function matchWildcard(pattern, key) {
|
|
25
|
+
const star = pattern.indexOf("*");
|
|
26
|
+
if (star === -1) return null;
|
|
27
|
+
const pre = pattern.slice(0, star);
|
|
28
|
+
const post = pattern.slice(star + 1);
|
|
29
|
+
if (key.length < pre.length + post.length) return null;
|
|
30
|
+
if (!key.startsWith(pre) || !key.endsWith(post)) return null;
|
|
31
|
+
return key.slice(pre.length, key.length - post.length);
|
|
32
|
+
}
|
|
33
|
+
function pickAllFromExports(exp, key = ".", depth = 0) {
|
|
34
|
+
if (depth > 8) return [];
|
|
35
|
+
if (typeof exp === "string") return key === "." ? [exp] : [];
|
|
36
|
+
if (Array.isArray(exp)) return exp.flatMap((e) => pickAllFromExports(e, key, depth + 1));
|
|
37
|
+
if (!exp || typeof exp !== "object") return [];
|
|
38
|
+
const o = exp;
|
|
39
|
+
if (isSubpathMap(o)) {
|
|
40
|
+
if (key in o) return pickAllFromExports(o[key], ".", depth + 1);
|
|
41
|
+
const patterns = Object.keys(o).filter((k) => k.includes("*")).sort((a, b) => b.length - a.length);
|
|
42
|
+
for (const p of patterns) {
|
|
43
|
+
const capture = matchWildcard(p, key);
|
|
44
|
+
if (capture === null) continue;
|
|
45
|
+
const targets = pickAllFromExports(o[p], ".", depth + 1);
|
|
46
|
+
if (targets.length) return targets.map((t) => t.split("*").join(capture));
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return CONDITIONS.filter((c) => c in o).flatMap((c) => pickAllFromExports(o[c], key, depth + 1));
|
|
51
|
+
}
|
|
52
|
+
function resolveFile(candidate, depth = 0) {
|
|
53
|
+
if (existsSync(candidate)) {
|
|
54
|
+
try {
|
|
55
|
+
if (statSync(candidate).isFile()) return candidate;
|
|
56
|
+
const main = depth < 4 ? readManifest(candidate)?.main : void 0;
|
|
57
|
+
if (main) {
|
|
58
|
+
const hit = resolveFile(resolvePath(candidate, main), depth + 1);
|
|
59
|
+
if (hit) return hit;
|
|
60
|
+
}
|
|
61
|
+
for (const ext of EXTENSIONS) {
|
|
62
|
+
const idx = join(candidate, `index${ext}`);
|
|
63
|
+
if (existsSync(idx) && statSync(idx).isFile()) return idx;
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const ext of EXTENSIONS) {
|
|
70
|
+
const withExt = `${candidate}${ext}`;
|
|
71
|
+
if (existsSync(withExt)) return withExt;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function resolveEntryCandidates(pkgDir, manifest, subpath) {
|
|
76
|
+
const m = manifest ?? readManifest(pkgDir);
|
|
77
|
+
if (!m) return [];
|
|
78
|
+
const sub = subpath?.replace(/^\.?\//, "").replace(/\/$/, "");
|
|
79
|
+
const specifiers = (sub ? (
|
|
80
|
+
// An `exports` map is a hard boundary in Node: a subpath it does not
|
|
81
|
+
// list cannot be imported, so guessing at a file would invent a surface
|
|
82
|
+
// the runtime refuses to load. The bare path is offered only for the
|
|
83
|
+
// legacy main/index layout, where any real file is genuinely reachable.
|
|
84
|
+
m.exports !== void 0 ? pickAllFromExports(m.exports, `./${sub}`) : [`./${sub}`]
|
|
85
|
+
) : [
|
|
86
|
+
...m.exports !== void 0 ? pickAllFromExports(m.exports) : [],
|
|
87
|
+
m.main ?? null,
|
|
88
|
+
m.module ?? null,
|
|
89
|
+
"./index.js"
|
|
90
|
+
]).filter((c) => typeof c === "string" && c.length > 0);
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const c of specifiers) {
|
|
93
|
+
const hit = resolveFile(resolvePath(pkgDir, c));
|
|
94
|
+
if (hit && !out.includes(hit)) out.push(hit);
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
function resolvesInsidePackage(spec) {
|
|
99
|
+
return spec.startsWith("./") || spec.startsWith("../") || spec === "." || spec === "..";
|
|
100
|
+
}
|
|
101
|
+
function resolveInternal(fromFile, spec, pkgDir) {
|
|
102
|
+
const target = resolvePath(dirname(fromFile), spec);
|
|
103
|
+
const root = resolvePath(pkgDir);
|
|
104
|
+
if (target !== root && !target.startsWith(root + sep)) return null;
|
|
105
|
+
return resolveFile(target);
|
|
106
|
+
}
|
|
107
|
+
var REQUIRE_CONDITIONS = /* @__PURE__ */ new Set(["require", "module-sync", "node", "node-addons", "default"]);
|
|
108
|
+
function requireTarget(pkgDir, manifest) {
|
|
109
|
+
const m = manifest ?? readManifest(pkgDir);
|
|
110
|
+
if (!m) return null;
|
|
111
|
+
let target;
|
|
112
|
+
if (m.exports !== void 0) {
|
|
113
|
+
target = nodeRequireTarget(rootExport(m.exports));
|
|
114
|
+
if (!target) return { format: "unexported", file: null };
|
|
115
|
+
} else {
|
|
116
|
+
target = m.main ?? "./index.js";
|
|
117
|
+
}
|
|
118
|
+
const file = resolveFile(resolvePath(pkgDir, target));
|
|
119
|
+
if (!file) return null;
|
|
120
|
+
const format = file.endsWith(".mjs") ? "esm" : file.endsWith(".cjs") || file.endsWith(".json") || file.endsWith(".node") ? "cjs" : nearestPackageType(file, pkgDir) === "module" ? "esm" : "cjs";
|
|
121
|
+
return { format, file };
|
|
122
|
+
}
|
|
123
|
+
function rootExport(exp) {
|
|
124
|
+
if (exp && typeof exp === "object" && !Array.isArray(exp) && isSubpathMap(exp)) {
|
|
125
|
+
return exp["."];
|
|
126
|
+
}
|
|
127
|
+
return exp;
|
|
128
|
+
}
|
|
129
|
+
function nodeRequireTarget(exp, depth = 0) {
|
|
130
|
+
if (depth > 8 || exp === null || exp === void 0) return null;
|
|
131
|
+
if (typeof exp === "string") return exp;
|
|
132
|
+
if (Array.isArray(exp)) {
|
|
133
|
+
for (const e of exp) {
|
|
134
|
+
const t = nodeRequireTarget(e, depth + 1);
|
|
135
|
+
if (t) return t;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (typeof exp !== "object") return null;
|
|
140
|
+
for (const [condition, value] of Object.entries(exp)) {
|
|
141
|
+
if (!REQUIRE_CONDITIONS.has(condition)) continue;
|
|
142
|
+
const t = nodeRequireTarget(value, depth + 1);
|
|
143
|
+
if (t) return t;
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
function nearestPackageType(file, pkgDir) {
|
|
148
|
+
const root = resolvePath(pkgDir);
|
|
149
|
+
for (let dir = dirname(file); dir.startsWith(root); dir = dirname(dir)) {
|
|
150
|
+
const manifest = join(dir, "package.json");
|
|
151
|
+
if (existsSync(manifest)) {
|
|
152
|
+
try {
|
|
153
|
+
return JSON.parse(readFileSync(manifest, "utf8")).type;
|
|
154
|
+
} catch {
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (dir === root || dirname(dir) === dir) break;
|
|
159
|
+
}
|
|
160
|
+
return void 0;
|
|
161
|
+
}
|
|
162
|
+
function subpathWithdrawn(pkgDir, manifest, sub) {
|
|
163
|
+
const m = manifest ?? readManifest(pkgDir);
|
|
164
|
+
if (!m) return false;
|
|
165
|
+
if (resolveEntryCandidates(pkgDir, m, sub).length) return false;
|
|
166
|
+
if (m.exports === void 0) return true;
|
|
167
|
+
const key = `./${sub.replace(/^\.?\//, "").replace(/\/$/, "")}`;
|
|
168
|
+
return !exportsDeclares(m.exports, key) || pickAllFromExports(m.exports, key).length > 0;
|
|
169
|
+
}
|
|
170
|
+
function exportsDeclares(exp, key) {
|
|
171
|
+
if (!exp || typeof exp !== "object" || Array.isArray(exp)) return key === ".";
|
|
172
|
+
const o = exp;
|
|
173
|
+
if (!isSubpathMap(o)) return key === ".";
|
|
174
|
+
return key in o || Object.keys(o).some((p) => p.includes("*") && matchWildcard(p, key) !== null);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
readManifest,
|
|
179
|
+
resolveEntryCandidates,
|
|
180
|
+
resolvesInsidePackage,
|
|
181
|
+
resolveInternal,
|
|
182
|
+
requireTarget,
|
|
183
|
+
subpathWithdrawn
|
|
184
|
+
};
|