missing documentation for how to run from source
AFAICS, there is nothing in any of README.md, CONTRIBUTING.md, https://opencode.ai/docs#install etc. explaining how to run OpenCode from source on another repository, i.e. whilst having the working directory be a different repo other than OpenCode itself.
Fixing this is really important if you want more people to help test (and even develop against) the latest development branches.
I spent several few hours bashing my head against this problem. Eventually I searched the OpenCode Discord chat history and found some breadcrumbs to follow which led me to #3764 and then #3778. Unfortunately however neither of those PRs added / updated any docs.
With extra help from OpenCode, I concluded that this approach works and seems to be correct:
# Save the path to the code we want to run OpenCode against
orig_cwd="$(pwd)"
# Now we can switch to the opencode repo...
cd "$OPENCODE_REPO"
# ... and pass the target directory as a parameter to bun:
bun dev "$orig_cwd" "$@"
Is this right?
If you wanna run it for a different dir:
bun dev dir
If you just wanna run it in root of opencode repo:
bun dev .
And if you wanna compile it and have a local executable (a localcode if you will):
./packages/opencode/script/build.ts --single
then run like so (for me this is):
./packages/opencode/dist/opencode-darwin-arm64/bin/opencode
I can update docs tho
/oc use docs agent to update CONTRIBUTING.md to include this
How is this?
https://github.com/sst/opencode/blob/dev/CONTRIBUTING.md#running-against-a-different-directory
I have this: ~/.local/bin/opencode
#!/bin/bash
set -eo pipefail
PROJECT_DIR=$(pwd)
cd ~/repos/opencode
exec bun dev --dir "$PROJECT_DIR" $@
# Proposed alternative syntax: https://github.com/paralin/opencode/commit/81275b1af11ccf51d20578765e2acf1db08caf0d
# exec bun run --cwd packages/opencode --conditions=browser src/index.ts --dir $PROJECT_DIR $@
Awesome thanks a lot @rekram1-node!
