@wirecat/attio-cli 0.8.0 → 0.10.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.
Files changed (207) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/contracts/wirecat.json +1 -0
  3. package/dist/bin/attio.js +11 -11
  4. package/dist/bundle/attio.js +5 -166
  5. package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
  6. package/dist/bundle/chunk-TQAECZFO.js +13 -0
  7. package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
  8. package/dist/bundle/program-NSBWZ25F.js +6201 -0
  9. package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
  10. package/dist/commands/api.js +1 -2
  11. package/dist/commands/crm.js +1 -4
  12. package/dist/commands/schedule.js +1 -1
  13. package/dist/commands/session.js +1 -2
  14. package/dist/config.js +1 -2
  15. package/dist/context.js +1 -1
  16. package/dist/identity.js +1 -0
  17. package/dist/program.js +1 -2
  18. package/dist/version.js +1 -1
  19. package/package.json +4 -4
  20. package/dist/activities.d.ts +0 -4
  21. package/dist/activities.d.ts.map +0 -1
  22. package/dist/activities.js.map +0 -1
  23. package/dist/bin/attio.d.ts +0 -3
  24. package/dist/bin/attio.d.ts.map +0 -1
  25. package/dist/bin/attio.js.map +0 -1
  26. package/dist/bundle/agent-GUXXSLT5.js +0 -38
  27. package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
  28. package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
  29. package/dist/bundle/app-server-EXNGTHWO.js +0 -250
  30. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  31. package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
  32. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  33. package/dist/bundle/chunk-2QDUP74I.js +0 -794
  34. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  35. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  36. package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
  37. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  38. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  39. package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
  40. package/dist/bundle/chunk-4RSWOPKL.js +0 -323
  41. package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
  42. package/dist/bundle/chunk-5N2V6XO7.js +0 -119
  43. package/dist/bundle/chunk-5WD22IXQ.js +0 -66
  44. package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
  45. package/dist/bundle/chunk-6TD3DCWC.js +0 -106
  46. package/dist/bundle/chunk-7Z53MLQP.js +0 -388
  47. package/dist/bundle/chunk-AATTOFNY.js +0 -2045
  48. package/dist/bundle/chunk-APARYILG.js +0 -743
  49. package/dist/bundle/chunk-D72URWJE.js +0 -532
  50. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  51. package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
  52. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  53. package/dist/bundle/chunk-DPD4FMHN.js +0 -388
  54. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  55. package/dist/bundle/chunk-DURNR4RO.js +0 -353
  56. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  57. package/dist/bundle/chunk-EVUMQKV7.js +0 -76
  58. package/dist/bundle/chunk-EY36BTKZ.js +0 -108
  59. package/dist/bundle/chunk-FH6OEGGN.js +0 -557
  60. package/dist/bundle/chunk-FOP6G45D.js +0 -358
  61. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  62. package/dist/bundle/chunk-GTEX4IUO.js +0 -334
  63. package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
  64. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  65. package/dist/bundle/chunk-J6GVVISK.js +0 -185
  66. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  67. package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
  68. package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
  69. package/dist/bundle/chunk-L45WN3AR.js +0 -80
  70. package/dist/bundle/chunk-L72WUJAS.js +0 -54
  71. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  72. package/dist/bundle/chunk-LM3W7YOM.js +0 -274
  73. package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
  74. package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
  75. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  76. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  77. package/dist/bundle/chunk-OYEVYOCL.js +0 -259
  78. package/dist/bundle/chunk-P7G5HFY3.js +0 -288
  79. package/dist/bundle/chunk-PAEKXVJW.js +0 -188
  80. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  81. package/dist/bundle/chunk-PLPBEWD4.js +0 -170
  82. package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
  83. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  84. package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
  85. package/dist/bundle/chunk-QSJKSPWF.js +0 -131
  86. package/dist/bundle/chunk-RDVTHFPP.js +0 -338
  87. package/dist/bundle/chunk-RQORQN2V.js +0 -4072
  88. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  89. package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
  90. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  91. package/dist/bundle/chunk-SCI7QEHF.js +0 -362
  92. package/dist/bundle/chunk-SSA6JBPA.js +0 -778
  93. package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
  94. package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
  95. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  96. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  97. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  98. package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
  99. package/dist/bundle/chunk-V57E7PJQ.js +0 -161
  100. package/dist/bundle/chunk-V7IF2K3P.js +0 -52
  101. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  102. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  103. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  104. package/dist/bundle/chunk-WXQGA6XK.js +0 -50
  105. package/dist/bundle/chunk-XQGN2D44.js +0 -86
  106. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  107. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  108. package/dist/bundle/chunk-YNGU36GW.js +0 -218
  109. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  110. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  111. package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
  112. package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
  113. package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
  114. package/dist/bundle/decode-26M7XE2B.js +0 -297
  115. package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
  116. package/dist/bundle/dist-EM7KLEG4.js +0 -7577
  117. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  118. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  119. package/dist/bundle/embed-XJLEAWXE.js +0 -38
  120. package/dist/bundle/embedder-OEL6PXEH.js +0 -111
  121. package/dist/bundle/failure-OHIXWTR6.js +0 -25
  122. package/dist/bundle/first-run-CIXGBXY6.js +0 -29
  123. package/dist/bundle/first-screen-5FK4D45F.js +0 -38
  124. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  125. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  126. package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
  127. package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
  128. package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
  129. package/dist/bundle/node-EGMCBAO7.js +0 -176
  130. package/dist/bundle/node-KM3CUABH.js +0 -2340
  131. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  132. package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
  133. package/dist/bundle/oauth-V5LGTXF2.js +0 -20
  134. package/dist/bundle/open-25EKOTZA.js +0 -23
  135. package/dist/bundle/openai-VX3OLIHM.js +0 -238
  136. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  137. package/dist/bundle/program-Z5NUNXME.js +0 -34214
  138. package/dist/bundle/prompt-2VSPX5S7.js +0 -17
  139. package/dist/bundle/recognize-NA5XUFKK.js +0 -26
  140. package/dist/bundle/remote-BOME6XOE.js +0 -31
  141. package/dist/bundle/rerank-NG3XMFCV.js +0 -52
  142. package/dist/bundle/serve-MR67OBED.js +0 -199
  143. package/dist/bundle/server-4BWAGJQO.js +0 -80
  144. package/dist/bundle/server-OP2HJNXD.js +0 -213
  145. package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
  146. package/dist/bundle/state-L4MWAATO.js +0 -36
  147. package/dist/bundle/store-2ALTEH55.js +0 -181
  148. package/dist/bundle/store-CXZFRG5D.js +0 -297
  149. package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
  150. package/dist/bundle/surface-3GRJ7473.js +0 -66
  151. package/dist/commands/api.d.ts +0 -12
  152. package/dist/commands/api.d.ts.map +0 -1
  153. package/dist/commands/api.js.map +0 -1
  154. package/dist/commands/crm.d.ts +0 -7
  155. package/dist/commands/crm.d.ts.map +0 -1
  156. package/dist/commands/crm.js.map +0 -1
  157. package/dist/commands/schedule.d.ts +0 -3
  158. package/dist/commands/schedule.d.ts.map +0 -1
  159. package/dist/commands/schedule.js.map +0 -1
  160. package/dist/commands/session.d.ts +0 -8
  161. package/dist/commands/session.d.ts.map +0 -1
  162. package/dist/commands/session.js.map +0 -1
  163. package/dist/config.d.ts +0 -13
  164. package/dist/config.d.ts.map +0 -1
  165. package/dist/config.js.map +0 -1
  166. package/dist/context.d.ts +0 -37
  167. package/dist/context.d.ts.map +0 -1
  168. package/dist/context.js.map +0 -1
  169. package/dist/generated/definitions.d.ts +0 -3
  170. package/dist/generated/definitions.d.ts.map +0 -1
  171. package/dist/generated/definitions.js.map +0 -1
  172. package/dist/generated/manifest.d.ts +0 -6
  173. package/dist/generated/manifest.d.ts.map +0 -1
  174. package/dist/generated/manifest.js.map +0 -1
  175. package/dist/generated/schemas.d.ts +0 -383
  176. package/dist/generated/schemas.d.ts.map +0 -1
  177. package/dist/generated/schemas.js.map +0 -1
  178. package/dist/generated/types.d.ts +0 -10166
  179. package/dist/generated/types.d.ts.map +0 -1
  180. package/dist/generated/types.js.map +0 -1
  181. package/dist/generated/wirecat-config.d.ts +0 -15
  182. package/dist/generated/wirecat-config.d.ts.map +0 -1
  183. package/dist/generated/wirecat-config.js.map +0 -1
  184. package/dist/hooks.d.ts +0 -33
  185. package/dist/hooks.d.ts.map +0 -1
  186. package/dist/hooks.js.map +0 -1
  187. package/dist/identity.d.ts +0 -33
  188. package/dist/identity.d.ts.map +0 -1
  189. package/dist/identity.js.map +0 -1
  190. package/dist/index.d.ts +0 -3
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/links.d.ts +0 -10
  194. package/dist/links.d.ts.map +0 -1
  195. package/dist/links.js.map +0 -1
  196. package/dist/meetings.d.ts +0 -57
  197. package/dist/meetings.d.ts.map +0 -1
  198. package/dist/meetings.js.map +0 -1
  199. package/dist/program.d.ts +0 -6
  200. package/dist/program.d.ts.map +0 -1
  201. package/dist/program.js.map +0 -1
  202. package/dist/version.d.ts +0 -2
  203. package/dist/version.d.ts.map +0 -1
  204. package/dist/version.js.map +0 -1
  205. package/dist/wcat.d.ts +0 -3
  206. package/dist/wcat.d.ts.map +0 -1
  207. package/dist/wcat.js.map +0 -1
@@ -1,411 +0,0 @@
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-DPV53EZC.js";
18
- import "./chunk-Y5E2WNWB.js";
19
- import {
20
- CliError
21
- } from "./chunk-S6JG4YUH.js";
22
- import {
23
- __name,
24
- __toESM
25
- } from "./chunk-ZVVMGPBJ.js";
26
-
27
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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-OHIXWTR6.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
- };