Repository navigation
Conversation
There was a problem hiding this comment.
The /init fix works. I opened sessions in a directory nested inside a git repository using the simulated model. On the base, the /init prompt points AGENTS.md at the repository root; with this change, it points at the session's directory. bun test test/plugin/command.test.ts passes. The public API is unchanged, but this changes how the built-in /init command behaves in nested sessions.
- Product decision needed: on #52833, a reply calls the current repository-root behaviour by design and turns the request into a feature request. A maintainer should confirm they want
/initto follow the session directory before this lands. Instruction loading already searches upward from the session directory to the repository root, so anAGENTS.mdwritten in a subdirectory will still be loaded. - The
/reviewchange does nothing:review.txthas no${path}placeholder, so/reviewbehaves exactly as before. The description's claim that/reviewnow targets the package directory isn't accurate. Either drop that line so the change stays minimal, or correct the description.
| ...input.prompt, | ||
| sessionID: input.sessionID, | ||
| text: append(PROMPT_REVIEW.replace("${path}", location.project.directory), input.prompt.text), | ||
| text: append(PROMPT_REVIEW.replace("${path}", location.directory), input.prompt.text), |
There was a problem hiding this comment.
PROMPT_REVIEW (command/review.txt) contains no ${path} placeholder, so this replacement has no effect and /review behaves exactly as before. This line can be dropped to keep the change minimal.
The command plugin substituted ${path} with location.project.directory,
the git worktree root. In a monorepo that made /init write AGENTS.md at
the repository root instead of the directory the session was opened in.
Use location.directory so ${path} points at the session location
directory, and pin the test to a session opened in a subdirectory of the
project instead of the project root.
/review is unchanged: review.txt has no ${path} placeholder.
Fixes anomalyco#52833
7970216 to
b542bdc
Compare
|
Thanks for the review. Updated the branch:
On the product decision: this intentionally changes nested-session |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
1 similar comment
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
There was a problem hiding this comment.
My earlier point is addressed: the change that did nothing to /review has been dropped, so the diff is now only /init. The /init change is the same one I checked before, and test/plugin/command.test.ts still passes. The public API is unchanged. One thing is still open: a maintainer needs to confirm that /init should follow the session directory, since #52833 has a reply describing the repository-root behaviour as intentional.


Issue for this PR
Closes #52833
Type of change
What does this PR do?
/initbuilds its prompt frominitialize.txtand replaces${path}withlocation.project.directory, the git worktree root. A session opened in a subdirectory of a repository therefore writesAGENTS.mdat the repository root instead of the directory the session belongs to.This PR substitutes
location.directoryinstead, so/inittargets the session's directory. When the session is opened at the repository root both values are the same, so that case is unchanged. Instruction loading still searches upward from the session directory to the repository root, so anAGENTS.mdwritten in a subdirectory is still loaded by sessions started below it./reviewis not touched:review.txthas no${path}placeholder, so the substitution had no effect. An earlier revision changed that line as well; it has been dropped to keep the diff minimal.The code change is one line in
packages/core/src/plugin/command.ts, plus the test expectations. The public plugin API is unchanged.Product decision: #52833 has a reply describing the current repository-root behaviour as intentional. This PR deliberately changes nested-session
/init; a maintainer should confirm that is wanted before merge. If the repository-root behaviour is preferred, the PR can be closed.How did you verify your code works?
bun test --timeout 30000 test/plugin/command.test.tsfrompackages/core: 1 pass, 0 fail./repo/packages/appinside the/repoproject and asserts that the/initprompt resolves${path}to/repo/packages/app./initprompt points at the repository root; with this change it points at the session directory.Checklist
Added by the opencode bot (AI-generated).
Related: #51191, #55776, #58148