opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: EDIT PLAN mode or allow editing of only certain (.md) files in PLAN mode

Open tgrushka opened this issue 1 month ago • 12 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Just signed up for Zen. Hoping to support this open-source project and have a better experience than I did with GitHub Copilot.

The AI agents are getting worse and more reckless. (Deliberate money grabbing by forcing users to use more tokens to accomplish something?) I ask it explicitly to create a plan file in PLAN mode. It complains that it cannot edit. So I turn on EDIT mode. And it goes haywire and starts editing the code and wrecking things. Happened to be GPT-5 but I've seen it happen with other agents too. All the agents seem to be getting more and more reckless and careless and not following user instructions. I think the word "caution" has been removed from their vocabulary.

Is there any way to have another mode, PLAN EDIT or EDIT PLAN that allows it to only CREATE or EDIT certain files (configurable, or *.md files by default or something)? (Or allow limited create/edit in the PLAN mode as configured by the user)?

The reason for this request is I am visually impaired and have the terminal enlarged, and copying is very, very difficult. It messes up the formatting, e.g. adds line breaks, and I can only copy a few lines at a time, and the agent just goes on and on. I can scroll the TUI, but it's tedious to copy, when it says, "I’m in plan-only (read-only) mode and cannot modify files. Here’s the updated ui/PLAN.md content for you to paste:". Right. It has no concept of, "if I put you in EDIT mode, you will take a bulldozer to my project and go haywire, and that will frustrate me."

Another feature that would be helpful would be a /copy command that would copy the previous response to the clipboard. Maybe been requested before, not sure. But I added to this issue because the two are kind of related.

Would really appreciate either of these features in whatever order is easiest. I think a lot of users would appreciate these. Thank you!

tgrushka avatar Nov 03 '25 23:11 tgrushka

This issue might be a duplicate of existing issues. Please check:

  • #2118: Add a /copy command to copy latest message (or allow scrolling while selecting text) - This issue specifically requests a /copy command to copy the entire last message to clipboard, which is exactly one of the features requested in this issue.

  • #2755: feat: Copy Mode for OpenCode - This comprehensive feature request discusses adding proper copy mode functionality and mentions that only entire message copying is currently available, which relates to the copy functionality requested here.

  • #3241: Opencode stuck in Plan mode - This issue discusses problems with Plan/Edit mode restrictions and the agent being unable to switch back from Plan mode, which relates to the request for better Plan/Edit mode control in this issue.

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Nov 03 '25 23:11 github-actions[bot]

I am trying to create a tool to restrict editing to .md files, but not having much luck because:

  • The opencode npm package isn't available to be installed;
  • The API interface for creating tools is completely different than the one opencode uses internally (why?)
  • There seems no supported way to "wrap" or re-use existing tools.
// import { Tool } from "./tool"
// import { EditTool } from "./edit"
import { Tool } from "./opencode/packages/opencode/src/tool/tool"
import { MultiEditTool } from "./opencode/packages/opencode/src/tool/multiedit"
import z from "zod"

export const MdEditTool = Tool.define("multiedit", {
    description: "Edit .md files",
    parameters: z.object({
        filePath: z.string().describe("The absolute path to the file to modify"),
        edits: z
            .array(
                z.object({
                    filePath: z.string().describe("The absolute path to the file to modify"),
                    oldString: z.string().describe("The text to replace"),
                    newString: z.string().describe("The text to replace it with (must be different from oldString)"),
                    replaceAll: z.boolean().optional().describe("Replace all occurrences of oldString (default false)"),
                }),
            )
            .describe("Array of edit operations to perform sequentially on the file"),
    }),
    async execute(params, ctx) {
        if (!params.filePath.endsWith(".md")) {
            throw new Error("File is not an .md file. You cannot edit anything but .md files with this tool.")
        }
        const tool = await MultiEditTool.init()
        return await tool.execute(params, ctx)
    },
})

tgrushka avatar Nov 04 '25 00:11 tgrushka

Very unrelated to this (I apologise for this!), but I think it would be beneficial to discuss it. I too have created a multiedit tool and it works ok so far. What I've noticed that we need to have a "permission" control over this, otherwise the agents would use it without asking permission. At the moment only internal tools can be set but not user tools.

arsham avatar Nov 04 '25 00:11 arsham

yeah we are gonna rework permissions so that for all tools u can do very granular definitions

I may be misunderstanding, not sure what some of these mean:

  • The opencode npm package isn't available to be installed?
  • The API interface for creating tools is completely different than the one opencode uses internally (why?)

There seems no supported way to "wrap" or re-use existing tools.

You can override pre-existing tools but yeah I guess we don't expose a great way to do this

rekram1-node avatar Nov 04 '25 00:11 rekram1-node

@tgrushka; I think the general statement for what you want is "User configurable (editable) system prompts". This and related issues have been discussed elsewhere, in case it helps: #3195 #1894 #356

taqtiqa-mark avatar Nov 04 '25 06:11 taqtiqa-mark

This is an interesting idea. Restricting edits to specific file types like .md could make Plan mode much safer and more predictable. It would be great to see limited edit permissions added in future versions.

mirbasit01 avatar Nov 04 '25 12:11 mirbasit01

Can we configure current plan mode with editing *.md files capability? Adding one more mode will overcomplicate switching.

ravshansbox avatar Nov 04 '25 13:11 ravshansbox

+1

dchasman avatar Nov 04 '25 13:11 dchasman

@tgrushka another workaround is to run OpenCode in a container (access project files via a mount). The critical part here is to ensure this folder is mounted to a location on your host where you can regain control of the prompts.

Not sure if OC will permit such full control via config settings, but even if not, this imperfect workaround should help?

taqtiqa-mark avatar Nov 05 '25 17:11 taqtiqa-mark

@tgrushka Try to explicitly instruct it to create a plan.md file with plan on implementing this feature.

This works for me 100% of time even though I don't use plan mode at all and use build mode for planning

Mishkun avatar Nov 06 '25 16:11 Mishkun