Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opencode/src/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export namespace Agent {
grep: "allow",
glob: "allow",
list: "allow",
bash: "allow",
bash: "ask",
webfetch: "allow",
websearch: "allow",
codesearch: "allow",
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/agent/prompt/explore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 16 additions & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 27 additions & 1 deletion packages/opencode/src/tool/bash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down