From c2144b74fdd7202966db954f36577cc685090609 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 23 Jun 2026 23:26:19 -0400 Subject: [PATCH] Getting more AI agent stuff set up. --- .gitignore | 3 ++- .opencode/opencode.json | 6 ++++++ .opencode/plugins/graphify.js | 28 ++++++++++++++++++++++++++++ AGENTS.md | 12 ++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .opencode/opencode.json create mode 100644 .opencode/plugins/graphify.js create mode 100644 AGENTS.md diff --git a/.gitignore b/.gitignore index 39d182e9..6839b9da 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,5 @@ graphify-out/ src/graphify-out/ # Claude Code local settings (machine-specific) -.claude/settings.local.json \ No newline at end of file +.claude/settings.local.json +.aider* diff --git a/.opencode/opencode.json b/.opencode/opencode.json new file mode 100644 index 00000000..ddb4d7ec --- /dev/null +++ b/.opencode/opencode.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://opencode.ai/config.json", + "plugin": [ + ".opencode/plugins/graphify.js" + ] +} \ No newline at end of file diff --git a/.opencode/plugins/graphify.js b/.opencode/plugins/graphify.js new file mode 100644 index 00000000..89a855d9 --- /dev/null +++ b/.opencode/plugins/graphify.js @@ -0,0 +1,28 @@ +// graphify OpenCode plugin +// Injects a knowledge graph reminder before bash tool calls when the graph exists. +// +// IMPORTANT: keep the reminder string free of backticks and $(...) constructs. +// The hook prepends `echo "" && ` to the user's bash command; +// backticks inside the double-quoted echo trigger bash command substitution, +// which both corrupts tool output and silently executes the very graphify +// command we are only suggesting. Plain words render fine in opencode's TUI. +import { existsSync } from "fs"; +import { join } from "path"; + +export const GraphifyPlugin = async ({ directory }) => { + let reminded = false; + + return { + "tool.execute.before": async (input, output) => { + if (reminded) return; + if (!existsSync(join(directory, "graphify-out", "graph.json"))) return; + + if (input.tool === "bash") { + output.args.command = + 'echo "[graphify] knowledge graph at graphify-out/. For focused questions, run graphify query with your question (scoped subgraph, usually much smaller than GRAPH_REPORT.md) instead of grepping raw files. Read GRAPH_REPORT.md only for broad architecture context." && ' + + output.args.command; + reminded = true; + } + }, + }; +}; diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..20cff728 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,12 @@ +## graphify + +This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships. + +When the user types `/graphify`, invoke the `skill` tool with `skill: "graphify"` before doing anything else. + +Rules: +- For codebase questions, first run `graphify query ""` when graphify-out/graph.json exists. Use `graphify path "" ""` for relationships and `graphify explain ""` for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output. +- Dirty graphify-out/ files are expected after hooks or incremental updates; dirty graph files are not a reason to skip graphify. Only skip graphify if the task is about stale or incorrect graph output, or the user explicitly says not to use it. +- If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing. +- Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context. +- After modifying code, run `graphify update .` to keep the graph current (AST-only, no API cost).