-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.ts
More file actions
71 lines (66 loc) · 1.94 KB
/
plugin.ts
File metadata and controls
71 lines (66 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Worktrunk OpenCode Plugin
* Bridges OpenCode/Kilo Code lifecycle with Worktrunk status markers.
*/
export default async ({ $, worktree }) => {
return {
hooks: {
/**
* Injects current Worktrunk status into the agent's prompt context.
*/
"tui.prompt.append": async () => {
try {
const info = await $`wt info --json`.json();
return `\n\n[CONTEXT: ACTIVE WORKTREE]\nPath: ${worktree}\nBranch: ${info.branch}\nStatus: ${info.status}`;
} catch (e) {
return "";
}
},
/**
* Lifecycle: Update Worktrunk marker to '🤖' (active) when a task starts.
*/
"session.status": async ({ status }) => {
if (status === "running") {
await $`wt config state marker set 🤖`.quiet();
}
},
/**
* Lifecycle: Revert Worktrunk marker to '💬' (idle) when the agent finishes.
*/
"session.idle": async () => {
await $`wt config state marker set 💬`.quiet();
},
/**
* Lifecycle: Clear marker on error.
*/
"session.error": async () => {
await $`wt config state marker clear`.quiet();
}
},
/**
* Expose Worktrunk CLI as tools for the AI agent.
*/
tools: {
wt_create: {
description: "Create a new Worktrunk worktree for a branch.",
args: { branch: "string", base: "string?" },
execute: async ({ branch, base }) => {
return await $`wt create ${branch} ${base || ""}`.text();
}
},
wt_switch: {
description: "Switch to an existing Worktrunk worktree.",
args: { target: "string" },
execute: async ({ target }) => {
return await $`wt switch ${target}`.text();
}
},
wt_list: {
description: "List all active Worktrunk worktrees.",
execute: async () => {
return await $`wt list`.text();
}
}
}
};
};