@wirecat/yandex-disk-cli 0.0.0-stage → 0.1.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/CHANGELOG.md +25 -0
- package/LICENSE +204 -0
- package/README.md +243 -2
- package/contracts/wirecat.json +1554 -0
- package/dist/bin/ydisk.d.ts +3 -0
- package/dist/bin/ydisk.d.ts.map +1 -0
- package/dist/bin/ydisk.js +40 -0
- package/dist/bin/ydisk.js.map +1 -0
- package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
- package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
- package/dist/bundle/app-server-G4545SSV.js +247 -0
- package/dist/bundle/bun-RXEQKFED.js +169 -0
- package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
- package/dist/bundle/chunk-2BITUXGC.js +12289 -0
- package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
- package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
- package/dist/bundle/chunk-3GVI2MAO.js +106 -0
- package/dist/bundle/chunk-3SZBWBMI.js +131 -0
- package/dist/bundle/chunk-44VSEXW6.js +4054 -0
- package/dist/bundle/chunk-4YPRRQBE.js +95 -0
- package/dist/bundle/chunk-5COYRL5B.js +379 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
- package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
- package/dist/bundle/chunk-762BS35H.js +2787 -0
- package/dist/bundle/chunk-AG64V7AB.js +1233 -0
- package/dist/bundle/chunk-BC5HGIXB.js +334 -0
- package/dist/bundle/chunk-BH7LFEX7.js +36 -0
- package/dist/bundle/chunk-BLNPGY7N.js +53 -0
- package/dist/bundle/chunk-CNIA2LJF.js +372 -0
- package/dist/bundle/chunk-COSXMDC7.js +230 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7FO33KU.js +785 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
- package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
- package/dist/bundle/chunk-DTMSCZDW.js +209 -0
- package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
- package/dist/bundle/chunk-E6YRIHS5.js +92 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-F3DDSZTF.js +78 -0
- package/dist/bundle/chunk-F4WWTQNL.js +188 -0
- package/dist/bundle/chunk-FDDAUASC.js +1028 -0
- package/dist/bundle/chunk-FMNPG6N2.js +170 -0
- package/dist/bundle/chunk-FOKJ4POB.js +274 -0
- package/dist/bundle/chunk-G22C7JG6.js +731 -0
- package/dist/bundle/chunk-GA442SYZ.js +161 -0
- package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
- package/dist/bundle/chunk-GGRKWAOK.js +594 -0
- package/dist/bundle/chunk-HHINRNZA.js +788 -0
- package/dist/bundle/chunk-HUZCL33L.js +128 -0
- package/dist/bundle/chunk-IALSIQVT.js +142 -0
- package/dist/bundle/chunk-IOXR2QBX.js +398 -0
- package/dist/bundle/chunk-J5CXR6VX.js +63 -0
- package/dist/bundle/chunk-J5PWSTOX.js +82 -0
- package/dist/bundle/chunk-J7BVAEHR.js +364 -0
- package/dist/bundle/chunk-JH46HMZW.js +1334 -0
- package/dist/bundle/chunk-JOBO7F6W.js +52 -0
- package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
- package/dist/bundle/chunk-KBIAMDZN.js +66 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-LNHTLSR5.js +288 -0
- package/dist/bundle/chunk-M24RAKMJ.js +58 -0
- package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
- package/dist/bundle/chunk-NQAKARHE.js +54 -0
- package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
- package/dist/bundle/chunk-OQVPE3XK.js +324 -0
- package/dist/bundle/chunk-OR3QG7UR.js +259 -0
- package/dist/bundle/chunk-OUUYVROP.js +76 -0
- package/dist/bundle/chunk-PQBAM64O.js +168 -0
- package/dist/bundle/chunk-PYVIA7WF.js +88 -0
- package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
- package/dist/bundle/chunk-QB3KECV2.js +218 -0
- package/dist/bundle/chunk-QGWXSFYN.js +73 -0
- package/dist/bundle/chunk-RC5QAAAE.js +29 -0
- package/dist/bundle/chunk-RMJ26HLB.js +18 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
- package/dist/bundle/chunk-TRCSMVV5.js +72 -0
- package/dist/bundle/chunk-UD2BQEKA.js +46 -0
- package/dist/bundle/chunk-V4TL55GS.js +1068 -0
- package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
- package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
- package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
- package/dist/bundle/chunk-XDESE3NY.js +44 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
- package/dist/bundle/chunk-ZMJ56GME.js +7 -0
- package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
- package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
- package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
- package/dist/bundle/decode-NUGJIOUW.js +297 -0
- package/dist/bundle/definitions-AILHKEQT.js +2005 -0
- package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
- package/dist/bundle/dist-4I2W6X2I.js +7577 -0
- package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
- package/dist/bundle/embed-ZDXTHHYS.js +38 -0
- package/dist/bundle/embedder-XFEELFUL.js +111 -0
- package/dist/bundle/failure-5S7VPBYK.js +25 -0
- package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
- package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
- package/dist/bundle/instructions-WKSMBUFX.js +11 -0
- package/dist/bundle/mcp-HS2ZDUVR.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-K4U4NYRZ.js +25 -0
- package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
- package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-CM6NC6UE.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
- package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
- package/dist/bundle/oauth-NY4C5UCK.js +20 -0
- package/dist/bundle/open-YNUTA6ZE.js +23 -0
- package/dist/bundle/openai-4CVT5PHH.js +241 -0
- package/dist/bundle/process-2XT3TL27.js +91 -0
- package/dist/bundle/program-FMIVF5T6.js +31904 -0
- package/dist/bundle/prompt-VNWY3H6S.js +17 -0
- package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
- package/dist/bundle/remote-RCLFH4V2.js +32 -0
- package/dist/bundle/rerank-EG6VKYGO.js +52 -0
- package/dist/bundle/schemas-ED2LHKXK.js +645 -0
- package/dist/bundle/serve-AHG25QXB.js +199 -0
- package/dist/bundle/server-5FTB7WM3.js +78 -0
- package/dist/bundle/server-JNZVSAZE.js +209 -0
- package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
- package/dist/bundle/state-XGVAJFF7.js +36 -0
- package/dist/bundle/store-OHSCWZEV.js +177 -0
- package/dist/bundle/store-PKSPKJXL.js +293 -0
- package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
- package/dist/bundle/ydisk.js +183 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +59 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/files.d.ts +3 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +272 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts +13 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +118 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +99 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +80 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +77 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +2001 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +1473 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +127 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +545 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +829 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +10 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +33 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +65 -0
- package/dist/program.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/dist/yandex/source.d.ts +39 -0
- package/dist/yandex/source.d.ts.map +1 -0
- package/dist/yandex/source.js +189 -0
- package/dist/yandex/source.js.map +1 -0
- package/dist/yandex/transport.d.ts +41 -0
- package/dist/yandex/transport.d.ts.map +1 -0
- package/dist/yandex/transport.js +152 -0
- package/dist/yandex/transport.js.map +1 -0
- package/dist/yandex/writes.d.ts +27 -0
- package/dist/yandex/writes.d.ts.map +1 -0
- package/dist/yandex/writes.js +61 -0
- package/dist/yandex/writes.js.map +1 -0
- package/package.json +88 -4
- package/skills/yandex-disk-cli/SKILL.md +46 -0
- package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
- package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
- package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
- package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
- package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
- package/skills/yandex-disk-cli/references/api.md +17 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
require_cross_spawn
|
|
5
|
+
} from "./chunk-D72URWJE.js";
|
|
6
|
+
import {
|
|
7
|
+
BUILT_IN_COMMANDS,
|
|
8
|
+
DESCRIBE_FLAG,
|
|
9
|
+
DESCRIBE_MAX_BYTES,
|
|
10
|
+
FIRST_PARTY_TOOLS,
|
|
11
|
+
PROGRAM_PREFIX,
|
|
12
|
+
TOOL_NAME,
|
|
13
|
+
fileState,
|
|
14
|
+
parseDescribe,
|
|
15
|
+
shimFiles,
|
|
16
|
+
writeShim
|
|
17
|
+
} from "./chunk-MLXQ4X5L.js";
|
|
18
|
+
import "./chunk-Y5E2WNWB.js";
|
|
19
|
+
import {
|
|
20
|
+
CliError
|
|
21
|
+
} from "./chunk-T7ZUDA4C.js";
|
|
22
|
+
import {
|
|
23
|
+
__name,
|
|
24
|
+
__toESM
|
|
25
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/wcat/dispatch.js
|
|
28
|
+
var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
|
|
29
|
+
import { randomUUID } from "node:crypto";
|
|
30
|
+
import { constants } from "node:os";
|
|
31
|
+
|
|
32
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/wcat/path.js
|
|
33
|
+
import { readdirSync, statSync } from "node:fs";
|
|
34
|
+
import { join } from "node:path";
|
|
35
|
+
var variable = /* @__PURE__ */ __name((env, name, platform) => platform === "win32" ? Object.entries(env).find(([key]) => key.toUpperCase() === name)?.[1] : env[name], "variable");
|
|
36
|
+
var pathEntries = /* @__PURE__ */ __name(({ env, platform }) => {
|
|
37
|
+
const raw = variable(env, "PATH", platform) ?? "";
|
|
38
|
+
const entries = raw.split(platform === "win32" ? ";" : ":").map((entry) => entry.replace(/^"(.*)"$/, "$1"));
|
|
39
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40
|
+
return entries.filter((entry) => {
|
|
41
|
+
const key = platform === "win32" ? entry.toLowerCase().replace(/[\\/]+$/, "") : entry.replace(/\/+$/, "");
|
|
42
|
+
if (entry === "" || seen.has(key))
|
|
43
|
+
return false;
|
|
44
|
+
seen.add(key);
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
}, "pathEntries");
|
|
48
|
+
var programExtensions = /* @__PURE__ */ __name(({ env, platform }) => platform === "win32" ? (variable(env, "PATHEXT", platform) ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext)).map((ext) => ext.toLowerCase()) : [""], "programExtensions");
|
|
49
|
+
var isProgram = /* @__PURE__ */ __name((path, platform) => {
|
|
50
|
+
try {
|
|
51
|
+
const stat = statSync(path);
|
|
52
|
+
return stat.isFile() && (platform === "win32" || (stat.mode & 73) !== 0);
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}, "isProgram");
|
|
57
|
+
var findOnPath = /* @__PURE__ */ __name((command, search) => {
|
|
58
|
+
const extensions = programExtensions(search);
|
|
59
|
+
return pathEntries(search).flatMap((dir) => {
|
|
60
|
+
for (const extension of extensions) {
|
|
61
|
+
const path = join(dir, command + extension);
|
|
62
|
+
if (isProgram(path, search.platform))
|
|
63
|
+
return [path];
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
});
|
|
67
|
+
}, "findOnPath");
|
|
68
|
+
var findTools = /* @__PURE__ */ __name((search) => {
|
|
69
|
+
const extensions = programExtensions(search);
|
|
70
|
+
const tools = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const dir of pathEntries(search)) {
|
|
72
|
+
let files;
|
|
73
|
+
try {
|
|
74
|
+
files = readdirSync(dir);
|
|
75
|
+
} catch {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const here = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const file of files) {
|
|
80
|
+
if (!(search.platform === "win32" ? file.toLowerCase() : file).startsWith(PROGRAM_PREFIX))
|
|
81
|
+
continue;
|
|
82
|
+
const extension = extensions.find((ext) => ext !== "" && file.toLowerCase().endsWith(ext)) ?? "";
|
|
83
|
+
if (search.platform === "win32" && extension === "")
|
|
84
|
+
continue;
|
|
85
|
+
const base = search.platform === "win32" ? file.toLowerCase() : file;
|
|
86
|
+
const name = base.slice(PROGRAM_PREFIX.length, base.length - extension.length);
|
|
87
|
+
if (!TOOL_NAME.test(name))
|
|
88
|
+
continue;
|
|
89
|
+
const best = here.get(name);
|
|
90
|
+
const rank = /* @__PURE__ */ __name((path2) => extensions.findIndex((ext) => path2.toLowerCase().endsWith(ext)), "rank");
|
|
91
|
+
const path = join(dir, file);
|
|
92
|
+
if (best !== void 0 && rank(best) <= rank(path))
|
|
93
|
+
continue;
|
|
94
|
+
if (isProgram(path, search.platform))
|
|
95
|
+
here.set(name, path);
|
|
96
|
+
}
|
|
97
|
+
for (const [name, path] of here)
|
|
98
|
+
tools.set(name, [...tools.get(name) ?? [], path]);
|
|
99
|
+
}
|
|
100
|
+
return new Map([...tools].sort(([a], [b]) => a < b ? -1 : 1));
|
|
101
|
+
}, "findTools");
|
|
102
|
+
var isBuiltIn = /* @__PURE__ */ __name((name) => name === "wcat" || BUILT_IN_COMMANDS.includes(name), "isBuiltIn");
|
|
103
|
+
|
|
104
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/wcat/probe.js
|
|
105
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
106
|
+
import { readFileSync } from "node:fs";
|
|
107
|
+
var probeDescribe = /* @__PURE__ */ __name((path, { env, timeoutMs }) => new Promise((resolve) => {
|
|
108
|
+
let child;
|
|
109
|
+
try {
|
|
110
|
+
child = (0, import_cross_spawn.default)(path, [DESCRIBE_FLAG], { stdio: ["ignore", "pipe", "ignore"], env, windowsHide: true });
|
|
111
|
+
} catch {
|
|
112
|
+
resolve(void 0);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const chunks = [];
|
|
116
|
+
let size = 0;
|
|
117
|
+
let settled = false;
|
|
118
|
+
const settle = /* @__PURE__ */ __name((answer) => {
|
|
119
|
+
if (settled)
|
|
120
|
+
return;
|
|
121
|
+
settled = true;
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
resolve(answer);
|
|
124
|
+
}, "settle");
|
|
125
|
+
const giveUp = /* @__PURE__ */ __name(() => {
|
|
126
|
+
child.kill();
|
|
127
|
+
child.stdout?.destroy();
|
|
128
|
+
child.unref();
|
|
129
|
+
settle(void 0);
|
|
130
|
+
}, "giveUp");
|
|
131
|
+
const timer = setTimeout(giveUp, timeoutMs);
|
|
132
|
+
child.stdout?.on("data", (chunk) => {
|
|
133
|
+
size += chunk.length;
|
|
134
|
+
if (size > DESCRIBE_MAX_BYTES)
|
|
135
|
+
giveUp();
|
|
136
|
+
else
|
|
137
|
+
chunks.push(chunk);
|
|
138
|
+
});
|
|
139
|
+
child.once("error", () => settle(void 0));
|
|
140
|
+
child.once("close", (code) => settle(code === 0 ? parseDescribe(Buffer.concat(chunks).toString("utf8")) : void 0));
|
|
141
|
+
}), "probeDescribe");
|
|
142
|
+
var baseVersion = /* @__PURE__ */ __name(() => {
|
|
143
|
+
try {
|
|
144
|
+
const raw = readFileSync(new URL("../../package.json", new URL("wcat/probe.js", import.meta.resolve("@wirecat/cli-base")).href), "utf8");
|
|
145
|
+
const { name, version } = JSON.parse(raw);
|
|
146
|
+
return name === "@wirecat/cli-base" && typeof version === "string" ? version : "unknown";
|
|
147
|
+
} catch {
|
|
148
|
+
return "unknown";
|
|
149
|
+
}
|
|
150
|
+
}, "baseVersion");
|
|
151
|
+
|
|
152
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/wcat/shortcuts.js
|
|
153
|
+
import { closeSync, openSync, readSync, realpathSync, rmSync } from "node:fs";
|
|
154
|
+
import { basename, dirname } from "node:path";
|
|
155
|
+
var WIRECAT_PACKAGE = /node_modules[\\/]+@wirecat[\\/]/;
|
|
156
|
+
var isWirecatPackage = /* @__PURE__ */ __name((path) => {
|
|
157
|
+
try {
|
|
158
|
+
if (WIRECAT_PACKAGE.test(realpathSync(path)))
|
|
159
|
+
return true;
|
|
160
|
+
const buffer = Buffer.alloc(16 * 1024);
|
|
161
|
+
const fd = openSync(path, "r");
|
|
162
|
+
try {
|
|
163
|
+
const read = readSync(fd, buffer, 0, buffer.length, 0);
|
|
164
|
+
return WIRECAT_PACKAGE.test(buffer.subarray(0, read).toString("latin1"));
|
|
165
|
+
} finally {
|
|
166
|
+
closeSync(fd);
|
|
167
|
+
}
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}, "isWirecatPackage");
|
|
172
|
+
var ourShortcut = /* @__PURE__ */ __name((path) => {
|
|
173
|
+
const state = fileState(path);
|
|
174
|
+
return state.state === "ours" && state.mark.kind === "shortcut";
|
|
175
|
+
}, "ourShortcut");
|
|
176
|
+
var statusOf = /* @__PURE__ */ __name((name, program, search) => {
|
|
177
|
+
const files = shimFiles("shortcut", {
|
|
178
|
+
dir: dirname(program),
|
|
179
|
+
name,
|
|
180
|
+
target: basename(program),
|
|
181
|
+
platform: search.platform
|
|
182
|
+
});
|
|
183
|
+
const named = findOnPath(name, search);
|
|
184
|
+
const made = [...files.map((file) => file.path), ...named].find(ourShortcut);
|
|
185
|
+
if (made)
|
|
186
|
+
return { name, status: "made", path: made, program };
|
|
187
|
+
const first = named[0];
|
|
188
|
+
if (first === void 0)
|
|
189
|
+
return { name, status: "free", program };
|
|
190
|
+
return { name, status: isWirecatPackage(first) ? "package" : "taken", path: first, program };
|
|
191
|
+
}, "statusOf");
|
|
192
|
+
var changeFile = /* @__PURE__ */ __name((path, change) => {
|
|
193
|
+
try {
|
|
194
|
+
change();
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throw new CliError("permission_error", `could not change ${path}: ${error.code ?? error}`, {
|
|
197
|
+
reason: "access.denied"
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}, "changeFile");
|
|
201
|
+
var installedPrograms = /* @__PURE__ */ __name((search) => new Map([...findTools(search)].filter(([name]) => !isBuiltIn(name))), "installedPrograms");
|
|
202
|
+
var chosen = /* @__PURE__ */ __name((names, search) => {
|
|
203
|
+
const installed = installedPrograms(search);
|
|
204
|
+
if (names === void 0 || names.length === 0)
|
|
205
|
+
return [...installed].map(([name, paths]) => [name, paths[0]]);
|
|
206
|
+
const missing = names.filter((name) => !installed.has(name));
|
|
207
|
+
if (missing.length > 0)
|
|
208
|
+
throw new CliError("not_found", `not installed: ${missing.map((name) => `wcat-${name}`).join(", ")}`, {
|
|
209
|
+
reason: "tool.not-installed",
|
|
210
|
+
tool: missing[0],
|
|
211
|
+
installed: [...installed.keys()]
|
|
212
|
+
});
|
|
213
|
+
return [...new Set(names)].map((name) => [name, installed.get(name)[0]]);
|
|
214
|
+
}, "chosen");
|
|
215
|
+
var listShortcuts = /* @__PURE__ */ __name((search, names) => chosen(names, search).map(([name, program]) => statusOf(name, program, search)), "listShortcuts");
|
|
216
|
+
var addShortcuts = /* @__PURE__ */ __name((search, names) => listShortcuts(search, names).map((shortcut) => {
|
|
217
|
+
if (shortcut.status !== "free")
|
|
218
|
+
return { ...shortcut, changed: false };
|
|
219
|
+
const files = shimFiles("shortcut", {
|
|
220
|
+
dir: dirname(shortcut.program),
|
|
221
|
+
name: shortcut.name,
|
|
222
|
+
target: basename(shortcut.program),
|
|
223
|
+
platform: search.platform
|
|
224
|
+
});
|
|
225
|
+
for (const file of files)
|
|
226
|
+
changeFile(file.path, () => writeShim(file));
|
|
227
|
+
return { ...shortcut, status: "made", path: files[0]?.path, changed: true };
|
|
228
|
+
}), "addShortcuts");
|
|
229
|
+
var removeShortcuts = /* @__PURE__ */ __name((search, names) => listShortcuts(search, names).map((shortcut) => {
|
|
230
|
+
if (shortcut.status !== "made")
|
|
231
|
+
return { ...shortcut, changed: false };
|
|
232
|
+
const files = shimFiles("shortcut", {
|
|
233
|
+
dir: dirname(shortcut.path),
|
|
234
|
+
name: shortcut.name,
|
|
235
|
+
target: basename(shortcut.program),
|
|
236
|
+
platform: search.platform
|
|
237
|
+
});
|
|
238
|
+
for (const file of files)
|
|
239
|
+
if (ourShortcut(file.path))
|
|
240
|
+
changeFile(file.path, () => rmSync(file.path, { force: true }));
|
|
241
|
+
return { ...statusOf(shortcut.name, shortcut.program, search), changed: true };
|
|
242
|
+
}), "removeShortcuts");
|
|
243
|
+
|
|
244
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/wcat/dispatch.js
|
|
245
|
+
var DEFAULT_DESCRIBE_TIMEOUT_MS = 2e3;
|
|
246
|
+
var listTools = /* @__PURE__ */ __name(async (context) => {
|
|
247
|
+
const installed = installedPrograms(context);
|
|
248
|
+
const timeoutMs = context.describeTimeoutMs ?? DEFAULT_DESCRIBE_TIMEOUT_MS;
|
|
249
|
+
const found = await Promise.all([...installed].map(async ([name, paths]) => {
|
|
250
|
+
const [path, ...shadowed] = paths;
|
|
251
|
+
const own = context.self?.command === name ? context.self : void 0;
|
|
252
|
+
const described = own ?? await probeDescribe(path, { env: context.env, timeoutMs });
|
|
253
|
+
return {
|
|
254
|
+
name,
|
|
255
|
+
installed: true,
|
|
256
|
+
path,
|
|
257
|
+
...described?.version ? { version: described.version } : {},
|
|
258
|
+
...described?.description ? { description: described.description } : {},
|
|
259
|
+
...described?.docs ? { docs_url: described.docs } : {},
|
|
260
|
+
...shadowed.length > 0 ? { shadowed } : {}
|
|
261
|
+
};
|
|
262
|
+
}));
|
|
263
|
+
const missing = FIRST_PARTY_TOOLS.filter((tool) => tool.package && !installed.has(tool.name)).map((tool) => ({
|
|
264
|
+
name: tool.name,
|
|
265
|
+
installed: false,
|
|
266
|
+
package: tool.package,
|
|
267
|
+
install: `npm install -g ${tool.package}`
|
|
268
|
+
}));
|
|
269
|
+
return [...found, ...missing];
|
|
270
|
+
}, "listTools");
|
|
271
|
+
var envelope = /* @__PURE__ */ __name((items, started) => ({
|
|
272
|
+
items,
|
|
273
|
+
page: { mode: "page", limit: Math.max(items.length, 1), has_more: false },
|
|
274
|
+
meta: { run_id: randomUUID(), duration_ms: Math.max(0, Math.round(performance.now() - started)), complete: true }
|
|
275
|
+
}), "envelope");
|
|
276
|
+
var column = /* @__PURE__ */ __name((rows) => {
|
|
277
|
+
const widths = rows[0]?.map((_, at) => rows.reduce((wide, row) => Math.max(wide, (row[at] ?? "").length), 0)) ?? [];
|
|
278
|
+
return rows.map((row) => ` ${row.map((cell, at) => cell.padEnd(widths[at] ?? 0)).join(" ")}`.trimEnd());
|
|
279
|
+
}, "column");
|
|
280
|
+
var USAGE = [
|
|
281
|
+
"wcat <tool> [arguments] run a tool: wcat tg --help",
|
|
282
|
+
"wcat shortcuts [add|remove] [tool...] short names, such as tg, for installed tools",
|
|
283
|
+
"wcat --json the list below as JSON"
|
|
284
|
+
];
|
|
285
|
+
var listText = /* @__PURE__ */ __name((tools) => {
|
|
286
|
+
const installed = tools.filter((tool) => tool.installed);
|
|
287
|
+
const missing = tools.filter((tool) => !tool.installed);
|
|
288
|
+
return [
|
|
289
|
+
"wcat runs WireCat tools, and any other wcat-<name> program on PATH.",
|
|
290
|
+
"",
|
|
291
|
+
...USAGE,
|
|
292
|
+
"",
|
|
293
|
+
installed.length > 0 ? "Installed:" : "Installed: none",
|
|
294
|
+
...column(installed.map((tool) => [tool.name, tool.version ?? "", tool.description ?? "(no description)"])),
|
|
295
|
+
...missing.length > 0 ? ["", "Not installed:", ...column(missing.map((tool) => [tool.name, tool.install ?? ""]))] : [],
|
|
296
|
+
""
|
|
297
|
+
].join("\n");
|
|
298
|
+
}, "listText");
|
|
299
|
+
var shadowWarnings = /* @__PURE__ */ __name((tools) => tools.filter((tool) => tool.shadowed).map((tool) => `wcat: ${(tool.shadowed?.length ?? 0) + 1} programs are named ${PROGRAM_PREFIX}${tool.name}; wcat runs the first:
|
|
300
|
+
${[tool.path, ...tool.shadowed ?? []].map((path) => ` ${path}`).join("\n")}
|
|
301
|
+
`).join(""), "shadowWarnings");
|
|
302
|
+
var shortcutText = /* @__PURE__ */ __name((shortcuts2) => {
|
|
303
|
+
if (shortcuts2.length === 0)
|
|
304
|
+
return "No wcat-<name> programs are installed.\n";
|
|
305
|
+
const said = /* @__PURE__ */ __name((shortcut) => {
|
|
306
|
+
switch (shortcut.status) {
|
|
307
|
+
case "made":
|
|
308
|
+
return `made: ${shortcut.path}`;
|
|
309
|
+
case "free":
|
|
310
|
+
return shortcut.changed ? "removed" : "free: wcat shortcuts add makes it";
|
|
311
|
+
case "package":
|
|
312
|
+
return `installed by the package: ${shortcut.path}`;
|
|
313
|
+
case "taken":
|
|
314
|
+
return `taken by ${shortcut.path}`;
|
|
315
|
+
}
|
|
316
|
+
}, "said");
|
|
317
|
+
return `${column(shortcuts2.map((shortcut) => [shortcut.name, said(shortcut)])).join("\n")}
|
|
318
|
+
`;
|
|
319
|
+
}, "shortcutText");
|
|
320
|
+
var signalNumber = /* @__PURE__ */ __name((signal) => constants.signals[signal] ?? 1, "signalNumber");
|
|
321
|
+
var runTool = /* @__PURE__ */ __name((path, args, context) => new Promise((resolve, reject) => {
|
|
322
|
+
const signals = context.signals ?? process;
|
|
323
|
+
const child = (0, import_cross_spawn2.default)(path, [...args], { stdio: "inherit", env: context.env });
|
|
324
|
+
const pass = /* @__PURE__ */ __name((signal) => () => child.kill(signal), "pass");
|
|
325
|
+
const term = pass("SIGTERM");
|
|
326
|
+
const hup = pass("SIGHUP");
|
|
327
|
+
const ignore = /* @__PURE__ */ __name(() => {
|
|
328
|
+
}, "ignore");
|
|
329
|
+
signals.on("SIGTERM", term).on("SIGHUP", hup).on("SIGINT", ignore);
|
|
330
|
+
const done = /* @__PURE__ */ __name(() => signals.off("SIGTERM", term).off("SIGHUP", hup).off("SIGINT", ignore), "done");
|
|
331
|
+
child.once("error", (error) => {
|
|
332
|
+
done();
|
|
333
|
+
reject(new CliError("configuration_error", `could not start ${path}: ${error.message}`));
|
|
334
|
+
});
|
|
335
|
+
child.once("exit", (code, signal) => {
|
|
336
|
+
done();
|
|
337
|
+
resolve(code ?? (signal ? 128 + signalNumber(signal) : 1));
|
|
338
|
+
});
|
|
339
|
+
}), "runTool");
|
|
340
|
+
var fail = /* @__PURE__ */ __name(async (error, json, context) => {
|
|
341
|
+
const { errorObjectOf, exitCodeOfError, renderError } = await import("./failure-5S7VPBYK.js");
|
|
342
|
+
const object = errorObjectOf(error);
|
|
343
|
+
context.stderr.write(`${renderError(object, { cli: "wcat", interactive: !json })}
|
|
344
|
+
`);
|
|
345
|
+
return exitCodeOfError(object);
|
|
346
|
+
}, "fail");
|
|
347
|
+
var shortcuts = /* @__PURE__ */ __name(async (args, json, context) => {
|
|
348
|
+
const [action, ...names] = args;
|
|
349
|
+
const started = performance.now();
|
|
350
|
+
const result = action === "add" ? addShortcuts(context, names) : action === "remove" ? removeShortcuts(context, names) : action === void 0 || action === "list" ? listShortcuts(context, names) : void 0;
|
|
351
|
+
if (result === void 0)
|
|
352
|
+
throw new CliError("validation_error", `wcat shortcuts takes list, add or remove, not "${action}"`, {
|
|
353
|
+
reason: "input.invalid"
|
|
354
|
+
});
|
|
355
|
+
context.stdout.write(json ? `${JSON.stringify(envelope(result, started))}
|
|
356
|
+
` : shortcutText(result));
|
|
357
|
+
return 0;
|
|
358
|
+
}, "shortcuts");
|
|
359
|
+
var runWcat = /* @__PURE__ */ __name(async (args, context) => {
|
|
360
|
+
const [first, ...rest] = args;
|
|
361
|
+
const json = args.includes("--json");
|
|
362
|
+
const words = args.filter((word) => word !== "--json");
|
|
363
|
+
const started = performance.now();
|
|
364
|
+
try {
|
|
365
|
+
if (first === "--version" || first === "-V" || first === "version") {
|
|
366
|
+
const tools = await listTools(context);
|
|
367
|
+
const by = context.self ? `, run by ${PROGRAM_PREFIX}${context.self.command} ${context.self.version}` : "";
|
|
368
|
+
context.stdout.write(`wcat ${baseVersion()} (@wirecat/cli-base${by})
|
|
369
|
+
|
|
370
|
+
${listText(tools)}`);
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
if (words.length === 0 || first === "--help" || first === "-h" || first === "help") {
|
|
374
|
+
const tools = await listTools(context);
|
|
375
|
+
if (json)
|
|
376
|
+
context.stdout.write(`${JSON.stringify(envelope(tools, started))}
|
|
377
|
+
`);
|
|
378
|
+
else {
|
|
379
|
+
context.stderr.write(shadowWarnings(tools));
|
|
380
|
+
context.stdout.write(listText(tools));
|
|
381
|
+
}
|
|
382
|
+
return 0;
|
|
383
|
+
}
|
|
384
|
+
if (first === "shortcuts")
|
|
385
|
+
return await shortcuts(words.slice(1), json, context);
|
|
386
|
+
if (BUILT_IN_COMMANDS.includes(first))
|
|
387
|
+
throw new CliError("validation_error", `wcat ${first} is reserved for a later version of wcat`, {
|
|
388
|
+
reason: "input.invalid"
|
|
389
|
+
});
|
|
390
|
+
if (first?.startsWith("-"))
|
|
391
|
+
throw new CliError("validation_error", `wcat does not take ${first} before a tool's name`, {
|
|
392
|
+
reason: "input.invalid"
|
|
393
|
+
});
|
|
394
|
+
const name = first;
|
|
395
|
+
const [path, ...shadowed] = TOOL_NAME.test(name) ? findOnPath(`${PROGRAM_PREFIX}${name}`, context) : [];
|
|
396
|
+
if (path === void 0) {
|
|
397
|
+
const installed = [...installedPrograms(context).keys()];
|
|
398
|
+
throw new CliError("not_found", `no ${PROGRAM_PREFIX}${name} on PATH; installed: ${installed.length > 0 ? installed.join(", ") : "none"}`, { reason: "tool.not-installed", tool: name, installed });
|
|
399
|
+
}
|
|
400
|
+
if (shadowed.length > 0 && context.stderr.isTTY)
|
|
401
|
+
context.stderr.write(shadowWarnings([{ name, installed: true, path, shadowed }]));
|
|
402
|
+
return await runTool(path, rest, context);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
return fail(error, json, context);
|
|
405
|
+
}
|
|
406
|
+
}, "runWcat");
|
|
407
|
+
export {
|
|
408
|
+
listTools,
|
|
409
|
+
runTool,
|
|
410
|
+
runWcat
|
|
411
|
+
};
|