feat(session): add support for per-session working directories#9365
Open
ssmirr wants to merge 1 commit intoanomalyco:devfrom
Open
feat(session): add support for per-session working directories#9365ssmirr wants to merge 1 commit intoanomalyco:devfrom
ssmirr wants to merge 1 commit intoanomalyco:devfrom
Conversation
Add Session.directory.get()/set() to allow sessions to have their own working directory, separate from Instance.directory. This enables use cases like: - Git worktrees per session - Sandboxed directories - Custom project layouts Changes: - Add Session.directory accessor in session/index.ts - Update all tools (bash, edit, write, grep, glob, ls, lsp, apply_patch) to use Session.directory.get() instead of Instance.directory - Update prompt.ts to set Session.directory from session.directory at the start of the prompt loop and shell command execution - Update system.ts to show Session.directory in environment info - Update compaction.ts to use Session.directory in path.cwd Session.directory falls back to Instance.directory if not set, ensuring backward compatibility.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one related PR that is closely connected to the current PR: Related PR (Companion Feature):
No duplicate PRs found addressing the same feature. |
1 task
1 task
This was referenced Jan 25, 2026
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
|
Fully support/keen on this feature. |
|
This would be a great feature to have to be able to do soemthing like I know +1 comments not great but want to bump this up. |
Contributor
|
建议也更新 skill 系统的目录获取逻辑。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds
Session.directory.get()/.set()so sessions can have their own working directory instead of always usingInstance.directory. This enables plugins to customize where each session operates, supporting use cases like:Updates all tools (bash, edit, write, grep, glob, ls, lsp, apply_patch) to use the session's directory.
Changes
Session.directoryaccessor withget()andset()methodsSession.directory.get()instead ofInstance.directorySession.directoryat the start of prompt loop and shell command executionSession.directoryin environment infoSession.directoryin path.cwdBackward Compatibility
Session.directory.get()falls back toInstance.directoryif not set, so existing behavior is unchanged.Note
This PR works standalone but is designed to pair with a
session.creatingplugin hook (#9361), which would allow plugins to set custom directories during session creation.How did you verify your code works?
packages/opencode/test/session/directory.test.tsInstance.directorycloses #9366