feat: add code-tree knowledge graph for AI-assisted development and PR reviews#1517
Open
jsonmp-k8 wants to merge 2 commits intokagent-dev:mainfrom
Open
feat: add code-tree knowledge graph for AI-assisted development and PR reviews#1517jsonmp-k8 wants to merge 2 commits intokagent-dev:mainfrom
jsonmp-k8 wants to merge 2 commits intokagent-dev:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an in-repo, zero-dependency “code-tree” knowledge graph toolchain to support AI-assisted development and PR reviews, and restructures the prior monolithic agent guidance into a navigable set of focused guides and review checklists.
Changes:
- Added
tools/code-tree/graph builder + query CLI for symbol/dependency/call/impact/test-impact analysis, plus unit tests. - Replaced
CLAUDE.mdwith anAGENTS.mdentry point and added topic-specific agent docs underdocs/agents/. - Added GitHub PR review guides under
.github/review-guides/and Copilot reviewer instructions, plus gitignore updates for generated artifacts.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/code-tree/code_tree.py | Builds the repo knowledge graph artifacts (nodes/edges/tags/modules/summary). |
| tools/code-tree/query_graph.py | CLI + query layer for looking up symbols, deps, call graph, and impact/test-impact. |
| tools/code-tree/test_query_graph.py | Unit tests covering graph query behaviors and determinism. |
| docs/agents/architecture.md | New architecture-focused agent guide (system boundaries, dependency rules). |
| docs/agents/go-guide.md | New Go-focused agent guide (controllers/CLI/testing patterns). |
| docs/agents/python-guide.md | New Python-focused agent guide (ADK/runtime/testing/type alignment). |
| docs/agents/ui-guide.md | New UI-focused agent guide (Next.js structure, testing, key components). |
| docs/agents/testing-ci.md | Consolidated testing/CI guidance and local reproduction steps. |
| docs/agents/code-tree.md | Usage guide for code-tree artifacts and query workflows. |
| AGENTS.md | New top-level entry point indexing the sub-guides and commands/policies. |
| CLAUDE.md | Redirects to AGENTS.md (replacing the previous monolithic content). |
| .github/copilot-instructions.md | Defines Copilot PR review strategy including code-tree usage. |
| .github/review-guides/architecture-context.md | Review checklist for multi-subsystem / CRD / controller changes. |
| .github/review-guides/impact-analysis.md | Review checklist emphasizing blast radius and hub-file scrutiny. |
| .github/review-guides/language-checklists.md | Language-specific review checklists (Go/Python/TS/YAML). |
| .github/review-guides/security-review.md | Security-oriented PR review checklist. |
| .github/review-guides/test-quality.md | Test quality/coverage expectations for PR reviews. |
| .gitignore | Ignores local knowledge-graph artifacts and other generated files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9d5f295 to
87b3264
Compare
…R reviews Restructure the monolithic 214-line CLAUDE.md into a slim entry point that redirects to a new AGENTS.md, with detailed content moved to topic-specific guides under docs/agents/. Code-tree tooling (tools/code-tree/): - code_tree.py: zero-dependency knowledge graph builder that parses Go, Python, TypeScript, Java, Rust via Python AST, tree-sitter, or regex fallback. Extracts symbols, imports, calls, inheritance, and test mappings. Outputs graph.json, tags.json, modules.json, and summary.md. Supports incremental rebuilds via file hashing. - query_graph.py: CLI query interface for symbol lookup, dependency and reverse-dependency queries, call graph traversal (callers, callees, call chains), inheritance hierarchy, BFS-based impact analysis, test impact analysis, and code chunk extraction. - test_query_graph.py: 31 unit tests covering impact BFS depth limiting, edge-type filtering, output determinism, symbol lookup, dependency queries, call graph, hierarchy, search, and stats. Agent guides (docs/agents/): - architecture.md: end-to-end flow, subsystem boundaries, dependency rules, CRD types, controller patterns, protocols, module structure - go-guide.md: controllers, API, ADK, CLI, coding standards, error handling, concurrency rules, CRD field workflow, linting - python-guide.md: ADK executor flow, UV workspace, type alignment with Go, LLM provider integration, framework support - ui-guide.md: Next.js 16 routing, components, technologies, Shadcn/ui primitives, hub components, development patterns - testing-ci.md: test suites, CI workflow matrix, E2E database matrix, coverage requirements, local CI reproduction, common failure patterns - code-tree.md: development workflow, query examples, entry points, hub files, module dependencies, type hierarchies PR review guides (.github/review-guides/): - architecture-context.md: subsystem boundaries, dependency directions, controller patterns, CRD type alignment, backward compatibility, cardinality changes - impact-analysis.md: PR size flags, hub files, cross-boundary changes, CRD change checklist, generated files policy - language-checklists.md: Go (error handling, concurrency, code quality, CRD-specific), Python (type hints, async, ruff), TypeScript (strict mode, Radix UI, Jest), YAML (Helm, CI) - security-review.md: container SecurityContext, RBAC manifests, credentials/secrets, network security, CI workflow security - test-quality.md: coverage requirements, proportional coverage table, type alignment coverage, test organization, fixture integrity, resource management Entry points: - AGENTS.md: main agent guide with kagent-dev skill reference, language guidelines, API versioning, code reuse/testing/commit policies, best practices, essential commands, reference file index, task routing table, validation checklist, and both code-tree options (in-repo tools + code-review-graph MCP) - .github/copilot-instructions.md: tier 1 PR reviewer with batch-based file review strategy, context pruning, code-tree impact analysis integration, security scan, review guide index - CLAUDE.md: slimmed to ./AGENTS.md redirect - .gitignore: added docs/code-tree/ and .code-review-graph/ Verified against codebase: 21 claims audited, all file paths, entry points, CI matrix values, and tool versions confirmed accurate. Code-tree builder tested on kagent repo: indexed 4,123 nodes and 12,435 edges across 557 files in 5 languages. All 31 unit tests pass. Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
87b3264 to
93a0764
Compare
Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
point + 6 topic-specific guides under
docs/agents/, 5 PR reviewguides under
.github/review-guides/, and Copilot reviewerinstructions
(
tools/code-tree/) for symbol lookup, dependency analysis, impactanalysis, call graph traversal, and test impact mapping
quick references stay in AGENTS.md; detailed content (architecture,
error handling, test patterns) moved to sub-guides
Why this matters
For contributors: The monolithic CLAUDE.md forced every agent/developer to load 214 lines of context regardless of what they were working on. Now a contributor adding a CRD field loads only the Go guide (~184 lines), while someone debugging CI loads only the testing guide (~178 lines). Task routing in AGENTS.md tells you exactly which guide to read.
For PR reviewers: Copilot and human reviewers previously had no structured review process. The new
.github/copilot-instructions.mddefines a batch-based file review strategy with explicit ordering (CRD types → controllers → ADK → UI → Helm → tests), context pruning between batches, and code-tree impact queries to catch untested blast radius. The 5 review guides under.github/review-guides/provide targeted checklists for architecture, impact, language-specific patterns, security, and test quality — loaded only when relevant.For blast-radius analysis: Before this PR, understanding "what breaks if I change
agent_types.go?" required manually tracing imports across Go, Python, and TypeScript. The code-tree tools automate this:For onboarding: New contributors get a clear entry point (AGENTS.md) with a task routing table that maps common tasks to the right guide and section. The code-tree
--searchand--symbolcommands help navigate unfamiliar code without reading every file.Zero runtime cost: The code-tree tools are optional developer tooling with no dependencies. They don't affect CI, builds, or production code. Generated artifacts (
docs/code-tree/) are git-ignored and rebuilt per session.What's new
Code-tree tools (
tools/code-tree/)code_tree.pyquery_graph.pytest_query_graph.pyAgent guides (
docs/agents/)architecture.mdgo-guide.mdpython-guide.mdui-guide.mdtesting-ci.mdcode-tree.mdPR review guides (
.github/review-guides/)architecture-context.mdimpact-analysis.mdlanguage-checklists.mdsecurity-review.mdtest-quality.mdEntry points
.github/copilot-instructions.md(81 lines): Batch-based PR review strategy with code-tree integration./AGENTS.mdredirectVerification
docs/code-tree/artifacts git-ignored (rebuilt per session)Test plan
python3.12 tools/code-tree/code_tree.py --repo-root . --incremental -qbuilds graph successfullypython3.12 tools/code-tree/query_graph.py --statsreports correct node/edge countspython3.12 tools/code-tree/query_graph.py --symbol Reconcilefinds all 5 controllerspython3.12 tools/code-tree/query_graph.py --impact go/api/v1alpha2/agent_types.go --depth 2shows correct blast radiuspython3.12 -m pytest tools/code-tree/test_query_graph.py -v— 31/31 pass