Skip to content

feat(code-visualizer): multi-language support (Python, TypeScript, Rust, Go)#4480

Merged
rysweet merged 2 commits intomainfrom
feat/code-visualizer-multilang
Apr 25, 2026
Merged

feat(code-visualizer): multi-language support (Python, TypeScript, Rust, Go)#4480
rysweet merged 2 commits intomainfrom
feat/code-visualizer-multilang

Conversation

@rysweet
Copy link
Copy Markdown
Owner

@rysweet rysweet commented Apr 25, 2026

Summary

Extends the code-visualizer skill from Python-only to a language-agnostic architecture covering Python, TypeScript/JavaScript, Rust, and Go, while preserving the existing UX (mermaid import/dependency diagrams + staleness detection).

Architecture

  • scripts/graph.py — Shared Node/Edge/Graph dataclasses (data contract; no inheritance among analyzers).
  • scripts/{python,ts,rust,go}_analyzer.py — Independent bricks; each exposes exactly one normalize(paths) -> Graph entry point.
    • Python: ast-based.
    • TS/JS: bounded regex; one analyzer covers .ts/.tsx/.js/.jsx/.mjs/.cjs (ESM, CommonJS, dynamic imports).
    • Rust: use/mod extraction.
    • Go: single + grouped import (...) extraction (with aliases).
  • scripts/dispatcher.py — Walks target dir, groups files by extension, lazy-loads analyzers via importlib. Skips IGNORE_DIRS (.git, node_modules, __pycache__, dist, build, target, …) and never follows symlinks.
  • scripts/mermaid_renderer.py — Language-blind render() and render_combined() (one subgraph per language with id namespacing). Sanitizes node ids.
  • scripts/staleness.py — Compares max mtime over detected-language sources vs. diagram mtime.
  • scripts/visualizer.py — CLI: visualizer.py <path> [--output DIR] [--basename NAME] [--combined] [--check-staleness]. Validates basename and rejects bad/missing paths.

Tests

36 new tests under amplifier-bundle/skills/code-visualizer/tests/:

  • Per-analyzer correctness (Python, TS, Rust, Go) including malformed-input resilience.
  • Dispatcher routing + IGNORE_DIRS enforcement + nonexistent-path rejection.
  • Renderer: empty graph, edges, id sanitization, combined-view subgraphs.
  • Staleness: missing diagram, fresh, stale, language-scoped.
  • CLI: per-language output files, --combined, basename validation, nonexistent path.
  • Smoke test: runs dispatcher against the repo root and asserts non-empty mermaid for Python (and TS if present).

pytest.ini updated to register the skill's tests/ path.

Mirror

amplifier-bundle/skills/code-visualizer/ is canonical and synced to .claude/skills/code-visualizer/ via rsync -a --delete. diff -r is clean.

Extending with a new language

Documented in SKILL.md: drop <lang>_analyzer.py exposing normalize() into scripts/, register its module name + extension set in dispatcher.LANGUAGES. No inheritance required.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Copilot and others added 2 commits April 25, 2026 16:21
…st, Go)

Refactor the code-visualizer skill into a language-agnostic dispatcher +
per-language analyzer architecture covering Python, TypeScript/JavaScript,
Rust, and Go.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Repo Guardian - Passed

All 75 changed files were reviewed. No ephemeral content or temporary scripts were found.

Files changed fall into three mirrored locations of the same skill, plus one config update:

Location Purpose
.claude/skills/code-visualizer/ Primary skill installation
amplifier-bundle/skills/code-visualizer/ Bundle distribution copy
docs/claude/skills/code-visualizer/ Documentation mirror
pytest.ini Test path registration

Why no violations:

  • No date-prefixed filenames or temporal indicators
  • No temp, hack, one-off, debug, or fix-* naming patterns
  • All scripts are parameterized, documented, and part of the project's permanent toolchain
  • README.md and SKILL.md contain durable reference documentation (versioned as 2.0.0) with no "as of today" / "currently we are" staleness-prone language
  • Test files are standard pytest fixtures for a reusable capability
  • pytest.ini is a durable configuration file

Generated by Repo Guardian for issue #4480 ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant