bug: -exec not caught by treesitter #1940

Closed
opened 2026-02-16 17:33:20 -05:00 by yindo · 9 comments
Owner

Originally created by @alanxoc3 on GitHub (Oct 3, 2025).

Originally assigned to: @rekram1-node on GitHub.

I just tried out the ask feature and allowed the AI to use the "find" command to see a sample. But then it went ahead and ran a find command again, which I didn't want to allow. Here is a screenshot of the whole conversation:

Image

In this case, the first find command was safe, it was just read only. But the second command had an exec sed, which I may have wanted to reject. And the opencode TUI didn't give me a chance to reject it.

This seems like an oversight to the ask feature.

Originally created by @alanxoc3 on GitHub (Oct 3, 2025). Originally assigned to: @rekram1-node on GitHub. I just tried out the ask feature and allowed the AI to use the "find" command to see a sample. But then it went ahead and ran a find command again, which I didn't want to allow. Here is a screenshot of the whole conversation: <img width="2233" height="869" alt="Image" src="https://github.com/user-attachments/assets/66fc80d0-db71-406c-a7f8-a76a8dcc7174" /> In this case, the first find command was safe, it was just read only. But the second command had an exec sed, which I may have wanted to reject. And the opencode TUI didn't give me a chance to reject it. This seems like an oversight to the ask feature.
yindo closed this issue 2026-02-16 17:33:20 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 3, 2025):

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

  • This appears to be the same issue described in this very issue (#2952) - there may have been a duplicate submission

The issue describes the ask feature not prompting for every command execution, specifically when find commands are used with potentially dangerous exec operations.

Feel free to ignore if this was the intended new issue submission.

@github-actions[bot] commented on GitHub (Oct 3, 2025): This issue might be a duplicate of existing issues. Please check: - This appears to be the same issue described in this very issue (#2952) - there may have been a duplicate submission The issue describes the ask feature not prompting for every command execution, specifically when find commands are used with potentially dangerous exec operations. Feel free to ignore if this was the intended new issue submission.
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@alanxoc3 did you set permissions in your opencode.json? can u share the config for them?

@rekram1-node commented on GitHub (Oct 3, 2025): @alanxoc3 did you set permissions in your opencode.json? can u share the config for them?
Author
Owner

@alanxoc3 commented on GitHub (Oct 3, 2025):

I just tried it again, and it worked for git.. hmm.

Yes, my config is:

{
  "$schema": "https://opencode.ai/config.json",
  "share": "disabled",
  "theme": "system",
  "agent": {
    "build": {
      "permission": {
        "edit": "allow",
        "bash": {
          "*": "ask",
        },
        "webfetch": "allow"
      }
    },
    "plan": {
      "permission": {
        "edit": "deny",
        "bash": {
          "*": "ask",
        },
        "webfetch": "allow"
      }
    }
  }
}
@alanxoc3 commented on GitHub (Oct 3, 2025): I just tried it again, and it worked for git.. hmm. Yes, my config is: ``` { "$schema": "https://opencode.ai/config.json", "share": "disabled", "theme": "system", "agent": { "build": { "permission": { "edit": "allow", "bash": { "*": "ask", }, "webfetch": "allow" } }, "plan": { "permission": { "edit": "deny", "bash": { "*": "ask", }, "webfetch": "allow" } } } } ```
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@alanxoc3 I see what could have been issue, treesitter code didn't properly catch the -exec it seems

@rekram1-node commented on GitHub (Oct 3, 2025): @alanxoc3 I see what could have been issue, treesitter code didn't properly catch the -exec it seems
Author
Owner

@alanxoc3 commented on GitHub (Oct 3, 2025):

Yeah, that's what I think is happening. I reproduced it again with this prompt:

use sed to replace all "krook" with "blah" in codebase, first run a preview of the files, then do it

I personally want an ask-always option. Because every system is different, there is always a possibility of a command not working the way the LLM was trained.

Maybe an "ask-regex" and "ask-always" option. I'm guessing you are parsing the command a bit to look for sub commands or similar.

@alanxoc3 commented on GitHub (Oct 3, 2025): Yeah, that's what I think is happening. I reproduced it again with this prompt: ``` use sed to replace all "krook" with "blah" in codebase, first run a preview of the files, then do it ``` I personally want an ask-always option. Because every system is different, there is always a possibility of a command not working the way the LLM was trained. Maybe an "ask-regex" and "ask-always" option. I'm guessing you are parsing the command a bit to look for sub commands or similar.
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@alanxoc3 it will always ask unless you do allow always, that exec should've been caught but if it tried to run find twice in a row but you said allow always to first one you won't be prompted for the second

@rekram1-node commented on GitHub (Oct 3, 2025): @alanxoc3 it will always ask unless you do allow always, that exec should've been caught but if it tried to run `find` twice in a row but you said allow always to first one you won't be prompted for the second
Author
Owner

@alanxoc3 commented on GitHub (Oct 3, 2025):

I'm so dumb, I thought "a" meant accept, not accept always. I didn't see that enter was an option.

Anyways... Another suggestion... I prefer it being a ctrl-x + a or similar, because a person could be in the middle of typing the next prompt while opencode is thinking, and if they type an "a", they will accidentally accept the command to be run.

@alanxoc3 commented on GitHub (Oct 3, 2025): I'm so dumb, I thought "a" meant accept, not accept always. I didn't see that enter was an option. Anyways... Another suggestion... I prefer it being a ctrl-x + a or similar, because a person could be in the middle of typing the next prompt while opencode is thinking, and if they type an "a", they will accidentally accept the command to be run.
Author
Owner

@alanxoc3 commented on GitHub (Oct 3, 2025):

Anyways, "enter" is what I wanted. Thanks.

@alanxoc3 commented on GitHub (Oct 3, 2025): Anyways, "enter" is what I wanted. Thanks.
Author
Owner

@rekram1-node commented on GitHub (Oct 3, 2025):

@alanxoc3 I totally agree it is too easy to accidentally hit.

We have another issue somewhere tracking that, I have already raised to team that Permission dialogs could use some work.

I will use this ticket to track the -exec catch and get a fix out soon for that hopefully. But for dialog changes that would most likely be in the opentui version that is still a wip but should ship in next week or so

@rekram1-node commented on GitHub (Oct 3, 2025): @alanxoc3 I totally agree it is too easy to accidentally hit. We have another issue somewhere tracking that, I have already raised to team that Permission dialogs could use some work. I will use this ticket to track the -exec catch and get a fix out soon for that hopefully. But for dialog changes that would most likely be in the opentui version that is still a wip but should ship in next week or so
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1940