claudemesh-cli 0.10.2 → 0.10.4

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 (2) hide show
  1. package/dist/index.js +169 -168
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -40189,7 +40189,7 @@ var package_default;
40189
40189
  var init_package = __esm(() => {
40190
40190
  package_default = {
40191
40191
  name: "claudemesh-cli",
40192
- version: "0.10.2",
40192
+ version: "0.10.4",
40193
40193
  description: "Claude Code MCP client for claudemesh — peer mesh messaging between Claude sessions.",
40194
40194
  keywords: [
40195
40195
  "claude-code",
@@ -54911,11 +54911,65 @@ init_config();
54911
54911
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
54912
54912
  import { homedir as homedir6, hostname as hostname4 } from "node:os";
54913
54913
  import { join as join6 } from "node:path";
54914
+ import { createInterface as createInterface3 } from "node:readline";
54915
+
54916
+ // src/commands/connect.ts
54917
+ import { hostname as hostname3 } from "node:os";
54914
54918
  import { createInterface as createInterface2 } from "node:readline";
54919
+ init_config();
54920
+ async function pickMesh2(meshes) {
54921
+ console.log(`
54922
+ Select mesh:`);
54923
+ meshes.forEach((m, i) => {
54924
+ console.log(` ${i + 1}) ${m.slug}`);
54925
+ });
54926
+ console.log("");
54927
+ const rl = createInterface2({ input: process.stdin, output: process.stdout });
54928
+ return new Promise((resolve2) => {
54929
+ rl.question(" Choice [1]: ", (answer) => {
54930
+ rl.close();
54931
+ const idx = parseInt(answer || "1", 10) - 1;
54932
+ if (idx >= 0 && idx < meshes.length) {
54933
+ resolve2(meshes[idx]);
54934
+ } else {
54935
+ console.error(" Invalid choice, using first mesh.");
54936
+ resolve2(meshes[0]);
54937
+ }
54938
+ });
54939
+ });
54940
+ }
54941
+ async function withMesh(opts, fn) {
54942
+ const config2 = loadConfig();
54943
+ if (config2.meshes.length === 0) {
54944
+ console.error("No meshes joined. Run `claudemesh join <url>` first.");
54945
+ process.exit(1);
54946
+ }
54947
+ let mesh;
54948
+ if (opts.meshSlug) {
54949
+ const found = config2.meshes.find((m) => m.slug === opts.meshSlug);
54950
+ if (!found) {
54951
+ console.error(`Mesh "${opts.meshSlug}" not found. Joined: ${config2.meshes.map((m) => m.slug).join(", ")}`);
54952
+ process.exit(1);
54953
+ }
54954
+ mesh = found;
54955
+ } else if (config2.meshes.length === 1) {
54956
+ mesh = config2.meshes[0];
54957
+ } else {
54958
+ mesh = await pickMesh2(config2.meshes);
54959
+ }
54960
+ const displayName = opts.displayName ?? config2.displayName ?? `${hostname3()}-${process.pid}`;
54961
+ const client2 = new BrokerClient(mesh, { displayName });
54962
+ try {
54963
+ await client2.connect();
54964
+ const result = await fn(client2, mesh);
54965
+ return result;
54966
+ } finally {
54967
+ client2.close();
54968
+ }
54969
+ }
54915
54970
 
54916
54971
  // src/commands/peers.ts
54917
54972
  init_config();
54918
- import { hostname as hostname3 } from "node:os";
54919
54973
  async function runPeers(flags) {
54920
54974
  const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
54921
54975
  const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
@@ -54923,62 +54977,121 @@ async function runPeers(flags) {
54923
54977
  const green2 = (s) => useColor ? `\x1B[32m${s}\x1B[39m` : s;
54924
54978
  const yellow2 = (s) => useColor ? `\x1B[33m${s}\x1B[39m` : s;
54925
54979
  const config2 = loadConfig();
54926
- const meshes = flags.mesh ? config2.meshes.filter((m) => m.slug === flags.mesh) : config2.meshes;
54927
- if (meshes.length === 0) {
54928
- console.error(flags.mesh ? `Mesh "${flags.mesh}" not found. Joined: ${config2.meshes.map((m) => m.slug).join(", ")}` : "No meshes joined. Run `claudemesh join <url>` first.");
54980
+ const slugs = flags.mesh ? [flags.mesh] : config2.meshes.map((m) => m.slug);
54981
+ if (slugs.length === 0) {
54982
+ console.error("No meshes joined. Run `claudemesh join <url>` first.");
54929
54983
  process.exit(1);
54930
54984
  }
54931
- const allPeers = [];
54932
- for (const mesh of meshes) {
54933
- const displayName = config2.displayName ?? `${hostname3()}-${process.pid}`;
54934
- const client2 = new BrokerClient(mesh, { displayName });
54985
+ const allJson = [];
54986
+ for (const slug of slugs) {
54935
54987
  try {
54936
- await client2.connect();
54937
- const peers = await client2.listPeers();
54938
- if (flags.json) {
54939
- allPeers.push({ mesh: mesh.slug, peers });
54940
- continue;
54941
- }
54942
- console.log(bold3(`Peers on ${mesh.slug}`) + dim2(` (${peers.length})`));
54943
- console.log("");
54944
- if (peers.length === 0) {
54945
- console.log(dim2(" No peers connected."));
54946
- } else {
54947
- for (const p of peers) {
54948
- const groups = p.groups.length ? " [" + p.groups.map((g) => `@${g.name}${g.role ? `:${g.role}` : ""}`).join(", ") + "]" : "";
54949
- const statusIcon = p.status === "working" ? yellow2("●") : green2("●");
54950
- const name = bold3(p.displayName);
54951
- const meta2 = [];
54952
- if (p.peerType)
54953
- meta2.push(p.peerType);
54954
- if (p.channel)
54955
- meta2.push(p.channel);
54956
- if (p.model)
54957
- meta2.push(p.model);
54958
- const metaStr = meta2.length ? dim2(` (${meta2.join(", ")})`) : "";
54959
- const cwdStr = p.cwd ? dim2(` cwd: ${p.cwd}`) : "";
54960
- const summary = p.summary ? dim2(` ${p.summary}`) : "";
54961
- console.log(` ${statusIcon} ${name}${groups}${metaStr}${summary}`);
54962
- if (cwdStr)
54963
- console.log(` ${cwdStr}`);
54988
+ await withMesh({ meshSlug: slug }, async (client2, mesh) => {
54989
+ const peers = await client2.listPeers();
54990
+ if (flags.json) {
54991
+ allJson.push({ mesh: mesh.slug, peers });
54992
+ return;
54964
54993
  }
54965
- }
54966
- console.log("");
54994
+ console.log(bold3(`Peers on ${mesh.slug}`) + dim2(` (${peers.length})`));
54995
+ console.log("");
54996
+ if (peers.length === 0) {
54997
+ console.log(dim2(" No peers connected."));
54998
+ } else {
54999
+ for (const p of peers) {
55000
+ const groups = p.groups.length ? " [" + p.groups.map((g) => `@${g.name}${g.role ? `:${g.role}` : ""}`).join(", ") + "]" : "";
55001
+ const statusIcon = p.status === "working" ? yellow2("●") : green2("●");
55002
+ const name = bold3(p.displayName);
55003
+ const meta2 = [];
55004
+ if (p.peerType)
55005
+ meta2.push(p.peerType);
55006
+ if (p.channel)
55007
+ meta2.push(p.channel);
55008
+ if (p.model)
55009
+ meta2.push(p.model);
55010
+ const metaStr = meta2.length ? dim2(` (${meta2.join(", ")})`) : "";
55011
+ const cwdStr = p.cwd ? dim2(` cwd: ${p.cwd}`) : "";
55012
+ const summary = p.summary ? dim2(` ${p.summary}`) : "";
55013
+ console.log(` ${statusIcon} ${name}${groups}${metaStr}${summary}`);
55014
+ if (cwdStr)
55015
+ console.log(` ${cwdStr}`);
55016
+ }
55017
+ }
55018
+ console.log("");
55019
+ });
54967
55020
  } catch (e) {
54968
- console.error(dim2(` Could not connect to ${mesh.slug}: ${e instanceof Error ? e.message : String(e)}`));
55021
+ console.error(dim2(` Could not connect to ${slug}: ${e instanceof Error ? e.message : String(e)}`));
54969
55022
  console.log("");
54970
- } finally {
54971
- client2.close();
54972
55023
  }
54973
55024
  }
54974
55025
  if (flags.json) {
54975
- console.log(JSON.stringify(meshes.length === 1 ? allPeers[0]?.peers : allPeers, null, 2));
55026
+ console.log(JSON.stringify(slugs.length === 1 ? allJson[0]?.peers : allJson, null, 2));
54976
55027
  }
54977
55028
  }
54978
55029
 
54979
55030
  // src/commands/welcome.ts
54980
55031
  init_colors();
54981
55032
  init_spinner();
55033
+ async function browserAuthFlow(action) {
55034
+ const { generatePairingCode: generatePairingCode2, startCallbackListener: startCallbackListener2, openBrowser: openBrowser2 } = await Promise.resolve().then(() => (init_auth(), exports_auth));
55035
+ const code = generatePairingCode2();
55036
+ const listener = await startCallbackListener2();
55037
+ const baseUrl = action === "register" ? `https://claudemesh.com/register?callbackUrl=${encodeURIComponent(`/cli-auth?port=${listener.port}&code=${code}&action=sync`)}` : `https://claudemesh.com/cli-auth?port=${listener.port}&code=${code}&action=sync`;
55038
+ console.log(dim(action === "register" ? ` Opening browser to create your account...
55039
+ ` : ` Opening browser to sign in...
55040
+ `));
55041
+ const opened = await openBrowser2(baseUrl);
55042
+ if (!opened) {
55043
+ console.log(" Couldn't open browser. Visit:");
55044
+ }
55045
+ console.log(dim(` ${baseUrl}
55046
+ `));
55047
+ const manualPromise = new Promise((resolve2) => {
55048
+ const rl = createInterface3({ input: process.stdin, output: process.stdout });
55049
+ rl.question(" Paste sync token (or wait for browser): ", (answer) => {
55050
+ rl.close();
55051
+ if (answer.trim())
55052
+ resolve2(answer.trim());
55053
+ });
55054
+ });
55055
+ const timeoutPromise = new Promise((resolve2) => {
55056
+ setTimeout(() => resolve2(null), 900000);
55057
+ });
55058
+ const syncToken = await Promise.race([
55059
+ listener.token,
55060
+ manualPromise,
55061
+ timeoutPromise
55062
+ ]);
55063
+ listener.close();
55064
+ if (!syncToken) {
55065
+ console.error(`
55066
+ Timed out waiting for sign-in.`);
55067
+ process.exit(1);
55068
+ }
55069
+ const { generateKeypair: generateKeypair3 } = await Promise.resolve().then(() => (init_keypair(), exports_keypair));
55070
+ const keypair = await generateKeypair3();
55071
+ const displayName = `${hostname4()}-${process.pid}`;
55072
+ const { syncWithBroker: syncWithBroker2 } = await Promise.resolve().then(() => exports_sync_with_broker);
55073
+ const result = await syncWithBroker2(syncToken, keypair.publicKey, displayName);
55074
+ const config2 = loadConfig();
55075
+ const { saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
55076
+ for (const m of result.meshes) {
55077
+ config2.meshes.push({
55078
+ meshId: m.mesh_id,
55079
+ memberId: m.member_id,
55080
+ slug: m.slug,
55081
+ name: m.slug,
55082
+ pubkey: keypair.publicKey,
55083
+ secretKey: keypair.secretKey,
55084
+ brokerUrl: m.broker_url,
55085
+ joinedAt: new Date().toISOString()
55086
+ });
55087
+ }
55088
+ config2.accountId = result.account_id;
55089
+ saveConfig2(config2);
55090
+ console.log(`
55091
+ ${green("✓")} Synced ${result.meshes.length} mesh(es): ${result.meshes.map((m) => m.slug).join(", ")}
55092
+ `);
55093
+ await runLaunch({}, []);
55094
+ }
54982
55095
  function detectState() {
54983
55096
  const claudeConfig = join6(homedir6(), ".claude.json");
54984
55097
  let mcpRegistered = false;
@@ -55059,85 +55172,28 @@ async function runWelcome() {
55059
55172
  }
55060
55173
  spinner.stop();
55061
55174
  const choice = await menuSelect({
55062
- title: "Connect to a mesh",
55175
+ title: "Get started",
55063
55176
  items: [
55064
- "Sign in via browser (create or join meshes)",
55177
+ "Create account (new to claudemesh)",
55178
+ "Sign in (existing account)",
55065
55179
  "Paste an invite URL",
55066
55180
  "Exit"
55067
55181
  ],
55068
55182
  row
55069
55183
  });
55070
- if (choice === 2) {
55071
- exitFullScreen();
55184
+ exitFullScreen();
55185
+ if (choice === 3)
55072
55186
  return;
55073
- }
55074
55187
  if (choice === 0) {
55075
- exitFullScreen();
55076
- console.log(dim(` Opening browser for sign-in...
55077
- `));
55078
- const { generatePairingCode: generatePairingCode2 } = await Promise.resolve().then(() => (init_auth(), exports_auth));
55079
- const { startCallbackListener: startCallbackListener2, openBrowser: openBrowser2 } = await Promise.resolve().then(() => (init_auth(), exports_auth));
55080
- const code = generatePairingCode2();
55081
- const listener = await startCallbackListener2();
55082
- const url = `https://claudemesh.com/cli-auth?port=${listener.port}&code=${code}&action=sync`;
55083
- const opened = await openBrowser2(url);
55084
- if (!opened) {
55085
- console.log(" Couldn't open browser. Visit:");
55086
- }
55087
- console.log(dim(` ${url}
55088
- `));
55089
- const manualPromise = new Promise((resolve2) => {
55090
- const rl = createInterface2({ input: process.stdin, output: process.stdout });
55091
- rl.question(" Paste sync token (or wait for browser): ", (answer) => {
55092
- rl.close();
55093
- if (answer.trim())
55094
- resolve2(answer.trim());
55095
- });
55096
- });
55097
- const timeoutPromise = new Promise((resolve2) => {
55098
- setTimeout(() => resolve2(null), 900000);
55099
- });
55100
- const syncToken = await Promise.race([
55101
- listener.token,
55102
- manualPromise,
55103
- timeoutPromise
55104
- ]);
55105
- listener.close();
55106
- if (!syncToken) {
55107
- console.error(`
55108
- Timed out waiting for sign-in.`);
55109
- process.exit(1);
55110
- }
55111
- const { generateKeypair: generateKeypair3 } = await Promise.resolve().then(() => (init_keypair(), exports_keypair));
55112
- const keypair = await generateKeypair3();
55113
- const displayName = `${hostname4()}-${process.pid}`;
55114
- const { syncWithBroker: syncWithBroker2 } = await Promise.resolve().then(() => exports_sync_with_broker);
55115
- const result = await syncWithBroker2(syncToken, keypair.publicKey, displayName);
55116
- const config2 = loadConfig();
55117
- const { saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), exports_config));
55118
- for (const m of result.meshes) {
55119
- config2.meshes.push({
55120
- meshId: m.mesh_id,
55121
- memberId: m.member_id,
55122
- slug: m.slug,
55123
- name: m.slug,
55124
- pubkey: keypair.publicKey,
55125
- secretKey: keypair.secretKey,
55126
- brokerUrl: m.broker_url,
55127
- joinedAt: new Date().toISOString()
55128
- });
55129
- }
55130
- config2.accountId = result.account_id;
55131
- saveConfig2(config2);
55132
- console.log(`
55133
- ${green("✓")} Synced ${result.meshes.length} mesh(es): ${result.meshes.map((m) => m.slug).join(", ")}
55134
- `);
55135
- await runLaunch({}, []);
55188
+ await browserAuthFlow("register");
55136
55189
  return;
55137
55190
  }
55138
55191
  if (choice === 1) {
55139
- exitFullScreen();
55140
- const rl = createInterface2({ input: process.stdin, output: process.stdout });
55192
+ await browserAuthFlow("sync");
55193
+ return;
55194
+ }
55195
+ if (choice === 2) {
55196
+ const rl = createInterface3({ input: process.stdin, output: process.stdout });
55141
55197
  const url = await new Promise((resolve2) => {
55142
55198
  rl.question(" Invite URL: ", (answer) => {
55143
55199
  rl.close();
@@ -55226,61 +55282,6 @@ function runWelcomePlain() {
55226
55282
  console.log("");
55227
55283
  }
55228
55284
 
55229
- // src/commands/connect.ts
55230
- import { hostname as hostname5 } from "node:os";
55231
- import { createInterface as createInterface3 } from "node:readline";
55232
- init_config();
55233
- async function pickMesh2(meshes) {
55234
- console.log(`
55235
- Select mesh:`);
55236
- meshes.forEach((m, i) => {
55237
- console.log(` ${i + 1}) ${m.slug}`);
55238
- });
55239
- console.log("");
55240
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
55241
- return new Promise((resolve2) => {
55242
- rl.question(" Choice [1]: ", (answer) => {
55243
- rl.close();
55244
- const idx = parseInt(answer || "1", 10) - 1;
55245
- if (idx >= 0 && idx < meshes.length) {
55246
- resolve2(meshes[idx]);
55247
- } else {
55248
- console.error(" Invalid choice, using first mesh.");
55249
- resolve2(meshes[0]);
55250
- }
55251
- });
55252
- });
55253
- }
55254
- async function withMesh(opts, fn) {
55255
- const config2 = loadConfig();
55256
- if (config2.meshes.length === 0) {
55257
- console.error("No meshes joined. Run `claudemesh join <url>` first.");
55258
- process.exit(1);
55259
- }
55260
- let mesh;
55261
- if (opts.meshSlug) {
55262
- const found = config2.meshes.find((m) => m.slug === opts.meshSlug);
55263
- if (!found) {
55264
- console.error(`Mesh "${opts.meshSlug}" not found. Joined: ${config2.meshes.map((m) => m.slug).join(", ")}`);
55265
- process.exit(1);
55266
- }
55267
- mesh = found;
55268
- } else if (config2.meshes.length === 1) {
55269
- mesh = config2.meshes[0];
55270
- } else {
55271
- mesh = await pickMesh2(config2.meshes);
55272
- }
55273
- const displayName = opts.displayName ?? config2.displayName ?? `${hostname5()}-${process.pid}`;
55274
- const client2 = new BrokerClient(mesh, { displayName });
55275
- try {
55276
- await client2.connect();
55277
- const result = await fn(client2, mesh);
55278
- return result;
55279
- } finally {
55280
- client2.close();
55281
- }
55282
- }
55283
-
55284
55285
  // src/commands/send.ts
55285
55286
  async function runSend(flags, to, message) {
55286
55287
  const priority = flags.priority === "now" ? "now" : flags.priority === "low" ? "low" : "next";
@@ -55746,7 +55747,7 @@ init_config();
55746
55747
  init_auth();
55747
55748
  init_keypair();
55748
55749
  import { createInterface as createInterface4 } from "node:readline";
55749
- import { hostname as hostname6 } from "node:os";
55750
+ import { hostname as hostname5 } from "node:os";
55750
55751
  async function runSync(args) {
55751
55752
  const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
55752
55753
  const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
@@ -55780,7 +55781,7 @@ async function runSync(args) {
55780
55781
  process.exit(1);
55781
55782
  }
55782
55783
  const keypair = config2.meshes.length > 0 ? { publicKey: config2.meshes[0].pubkey, secretKey: config2.meshes[0].secretKey } : await generateKeypair2();
55783
- const displayName = config2.displayName ?? `${hostname6()}-${process.pid}`;
55784
+ const displayName = config2.displayName ?? `${hostname5()}-${process.pid}`;
55784
55785
  const result = await syncWithBroker(syncToken, keypair.publicKey, displayName);
55785
55786
  let added = 0;
55786
55787
  for (const m of result.meshes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudemesh-cli",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Claude Code MCP client for claudemesh — peer mesh messaging between Claude sessions.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -50,8 +50,8 @@
50
50
  "vitest": "4.0.14",
51
51
  "@turbostarter/tsconfig": "0.1.0",
52
52
  "@turbostarter/vitest-config": "0.1.0",
53
- "@turbostarter/eslint-config": "0.1.0",
54
- "@turbostarter/prettier-config": "0.1.0"
53
+ "@turbostarter/prettier-config": "0.1.0",
54
+ "@turbostarter/eslint-config": "0.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "bun build src/index.ts --target=node --outfile dist/index.js --banner \"#!/usr/bin/env node\" && chmod +x dist/index.js",