code-graph-llm
Advanced tools
+108
-111
@@ -326,129 +326,126 @@ #!/usr/bin/env node | ||
| async execute(platform, action) { | ||
| if (!platform) return console.error('[Code-Graph] Platform required. Usage: code-graph <platform> [install|uninstall]'); | ||
| async execute(platform, action, skill) { | ||
| if (!platform) return console.error('[Code-Graph] Platform required. Usage: code-graph install-skills <platform> [projectmap|reflections]'); | ||
| const p = platform.toLowerCase(); | ||
| const act = (action || 'install').toLowerCase(); | ||
| const act = (action || 'install-skills').toLowerCase(); | ||
| const s = (skill || 'all').toLowerCase(); | ||
| if (act === 'install') await this.install(p); | ||
| else if (act === 'uninstall') await this.uninstall(p); | ||
| else console.error(`[Code-Graph] Unknown action: ${act}`); | ||
| if (act === 'install-skills') await this.install(p, s); | ||
| else if (act === 'uninstall-skills') await this.uninstall(p, s); | ||
| else console.error(`[Code-Graph] Unknown action: ${act}. Use install-skills or uninstall-skills.`); | ||
| } | ||
| async install(p) { | ||
| console.log(`[Code-Graph] Installing skill for ${p}...`); | ||
| async install(p, s) { | ||
| console.log(`[Code-Graph] Running install-skills (${s}) for ${p}...`); | ||
| try { | ||
| switch (p) { | ||
| case 'claude': await this.installClaude(); break; | ||
| case 'codex': await this.installCodex(); break; | ||
| case 'opencode': await this.installOpenCode(); break; | ||
| case 'cursor': await this.installCursor(); break; | ||
| case 'gemini': await this.installGemini(); break; | ||
| case 'aider': | ||
| case 'openclaw': | ||
| case 'droid': | ||
| case 'trae': | ||
| case 'trae-cn': | ||
| case 'hermes': | ||
| await this.installGenericAgent(p); | ||
| break; | ||
| case 'kiro': await this.installKiro(); break; | ||
| case 'antigravity': await this.installAntigravity(); break; | ||
| case 'copilot': await this.installCopilot(); break; | ||
| case 'vscode': await this.installVSCode(); break; | ||
| default: return console.error(`[Code-Graph] Unsupported platform: ${p}`); | ||
| } | ||
| console.log(`[Code-Graph] Successfully installed ${p} skill.`); | ||
| if (s === 'all' || s === 'projectmap') await this.installProjectMap(p); | ||
| if (s === 'all' || s === 'reflections') await this.installReflections(p); | ||
| console.log(`[Code-Graph] Successfully completed install-skills for ${p}.`); | ||
| } catch (err) { | ||
| console.error(`[Code-Graph] Installation failed for ${p}: ${err.message}`); | ||
| console.error(`[Code-Graph] install-skills failed for ${p}: ${err.message}`); | ||
| } | ||
| } | ||
| async uninstall(p) { | ||
| console.log(`[Code-Graph] Uninstalling skill for ${p}...`); | ||
| // Simplification: just remove the primary files | ||
| try { | ||
| switch (p) { | ||
| case 'claude': await this.removeFile('CLAUDE.md'); break; | ||
| case 'codex': await this.removeFile('AGENTS.md'); break; | ||
| case 'opencode': await this.removeFile('AGENTS.md'); break; | ||
| case 'cursor': await this.removeFile('.cursor/rules/code-graph.mdc'); break; | ||
| case 'gemini': await this.removeFile('GEMINI.md'); break; | ||
| case 'aider': | ||
| case 'openclaw': | ||
| case 'droid': | ||
| case 'trae': | ||
| case 'trae-cn': | ||
| case 'hermes': | ||
| await this.removeFile('AGENTS.md'); | ||
| break; | ||
| case 'kiro': await this.removeFile('.kiro/steering/code-graph.md'); break; | ||
| case 'antigravity': await this.removeFile('.agent/rules/code-graph.md'); break; | ||
| case 'copilot': await fsp.rm(path.join(this.home, '.copilot', 'skills', 'code-graph'), { recursive: true, force: true }); break; | ||
| case 'vscode': await this.removeFile('.github/copilot-instructions.md'); break; | ||
| } | ||
| console.log(`[Code-Graph] Successfully uninstalled ${p} skill.`); | ||
| } catch (err) { | ||
| console.error(`[Code-Graph] Uninstallation failed: ${err.message}`); | ||
| async installProjectMap(p) { | ||
| const section = `\n## ๐บ๏ธ Skill: ProjectMap\nBefore answering architecture questions, read \`${CONFIG.MAP_FILE}\` for god nodes and structural context. This ensures high-level awareness before searching raw files.\n`; | ||
| const skillContent = `# ProjectMap Skill\nUse \`${CONFIG.MAP_FILE}\` for project navigation and architectural awareness.\n`; | ||
| switch (p) { | ||
| case 'claude': | ||
| await this.appendToFile('CLAUDE.md', section); | ||
| await this.writeJson('.claude/settings.json', { hooks: { preToolUse: [{ tools: ['glob', 'grep'], message: `Skill(ProjectMap): Knowledge graph exists. Read ${CONFIG.MAP_FILE} before searching raw files.` }] } }); | ||
| break; | ||
| case 'cursor': | ||
| await this.writeFile('.cursor/rules/projectmap.mdc', `---\ndescription: Use knowledge graph for navigation.\nalwaysApply: true\n---\n# ProjectMap\nRead \`${CONFIG.MAP_FILE}\` to locate core logic and dependencies.\n`); | ||
| break; | ||
| case 'gemini': | ||
| await this.installGlobalSkill('gemini', 'projectmap', skillContent); | ||
| await this.appendToFile('GEMINI.md', section); | ||
| await this.writeJson('.gemini/settings.json', { hooks: { beforeTool: [{ tools: ['read_file'], message: `Skill(ProjectMap): Read ${CONFIG.MAP_FILE} for structural context.` }] } }); | ||
| break; | ||
| case 'copilot': | ||
| await this.installGlobalSkill('copilot', 'projectmap', skillContent); | ||
| break; | ||
| case 'vscode': | ||
| await this.appendToFile('.github/copilot-instructions.md', section); | ||
| break; | ||
| case 'roocode': | ||
| await this.appendToFile('.clinerules', section); | ||
| await this.appendToFile('.roomodes', section); | ||
| break; | ||
| default: | ||
| await this.appendToFile('AGENTS.md', section); | ||
| await this.installGlobalSkill(p, 'projectmap', skillContent); | ||
| } | ||
| } | ||
| async installClaude() { | ||
| const section = `\n## ๐บ๏ธ Code-Graph Integration\nBefore answering architecture questions, read \`${CONFIG.MAP_FILE}\` for god nodes and community structure. This ensures high-level context before searching raw files.\n`; | ||
| await this.appendToFile('CLAUDE.md', section); | ||
| await this.writeJson('.claude/settings.json', { hooks: { preToolUse: [{ tools: ['glob', 'grep'], message: `code-graph: Knowledge graph exists. Read ${CONFIG.MAP_FILE} before searching raw files.` }] } }); | ||
| } | ||
| async installReflections(p) { | ||
| const section = `\n## ๐ง Skill: Reflections\nFollow the reflection cycle: Read \`${CONFIG.REFLECTIONS_FILE}\` for past lessons and run \`code-graph reflect\` after any bug fix or failure.\n`; | ||
| const skillContent = `# Reflections Skill\nUse \`${CONFIG.REFLECTIONS_FILE}\` to persist and retrieve project-specific lessons and environment quirks.\n`; | ||
| async installCodex() { | ||
| const section = `\n## ๐บ๏ธ Code-Graph Navigation\nAlways check for \`${CONFIG.MAP_FILE}\` to understand project structure before using bash tools.\n`; | ||
| await this.appendToFile('AGENTS.md', section); | ||
| await this.writeJson('.codex/hooks.json', { hooks: { preToolUse: [{ tools: ['bash'], message: `code-graph: Knowledge graph exists. Read ${CONFIG.MAP_FILE} for architectural context.` }] } }); | ||
| switch (p) { | ||
| case 'claude': | ||
| await this.appendToFile('CLAUDE.md', section); | ||
| break; | ||
| case 'cursor': | ||
| await this.writeFile('.cursor/rules/reflections.mdc', `---\ndescription: Mandatory reflection cycle.\nalwaysApply: true\n---\n# Reflections\nFollow \`${CONFIG.RULES_FILE}\`. Update \`${CONFIG.REFLECTIONS_FILE}\` after every fix.\n`); | ||
| break; | ||
| case 'gemini': | ||
| await this.installGlobalSkill('gemini', 'reflections', skillContent); | ||
| await this.appendToFile('GEMINI.md', section); | ||
| await this.writeJson('.gemini/settings.json', { hooks: { beforeTool: [{ tools: ['run_shell_command'], message: `Skill(Reflections): Remember to run 'code-graph reflect' after identifying a fix or quirk.` }] } }); | ||
| break; | ||
| case 'copilot': | ||
| await this.installGlobalSkill('copilot', 'reflections', skillContent); | ||
| break; | ||
| case 'vscode': | ||
| await this.appendToFile('.github/copilot-instructions.md', section); | ||
| break; | ||
| case 'roocode': | ||
| const rules = `\n# Reflections Protocol\nStrictly follow the reflection cycle in \`${CONFIG.RULES_FILE}\`. Persist lessons to \`${CONFIG.REFLECTIONS_FILE}\`.\n`; | ||
| await this.appendToFile('.clinerules', rules); | ||
| await this.appendToFile('.roomodes', rules); | ||
| break; | ||
| default: | ||
| await this.appendToFile('AGENTS.md', section); | ||
| await this.installGlobalSkill(p, 'reflections', skillContent); | ||
| } | ||
| } | ||
| async installOpenCode() { | ||
| await this.appendToFile('AGENTS.md', `\n## ๐บ๏ธ Code-Graph\nRead \`${CONFIG.MAP_FILE}\` for high-level mapping.\n`); | ||
| const plugin = `export default { name: 'code-graph', beforeExecute: (tool) => { if (tool.name === 'bash') return "code-graph: Read ${CONFIG.MAP_FILE} for god nodes."; } };`; | ||
| await this.writeFile('.opencode/plugins/code-graph.js', plugin); | ||
| await this.writeJson('opencode.json', { plugins: ['./.opencode/plugins/code-graph.js'] }); | ||
| async installGlobalSkill(platform, skillName, content) { | ||
| const skillPath = path.join(this.home, `.${platform}`, 'skills', skillName, 'SKILL.md'); | ||
| try { | ||
| await fsp.mkdir(path.dirname(skillPath), { recursive: true }); | ||
| await fsp.writeFile(skillPath, content); | ||
| } catch (e) { | ||
| // Ignore errors for platforms that don't support global skills | ||
| } | ||
| } | ||
| async installCursor() { | ||
| const content = `---\ndescription: Always use knowledge graph for navigation.\nalwaysApply: true\n---\n# Code-Graph\n- Read \`${CONFIG.MAP_FILE}\` before searching.\n- Prioritize god nodes for architecture.\n- Adhere to \`${CONFIG.RULES_FILE}\`.\n`; | ||
| await this.writeFile('.cursor/rules/code-graph.mdc', content); | ||
| } | ||
| async uninstall(p, s) { | ||
| console.log(`[Code-Graph] Running uninstall-skills (${s}) for ${p}...`); | ||
| try { | ||
| if (s === 'all' || s === 'projectmap') { | ||
| await this.removeFile('.cursor/rules/projectmap.mdc'); | ||
| await fsp.rm(path.join(this.home, `.${p}`, 'skills', 'projectmap'), { recursive: true, force: true }); | ||
| } | ||
| if (s === 'all' || s === 'reflections') { | ||
| await this.removeFile('.cursor/rules/reflections.mdc'); | ||
| await fsp.rm(path.join(this.home, `.${p}`, 'skills', 'reflections'), { recursive: true, force: true }); | ||
| } | ||
| async installGemini() { | ||
| const skillPath = path.join(this.home, '.gemini', 'skills', 'code-graph', 'SKILL.md'); | ||
| await fsp.mkdir(path.dirname(skillPath), { recursive: true }); | ||
| await fsp.writeFile(skillPath, `# Code-Graph Skill\nUse \`${CONFIG.MAP_FILE}\` for navigation.\n`); | ||
| await this.appendToFile('GEMINI.md', `\n## ๐บ๏ธ Code-Graph\nRead \`${CONFIG.MAP_FILE}\` before file-read tools.\n`); | ||
| await this.writeJson('.gemini/settings.json', { hooks: { beforeTool: [{ tools: ['read_file'], message: `code-graph: Knowledge graph exists. Read ${CONFIG.MAP_FILE}.` }] } }); | ||
| if (s === 'all') { | ||
| const filesToRemove = [ | ||
| 'CLAUDE.md', 'GEMINI.md', 'AGENTS.md', '.clinerules', '.roomodes', | ||
| '.github/copilot-instructions.md' | ||
| ]; | ||
| for (const f of filesToRemove) await this.removeFile(f); | ||
| } | ||
| console.log(`[Code-Graph] Successfully completed uninstall-skills for ${p}.`); | ||
| } catch (err) { | ||
| console.error(`[Code-Graph] uninstall-skills failed for ${p}: ${err.message}`); | ||
| } | ||
| } | ||
| async installGenericAgent(p) { | ||
| await this.appendToFile('AGENTS.md', `\n## ๐บ๏ธ Code-Graph\nRead \`${CONFIG.MAP_FILE}\` for structural context.\n`); | ||
| const globalPath = path.join(this.home, `.${p}`, 'skills', 'code-graph', 'SKILL.md'); | ||
| await fsp.mkdir(path.dirname(globalPath), { recursive: true }); | ||
| await fsp.writeFile(globalPath, `# Code-Graph Skill for ${p}\n`); | ||
| } | ||
| async installKiro() { | ||
| await this.writeFile('.kiro/skills/code-graph/SKILL.md', `# Code-Graph Skill\n`); | ||
| await this.writeFile('.kiro/steering/code-graph.md', `inclusion: always\n# Code-Graph\nRead \`${CONFIG.MAP_FILE}\`.\n`); | ||
| } | ||
| async installAntigravity() { | ||
| await this.writeFile('.agent/rules/code-graph.md', `# Code-Graph Rules\nAlways read \`${CONFIG.MAP_FILE}\`.\n`); | ||
| await this.writeFile('.agent/workflows/code-graph.md', `# Code-Graph Workflow\nRegisters /code-graph\n`); | ||
| } | ||
| async installCopilot() { | ||
| const skillPath = path.join(this.home, '.copilot', 'skills', 'code-graph', 'SKILL.md'); | ||
| await fsp.mkdir(path.dirname(skillPath), { recursive: true }); | ||
| await fsp.writeFile(skillPath, `# Code-Graph Skill\nUse \`${CONFIG.MAP_FILE}\`.\n`); | ||
| } | ||
| async installVSCode() { | ||
| await this.appendToFile('.github/copilot-instructions.md', `\n## ๐บ๏ธ Code-Graph\nAlways read \`${CONFIG.MAP_FILE}\` for architectural context.\n`); | ||
| } | ||
| async appendToFile(filename, content) { | ||
@@ -493,3 +490,3 @@ const fullPath = path.join(this.cwd, filename); | ||
| try { | ||
| const platforms = ['claude', 'codex', 'opencode', 'cursor', 'gemini', 'aider', 'openclaw', 'droid', 'trae', 'trae-cn', 'hermes', 'kiro', 'antigravity', 'copilot', 'vscode']; | ||
| const platforms = ['claude', 'codex', 'opencode', 'cursor', 'gemini', 'aider', 'openclaw', 'droid', 'trae', 'trae-cn', 'hermes', 'kiro', 'antigravity', 'copilot', 'vscode', 'roocode', 'intellij']; | ||
@@ -511,3 +508,3 @@ switch (command || 'generate') { | ||
| case 'install-skills': | ||
| await new SkillManager(cwd).execute(args[0], args[1]); | ||
| await new SkillManager(cwd).execute(args[0], args[1], args[2]); | ||
| break; | ||
@@ -519,5 +516,5 @@ case 'watch': | ||
| if (platforms.includes(command?.toLowerCase())) { | ||
| await new SkillManager(cwd).execute(command, args[0]); | ||
| await new SkillManager(cwd).execute(command, args[0], args[1]); | ||
| } else { | ||
| console.log('Usage: code-graph [generate|init|reflect|install-hook|watch|install-skills <platform>]'); | ||
| console.log('Usage: code-graph [generate|init|reflect|install-hook|watch|install-skills <platform> [install|uninstall] [projectmap|reflections]]'); | ||
| } | ||
@@ -524,0 +521,0 @@ } |
@@ -15,2 +15,3 @@ # LLM_AGENT_PROJECT_LEARNINGS | ||
| - [TOOLING: 2026-04-15] Added reflect command to simplify LLM memory updates. | ||
| - [TOOLING: 2026-04-16] Upgraded to v3.0.0: Unified agent renaming (llm-agent-*) and added `install-skills` for automated platform integration (Claude, Cursor, Gemini, etc.). | ||
| - [TOOLING: 2026-04-16] Upgraded to v3.0.0: Unified agent renaming (llm-agent-*) and added `install-skills` for automated platform integration (Claude, Cursor, Gemini, etc.). | ||
| - [TOOLING: 2026-04-16] Upgraded to v3.1.0: Segregated skills into `projectmap` and `reflections`, enabling selective installation and standardizing on `install-skills` command. |
@@ -7,4 +7,4 @@ # CODE_GRAPH_MAP | ||
| - [CORE] index.js (โ8 โ1) [TODO: |FIXME|BUG|DEPRECATED):?\s*(.*)/i,, bug: s or complex regex pitfalls., bug: s or version deprecations., bug: ,"] | desc: !usrbinenv node | ||
| - syms: [CONFIG [=], CodeParser [--- Core Services --- Handles extraction of symbols, edges, and metadata from source code.], ProjectInitializer [Scaffolds the initial agent-agnostic rule and reflection files.], ProjectMapper [Manages the project mapping and file generation.], ReflectionManager [Manages project reflections and lessons learned.], SUPPORTED_EXTENSIONS [: [], SkillManager [Manages platform-specific skills and agent integrations.], add [(context ? `${display} [${context}]` : display)], appendToFile [('CLAUDE.md', section)], execute [(platform, action)], extract [(content)], init [(cwd)], install [|uninstall]')], installAntigravity [()], installClaude [()], installCodex [()], installCopilot [()], installCursor [()], installGemini [()], installGenericAgent [(p)], installGitHook [(cwd)], installKiro [()], installOpenCode [()], installVSCode [()], main [|app|server|cli)\./i.test(path.basename(relPath))], processFile [(fullPath, relPath)], removeFile [('CLAUDE.md')], uninstall []')], walk [(dir, ig)], writeFile [(path.join(this.cwd, CONFIG.MAP_FILE)], writeJson [('.claude/settings.json', { hooks: { preToolUse: [{ tools: ['glob', 'grep'], message: `code-graph: Knowledge graph exists. Read ${CONFIG.MAP_FILE} before searching raw files.` }] } })]] | ||
| - [CORE] index.js (โ7 โ1) [TODO: |FIXME|BUG|DEPRECATED):?\s*(.*)/i,, bug: s or complex regex pitfalls., bug: s or version deprecations., bug: fix or failure.\n`;, bug: ,"] | desc: !usrbinenv node | ||
| - syms: [CONFIG [=], CodeParser [--- Core Services --- Handles extraction of symbols, edges, and metadata from source code.], ProjectInitializer [Scaffolds the initial agent-agnostic rule and reflection files.], ProjectMapper [Manages the project mapping and file generation.], ReflectionManager [Manages project reflections and lessons learned.], SUPPORTED_EXTENSIONS [: [], SkillManager [Manages platform-specific skills and agent integrations.], add [(context ? `${display} [${context}]` : display)], appendToFile [('CLAUDE.md', section)], execute [(platform, action, skill)], extract [(content)], init [(cwd)], install [-skills <platform> [projectmap|reflections]')], installGitHook [(cwd)], installGlobalSkill [('gemini', 'projectmap', skillContent)], installProjectMap [(p)], installReflections [(p)], main [|app|server|cli)\./i.test(path.basename(relPath))], processFile [(fullPath, relPath)], removeFile [('.cursor/rules/projectmap.mdc')], uninstall [-skills') await this.uninstall(p, s)], walk [(dir, ig)], writeFile [(path.join(this.cwd, CONFIG.MAP_FILE)], writeJson [('.claude/settings.json', { hooks: { preToolUse: [{ tools: ['glob', 'grep'], message: `Skill(ProjectMap)]] | ||
| - [CORE] test/index.test.js (โ10 โ0) | desc: | ||
@@ -14,3 +14,2 @@ - syms: [] | ||
| ## GRAPH EDGES | ||
| [index.js] -> [imports] -> [bash] | ||
| [index.js] -> [imports] -> [chokidar] | ||
@@ -17,0 +16,0 @@ [index.js] -> [imports] -> [fs] |
+1
-1
| { | ||
| "name": "code-graph-llm", | ||
| "version": "3.0.1", | ||
| "version": "3.1.0", | ||
| "description": "Compact, language-agnostic codebase mapper for LLM token efficiency.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+47
-65
@@ -1,81 +0,61 @@ | ||
| # CODE-GRAPH (v3.0.1) | ||
| # CODE-GRAPH (v3.1.0) | ||
| A language-agnostic, ultra-compact codebase mapper and **agent memory system** designed specifically for LLM agents. It optimizes context and token usage while enabling agents to learn from their own mistakes across sessions. | ||
| ## ๐ New in v3.0: Major Version Upgrade | ||
| - **Project Initializer:** Automated bootstrapping with `code-graph init`. | ||
| - **Intelligent Reflection:** Deduplication and categorization in `llm-agent-project-learnings.md`. | ||
| - **Commit Advisories:** Soft-nudge git hooks to remind agents of missing reflections. | ||
| ## ๐ New in v3.1: Selective Skill Architecture | ||
| - **Segregated Skills:** Choose between `projectmap`, `reflections`, or both. | ||
| - **Enhanced Platform Support:** Standardized `install-skills` for 15+ platforms. | ||
| - **Granular Controls:** Selective installation/uninstallation supported. | ||
| - **Production-Ready Core:** Refactored Service-based architecture with full async support. | ||
| ## ๐ ๏ธ The Code-Graph Skillset | ||
| ## ๐ ๏ธ The Code-Graph Skills | ||
| Code-Graph transforms your codebase into an agent-friendly environment using five core skills: | ||
| Code-Graph provides two primary skills that can be installed independently or together (default). | ||
| ### 1. **Structural Mapping (`generate`)** | ||
| ### 1. **Structural Mapping (`projectmap`)** | ||
| * **What it does:** Scans your project for symbols (classes, functions, interfaces) and builds a dense dependency graph (`imports`, `requires`, `inheritance`). | ||
| * **How to use:** Run `code-graph generate`. This creates `llm-code-graph.md`, which agents use as their "Source of Truth" for navigation. | ||
| * **Agent Benefit:** Prevents "hallucinating" file paths and reduces token usage by giving the agent a compact map instead of raw file content. | ||
| * **Skill Goal:** High-level architectural awareness and navigation. | ||
| * **Agent Benefit:** Prevents "hallucinating" file paths and reduces token usage by giving the agent a compact map (`llm-code-graph.md`) instead of raw file content. | ||
| ### 2. **Memory Persistence (`reflect`)** | ||
| ### 2. **Memory Persistence (`reflections`)** | ||
| * **What it does:** Logs non-obvious fixes, environment quirks, and architectural lessons into `llm-agent-project-learnings.md`. | ||
| * **How to use:** `code-graph reflect <CATEGORY> "The lesson learned"`. | ||
| * **Agent Benefit:** Enables "Cross-Session Memory." If an agent fixes a Windows-specific bug in one session, the next agent reads the reflection and avoids the same pitfall. | ||
| * **Skill Goal:** Persistent project memory across sessions. | ||
| * **Agent Benefit:** Enables "Cross-Session Memory." If an agent fixes a bug in one session, the next agent reads the reflection and avoids the same pitfall. | ||
| ### 3. **Automated Integration (`install-skills`)** | ||
| * **What it does:** Bridges the gap between the graph and your LLM platform (Claude, Cursor, Gemini, etc.). | ||
| * **How to use:** `code-graph <platform> install`. | ||
| * **Agent Benefit:** Installs **Tool Hooks** and **Always-On Rules** that force the agent to consult the graph before using search tools. It effectively "bakes" the graph into the agent's internal loop. | ||
| --- | ||
| ### 4. **Self-Healing Sync (`install-hook`)** | ||
| * **What it does:** Installs a Git pre-commit hook to keep the map and memory in sync with code changes. | ||
| * **How to use:** `code-graph install-hook`. | ||
| * **Agent Benefit:** Ensures the agent is never working with an outdated map. It also nudges the agent to record a reflection if significant code changed but no lesson was logged. | ||
| ## ๐ Automated Agent Integration | ||
| ### 5. **Real-Time Context (`watch`)** | ||
| * **What it does:** Monitors your filesystem and rebuilds the graph instantly as you or the agent edits code. | ||
| * **How to use:** `code-graph watch`. | ||
| * **Agent Benefit:** Vital for long-running agent sessions where the project structure is rapidly evolving. | ||
| Configure your agent to use these skills by running the `install-skills` command. **Both skills are installed by default.** | ||
| --- | ||
| | Platform | Command | | ||
| | :--- | :--- | | ||
| | **Claude Code** | `code-graph install-skills claude` | | ||
| | **Cursor** | `code-graph install-skills cursor` | | ||
| | **Gemini CLI** | `code-graph install-skills gemini` | | ||
| | **Codex** | `code-graph install-skills codex` | | ||
| | **OpenCode** | `code-graph install-skills opencode` | | ||
| | **GitHub Copilot CLI** | `code-graph install-skills copilot` | | ||
| | **VS Code Copilot Chat** | `code-graph install-skills vscode` | | ||
| | **Aider / Trae / etc.** | `code-graph install-skills <platform>` | | ||
| ## ๐ง Workflow: The Reflection Cycle | ||
| ### Selective Installation | ||
| You can choose to install or uninstall specific skills: | ||
| To get the most out of Code-Graph, force your agent to follow this **Strict Protocol** (defined in `llm-agent-rules.md`): | ||
| ```bash | ||
| # Install only the project map | ||
| code-graph install-skills gemini projectmap | ||
| 1. **PRE-TASK (Read):** The agent MUST read `llm-agent-project-learnings.md` to check for existing pitfalls and `llm-code-graph.md` to locate the relevant "God Nodes" (core logic). | ||
| 2. **EXECUTION (Monitor):** During the task, the agent monitors for "Learned Moments"โfailures, unexpected OS behaviors, or complex regex fixes. | ||
| 3. **POST-TASK (Reflect):** If a lesson was learned, the agent MUST run `code-graph reflect`. | ||
| 4. **COMMIT (Sync):** Upon commit, the Git hook automatically runs `code-graph generate` to update the map for the next agent. | ||
| # Install only reflections | ||
| code-graph install-skills cursor reflections | ||
| --- | ||
| # Uninstall only reflections | ||
| code-graph uninstall-skills claude reflections | ||
| ``` | ||
| ## ๐ Automated Agent Integration | ||
| **Uninstall all skills** by using `uninstall-skills <platform>`. | ||
| After generating a graph, you can automatically configure your favorite LLM agent to use it by running the matching install command. | ||
| | Platform | Command | | ||
| | :--- | :--- | | ||
| | **Claude Code** | `code-graph claude install` | | ||
| | **Cursor** | `code-graph cursor install` | | ||
| | **Gemini CLI** | `code-graph gemini install` | | ||
| | **Codex** | `code-graph codex install` | | ||
| | **OpenCode** | `code-graph opencode install` | | ||
| | **GitHub Copilot CLI** | `code-graph copilot install` | | ||
| | **VS Code Copilot Chat** | `code-graph vscode install` | | ||
| | **Aider** | `code-graph aider install` | | ||
| | **OpenClaw** | `code-graph openclaw install` | | ||
| | **Factory Droid** | `code-graph droid install` | | ||
| | **Trae** | `code-graph trae install` | | ||
| | **Hermes** | `code-graph hermes install` | | ||
| | **Kiro IDE/CLI** | `code-graph kiro install` | | ||
| | **Google Antigravity** | `code-graph antigravity install` | | ||
| ## ๐ง Workflow: The Reflection Cycle | ||
| ### What this does: | ||
| - **Always-on Rules:** Writes project-level rule files (e.g., `CLAUDE.md`, `.cursor/rules/`, `AGENTS.md`) telling the agent to read `llm-code-graph.md` before answering architecture questions. | ||
| - **Pre-Tool Hooks:** For platforms that support it (Claude, Codex, Gemini, OpenCode), it installs hooks that fire before every file-search or bash call, injecting a reminder to check the graph first. This prevents the agent from grepping every file when a high-level map already exists. | ||
| - **Global Skills:** Copies the Code-Graph skill to the platform's global skill directory for persistence across projects. | ||
| **Uninstall** by replacing `install` with `uninstall` (e.g., `code-graph claude uninstall`). | ||
| ### Skill Installation Details | ||
@@ -85,12 +65,14 @@ | ||
| | :--- | :--- | :--- | | ||
| | **Claude Code** | Adds instructions to `CLAUDE.md` and installs a `preToolUse` hook for `glob` and `grep`. | `.claude/settings.json` | | ||
| | **Cursor** | Writes a global rule with `alwaysApply: true`. | `.cursor/rules/code-graph.mdc` | | ||
| | **Gemini CLI** | Copies skill globally and adds a `beforeTool` hook for `read_file`. | `~/.gemini/skills/code-graph/SKILL.md`, `.gemini/settings.json`, `GEMINI.md` | | ||
| | **Claude Code** | Adds instructions to `CLAUDE.md` and installs `preToolUse` hooks for `glob` and `grep`. | `.claude/settings.json` | | ||
| | **Cursor** | Writes global rules with `alwaysApply: true`. | `.cursor/rules/projectmap.mdc`, `.cursor/rules/reflections.mdc` | | ||
| | **Gemini CLI** | Copies skills globally and adds `beforeTool` hooks for `read_file` and `run_shell_command`. | `~/.gemini/skills/projectmap/SKILL.md`, `~/.gemini/skills/reflections/SKILL.md`, `GEMINI.md` | | ||
| | **Codex** | Updates `AGENTS.md` and installs a `preToolUse` hook for `bash`. | `.codex/hooks.json` | | ||
| | **OpenCode** | Registers a plugin that fires before `bash` tool calls. | `.opencode/plugins/code-graph.js`, `opencode.json`, `AGENTS.md` | | ||
| | **GitHub Copilot CLI** | Copies the Code-Graph skill to the global skill directory. | `~/.copilot/skills/code-graph/SKILL.md` | | ||
| | **GitHub Copilot CLI** | Copies skills globally for persistence. | `~/.copilot/skills/projectmap/SKILL.md`, `~/.copilot/skills/reflections/SKILL.md` | | ||
| | **VS Code Copilot** | Writes session-persistent instructions. | `.github/copilot-instructions.md` | | ||
| | **Aider / Trae / etc.** | Updates `AGENTS.md` and copies skill to global platform directory. | `~/.<platform>/skills/code-graph/SKILL.md`, `AGENTS.md` | | ||
| | **Kiro IDE/CLI** | Writes global skill and steering file for automatic inclusion. | `.kiro/skills/code-graph/SKILL.md`, `.kiro/steering/code-graph.md` | | ||
| | **Antigravity** | Writes always-on rules and registers a slash command workflow. | `.agent/rules/code-graph.md`, `.agent/workflows/code-graph.md` | | ||
| | **Roo Code** | Injects instructions into project rule files. | `.clinerules`, `.roomodes` | | ||
| | **IntelliJ / JetBrains** | Adds architectural context to a discoverable file. | `AGENTS.md` | | ||
| | **Aider / Trae / etc.** | Updates `AGENTS.md` and copies skills globally. | `~/.<platform>/skills/projectmap/SKILL.md`, `~/.<platform>/skills/reflections/SKILL.md`, `AGENTS.md` | | ||
| | **Kiro IDE/CLI** | Writes global skills and steering files. | `.kiro/skills/projectmap/SKILL.md`, `.kiro/skills/reflections/SKILL.md`, `.kiro/steering/code-graph.md` | | ||
| | **Antigravity** | Writes always-on rules and registers workflow commands. | `.agent/rules/projectmap.md`, `.agent/rules/reflections.md`, `.agent/workflows/code-graph.md` | | ||
@@ -97,0 +79,0 @@ ### How agents use it: |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
3
-25%43475
-5.17%158
-10.23%