feat: add read_file tool

This commit is contained in:
2026-05-31 12:11:09 -05:00
parent 3f0d9a80c7
commit 0dc0f7eb53
5 changed files with 49 additions and 10 deletions
+3 -6
View File
@@ -99,7 +99,7 @@ function getShellInstructions(
case "restricted":
return `### Shell commands\n\nUse the \`${t("shell")}\` MCP tool for all shell command execution. This tool provides a secure environment with filtered credentials. Do NOT use any native shell tool — it is disabled for security. For long-running processes, use \`shell({ command, background: true })\`. Use \`${t("kill_background")}\` to stop background processes.`;
case "enabled":
return `### Shell commands\n\nUse the \`${t("shell")}\` MCP tool for all shell command execution (unrestricted environment, credentials available).`;
return `### Shell commands\n\nUse your native shell tool for shell command execution.`;
default: {
const _exhaustive: never = shell;
return _exhaustive satisfies never;
@@ -107,11 +107,8 @@ function getShellInstructions(
}
}
function getFileInstructions(shell: ResolvedPayload["shell"]): string {
if (shell === "disabled") {
return `### File operations\n\nShell is disabled — you cannot read arbitrary files. Use the diff content returned by MCP tools directly.`;
}
return `### File operations\n\nUse the \`shell\` MCP tool for all file operations. Examples:\n- Read a file: \`shell({ command: 'cat /path/to/file', description: 'read file' })\`\n- Read specific lines: \`shell({ command: 'sed -n "<start>,<end>p" /path/to/file', description: 'read lines' })\`\n- Search in a file: \`shell({ command: 'grep -n "pattern" /path/to/file', description: 'search' })\``;
function getFileInstructions(_shell: ResolvedPayload["shell"]): string {
return `### File operations\n\nUse the \`read_file\` MCP tool to read files. For example: \`read_file({ path: diffPath, start_line: 5, end_line: 42 })\`. This is the primary way to read the PR diff returned by \`checkout_pr\`.`;
}
function getStandaloneModeInstructions(