Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(plugin): scope OpenCode marker commands to the plugin's directory (#3554)

4i3n6b00e6b612a57
diff --git a/dev/opencode-plugin.ts b/dev/opencode-plugin.ts
index 77a8509b1..bc198c008 100644
--- a/dev/opencode-plugin.ts
+++ b/dev/opencode-plugin.ts
@@ -9,18 +9,25 @@
import type { Plugin } from "@opencode-ai/plugin";
-export default (async ({ $ }) => {
+export default (async ({ $, directory }) => {
return {
event: async ({ event }) => {
+ // `$` is the host's process-global Bun shell, shared by every plugin in
+ // the process. The promise-level `.cwd(directory)` on each command below
+ // is load-bearing: it pins the command to the directory this plugin
+ // instance was created for. Without it, the command runs in whatever the
+ // process-wide cwd happens to be at spawn time. Do not "simplify" to the
+ // instance-level `$.cwd(...)` β€” that mutates the shared default for every
+ // plugin in the host process.
switch (event.type) {
case "session.status":
- await $`wt config state marker set ${'πŸ€–'} || true`.quiet();
+ await $`wt config state marker set ${'πŸ€–'} || true`.cwd(directory).quiet();
break;
case "session.idle":
- await $`wt config state marker set ${'πŸ’¬'} || true`.quiet();
+ await $`wt config state marker set ${'πŸ’¬'} || true`.cwd(directory).quiet();
break;
case "session.deleted":
- await $`wt config state marker clear || true`.quiet();
+ await $`wt config state marker clear || true`.cwd(directory).quiet();
break;
}
},