MCPcopy Create free account
hub / github.com/TtTRz/graphify-rs / write_opencode_plugin

Function write_opencode_plugin

src/install.rs:603–629  ·  view source on GitHub ↗

Write OpenCode plugin file.

(path: &Path, output_dir: &str)

Source from the content-addressed store, hash-verified

601
602/// Write OpenCode plugin file.
603fn write_opencode_plugin(path: &Path, output_dir: &str) -> Result<()> {
604 if let Some(parent) = path.parent() {
605 fs::create_dir_all(parent)?;
606 }
607
608 let plugin_content = format!(
609 r#"// graphify-rs plugin for OpenCode
610module.exports = {{
611 name: "graphify-rs",
612 description: "Knowledge graph integration",
613 hooks: {{
614 preToolUse: async (ctx) => {{
615 const fs = require("fs");
616 if (fs.existsSync("{output_dir}/graph.json")) {{
617 return {{
618 prefix: "[graphify-rs] Knowledge graph available. Read {output_dir}/GRAPH_REPORT.md for architecture overview."
619 }};
620 }}
621 }}
622 }}
623}};
624"#
625 );
626
627 fs::write(path, plugin_content)?;
628 Ok(())
629}
630
631/// Register graphify-rs plugin in opencode.json.
632fn register_opencode_config(path: &Path) -> Result<()> {

Callers 1

opencode_installFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected