Skip to content

Support for line range with file tagging? #2129

@regb

Description

@regb

Hello, recently started to use opencode, I like it a lot, thanks for all that hard work!
I've been trying to figure out if there is a way to append line ranges to file tagging in TUI. I've been trying to explore the codebase a bit and it seems the backend supports the concept of file range with the message attachment and the Read tool can thus read specific file-range, and apparently there's a way to pass it with the API. But as far as I can tell, it's not possible to trigger it through the TUI.

The use-case I had in mind is something similar to Cursor, where you can navigate in your editor, select a few lines of code, and use a plugin to attach the file tag with the lines to the opencode input prompt via the TUI API. Not sure how much of a tiny optimization that is compared to sending the entire file, but in my experience that was useful to give precise context to the agent and guide it.

In my tests I've noticed that the agent will usually naturally make the tool call to read the file if you do something like @filepath:10:20, but that's not the same as it requires the agent to make the decision to invoke the Read tool, and it's both less reliable and more expensive than just having opencode pro-actively inline that information before sending to the LLM.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions