Skip to content

feat(code-graph): graphify's code graph as one Rust binary, with an interactive graph.html - #138

Merged
h0ffmann merged 2 commits into
mainfrom
feat/code-graph
Oct 21, 2026
Merged

h0ffmann merged 2 commits into
mainfrom
feat/code-graph

Conversation

@h0ffmann

Copy link
Copy Markdown
Owner

What

A new lab, labs/code-graph: graphify's code-only graph as one Rust binary. It has no Python, no pip, no model and no network at run time.

  • code-graph extract DIR writes graph.json (graphify's schema), GRAPH_REPORT.md and graph.html. query, path, explain, cluster-only, update and html are there too.
  • Languages (tree-sitter crates): Rust, Python, JavaScript, TypeScript and TSX, Scala, Fortran, and, new compared with graphify, Gleam and Nix.
  • graph.html is one offline file: the layout is computed in Rust, the SVG is complete with JavaScript off, and a 4.8 KB hand-written viewer (assets/viewer.js, inlined with include_str!) adds pan, zoom, search, click-to-focus and a community legend. Light and dark follow prefers-color-scheme.
  • Same tree, byte-identical graph.json, GRAPH_REPORT.md and graph.html (tested).
  • labs/viz is not changed. A follow-up can switch viz to this binary.

Licence of graphify

Apache-2.0 (with older MIT parts and a NOTICE). It allows a re-implementation. No source is copied: the behaviour and the format were learnt from the output and from reading it. Apache-2.0 section 6 gives no right to the name, so the binary is code-graph, "compatible with graphify's graph.json". Details and pins are in the lab README.

Needs the owner before merge: AGENTS.md

AGENTS.md changes in this PR (a guardrail file): the hard rule's exceptions now also name "the code-graph viewer (labs/code-graph/assets/viewer.js, hand-written and dependency-free, inlined into each generated graph.html; approved by the owner on 2026-10-21)". The owner approved this change by name in the task. .github/workflows/ci.yml also gets code-graph in the labs matrix (the owner asked for the lab).

Sizes (x86_64-linux, nixpkgs 6510408d)

packages.default binary 15.8 MiB; closure 62.8 MiB
packages.static (musl) 15.9 MiB, one file; 1.1 MiB with xz -9e (measurement only)
nixpkgs graphify 0.9.74 closure 579.7 MiB
graph.html of this repository about 370 KB (not committed; just graph writes it to ~/.cache/code-graph/<name>/)

Differential check against graphify 0.9.74

On this repository (Rust files only, same node ids in both): calls 532 of graphify's 553 are also here (this tool writes 698); contains 625 of 625; method 38 of 45; imports_from 12 of 14. graphify writes references and case_of edges, this tool does not. Clustering is Louvain here and Leiden in graphify, so partitions differ (45 and 49 communities). On labs/viz/example the 5 nodes and 5 edges are the same, plus one extra imports edge. The 166 extra calls edges were not checked by a person. Full table: lab README.

Not implemented

Documents, papers, images and video, every LLM pass (community labels, add, install, MCP server), Markdown pages and links, references edges, the other 30 graphify languages, the extraction cache, .gitignore handling, --dfs.

What a consumer does

Nothing. No exported shape changes. labs/viz and marola-devkit keep using graphify until a follow-up PR.

Tested

nix flake check --no-update-lock-file in labs/code-graph (build with 9 cargo tests, clippy -D warnings, fmt, lab-json, size, smoke); nixpkgs-fmt, statix, deadnix, actionlint, reuse lint; just --summary on just 1.21-safe syntax (no new attributes); a headless Chrome check of graph.html at 1280 px (search, node click and legend click work). CI is off on pull requests, so these ran locally.

h0ffmann and others added 2 commits October 21, 2026 02:44
…nteractive graph.html

New lab labs/code-graph: tree-sitter extraction (Rust, Python, JavaScript, TypeScript, Scala,
Fortran, Gleam, Nix), Louvain clustering, query/path/explain, graph.json in graphify's schema
(readable by marola-devkit's route.py), GRAPH_REPORT.md and a self-contained graph.html with a
layout computed in Rust and a 5 KB hand-written viewer. No Python, no network at run time,
byte-identical output for one tree. Written new: graphify (Apache-2.0) was read for behaviour
only; the name is neutral. labs/viz is not changed.

Also adds the lab to the CI matrix and one row to the root README. AGENTS.md: the hard rule's
exceptions now name the code-graph viewer (labs/code-graph/assets/viewer.js). The owner approved
this guardrail change by name, on 2026-10-21.

Tested: nix flake check --no-update-lock-file in labs/code-graph (build + 9 cargo tests, clippy -D warnings, fmt, lab-json, size, smoke) passes; nixpkgs-fmt, statix, deadnix, actionlint and reuse lint clean; differential against nixpkgs graphify 0.9.74 on this repo and on labs/viz/example (see the lab README)
Co-Authored-By: Claude <[email protected]>
…ar that does not overflow

- extract skips any directory below the root that has its own .git (a submodule has a .git file,
  a nested repository a .git directory): they are other repositories. --exclude PATH (repeatable,
  relative to DIR) skips more. A test covers both.
- --title TEXT names the page (header and <title>); the default is the directory name.
- graph.html: a community name in the sidebar is cut with an ellipsis, the full name is in a
  title attribute, and the sidebar never scrolls sideways.
- The first commit of this PR left out the files outside labs/code-graph by mistake. This commit
  adds them: the AGENTS.md exception for the code-graph viewer (the owner approved this guardrail
  change by name, on 2026-10-21), "code-graph" in the CI labs matrix, and the root README row.

Tested: nix flake check --no-update-lock-file in labs/code-graph (8 cargo tests incl. the new one, clippy -D warnings, fmt, lab-json, size, smoke) passes; nixpkgs-fmt clean; code-graph extract on ptbr-writter with --exclude vendor gives 115 nodes
Co-Authored-By: Claude <[email protected]>
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