The CLI source (242 files, ~14k lines) was gitignored during the earlier cli→cli-v2 reorg so only the published npm package carried it. That blocks the GitHub Actions release workflow (release-cli.yml), which clones the repo fresh on each runner and needs the source to compile binaries via `bun build --compile`. Moves the gitignore from root-level to `apps/cli-v2/.gitignore` with only the usual build artefacts excluded (node_modules, dist, .turbo, .cache). Source is now in git at apps/cli-v2/src/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
/**
|
|
* `claudemesh send <to> <message>` — send a message to a peer or group.
|
|
*
|
|
* <to> can be:
|
|
* - a display name ("Mou")
|
|
* - a pubkey hex ("abc123...")
|
|
* - @group ("@flexicar")
|
|
* - * (broadcast to all)
|
|
*/
|
|
|
|
import { withMesh } from "./connect.js";
|
|
import type { Priority } from "~/services/broker/facade.js";
|
|
|
|
export interface SendFlags {
|
|
mesh?: string;
|
|
priority?: string;
|
|
}
|
|
|
|
export async function runSend(flags: SendFlags, to: string, message: string): Promise<void> {
|
|
const priority: Priority =
|
|
flags.priority === "now" ? "now"
|
|
: flags.priority === "low" ? "low"
|
|
: "next";
|
|
|
|
await withMesh({ meshSlug: flags.mesh ?? null }, async (client) => {
|
|
// Resolve display name → pubkey for direct messages.
|
|
// If `to` starts with @, *, or looks like a hex pubkey, use as-is.
|
|
let targetSpec = to;
|
|
if (!to.startsWith("@") && to !== "*" && !/^[0-9a-f]{64}$/i.test(to)) {
|
|
// Treat as display name — look up pubkey via list_peers.
|
|
const peers = await client.listPeers();
|
|
const match = peers.find(
|
|
(p) => p.displayName.toLowerCase() === to.toLowerCase(),
|
|
);
|
|
if (!match) {
|
|
const names = peers.map((p) => p.displayName).join(", ");
|
|
console.error(`Peer "${to}" not found. Online: ${names || "(none)"}`);
|
|
process.exit(1);
|
|
}
|
|
targetSpec = match.pubkey;
|
|
}
|
|
|
|
const result = await client.send(targetSpec, message, priority);
|
|
if (result.ok) {
|
|
console.log(`✓ Sent to ${to}${result.messageId ? ` (${result.messageId.slice(0, 8)})` : ""}`);
|
|
} else {
|
|
console.error(`✗ Send failed: ${result.error ?? "unknown error"}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
}
|