fix(cli): production-grade peer disambiguation (alpha.42)
Three bugs compounding when multiple peers share a display name: 1. list_peers (MCP + CLI) truncated pubkey to 12 hex chars with an ellipsis. A truncated pubkey cannot be used as a routing key, so the caller had no way to disambiguate visually. 2. send_message required the full 64-hex pubkey and refused prefix input, forcing callers to rely on --json output to get a full key. 3. Name-based resolution returned the first exact match without filtering the caller's own session — so "send to <my-own-name>" would bounce against the broker's self-send guard when another session of the same user was the intended target. Fixes: - list_peers now prints 16-char pubkey prefix labelled "pubkey: …" (MCP) and appends it to CLI output - send_message accepts any 8–64 hex-char prefix and resolves against live peer lists across joined meshes; unique match routes, multi- match returns a disambiguation error listing each candidate's displayName + pubkey + cwd - Name matches now skip the caller's own session pubkey; multiple same-named matches fail loudly with a copy-pasteable pubkey disambiguation hint instead of silently picking one - Full 64-char pubkeys without a live match still queue at the broker (preserves offline-delivery semantics) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,7 +61,8 @@ export async function runPeers(flags: PeersFlags): Promise<void> {
|
||||
if (p.model) meta.push(p.model);
|
||||
const metaStr = meta.length ? dim(` (${meta.join(", ")})`) : "";
|
||||
const summary = p.summary ? dim(` — ${p.summary}`) : "";
|
||||
render.info(`${statusDot} ${name}${groups}${metaStr}${summary}`);
|
||||
const pubkeyTag = dim(` · ${p.pubkey.slice(0, 16)}…`);
|
||||
render.info(`${statusDot} ${name}${groups}${metaStr}${pubkeyTag}${summary}`);
|
||||
if (p.cwd) render.info(dim(` cwd: ${p.cwd}`));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user