@conveno/cli 0.1.1 → 0.2.0-rc.10

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  # @conveno/cli
2
2
 
3
- Conveno connects the AI coding CLI sessions on one machine so they can find each other, send messages and route work to the one session you pick as the orchestrator. You keep using each CLI the way you do today. This package is the `conveno` command and everything it needs, including the local daemon.
3
+ Conveno connects your AI coding CLI sessions. Open your CLIs, make one the lead, and it hands out work. The other sessions wake up and start working. With Pro it works across your computers and servers. You keep using each CLI the way you do today. This package is the `conveno` command and everything it needs, including the local daemon.
4
4
 
5
5
  - Website: https://conveno.dev
6
6
  - Source and issues: https://github.com/0xPixelNinja/conveno
7
- - Status: pre-alpha. The local mesh works. The relay, tickets, handoff, peek and spawn are planned.
7
+ - Status: pre-alpha. The local mesh works, with spawn and handoff. Pro, the end-to-end encrypted relay between your machines, is in preview.
8
8
 
9
9
  ## Install
10
10
 
@@ -23,7 +23,9 @@ conveno init
23
23
 
24
24
  `conveno init` finds the supported CLIs on your machine and shows a diff of every config file it would change. It asks before it writes, and it backs each file up first. Add `--dry-run` to print the plan and write nothing.
25
25
 
26
- Then open two CLI sessions, for example Claude Code and Codex. In one, ask it to run `list_sessions`, then to `send` a message to the other. `conveno status` lists the sessions.
26
+ Then open two CLI sessions, for example Claude Code and Codex. Make one the lead (in the app, with `conveno lead <session>`, or by asking it to coordinate) and ask it to hand out work. The other session wakes up and starts. `conveno status` lists the sessions.
27
+
28
+ Or run `conveno` with no arguments. It opens a full-screen app (Sessions, New, Devices, Setup) for the keyboard and mouse: `/` searches, `?` shows the keys. Turn the mouse off in Setup or with `CONVENO_MOUSE=0`.
27
29
 
28
30
  `conveno uninstall` reverts what `init` did. A file that has not changed since `init` is restored byte for byte. If a CLI has rewritten it since, only Conveno's entries are removed.
29
31
 
@@ -33,26 +35,42 @@ Then open two CLI sessions, for example Claude Code and Codex. In one, ask it to
33
35
  |---|---|
34
36
  | `conveno init` | Add the Conveno MCP server and hooks to each detected CLI. |
35
37
  | `conveno uninstall` | Undo every install that has not been undone. |
36
- | `conveno status` | Online sessions grouped by repo, with the orchestrator marked. `--all` includes offline ones. |
37
- | `conveno forget [<name\|pattern>...] [--offline] [--older-than <duration>] [--dry-run] [--yes]` | Remove offline sessions from the list, for example the leftovers of deleted test repos. A name is exact or a pattern where `*` matches any run of characters (quote it: `'conveno-real-*'`). `--offline` with no name means every offline session, and `--older-than 30m`, `24h` or `7d` keeps only those last seen that long ago. It lists what it will remove and asks; `--yes` skips the question, and without a terminal it exits 2 unless `--yes` is given. `--dry-run` lists and changes nothing. A running session that matches is listed as skipped and never removed. Forgetting deletes the queued messages of the session; messages it sent stay with the receivers. The daemon also forgets offline sessions whose folder has been missing for 5 minutes and that have no unread messages. |
38
- | `conveno doctor` | Check each CLI and the daemon, and say how to fix what is wrong. |
39
- | `conveno daemon start\|stop\|status` | Control the local daemon. It also starts when a CLI opens the Conveno MCP server, and exits when no session has been online for a while. |
40
-
41
- `conveno --help` lists the rest, and `conveno <command> --help` shows the options of one. The `mcp` and `hook` commands are what the CLIs call; you do not run them yourself.
38
+ | `conveno status` | Online sessions grouped by repo, with the lead marked. |
39
+ | `conveno send <to> <text...> [--urgent]` | Send a message as you to a session name or id, `lead`, or `device:name`. `-` reads the text from standard input. |
40
+ | `conveno rename <session> <new-name>` | Rename an online session. |
41
+ | `conveno lead <session>` | Make a session the lead. `conveno lead --clear` leaves no lead. |
42
+ | `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--window] [--allow <kinds>] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `cursor`, `copilot`, `antigravity` or `grok`, and print its name once it registers. The CLI must be installed. By default the worker runs in the background through the CLI's Agent Client Protocol server, with `conveno acp-host` driving it. It keeps running: each message sent to it becomes its next prompt at once when it is idle, or when its current turn ends. `--window` opens the real CLI in a new terminal instead, so you can watch it and take over: Windows Terminal (`wt -w 0 new-tab`, else a new console window) on Windows, Terminal.app (iTerm2 when it is your terminal) on macOS, and on Linux a new tmux window when you are inside tmux, else the first of `x-terminal-emulator`, `gnome-terminal`, `konsole`, `kitty`, `wezterm`, `alacritty` and `xterm`. The ACP commands are `claude-agent-acp` (install `@agentclientprotocol/claude-agent-acp`), `codex-acp` (install `@agentclientprotocol/codex-acp`), `opencode acp`, `agent acp` (Cursor), `copilot --acp --stdio`, `agy acp` and `grok agent stdio`; a missing one is an error that says what to install. For Claude Code and Codex, `conveno init` can allow running the adapter with `npx -y <package>@<pinned version>`, and `CONVENO_ACP_CODEX_CMD` / `CONVENO_ACP_CLAUDE_CMD` replace the command. In the background a tool call that needs approval is denied unless `--allow` covers it: comma-separated ACP tool kinds (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `switch_mode`, `other`, or `*`), each optionally with `:` and a title glob (`execute:npm test*`). Allowed calls are answered "allow once", never "always". The first task is optional. `--name` sets the session name (a taken or reserved one is refused); otherwise the usual `<cli>@<repo>-<n>` name is used. `--cwd` defaults to the current folder, which must be inside your home folder; an explicit `--cwd` can be anywhere. It asks first and `--yes` skips the question; without a terminal it exits 2 unless `--yes` is given. At most 8 spawned sessions run at once (`CONVENO_SPAWN_MAX` changes that), and a spawned session cannot spawn more than 3 levels deep. A task is at most 16000 characters. See `packages/protocol/PROTOCOL.md`. |
43
+ | `conveno stop <worker>` | Stop a background worker. It cancels a running turn, ends its CLI and the processes it started, tells the spawning session why, and goes offline. A worker in a window is yours to close. |
44
+ | `conveno doctor [--cli <list>]` | Check each CLI and the daemon, and say how to fix what is wrong. `--cli claude,codex` checks only those CLIs, so problems in the others do not count. |
45
+ | `conveno devices [pair\|join\|revoke\|rename\|accept\|reset]` | Pro. List your devices, or pair a new machine: `pair` on one device and `join` on the new one at the same time, then type the 8-digit code each screen shows. `revoke` removes a device for good. Needs a Pro login on both. |
46
+ | `conveno relay status` | Show the relay connection. |
47
+ | `conveno login [--no-browser]` | Sign in to your Conveno account for Pro. Shows a code and a link, opens the browser, and waits for you to approve the code. The tokens go to `account.json` in the data dir, readable by you only. The local mesh does not need an account. |
48
+ | `conveno logout` | Sign out on the server and delete the saved tokens. |
49
+ | `conveno account` | Show your plan and trial. |
50
+
51
+ `conveno --help` lists the rest, and `conveno <command> --help` shows the options of one. The `daemon`, `mcp`, `hook`, `spawn-run` and `acp-host` commands are hidden or are what the CLIs and spawned workers call; you do not run them yourself.
42
52
 
43
53
  ## Supported CLIs
44
54
 
45
- | CLI | Delivery |
46
- |---|---|
47
- | Claude Code | At the start of the next turn (hook), or with the `inbox` tool |
48
- | Codex | At the start of the next turn (hook), or with the `inbox` tool |
49
- | OpenCode | With the `inbox` tool |
55
+ | CLI | Messages arrive | Wakes when idle |
56
+ |---|---|---|
57
+ | Claude Code | Next turn (hook), or `inbox` | Yes |
58
+ | OpenCode | `inbox`, plus the plugin at the end of a turn | Yes (plugin) |
59
+ | Codex | Next turn (hook), or `inbox` | Coming in the next release |
60
+ | Cursor CLI | After the next tool call (hook), or `inbox` | Coming in the next release |
61
+ | GitHub Copilot CLI | Next turn (hook), or `inbox` | Coming in the next release |
62
+ | Antigravity | Before each model call (hook), or `inbox` | Coming in the next release |
63
+ | Grok | `inbox`, plus a hook at the end of a turn | Coming in the next release |
64
+
65
+ A worker started with `conveno spawn` wakes on every message, whatever the CLI.
66
+
67
+ ## Compatibility
50
68
 
51
- Antigravity, Cursor and Copilot are planned.
69
+ Vendors change config and hook formats without notice. `conveno doctor` compares each detected CLI with the versions Conveno was checked against: a newer one is a warning, one older than the minimum is a problem with an upgrade hint. A nightly workflow installs the latest release of every supported CLI and checks that it accepts what `conveno init` writes, then raises the checked version or opens an issue. The table of versions and the details are in the [repository README](https://github.com/0xPixelNinja/conveno#compatibility).
52
70
 
53
71
  ## How it works
54
72
 
55
- Each CLI session starts its own MCP server through `conveno mcp`. The servers talk to one small daemon on your machine, which keeps the session list, the mailboxes and the routing. The daemon listens on a local socket and nothing leaves your machine. Messages from other sessions reach an agent labelled as data from a peer, not as instructions from you.
73
+ Each CLI session starts its own MCP server through `conveno mcp`. The servers talk to one small daemon on your machine, which keeps the session list, the mailboxes and the routing. The daemon listens on a local socket and, without Pro, nothing leaves your machine. With Pro, end-to-end encrypted envelopes go through `relay.conveno.dev` to your other machines. The relay sees device names, public keys, routing metadata and sizes, never message content. Conveno sends no telemetry. Messages from other sessions reach an agent labelled as data from a peer, not as instructions from you.
56
74
 
57
75
  Conveno never reads, stores or forwards a provider login token or credential file. It works with the official CLIs only, under your own login or API key.
58
76
 
@@ -0,0 +1,82 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-BLfduOoT.js";
3
+ import { At as readSpawnRecord, Wt as spawnRecordPath } from "./dist-STNJjbNH.js";
4
+ import { a as parseFlags, n as COMMANDS } from "./args-B3Cj2Ie4.js";
5
+ import { a as fail, n as cmd } from "./fmt-C2SsP5Y0.js";
6
+ // src/acp.ts
7
+ /** How long `conveno stop` waits for a worker to end by itself before it ends the process tree. */
8
+ const STOP_WAIT_MS = 1e4;
9
+ /** `conveno acp-host <launch file>`: what `conveno spawn` runs in the background. Not for people. */
10
+ async function runAcpHostCmd(ctx, argv) {
11
+ const [file] = argv;
12
+ if (!file) return fail(ctx, {
13
+ what: "conveno acp-host needs a launch file",
14
+ detail: ["It is started by conveno spawn."],
15
+ fix: `Run ${cmd(ctx.theme, "conveno spawn <cli>")} instead.`,
16
+ exit: 2,
17
+ ref: "e_usage"
18
+ });
19
+ try {
20
+ return await runAcpHostFromFile(file, {
21
+ dataDir: ctx.dataDir,
22
+ ...ctx.socketPath ? { socketPath: ctx.socketPath } : {},
23
+ ...ctx.daemonEntry ? { daemonEntry: ctx.daemonEntry } : {}
24
+ });
25
+ } catch (e) {
26
+ return fail(ctx, {
27
+ what: "The ACP host could not start",
28
+ detail: [e instanceof Error ? e.message : String(e)],
29
+ fix: `Run ${cmd(ctx.theme, "conveno spawn <cli>")} again.`,
30
+ exit: 1,
31
+ ref: "e_spawn"
32
+ });
33
+ }
34
+ }
35
+ function findWorker(ctx, name, command) {
36
+ if (!name) return fail(ctx, {
37
+ what: `conveno ${command} needs a worker name`,
38
+ fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
39
+ exit: 2,
40
+ ref: "e_usage"
41
+ });
42
+ const rec = /^[a-z0-9][a-z0-9._@-]{0,63}$/.test(name) ? readSpawnRecord(spawnRecordPath(ctx.dataDir, name)) : void 0;
43
+ if (!rec) return fail(ctx, {
44
+ what: `No running worker named "${name}"`,
45
+ detail: ["Only sessions started by conveno spawn or spawn_session on this machine are workers."],
46
+ fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
47
+ exit: 1,
48
+ ref: "e_not_found"
49
+ });
50
+ return rec;
51
+ }
52
+ /**
53
+ * `conveno stop <worker>`. An ACP worker gets a stop request: its host sends `session/cancel` for
54
+ * a running turn, ends the agent, reports to the spawner and takes the session offline. A worker in a
55
+ * terminal window is the user's to close.
56
+ */
57
+ async function runStop(ctx, argv) {
58
+ const spec = COMMANDS.find((c) => c.name === "stop");
59
+ if (!spec) return 2;
60
+ const parsed = parseFlags(ctx, spec, argv);
61
+ if (typeof parsed === "number") return parsed;
62
+ const [name] = parsed.positionals;
63
+ const rec = findWorker(ctx, name, "stop");
64
+ if (typeof rec === "number") return rec;
65
+ const t = ctx.theme;
66
+ if (!rec.acp) return fail(ctx, {
67
+ what: `${rec.name} runs in a terminal`,
68
+ detail: ["Conveno does not close a terminal you can see."],
69
+ fix: "Exit the CLI in that terminal.",
70
+ exit: 1,
71
+ ref: "e_spawn"
72
+ });
73
+ const alive = () => rec.pid !== void 0 && ctx.isAlive(rec.pid);
74
+ writeFileSync(stopRequestPath(spawnRecordPath(ctx.dataDir, rec.name)), "", { mode: 384 });
75
+ const end = Date.now() + STOP_WAIT_MS;
76
+ while (alive() && Date.now() < end) await new Promise((r) => setTimeout(r, 100));
77
+ if (alive() && rec.pid !== void 0) killProcessTree(rec.pid, ctx.platform);
78
+ if (rec.agentPid !== void 0 && ctx.isAlive(rec.agentPid)) killProcessTree(rec.agentPid, ctx.platform);
79
+ ctx.out(`${t.status("ok")} ${t.bold(`Stopped ${rec.name}`)}\n`);
80
+ return 0;
81
+ }
82
+ export { runAcpHostCmd, runStop };
@@ -0,0 +1,137 @@
1
+ import { execFile } from "node:child_process";
2
+ import { t as RELAY_SUBCOMMAND } from "./dist-VOS92iqO.js";
3
+ import { Vt as runWaker } from "./dist-STNJjbNH.js";
4
+ import { n as connectOpts } from "./ctx-tYftvhz_.js";
5
+ // src/agy-relay.ts
6
+ /**
7
+ * Time limit of one `agentapi send-message`. It normally answers within about a second; the limit
8
+ * only stops a hung run. It is long so a slow send that succeeds is not taken for a failure.
9
+ */
10
+ const SEND_TIMEOUT_MS = 12e4;
11
+ /** Runs the file directly, never through a shell, so every argument stays one argument. */
12
+ const runSend = (file, args, timeoutMs) => new Promise((resolve) => {
13
+ execFile(file, args, {
14
+ timeout: timeoutMs,
15
+ windowsHide: true,
16
+ encoding: "utf8"
17
+ }, (err) => {
18
+ if (!err) return resolve("sent");
19
+ resolve(err.killed ? "unknown" : "failed");
20
+ });
21
+ });
22
+ const UUID = /^[0-9a-fA-F-]{8,64}$/;
23
+ function relayText(text, count) {
24
+ if (text.length <= 16e3) return text;
25
+ return `[conveno] ${count} message${count === 1 ? "" : "s"} arrived through Conveno, too long to show here. Conveno started this turn; the user did not type it. Read them with the inbox tool (unread_only false).`;
26
+ }
27
+ /**
28
+ * Run `<agy> agentapi send-message <conversation> <text>`. The executable is run directly, never
29
+ * through a shell, so the text stays one argument; on Windows only a real `.exe` is run, because a
30
+ * `.cmd` or `.bat` shim would have cmd.exe parse the text. False only when no turn started: a send
31
+ * killed at the time limit counts as sent, so the waker does not requeue messages agy may already
32
+ * have taken and send them twice (they stay readable with the inbox tool).
33
+ */
34
+ async function sendToConversation(io, exe, conversationId, text) {
35
+ if (io.platform === "win32" && !/\.exe$/i.test(exe)) return false;
36
+ try {
37
+ return await (io.run ?? runSend)(exe, [
38
+ "agentapi",
39
+ "send-message",
40
+ conversationId,
41
+ text
42
+ ], SEND_TIMEOUT_MS) !== "failed";
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ const END = {
48
+ superseded: "another relay for this conversation took over. Do not start it again.",
49
+ no_session: "no Conveno session belongs to this conversation (is the conveno MCP server on?). Do not start it again.",
50
+ one_shot: "this agy run is one-shot (agy -p), so nothing can wake it. Do not start it again."
51
+ };
52
+ /** agy's one-shot flags: `-p` and its aliases `--print` and `--prompt` (agy docs cli/headless). */
53
+ const ONE_SHOT = /^(?:-p|--print|--prompt)(?:=|$)/;
54
+ /** True when an ancestor of this process is a one-shot `agy -p` run. */
55
+ async function underOneShotAgy(ctx) {
56
+ return ((await ctx.ancestry(2e3).catch(() => void 0))?.entries ?? []).some((e) => {
57
+ const words = Array.from((e.command ?? "").matchAll(/"([^"]*)"|(\S+)/g)).map((m) => m[1] ?? m[2] ?? "");
58
+ const exe = (words[0] ?? "").split(/[\\/]/).pop()?.toLowerCase();
59
+ return (exe === "agy" || exe === "agy.exe") && words.slice(1).some((w) => ONE_SHOT.test(w));
60
+ });
61
+ }
62
+ async function runAgyRelay(ctx, argv, deps = {}) {
63
+ const end = (why, code = 0) => {
64
+ ctx.out(`[conveno] ${RELAY_SUBCOMMAND} ended: ${why}\n`);
65
+ return code;
66
+ };
67
+ if (argv.length > 0) return end("it takes no arguments.", 2);
68
+ const conversationId = ctx.env.ANTIGRAVITY_CONVERSATION_ID;
69
+ const exe = ctx.env.ANTIGRAVITY_AGENTAPI_EXE;
70
+ if (!conversationId || !UUID.test(conversationId) || !exe) return end("it only runs inside an Antigravity agent's command. Nothing to do.");
71
+ if (ctx.platform === "win32" && !/\.exe$/i.test(exe)) return end("ANTIGRAVITY_AGENTAPI_EXE is not an .exe. Do not start it again.");
72
+ if (await underOneShotAgy(ctx)) return end(END.one_shot);
73
+ const controller = new AbortController();
74
+ const signal = controller.signal;
75
+ const stop = () => controller.abort();
76
+ deps.signal?.addEventListener("abort", stop, { once: true });
77
+ if (deps.signal?.aborted) stop();
78
+ const signals = deps.signal ? [] : ["SIGINT", "SIGTERM"];
79
+ for (const s of signals) process.once(s, stop);
80
+ const runWaker$1 = deps.runWaker ?? runWaker;
81
+ const pollMs = deps.pollMs ?? 3e3;
82
+ const findMs = deps.findMs ?? 6e5;
83
+ const retryBase = deps.retryMs ?? 2e3;
84
+ const sleep = (ms) => new Promise((resolve) => {
85
+ const t = setTimeout(resolve, ms);
86
+ signal.addEventListener("abort", () => {
87
+ clearTimeout(t);
88
+ resolve();
89
+ }, { once: true });
90
+ });
91
+ let client;
92
+ let retry = retryBase;
93
+ let looking = Date.now();
94
+ try {
95
+ while (!signal.aborted) {
96
+ let session;
97
+ let c;
98
+ try {
99
+ c = client ??= await ctx.connect(connectOpts(ctx, false));
100
+ const { sessions } = await c["session.list"]({ cli: "antigravity" });
101
+ session = sessions.find((s) => s.nativeId === conversationId && s.status !== "offline");
102
+ retry = retryBase;
103
+ } catch {
104
+ await client?.close().catch(() => void 0);
105
+ client = void 0;
106
+ await sleep(retry);
107
+ retry = Math.min(retry * 2, 6e4);
108
+ continue;
109
+ }
110
+ if (!session) {
111
+ if (Date.now() - looking > findMs) return end(END.no_session);
112
+ await sleep(pollMs);
113
+ continue;
114
+ }
115
+ const hostPid = session.hostPid;
116
+ const reason = await runWaker$1({
117
+ client: c,
118
+ sessionId: session.id,
119
+ signal,
120
+ ...hostPid ? { isHostAlive: () => ctx.isAlive(hostPid) } : {},
121
+ inject: (text, messages) => sendToConversation({
122
+ platform: ctx.platform,
123
+ ...deps.run ? { run: deps.run } : {}
124
+ }, exe, conversationId, relayText(text, messages.length))
125
+ });
126
+ if (reason === "aborted" || reason === "host_exited") return 0;
127
+ if (reason === "superseded") return end(END.superseded);
128
+ looking = Date.now();
129
+ }
130
+ return 0;
131
+ } finally {
132
+ deps.signal?.removeEventListener("abort", stop);
133
+ for (const s of signals) process.off(s, stop);
134
+ await client?.close().catch(() => void 0);
135
+ }
136
+ }
137
+ export { runAgyRelay };
@@ -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 copilot-idle-wake"
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, such as Copilot idle wake (it turns on Copilot's experimental mode), 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, such as Copilot idle wake (it turns on Copilot's experimental mode), 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 };