@conveno/cli 0.2.0-rc.7 → 0.2.0-rc.8

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.
@@ -4,18 +4,18 @@ import { homedir } from "node:os";
4
4
  import { delimiter, join, win32 } from "node:path";
5
5
  import { createInterface } from "node:readline";
6
6
  import { fileURLToPath } from "node:url";
7
- import { n as antigravityAdapter } from "./dist-D9Gu-mQm.js";
8
- import { a as opencodeAdapter, c as claudeAdapter, o as cursorAdapter, r as readAllStdin, s as copilotAdapter } from "./hook-entry-BXmSN--S.js";
9
- import { t as codexAdapter } from "./dist-DOGlDbRb.js";
10
- import { t as grokAdapter } from "./dist-Dd31Fg0h.js";
7
+ import { n as antigravityAdapter } from "./dist-B6Sm0MRT.js";
8
+ import { a as opencodeAdapter, c as claudeAdapter, o as cursorAdapter, r as readAllStdin, s as copilotAdapter } from "./hook-entry-pHJioNgN.js";
9
+ import { t as codexAdapter } from "./dist-B1EVHdIM.js";
10
+ import { t as grokAdapter } from "./dist-CcoTmwrf.js";
11
11
  import { t as createTheme } from "./dist-BRjg9CLd.js";
12
- import { n as connect$1 } from "./dist-ftx5RNCp.js";
13
- import { C as claimSpawnRecord, Ct as realSpawnDeps, Dn as array, En as _enum, F as detectRepo, K as formatInbox, Kt as validateRename, Lt as spawnSession, Nn as string, On as boolean, Xt as CLI_KINDS, _ as attachAcpSession, b as baseName, ct as parsePs1ShimTarget, f as SpawnError, in as OWNER_SESSION_ID, j as dataDir, jn as number, jt as resolveWindowsCommand, ln as SessionId, o as HEARTBEAT_INTERVAL_MS, pt as planSpawn, r as ConvenoError, rn as MessageId, s as NOT_FROM_USER_NOTICE, sn as RpcErrorCode, st as parseCmdShimTarget, u as SPAWN_CLIS, vt as readAncestry, yt as readCommandLine } from "./dist-D2hMvcZu.js";
14
- import "./dist-iFaY42Bs.js";
12
+ import { n as connect$1 } from "./dist-WTkKRM39.js";
13
+ import { C as claimSpawnRecord, Ct as realSpawnDeps, Dn as _enum, F as detectRepo, K as formatInbox, Kt as validateRename, Lt as spawnSession, Mn as number, On as array, Pn as string, Xt as CLI_KINDS, _ as attachAcpSession, b as baseName, ct as parsePs1ShimTarget, f as SpawnError, in as OWNER_SESSION_ID, j as dataDir, jt as resolveWindowsCommand, kn as boolean, o as HEARTBEAT_INTERVAL_MS, pt as planSpawn, r as ConvenoError, rn as MessageId, s as NOT_FROM_USER_NOTICE, sn as RpcErrorCode, st as parseCmdShimTarget, u as SPAWN_CLIS, un as SessionId, vt as readAncestry, yt as readCommandLine } from "./dist-BBdba94T.js";
14
+ import "./dist-C6cMQ00I.js";
15
15
  import { access } from "node:fs/promises";
16
16
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
18
- // ../daemon/dist/server-Da4eFZ5j.js
18
+ // ../daemon/dist/server--RKl3u3P.js
19
19
  /** `kill(pid, 0)` liveness: EPERM means the process exists but belongs to someone else. */
20
20
  function defaultIsAlive(pid) {
21
21
  try {
@@ -28,7 +28,7 @@ function defaultIsAlive(pid) {
28
28
  `${OWNER_SESSION_ID}`;
29
29
  SessionId.parse("0".repeat(26));
30
30
  // ../mcp/dist/index.js
31
- const SERVER_VERSION = "0.2.0-rc.7";
31
+ const SERVER_VERSION = "0.2.0-rc.8";
32
32
  const ok = (text) => ({ content: [{
33
33
  type: "text",
34
34
  text
@@ -1,11 +1,11 @@
1
- import { D as completeLogin, E as compatStatus, H as fetchAccountStatus, M as dataPaths, Tt as requestDeviceCode, U as findOnPath, Xt as CLI_KINDS, Yt as writeSettings, _t as readAccountTokens, d as SPAWN_TABLE, dt as pinnedAdapter, g as adapterNpxCommand, h as adapterInstallCommand, kt as resolveAcpProgram, m as acpOverrideVar, mt as pollDeviceCode, n as AccountError, tt as logoutAccount, xt as readSettings } from "./dist-D2hMvcZu.js";
1
+ import { D as completeLogin, E as compatStatus, H as fetchAccountStatus, M as dataPaths, Tt as requestDeviceCode, U as findOnPath, Xt as CLI_KINDS, Yt as writeSettings, _t as readAccountTokens, d as SPAWN_TABLE, dt as pinnedAdapter, g as adapterNpxCommand, h as adapterInstallCommand, kt as resolveAcpProgram, m as acpOverrideVar, mt as pollDeviceCode, n as AccountError, tt as logoutAccount, xt as readSettings } from "./dist-BBdba94T.js";
2
2
  import { a as fail, c as plural, d as warnBlock, i as errorBlock, l as seconds, n as cmd, o as localStamp, r as columns, s as plainError, t as closest, u as tilde } from "./fmt-C2SsP5Y0.js";
3
- import { i as parseFlags, t as COMMANDS } from "./args-C7Agak9f.js";
3
+ import { a as parseFlags, n as COMMANDS } from "./args-CGL-AmNd.js";
4
4
  import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
5
- import { t as daemonProblem } from "./daemonError-DNAKEyRT.js";
5
+ import { t as daemonProblem } from "./daemonError-DJ-P55nH.js";
6
6
  import { basename, dirname, join } from "node:path";
7
7
  import { spawn } from "node:child_process";
8
- import { chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, rmdir, stat, writeFile } from "node:fs/promises";
8
+ import { access, chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, rmdir, stat, writeFile } from "node:fs/promises";
9
9
  import { createHash, randomBytes } from "node:crypto";
10
10
  // src/account.ts
11
11
  const accountIo = (ctx, io) => ({
@@ -140,6 +140,193 @@ async function runAccount(ctx, argv, io = {}) {
140
140
  return accountFailure(ctx, e, "Could not read your account");
141
141
  }
142
142
  }
143
+ // src/daemon.ts
144
+ async function lockPid(ctx) {
145
+ try {
146
+ const raw = await readFile(dataPaths(ctx.platform, ctx.dataDir).lock, "utf8");
147
+ const pid = JSON.parse(raw).pid;
148
+ return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
149
+ } catch {
150
+ return null;
151
+ }
152
+ }
153
+ const sleep$1 = (ms) => new Promise((r) => setTimeout(r, ms));
154
+ /** Does something on the socket answer the Conveno handshake? */
155
+ async function reachable(ctx) {
156
+ try {
157
+ await (await ctx.connect(connectOpts(ctx, false))).close().catch(() => void 0);
158
+ return true;
159
+ } catch {
160
+ return false;
161
+ }
162
+ }
163
+ const lockExists = (ctx) => access(dataPaths(ctx.platform, ctx.dataDir).lock).then(() => true, () => false);
164
+ /** Poll until `done()` holds or `ms` pass. Returns whether it held. */
165
+ async function waitFor(done, ms) {
166
+ const deadline = Date.now() + ms;
167
+ for (;;) {
168
+ if (await done()) return true;
169
+ if (Date.now() >= deadline) return false;
170
+ await sleep$1(50);
171
+ }
172
+ }
173
+ const norm = (text) => text.replaceAll("\\", "/").toLowerCase();
174
+ /**
175
+ * Does this command line belong to the Conveno daemon? It must run the daemon's entry script: the
176
+ * one this install resolved, any installed `@conveno/cli`'s `daemon.js`, or the `bin.js` of the
177
+ * `@conveno/daemon` package that releases before 0.1.1 started.
178
+ */
179
+ function isConvenoDaemonCommand(commandLine, daemonEntry) {
180
+ const line = norm(commandLine);
181
+ if (daemonEntry !== void 0 && line.includes(norm(daemonEntry))) return true;
182
+ return /@conveno\/cli\/(?:[^ ]+\/)?daemon\.js|@conveno\/daemon\/(?:[^ ]+\/)?bin\.js/.test(line);
183
+ }
184
+ const STOP_FIX = (t) => `then run ${cmd(t, "conveno daemon status")}`;
185
+ /**
186
+ * `conveno daemon stop`. The normal path asks the daemon to shut itself down over the control
187
+ * channel (`daemon.shutdown`), the way Docker and pm2 do. That needs no signal and no external
188
+ * tool, so it works for a normal user in a Windows SSH session. Only when the daemon does not answer,
189
+ * and its lock pid is verified to be the daemon, is the process ended directly.
190
+ */
191
+ async function stopDaemon(ctx, plain = false) {
192
+ const t = ctx.theme;
193
+ const lock = dataPaths(ctx.platform, ctx.dataDir).lock;
194
+ const pid = await lockPid(ctx);
195
+ const named = pid === null ? "" : ` (pid ${pid})`;
196
+ let client;
197
+ try {
198
+ client = await ctx.connect(connectOpts(ctx, false));
199
+ } catch {
200
+ client = void 0;
201
+ }
202
+ if (client) {
203
+ try {
204
+ await client["daemon.shutdown"]({});
205
+ } catch (e) {
206
+ await client.close().catch(() => void 0);
207
+ return fail(ctx, {
208
+ what: `The background service${named} did not accept the stop request`,
209
+ detail: [plainError(e)],
210
+ fix: `${pid === null ? "Stop the process that owns the daemon socket yourself" : `Stop pid ${pid} yourself`}, ${STOP_FIX(t)}.`,
211
+ exit: 1,
212
+ ref: "e_daemon_stop"
213
+ });
214
+ }
215
+ await client.close().catch(() => void 0);
216
+ if (!await waitFor(async () => !await reachable(ctx) && !await lockExists(ctx) && (pid === null || !ctx.isAlive(pid)), ctx.stopTimeoutMs)) return fail(ctx, {
217
+ what: `The background service${named} is still running after ${Math.round(ctx.stopTimeoutMs / 1e3)}s`,
218
+ detail: ["It accepted the stop request, but its process, socket or lock file is still there."],
219
+ fix: `${pid === null ? "Stop the process that owns the daemon socket yourself" : `Stop pid ${pid} yourself`}, ${STOP_FIX(t)}.`,
220
+ exit: 1,
221
+ ref: "e_daemon_stop"
222
+ });
223
+ ctx.out(`${t.status("ok")} Stopped ${plain ? "Conveno's background service" : "the daemon"}${named}.\n`);
224
+ return 0;
225
+ }
226
+ if (pid === null) {
227
+ ctx.out(`${t.status("info")} Conveno's background service is not running. Nothing to stop.\n`);
228
+ return 0;
229
+ }
230
+ const stale = async () => {
231
+ await rm(lock, { force: true }).catch(() => void 0);
232
+ ctx.out(`${t.status("info")} Nothing answered as the Conveno daemon, so no process was stopped. Removed the stale lock file (it named pid ${pid}).\n`);
233
+ return 0;
234
+ };
235
+ if (!ctx.isAlive(pid)) return stale();
236
+ const commandLine = await ctx.commandLineOf(pid);
237
+ if (commandLine === null) return fail(ctx, {
238
+ what: `The background service did not answer, and pid ${pid} could not be checked`,
239
+ detail: ["Conveno could not read that process's command line, so it cannot tell whether it is the daemon. It stopped nothing."],
240
+ fix: `If pid ${pid} is the Conveno daemon, end it yourself (Task Manager on Windows, \`kill ${pid}\` elsewhere), ${STOP_FIX(t)}.`,
241
+ exit: 1,
242
+ ref: "e_daemon_lock"
243
+ });
244
+ if (!isConvenoDaemonCommand(commandLine, ctx.daemonEntry)) return stale();
245
+ try {
246
+ ctx.kill(pid);
247
+ } catch (e) {
248
+ return fail(ctx, {
249
+ what: `Could not stop the daemon (pid ${pid})`,
250
+ detail: [plainError(e)],
251
+ fix: `Stop that process yourself, ${STOP_FIX(t)}.`,
252
+ exit: 1,
253
+ ref: "e_daemon_stop"
254
+ });
255
+ }
256
+ if (!await waitFor(() => !ctx.isAlive(pid), ctx.stopTimeoutMs)) return fail(ctx, {
257
+ what: `The background service (pid ${pid}) is still running after ${Math.round(ctx.stopTimeoutMs / 1e3)}s`,
258
+ detail: ["It did not answer, was ended, and has not exited."],
259
+ fix: `Stop that process yourself, ${STOP_FIX(t)}.`,
260
+ exit: 1,
261
+ ref: "e_daemon_stop"
262
+ });
263
+ await rm(lock, { force: true }).catch(() => void 0);
264
+ ctx.out(`${t.status("ok")} Stopped ${plain ? "Conveno's background service" : "the daemon"} (pid ${pid}). It was not answering, so it was ended directly.\n`);
265
+ return 0;
266
+ }
267
+ /**
268
+ * Stop the daemon if one is running, and say nothing when none is. Used before `conveno uninstall`
269
+ * changes any file, because a running daemon keeps files open (on Windows that blocks removing them).
270
+ * Returns 0 when nothing is left running, else the exit code of the failed stop.
271
+ */
272
+ async function stopDaemonIfRunning(ctx) {
273
+ if (!await reachable(ctx)) {
274
+ const pid = await lockPid(ctx);
275
+ if (pid === null || !ctx.isAlive(pid)) return 0;
276
+ }
277
+ return stopDaemon(ctx, true);
278
+ }
279
+ const SUBCOMMANDS = [
280
+ "start",
281
+ "stop",
282
+ "status"
283
+ ];
284
+ async function runDaemon(ctx, argv) {
285
+ const t = ctx.theme;
286
+ const sub = argv[0];
287
+ if (sub === "start") {
288
+ try {
289
+ await (await ctx.connect(connectOpts(ctx, true))).close().catch(() => void 0);
290
+ } catch (e) {
291
+ const problem = daemonProblem(t, e);
292
+ return fail(ctx, {
293
+ what: "The Conveno daemon did not start",
294
+ detail: [problem.why],
295
+ fix: problem.notRunning ? `Run ${cmd(t, "conveno doctor")} to check the install, then try again.` : problem.fix,
296
+ exit: 1,
297
+ ref: "e_daemon_start"
298
+ });
299
+ }
300
+ const pid = await lockPid(ctx);
301
+ ctx.out(`${t.status("ok")} Daemon running${pid ? `, pid ${pid}` : ""}.\n`);
302
+ return 0;
303
+ }
304
+ if (sub === "status") {
305
+ const pid = await lockPid(ctx);
306
+ try {
307
+ await (await ctx.connect(connectOpts(ctx, false))).close().catch(() => void 0);
308
+ ctx.out(`${t.status("ok")} daemon running${pid ? `, pid ${pid}` : ""}\n`);
309
+ return 0;
310
+ } catch (e) {
311
+ const problem = daemonProblem(t, e);
312
+ if (problem.notRunning) ctx.out(`${t.glyph("offline")} daemon not running\n`);
313
+ else {
314
+ ctx.out(`${t.status("error")} daemon cannot be reached\n`);
315
+ ctx.err(warnBlock(t, "Conveno's background service cannot be reached.", problem.fix, problem.why));
316
+ }
317
+ return 1;
318
+ }
319
+ }
320
+ if (sub === "stop") return stopDaemon(ctx);
321
+ const suggestion = sub ? closest(sub, SUBCOMMANDS) : void 0;
322
+ return fail(ctx, {
323
+ what: sub ? `Unknown daemon command "${sub}"` : "conveno daemon needs a command",
324
+ fix: `Run ${cmd(t, "conveno daemon start")}, ${cmd(t, "conveno daemon stop")} or ${cmd(t, "conveno daemon status")}.`,
325
+ ...suggestion ? { didYouMean: `Did you mean ${suggestion}?` } : {},
326
+ exit: 2,
327
+ ref: "e_usage"
328
+ });
329
+ }
143
330
  const PAIR_TIMEOUT_MS = 3e5;
144
331
  /**
145
332
  * Run `run` with a daemon client. Commands that change something start the daemon when needed;
@@ -995,8 +1182,8 @@ async function markRestored(ctx, found) {
995
1182
  await writeFile(join(found.dir, MANIFEST_NAME), `${JSON.stringify(done, null, 2)}\n`, { mode: 384 });
996
1183
  }
997
1184
  // src/init.ts
998
- const CODEX_NOTE = "Codex asks you to trust new hooks once: run /hooks inside Codex.";
999
- const CURSOR_NOTE = "Cursor CLI can ask to approve the Conveno MCP server when you start it in your home folder. Approve it once there with: cursor-agent mcp enable conveno";
1185
+ const CODEX_NOTE = "Codex asks you to approve Conveno once: run /hooks inside Codex.";
1186
+ const CURSOR_NOTE = "Cursor can ask you to approve Conveno when you start it in your home folder. Approve it once there with: cursor-agent mcp enable conveno";
1000
1187
  /** Detect every adapter. A detection that throws counts as not installed. */
1001
1188
  async function detectAll(ctx, adapters = ctx.adapters) {
1002
1189
  const env = adapterEnv(ctx);
@@ -1039,7 +1226,7 @@ function parseCliList(raw, ctx) {
1039
1226
  }
1040
1227
  function printDetections(ctx, found) {
1041
1228
  const t = ctx.theme;
1042
- ctx.out(`${t.bold("Looking for AI coding CLIs on this machine")}\n`);
1229
+ ctx.out(`${t.bold("Looking for AI tools on this machine")}\n`);
1043
1230
  const rows = found.map(({ adapter, detection }) => detection.installed ? [
1044
1231
  ` ${t.status("ok")} ${adapter.cli}`,
1045
1232
  adapter.displayName,
@@ -1108,6 +1295,10 @@ async function confirmAndApply(ctx, items, opts) {
1108
1295
  return { exit: 0 };
1109
1296
  }
1110
1297
  }
1298
+ if (opts.beforeApply) {
1299
+ const code = await opts.beforeApply();
1300
+ if (code !== 0) return { exit: code };
1301
+ }
1111
1302
  try {
1112
1303
  return { applied: await applyChanges(ctx, items, opts.markRestored ? { markRestored: true } : {}) };
1113
1304
  } catch (e) {
@@ -1147,11 +1338,33 @@ function extraChanges(base, withOpt) {
1147
1338
  const had = new Set(base.map((i) => `${i.change.path}\0${i.change.after}\0${i.change.kind}`));
1148
1339
  return withOpt.filter((i) => !had.has(`${i.change.path}\0${i.change.after}\0${i.change.kind}`));
1149
1340
  }
1150
- async function runInit(ctx, argv) {
1341
+ /** `conveno setup` and its older name `conveno init`. Both end here. */
1342
+ async function runInit(ctx, argv, name = "init") {
1343
+ const first = COMMANDS.find((c) => c.name === name);
1344
+ const early = first ? parseFlags(ctx, first, argv) : void 0;
1345
+ if (typeof early === "number") return early;
1346
+ const lead = early?.values.lead;
1347
+ if (typeof lead === "string" && !CLI_KINDS.includes(lead)) {
1348
+ const suggestion = closest(lead, [...CLI_KINDS]);
1349
+ return fail(ctx, {
1350
+ what: `Unknown AI tool "${lead}" for --lead`,
1351
+ detail: [`Known AI tools: ${CLI_KINDS.join(", ")}.`],
1352
+ fix: `Pass ${cmd(ctx.theme, `--lead ${CLI_KINDS[0]}`)} or leave it out.`,
1353
+ ...suggestion ? { didYouMean: `Did you mean ${suggestion}?` } : {},
1354
+ exit: 2,
1355
+ ref: "e_usage"
1356
+ });
1357
+ }
1151
1358
  const outcome = {};
1152
- const code = await initSetup(ctx, argv, outcome);
1153
- if (code !== 0 || !outcome.offer) return code;
1154
- const spec = COMMANDS.find((c) => c.name === "init");
1359
+ const code = await initSetup(ctx, argv, outcome, name);
1360
+ if (code !== 0) return code;
1361
+ if (typeof lead === "string" && early?.values["dry-run"] !== true) {
1362
+ writeSettings(dataPaths(ctx.platform, ctx.dataDir).settings, { leadCli: lead });
1363
+ const shown = ctx.adapters.find((a) => a.cli === lead)?.displayName ?? lead;
1364
+ ctx.out(`${ctx.theme.status("ok")} ${shown} will lead when it starts and nobody else leads.\n`);
1365
+ }
1366
+ if (!outcome.offer) return code;
1367
+ const spec = COMMANDS.find((c) => c.name === name);
1155
1368
  const parsed = spec ? parseFlags(ctx, spec, argv) : void 0;
1156
1369
  const values = typeof parsed === "object" ? parsed.values : {};
1157
1370
  await offerAcpAdapters(ctx, {
@@ -1161,17 +1374,17 @@ async function runInit(ctx, argv) {
1161
1374
  });
1162
1375
  return 0;
1163
1376
  }
1164
- async function initSetup(ctx, argv, outcome) {
1377
+ async function initSetup(ctx, argv, outcome, name) {
1165
1378
  const t = ctx.theme;
1166
1379
  const started = ctx.now();
1167
- const spec = COMMANDS.find((c) => c.name === "init");
1380
+ const spec = COMMANDS.find((c) => c.name === name);
1168
1381
  if (!spec) return 2;
1169
1382
  const parsed = parseFlags(ctx, spec, argv);
1170
1383
  if (typeof parsed === "number") return parsed;
1171
1384
  const values = parsed.values;
1172
1385
  if (values["acp-adapters"] === true && values["no-acp-adapters"] === true) return fail(ctx, {
1173
1386
  what: "Use --acp-adapters or --no-acp-adapters, not both",
1174
- fix: `Run ${cmd(t, "conveno init --help")} to see the options.`,
1387
+ fix: `Run ${cmd(t, `conveno ${name} --help`)} to see the options.`,
1175
1388
  exit: 2,
1176
1389
  ref: "e_usage"
1177
1390
  });
@@ -1187,9 +1400,9 @@ async function initSetup(ctx, argv, outcome) {
1187
1400
  printDetections(ctx, found);
1188
1401
  const installed = found.filter((f) => f.detection.installed);
1189
1402
  if (installed.length === 0) return fail(ctx, {
1190
- what: "No supported AI coding CLI was found",
1403
+ what: "No supported AI tool was found",
1191
1404
  detail: [`Looked for ${chosen.map((a) => a.displayName).join(", ")} on PATH.`],
1192
- fix: "Install one of them, then run conveno init again.",
1405
+ fix: `Install one of them, then run conveno ${name} again.`,
1193
1406
  exit: 1,
1194
1407
  ref: "e_no_cli"
1195
1408
  });
@@ -1201,7 +1414,7 @@ async function initSetup(ctx, argv, outcome) {
1201
1414
  if (!known.has(id)) return fail(ctx, {
1202
1415
  what: `Unknown option "${id}" for --accept`,
1203
1416
  detail: [known.size > 0 ? `Known: ${[...known].join(", ")}.` : "There are none."],
1204
- fix: `Run ${cmd(t, "conveno init --help")} to see the options.`,
1417
+ fix: `Run ${cmd(t, `conveno ${name} --help`)} to see the options.`,
1205
1418
  exit: 2,
1206
1419
  ref: "e_usage"
1207
1420
  });
@@ -1217,7 +1430,7 @@ async function initSetup(ctx, argv, outcome) {
1217
1430
  }
1218
1431
  const { items, failures } = await collectPlans(ctx, installed, "plan", void 0, [...accepted]);
1219
1432
  if (failures.length > 0) {
1220
- reportFailures(ctx, failures, "conveno init --cli <others>");
1433
+ reportFailures(ctx, failures, `conveno ${name} --cli <others>`);
1221
1434
  return 1;
1222
1435
  }
1223
1436
  const extras = [];
@@ -1242,18 +1455,18 @@ async function initSetup(ctx, argv, outcome) {
1242
1455
  ctx.out(`${t.bold(x.option.question)}\n ${t.paint("quiet", `Not turned on. With --accept ${x.option.id} Conveno would also change:`)}\n\n`);
1243
1456
  presentChanges(ctx, x.items);
1244
1457
  }
1245
- ctx.out(`${t.status("info")} Dry run: nothing was written. Run ${cmd(t, "conveno init")} to apply.\n`);
1458
+ ctx.out(`${t.status("info")} Dry run: nothing was written. Run ${cmd(t, `conveno ${name}`)} to apply.\n`);
1246
1459
  return 0;
1247
1460
  }
1248
1461
  const result = await confirmAndApply(ctx, items, {
1249
1462
  yes: values.yes === true,
1250
1463
  verb: "Apply",
1251
- rerun: "conveno init"
1464
+ rerun: `conveno ${name}`
1252
1465
  });
1253
1466
  if ("exit" in result) return result.exit;
1254
1467
  const byCli = /* @__PURE__ */ new Map();
1255
1468
  for (const h of result.applied.how) byCli.set(h.cli, [...byCli.get(h.cli) ?? [], h.via]);
1256
- const rows = [...byCli].map(([cli, vias]) => [` ${t.status("ok")} ${cli}`, vias.every((v) => v === "command") ? "configured with the CLI's own command" : "configured"]);
1469
+ const rows = [...byCli].map(([cli, vias]) => [` ${t.status("ok")} ${cli}`, vias.every((v) => v === "command") ? "set up with its own command" : "configured"]);
1257
1470
  ctx.out(`${columns(rows).join("\n")}\n\n`);
1258
1471
  ctx.out(`${t.status("ok")} ${t.bold("Done.")} ${seconds(started, ctx.now())}\n`);
1259
1472
  ctx.out(` Backups are in ${tilde(result.applied.backupDir, ctx.home)}.\n`);
@@ -1264,6 +1477,19 @@ async function initSetup(ctx, argv, outcome) {
1264
1477
  outcome.offer = installed.map((f) => f.adapter);
1265
1478
  return 0;
1266
1479
  }
1480
+ /**
1481
+ * `conveno setup`. In a terminal with no --yes it opens the onboarding in the app. Anywhere else
1482
+ * it does what `conveno init` does, and also saves --lead.
1483
+ */
1484
+ async function runSetup(ctx, argv) {
1485
+ const spec = COMMANDS.find((c) => c.name === "setup");
1486
+ if (!spec) return 2;
1487
+ const parsed = parseFlags(ctx, spec, argv);
1488
+ if (typeof parsed === "number") return parsed;
1489
+ const v = parsed.values;
1490
+ if (ctx.interactive && v.yes !== true && v["dry-run"] !== true) return (await import("./run-C32oP2c_.js")).runTui(ctx, { start: "setup" });
1491
+ return runInit(ctx, argv, "setup");
1492
+ }
1267
1493
  // src/doctor.ts
1268
1494
  /** What the plan says about one part: nothing to do, an addition, or an update to what is there. */
1269
1495
  function partState(changes, component) {
@@ -1498,4 +1724,137 @@ async function runDoctor(ctx, argv = []) {
1498
1724
  ctx.out(`\n${ok} ok, ${plural(warnings, "warning")}, ${plural(problems, "problem")}\n`);
1499
1725
  return problems > 0 ? 1 : 0;
1500
1726
  }
1501
- export { runLogout as C, runLogin as S, PAIR_TIMEOUT_MS as _, detectAll as a, openInBrowser as b, runInit as c, applyChanges as d, listManifests as f, unifiedDiff as g, restoreEntry as h, confirmAndApply as i, staleFailure as l, previewRestore as m, runDoctor as n, pendingOptions as o, markRestored as p, collectPlans as r, reportFailures as s, inspect as t, StaleError as u, runDevices as v, runAccount as x, runRelay as y };
1727
+ // src/uninstall.ts
1728
+ const NOTE = {
1729
+ restore: "restored byte for byte",
1730
+ remove: "removed, it did not exist before",
1731
+ edit: "edited since setup, so only Conveno's entries are removed",
1732
+ gone: "already gone, left as it is"
1733
+ };
1734
+ /**
1735
+ * The files as init found them, from the backups: their text, or null when they did not exist. A
1736
+ * backup that cannot be read leaves its file out, and the adapter then treats what it finds as
1737
+ * Conveno's own.
1738
+ */
1739
+ async function baselineOf(dir, entries) {
1740
+ const out = /* @__PURE__ */ new Map();
1741
+ for (const e of entries) if (e.backup === null) out.set(e.path, null);
1742
+ else try {
1743
+ out.set(e.path, await readFile(join(dir, e.backup), "utf8"));
1744
+ } catch {}
1745
+ return out;
1746
+ }
1747
+ /** Remove Conveno's own entries from files that changed since init, through each adapter. */
1748
+ async function removeOwnEntries(ctx, dir, entries) {
1749
+ if (entries.length === 0) return {
1750
+ edited: [],
1751
+ failures: []
1752
+ };
1753
+ const clis = new Set(entries.map((e) => e.cli));
1754
+ const { items, failures } = await collectPlans(ctx, (await detectAll(ctx)).filter((f) => clis.has(f.adapter.cli)), "uninstallPlan", await baselineOf(dir, entries));
1755
+ const wanted = new Set(entries.map((e) => e.path));
1756
+ const mine = items.filter((i) => wanted.has(i.change.path));
1757
+ if (mine.length > 0) await applyChanges(ctx, mine, { markRestored: true });
1758
+ return {
1759
+ edited: mine.map((i) => i.change.path),
1760
+ failures
1761
+ };
1762
+ }
1763
+ async function restoreAll(ctx, manifests) {
1764
+ const restored = [];
1765
+ const edited = [];
1766
+ const untouched = [];
1767
+ for (const found of manifests) {
1768
+ const needEdit = [];
1769
+ for (const entry of found.manifest.entries) {
1770
+ const action = await restoreEntry(found.dir, entry);
1771
+ if (action === "edit") needEdit.push(entry);
1772
+ else if (action === "gone") untouched.push(entry.path);
1773
+ else restored.push(entry.path);
1774
+ }
1775
+ const r = await removeOwnEntries(ctx, found.dir, needEdit);
1776
+ if (r.failures.length > 0) {
1777
+ reportFailures(ctx, r.failures, "conveno uninstall");
1778
+ throw new Error("A config file could not be read, so it was left as it is.");
1779
+ }
1780
+ edited.push(...r.edited);
1781
+ for (const e of needEdit) if (!r.edited.includes(e.path)) untouched.push(e.path);
1782
+ await markRestored(ctx, found);
1783
+ }
1784
+ return {
1785
+ restored,
1786
+ edited,
1787
+ untouched
1788
+ };
1789
+ }
1790
+ async function runUninstall(ctx, argv) {
1791
+ const t = ctx.theme;
1792
+ const started = ctx.now();
1793
+ const spec = COMMANDS.find((c) => c.name === "uninstall");
1794
+ if (!spec) return 2;
1795
+ const parsed = parseFlags(ctx, spec, argv);
1796
+ if (typeof parsed === "number") return parsed;
1797
+ const yes = parsed.values.yes === true;
1798
+ const manifests = await listManifests(ctx).catch(() => []);
1799
+ if (manifests.length > 0) {
1800
+ const rows = await previewRestore(manifests);
1801
+ const made = manifests.map((m) => localStamp(m.manifest.createdAt));
1802
+ ctx.out(`${t.bold(`Conveno will undo ${plural(manifests.length, "install")}`)}, made ${made.join(", ")} (local time).\n\n`);
1803
+ ctx.out(`${columns(rows.map((r) => [` ${tilde(r.entry.path, ctx.home)}`, t.paint("quiet", NOTE[r.action])])).join("\n")}\n\n`);
1804
+ if (!yes) {
1805
+ if (!ctx.interactive) return fail(ctx, {
1806
+ what: "Needs a terminal to confirm",
1807
+ detail: ["No files were changed."],
1808
+ fix: `Run ${cmd(t, "conveno uninstall --yes")} to undo the changes listed above.`,
1809
+ exit: 2,
1810
+ ref: "e_no_tty"
1811
+ });
1812
+ if (!await ctx.confirm("Undo these changes?", false)) {
1813
+ ctx.out(`${t.status("info")} Nothing was changed.\n`);
1814
+ return 0;
1815
+ }
1816
+ }
1817
+ const stopped = await stopDaemonIfRunning(ctx);
1818
+ if (stopped !== 0) return stopped;
1819
+ let result;
1820
+ try {
1821
+ result = await restoreAll(ctx, manifests);
1822
+ } catch (e) {
1823
+ if (e instanceof StaleError) return staleFailure(ctx, e, "conveno uninstall");
1824
+ return fail(ctx, {
1825
+ what: "Could not restore a file",
1826
+ detail: [plainError(e), `The backups are still in ${tilde(manifests[0]?.dir ?? ctx.dataDir, ctx.home)} and the other backup folders next to it.`],
1827
+ fix: "Fix the problem above, then run conveno uninstall again.",
1828
+ exit: 1,
1829
+ ref: "e_restore"
1830
+ });
1831
+ }
1832
+ ctx.out(`${t.status("ok")} ${t.bold("Done.")} ${seconds(started, ctx.now())}\n`);
1833
+ ctx.out(` Restored ${plural(result.restored.length, "file")} to how they were before setup.\n`);
1834
+ if (result.edited.length > 0) ctx.out(` Edited, not restored, because they changed since setup: ${result.edited.map((p) => tilde(p, ctx.home)).join(", ")}. Only Conveno's entries were removed.\n`);
1835
+ ctx.out(" Restart open sessions to drop Conveno.\n");
1836
+ return 0;
1837
+ }
1838
+ const { items, failures } = await collectPlans(ctx, await detectAll(ctx), "uninstallPlan");
1839
+ if (failures.length > 0) {
1840
+ reportFailures(ctx, failures, "conveno uninstall");
1841
+ return 1;
1842
+ }
1843
+ if (items.length === 0) {
1844
+ ctx.out(`${t.status("ok")} Nothing to remove. No Conveno entries were found in any supported CLI.\n`);
1845
+ return 0;
1846
+ }
1847
+ ctx.out(`${t.status("info")} No install backup found, so Conveno will remove only its own entries.\n\n`);
1848
+ const result = await confirmAndApply(ctx, items, {
1849
+ yes,
1850
+ verb: "Remove",
1851
+ rerun: "conveno uninstall",
1852
+ markRestored: true,
1853
+ beforeApply: () => stopDaemonIfRunning(ctx)
1854
+ });
1855
+ if ("exit" in result) return result.exit;
1856
+ ctx.out(`${t.status("ok")} ${t.bold("Done.")} ${seconds(started, ctx.now())}\n`);
1857
+ ctx.out(" Removed the Conveno entries. Restart open sessions to drop Conveno.\n");
1858
+ return 0;
1859
+ }
1860
+ export { showCode as S, stopDaemonIfRunning as _, collectPlans as a, runLogin as b, runInit as c, applyChanges as d, unifiedDiff as f, runDaemon as g, runRelay as h, runDoctor as i, runSetup as l, runDevices as m, inspect as n, detectAll as o, PAIR_TIMEOUT_MS as p, partState as r, pendingOptions as s, runUninstall as t, StaleError as u, openInBrowser as v, runLogout as x, runAccount as y };
@@ -1,8 +1,8 @@
1
- import { n as isOneShotGrok } from "./dist-Dd31Fg0h.js";
2
- import { Ft as senderOf, Nt as runWaker, X as isFromOwner, wt as renderBody } from "./dist-D2hMvcZu.js";
1
+ import { n as isOneShotGrok } from "./dist-CcoTmwrf.js";
2
+ import { Ft as senderOf, Nt as runWaker, X as isFromOwner, wt as renderBody } from "./dist-BBdba94T.js";
3
3
  import { n as connectOpts } from "./ctx-tYftvhz_.js";
4
- import { t as daemonProblem } from "./daemonError-DNAKEyRT.js";
5
- import { t as findSession } from "./pick-DoyocW55.js";
4
+ import { t as daemonProblem } from "./daemonError-DJ-P55nH.js";
5
+ import { t as findSession } from "./pick-Bi1yJDh6.js";
6
6
  // src/watch.ts
7
7
  const CONNECT_MAX_RETRY_MS = 3e4;
8
8
  const CONNECT_GIVE_UP_MS = 3e5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conveno/cli",
3
- "version": "0.2.0-rc.7",
3
+ "version": "0.2.0-rc.8",
4
4
  "description": "Connect AI coding CLI sessions so they can message each other.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -52,26 +52,29 @@
52
52
  "zod": "4.6.7"
53
53
  },
54
54
  "devDependencies": {
55
- "@conveno/acp": "0.2.0-rc.7",
56
- "@conveno/adapter-antigravity": "0.2.0-rc.7",
57
- "@conveno/adapter-claude": "0.2.0-rc.7",
58
- "@conveno/adapter-codex": "0.2.0-rc.7",
59
- "@conveno/adapter-copilot": "0.2.0-rc.7",
60
- "@conveno/adapter-cursor": "0.2.0-rc.7",
61
- "@conveno/adapter-grok": "0.2.0-rc.7",
62
- "@conveno/adapter-opencode": "0.2.0-rc.7",
63
- "@conveno/brand": "0.2.0-rc.7",
64
- "@conveno/client": "0.2.0-rc.7",
65
- "@conveno/core": "0.2.0-rc.7",
66
- "@conveno/daemon": "0.2.0-rc.7",
67
- "@conveno/mcp": "0.2.0-rc.7",
68
- "@conveno/protocol": "0.2.0-rc.7",
55
+ "@conveno/acp": "0.2.0-rc.8",
56
+ "@conveno/adapter-antigravity": "0.2.0-rc.8",
57
+ "@conveno/adapter-claude": "0.2.0-rc.8",
58
+ "@conveno/adapter-codex": "0.2.0-rc.8",
59
+ "@conveno/adapter-copilot": "0.2.0-rc.8",
60
+ "@conveno/adapter-cursor": "0.2.0-rc.8",
61
+ "@conveno/adapter-grok": "0.2.0-rc.8",
62
+ "@conveno/adapter-opencode": "0.2.0-rc.8",
63
+ "@conveno/brand": "0.2.0-rc.8",
64
+ "@conveno/client": "0.2.0-rc.8",
65
+ "@conveno/core": "0.2.0-rc.8",
66
+ "@conveno/daemon": "0.2.0-rc.8",
67
+ "@conveno/mcp": "0.2.0-rc.8",
68
+ "@conveno/protocol": "0.2.0-rc.8",
69
69
  "@types/react": "19.3.0",
70
70
  "ink-testing-library": "4.0.0"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",
74
74
  "typecheck": "tsc -p tsconfig.json",
75
- "test": "vitest run"
75
+ "test": "vitest run",
76
+ "kit-preview": "tsdown -c false scripts/kit-preview.tsx -d node_modules/.kit-preview --platform node --target node24 --no-dts --clean && node node_modules/.kit-preview/kit-preview.js",
77
+ "onboarding-preview": "tsdown -c false scripts/onboarding-preview.tsx -d node_modules/.onboarding-preview --platform node --target node24 --no-dts --clean && node node_modules/.onboarding-preview/onboarding-preview.js",
78
+ "home-preview": "tsdown -c false scripts/home-preview.tsx -d node_modules/.home-preview --platform node --target node24 --no-dts --clean && node node_modules/.home-preview/home-preview.js"
76
79
  }
77
80
  }
@@ -1 +0,0 @@
1
- export { i as runHookEntry } from "./hook-entry-BXmSN--S.js";