[PR #10660] docs: Update plugin loading documentation #13517

Closed
opened 2026-02-16 18:18:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10660

State: closed
Merged: No


Closes #10556

Expanded documentation on loading plugins, including new methods and limitations.

What does this PR do?

Improve docs on plugin loading.

How did you verify your code works?

workspace with .opencode

#!/usr/bin/env bash

# Script to create test workspace by cloning opencode-pty repository
ROOT_DIR="$(pwd)"
OPENCODE_PTY="$ROOT_DIR/opencode-pty"
WORKSPACE="$ROOT_DIR/opencode_workspace"
OPENCODE_CONFIG="$WORKSPACE/.opencode/opencode.json"
OPENCODE_LOG="$WORKSPACE/opencode.log"
rm -rf "$OPENCODE_PTY"
rm -rf "$WORKSPACE"
git clone https://github.com/shekohex/opencode-pty
cd "$OPENCODE_PTY"
bun install
echo 'console.log("opencode-pty plugin loaded");' >> index.ts
cd "$ROOT_DIR"
mkdir "$WORKSPACE"
mkdir "$WORKSPACE/.opencode"

# Create opencode.json config file in workspace/.opencode
cat <<'EOF' > "$OPENCODE_CONFIG"
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["file://__OPENCODE_PTY__/index.ts"]
}
EOF
sed -i "s|__OPENCODE_PTY__|$OPENCODE_PTY|g" "$OPENCODE_CONFIG"

# Run opencode in debug wait mode in background and print PID
cd "$WORKSPACE"
opencode debug wait &
pid=$!
trap "kill $pid" EXIT
echo $pid
tree -L 3 "$ROOT_DIR"
sleep 5

output

Cloning into 'opencode-pty'...
bun install v1.3.6 (d530ed99)

+ @types/bun@1.3.1
+ @opencode-ai/plugin@1.1.3
+ @opencode-ai/sdk@1.1.3
+ bun-pty@0.4.2
+ typescript@5.9.3

11 packages installed [27.00ms]
43568
/tmp/opencode-pty-bug
├── opencode-pty
│   ├── AGENTS.md
│   ├── bun.lock
│   ├── flake.lock
│   ├── flake.nix
│   ├── index.ts
│   ├── LICENSE
│   ├── nix
│   │   ├── bun.nix
│   │   └── README.bun2nix.md
│   ├── node_modules
│   │   ├── bun-pty
│   │   ├── bun-types
│   │   ├── csstype
│   │   ├── @opencode-ai
│   │   ├── @types
│   │   ├── typescript
│   │   ├── undici-types
│   │   └── zod
│   ├── package.json
│   ├── README.md
│   ├── release.sh
│   ├── src
│   │   ├── plugin
│   │   └── plugin.ts
│   └── tsconfig.json
├── opencode_workspace
├── setup_opencode_workspace.sh
└── setup_workspace_with_dot_opencode.sh

15 directories, 15 files
opencode-pty plugin loaded

workspace without .opencode

#!/usr/bin/env bash

# Script to create test workspace by cloning opencode-pty repository
ROOT_DIR="$(pwd)"
OPENCODE_PTY="$ROOT_DIR/opencode-pty"
WORKSPACE="$ROOT_DIR/opencode_workspace"
OPENCODE_LOG="$WORKSPACE/opencode.log"
rm -rf "$OPENCODE_PTY"
rm -rf "$WORKSPACE"
git clone https://github.com/shekohex/opencode-pty
cd "$OPENCODE_PTY"
bun install
echo 'console.log("opencode-pty plugin loaded");' >> index.ts
cd "$ROOT_DIR"
mkdir "$WORKSPACE"

# Create opencode.json config file in workspace
cat <<'EOF' > "$WORKSPACE/opencode.json"
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["file://__OPENCODE_PTY__/index.ts"]
}
EOF
sed -i "s|__OPENCODE_PTY__|$OPENCODE_PTY|g" "$WORKSPACE/opencode.json"

# Run opencode in debug wait mode in background and print PID
cd "$WORKSPACE"
echo "starting opencode in workspapce $(pwd)"
opencode debug wait > "$OPENCODE_LOG" &
pid=$!
trap "kill $pid" EXIT
echo "pid of opencode: $pid"
echo "content of $WORKSPACE/opencode.json"
cat "$WORKSPACE/opencode.json"
echo "content of $OPENCODE_PTY/index.ts"
cat "$OPENCODE_PTY/index.ts"
tree -L 3 "$ROOT_DIR"
sleep 5
echo "content of $OPENCODE_LOG"
cat "$OPENCODE_LOG"

output

Cloning into 'opencode-pty'...
bun install v1.3.6 (d530ed99)

+ @types/bun@1.3.1
+ @opencode-ai/plugin@1.1.3
+ @opencode-ai/sdk@1.1.3
+ bun-pty@0.4.2
+ typescript@5.9.3

11 packages installed [21.00ms]
starting opencode in workspapce /tmp/opencode-pty-bug/opencode_workspace
pid of opencode: 130033
content of /tmp/opencode-pty-bug/opencode_workspace/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["file:///tmp/opencode-pty-bug/opencode-pty/index.ts"]
}
content of /tmp/opencode-pty-bug/opencode-pty/index.ts
export {
  PTYPlugin
} from "./src/plugin.ts";
console.log("opencode-pty plugin loaded");
/tmp/opencode-pty-bug
├── opencode-pty
│   ├── AGENTS.md
│   ├── bun.lock
│   ├── flake.lock
│   ├── flake.nix
│   ├── index.ts
│   ├── LICENSE
│   ├── nix
│   │   ├── bun.nix
│   │   └── README.bun2nix.md
│   ├── node_modules
│   │   ├── bun-pty
│   │   ├── bun-types
│   │   ├── csstype
│   │   ├── @opencode-ai
│   │   ├── @types
│   │   ├── typescript
│   │   ├── undici-types
│   │   └── zod
│   ├── package.json
│   ├── README.md
│   ├── release.sh
│   ├── src
│   │   ├── plugin
│   │   └── plugin.ts
│   └── tsconfig.json
├── opencode_workspace
│   ├── opencode.json
│   └── opencode.log
├── setup_opencode_workspace.sh
└── setup_workspace_with_dot_opencode.sh

15 directories, 17 files
content of /tmp/opencode-pty-bug/opencode_workspace/opencode.log
opencode-pty plugin loaded
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10660 **State:** closed **Merged:** No --- Closes #10556 Expanded documentation on loading plugins, including new methods and limitations. ### What does this PR do? Improve docs on plugin loading. ### How did you verify your code works? #### workspace with `.opencode` ```bash title="setup_workspace_with_dot_opencode.sh" #!/usr/bin/env bash # Script to create test workspace by cloning opencode-pty repository ROOT_DIR="$(pwd)" OPENCODE_PTY="$ROOT_DIR/opencode-pty" WORKSPACE="$ROOT_DIR/opencode_workspace" OPENCODE_CONFIG="$WORKSPACE/.opencode/opencode.json" OPENCODE_LOG="$WORKSPACE/opencode.log" rm -rf "$OPENCODE_PTY" rm -rf "$WORKSPACE" git clone https://github.com/shekohex/opencode-pty cd "$OPENCODE_PTY" bun install echo 'console.log("opencode-pty plugin loaded");' >> index.ts cd "$ROOT_DIR" mkdir "$WORKSPACE" mkdir "$WORKSPACE/.opencode" # Create opencode.json config file in workspace/.opencode cat <<'EOF' > "$OPENCODE_CONFIG" { "$schema": "https://opencode.ai/config.json", "plugin": ["file://__OPENCODE_PTY__/index.ts"] } EOF sed -i "s|__OPENCODE_PTY__|$OPENCODE_PTY|g" "$OPENCODE_CONFIG" # Run opencode in debug wait mode in background and print PID cd "$WORKSPACE" opencode debug wait & pid=$! trap "kill $pid" EXIT echo $pid tree -L 3 "$ROOT_DIR" sleep 5 ``` #### output ```console Cloning into 'opencode-pty'... bun install v1.3.6 (d530ed99) + @types/bun@1.3.1 + @opencode-ai/plugin@1.1.3 + @opencode-ai/sdk@1.1.3 + bun-pty@0.4.2 + typescript@5.9.3 11 packages installed [27.00ms] 43568 /tmp/opencode-pty-bug ├── opencode-pty │   ├── AGENTS.md │   ├── bun.lock │   ├── flake.lock │   ├── flake.nix │   ├── index.ts │   ├── LICENSE │   ├── nix │   │   ├── bun.nix │   │   └── README.bun2nix.md │   ├── node_modules │   │   ├── bun-pty │   │   ├── bun-types │   │   ├── csstype │   │   ├── @opencode-ai │   │   ├── @types │   │   ├── typescript │   │   ├── undici-types │   │   └── zod │   ├── package.json │   ├── README.md │   ├── release.sh │   ├── src │   │   ├── plugin │   │   └── plugin.ts │   └── tsconfig.json ├── opencode_workspace ├── setup_opencode_workspace.sh └── setup_workspace_with_dot_opencode.sh 15 directories, 15 files opencode-pty plugin loaded ``` #### workspace without `.opencode` ```bash title="setup_opencode_workspace.sh" #!/usr/bin/env bash # Script to create test workspace by cloning opencode-pty repository ROOT_DIR="$(pwd)" OPENCODE_PTY="$ROOT_DIR/opencode-pty" WORKSPACE="$ROOT_DIR/opencode_workspace" OPENCODE_LOG="$WORKSPACE/opencode.log" rm -rf "$OPENCODE_PTY" rm -rf "$WORKSPACE" git clone https://github.com/shekohex/opencode-pty cd "$OPENCODE_PTY" bun install echo 'console.log("opencode-pty plugin loaded");' >> index.ts cd "$ROOT_DIR" mkdir "$WORKSPACE" # Create opencode.json config file in workspace cat <<'EOF' > "$WORKSPACE/opencode.json" { "$schema": "https://opencode.ai/config.json", "plugin": ["file://__OPENCODE_PTY__/index.ts"] } EOF sed -i "s|__OPENCODE_PTY__|$OPENCODE_PTY|g" "$WORKSPACE/opencode.json" # Run opencode in debug wait mode in background and print PID cd "$WORKSPACE" echo "starting opencode in workspapce $(pwd)" opencode debug wait > "$OPENCODE_LOG" & pid=$! trap "kill $pid" EXIT echo "pid of opencode: $pid" echo "content of $WORKSPACE/opencode.json" cat "$WORKSPACE/opencode.json" echo "content of $OPENCODE_PTY/index.ts" cat "$OPENCODE_PTY/index.ts" tree -L 3 "$ROOT_DIR" sleep 5 echo "content of $OPENCODE_LOG" cat "$OPENCODE_LOG" ``` #### output ```console Cloning into 'opencode-pty'... bun install v1.3.6 (d530ed99) + @types/bun@1.3.1 + @opencode-ai/plugin@1.1.3 + @opencode-ai/sdk@1.1.3 + bun-pty@0.4.2 + typescript@5.9.3 11 packages installed [21.00ms] starting opencode in workspapce /tmp/opencode-pty-bug/opencode_workspace pid of opencode: 130033 content of /tmp/opencode-pty-bug/opencode_workspace/opencode.json { "$schema": "https://opencode.ai/config.json", "plugin": ["file:///tmp/opencode-pty-bug/opencode-pty/index.ts"] } content of /tmp/opencode-pty-bug/opencode-pty/index.ts export { PTYPlugin } from "./src/plugin.ts"; console.log("opencode-pty plugin loaded"); /tmp/opencode-pty-bug ├── opencode-pty │   ├── AGENTS.md │   ├── bun.lock │   ├── flake.lock │   ├── flake.nix │   ├── index.ts │   ├── LICENSE │   ├── nix │   │   ├── bun.nix │   │   └── README.bun2nix.md │   ├── node_modules │   │   ├── bun-pty │   │   ├── bun-types │   │   ├── csstype │   │   ├── @opencode-ai │   │   ├── @types │   │   ├── typescript │   │   ├── undici-types │   │   └── zod │   ├── package.json │   ├── README.md │   ├── release.sh │   ├── src │   │   ├── plugin │   │   └── plugin.ts │   └── tsconfig.json ├── opencode_workspace │   ├── opencode.json │   └── opencode.log ├── setup_opencode_workspace.sh └── setup_workspace_with_dot_opencode.sh 15 directories, 17 files content of /tmp/opencode-pty-bug/opencode_workspace/opencode.log opencode-pty plugin loaded ```
yindo added the pull-request label 2026-02-16 18:18:22 -05:00
yindo closed this issue 2026-02-16 18:18:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13517