-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
Summary
When running opencode from a subdirectory (e.g., packages/lib-relay in a monorepo), accessing .opencode/state/ at the project root triggers external_directory permission prompts—even though the path is within the git worktree.
Reproduction
cd ~/Code/project/packages/some-package # subdirectory of git repo
opencode run --command some-command feature-name
# Prompts for external_directory permission to access:
# /path/to/project/.opencode/state/feature-nameRoot Cause
In packages/opencode/src/file/read.ts:30:
if (!Filesystem.contains(Instance.directory, filepath))Instance.directory= CWD (packages/some-package)Instance.worktree= git root (correctly identified)- Containment check uses CWD, not worktree
Paths within the git worktree but outside CWD are treated as external.
Expected Behavior
Paths within Instance.worktree (especially .opencode/ directories) should not trigger external_directory permission. Similar to how Truncate.DIR is auto-allowed in agent.ts:223.
Suggested Fix
Either:
- Check containment against both
Instance.directoryandInstance.worktree - Auto-allow
.opencode/**paths within the worktree (likeTruncate.DIR)
Workarounds
- Run from project root
- Add to project
opencode.json:
{
"permission": {
"external_directory": {
"**/.opencode/**": "allow"
}
}
}Metadata
Metadata
Assignees
Labels
No labels