[Feature Request] Watch files for instructions #1071

Open
opened 2026-02-16 17:29:22 -05:00 by yindo · 9 comments
Owner

Originally created by @Axenide on GitHub (Aug 2, 2025).

Originally assigned to: @rekram1-node on GitHub.

Hello! Are there plans for implementing something like Aider's --watch-files? Where you can write a comment in a file like # Thread this function, AI! and Aider will edit the file following that instruction.
I think this would be really useful for smaller edits.

For example, I'm working on a project and the import syntax changed. I could do this in the file:

import QtQuick
import Quickshell
// Modify the imports to the new syntax (qs.modules.bar), opencode!
import "./modules/bar/"
import "./modules/workspaces/"
import "./modules/notifications/"

opencode would show that it received the instruction in the chat and I would get this:

import QtQuick
import Quickshell
import qs.modules.bar
import qs.modules.workspaces
import qs.modules.notifications
Originally created by @Axenide on GitHub (Aug 2, 2025). Originally assigned to: @rekram1-node on GitHub. Hello! Are there plans for implementing something like Aider's `--watch-files`? Where you can write a comment in a file like `# Thread this function, AI!` and Aider will edit the file following that instruction. I think this would be really useful for smaller edits. For example, I'm working on a project and the import syntax changed. I could do this in the file: ```qml import QtQuick import Quickshell // Modify the imports to the new syntax (qs.modules.bar), opencode! import "./modules/bar/" import "./modules/workspaces/" import "./modules/notifications/" ``` opencode would show that it received the instruction in the chat and I would get this: ```qml import QtQuick import Quickshell import qs.modules.bar import qs.modules.workspaces import qs.modules.notifications ```
Author
Owner

@thdxr commented on GitHub (Aug 3, 2025):

oo interesting i like this idea

@thdxr commented on GitHub (Aug 3, 2025): oo interesting i like this idea
Author
Owner

@ucirello commented on GitHub (Aug 5, 2025):

One of the tricks I used in VSCode is to sprinkle a file with // GPT: or /* GPT: */ comments that worked as instructions - and then in the chat screen something along the lines: "go observe @file and address all the GPT contents". I wonder if something similar would be viable if file parsing was available, beyond a naive file watchet that would automatically feed the file into OC's chat context.

@ucirello commented on GitHub (Aug 5, 2025): One of the tricks I used in VSCode is to sprinkle a file with `// GPT:` or `/* GPT: */` comments that worked as instructions - and then in the chat screen something along the lines: "go observe @file and address all the GPT contents". I wonder if something similar would be viable if file parsing was available, beyond a naive file watchet that would automatically feed the file into OC's chat context.
Author
Owner

@noahfraiture commented on GitHub (Aug 10, 2025):

Hello,

I have noticed that there is already some code for this feature in the watch.ts file. However, the feature is not yet implemented. Is it expected to be implemented soon, or is it currently in a pending state? If we submit a pull request to complete the feature, will it be accepted?

@noahfraiture commented on GitHub (Aug 10, 2025): Hello, I have noticed that there is already some code for this feature in the watch.ts file. However, the feature is not yet implemented. Is it expected to be implemented soon, or is it currently in a pending state? If we submit a pull request to complete the feature, will it be accepted?
Author
Owner

@pakerfeldt commented on GitHub (Aug 12, 2025):

While the suggested approach in this issue is generic enough to work with any IDE, I was thinking of a more direct integration where opencode would offer some sort of API to call into to initiate a conversation. Pretend that you're in neovim and you find yourself wanting to refactor a piece of code. You would stand on a relevant line in the file, open a dialog and initiate a conversation. This could allow for starting off in planning mode, if needed. Conversation could either continue in nvim or in opencode. But the big upside here is that you can start a conversation, not needing to fit all the instructions in a comment.

I fully recognise that this is a bigger scope, but IMHO, opencode could offer an API to support this and the IDE integrations could come from the community.

Anyway, just food for thought.

@pakerfeldt commented on GitHub (Aug 12, 2025): While the suggested approach in this issue is generic enough to work with any IDE, I was thinking of a more direct integration where opencode would offer some sort of API to call into to initiate a conversation. Pretend that you're in neovim and you find yourself wanting to refactor a piece of code. You would stand on a relevant line in the file, open a dialog and initiate a conversation. This could allow for starting off in planning mode, if needed. Conversation could either continue in nvim or in opencode. But the big upside here is that you can start a conversation, not needing to fit all the instructions in a comment. I fully recognise that this is a bigger scope, but IMHO, opencode could offer an API to support this and the IDE integrations could come from the community. Anyway, just food for thought.
Author
Owner

@thdxr commented on GitHub (Aug 12, 2025):

the watcher is disabled because the native file watcher has terrible performance

it should be rewritten with chokidar - would accept one PR for that

i would also take a PR taking a crack at this feature too - seems straight forward

@thdxr commented on GitHub (Aug 12, 2025): the watcher is disabled because the native file watcher has terrible performance<br><br>it should be rewritten with chokidar - would accept one PR for that<br><br>i would also take a PR taking a crack at this feature too - seems straight forward
Author
Owner

@thdxr commented on GitHub (Aug 12, 2025):

btw opencode does have an api!

@thdxr commented on GitHub (Aug 12, 2025): btw opencode does have an api!
Author
Owner

@trose commented on GitHub (Sep 22, 2025):

@noahfraiture Looks like this was recently addressed: https://github.com/sst/opencode/pull/2621

@trose commented on GitHub (Sep 22, 2025): @noahfraiture Looks like this was recently addressed: https://github.com/sst/opencode/pull/2621
Author
Owner

@noahfraiture commented on GitHub (Sep 23, 2025):

@noahfraiture Looks like this was recently addressed: #2621

Oh ty, I'll close then

@noahfraiture commented on GitHub (Sep 23, 2025): > [@noahfraiture](https://github.com/noahfraiture) Looks like this was recently addressed: [#2621](https://github.com/sst/opencode/pull/2621) Oh ty, I'll close then
Author
Owner

@juliusz-cwiakalski commented on GitHub (Oct 24, 2025):

From my perspective watching files woudl be also useful not only to execute instructions from comments but also just to make Opencode aware of the changes I'm doing in IDE or other tools. I'm now jumping between Opencode, Intellij and Aider - and sadly Opencode is the only one not aware of changes of others immedietly.

Also looks like it's not aware of changes when I switch git branches -> need to restart which is not the best user experience :)

Maybe let's first start with having proper scanning for changes (not an expert but probably something like inotify would do the job here)?

@juliusz-cwiakalski commented on GitHub (Oct 24, 2025): From my perspective watching files woudl be also useful not only to execute instructions from comments but also just to make Opencode aware of the changes I'm doing in IDE or other tools. I'm now jumping between Opencode, Intellij and Aider - and sadly Opencode is the only one not aware of changes of others immedietly. Also looks like it's not aware of changes when I switch git branches -> need to restart which is not the best user experience :) Maybe let's first start with having proper scanning for changes (not an expert but probably something like inotify would do the job here)?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1071