MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _install_opencode_plugin

Function _install_opencode_plugin

graphify/install.py:1995–2007  ·  view source on GitHub ↗

Write graphify.js into /plugins/, where OpenCode discovers it. ``opencode_dir`` comes from _opencode_dir. Both files are replaced atomically. The CLI refresh can run this while OpenCode is watching them, and it must never see half a plugin.

(opencode_dir: Path)

Source from the content-addressed store, hash-verified

1993 _write_text_atomic(config_file, json.dumps(config, indent=2, ensure_ascii=False))
1994 return changed
1995def _install_opencode_plugin(opencode_dir: Path) -> None:
1996 """Write graphify.js into <opencode_dir>/plugins/, where OpenCode discovers it.
1997
1998 ``opencode_dir`` comes from _opencode_dir. Both files are replaced
1999 atomically. The CLI refresh can run this while OpenCode is watching them,
2000 and it must never see half a plugin.
2001 """
2002 plugin_file = opencode_dir / _OPENCODE_PLUGIN_PATH.relative_to(".opencode")
2003 _write_text_atomic(plugin_file, _OPENCODE_PLUGIN_JS)
2004 print(f" {plugin_file} -> tool.execute.before hook written")
2005
2006 if _drop_opencode_config_entry(opencode_dir):
2007 print(f" {opencode_dir / _OPENCODE_CONFIG_PATH.name} -> stale plugin entry removed")
2008def _uninstall_opencode_plugin(opencode_dir: Path) -> None:
2009 """Remove graphify.js plugin and deregister from opencode.json."""
2010 plugin_file = opencode_dir / _OPENCODE_PLUGIN_PATH.relative_to(".opencode")

Callers 3

installFunction · 0.85
_agents_installFunction · 0.85

Calls 1

Tested by

no test coverage detected