graphify.js 733 B

12345678910111213141516171819202122
  1. // graphify OpenCode plugin
  2. // Injects a knowledge graph reminder before bash tool calls when the graph exists.
  3. import { existsSync } from "fs";
  4. import { join } from "path";
  5. export const GraphifyPlugin = async ({ directory }) => {
  6. let reminded = false;
  7. return {
  8. "tool.execute.before": async (input, output) => {
  9. if (reminded) return;
  10. if (!existsSync(join(directory, "graphify-out", "graph.json"))) return;
  11. if (input.tool === "bash") {
  12. output.args.command =
  13. 'echo "[graphify] Knowledge graph available. Read graphify-out/GRAPH_REPORT.md for god nodes and architecture context before searching files." && ' +
  14. output.args.command;
  15. reminded = true;
  16. }
  17. },
  18. };
  19. };