Skip to content

Commit 87d4c2f

Browse files
benjaminshafiigithub-actions[bot]
authored andcommitted
feat(hotreload): reset plugins, tools, and mcp on apply
1 parent bd48c5f commit 87d4c2f

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

packages/opencode/src/mcp/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ export namespace MCP {
209209
},
210210
)
211211

212+
export async function reset() {
213+
await state.reset()
214+
}
215+
212216
// Helper function to fetch prompts for a specific client
213217
async function fetchPromptsForClient(clientName: string, client: Client) {
214218
const prompts = await client.listPrompts().catch((e) => {

packages/opencode/src/plugin/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export namespace Plugin {
119119
return state().then((x) => x.hooks)
120120
}
121121

122+
export async function reset() {
123+
await state.reset()
124+
}
125+
122126
export async function init() {
123127
const hooks = await state().then((x) => x.hooks)
124128
const config = await Config.get()

packages/opencode/src/project/hotreload.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import { Command } from "@/command"
66
import { Config } from "@/config/config"
77
import { FileWatcher } from "@/file/watcher"
88
import { Flag } from "@/flag/flag"
9+
import { MCP } from "@/mcp"
10+
import { Plugin } from "@/plugin"
911
import { SessionStatus } from "@/session/status"
1012
import { Skill } from "@/skill"
13+
import { ToolRegistry } from "@/tool/registry"
1114
import { Log } from "@/util/log"
1215
import { Instance } from "./instance"
1316
import z from "zod"
@@ -135,6 +138,9 @@ export namespace HotReload {
135138

136139
const reload = async () => {
137140
await Config.reset()
141+
await Plugin.reset()
142+
await MCP.reset()
143+
await ToolRegistry.reset()
138144
await Skill.reset()
139145
await Agent.reset()
140146
await Command.reset()

packages/opencode/src/tool/registry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export namespace ToolRegistry {
5757
return { custom }
5858
})
5959

60+
export async function reset() {
61+
await state.reset()
62+
}
63+
6064
function fromPlugin(id: string, def: ToolDefinition): Tool.Info {
6165
return {
6266
id,

0 commit comments

Comments
 (0)