Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/opencode/src/tool/apply_patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const PatchParams = z.object({

export const ApplyPatchTool = Tool.define("apply_patch", {
description: DESCRIPTION,
isDestructive: true,
parameters: PatchParams,
async execute(params, ctx) {
if (!params.patchText) {
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/codesearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface McpCodeResponse {

export const CodeSearchTool = Tool.define("codesearch", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
query: z
.string()
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function convertToLineEnding(text: string, ending: "\n" | "\r\n"): string {

export const EditTool = Tool.define("edit", {
description: DESCRIPTION,
isDestructive: true,
parameters: z.object({
filePath: z.string().describe("The absolute path to the file to modify"),
oldString: z.string().describe("The text to replace"),
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { assertExternalDirectory } from "./external-directory"

export const GlobTool = Tool.define("glob", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
pattern: z.string().describe("The glob pattern to match files against"),
path: z
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/grep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const MAX_LINE_LENGTH = 2000

export const GrepTool = Tool.define("grep", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
pattern: z.string().describe("The regex pattern to search for in file contents"),
path: z.string().optional().describe("The directory to search in. Defaults to the current working directory."),
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const LIMIT = 100

export const ListTool = Tool.define("list", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
path: z.string().describe("The absolute path to the directory to list (must be absolute, not relative)").optional(),
ignore: z.array(z.string()).describe("List of glob patterns to ignore").optional(),
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/multiedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Instance } from "../project/instance"

export const MultiEditTool = Tool.define("multiedit", {
description: DESCRIPTION,
isDestructive: true,
parameters: z.object({
filePath: z.string().describe("The absolute path to the file to modify"),
edits: z
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const MAX_BYTES_LABEL = `${MAX_BYTES / 1024} KB`

export const ReadTool = Tool.define("read", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
filePath: z.string().describe("The absolute path to the file or directory to read"),
offset: z.coerce.number().describe("The line number to start reading from (1-indexed)").optional(),
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Todo } from "../session/todo"

export const TodoWriteTool = Tool.define("todowrite", {
description: DESCRIPTION_WRITE,
isReadOnly: false,
parameters: z.object({
todos: z.array(z.object(Todo.Info.shape)).describe("The updated todo list"),
}),
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/tool/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export namespace Tool {
export interface Def<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
description: string
parameters: Parameters
/** Whether this tool only reads data (never modifies state). Used for permission auto-approval. */
isReadOnly?: boolean
/** Whether this tool can destruct or irreversibly modify state. Used for elevated permission prompts. */
isDestructive?: boolean
execute(
args: z.infer<Parameters>,
ctx: Context,
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/webfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const MAX_TIMEOUT = 120 * 1000 // 2 minutes

export const WebFetchTool = Tool.define("webfetch", {
description: DESCRIPTION,
isReadOnly: true,
parameters: z.object({
url: z.string().describe("The URL to fetch content from"),
format: z
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const MAX_PROJECT_DIAGNOSTICS_FILES = 5

export const WriteTool = Tool.define("write", {
description: DESCRIPTION,
isDestructive: true,
parameters: z.object({
content: z.string().describe("The content to write to the file"),
filePath: z.string().describe("The absolute path to the file to write (must be absolute, not relative)"),
Expand Down
Loading