@wirecat/drive-cli 0.44.0 → 0.45.1
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/dist/bin/drive.js +35 -40
- package/dist/bundle/all-profiles-O7CNQ7FO.js +26 -0
- package/dist/bundle/anthropic-6T67J2CE.js +71 -0
- package/dist/bundle/app-server-BVBZT3UY.js +237 -0
- package/dist/bundle/bun-O6RL6LRQ.js +169 -0
- package/dist/bundle/bun-sqlite-54W7JUY3.js +70 -0
- package/dist/bundle/chunk-2DLAJGRN.js +62 -0
- package/dist/bundle/chunk-37MAA6F2.js +5624 -0
- package/dist/bundle/chunk-3HRDEJJW.js +161 -0
- package/dist/bundle/chunk-3Z7WSD2A.js +433 -0
- package/dist/bundle/chunk-44FV5JAS.js +1855 -0
- package/dist/bundle/chunk-4DW6QGEV.js +164 -0
- package/dist/bundle/chunk-4NGLRHWO.js +24 -0
- package/dist/bundle/chunk-5DPV7X27.js +663 -0
- package/dist/bundle/chunk-5FONRUG6.js +24805 -0
- package/dist/bundle/chunk-5MGIL5LW.js +846 -0
- package/dist/bundle/chunk-5TC3NCAF.js +42 -0
- package/dist/bundle/chunk-6Y2BYFXQ.js +65 -0
- package/dist/bundle/chunk-A3FU4RR6.js +150 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AIXLOMH4.js +63 -0
- package/dist/bundle/chunk-AOOD3RMK.js +384 -0
- package/dist/bundle/chunk-AUS6TKP5.js +1975 -0
- package/dist/bundle/chunk-B2J6FJNL.js +19 -0
- package/dist/bundle/chunk-BEXHAGXH.js +3542 -0
- package/dist/bundle/chunk-BHE7ZY2N.js +2352 -0
- package/dist/bundle/chunk-BJ3JRO34.js +2356 -0
- package/dist/bundle/chunk-BQUPOB5H.js +2315 -0
- package/dist/bundle/chunk-CFZWPIVC.js +1092 -0
- package/dist/bundle/chunk-CKR3DVUK.js +754 -0
- package/dist/bundle/chunk-CVIKKIGE.js +76 -0
- package/dist/bundle/chunk-D67JGWSC.js +190 -0
- package/dist/bundle/chunk-DDYR6DYL.js +78 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DL7D6Y3B.js +18102 -0
- package/dist/bundle/chunk-DORXXBFC.js +484 -0
- package/dist/bundle/chunk-DXKVEOSS.js +53 -0
- package/dist/bundle/chunk-DXQEJWI3.js +522 -0
- package/dist/bundle/chunk-FEULDMWM.js +35598 -0
- package/dist/bundle/chunk-G3FAOS52.js +630 -0
- package/dist/bundle/chunk-GHOWRW7E.js +237 -0
- package/dist/bundle/chunk-GNFHZZ55.js +264 -0
- package/dist/bundle/chunk-GNI7INK6.js +18 -0
- package/dist/bundle/chunk-GOR3Z2FR.js +17 -0
- package/dist/bundle/chunk-GQW4GRYR.js +886 -0
- package/dist/bundle/chunk-GWPKIRNQ.js +220 -0
- package/dist/bundle/chunk-GYCUY4CL.js +9 -0
- package/dist/bundle/chunk-HEPIOCHN.js +8181 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-IAW5A7OR.js +1913 -0
- package/dist/bundle/chunk-IGMRWQP3.js +1071 -0
- package/dist/bundle/chunk-IKNU5A5Y.js +82 -0
- package/dist/bundle/chunk-JVTVAZ5X.js +1054 -0
- package/dist/bundle/chunk-K74PQVQZ.js +168 -0
- package/dist/bundle/chunk-K7FRUB33.js +795 -0
- package/dist/bundle/chunk-KADPV4YA.js +45 -0
- package/dist/bundle/chunk-KJMBV574.js +16225 -0
- package/dist/bundle/chunk-LHIL46I3.js +31 -0
- package/dist/bundle/chunk-LJARCTGL.js +60 -0
- package/dist/bundle/chunk-LOTQ2HMT.js +3954 -0
- package/dist/bundle/chunk-MAXN7COO.js +99 -0
- package/dist/bundle/chunk-MFS52LTZ.js +570 -0
- package/dist/bundle/chunk-MFSIOSUM.js +1714 -0
- package/dist/bundle/chunk-NB2N6L3R.js +138 -0
- package/dist/bundle/chunk-NDNTLUPS.js +58 -0
- package/dist/bundle/chunk-NLEB26GA.js +288 -0
- package/dist/bundle/chunk-NP3XLLN3.js +73 -0
- package/dist/bundle/chunk-NW7IMGRR.js +6848 -0
- package/dist/bundle/chunk-O5EHUB2V.js +2 -0
- package/dist/bundle/chunk-OWXTPXIQ.js +215 -0
- package/dist/bundle/chunk-PDBBBUY7.js +166 -0
- package/dist/bundle/chunk-PH74B2VZ.js +122 -0
- package/dist/bundle/chunk-PJ7IQVOM.js +421 -0
- package/dist/bundle/chunk-Q2Z3VCM4.js +2 -0
- package/dist/bundle/chunk-QTJUH3LS.js +15572 -0
- package/dist/bundle/chunk-QW36EOAM.js +106 -0
- package/dist/bundle/chunk-QWSRPXCJ.js +281 -0
- package/dist/bundle/chunk-R2A3K7ZF.js +193 -0
- package/dist/bundle/chunk-R2QRP7EJ.js +835 -0
- package/dist/bundle/chunk-RCS2SCX5.js +375 -0
- package/dist/bundle/chunk-RJ633GFA.js +25 -0
- package/dist/bundle/chunk-SBZB7HMU.js +1055 -0
- package/dist/bundle/chunk-SMHQA5J6.js +459 -0
- package/dist/bundle/chunk-SWMMR3FR.js +48 -0
- package/dist/bundle/chunk-TRMIV3OA.js +18 -0
- package/dist/bundle/chunk-VAGF723Z.js +74 -0
- package/dist/bundle/chunk-VCYFEWPD.js +18078 -0
- package/dist/bundle/chunk-VHQNVG3J.js +263 -0
- package/dist/bundle/chunk-VHT2WI4I.js +2941 -0
- package/dist/bundle/chunk-VYBOYBLX.js +100 -0
- package/dist/bundle/chunk-WUFCYDKB.js +71 -0
- package/dist/bundle/chunk-XAZQTJXR.js +3402 -0
- package/dist/bundle/chunk-XEBFFKXO.js +111 -0
- package/dist/bundle/chunk-XF5MFUEB.js +498 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZBM4GEV2.js +120 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-MXCBV3GJ.js +38 -0
- package/dist/bundle/dist-MWTMOYWT.js +7577 -0
- package/dist/bundle/dist-PY3MVR3G.js +21 -0
- package/dist/bundle/drive.js +50 -0
- package/dist/bundle/echarts-LD3AI55P.js +42501 -0
- package/dist/bundle/embed-FJKIIM43.js +37 -0
- package/dist/bundle/embedder-NNQ5ZC25.js +110 -0
- package/dist/bundle/entry-ZYSNPDSD.js +15 -0
- package/dist/bundle/failure-MJJXFR63.js +37 -0
- package/dist/bundle/first-run-KA2UPZAU.js +24 -0
- package/dist/bundle/first-screen-VQ3RXDMF.js +36 -0
- package/dist/bundle/google-ZYDFTHLN.js +32 -0
- package/dist/bundle/google-api-2GT5PAW2.js +82 -0
- package/dist/bundle/identity-JQFQXQIR.js +10 -0
- package/dist/bundle/instructions-RZMSW3OC.js +11 -0
- package/dist/bundle/login-JU6NKW5P.js +158 -0
- package/dist/bundle/mcp-2PZDI7WE.js +501 -0
- package/dist/bundle/mcp-JOQMFGBC.js +95 -0
- package/dist/bundle/mcp-OQBZXELQ.js +165 -0
- package/dist/bundle/mdast-util-from-markdown-FXEPSNER.js +1958 -0
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +2103 -0
- package/dist/bundle/micromark-extension-gfm-GRL24TU6.js +1838 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-ZRLYQL7J.js +176 -0
- package/dist/bundle/node-sqlite-TXPSRROT.js +46 -0
- package/dist/bundle/oauth-NAIBKERJ.js +18 -0
- package/dist/bundle/open-3P5EPXPV.js +20 -0
- package/dist/bundle/process-LL77573L.js +91 -0
- package/dist/bundle/program-CZ55L6EW.js +24078 -0
- package/dist/bundle/prompt-3TX2SWOY.js +13 -0
- package/dist/bundle/reasons-GF2TYGX6.js +11 -0
- package/dist/bundle/recognize-IFXOJHEA.js +191 -0
- package/dist/bundle/remote-663M42Y5.js +28 -0
- package/dist/bundle/rerank-OT2F2DBV.js +51 -0
- package/dist/bundle/serve-PDNNI6O6.js +20 -0
- package/dist/bundle/server-BFOEPMR7.js +56 -0
- package/dist/bundle/server-K566PJ7H.js +69 -0
- package/dist/bundle/services-5MCTECBU.js +333 -0
- package/dist/bundle/sqlite-runtime-BF3KDM7W.js +17 -0
- package/dist/bundle/state-SZX65E74.js +34 -0
- package/dist/bundle/store-TCWNLA3V.js +125 -0
- package/dist/bundle/store-UKPGGAPW.js +142 -0
- package/dist/bundle/store-maintenance-command-QHLUVBTJ.js +57 -0
- package/dist/bundle/terminal-TFCTWLOS.js +11 -0
- package/dist/bundle/tokens-DFCFRF7I.js +103 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +82 -36
- package/dist/commands/mcp.js.map +1 -1
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +59 -53
- package/dist/contract-overrides.js.map +1 -1
- package/dist/mcp.d.ts +6 -5
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +13 -10
- package/dist/mcp.js.map +1 -1
- package/dist/program.js +4 -4
- package/dist/program.js.map +1 -1
- package/dist/registry.d.ts +2 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +1 -1
- package/dist/state.d.ts +13 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +12 -2
- package/dist/state.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -5
- package/skills/drive-cli/SKILL.md +1 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
installerOf,
|
|
5
|
+
updateCommand
|
|
6
|
+
} from "./chunk-A3FU4RR6.js";
|
|
7
|
+
import {
|
|
8
|
+
QUESTIONS,
|
|
9
|
+
readSetupAnswers,
|
|
10
|
+
unanswered,
|
|
11
|
+
writeSetupAnswers
|
|
12
|
+
} from "./chunk-LJARCTGL.js";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_STEMMERS,
|
|
15
|
+
LANGUAGES
|
|
16
|
+
} from "./chunk-BQUPOB5H.js";
|
|
17
|
+
import {
|
|
18
|
+
sharedConfigPath
|
|
19
|
+
} from "./chunk-GQW4GRYR.js";
|
|
20
|
+
import {
|
|
21
|
+
storePath
|
|
22
|
+
} from "./chunk-TRMIV3OA.js";
|
|
23
|
+
import {
|
|
24
|
+
__name
|
|
25
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.473.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_39633e3162553a2c86dde989a9811fcb/node_modules/@wirecat/cli-core/dist/cli/first-run.js
|
|
28
|
+
import { spawnSync } from "node:child_process";
|
|
29
|
+
import { accessSync, constants, realpathSync } from "node:fs";
|
|
30
|
+
import { delimiter, join } from "node:path";
|
|
31
|
+
var SKIPPED = /* @__PURE__ */ new Set(["help", "guide", "completion", "mcp", "serve", "server", "update", "store"]);
|
|
32
|
+
var asksAtStart = /* @__PURE__ */ __name((start) => !start.headless && start.terminal && !start.env.AI_AGENT && !start.env.CLAUDECODE && start.readOnlyLock === void 0 && !SKIPPED.has(start.path[0] ?? ""), "asksAtStart");
|
|
33
|
+
var systemLanguage = /* @__PURE__ */ __name((env) => {
|
|
34
|
+
const named = [env.LC_ALL, env.LC_MESSAGES, env.LANG, ...(env.LANGUAGE ?? "").split(":")].map((value) => value?.trim()).find((value) => value && value !== "C" && value !== "POSIX" && !value.startsWith("C."));
|
|
35
|
+
return (named ?? Intl.DateTimeFormat().resolvedOptions().locale).slice(0, 2).toLowerCase();
|
|
36
|
+
}, "systemLanguage");
|
|
37
|
+
var stemmersOf = /* @__PURE__ */ __name((languages) => {
|
|
38
|
+
const latin = LANGUAGES.filter(({ name, script }) => script === "latin" && languages.includes(name));
|
|
39
|
+
return {
|
|
40
|
+
cyrillic: languages.includes("russian") ? "russian" : "none",
|
|
41
|
+
latin: latin.length ? latin.map(({ name }) => name).join(",") : "none"
|
|
42
|
+
};
|
|
43
|
+
}, "stemmersOf");
|
|
44
|
+
var languagesOf = /* @__PURE__ */ __name((stemmers) => LANGUAGES.filter(({ name }) => stemmers.cyrillic === name || stemmers.latin.split(",").includes(name)).map(({ name }) => name), "languagesOf");
|
|
45
|
+
var choose = /* @__PURE__ */ __name(async (io, prompt, count, chosen) => {
|
|
46
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
47
|
+
const answer = (await io.ask(prompt)).trim();
|
|
48
|
+
if (!answer)
|
|
49
|
+
return chosen;
|
|
50
|
+
if (/^(none|-)$/i.test(answer))
|
|
51
|
+
return [];
|
|
52
|
+
const numbers = answer.split(/[\s,]+/).filter(Boolean).map(Number);
|
|
53
|
+
if (numbers.every((number) => Number.isInteger(number) && number >= 1 && number <= count))
|
|
54
|
+
return [...new Set(numbers)].sort((a, b) => a - b);
|
|
55
|
+
io.say(`Choose numbers from 1 to ${count}, separated by commas.`);
|
|
56
|
+
}
|
|
57
|
+
return chosen;
|
|
58
|
+
}, "choose");
|
|
59
|
+
var yes = /* @__PURE__ */ __name(async (io, prompt) => /^y(es)?$/i.test((await io.ask(prompt)).trim()), "yes");
|
|
60
|
+
var onPath = /* @__PURE__ */ __name((command, env) => {
|
|
61
|
+
const names = process.platform === "win32" ? [".cmd", ".exe", ""].map((ending) => command + ending) : [command];
|
|
62
|
+
return (env.PATH ?? env.Path ?? "").split(delimiter).some((folder) => names.some((name) => {
|
|
63
|
+
try {
|
|
64
|
+
accessSync(join(folder, name), process.platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
65
|
+
return true;
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
}, "onPath");
|
|
71
|
+
var installWith = /* @__PURE__ */ __name((argv) => spawnSync(argv[0], argv.slice(1), { stdio: ["inherit", 2, 2] }).status === 0, "installWith");
|
|
72
|
+
var installerHere = /* @__PURE__ */ __name(() => {
|
|
73
|
+
try {
|
|
74
|
+
return installerOf(realpathSync(process.argv[1] ?? ""));
|
|
75
|
+
} catch {
|
|
76
|
+
return "unknown";
|
|
77
|
+
}
|
|
78
|
+
}, "installerHere");
|
|
79
|
+
var suggested = /* @__PURE__ */ __name((env, contentLanguages) => {
|
|
80
|
+
const own = LANGUAGES.filter(({ code }) => contentLanguages?.includes(code));
|
|
81
|
+
const system = systemLanguage(env);
|
|
82
|
+
return (own.length ? own : LANGUAGES.filter(({ code }) => code === "en" || code === system)).map(({ name }) => name);
|
|
83
|
+
}, "suggested");
|
|
84
|
+
var askLanguages = /* @__PURE__ */ __name(async ({ command, env, io, contentLanguages }) => {
|
|
85
|
+
const { openStore } = await import("./store-TCWNLA3V.js");
|
|
86
|
+
const store = await openStore({ env });
|
|
87
|
+
let rebuild = false;
|
|
88
|
+
try {
|
|
89
|
+
const saved = await store.searchIndex.stemmers() ?? void 0;
|
|
90
|
+
const inUse = saved !== void 0 || (await store.accounts.accounts()).length > 0;
|
|
91
|
+
const ticked = inUse ? languagesOf(saved ?? DEFAULT_STEMMERS) : suggested(env, contentLanguages);
|
|
92
|
+
const numbers = ticked.map((name) => LANGUAGES.findIndex((one) => one.name === name) + 1);
|
|
93
|
+
io.say("Languages you write and speak \u2014 search finds every form of their words, and spellings speech mangles:");
|
|
94
|
+
LANGUAGES.forEach(({ name, label }, at) => {
|
|
95
|
+
io.say(` ${at + 1}. ${label}${ticked.includes(name) ? " \u2713" : ""}`);
|
|
96
|
+
});
|
|
97
|
+
const chosen = await choose(io, `Numbers (${numbers.join(",")}): `, LANGUAGES.length, numbers);
|
|
98
|
+
const next = stemmersOf(chosen.map((number) => LANGUAGES[number - 1].name));
|
|
99
|
+
const before = saved ?? DEFAULT_STEMMERS;
|
|
100
|
+
if (inUse && before.cyrillic === next.cyrillic && before.latin === next.latin)
|
|
101
|
+
return;
|
|
102
|
+
if (inUse && !await yes(io, "Rebuild the word forms of every stored message now? Word search waits for it; a large store takes minutes. [y/N] ")) {
|
|
103
|
+
io.say(`Languages kept as they were; \`${command} setup\` asks again.`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await store.searchIndex.saveStemmers(next);
|
|
107
|
+
rebuild = inUse;
|
|
108
|
+
} finally {
|
|
109
|
+
await store.close();
|
|
110
|
+
}
|
|
111
|
+
if (!rebuild)
|
|
112
|
+
return;
|
|
113
|
+
const [{ openCache }, { buildStems }] = await Promise.all([
|
|
114
|
+
import("./open-3P5EPXPV.js"),
|
|
115
|
+
import("./store-maintenance-command-QHLUVBTJ.js")
|
|
116
|
+
]);
|
|
117
|
+
const database = await openCache(storePath(env));
|
|
118
|
+
try {
|
|
119
|
+
buildStems(database, (note) => io.say(` ${note}`), { force: true });
|
|
120
|
+
} finally {
|
|
121
|
+
database.close();
|
|
122
|
+
}
|
|
123
|
+
}, "askLanguages");
|
|
124
|
+
var askTools = /* @__PURE__ */ __name(async (run) => {
|
|
125
|
+
const { command, env, io } = run;
|
|
126
|
+
const installed = run.installed ?? ((name) => onPath(name, env));
|
|
127
|
+
const { WIRECAT_TOOLS } = await import("./first-screen-VQ3RXDMF.js");
|
|
128
|
+
const others = WIRECAT_TOOLS.filter((tool) => tool.command !== command);
|
|
129
|
+
const missing = others.filter((tool) => !installed(tool.command));
|
|
130
|
+
io.say("Other WireCat tools \u2014 they share this store, so one search finds everything:");
|
|
131
|
+
for (const tool of others) {
|
|
132
|
+
const at = missing.indexOf(tool);
|
|
133
|
+
io.say(` ${at < 0 ? "\u2713 " : `${at + 1}.`} ${tool.command} \u2014 ${tool.does}`);
|
|
134
|
+
}
|
|
135
|
+
if (!missing.length)
|
|
136
|
+
return;
|
|
137
|
+
const chosen = await choose(io, "Numbers to install (none): ", missing.length, []);
|
|
138
|
+
const installer = run.installer ?? installerHere();
|
|
139
|
+
for (const number of chosen) {
|
|
140
|
+
const tool = missing[number - 1];
|
|
141
|
+
const argv = updateCommand(installer, tool.package);
|
|
142
|
+
if (!argv) {
|
|
143
|
+
io.say(`Install ${tool.command} with \`npm install -g ${tool.package}\`.`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
io.say(`Installing ${tool.command}: ${argv.join(" ")}`);
|
|
147
|
+
if (!(run.install ?? installWith)(argv))
|
|
148
|
+
io.say(`${tool.command} was not installed; run \`${argv.join(" ")}\`.`);
|
|
149
|
+
}
|
|
150
|
+
}, "askTools");
|
|
151
|
+
var PERMISSION_CHOICES = [
|
|
152
|
+
{ answer: "readonly", text: "read only \u2014 search and read; nothing sends or changes" },
|
|
153
|
+
{ answer: "allow", text: "read and write \u2014 as each profile's permissions allow" }
|
|
154
|
+
];
|
|
155
|
+
var askPermissions = /* @__PURE__ */ __name(async ({ io }, answers) => {
|
|
156
|
+
const now = answers.permissions ?? "allow";
|
|
157
|
+
const current = Math.max(1, PERMISSION_CHOICES.findIndex(({ answer }) => answer === now) + 1);
|
|
158
|
+
io.say("Read only, or read and write? The same for you, scripts and agents over MCP, in every WireCat tool:");
|
|
159
|
+
PERMISSION_CHOICES.forEach(({ text }, at) => {
|
|
160
|
+
io.say(` ${at + 1}. ${text}`);
|
|
161
|
+
});
|
|
162
|
+
const [chosen = current] = await choose(io, `Number (${current}): `, PERMISSION_CHOICES.length, [current]);
|
|
163
|
+
return PERMISSION_CHOICES[chosen - 1].answer;
|
|
164
|
+
}, "askPermissions");
|
|
165
|
+
var answersAt = /* @__PURE__ */ __name((path) => {
|
|
166
|
+
try {
|
|
167
|
+
return readSetupAnswers(path);
|
|
168
|
+
} catch {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
}, "answersAt");
|
|
172
|
+
var askSetupQuestions = /* @__PURE__ */ __name(async (run) => {
|
|
173
|
+
const path = sharedConfigPath(storePath(run.env), run.env);
|
|
174
|
+
const answers = answersAt(path);
|
|
175
|
+
const asking = run.all ? [...QUESTIONS] : unanswered(answers);
|
|
176
|
+
for (const question of asking) {
|
|
177
|
+
run.io.say("");
|
|
178
|
+
if (question === "languages") {
|
|
179
|
+
await askLanguages(run);
|
|
180
|
+
writeSetupAnswers(path, { languages: true });
|
|
181
|
+
} else if (question === "tools") {
|
|
182
|
+
await askTools(run);
|
|
183
|
+
writeSetupAnswers(path, { tools: true });
|
|
184
|
+
} else
|
|
185
|
+
writeSetupAnswers(path, { permissions: await askPermissions(run, answers) });
|
|
186
|
+
}
|
|
187
|
+
return asking;
|
|
188
|
+
}, "askSetupQuestions");
|
|
189
|
+
var setupAtStart = /* @__PURE__ */ __name(async (start) => {
|
|
190
|
+
const input = start.input ?? process.stdin;
|
|
191
|
+
const terminal = start.terminal ?? (input.isTTY === true && process.stderr.isTTY === true);
|
|
192
|
+
if (!asksAtStart({ ...start, terminal, readOnlyLock: start.readOnlyLock }))
|
|
193
|
+
return;
|
|
194
|
+
await askSetupQuestions({
|
|
195
|
+
command: start.command,
|
|
196
|
+
env: start.env,
|
|
197
|
+
contentLanguages: start.contentLanguages,
|
|
198
|
+
all: start.path[0] === "setup",
|
|
199
|
+
io: {
|
|
200
|
+
ask: /* @__PURE__ */ __name(async (prompt) => (await import("./prompt-3TX2SWOY.js")).readSecret(prompt, { input, echo: true }), "ask"),
|
|
201
|
+
say: /* @__PURE__ */ __name((text) => process.stderr.write(`${text}
|
|
202
|
+
`), "say")
|
|
203
|
+
}
|
|
204
|
+
}).catch((error) => {
|
|
205
|
+
process.stderr.write(`setup questions skipped: ${error instanceof Error ? error.message : String(error)} \u2014 \`${start.command} setup\` asks them again
|
|
206
|
+
`);
|
|
207
|
+
});
|
|
208
|
+
}, "setupAtStart");
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
asksAtStart,
|
|
212
|
+
systemLanguage,
|
|
213
|
+
askSetupQuestions,
|
|
214
|
+
setupAtStart
|
|
215
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
envName,
|
|
5
|
+
readOnlyLockOf
|
|
6
|
+
} from "./chunk-RJ633GFA.js";
|
|
7
|
+
import {
|
|
8
|
+
ensureSqlite
|
|
9
|
+
} from "./chunk-QW36EOAM.js";
|
|
10
|
+
import {
|
|
11
|
+
catchCrashes
|
|
12
|
+
} from "./chunk-VHT2WI4I.js";
|
|
13
|
+
import {
|
|
14
|
+
CliError
|
|
15
|
+
} from "./chunk-BJ3JRO34.js";
|
|
16
|
+
import {
|
|
17
|
+
__name
|
|
18
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
19
|
+
|
|
20
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.473.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_39633e3162553a2c86dde989a9811fcb/node_modules/@wirecat/cli-core/dist/cli/entry.js
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
|
|
23
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.473.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_39633e3162553a2c86dde989a9811fcb/node_modules/@wirecat/cli-core/dist/cli/argv-log.js
|
|
24
|
+
import { appendFileSync } from "node:fs";
|
|
25
|
+
var logVersion = /* @__PURE__ */ __name((file) => {
|
|
26
|
+
appendFileSync(file, `${JSON.stringify({ command: "", options: ["--version"] })}
|
|
27
|
+
`);
|
|
28
|
+
}, "logVersion");
|
|
29
|
+
|
|
30
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.473.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_39633e3162553a2c86dde989a9811fcb/node_modules/@wirecat/cli-core/dist/cli/entry.js
|
|
31
|
+
var processIo = /* @__PURE__ */ __name(() => ({
|
|
32
|
+
argv: process.argv,
|
|
33
|
+
env: process.env,
|
|
34
|
+
platform: process.platform,
|
|
35
|
+
stdin: process.stdin,
|
|
36
|
+
stdout: process.stdout,
|
|
37
|
+
stderr: process.stderr,
|
|
38
|
+
signals: process,
|
|
39
|
+
setExitCode: /* @__PURE__ */ __name((code) => {
|
|
40
|
+
process.exitCode = code;
|
|
41
|
+
}, "setExitCode"),
|
|
42
|
+
spawn
|
|
43
|
+
}), "processIo");
|
|
44
|
+
var startCli = /* @__PURE__ */ __name(async (entry) => {
|
|
45
|
+
const io = { ...processIo(), ...entry.io };
|
|
46
|
+
const args = io.argv.slice(2);
|
|
47
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-V"))
|
|
48
|
+
return printVersion(entry.app, io);
|
|
49
|
+
const tty = io.stdout.isTTY === true;
|
|
50
|
+
const release = catchCrashes({
|
|
51
|
+
cli: entry.app.command,
|
|
52
|
+
interactive: entry.interactive?.(args, tty) ?? tty,
|
|
53
|
+
...entry.reasons ? { reasons: entry.reasons } : {},
|
|
54
|
+
target: io.signals
|
|
55
|
+
});
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
let closed = false;
|
|
58
|
+
let unwritable = false;
|
|
59
|
+
const interrupted = /* @__PURE__ */ __name((signal) => () => controller.abort(new CliError("cancelled", `command interrupted by ${signal}`, { reason: signal, retryable: false })), "interrupted");
|
|
60
|
+
const sigint = interrupted("SIGINT");
|
|
61
|
+
const sigterm = interrupted("SIGTERM");
|
|
62
|
+
const outputFailed = /* @__PURE__ */ __name((error) => {
|
|
63
|
+
if (error.code === "EPIPE") {
|
|
64
|
+
closed = true;
|
|
65
|
+
controller.abort(new CliError("cancelled", "output pipe closed", { retryable: false }));
|
|
66
|
+
} else {
|
|
67
|
+
unwritable = true;
|
|
68
|
+
controller.abort(new CliError("configuration_error", "could not write command output"));
|
|
69
|
+
}
|
|
70
|
+
}, "outputFailed");
|
|
71
|
+
const headless = /* @__PURE__ */ __name((command) => {
|
|
72
|
+
const flags = command?.optsWithGlobals() ?? {};
|
|
73
|
+
return Boolean(flags.json || flags.jsonl || flags.input === false || io.env.CI) || !tty;
|
|
74
|
+
}, "headless");
|
|
75
|
+
const context = {
|
|
76
|
+
args,
|
|
77
|
+
env: io.env,
|
|
78
|
+
tty,
|
|
79
|
+
signal: controller.signal,
|
|
80
|
+
atStart: /* @__PURE__ */ __name(async (command) => {
|
|
81
|
+
if (command.optsWithGlobals().dryRun === true)
|
|
82
|
+
return;
|
|
83
|
+
const [{ setupAtStart }, { commandPathOf }] = await Promise.all([
|
|
84
|
+
import("./first-run-KA2UPZAU.js"),
|
|
85
|
+
import("./command-contract-MXCBV3GJ.js")
|
|
86
|
+
]);
|
|
87
|
+
await setupAtStart({
|
|
88
|
+
command: entry.app.command,
|
|
89
|
+
env: io.env,
|
|
90
|
+
contentLanguages: entry.app.contentLanguages,
|
|
91
|
+
path: commandPathOf(command),
|
|
92
|
+
headless: headless(command),
|
|
93
|
+
readOnlyLock: readOnlyLockOf(entry.app, io.env),
|
|
94
|
+
input: io.stdin
|
|
95
|
+
});
|
|
96
|
+
}, "atStart"),
|
|
97
|
+
ask: /* @__PURE__ */ __name(async (question, command) => {
|
|
98
|
+
if (headless(command) || io.stdin.isTTY !== true)
|
|
99
|
+
return false;
|
|
100
|
+
const { readSecret } = await import("./prompt-3TX2SWOY.js");
|
|
101
|
+
const answer = await readSecret(`${question} [y/N] `, {
|
|
102
|
+
input: io.stdin,
|
|
103
|
+
output: io.stderr,
|
|
104
|
+
echo: true,
|
|
105
|
+
signal: controller.signal
|
|
106
|
+
});
|
|
107
|
+
return /^(y|yes)$/i.test(answer.trim());
|
|
108
|
+
}, "ask"),
|
|
109
|
+
openBrowser: /* @__PURE__ */ __name((url, browser) => openBrowser(io, url, browser), "openBrowser"),
|
|
110
|
+
outputClosed: /* @__PURE__ */ __name(() => closed, "outputClosed")
|
|
111
|
+
};
|
|
112
|
+
let code;
|
|
113
|
+
try {
|
|
114
|
+
if (entry.sqlite)
|
|
115
|
+
await ensureSqlite();
|
|
116
|
+
io.signals.on("SIGINT", sigint).on("SIGTERM", sigterm);
|
|
117
|
+
io.stdout.on("error", outputFailed);
|
|
118
|
+
io.stderr.on("error", outputFailed);
|
|
119
|
+
const returned = await entry.run(context);
|
|
120
|
+
if (typeof returned === "number")
|
|
121
|
+
code = returned;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
code = commanderExit(error) ?? entry.fail(error, context);
|
|
124
|
+
} finally {
|
|
125
|
+
io.signals.off("SIGINT", sigint).off("SIGTERM", sigterm);
|
|
126
|
+
release();
|
|
127
|
+
}
|
|
128
|
+
if (closed)
|
|
129
|
+
io.setExitCode(0);
|
|
130
|
+
else if (unwritable)
|
|
131
|
+
io.setExitCode(3);
|
|
132
|
+
else if (code !== void 0)
|
|
133
|
+
io.setExitCode(code);
|
|
134
|
+
}, "startCli");
|
|
135
|
+
var printVersion = /* @__PURE__ */ __name((app, io) => {
|
|
136
|
+
const argvLog = io.env[envName(app, "TEST_ARGV_LOG")];
|
|
137
|
+
if (argvLog)
|
|
138
|
+
logVersion(argvLog);
|
|
139
|
+
io.stdout.write(`${app.version}
|
|
140
|
+
`);
|
|
141
|
+
}, "printVersion");
|
|
142
|
+
var commanderExit = /* @__PURE__ */ __name((error) => {
|
|
143
|
+
if (!(error instanceof Error))
|
|
144
|
+
return void 0;
|
|
145
|
+
const { code, exitCode } = error;
|
|
146
|
+
if (typeof code !== "string" || !code.startsWith("commander.") || typeof exitCode !== "number")
|
|
147
|
+
return void 0;
|
|
148
|
+
if (exitCode === 0)
|
|
149
|
+
return 0;
|
|
150
|
+
return code === "commander.help" ? 2 : void 0;
|
|
151
|
+
}, "commanderExit");
|
|
152
|
+
var openBrowser = /* @__PURE__ */ __name((io, url, browser) => {
|
|
153
|
+
const [command, prefix] = browser !== void 0 ? [browser, []] : io.platform === "darwin" ? ["open", []] : io.platform === "win32" ? ["rundll32.exe", ["url.dll,FileProtocolHandler"]] : ["xdg-open", []];
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
const child = io.spawn(command, [...prefix, url], { detached: true, stdio: "ignore", windowsHide: true });
|
|
156
|
+
child.once("error", () => reject(new CliError("configuration_error", `could not start ${command} \u2014 open the printed URL in a browser`)));
|
|
157
|
+
child.once("spawn", () => {
|
|
158
|
+
child.unref();
|
|
159
|
+
resolve();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}, "openBrowser");
|
|
163
|
+
|
|
164
|
+
export {
|
|
165
|
+
startCli
|
|
166
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
unit
|
|
5
|
+
} from "./chunk-RCS2SCX5.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-BJ3JRO34.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.473.0_@wirecat+cli-base@0.65.0_commander@15.0.0_esbuild@0.28.2_type_39633e3162553a2c86dde989a9811fcb/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
|
|
14
|
+
import { setTimeout } from "node:timers/promises";
|
|
15
|
+
var OPENAI_URL = "https://api.openai.com/v1";
|
|
16
|
+
var OPENAI_MODELS = {
|
|
17
|
+
"text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
|
|
18
|
+
"text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
|
|
19
|
+
};
|
|
20
|
+
var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
|
|
21
|
+
var PER_REQUEST = 256;
|
|
22
|
+
var LOCAL = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
23
|
+
var isLocal = /* @__PURE__ */ __name((baseUrl) => LOCAL.has(new URL(baseUrl).hostname), "isLocal");
|
|
24
|
+
var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
|
|
25
|
+
const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
|
|
26
|
+
if (baseUrl === void 0 && !known) {
|
|
27
|
+
throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
|
|
28
|
+
}
|
|
29
|
+
const size = dims ?? known?.dims;
|
|
30
|
+
if (size === void 0)
|
|
31
|
+
throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
|
|
32
|
+
return {
|
|
33
|
+
provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
|
|
34
|
+
model,
|
|
35
|
+
dims: size,
|
|
36
|
+
baseUrl: baseUrl ?? OPENAI_URL,
|
|
37
|
+
shorten: known !== void 0 && size !== known.dims,
|
|
38
|
+
...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
|
|
39
|
+
};
|
|
40
|
+
}, "remoteModel");
|
|
41
|
+
var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
|
|
42
|
+
var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5 } = {}) => {
|
|
43
|
+
const request = /* @__PURE__ */ __name(async (input) => {
|
|
44
|
+
for (let attempt = 1; ; attempt++) {
|
|
45
|
+
let response;
|
|
46
|
+
try {
|
|
47
|
+
response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
model: remote.model,
|
|
55
|
+
input,
|
|
56
|
+
encoding_format: "float",
|
|
57
|
+
...remote.shorten ? { dimensions: remote.dims } : {}
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
if (attempt >= tries)
|
|
62
|
+
throw new CliError("network_error", `${remote.provider} could not be reached`);
|
|
63
|
+
await setTimeout(1e3 * attempt);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (response.ok) {
|
|
67
|
+
const body = await response.json();
|
|
68
|
+
const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
|
|
69
|
+
if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
|
|
70
|
+
throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
|
|
71
|
+
}
|
|
72
|
+
return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
|
|
73
|
+
}
|
|
74
|
+
const code = await errorCode(response);
|
|
75
|
+
if (response.status === 401 || response.status === 403) {
|
|
76
|
+
throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
|
|
77
|
+
}
|
|
78
|
+
const again = response.status === 429 || response.status >= 500;
|
|
79
|
+
if (!again || attempt >= tries) {
|
|
80
|
+
throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
|
|
81
|
+
}
|
|
82
|
+
const wait = Number(response.headers.get("retry-after"));
|
|
83
|
+
await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
|
|
84
|
+
}
|
|
85
|
+
}, "request");
|
|
86
|
+
return {
|
|
87
|
+
model: { id: remote.model, dims: remote.dims },
|
|
88
|
+
embed: /* @__PURE__ */ __name(async (texts) => {
|
|
89
|
+
const parts = [];
|
|
90
|
+
for (let start = 0; start < texts.length; start += PER_REQUEST)
|
|
91
|
+
parts.push(texts.slice(start, start + PER_REQUEST));
|
|
92
|
+
const results = new Array(parts.length);
|
|
93
|
+
let next = 0;
|
|
94
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
|
|
95
|
+
for (let index = next++; index < parts.length; index = next++)
|
|
96
|
+
results[index] = await request(parts[index]);
|
|
97
|
+
}));
|
|
98
|
+
return results.flat();
|
|
99
|
+
}, "embed"),
|
|
100
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
101
|
+
}, "close")
|
|
102
|
+
};
|
|
103
|
+
}, "openRemote");
|
|
104
|
+
var errorCode = /* @__PURE__ */ __name(async (response) => {
|
|
105
|
+
try {
|
|
106
|
+
const body = await response.json();
|
|
107
|
+
const code = body.error?.code ?? body.error?.type;
|
|
108
|
+
return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
|
|
109
|
+
} catch {
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
}, "errorCode");
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
OPENAI_URL,
|
|
116
|
+
OPENAI_MODELS,
|
|
117
|
+
DEFAULT_OPENAI_MODEL,
|
|
118
|
+
isLocal,
|
|
119
|
+
remoteModel,
|
|
120
|
+
remoteKey,
|
|
121
|
+
openRemote
|
|
122
|
+
};
|