pr-lens-visualizer
Draw pull request diffs and codebase structures as animated, self-contained SVG architecture and data-flow diagrams. Author and validate graph documents, render standalone SVGs, and compose PR comments. Do not use for non-code diagrams or general image generation.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- pr-lens-visualizer
- description
- Draw pull request diffs and codebase structures as animated, self-contained SVG architecture and data-flow diagrams. Author and validate graph documents, render standalone SVGs, and compose PR comments. Do not use for non-code diagrams or general image generation.
02 资源文件 3
- 参考文档CARD.md3.1 KB
- 参考文档config.default.yaml324 B
- 脚本scripts/visualizer_engine.py17.6 KB
03 SKILL.md 正文
PR Lens Visualizer: Standalone Animated Architecture & Data-Flow Diagrams
pr-lens-visualizer transforms git pull request diffs and codebase directory structures into self-contained, zero-dependency animated SVG architecture and data-flow diagrams.
See CARD.md for the companion summary card, stage progression table, and invariants checklist. Consult config.default.yaml for baseline operational budgets and layout parameters.
The 4-Stage Visualizer Progression
[1. Diff Ingestion & Topology Extraction] ──► [2. Graph Schema & Semantic Validation]
│
▼
[4. PR Comment & Walkthrough Composition] ◄── [3. Standalone Animated SVG Rendering]
1. Diff Ingestion & Topology Extraction
Ingest git diffs or codebase structures and extract architectural topology:
- Ingest Git Diff:
- Extract modified, added, and deleted files and entities using
parse_git_diff(). - Identify module boundaries, ingress endpoints, services, and storage entities.
- Extract modified, added, and deleted files and entities using
- Apply Architectural Overlay:
- If a human-curated
.pr-lens/map.jsonexists in the repository, apply idempotent overlays usingapply_overlay(). - Preserve human subsystem boundaries, lane assignments, and curated labels while mapping diff delta nodes into designated lanes.
- If a human-curated
- Construct Graph Document:
- Build a structured
GraphDocumententity with nodes, directed edges, lanes, and progressive disclosure walkthrough steps.
- Build a structured
Completion criterion: Structured
GraphDocumentassembled with all nodes, edges, lanes, and walkthrough steps populated.
2. Graph Schema & Semantic Validation
Validate graph documents prior to rendering to eliminate layout engine failure modes:
- Structural Type Verification:
- Assert all required fields (
version,title,nodes,edges) are present and valid.
- Assert all required fields (
- Semantic Graph Integrity Verification:
- Enforce terminal validity: every
edge.sourceandedge.targetMUST resolve to an existingnode.id. - Enforce lane membership: every
node.laneMUST resolve to an existinglane.id. - Enforce walkthrough references: every
focus_nodesreference in walkthrough steps MUST resolve to an existing node. - Enforce node uniqueness: duplicate node identifiers are strictly rejected.
- Enforce terminal validity: every
Completion criterion:
validate_graph()returnsvalid == Truewith zero blocking validation errors.
3. Standalone Animated SVG Rendering
Compile the validated graph document into a zero-dependency standalone SVG:
- Inline CSS Keyframe Animation:
- Embed pure CSS
@keyframes pulsein the SVG<style>block to animate stroke offsets along directed edges. - Requires zero external CDNs, client-side JavaScript, or iframe wrappers.
- Embed pure CSS
- Responsive Color Themes:
- Inject
@media (prefers-color-scheme: dark)styling to adapt node fills, borders, text, and edge paths seamlessly between light and dark modes.
- Inject
- Geometry & Lane Layout:
- Position nodes within lane clusters, routing orthogonal or cubic bezier curves for edge transitions.
Completion criterion: Standalone
<svg>generated with valid XML syntax, inline CSS keyframes, and dark/light mode responsiveness.
4. PR Comment & Walkthrough Composition
Compose an actionable GitHub PR markdown comment:
- Progressive Disclosure Walkthrough (ELI5):
- Scaffold ordered walkthrough steps beginning with the 2-node core mental model and expanding outwards.
- Collapsible Architecture Details:
- Wrap the full animated SVG inside a
<details>block with summary statistics (files touched, lane distribution, node count).
- Wrap the full animated SVG inside a
- Reviewer Guidance:
- Highlight high-impact blast radius areas and architectural invariants.
Completion criterion: Markdown PR comment formatted with embedded SVG, ELI5 walkthrough, and architectural impact summary.
The Three Foundational Pillars
1. The Zero-Dependency Invariant
All generated SVG diagrams must be 100% self-contained. Never reference external stylesheets, external fonts, or client-side JavaScript that would be stripped by GitHub comment sanitizers.
2. The Semantic Integrity Invariant
Every edge endpoint and lane reference must be verified against extant nodes and lanes prior to rendering to eliminate downstream layout engine crashes.
3. Progressive Disclosure Pedagogy
Diagram walkthroughs must present architectures progressively—starting from high-level entry points before unfolding subsystem internals.
The Visual Brief Pillar
When completing PR diff visualization sessions or architecture SVG rendering runs, synthesize the generated SVG graph structure, node/edge counts, and XML schema validation results into a standalone interactive HTML visual brief written to %TEMP%\pr-lens-<timestamp>.html. Embed the rendered SVG inline with annotated diff edge highlights and a containment status badge per subgraph.
Mandatory Checkpoint Gates
Before publishing any generated SVG or composing PR comments:
- Gate 1 (SVG Schema Validity): Assert all generated SVG output passes XML well-formedness validation (zero malformed tags or unclosed elements).
- Gate 2 (PR Diff Containment): Assert all visualized nodes and edges are traceable to actual diff hunks (zero phantom nodes from non-diff content).
- Gate 3 (Self-Contained): Assert rendered SVG files load correctly in isolation without external CDN dependencies.
Anti-Patterns
- External Dependency Leaks — Referencing CDN scripts or remote styles that fail inside sanitized GitHub PR comments.
- Dangling Edge Pointers — Emitting graph edges whose source or target nodes do not exist in the node catalog.
- Monolithic Cognitive Flooding — Dumping 50+ unclustered nodes in a single flat view without lanes or progressive walkthrough steps.
- Destructive Map Overwrites — Overwriting human-curated
.pr-lens/map.jsonarchitecture definitions during automated diff analysis. - Mutable Graph State — Using mutable dictionary state instead of immutable slotted/frozen dataclasses for graph entities.
04 同仓库更多 Skills
ui-behavior-primitive-architect
Architect, audit, and verify zero-dependency headless UI behavior primitives, WebMCP agent bridges, WAI-ARIA/SSR/RTL tri-modal checks, and framework expert routing. Do not use for static CSS theme styling or backend database migrations.
trustgraph-ontology-governor
Govern knowledge graphs, SHACL-AF triple policies, OntologyRAG subclass validation, PROV-O dual named graphs, and Laya entropy decision scoring. Do not use for relational SQL queries or generic web scraping.
shim-harness-governor
Govern universal CLI agent loops, 4-tier tool permissions, ancestor-symlink workspace sandboxes, deterministic-first command routing, collision-safe MCP namespacing, and layered skill loading. Do not use for static UI styling or external SQL analytics.
graphiti-zep-memory-governor
Govern bi-temporal knowledge graphs with Graphiti future-edge clamping, MinHash/LSH entity dedup, RRF/MMR reranking, and Zep typed ontologies. Do not use for static SQL joins or generic web crawling.
agora-mcp-workbench-architect
Architect, audit, and orchestrate Agora Workbench MCP servers, loopback sidecars, unified state graphs, gateway/dispatcher connectors, and policy-enforced data lakes. Do not use for static frontend CSS styling or non-MCP desktop GUI automation.
skill-eval-assurance-runner
Evaluate and assure agent skills using small-N Wilson confidence intervals, unbiased pass^k reliability, deterministic trajectory graders, preflight boundary honesty, and sealed digest verification. Do not use for subjective prose review or unconstrained production deployment.