@wirecat/tg-cli 0.99.0 → 0.101.0
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 +6 -5
- package/dist/bin/tg.js +23 -28
- package/dist/bundle/adapter-A3VD4Y6Z.js +2790 -0
- package/dist/bundle/all-profiles-UPVNHXB2.js +264 -0
- package/dist/bundle/anthropic-IRKNWPIB.js +71 -0
- package/dist/bundle/bot-api-UNTQG2M5.js +39793 -0
- package/dist/bundle/bot-history-V4RTY5K7.js +167 -0
- package/dist/bundle/bun-2JZPG2NL.js +169 -0
- package/dist/bundle/bun-sqlite-TZHKM225.js +70 -0
- package/dist/bundle/chunk-22PQUX72.js +190 -0
- package/dist/bundle/chunk-2DGOFLDA.js +58 -0
- package/dist/bundle/chunk-2SJOUK6J.js +2 -0
- package/dist/bundle/chunk-2XBSVRT2.js +98 -0
- package/dist/bundle/chunk-3KHKYYCR.js +24782 -0
- package/dist/bundle/chunk-4ZS73HTJ.js +6848 -0
- package/dist/bundle/chunk-54R2GDQ3.js +119 -0
- package/dist/bundle/chunk-5GKXETRP.js +1345 -0
- package/dist/bundle/chunk-5KU4UQBM.js +570 -0
- package/dist/bundle/chunk-5TPT2S2Z.js +41 -0
- package/dist/bundle/chunk-64DK7S4F.js +76 -0
- package/dist/bundle/chunk-6IPY2QRG.js +82 -0
- package/dist/bundle/chunk-7BFO3DY6.js +21 -0
- package/dist/bundle/chunk-7CBUCTB6.js +1142 -0
- package/dist/bundle/chunk-A5JSTZZZ.js +122 -0
- package/dist/bundle/chunk-ACGTFLEB.js +1275 -0
- package/dist/bundle/chunk-AFV74GK3.js +50 -0
- package/dist/bundle/chunk-AVWK4NCW.js +24600 -0
- package/dist/bundle/chunk-BJG6JA5U.js +35 -0
- package/dist/bundle/chunk-BX6HH4F6.js +215 -0
- package/dist/bundle/chunk-BXQS5RCE.js +8170 -0
- package/dist/bundle/chunk-CJ6IYCYP.js +583 -0
- package/dist/bundle/chunk-DG62L57H.js +2795 -0
- package/dist/bundle/chunk-DYNSP6FW.js +33720 -0
- package/dist/bundle/chunk-F7TDFWXY.js +82 -0
- package/dist/bundle/chunk-G2US6LJB.js +35 -0
- package/dist/bundle/chunk-G3ZRY436.js +3077 -0
- package/dist/bundle/chunk-G77QOTXE.js +18 -0
- package/dist/bundle/chunk-H6OXALTJ.js +45 -0
- package/dist/bundle/chunk-LPB2MDUW.js +452 -0
- package/dist/bundle/chunk-MLLJ74LM.js +24 -0
- package/dist/bundle/chunk-N5UFBWDM.js +166 -0
- package/dist/bundle/chunk-NC5WS7OP.js +31 -0
- package/dist/bundle/chunk-NKJJJAIJ.js +237 -0
- package/dist/bundle/chunk-NMGO6LW6.js +1950 -0
- package/dist/bundle/chunk-ODSVNH3H.js +18588 -0
- package/dist/bundle/chunk-OEJ5DMCX.js +2374 -0
- package/dist/bundle/chunk-OILBDLWL.js +724 -0
- package/dist/bundle/chunk-OPBTNQ35.js +1007 -0
- package/dist/bundle/chunk-PUBS2F5J.js +35803 -0
- package/dist/bundle/chunk-PYTOIDSM.js +153 -0
- package/dist/bundle/chunk-QOWSVDPZ.js +3526 -0
- package/dist/bundle/chunk-QYVVRQTN.js +73 -0
- package/dist/bundle/chunk-RF54YDBB.js +46 -0
- package/dist/bundle/chunk-RVCS7Q3A.js +6672 -0
- package/dist/bundle/chunk-S2JSZWEC.js +277 -0
- package/dist/bundle/chunk-S7ZNLLY5.js +54 -0
- package/dist/bundle/chunk-TGREFJVA.js +2315 -0
- package/dist/bundle/chunk-U46UNBMT.js +524 -0
- package/dist/bundle/chunk-UN6CKIBN.js +285 -0
- package/dist/bundle/chunk-VA5YEJS3.js +161 -0
- package/dist/bundle/chunk-VCGL2ETF.js +78 -0
- package/dist/bundle/chunk-VRSN7VLO.js +63 -0
- package/dist/bundle/chunk-VYDTI254.js +3332 -0
- package/dist/bundle/chunk-W2336E7Y.js +886 -0
- package/dist/bundle/chunk-X4Y2ROJI.js +541 -0
- package/dist/bundle/chunk-XCKD54TN.js +100 -0
- package/dist/bundle/chunk-ZEOCU24Z.js +738 -0
- package/dist/bundle/chunk-ZJVZXJOG.js +71 -0
- package/dist/bundle/chunk-ZV24I2UJ.js +25 -0
- package/dist/bundle/chunk-ZZLKX62Z.js +928 -0
- package/dist/bundle/command-contract-TKDI7E56.js +31 -0
- package/dist/bundle/dist-RJMT44PL.js +7577 -0
- package/dist/bundle/echarts-QZ6PR3VC.js +42501 -0
- package/dist/bundle/embed-UBXCXSRD.js +35 -0
- package/dist/bundle/embedder-B4ZTKC23.js +108 -0
- package/dist/bundle/entry-BTUTHO5M.js +14 -0
- package/dist/bundle/first-run-UC4HRIFV.js +24 -0
- package/dist/bundle/first-screen-SMCX6YKY.js +29 -0
- package/dist/bundle/identity-QSDEGDH7.js +11 -0
- package/dist/bundle/instructions-BBGLZKO3.js +9 -0
- package/dist/bundle/mcp-4Y37G2UY.js +165 -0
- package/dist/bundle/node-IUL5HSYI.js +2340 -0
- package/dist/bundle/node-LZZX22VR.js +176 -0
- package/dist/bundle/node-UPPL626U.js +21 -0
- package/dist/bundle/node-sqlite-BPGT6T5U.js +46 -0
- package/dist/bundle/oauth-XNE2KPKJ.js +18 -0
- package/dist/bundle/open-SXGYZLB5.js +20 -0
- package/dist/bundle/process-GPUXC4PG.js +91 -0
- package/dist/bundle/program-NEXEAL7T.js +1060 -0
- package/dist/bundle/prompt-SORGLEYI.js +13 -0
- package/dist/bundle/proxy-transport-G4MA6BGU.js +17 -0
- package/dist/bundle/recognize-UJBXORVD.js +191 -0
- package/dist/bundle/remote-W72AR7KH.js +26 -0
- package/dist/bundle/rerank-3Y2VZM3J.js +49 -0
- package/dist/bundle/serve-VDZIVOPR.js +196 -0
- package/dist/bundle/server-BERXP4GW.js +785 -0
- package/dist/bundle/server-ZFHN4GUF.js +178 -0
- package/dist/bundle/state-DGR4EE3E.js +34 -0
- package/dist/bundle/store-MRCFSCZD.js +121 -0
- package/dist/bundle/store-maintenance-command-DCMZDMYS.js +46 -0
- package/dist/bundle/tg.js +40 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +3 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/install/postinstall.js +1 -1
- package/dist/install/postinstall.js.map +1 -1
- package/dist/program.js +1 -1
- package/dist/program.js.map +1 -1
- package/dist/telegram/errors.js +1 -1
- package/dist/telegram/errors.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/install/windows.ps1 +1 -1
- package/package.json +6 -4
- package/skills/{wirecat-tg → tg-cli}/SKILL.md +4 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { createRequire as __tgRequire } from "node:module";
|
|
2
|
+
const require = __tgRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
envName,
|
|
5
|
+
readOnlyLockOf
|
|
6
|
+
} from "./chunk-ZV24I2UJ.js";
|
|
7
|
+
import {
|
|
8
|
+
CAPABILITY_STATEMENTS,
|
|
9
|
+
storeCapable
|
|
10
|
+
} from "./chunk-XCKD54TN.js";
|
|
11
|
+
import {
|
|
12
|
+
catchCrashes
|
|
13
|
+
} from "./chunk-DG62L57H.js";
|
|
14
|
+
import {
|
|
15
|
+
CliError
|
|
16
|
+
} from "./chunk-OEJ5DMCX.js";
|
|
17
|
+
import {
|
|
18
|
+
importFrom
|
|
19
|
+
} from "./chunk-BJG6JA5U.js";
|
|
20
|
+
import {
|
|
21
|
+
__name
|
|
22
|
+
} from "./chunk-AFV74GK3.js";
|
|
23
|
+
|
|
24
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/entry.js
|
|
25
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/sqlite-runtime.js
|
|
28
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
29
|
+
import { readFileSync } from "node:fs";
|
|
30
|
+
import { dirname } from "node:path";
|
|
31
|
+
var RESTARTED = "CLI_MESSAGING_SQLITE_RESTARTED";
|
|
32
|
+
var USER_LIBRARY_PATH = "CLI_MESSAGING_USER_LD_LIBRARY_PATH";
|
|
33
|
+
var FORWARDED = ["SIGTERM", "SIGHUP", "SIGQUIT"];
|
|
34
|
+
var ensureSqlite = /* @__PURE__ */ __name(async (runtime = nodeRuntime()) => {
|
|
35
|
+
const { env } = runtime;
|
|
36
|
+
if (env[RESTARTED]) {
|
|
37
|
+
if (env[USER_LIBRARY_PATH] === void 0)
|
|
38
|
+
delete env.LD_LIBRARY_PATH;
|
|
39
|
+
else
|
|
40
|
+
env.LD_LIBRARY_PATH = env[USER_LIBRARY_PATH];
|
|
41
|
+
delete env[USER_LIBRARY_PATH];
|
|
42
|
+
delete env[RESTARTED];
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (runtime.bun || runtime.platform !== "linux")
|
|
46
|
+
return;
|
|
47
|
+
const maps = runtime.maps();
|
|
48
|
+
if (!maps.includes("libsqlite3"))
|
|
49
|
+
return;
|
|
50
|
+
if (await runtime.capable())
|
|
51
|
+
return;
|
|
52
|
+
const library = await runtime.library(maps.includes("ld-musl"));
|
|
53
|
+
if (!library)
|
|
54
|
+
return;
|
|
55
|
+
const restarted = {
|
|
56
|
+
...env,
|
|
57
|
+
LD_LIBRARY_PATH: [dirname(library.path), env.LD_LIBRARY_PATH].filter(Boolean).join(":"),
|
|
58
|
+
[RESTARTED]: "1"
|
|
59
|
+
};
|
|
60
|
+
if (env.LD_LIBRARY_PATH !== void 0)
|
|
61
|
+
restarted[USER_LIBRARY_PATH] = env.LD_LIBRARY_PATH;
|
|
62
|
+
if (!runtime.works(restarted, library.version))
|
|
63
|
+
return;
|
|
64
|
+
await runtime.restart(restarted);
|
|
65
|
+
}, "ensureSqlite");
|
|
66
|
+
var trialScript = /* @__PURE__ */ __name((version) => `
|
|
67
|
+
const { DatabaseSync } = await import("node:sqlite")
|
|
68
|
+
const database = new DatabaseSync(":memory:")
|
|
69
|
+
if (database.prepare("SELECT sqlite_version() AS v").get().v !== ${JSON.stringify(version)}) process.exit(1)
|
|
70
|
+
for (const statement of ${JSON.stringify(CAPABILITY_STATEMENTS)}) database.exec(statement)
|
|
71
|
+
`, "trialScript");
|
|
72
|
+
var nodeRuntime = /* @__PURE__ */ __name(() => ({
|
|
73
|
+
env: process.env,
|
|
74
|
+
platform: process.platform,
|
|
75
|
+
bun: "Bun" in globalThis,
|
|
76
|
+
maps: /* @__PURE__ */ __name(() => {
|
|
77
|
+
try {
|
|
78
|
+
return readFileSync("/proc/self/maps", "utf8");
|
|
79
|
+
} catch {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
}, "maps"),
|
|
83
|
+
capable: /* @__PURE__ */ __name(() => storeCapable().then(() => true, () => false), "capable"),
|
|
84
|
+
library: /* @__PURE__ */ __name(async (musl) => {
|
|
85
|
+
try {
|
|
86
|
+
const { libraryFor, SQLITE_VERSION } = await importFrom(new URL("sqlite-runtime.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
|
|
87
|
+
const path = libraryFor({ musl });
|
|
88
|
+
return path === void 0 ? void 0 : { path, version: SQLITE_VERSION };
|
|
89
|
+
} catch {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
}, "library"),
|
|
93
|
+
works: /* @__PURE__ */ __name((env, version) => spawnSync(process.execPath, ["--no-warnings", "--input-type=module", "-e", trialScript(version)], {
|
|
94
|
+
env,
|
|
95
|
+
stdio: "ignore",
|
|
96
|
+
timeout: 1e4
|
|
97
|
+
}).status === 0, "works"),
|
|
98
|
+
restart: /* @__PURE__ */ __name((env) => relay(spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], { env, stdio: "inherit" })), "restart")
|
|
99
|
+
}), "nodeRuntime");
|
|
100
|
+
var relay = /* @__PURE__ */ __name((child, host = process) => new Promise(() => {
|
|
101
|
+
for (const signal of FORWARDED)
|
|
102
|
+
host.on(signal, () => child.kill(signal));
|
|
103
|
+
host.on("SIGINT", () => {
|
|
104
|
+
});
|
|
105
|
+
child.on("error", () => host.exit(1));
|
|
106
|
+
child.on("exit", (code, signal) => {
|
|
107
|
+
if (signal) {
|
|
108
|
+
host.removeAllListeners(signal);
|
|
109
|
+
host.kill(host.pid, signal);
|
|
110
|
+
} else
|
|
111
|
+
host.exit(code ?? 1);
|
|
112
|
+
});
|
|
113
|
+
}), "relay");
|
|
114
|
+
|
|
115
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/argv-log.js
|
|
116
|
+
import { appendFileSync } from "node:fs";
|
|
117
|
+
var logParsedArgv = /* @__PURE__ */ __name((file, action) => {
|
|
118
|
+
const words = [];
|
|
119
|
+
const options = [];
|
|
120
|
+
for (let at = action; at; at = at.parent) {
|
|
121
|
+
if (at.parent)
|
|
122
|
+
words.unshift(at.name());
|
|
123
|
+
for (const option of at.options) {
|
|
124
|
+
const key = option.attributeName();
|
|
125
|
+
if (at.getOptionValueSource(key) !== "cli" || !option.long)
|
|
126
|
+
continue;
|
|
127
|
+
if (option.negate === (at.getOptionValue(key) === false))
|
|
128
|
+
options.push(option.long);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
appendFileSync(file, `${JSON.stringify({ command: words.join(" "), options })}
|
|
132
|
+
`);
|
|
133
|
+
}, "logParsedArgv");
|
|
134
|
+
var logVersion = /* @__PURE__ */ __name((file) => {
|
|
135
|
+
appendFileSync(file, `${JSON.stringify({ command: "", options: ["--version"] })}
|
|
136
|
+
`);
|
|
137
|
+
}, "logVersion");
|
|
138
|
+
|
|
139
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/entry.js
|
|
140
|
+
var processIo = /* @__PURE__ */ __name(() => ({
|
|
141
|
+
argv: process.argv,
|
|
142
|
+
env: process.env,
|
|
143
|
+
platform: process.platform,
|
|
144
|
+
stdin: process.stdin,
|
|
145
|
+
stdout: process.stdout,
|
|
146
|
+
stderr: process.stderr,
|
|
147
|
+
signals: process,
|
|
148
|
+
setExitCode: /* @__PURE__ */ __name((code) => {
|
|
149
|
+
process.exitCode = code;
|
|
150
|
+
}, "setExitCode"),
|
|
151
|
+
spawn: spawn2
|
|
152
|
+
}), "processIo");
|
|
153
|
+
var startCli = /* @__PURE__ */ __name(async (entry) => {
|
|
154
|
+
const io = { ...processIo(), ...entry.io };
|
|
155
|
+
const args = io.argv.slice(2);
|
|
156
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-V"))
|
|
157
|
+
return printVersion(entry.app, io);
|
|
158
|
+
const tty = io.stdout.isTTY === true;
|
|
159
|
+
const release = catchCrashes({
|
|
160
|
+
cli: entry.app.command,
|
|
161
|
+
interactive: entry.interactive?.(args, tty) ?? tty,
|
|
162
|
+
...entry.reasons ? { reasons: entry.reasons } : {},
|
|
163
|
+
target: io.signals
|
|
164
|
+
});
|
|
165
|
+
const controller = new AbortController();
|
|
166
|
+
let closed = false;
|
|
167
|
+
let unwritable = false;
|
|
168
|
+
const interrupted = /* @__PURE__ */ __name((signal) => () => controller.abort(new CliError("cancelled", `command interrupted by ${signal}`, { reason: signal, retryable: false })), "interrupted");
|
|
169
|
+
const sigint = interrupted("SIGINT");
|
|
170
|
+
const sigterm = interrupted("SIGTERM");
|
|
171
|
+
const outputFailed = /* @__PURE__ */ __name((error) => {
|
|
172
|
+
if (error.code === "EPIPE") {
|
|
173
|
+
closed = true;
|
|
174
|
+
controller.abort(new CliError("cancelled", "output pipe closed", { retryable: false }));
|
|
175
|
+
} else {
|
|
176
|
+
unwritable = true;
|
|
177
|
+
controller.abort(new CliError("configuration_error", "could not write command output"));
|
|
178
|
+
}
|
|
179
|
+
}, "outputFailed");
|
|
180
|
+
const headless = /* @__PURE__ */ __name((command) => {
|
|
181
|
+
const flags = command?.optsWithGlobals() ?? {};
|
|
182
|
+
return Boolean(flags.json || flags.jsonl || flags.input === false || io.env.CI) || !tty;
|
|
183
|
+
}, "headless");
|
|
184
|
+
const context = {
|
|
185
|
+
args,
|
|
186
|
+
env: io.env,
|
|
187
|
+
tty,
|
|
188
|
+
signal: controller.signal,
|
|
189
|
+
atStart: /* @__PURE__ */ __name(async (command) => {
|
|
190
|
+
if (command.optsWithGlobals().dryRun === true)
|
|
191
|
+
return;
|
|
192
|
+
const [{ setupAtStart }, { commandPathOf }] = await Promise.all([
|
|
193
|
+
import("./first-run-UC4HRIFV.js"),
|
|
194
|
+
import("./command-contract-TKDI7E56.js")
|
|
195
|
+
]);
|
|
196
|
+
await setupAtStart({
|
|
197
|
+
command: entry.app.command,
|
|
198
|
+
env: io.env,
|
|
199
|
+
contentLanguages: entry.app.contentLanguages,
|
|
200
|
+
path: commandPathOf(command),
|
|
201
|
+
headless: headless(command),
|
|
202
|
+
readOnlyLock: readOnlyLockOf(entry.app, io.env),
|
|
203
|
+
input: io.stdin
|
|
204
|
+
});
|
|
205
|
+
}, "atStart"),
|
|
206
|
+
ask: /* @__PURE__ */ __name(async (question, command) => {
|
|
207
|
+
if (headless(command) || io.stdin.isTTY !== true)
|
|
208
|
+
return false;
|
|
209
|
+
const { readSecret } = await import("./prompt-SORGLEYI.js");
|
|
210
|
+
const answer = await readSecret(`${question} [y/N] `, {
|
|
211
|
+
input: io.stdin,
|
|
212
|
+
output: io.stderr,
|
|
213
|
+
echo: true,
|
|
214
|
+
signal: controller.signal
|
|
215
|
+
});
|
|
216
|
+
return /^(y|yes)$/i.test(answer.trim());
|
|
217
|
+
}, "ask"),
|
|
218
|
+
openBrowser: /* @__PURE__ */ __name((url, browser) => openBrowser(io, url, browser), "openBrowser"),
|
|
219
|
+
outputClosed: /* @__PURE__ */ __name(() => closed, "outputClosed")
|
|
220
|
+
};
|
|
221
|
+
let code;
|
|
222
|
+
try {
|
|
223
|
+
if (entry.sqlite)
|
|
224
|
+
await ensureSqlite();
|
|
225
|
+
io.signals.on("SIGINT", sigint).on("SIGTERM", sigterm);
|
|
226
|
+
io.stdout.on("error", outputFailed);
|
|
227
|
+
io.stderr.on("error", outputFailed);
|
|
228
|
+
const returned = await entry.run(context);
|
|
229
|
+
if (typeof returned === "number")
|
|
230
|
+
code = returned;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
code = commanderExit(error) ?? entry.fail(error, context);
|
|
233
|
+
} finally {
|
|
234
|
+
io.signals.off("SIGINT", sigint).off("SIGTERM", sigterm);
|
|
235
|
+
release();
|
|
236
|
+
}
|
|
237
|
+
if (closed)
|
|
238
|
+
io.setExitCode(0);
|
|
239
|
+
else if (unwritable)
|
|
240
|
+
io.setExitCode(3);
|
|
241
|
+
else if (code !== void 0)
|
|
242
|
+
io.setExitCode(code);
|
|
243
|
+
}, "startCli");
|
|
244
|
+
var printVersion = /* @__PURE__ */ __name((app, io) => {
|
|
245
|
+
const argvLog = io.env[envName(app, "TEST_ARGV_LOG")];
|
|
246
|
+
if (argvLog)
|
|
247
|
+
logVersion(argvLog);
|
|
248
|
+
io.stdout.write(`${app.version}
|
|
249
|
+
`);
|
|
250
|
+
}, "printVersion");
|
|
251
|
+
var commanderExit = /* @__PURE__ */ __name((error) => {
|
|
252
|
+
if (!(error instanceof Error))
|
|
253
|
+
return void 0;
|
|
254
|
+
const { code, exitCode } = error;
|
|
255
|
+
if (typeof code !== "string" || !code.startsWith("commander.") || typeof exitCode !== "number")
|
|
256
|
+
return void 0;
|
|
257
|
+
if (exitCode === 0)
|
|
258
|
+
return 0;
|
|
259
|
+
return code === "commander.help" ? 2 : void 0;
|
|
260
|
+
}, "commanderExit");
|
|
261
|
+
var openBrowser = /* @__PURE__ */ __name((io, url, browser) => {
|
|
262
|
+
const [command, prefix] = browser !== void 0 ? [browser, []] : io.platform === "darwin" ? ["open", []] : io.platform === "win32" ? ["rundll32.exe", ["url.dll,FileProtocolHandler"]] : ["xdg-open", []];
|
|
263
|
+
return new Promise((resolve, reject) => {
|
|
264
|
+
const child = io.spawn(command, [...prefix, url], { detached: true, stdio: "ignore", windowsHide: true });
|
|
265
|
+
child.once("error", () => reject(new CliError("configuration_error", `could not start ${command} \u2014 open the printed URL in a browser`)));
|
|
266
|
+
child.once("spawn", () => {
|
|
267
|
+
child.unref();
|
|
268
|
+
resolve();
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
}, "openBrowser");
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
logParsedArgv,
|
|
275
|
+
logVersion,
|
|
276
|
+
startCli
|
|
277
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire as __tgRequire } from "node:module";
|
|
2
|
+
const require = __tgRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
readSharedSection,
|
|
5
|
+
writeSharedSection
|
|
6
|
+
} from "./chunk-W2336E7Y.js";
|
|
7
|
+
import {
|
|
8
|
+
CliError
|
|
9
|
+
} from "./chunk-OEJ5DMCX.js";
|
|
10
|
+
import {
|
|
11
|
+
__name
|
|
12
|
+
} from "./chunk-AFV74GK3.js";
|
|
13
|
+
|
|
14
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/setup-answers.js
|
|
15
|
+
var PERMISSION_ANSWERS = ["readonly", "allow"];
|
|
16
|
+
var QUESTIONS = ["languages", "tools", "permissions"];
|
|
17
|
+
var SECTION = "setup";
|
|
18
|
+
var readSetupAnswers = /* @__PURE__ */ __name((path) => {
|
|
19
|
+
const section = readSharedSection(path, SECTION);
|
|
20
|
+
if (section === void 0)
|
|
21
|
+
return {};
|
|
22
|
+
const answers = section;
|
|
23
|
+
if (section === null || typeof section !== "object" || Array.isArray(section) || answers.languages !== void 0 && answers.languages !== true || answers.tools !== void 0 && answers.tools !== true || answers.permissions !== void 0 && !PERMISSION_ANSWERS.includes(answers.permissions))
|
|
24
|
+
throw new CliError("configuration_error", `${path}: ${SECTION} holds what setup asked \u2014 languages: true, tools: true, permissions: ${PERMISSION_ANSWERS.join(" | ")}`);
|
|
25
|
+
return answers;
|
|
26
|
+
}, "readSetupAnswers");
|
|
27
|
+
var unanswered = /* @__PURE__ */ __name((answers) => QUESTIONS.filter((question) => answers[question] === void 0), "unanswered");
|
|
28
|
+
var writeSetupAnswers = /* @__PURE__ */ __name((path, answers) => {
|
|
29
|
+
let kept = {};
|
|
30
|
+
try {
|
|
31
|
+
kept = readSetupAnswers(path);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!(error instanceof CliError) || !error.message.includes(`${SECTION} holds`))
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
writeSharedSection(path, SECTION, { ...kept, ...answers });
|
|
37
|
+
}, "writeSetupAnswers");
|
|
38
|
+
var permissionCeiling = /* @__PURE__ */ __name((path) => {
|
|
39
|
+
let answer;
|
|
40
|
+
try {
|
|
41
|
+
answer = readSetupAnswers(path).permissions;
|
|
42
|
+
} catch {
|
|
43
|
+
return "readonly";
|
|
44
|
+
}
|
|
45
|
+
return answer === "allow" ? void 0 : answer;
|
|
46
|
+
}, "permissionCeiling");
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
QUESTIONS,
|
|
50
|
+
readSetupAnswers,
|
|
51
|
+
unanswered,
|
|
52
|
+
writeSetupAnswers,
|
|
53
|
+
permissionCeiling
|
|
54
|
+
};
|