Loading...
Loading...
Manages persistent Knowledge Graph for specifications. Caches agent discoveries and codebase analysis to remember findings across sessions. Validates task dependencies, stores patterns, components, and APIs to avoid redundant exploration. Use when: you need to cache analysis results, remember findings, reuse previous discoveries, look up what we found, spec-to-tasks needs to persist codebase analysis, task-implementation needs to validate contracts, or any command needs to query existing patterns/components/APIs.
npx skill4agent add giuseppe-trisciuoglio/developer-kit knowledge-graphdocs/specs/[ID-feature]/knowledge-graph.jsonRead file_path="docs/specs/001/knowledge-graph.json"componentspatternsapisintegration-pointsallRead file_path="docs/specs/001/knowledge-graph.json"# 1. Read existing
Read file_path="docs/specs/001/knowledge-graph.json"
# 2. Deep-merge updates (arrays append by ID, objects preserve existing)
# 3. Update timestamp
Write file_path="docs/specs/001/knowledge-graph.json" content="<merged JSON>"idmetadata.updated_at{
"metadata": {
"spec_id": "001-hotel-search",
"created_at": "2026-03-14T10:30:00Z",
"updated_at": "2026-03-23T10:00:00Z",
"version": "1.0.0"
},
"patterns": {
"architectural": [
{
"id": "pat-001",
"name": "Repository Pattern",
"convention": "Extend JpaRepository<Entity, ID>",
"files": ["src/main/java/**/repository/*Repository.java"]
}
]
},
"components": {
"services": [
{
"id": "comp-svc-001",
"name": "HotelService",
"location": "src/main/java/com/example/hotel/service/HotelService.java",
"type": "service",
"methods": [{"name": "searchHotels", "returns": "List<HotelDTO>"}]
}
]
}
}# 1. Read KG
Read file_path="docs/specs/001/knowledge-graph.json"
# 2. Check KG contains required IDs
# 3. Verify actual files exist
Grep pattern="src/**/HotelRepository.java"# 1. Read KG and task expectations
Read file_path="docs/specs/001/knowledge-graph.json"
Glob pattern="src/**/ExpectedFile.java"
Grep pattern="class ExpectedClass|interface ExpectedInterface"
# 2. Match expectations against KG.provides
# 3. Report satisfied/unsatisfied contracts# 1. Find implementation files
Glob pattern="src/**/*.java"
# 2. Extract symbols
Grep pattern="^(public|protected)? (class|interface|enum) " output_mode="content"
# 3. Classify by directory: /entity/ → entity, /service/ → service, /repository/ → repository
# 4. Update KG.provides with {task_id, file, symbols, type, implemented_at}# 1. Find all KG files
Glob pattern="docs/specs/*/knowledge-graph.json"
# 2. Read each, extract patterns.architectural and patterns.conventions
# 3. Write merged .global-knowledge-graph.json
Write file_path="docs/specs/.global-knowledge-graph.json" content="<aggregated>"knowledge-graph.json
├── metadata (spec_id, created_at, updated_at, version, analysis_sources)
├── codebase_context (project_structure, technology_stack)
├── patterns (architectural[], conventions[])
├── components (controllers[], services[], repositories[], entities[], dtos[])
├── provides[] ({ task_id, file, symbols[], type, implemented_at })
├── apis (internal[], external[])
└── integration_points[]references/schema.md| Scenario | Handling |
|---|---|
| File not found | Return empty KG; creates on first update |
| Invalid JSON | Raise error; offer to recreate from analysis |
| Merge conflicts | Deep-merge preserves existing, adds new with timestamps |
| Write failure | Log error; continue without caching (non-blocking) |
Readdocs/specs/[ID]/knowledge-graph.jsonWrite30 days: Stale, re-analysis recommended
# Step 1: Check existing KG
Read file_path="docs/specs/001/knowledge-graph.json"
# Step 2: Analyze codebase (agent task)
Glob pattern="src/main/java/**/*.java"
Grep pattern="public (class|interface) " output_mode="content"
# Step 3: Build update with discoveries
Write file_path="docs/specs/001/knowledge-graph.json" content="{
\"metadata\": {
\"spec_id\": \"001-hotel-search\",
\"created_at\": \"2026-03-14T10:30:00Z\",
\"updated_at\": \"2026-03-23T10:00:00Z\",
\"version\": \"1.0.0\",
\"analysis_sources\": [{\"agent\": \"general-code-explorer\", \"timestamp\": \"2026-03-23T10:00:00Z\"}]
},
\"patterns\": {
\"architectural\": [{
\"id\": \"pat-001\",
\"name\": \"Repository Pattern\",
\"convention\": \"Extend JpaRepository<Entity, ID>\"
}]
},
\"components\": {
\"services\": [{
\"id\": \"comp-svc-001\",
\"name\": \"HotelService\",
\"location\": \"src/main/java/com/example/hotel/service/HotelService.java\",
\"type\": \"service\"
}],
\"repositories\": [{
\"id\": \"comp-repo-001\",
\"name\": \"HotelRepository\",
\"location\": \"src/main/java/com/example/hotel/repository/HotelRepository.java\",
\"type\": \"repository\"
}]
}
}"# Read KG and task requirements
Read file_path="docs/specs/001/knowledge-graph.json"
# Verify components exist in codebase
Grep pattern="src/main/java/com/example/hotel/repository/HotelRepository.java"
Grep pattern="src/main/java/com/example/hotel/service/HotelService.java"
# Report validation result
# If all found: "All dependencies satisfied, proceed with implementation"
# If missing: "Warning: HotelService not found. Create it first?"# Load KG to get cached context
Read file_path="docs/specs/001/knowledge-graph.json"
# Present summary to user:
# "Found cached analysis (2 days old):
# - Patterns: Repository Pattern, Service Layer
# - Components: HotelService, HotelController
# - Conventions: naming with *Controller/*Service/*Repository
# Use cached context for task generation?"references/query-examples.mdknowledge-graph.jsondocs/specs/[ID]/aggregatereferences/schema.mdreferences/query-examples.mdreferences/integration-patterns.md