|
6 | 6 | import * as fs from "node:fs/promises"; |
7 | 7 | import * as path from "node:path"; |
8 | 8 | import matter from "gray-matter"; |
9 | | -import { configExists, getConfig } from "../../config/index.js"; |
| 9 | +import { configExists, getConfig, getRawConfig } from "../../config/index.js"; |
10 | 10 | import { HEARTBEAT_OK, SILENT_REPLY_TOKEN } from "../../lib/tokens.js"; |
11 | 11 | import { buildSkillsPrompt } from "../../skills/SkillService.js"; |
12 | 12 | import type { |
@@ -184,7 +184,31 @@ You have FULL read/write access to the workspace directory. Use these tools to m |
184 | 184 | - Extra flags/arguments ARE allowed: \`git log --author=Marvel --since=yesterday --oneline\` works because \`git log\` is allowlisted. |
185 | 185 | - Avoid shell metacharacters (\`; & | $ !\`). Use simple commands without pipes or chaining. |
186 | 186 | - For dates with spaces, use dotted format: \`--since=2.days.ago\` instead of \`--since="2 days ago"\`. |
187 | | - - \`gh\` (GitHub CLI) is available for GitHub API queries: PRs, issues, commits, etc.`; |
| 187 | + - \`gh\` (GitHub CLI) is available for GitHub API queries: PRs, issues, commits, etc. |
| 188 | +${buildRemoteFileSystemSection()}`; |
| 189 | +} |
| 190 | + |
| 191 | +/** |
| 192 | + * Build the remote filesystem tools section (only when enabled) |
| 193 | + */ |
| 194 | +function buildRemoteFileSystemSection(): string { |
| 195 | + try { |
| 196 | + const rawConfig = getRawConfig(); |
| 197 | + const remoteFsConfig = rawConfig.tools.remoteFileSystem; |
| 198 | + if (!remoteFsConfig?.enabled) return ""; |
| 199 | + |
| 200 | + const host = remoteFsConfig.sshHost; |
| 201 | + const paths = remoteFsConfig.allowedPaths.join(", "); |
| 202 | + |
| 203 | + return `\n**Remote PC Tools (via SSH to \`${host}\`):** |
| 204 | +- These tools access files on the user's *remote machine* over SSH — they are NOT local workspace tools. |
| 205 | +- Remote host: \`${host}\` | Accessible paths: \`${paths}\` |
| 206 | +- All remote tools are prefixed with \`remote_\`: \`remote_read_file\`, \`remote_write_file\`, \`remote_list_directory\`, \`remote_search_files\`, \`remote_get_file_info\`, \`remote_create_directory\`, \`remote_move_file\` |
| 207 | +- When the user asks about files on "my PC", "my computer", "my desktop", or "remote machine", use these \`remote_*\` tools — NOT the local workspace tools. |
| 208 | +- The remote tools operate on the remote machine's filesystem at the allowed paths listed above.`; |
| 209 | + } catch { |
| 210 | + return ""; |
| 211 | + } |
188 | 212 | } |
189 | 213 |
|
190 | 214 | /** |
|
0 commit comments