Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dev/opencode-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
Expand Down
Loading