[FEATURE]: Add cwd option to createOpencodeServer #2204

Open
opened 2026-02-16 17:34:39 -05:00 by yindo · 5 comments
Owner

Originally created by @simonxabris on GitHub (Oct 21, 2025).

Originally assigned to: @simonxabris on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I'm working on a vite plugin that starts an opencode server in the onStart hook. My problem is that I'm working in a monorepo and my app is at packages/app, the server will be spawned in packages/app and won't have access to other parts of the monorepo.

By adding a cwd property to the options of createOpencodeServer, I could spawn the opencode server process at the root of the monorepo and opencode would have access to the whole monorepo.

If it's approved I'm happy to create the PR, it's a fairly small change imo.

Originally created by @simonxabris on GitHub (Oct 21, 2025). Originally assigned to: @simonxabris on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request I'm working on a vite plugin that starts an opencode server in the `onStart` hook. My problem is that I'm working in a monorepo and my app is at `packages/app`, the server will be spawned in `packages/app` and won't have access to other parts of the monorepo. By adding a `cwd` property to the options of `createOpencodeServer`, I could spawn the opencode server process at the root of the monorepo and opencode would have access to the whole monorepo. If it's approved I'm happy to create the PR, it's a fairly small change imo.
yindo added the discussion label 2026-02-16 17:34:39 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 21, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1877: Requests a root folder configuration to aggregate sessions across subdirectories, which includes the ability to set working directories and capture sessions from subfolders
  • #1143: Discusses creating sessions with different root/working directories in monorepo contexts, similar to your use case
  • #2177: Requests the ability to explicitly change working directory during sessions, including programmatic directory changes

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 21, 2025): This issue might be a duplicate of existing issues. Please check: - #1877: Requests a root folder configuration to aggregate sessions across subdirectories, which includes the ability to set working directories and capture sessions from subfolders - #1143: Discusses creating sessions with different root/working directories in monorepo contexts, similar to your use case - #2177: Requests the ability to explicitly change working directory during sessions, including programmatic directory changes Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 22, 2025):

Yeah I think that'd be acceptable

@rekram1-node commented on GitHub (Oct 22, 2025): Yeah I think that'd be acceptable
Author
Owner

@veracioux commented on GitHub (Oct 22, 2025):

Perhaps allow the SDK client to override the spawn options for the server as a more general feature? Which would cover cwd as well.

@veracioux commented on GitHub (Oct 22, 2025): Perhaps allow the SDK client to override the spawn options for the server as a more general feature? Which would cover cwd as well.
Author
Owner

@rekram1-node commented on GitHub (Oct 22, 2025):

yeah that works

@rekram1-node commented on GitHub (Oct 22, 2025): yeah that works
Author
Owner

@wan-kong commented on GitHub (Oct 23, 2025):

cwd-option

add a new --cwd option to specify the current working directory when running opencode serve.

All right , just a idea now.

@wan-kong commented on GitHub (Oct 23, 2025): [cwd-option](https://github.com/wan-kong/opencode/tree/feat/cwd-option) add a new `--cwd` option to specify the current working directory when running `opencode serve`. All right , just a idea now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2204