@conveno/cli 0.2.0-rc.1 → 0.2.0-rc.11

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.
@@ -0,0 +1,361 @@
1
+ import { parseArgs } from "node:util";
2
+ import { a as fail, n as cmd, t as closest } from "./fmt-C2SsP5Y0.js";
3
+ // src/args.ts
4
+ const SETUP_FLAGS = {
5
+ yes: {
6
+ type: "boolean",
7
+ short: "y",
8
+ help: "Apply without asking"
9
+ },
10
+ "dry-run": {
11
+ type: "boolean",
12
+ help: "Show the changes and write nothing"
13
+ },
14
+ cli: {
15
+ type: "string",
16
+ value: "<list>",
17
+ help: "Only these AI tools, separated by commas or spaces, such as claude,codex"
18
+ },
19
+ accept: {
20
+ type: "string",
21
+ value: "<ids>",
22
+ help: "Say yes to these extras without asking, such as codex-trust-hooks"
23
+ },
24
+ "acp-adapters": {
25
+ type: "boolean",
26
+ help: "Let ACP workers fetch the Codex and Claude adapters with npx, without asking"
27
+ },
28
+ "no-acp-adapters": {
29
+ type: "boolean",
30
+ help: "Do not let ACP workers fetch adapters; print how to install them"
31
+ }
32
+ };
33
+ const COMMANDS = [
34
+ {
35
+ name: "setup",
36
+ usage: "conveno setup [--yes] [--dry-run] [--cli <list>] [--lead <cli>]",
37
+ summary: "Connect Conveno to your AI tools",
38
+ flags: {
39
+ ...SETUP_FLAGS,
40
+ lead: {
41
+ type: "string",
42
+ value: "<cli>",
43
+ help: "The AI tool that should lead when it starts, such as claude"
44
+ }
45
+ },
46
+ notes: [
47
+ "In a terminal, setup walks you through it. With --yes, or without a terminal, it applies the changes without a walk-through.",
48
+ "Setup shows every file it will change and asks first. Without a terminal it needs --yes, and exits 2 without it.",
49
+ "Approving Conveno inside Codex and Antigravity is asked as yes/no, default yes. Extras default no. --yes takes the defaults; --accept <ids> says yes to only those.",
50
+ "Undo any time with conveno uninstall."
51
+ ]
52
+ },
53
+ {
54
+ name: "init",
55
+ usage: "conveno init [--yes] [--dry-run] [--cli <list>] [--acp-adapters | --no-acp-adapters]",
56
+ summary: "Set up every supported AI tool that is installed",
57
+ flags: SETUP_FLAGS,
58
+ notes: [
59
+ "init is the older name for setup. It shows every file it will change, with a diff, and asks first.",
60
+ "Without a terminal it needs --yes, and exits 2 without it.",
61
+ "Approving Conveno inside Codex and Antigravity is asked as yes/no, default yes. Other optional setups default no. --yes takes the defaults; --accept <ids> says yes to only those.",
62
+ "When Codex or Claude Code is installed without its ACP adapter, init asks once whether npx may fetch it (third-party npm packages, pinned versions). The answer is kept; the two adapter flags change it."
63
+ ],
64
+ hidden: true
65
+ },
66
+ {
67
+ name: "uninstall",
68
+ usage: "conveno uninstall [--yes]",
69
+ summary: "Remove Conveno from your AI tools",
70
+ flags: { yes: {
71
+ type: "boolean",
72
+ short: "y",
73
+ help: "Go ahead without asking"
74
+ } },
75
+ notes: [
76
+ "Stops Conveno's background service first, then puts your AI tools back the way they were.",
77
+ "Files that are still as setup left them are restored exactly.",
78
+ "Files you or the AI tool changed since lose only Conveno's own entries."
79
+ ]
80
+ },
81
+ {
82
+ name: "status",
83
+ usage: "conveno status",
84
+ summary: "See which AI sessions are running",
85
+ flags: {}
86
+ },
87
+ {
88
+ name: "send",
89
+ usage: "conveno send <to> <text...> [--urgent]",
90
+ summary: "Send a message to a running session",
91
+ flags: { urgent: {
92
+ type: "boolean",
93
+ help: "Mark the message urgent"
94
+ } },
95
+ notes: [
96
+ "<to> is a session name or id, lead, or device:name for a session on another device.",
97
+ "Give - as the text to read it from standard input.",
98
+ "The session sees the message as coming from you."
99
+ ],
100
+ positionals: true
101
+ },
102
+ {
103
+ name: "rename",
104
+ usage: "conveno rename <session> <new-name>",
105
+ summary: "Give an online session a new name",
106
+ flags: {},
107
+ notes: ["<session> is a name or id. Names use lowercase letters, digits and . _ @ -."],
108
+ positionals: true,
109
+ hidden: true
110
+ },
111
+ {
112
+ name: "lead",
113
+ usage: "conveno lead <session> | conveno lead --clear",
114
+ summary: "Make a session the lead, or clear the lead",
115
+ flags: { clear: {
116
+ type: "boolean",
117
+ help: "Make no session the lead"
118
+ } },
119
+ notes: [
120
+ "The lead gets the messages sent to lead.",
121
+ "<session> is a name or id. The old lead is told.",
122
+ "--clear leaves no lead."
123
+ ],
124
+ positionals: true,
125
+ hidden: true
126
+ },
127
+ {
128
+ name: "spawn",
129
+ usage: "conveno spawn <cli> [options]",
130
+ summary: "Start a worker session of any CLI",
131
+ flags: {
132
+ cwd: {
133
+ type: "string",
134
+ value: "<dir>",
135
+ help: "Folder to work in (default: the current one)"
136
+ },
137
+ name: {
138
+ type: "string",
139
+ value: "<name>",
140
+ help: "Session name (default: the usual one)"
141
+ },
142
+ task: {
143
+ type: "string",
144
+ value: "<text>",
145
+ help: "The first task"
146
+ },
147
+ "task-file": {
148
+ type: "string",
149
+ value: "<path>",
150
+ help: "Read the first task from a file"
151
+ },
152
+ window: {
153
+ type: "boolean",
154
+ help: "Open the CLI in a terminal window you can watch, instead of the background"
155
+ },
156
+ allow: {
157
+ type: "string",
158
+ value: "<kinds>",
159
+ help: "Background: tool calls to approve, such as read,search or execute:npm test*"
160
+ },
161
+ yes: {
162
+ type: "boolean",
163
+ short: "y",
164
+ help: "Start without asking"
165
+ }
166
+ },
167
+ notes: [
168
+ "By default the worker runs in the background over ACP and stays alive. Each message sent to",
169
+ "it becomes its next prompt: right away when it is idle, else when its turn ends.",
170
+ "--window opens the real CLI in a new terminal instead, so you can watch it and take over.",
171
+ "In the background, tool calls that need approval are denied unless --allow covers them.",
172
+ "claude and codex need an ACP adapter installed. End a worker with conveno stop.",
173
+ "Waits until the session registers, then prints its name.",
174
+ "Without a terminal of your own it needs --yes, and exits 2 without it.",
175
+ "At most 8 spawned sessions run at once; CONVENO_SPAWN_MAX changes that."
176
+ ],
177
+ positionals: true,
178
+ hidden: true
179
+ },
180
+ {
181
+ name: "stop",
182
+ usage: "conveno stop <worker>",
183
+ summary: "Stop a background worker",
184
+ flags: {},
185
+ notes: ["A background worker cancels its current turn, stops its CLI and tells the session that spawned it.", "A worker in a terminal window is yours to close."],
186
+ positionals: true,
187
+ hidden: true
188
+ },
189
+ {
190
+ name: "devices",
191
+ usage: "conveno devices [pair|join|revoke|rename|accept|reset]",
192
+ summary: "Pair your machines over the relay (Pro)",
193
+ flags: { yes: {
194
+ type: "boolean",
195
+ short: "y",
196
+ help: "Revoke, accept or reset without asking"
197
+ } },
198
+ notes: [
199
+ "conveno devices lists your devices. revoke takes a device name or id, rename a new name.",
200
+ "pair runs on a device you already use, join on the new one, at the same time.",
201
+ "Each device shows an 8-digit code. Type the code from the other screen on each device.",
202
+ "revoke removes a device for good: it can no longer read or send for your sessions.",
203
+ "accept <head> ends a device list conflict by taking the relay's list with that head.",
204
+ "reset forgets this device's list after you reset your devices on the account page.",
205
+ "Needs a Conveno Pro login on both devices."
206
+ ],
207
+ positionals: true,
208
+ hidden: true
209
+ },
210
+ {
211
+ name: "relay",
212
+ usage: "conveno relay status",
213
+ summary: "Show the relay connection",
214
+ flags: {},
215
+ positionals: true,
216
+ hidden: true
217
+ },
218
+ {
219
+ name: "doctor",
220
+ usage: "conveno doctor [--cli <list>]",
221
+ summary: "Check each CLI and the daemon",
222
+ flags: { cli: {
223
+ type: "string",
224
+ value: "<list>",
225
+ help: "Only these AI tools, separated by commas or spaces, such as claude,codex"
226
+ } },
227
+ hidden: true
228
+ },
229
+ {
230
+ name: "login",
231
+ usage: "conveno login [--no-browser]",
232
+ summary: "Sign in to your Conveno account",
233
+ flags: { "no-browser": {
234
+ type: "boolean",
235
+ help: "Print the sign-in link, do not open it"
236
+ } },
237
+ notes: [
238
+ "login shows a code and a link. Approve the code in your browser and the terminal signs in.",
239
+ "The account is only for Conveno Pro. Everything on this machine works without one.",
240
+ "The tokens are kept in the data dir, in account.json, readable by you only."
241
+ ],
242
+ hidden: true
243
+ },
244
+ {
245
+ name: "logout",
246
+ usage: "conveno logout",
247
+ summary: "Sign out and delete the saved tokens",
248
+ flags: {},
249
+ hidden: true
250
+ },
251
+ {
252
+ name: "account",
253
+ usage: "conveno account",
254
+ summary: "Show your plan and trial",
255
+ flags: {},
256
+ hidden: true
257
+ },
258
+ {
259
+ name: "daemon",
260
+ usage: "conveno daemon start|stop|status",
261
+ summary: "Manage the background daemon",
262
+ flags: {},
263
+ positionals: true,
264
+ hidden: true
265
+ },
266
+ {
267
+ name: "mcp",
268
+ usage: "conveno mcp --cli <cli>",
269
+ summary: "MCP server on stdio (CLIs launch this)",
270
+ flags: { cli: {
271
+ type: "string",
272
+ value: "<cli>",
273
+ help: "The CLI that starts it, such as claude"
274
+ } },
275
+ hidden: true
276
+ },
277
+ {
278
+ name: "hook",
279
+ usage: "conveno hook <cli> <event>",
280
+ summary: "Hook entry (CLIs launch this)",
281
+ flags: {},
282
+ positionals: true,
283
+ hidden: true
284
+ }
285
+ ];
286
+ const COMMAND_NAMES = COMMANDS.filter((c) => !c.hidden).map((c) => c.name);
287
+ /** Every command that works, shown in help or not. Used for "Did you mean". */
288
+ const ALL_COMMAND_NAMES = COMMANDS.map((c) => c.name);
289
+ /** `conveno <command> --help`. */
290
+ function commandHelp(ctx, spec) {
291
+ const t = ctx.theme;
292
+ const lines = [
293
+ spec.summary,
294
+ "",
295
+ `Usage: ${spec.usage}`
296
+ ];
297
+ const flags = Object.entries(spec.flags);
298
+ if (flags.length > 0) {
299
+ lines.push("", "Options:");
300
+ const rows = flags.map(([name, f]) => {
301
+ return [`${f.short ? `-${f.short}, ` : ""}--${name}${f.value ? ` ${f.value}` : ""}`, f.help];
302
+ });
303
+ const width = Math.max(...rows.map(([l]) => l.length)) + 2;
304
+ for (const [l, h] of rows) lines.push(` ${t.bold(l.padEnd(width))}${h}`);
305
+ }
306
+ if (spec.notes?.length) lines.push("", ...spec.notes);
307
+ return `${lines.join("\n")}\n`;
308
+ }
309
+ /**
310
+ * Parse a command's arguments. Unknown flags and stray words are usage errors (exit 2) with a
311
+ * "Did you mean" when a known flag is within two edits. Returns the exit code on failure.
312
+ */
313
+ function parseFlags(ctx, spec, argv) {
314
+ const options = {};
315
+ for (const [name, f] of Object.entries(spec.flags)) options[name] = {
316
+ type: f.type,
317
+ ...f.short ? { short: f.short } : {}
318
+ };
319
+ try {
320
+ const r = parseArgs({
321
+ args: argv,
322
+ options,
323
+ allowPositionals: spec.positionals === true,
324
+ strict: true
325
+ });
326
+ return {
327
+ values: r.values,
328
+ positionals: r.positionals
329
+ };
330
+ } catch (e) {
331
+ const t = ctx.theme;
332
+ const code = e.code;
333
+ const message = e instanceof Error ? e.message : "";
334
+ const unknown = /Unknown option '(-{1,2}[^']+)'/.exec(message)?.[1];
335
+ if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && unknown) {
336
+ const suggestion = closest(unknown.replace(/^-+/, ""), Object.keys(spec.flags));
337
+ return fail(ctx, {
338
+ what: `Unknown option ${unknown} for conveno ${spec.name}`,
339
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
340
+ ...suggestion ? { didYouMean: `Did you mean --${suggestion}?` } : {},
341
+ exit: 2,
342
+ ref: "e_usage"
343
+ });
344
+ }
345
+ if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") return fail(ctx, {
346
+ what: `A conveno ${spec.name} option is missing its value`,
347
+ detail: [message.split("\n")[0] ?? message],
348
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
349
+ exit: 2,
350
+ ref: "e_usage"
351
+ });
352
+ const stray = /argument '([^']+)'/.exec(message)?.[1];
353
+ return fail(ctx, {
354
+ what: stray ? `Unexpected argument "${stray}" for conveno ${spec.name}` : `Could not read the arguments for conveno ${spec.name}`,
355
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
356
+ exit: 2,
357
+ ref: "e_usage"
358
+ });
359
+ }
360
+ }
361
+ export { parseFlags as a, commandHelp as i, COMMANDS as n, COMMAND_NAMES as r, ALL_COMMAND_NAMES as t };
package/dist/bin.js CHANGED
@@ -9,7 +9,7 @@ import { join } from "node:path";
9
9
  * bundle and zod is most of the time a hook spends starting. Node checks each entry against the
10
10
  * file's contents and its own version, and a cache that cannot be written is ignored.
11
11
  */
12
- function useCompileCache() {
12
+ function startCompileCache() {
13
13
  if (process.env.NODE_DISABLE_COMPILE_CACHE || process.env.NODE_COMPILE_CACHE) return;
14
14
  try {
15
15
  const env = process.env;
@@ -17,7 +17,7 @@ function useCompileCache() {
17
17
  enableCompileCache(join(base, "conveno", "compile-cache"));
18
18
  } catch {}
19
19
  }
20
- useCompileCache();
20
+ startCompileCache();
21
21
  const argv = process.argv.slice(2);
22
22
  const isHook = argv[0] === "hook";
23
23
  for (const stream of [process.stdout, process.stderr]) stream.on("error", (err) => {
@@ -26,9 +26,9 @@ for (const stream of [process.stdout, process.stderr]) stream.on("error", (err)
26
26
  });
27
27
  try {
28
28
  let code;
29
- if (isHook) code = await (await import("./hook-entry-Daxws9EC.js")).runHookEntry(argv.slice(1));
29
+ if (isHook) code = await (await import("./hook-entry-D2CAJsq-.js")).runHookEntry(argv.slice(1));
30
30
  else {
31
- const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-sIWDc4jt.js"), import("./runtime-5nEur1P5.js")]);
31
+ const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-EqfI0btx.js"), import("./runtime-BDNmkbsS.js")]);
32
32
  code = await main(argv, createRuntimeCtx());
33
33
  }
34
34
  if (isHook) process.exit(code);
@@ -0,0 +1,17 @@
1
+ // src/ctx.ts
2
+ const adapterEnv = (ctx) => ({
3
+ home: ctx.home,
4
+ platform: ctx.platform,
5
+ cwd: ctx.cwd,
6
+ exec: ctx.exec,
7
+ conveno: ctx.conveno,
8
+ env: ctx.env
9
+ });
10
+ const connectOpts = (ctx, autoStart) => ({
11
+ kind: "cli",
12
+ dataDir: ctx.dataDir,
13
+ autoStart,
14
+ ...ctx.socketPath ? { socketPath: ctx.socketPath } : {},
15
+ ...ctx.daemonEntry ? { daemonEntry: ctx.daemonEntry } : {}
16
+ });
17
+ export { connectOpts as n, adapterEnv as t };