building-java-knowledge-graph

bởi microsoft

Phân tích các dự án JVM (Java/Kotlin/Scala/Groovy) và tạo đồ thị tri thức với phân tích cú pháp tree-sitter. Yêu cầu Python 3 trên máy chủ và một dự án JVM với…

npx skills add https://github.com/microsoft/github-copilot-modernization --skill building-java-knowledge-graph

Prerequisites

Step 1 — Verify JVM project:

find "$PROJECT_ROOT" -maxdepth 5 -type f \( -name "*.java" -o -name "*.kt" -o -name "*.scala" -o -name "*.groovy" \) | head -1

If no JVM files found: skip this skill. Set knowledge_graph_dir to null in setup_artifacts. Non-fatal — downstream agents fall back to direct source analysis.

Step 2 — Verify Python:

python3 --version 2>/dev/null || python --version 2>/dev/null

If unavailable: skip this skill with same fallback as above.

Quick Start

# First-time setup (~1 minute)
pip3 install --user 'tree-sitter<0.21'
python3 scripts/install_grammars.py

# Optional: SVG generation
brew install graphviz  # macOS

# Analyze project
python3 scripts/build_knowledge_graph.py /path/to/project output-dir

⚠️ DESTRUCTIVE OUTPUT: The script wipes ALL files in output-dir before writing. NEVER point it at a shared directory like {{BASE_PATH}}/ or {{BASE_PATH}}/artifacts/. Use a dedicated subdirectory:

# ✅ SAFE — dedicated subdirectory
python3 scripts/build_knowledge_graph.py /path/to/project {{BASE_PATH}}/artifacts/kg_output

# ❌ DANGER — will delete constitution.md, board.md, other artifacts!
python3 scripts/build_knowledge_graph.py /path/to/project {{BASE_PATH}}

After the script finishes, copy knowledge-graph.json to {{BASE_PATH}}/ for other agents to consume.

What It Detects

  • Build systems: Maven (pom.xml), Gradle (build.gradle*), Ant (build.xml), Ivy (ivy.xml)
  • Languages: Java, Kotlin, Scala, Groovy via tree-sitter AST
  • Structure: Modules, packages, classes, interfaces, enums, annotations
  • Relationships: Inheritance, implementations, module dependencies
  • Patterns: Architecture layers (controller/service/repository/model/config/util)
  • Config: application*.properties, application*.yaml/yml
  • Gradle subprojects: settings.gradle parsing

Output

All outputs are written under the provided artifact path (pass as 2nd argument to the script).

knowledge-graph.json           ← complete graph (nodes + edges)
module-dependencies.{dot,svg}  ← module dependency diagram
module-{name}.{dot,svg}        ← per-module class diagrams
project-{name}.{dot,svg}       ← complete project diagram

Resources

  • references/schema.md — node/edge types, ID patterns, fields, visualization colors
  • references/querying.md — jq and Python query examples
  • scripts/build_knowledge_graph.py — main analyzer
  • scripts/install_grammars.py — grammar installer

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
official
accessibility-aria-expert
microsoft
Phát hiện và sửa các vấn đề về khả năng tiếp cận trong giao diện web React/Fluent UI. Sử dụng khi xem xét mã để đảm bảo tương thích với trình đọc màn hình, sửa nhãn ARIA, đảm bảo…
official
generate-canvas-app
microsoft
[DEPRECATED — sử dụng canvas-app thay thế] Tạo một ứng dụng canvas Power Apps hoàn chỉnh.
official
django
microsoft
Các phương pháp tốt nhất cho phát triển web Django bao gồm models, views, templates và testing.
official
github-issue-creator
microsoft
Chuyển đổi ghi chú thô, nhật ký lỗi, ghi âm giọng nói hoặc ảnh chụp màn hình thành báo cáo vấn đề markdown sắc nét theo phong cách GitHub. Sử dụng khi người dùng dán thông tin lỗi, lỗi…
official
python-package-management
microsoft
Sử dụng uv để quản lý phụ thuộc và poethepoet để tự động hóa tác vụ.
official
runtime-validation
microsoft
Xác thực thời gian chạy cho các ứng dụng đã di chuyển — bao gồm chiến lược kiểm thử (giai đoạn lập kế hoạch) và thực thi kiểm thử (giai đoạn xác thực): xác minh khởi động,…
official
azure-postgres-ts
microsoft
Kết nối đến Azure Database for PostgreSQL Flexible Server bằng gói pg (node-postgres) với hỗ trợ xác thực mật khẩu và Microsoft Entra ID (không mật khẩu).
official