Write OpenCode plugin file.
(path: &Path, output_dir: &str)
| 601 | |
| 602 | /// Write OpenCode plugin file. |
| 603 | fn 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 |
| 610 | module.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. |
| 632 | fn register_opencode_config(path: &Path) -> Result<()> { |