diff --git a/packages/opencode/src/agent/agent.ts b/packages/opencode/src/agent/agent.ts index 17695583867..1adb8378b04 100644 --- a/packages/opencode/src/agent/agent.ts +++ b/packages/opencode/src/agent/agent.ts @@ -117,7 +117,7 @@ export namespace Agent { grep: "allow", glob: "allow", list: "allow", - bash: "allow", + bash: "ask", webfetch: "allow", websearch: "allow", codesearch: "allow", diff --git a/packages/opencode/src/agent/prompt/explore.txt b/packages/opencode/src/agent/prompt/explore.txt index 5761077cbd8..2411338d00f 100644 --- a/packages/opencode/src/agent/prompt/explore.txt +++ b/packages/opencode/src/agent/prompt/explore.txt @@ -9,9 +9,10 @@ Guidelines: - Use Glob for broad file pattern matching - Use Grep for searching file contents with regex - Use Read when you know the specific file path you need to read -- Use Bash for file operations like copying, moving, or listing directory contents +- Use Bash for file operations like listing directory contents (ls, find). Note that Bash commands may trigger permission requests. - Adapt your search approach based on the thoroughness level specified by the caller - Return file paths as absolute paths in your final response +- Stay within the project directory unless explicitly instructed to search elsewhere - For clear communication, avoid using emojis - Do not create any files, or run bash commands that modify the user's system state in any way diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index f891612272c..34596e62902 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -777,8 +777,23 @@ export namespace SessionPrompt { mime: contentItem.mimeType, url: `data:${contentItem.mimeType};base64,${contentItem.data}`, }) + } else if (contentItem.type === "resource") { + const { resource } = contentItem + if (resource.text) { + textParts.push(resource.text) + } + if (resource.blob) { + attachments.push({ + id: Identifier.ascending("part"), + sessionID: input.session.id, + messageID: input.processor.message.id, + type: "file", + mime: resource.mimeType ?? "application/octet-stream", + url: `data:${resource.mimeType ?? "application/octet-stream"};base64,${resource.blob}`, + filename: resource.uri, + }) + } } - // Add support for other types if needed } return { diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index f3a1b04d431..6d9b69b2e23 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -108,7 +108,33 @@ export const BashTool = Tool.define("bash", async () => { } // not an exhaustive list, but covers most common cases - if (["cd", "rm", "cp", "mv", "mkdir", "touch", "chmod", "chown"].includes(command[0])) { + const commandsToCheck = [ + "cd", + "rm", + "cp", + "mv", + "mkdir", + "touch", + "chmod", + "chown", + "ls", + "find", + "cat", + "head", + "tail", + "grep", + "rg", + "ag", + "stat", + "du", + "file", + "which", + "whereis", + "less", + "more", + ] + + if (commandsToCheck.includes(command[0])) { for (const arg of command.slice(1)) { if (arg.startsWith("-") || (command[0] === "chmod" && arg.startsWith("+"))) continue const resolved = await $`realpath ${arg}`