Skip to content
Closed
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion packages/opencode/src/tool/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ import { Agent } from "../agent/agent"
export const WriteTool = Tool.define("write", {
description: DESCRIPTION,
parameters: z.object({
content: z.string().describe("The content to write to the file"),
content: z.preprocess(
(val) => {
if (typeof val === 'string') {
Comment thread
georgeglarson marked this conversation as resolved.
Resolved
return val
}
if (Array.isArray(val)) {
// Join array elements with newlines
return val.map(item => String(item)).join('\n')
Comment thread
georgeglarson marked this conversation as resolved.
Resolved
}
return String(val)
},
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)"),
}),
async execute(params, ctx) {
Expand Down
Loading