MCPcopy Create free account
hub / github.com/Tencent/teamai-cli / reconcileOpencodePlugin

Function reconcileOpencodePlugin

src/hooks.ts:823–840  ·  view source on GitHub ↗

* Reconcile the single teamai OpenCode plugin. * * OpenCode auto-loads plugins from BOTH `~/.config/opencode/plugin` and * ` /.opencode/plugin`, so a project-scope copy living next to a * user-scope one makes OpenCode load two identical plugins and dispatch every * event twice. teamai t

(baseDir: string, removeAll = false, installedBaseDir?: string)

Source from the content-addressed store, hash-verified

821 * an earlier layout is deleted on the way through.
822 */
823async function reconcileOpencodePlugin(baseDir: string, removeAll = false, installedBaseDir?: string): Promise<void> {
824 const home = getUserHome();
825 const { injectOpencodeHooks, removeOpencodeHooks } = await import('./opencode-hooks.js');
826 if (path.resolve(baseDir) !== path.resolve(home)) {
827 await removeOpencodeHooks(baseDir, 'project');
828 }
829 if (removeAll) {
830 await removeOpencodeHooks(home, 'user');
831 return;
832 }
833 const homeInstalled = await pathExists(path.join(home, '.config', 'opencode'));
834 const projectInstalled = installedBaseDir
835 ? await pathExists(path.join(installedBaseDir, '.opencode'))
836 : false;
837 if (homeInstalled || projectInstalled) {
838 await injectOpencodeHooks(home, 'user');
839 }
840}
841
842/**
843 * Inject teamai built-in hooks into all AI tool settings.

Callers 2

injectHooksToAllToolsFunction · 0.85
reconcileHooksToAllToolsFunction · 0.85

Calls 4

getUserHomeFunction · 0.85
removeOpencodeHooksFunction · 0.85
pathExistsFunction · 0.85
injectOpencodeHooksFunction · 0.85

Tested by

no test coverage detected