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
I'm using git worktrees and opencode has issues identifying what the root directory of the project is.
Opencode always falls back to the git root directory, even if it should be work in in a worktree.
I'm working inside a worktree:
however, when doing any operations, opencode tries to work in the git main directory, therefore I get errors like
Error: File $HOME/Repositories/my-proj/AGENTS.md is not in the
current working directory
While I'm running opencode from $HOME/Repositories/my-proj-new-feature/AGENTS.md and the agents should actually be working in this directory not in the original git repo.
Reproducer:
Go into a git repository and run git worktree add ../my-proj-new-feature cd ../my-proj-new-feature' opencode`
From there try anything, such as /init
Or ask it to interact with the code.
The agent will often/always land in the
$HOME/Repositories/my-proj/ directory
instead of the
$HOME/Repositories/my-proj-new-feature/ directory
General Comments:
It makes sense that a shared AGENTS.md may be desired (e.g. compare to !2094), however identifying the root "working" directory should work first.
Ok, I may have a strange way of using worktrees:
In fact I do the following: Inside my Repos directory
~/Repositories/
I create a project directory and checkout main or dev. e.g.:
> mkdir opencode
> cd opencode
> git checkout https://github.com/sst/opencode dev
> cd dev
From this i create my worktrees:
> git worktree add ../feature-x
> cd ../feature-x
This may be a bit unconventional but keeps my Repositories clean.
When checking the --git-common-dir I get this:
In this case opencode often moves up to here: $HOME/Repositories/opencode or lands in $HOME/Repositories/opencode/dev instead of my $HOME/Repositories/opencode/feature-x.
I checked out the new code changes in !2360 , and it initially seemed like this fixed my issue, however:
/Init seemed fine, reading files seemed fine, but now with the project, worktree and directory, we at times still land in the most common shared directory.
Fun sidestory:
I asked to find a function signature, and the agent ran off grepping in the most common directory:
To test if the changes worked, I asked "Which file is function_x in?" (after having interacted based on that function and file before)
The LLM in opencode ran off into the directory one up and grepped through my venv. Reading 90K of context and LICENSE files, forgot my prompt and gave a generic response "And this is how you run TensorFlow"
$HOME/Repositories/my-project/venv-python3.13/lib/python3.13/site-packages/boto3-1.40.26.dist-info/LICENSE: ┃
┃ Line 70: copyright license to reproduce, prepare Derivative Works of, ┃
┃ ┃
┃ $HOME/Repositories/my-project/venv-python3.13/lib/python3.13/site-packages/s3transfer-0.13.1.dist- ┃
┃ info/LICENSE.txt: ┃
┃ ┃
Sure! Here’s a quick guide to using TensorFlow.js (tfjs) for classification and inference with a pre-trained model.
1. Set up the environment
• Add the TensorFlow.js script to your HTML or install it via npm:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>
or
npm install @tensorflow/tfjs
2. Load a pre-trained model
• TensorFlow.js supports several
It completely forgot the prompt or codebase and stating "That’s it! With these steps you can load any pre-trained TensorFlow.js models" (the project is about something else, and the output is definitely not the intended one, not sure if I want to blame it on the model ;) .)
Going back to the subject,
These are the directories I have:
$HOME/Repositories/my-project/main
$HOME/Repositories/my-project/worktree-x
While the common upper directory
$HOME/Repositories/my-project/
only contains the worktrees and main branch in thei respective directory, and in this case my venv. (no git or hidden files).
The fixe in !2360 I think does the right thing with identifying project, directory and worktree, but something seems to not go right.
The path where I expected it to run in is was worktree-x, while the common my-project directory (on up) was chosen.
The merge in !2360 mentions every endpoint takes an optional directory parameter to operate as though opencode is running in that directory
Do I have to set this directory as a user or am I missing something?
I run from the worktree-x directory and
My status line shows opencode v0.7.0 ~/Repositories/my-project/worktree-x:main
git status shows On branch worktree-x (worktree and feature are named alike)
Activity
rekram1-node commentedon Sep 5, 2025
Hmm I will try to reproduce this
maiterth commentedon Sep 5, 2025
Ok, I may have a strange way of using worktrees:
In fact I do the following: Inside my Repos directory
~/Repositories/
I create a project directory and checkout main or dev. e.g.:
From this i create my worktrees:
This may be a bit unconventional but keeps my Repositories clean.
When checking the --git-common-dir I get this:
and
In this case opencode often moves up to here: $HOME/Repositories/opencode or lands in $HOME/Repositories/opencode/dev instead of my $HOME/Repositories/opencode/feature-x.
rekram1-node commentedon Sep 5, 2025
I do mine in the same way P much but I will look into it
git worktree list
/Users/aidencline/development/opencode
/Users/aidencline/development/opencode-dev
maiterth commentedon Sep 10, 2025
I checked out the new code changes in !2360 , and it initially seemed like this fixed my issue, however:
/Init seemed fine, reading files seemed fine, but now with the project, worktree and directory, we at times still land in the most common shared directory.
Fun sidestory:
I asked to find a function signature, and the agent ran off grepping in the most common directory:
To test if the changes worked, I asked "
Which file is function_x in?" (after having interacted based on that function and file before)The LLM in opencode ran off into the directory one up and grepped through my venv. Reading 90K of context and LICENSE files, forgot my prompt and gave a generic response "And this is how you run TensorFlow"
It completely forgot the prompt or codebase and stating "
That’s it! With these steps you can load any pre-trained TensorFlow.js models" (the project is about something else, and the output is definitely not the intended one, not sure if I want to blame it on the model ;) .)Going back to the subject,
These are the directories I have:
$HOME/Repositories/my-project/main
$HOME/Repositories/my-project/worktree-x
While the common upper directory
$HOME/Repositories/my-project/
only contains the worktrees and main branch in thei respective directory, and in this case my venv. (no git or hidden files).
The fixe in !2360 I think does the right thing with identifying project, directory and worktree, but something seems to not go right.
The path where I expected it to run in is was worktree-x, while the common my-project directory (on up) was chosen.
The merge in !2360 mentions
every endpoint takes an optional directory parameter to operate as though opencode is running in that directoryDo I have to set this directory as a user or am I missing something?
I run from the worktree-x directory and
My status line shows
opencode v0.7.0 ~/Repositories/my-project/worktree-x:maingit status shows
On branch worktree-x(worktree and feature are named alike)rekram1-node commentedon Sep 29, 2025
@maiterth are you still encountering this. think it may have been fixed recently
lgladysz commentedon Sep 29, 2025
In
v0.13.5/initcommand still pointing to the git main directory instead of the git worktree.After using
/initin theproject-1-worktreedirectory, I seeproject-1instead ofproject-1-worktree:rekram1-node commentedon Sep 29, 2025
ty @lgladysz I will check it out
rekram1-node commentedon Sep 30, 2025
I just merged a fix for this #2870
will be in next release