-
Notifications
You must be signed in to change notification settings - Fork 76
chore: add graphify knowledge graph and IDE integrations #1714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
adb11ab
c95e965
4baba6a
4f8825f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "hooks": { | ||
| "PreToolUse": [ | ||
| { | ||
| "matcher": "Bash", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "CMD=$(python3 -c \"import json,sys; d=json.load(sys.stdin); print(d.get('tool_input',d).get('command',''))\" 2>/dev/null || true); case \"$CMD\" in *grep*|*rg\\ *|*ripgrep*|*find\\ *|*fd\\ *|*ack\\ *|*ag\\ *) [ -f graphify-out/graph.json ] && echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"MANDATORY: graphify-out/graph.json exists. You MUST run `graphify query \\\"<question>\\\"` before grepping raw files. Only grep after graphify has oriented you, or to modify/debug specific lines.\"}}' || true ;; esac" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "matcher": "Read|Glob", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "HIT=$(python3 -c \"import json,sys;d=json.load(sys.stdin);t=d.get('tool_input',d);s=(str(t.get('file_path') or '')+' '+str(t.get('pattern') or '')+' '+str(t.get('path') or '')).lower().replace(chr(92),'/');exts=('.py','.js','.ts','.tsx','.jsx','.go','.rs','.java','.rb','.c','.h','.cpp','.hpp','.cc','.cs','.kt','.swift','.php','.scala','.lua','.sh','.md','.rst','.txt','.mdx');sys.stdout.write('1' if 'graphify-out/' not in s and any(e in s for e in exts) else '')\" 2>/dev/null || true); if [ \"$HIT\" = 1 ] && [ -f graphify-out/graph.json ]; then echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"MANDATORY: graphify-out/graph.json exists. You MUST run graphify before reading source files. Use: `graphify query \\\"<question>\\\"` (scoped subgraph), `graphify explain \\\"<concept>\\\"`, or `graphify path \\\"<A>\\\" \\\"<B>\\\"`. Only read raw files after graphify has oriented you, or to modify/debug specific lines. This rule applies to subagents too \u2014 include it in every subagent prompt involving code exploration.\"}}'; fi || true" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| description: graphify knowledge graph — mandatory exploration workflow | ||
| alwaysApply: true | ||
| --- | ||
|
|
||
| Before using Read, Grep, Glob, or Bash to explore this codebase, you MUST run graphify first. | ||
|
|
||
| Full workflow, commands, exceptions, and subagent requirements: see the **Codebase Navigation (Graphify)** section in [AGENTS.md](../../AGENTS.md). | ||
|
|
||
| Include this rule explicitly in every subagent prompt that involves code exploration. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "plugin": [ | ||
| ".opencode/plugins/graphify.js" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // graphify OpenCode plugin | ||
| // Injects a knowledge graph reminder before bash tool calls when the graph exists. | ||
| 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 \"<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; | ||
| } | ||
| }, | ||
| }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,32 @@ After addressing review comments, don't forget to add a comment in the PR afterw | |
|
|
||
| Detailed instructions regarding the DevWorkspace Operator development are provided in this section. | ||
|
|
||
| ### Codebase Navigation (Graphify) | ||
|
|
||
| This repository ships a pre-built knowledge graph (`graphify-out/`) to help navigate the codebase without expensive file searches. After cloning or pulling, run once to anchor the graph to your local paths: | ||
|
|
||
| ```bash | ||
| graphify update . | ||
|
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Install Graphify before the first setup command. On a fresh development environment, this procedure fails with 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| Optionally, enable auto-rebuild on every commit: | ||
|
|
||
| ```bash | ||
| graphify hook install | ||
| ``` | ||
|
|
||
| Once set up, use these commands instead of `grep`/`find` across the source tree: | ||
|
|
||
| | Task | Command | | ||
| |---|---| | ||
| | Architecture overview | read `graphify-out/GRAPH_REPORT.md` | | ||
| | Specific question | `/graphify query "<question>"` | | ||
| | Trace relationship | `/graphify path "<StructA>" "<StructB>"` | | ||
| | Concept details | `/graphify explain "<NodeName>"` | | ||
| | After modifying code | `graphify update .` (terminal) | | ||
|
|
||
| > **Note:** Do not run `graphify claude install` — graphify guidance is already included in `AGENTS.md`. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| To build, test and debug the DevWorkspace Operator the following development tools are required: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: devfile/devworkspace-operator
Length of output: 2239
🏁 Script executed:
Repository: devfile/devworkspace-operator
Length of output: 748
Quote the reminder without shell command substitution.
When the graph exists, the first eligible Bash call can execute
graphify query "<question>"as command substitution. Its output replaces the example in the reminder, while the original Bash command still runs. Useprintfwith a shell single-quoted reminder.🐛 Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents