Skip to content

Conversation

@stumct
Copy link
Owner

@stumct stumct commented Jan 7, 2026

Why

When running opencode serve in containerized multi-repo workspaces (e.g. /work/src), the workspace root often is not a Git repo. In that case the server falls back to / as the worktree, which breaks permissions/config discovery and file ops.

What

  • Add --cwd to opencode serve and pass it through as the server default directory.
  • Treat an explicit --cwd as the root/worktree fallback when no Git root is found (so non-git roots behave like a real workspace).
  • Allow JS SDK createOpencodeServer({ cwd }) to pass the flag through.

Notes

  • Per-request directory query param / x-opencode-directory header still overrides the default.
  • Git projects are unchanged.
  • Related to PR feat(cli): add --cwd flag to web and serve commands anomalyco/opencode#7011: that approach updates serve/web to chdir, but does not change non-git worktree fallback behavior. This PR adds explicit non-git root/worktree handling when --cwd is provided.

Test Plan

  • Not run (manual): opencode serve --cwd /work/src in a non-git workspace and confirm file ops/permissions resolve under /work/src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants