ProjectGraphAgent is a Jsonnet-driven project control system designed for AI agents (Cursor, Gemini, Claude, Roo, Kilocode). It provides a comprehensive framework for documenting project architecture, tracking drift between declared and observed states, generating visual diagrams, automating grouped commits, and producing agent-friendly artifacts.
- Declared vs Observed Graph: Jsonnet "declared" model + language adapters "observed" model → automatic drift detection
- Path Indexing System: Fast file path lookups with multiple search strategies (by path, directory, file type, name patterns)
- Agent-Friendly Outputs: Compiled graph JSON, drift reports, Mermaid diagrams, plans markdown, snapshots and events
- Automation: Grouped commits, AI command synchronization, CI workflow integration
- Multi-Language Support: TypeScript/JavaScript and Python adapters (extensible)
-
project_graph.jsonnet
- The root file that assembles the entire graph, including project metadata, entities, relations, policies, and commit grouping rules.
-
graph_parts/
entities.jsonnet
: Defines all the core components, files, and resources of the project.relations.jsonnet
: Defines the relationships between the entities (e.g., which component uses which, IPC channels).templates.jsonnet
: Reusable schemas for different types of entities.policies.jsonnet
: Defines architectural rules and conventions for the project.meta.jsonnet
: Contains metadata about the project graph itself.ai_commands.jsonnet
: Defines mappings for AI assistant commands.
-
scripts/
ai_committer.mjs
: The script that automates the creation of categorized Git commits based on thecommitGroups
defined inproject_graph.jsonnet
.clean_project.mjs
: A script related to the project graph.graph_generator.mjs
: The script that generates this README and compares the graph to the live project files and reports any drift.graph_validator.mjs
: (Future) A script to validate the graph against the policies defined inpolicies.jsonnet
.publish_workflow.mjs
: A script related to the project graph.sync_ai_commands.mjs
: The script that synchronizes AI command definitions across various AI assistant rule files.sync_to_standalone.mjs
: A script related to the project graph.
ProjectGraphAgent includes a powerful path indexing system that enables fast lookups of files and entities by various criteria:
findByPath(path)
: Find entity by exact file pathfindByDirectory(dir)
: Find all files in a directoryfindByFileType(ext)
: Find all files with specific extensionfindByFileName(name)
: Find files with specific namefindByPattern(pattern)
: Search files containing a patternpathExists(path)
: Check if file exists in indexgetIndexStats()
: Get statistics about the index
- Path Index: Direct path → entity mapping
- Directory Index: Directory → list of entities
- File Type Index: Extension → list of entities
- File Name Index: Name → list of entities
// Find a specific configuration file local config = graph.templates.PathSearch.findByPath("package.json"); // Get all TypeScript files local tsFiles = graph.templates.PathSearch.findByFileType("ts"); // Find all files in src directory local srcFiles = graph.templates.PathSearch.findByDirectory("src"); // Check if README exists local hasReadme = graph.templates.PathSearch.pathExists("README.md");
This indexing system is particularly valuable for AI agents, enabling efficient navigation and analysis of large codebases.
-
Copy the system into your project:
cp -r ProjectGraphAgent/ your-project/
-
Customize configuration in
ProjectGraphAgent/project_graph.jsonnet
:{ projectName: 'your-project-name', projectUrl: 'https://github.com/your-username/your-project', description: 'Your project description here.', // ... rest of configuration }
-
Install dependencies:
# Install Jsonnet # Linux: apt install jsonnet # macOS: brew install jsonnet # Windows: winget install jsonnet
-
Run the generator:
node ProjectGraphAgent/scripts/graph_generator.mjs --keep-compiled
ProjectGraphAgent/.cache/graph.json
- Compiled graph with observed data and driftmemory-bank/diagrams/graph.mmd
- Mermaid diagram of relationsmemory-bank/drift.md
- Drift report (declared vs observed)memory-bank/plans/
- Domain-specific plan markdown files
Add to .github/workflows/*.yml
:
- name: Generate Graph
run: node ProjectGraphAgent/scripts/graph_generator.mjs --keep-compiled
- name: Validate Graph
run: node ProjectGraphAgent/scripts/graph_validator.mjs
To streamline interaction with AI assistants, you can configure them to trigger npm run graph:audit
and npm run graph:commit
using simpler, more conversational commands. Below are examples of how to set this up for various AI assistants, based on the definitions in graph_parts/ai_commands.jsonnet
.
Important: The exact syntax and capabilities may vary between AI assistants. Refer to your specific AI's documentation for precise configuration details.
## Graph Audit
- **Trigger Phrase:** "graph-audit"
- **Action:** Run `node project_graph/scripts/graph_generator.mjs`
- **Description:** Executes the project graph audit script to check for discrepancies between the graph definition and actual project files.
## Graph Commit
- **Trigger Phrase:** "graph-commit"
- **Action:** Run `npm run graph:commit`
- **Description:** Executes the AI Committer script to automatically categorize and commit staged changes based on project_graph.jsonnet rules.
## Sync Ai Commands
- **Trigger Phrase:** "sync-ai-commands"
- **Action:** Run `npm run sync:ai-commands`
- **Description:** Synchronizes AI command definitions across various AI assistant rule files.
- Trigger Phrase: "graph-audit"
- Action: Run
node project_graph/scripts/graph_generator.mjs
- Description: Executes the project graph audit script to check for discrepancies between the graph definition and actual project files.
- Trigger Phrase: "graph-commit"
- Action: Run
npm run graph:commit
- Description: Executes the AI Committer script to automatically categorize and commit staged changes based on project_graph.jsonnet rules.
- Trigger Phrase: "sync-ai-commands"
- Action: Run
npm run sync:ai-commands
- Description: Synchronizes AI command definitions across various AI assistant rule files.
### For Gemini Code Assistant (`.gemini/GEMINI.md`)
```markdown
- **Command Aliases:** When the user requests "graph-audit" or "audit graph" or "check graph" or "run audit", execute `node project_graph/scripts/graph_generator.mjs`.
- **Command Aliases:** When the user requests "graph-commit" or "commit graph" or "auto commit" or "run committer", execute `npm run graph:commit`.
- **Command Aliases:** When the user requests "sync-ai-commands" or "sync ai" or "update ai rules" or "sync assistant commands", execute `npm run sync:ai-commands`.
## Graph Audit
- **Trigger Phrase:** "graph-audit"
- **Action:** Run `node project_graph/scripts/graph_generator.mjs`
- **Description:** Executes the project graph audit script to check for discrepancies between the graph definition and actual project files.
## Graph Commit
- **Trigger Phrase:** "graph-commit"
- **Action:** Run `npm run graph:commit`
- **Description:** Executes the AI Committer script to automatically categorize and commit staged changes based on project_graph.jsonnet rules.
## Sync Ai Commands
- **Trigger Phrase:** "sync-ai-commands"
- **Action:** Run `npm run sync:ai-commands`
- **Description:** Synchronizes AI command definitions across various AI assistant rule files.
- observedNotDeclared: 0
- declaredNotObserved: 17
This ProjectGraphAgent is designed to work in two modes:
-
Parent Project Mode (
/home/igor/Документы/Проекты/agent_plugins_platform/ProjectGraphAgent/
)- Contains project-specific data (Agent Plugins Platform entities, settings)
- Used for active development and testing
- Manages the parent project (Agent Plugins Platform)
-
Standalone Mode (
/home/igor/Документы/Проекты/ProjectGraphAgent/
)- Clean, universal template
- Ready for publication on GitHub
- Used for distribution and reuse
-
Develop in Parent Project:
# Work in agent_plugins_platform/ProjectGraphAgent/ # Make changes to scripts, graph_parts, adapters, etc.
-
Sync to Standalone:
# From agent_plugins_platform/ProjectGraphAgent/ npm run sync
-
Clean Standalone for Publication:
cd /home/igor/Документы/Проекты/ProjectGraphAgent npm run clean
-
Publish to GitHub:
cd /home/igor/Документы/Проекты/ProjectGraphAgent git add -A git commit -m "feat: new feature" git push origin main
For convenience, use the automated publish workflow:
# From agent_plugins_platform/ProjectGraphAgent/
npm run publish
This will:
- Sync changes to standalone directory
- Clean standalone from parent project data
- Prepare Git commit
- Show push instructions
To auto-push to GitHub:
npm run publish -- --push
Synced Files (from parent to standalone):
scripts/
- All automation scriptsgraph_parts/
- Templates, policies, schemas (excluding entities)adapters/
- Language adaptersREADME.md
,README_PUBLISH.md
,CHANGELOG.md
,LLM_GUIDELINES.md
LICENSE
,package.json
,.gitignore
Excluded Files (parent-specific):
project_graph.jsonnet
- Contains parent project datagraph_parts/entities.jsonnet
- Contains parent project entitiessettings.json
- Parent project settings.cache/
,memory-bank/
- Generated artifacts
When you copy ProjectGraphAgent from a parent project, you can clean it to remove parent-specific data:
# Clean from parent project data
npm run clean
# Or directly
node scripts/clean_project.mjs
This will:
- Reset
project_graph.jsonnet
to template values - Clean
graph_parts/entities.jsonnet
to universal examples - Remove
.cache/
,memory-bank/
,settings.json
- Update
package.json
with ProjectGraphAgent metadata - Create appropriate
.gitignore
-
Copy to separate directory:
mkdir -p /home/igor/Документы/Проекты/ProjectGraphAgent cp -r ProjectGraphAgent/* /home/igor/Документы/Проекты/ProjectGraphAgent/
-
Run cleanup:
cd /home/igor/Документы/Проекты/ProjectGraphAgent npm run clean
-
Publish to GitHub:
git init git remote add origin https://github.com/LebedevIV/ProjectGraphAgent.git git add -A git commit -m "Initial commit: ProjectGraphAgent v0.1.0-alpha" git push -u origin main
See CLEANUP_INSTRUCTIONS.md
for detailed instructions.
✅ v1.0.0 - PRODUCTION READY! 🎉
Features:
- Intelligent indexing system with 4 index types
- Full AI agent integration via PathSearch API
- Automated export and publish processes
- Production-grade error handling and logging
- Extensive documentation and automated workflows
Compatibility:
- Node.js ≥18.0.0 | Jsonnet | ESM modules
- TypeScript & Python adapters
- Declarative Jsonnet configuration
- CI/CD ready
MIT License
See CONTRIBUTING.md
for development guidelines and contribution process.