From a92cf6b6291cc79f5af2419296ca865ca8972ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Wed, 8 Apr 2026 00:06:27 +0100 Subject: [PATCH] feat: hint AI to use filesystem for local peer file reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When read_peer_file targets a local peer (same hostname), prepend a hint with the direct filesystem path. Still executes the relay as fallback — AI learns the shortcut without being blocked. Co-Authored-By: Claude Sonnet 4.6 --- apps/cli/src/mcp/server.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/mcp/server.ts b/apps/cli/src/mcp/server.ts index 7a6e214..8e0b13c 100644 --- a/apps/cli/src/mcp/server.ts +++ b/apps/cli/src/mcp/server.ts @@ -1234,6 +1234,15 @@ Your message mode is "${messageMode}". } } + // Check if peer is local — hint AI to use filesystem directly + const resolvedPeer = peers.find(p => p.pubkey === targetPubkey); + const isLocal = resolvedPeer?.hostname && resolvedPeer.hostname === require("os").hostname(); + let localHint = ""; + if (isLocal && resolvedPeer?.cwd) { + const directPath = require("path").resolve(resolvedPeer.cwd, filePath); + localHint = `\n\n> **Hint:** This peer is LOCAL (same machine). Next time, read directly: \`${directPath}\` — faster, no size limit.\n\n`; + } + const result = await client.requestFile(targetPubkey, filePath); if (result.error) return text(`read_peer_file: ${result.error}`, true); if (!result.content) return text("read_peer_file: empty response from peer", true); @@ -1241,7 +1250,7 @@ Your message mode is "${messageMode}". // Decode base64 try { const decoded = Buffer.from(result.content, "base64").toString("utf-8"); - return text(decoded); + return text(localHint + decoded); } catch { return text("read_peer_file: failed to decode file content (binary file?)", true); }