MCPcopy Index your code
hub / github.com/tiann/hapi / ensureOpencodeHookPlugin

Function ensureOpencodeHookPlugin

cli/src/opencode/utils/hookPlugin.ts:214–233  ·  view source on GitHub ↗
(rootPath: string, hookUrl: string, token: string)

Source from the content-addressed store, hash-verified

212}
213
214export function ensureOpencodeHookPlugin(rootPath: string, hookUrl: string, token: string): string {
215 const pluginDir = resolvePluginDir(rootPath);
216 mkdirSync(pluginDir, { recursive: true });
217 ensurePluginRuntime(rootPath);
218
219 const pluginPath = join(pluginDir, PLUGIN_FILENAME);
220 const nextSource = buildPluginSource(hookUrl, token);
221
222 try {
223 const current = readFileSync(pluginPath, 'utf-8');
224 if (current === nextSource) {
225 return pluginPath;
226 }
227 } catch {
228 // Ignore missing or unreadable file.
229 }
230
231 writeFileSync(pluginPath, nextSource, 'utf-8');
232 return pluginPath;
233}

Callers 2

opencodeLocalLauncherFunction · 0.90
hookPlugin.test.tsFile · 0.90

Calls 3

resolvePluginDirFunction · 0.85
ensurePluginRuntimeFunction · 0.85
buildPluginSourceFunction · 0.85

Tested by

no test coverage detected