How Egonex-AI's Multi-Agent Pipeline Orchestrates Knowledge Graph Construction
Egonex-AI's Understand-Anything tool orchestrates knowledge graph construction through a deterministic sequence of specialized agents—project-scanner, file-analyzer, domain-analyzer, architecture-analyzer, and graph-reviewer—that feed JSON artifacts into a central GraphBuilder class to produce a validated, layered knowledge graph.
The Egonex-AI/Understand-Anything repository implements a modular multi-agent pipeline that transforms raw codebase files into structured knowledge graphs. Triggered by the understand skill when users invoke /understand --full, the pipeline coordinates discrete agents through the skill definition in understand-anything-plugin/skills/understand/SKILL.md. Each agent handles a specific extraction phase, storing intermediate results under .understand-anything/ before the GraphBuilder assembles the final graph.
The Agent Orchestration Flow
The pipeline executes six specialized agents in a strict sequence, with each agent consuming the outputs of its predecessors and producing typed JSON artifacts for the next stage.
Project Scanning with project-scanner
The project-scanner agent (understand-anything-plugin/agents/project-scanner.md) initiates the pipeline by walking the target repository and cataloging every file path. It categorizes files by type—code, config, document, service, or pipeline—and generates scan-inventory.json containing the complete inventory of file-level nodes.
{
"files": [
{"path":"src/main.ts","type":"file"},
{"path":".github/workflows/ci.yml","type":"pipeline"}
]
}
File Structure Extraction with file-analyzer
The file-analyzer agent (understand-anything-plugin/agents/file-analyzer.md) processes each entry from the inventory. It invokes language-specific Tree-Sitter parsers to extract functions, classes, definitions, services, endpoints, and pipeline steps. The agent outputs per-file JSON blobs to file-analysis/<path>.json alongside a centralized meta.json containing summaries, tags, and complexity metrics.
The skill calls the extract-structure.mjs script, which instantiates the GraphBuilder and feeds structural analysis data into the builder's intake methods.
Domain Concept Identification with domain-analyzer
The domain-analyzer agent (understand-anything-plugin/agents/domain-analyzer.md) identifies business concepts and domain models that transcend individual source files. It produces domain-nodes.json, a structured list of domain and flow nodes that will later attach to architectural layers, ensuring the knowledge graph captures semantic meaning beyond code structure.
Architecture Synthesis with architecture-analyzer
The architecture-analyzer agent (understand-anything-plugin/agents/architecture-analyzer.md) groups file-level nodes into logical layers based on node type heuristics:
- CI/CD Layer: Created when
pipelinenodes exist in the inventory - Infrastructure Layer: Contains
serviceandresourcenodes - Application Layer: Houses remaining
file,class, andfunctionnodes
This agent outputs layers.json, mapping each layer name to its constituent nodeIds.
Graph Assembly with GraphBuilder
The GraphBuilder class (understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts) serves as the central aggregation point for all pipeline data:
export class GraphBuilder {
addFile(filePath:string, meta:FileMeta): void { … }
addFileWithAnalysis(filePath:string, analysis:StructuralAnalysis, meta:FileAnalysisMeta): void { … }
addNonCodeFileWithAnalysis(filePath:string, meta:NonCodeFileAnalysisMeta): void { … }
build(): KnowledgeGraph { … }
}
The builder creates file nodes, function/class child nodes, and non-code child nodes (such as pipeline and resource types). It establishes relationships through contains, imports, and calls edges based on the analysis data. When the final agent completes, GraphBuilder.build() returns the complete KnowledgeGraph object, serialized to .understand-anything/knowledge-graph.json.
Validation with graph-reviewer
The graph-reviewer agent (understand-anything-plugin/agents/graph-reviewer.md) performs QA checks on the assembled graph before final delivery. It verifies that every file-level node appears in exactly one layer, that pipeline nodes maintain at least one triggers edge, and that no duplicate node IDs exist. If validation fails, the pipeline aborts and surfaces a diagnostic report; otherwise, the graph is marked approved and passed to the dashboard UI.
Running the Full Pipeline
Execute the complete multi-agent pipeline using the skill entry script:
# Install dependencies (pnpm workspace)
pnpm install
# Build core and skill packages
pnpm --filter @understand-anything/core build
pnpm --filter @understand-anything/skill build
# Execute the full pipeline
understand-anything-plugin/skills/understand/scan-project.mjs \
--project <path> \
--full
The --full flag triggers the entire agent sequence, storing intermediate JSON artifacts under .understand-anything/ and outputting the final validated graph.
Summary
- The multi-agent pipeline operates as a deterministic chain defined in the
understandskill, processing codebases through six specialized agents. - project-scanner inventories files, file-analyzer extracts structure, domain-analyzer identifies business concepts, and architecture-analyzer organizes nodes into layers.
- The GraphBuilder class aggregates all agent outputs to construct typed nodes and edges (
contains,imports,calls). - graph-reviewer enforces integrity constraints before finalizing the knowledge graph to
.understand-anything/knowledge-graph.json. - Intermediate results are stored as JSON artifacts, making the pipeline auditable and repeatable.
Frequently Asked Questions
What is the exact execution order of agents in the pipeline?
The pipeline executes in this strict sequence: first project-scanner creates the inventory, then file-analyzer extracts code structure, followed by domain-analyzer for business concepts, then architecture-analyzer for layer grouping, then graph-builder assembles the graph, and finally graph-reviewer validates the output. This order ensures each agent has access to the previous stage's JSON artifacts.
How does the GraphBuilder establish relationships between nodes?
The GraphBuilder creates edges based on analysis metadata fed by the file-analyzer. It generates contains edges for parent-child relationships (files containing functions or classes), imports edges for dependency relationships, and calls edges for invocation relationships. These edges are established through the addFileWithAnalysis and addNonCodeFileWithAnalysis methods before build() finalizes the graph.
Where does the pipeline store intermediate results during execution?
All agents write JSON artifacts to the .understand-anything/ directory within the target project. Specific files include scan-inventory.json from the scanner, file-analysis/<path>.json from the analyzer, domain-nodes.json from the domain agent, layers.json from the architecture agent, and knowledge-graph.json from the final builder.
What validation rules must the knowledge graph pass?
The graph-reviewer enforces three critical constraints: every file-level node must belong to exactly one architectural layer, every pipeline node must have at least one triggers edge connecting it to other nodes, and the entire graph must contain zero duplicate node IDs. Violations trigger pipeline abortions with diagnostic reports pointing to specific integrity failures.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →