You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
opencode can be started from a project's subdirectory. In this case it looks for AGENT*.md in current directory only, not in the project's root.
Suggestion: implement project root identification (e.g. based on special file existence like .git, pyproject.toml, etc.) & additionally load agents files starting from the project root.
Maybe I misread your wording but as you can see in this basic project we definitely read AGENTS.md from project root even when you are in subdirectory.
Line 69 in 1f57b9a
const root = git ?? input.cwd
? I don't think it is generic enough - there are projects without git and with other VCSs or even without VCS at all. It's better to enable user to define root marker files with some sane defaults (e.g. .git, .hg and similar).
I started using git worktree and realized that opencode always is looking into the main worktree, but not in my current worktree. This implementation detail made me understand why. running git config --list --show-origin made me realize that opencode thinks it should look in the directory from which the worktree was generated.
Not sure what a solution to this would be.
And this looks like it already solves my issue. While i think git rev-parse --path-format=absolute --git-dir would give the worktree's directory and the above command gives the common directory.
I'll have to test with the current develop.
Activity
github-actions commentedon Aug 20, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
segoon commentedon Aug 20, 2025
I think there are 2 different tasks and 1 common subtask:
rekram1-node commentedon Aug 20, 2025
hmm i thought we already loaded agents.md from project root everytime
rekram1-node commentedon Aug 20, 2025
Maybe I misread your wording but as you can see in this basic project we definitely read AGENTS.md from project root even when you are in subdirectory.
segoon commentedon Aug 23, 2025
Hmm looks like it works for projects with .git. However, how do you discover project root? It is this code - https://github.com/sst/opencode/blob/1f57b9a70f09bea9c9fd5662becdda18c967f9a1/packages/opencode/src/app/app.ts#L69 ? I don't think it is generic enough - there are projects without git and with other VCSs or even without VCS at all. It's better to enable user to define root marker files with some sane defaults (e.g. .git, .hg and similar).
rekram1-node commentedon Aug 23, 2025
makes sense
maiterth commentedon Sep 5, 2025
I started using git worktree and realized that opencode always is looking into the main worktree, but not in my current worktree. This implementation detail made me understand why. running git config --list --show-origin made me realize that opencode thinks it should look in the directory from which the worktree was generated.
Not sure what a solution to this would be.
--- After some digging:
I looked: since the referenced code is old, most likely this part is relevant, which is already in develop:
https://github.com/sst/opencode/blob/900fe5ca041c5b9e2de9449c441dd9cb10beed0a/packages/opencode/src/project/project.ts#L68C17-L68C70
And this looks like it already solves my issue. While i think
git rev-parse --path-format=absolute --git-dirwould give the worktree's directory and the above command gives the common directory.I'll have to test with the current develop.
rekram1-node commentedon Sep 5, 2025
Does this mean you have to test on latest? sorry i didn't quite follow u
maiterth commentedon Sep 5, 2025
Sorry, for the confusion, I have opened an new issue #2445 And I have tested with latest and found a quick fix.
https://github.com/maiterth/opencode/compare/dev...feature-test-worktree-rootdir
But this is actually unrelated to OPs issue. -> #2445
rekram1-node commentedon Sep 5, 2025
sweet, just saw it thanks @maiterth
rekram1-node commentedon Dec 28, 2025
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!