Skip to content

feat(graph): index HTML files so templates are findable by name (#150) - #196

Open
Frankie-Xu wants to merge 1 commit into
trailhq:mainfrom
Frankie-Xu:feat/150-html-files
Open

feat(graph): index HTML files so templates are findable by name (#150)#196
Frankie-Xu wants to merge 1 commit into
trailhq:mainfrom
Frankie-Xu:feat/150-html-files

Conversation

@Frankie-Xu

Copy link
Copy Markdown
Contributor

Summary

  • Register HTML (.html / .htm) on the breadth tier so template files get a kind: "file" graph node and show up in ask / grep by name — Django users no longer have to walk View class → template_name to find the template (Support HTML files #150).
  • tree-sitter-wasm already ships tree-sitter-html.wasm, so this is one GENERIC_LANGS row (same path as Clojure/Dart). No tags.scm: HTML has no definition-shaped nodes, and the node-kind walker correctly yields a file node only (ocaml/zig precedent).
  • Grammar load stays lazy — a repo with no HTML files does not warm the HTML wasm.

Closes #150

Route tradeoff

Option Why / why not
GENERIC_LANGS + html wasm (this PR) Grammar is already in the bundle. File collection, lazy warmup, graft build -e, and banner labeling all fall out of the existing registry.
File-only ingest in fs.ts / build.ts Would work without a grammar, but would duplicate "is this a source file?" outside the three-tier extension tables. Unnecessary once the wasm is there.
Deep HTML parse (ids/classes as @definition) Out of scope. Useful later; not needed to find a template by filename.
Python render / template_name → HTML file edges Cross-language, larger. Follow-up below.

Test plan

  • npm run build && npm test — 868 pass, 0 fail
  • test/generic-extract.test.ts.html/.htm routing; extract is file-node-only; Django-style templates/index.html + views.py build: grep hits template content, resolveSymbol("index.html") and ask("index.html") hit the file node
  • test/supported-extensions.test.ts.html / .htm in the -e supported set
  • Manual fixture (templates/index.html + Django TemplateView):
✓ wiring: 3 nodes (2 file, 1 class), … [html, python]

graft ask — "index.html"
1. index.html · file  [symbol]
   templates/index.html
2. Home · class  [symbol]
   views.py:L3-L4

graft grep welcome-to-the-shop
templates/index.html (module level)
  L6: {% block content %}welcome-to-the-shop{% endblock %}

Follow-up

  • Cross-language edges: resolve Python render("…") / template_name = "…" string literals onto the matching HTML file node. That is the "go to the template from the View" direction; this PR is the "find the template by name" direction.

Made with Cursor

@Frankie-Xu Frankie-Xu mentioned this pull request Aug 24, 2026
@Frankie-Xu
Frankie-Xu force-pushed the feat/150-html-files branch from b4d5c3d to 2b333dc Compare August 24, 2026 15:59
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (ee1ef03). Conflicts kept Nix/Lua (and Kotlin on the depth tier) and added HTML as a file-node-only breadth row so templates stay findable by name.

npm run build OK. npm test 918/918 (4 load flakes — PageRank timing, MCP stdio — passed on isolated re-run).

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

1 area changed → 4 areas can be affected. 11 dependent symbols, depth 2.

flowchart TB
  A0(("Dependency Graph<br/>7 symbols"))
  A1(("CLI Engine<br/>2 symbols"))
  A2(("LSP Enrichment<br/>1 symbol"))
  A3(("MCP Tools<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0,A1,A2,A3 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Dependency Graph 7 src/graph/build.ts:L1-L404 build.ts — imports, depth 1 Generic Graph
CLI Engine 2 src/cli.ts:L1-L1033 cli.ts — imports, depth 2 Generic Graph
LSP Enrichment 1 src/graph/lsp/enrich.ts:L1-L141 enrich.ts — imports, depth 1 Generic Graph
MCP Tools 1 src/mcp/tools.ts:L1-L339 tools.ts — imports, depth 2 Generic Graph
All 11 dependent symbols, grouped by area

Dependency Graph — 7 symbols in 7 files

  • src/graph/build.ts:L1-L404 — build.ts (imports, depth 1)
    21: import { extractGeneric, genericLangOf, warmGenericGrammars } from "./generic.js";
  • src/graph/check.ts:L1-L190 — check.ts (imports, depth 1)
    24: import { extractGeneric, genericLangOf, warmGenericGrammars } from "./generic.js";
  • src/graph/container.ts:L1-L209 — container.ts (imports, depth 1)
    25: import { loadWasmLanguage, parseWasm, type TsNode } from "./generic.js";
  • src/graph/source-files.ts:L1-L94 — source-files.ts (imports, depth 1)
    15: import { genericLangOf, genericExtensions } from "./generic.js";
  • src/graph/fingerprint.ts:L1-L185 — fingerprint.ts (imports, depth 2)
  • src/graph/refresh.ts:L1-L270 — refresh.ts (imports, depth 2)
  • src/graph/workspace.ts:L1-L509 — workspace.ts (imports, depth 2)

CLI Engine — 2 symbols in 2 files

  • src/cli.ts:L1-L1033 — cli.ts (imports, depth 2)
  • src/engine.ts:L1-L155 — engine.ts (imports, depth 2)

LSP Enrichment — 1 symbol in 1 file

  • src/graph/lsp/enrich.ts:L1-L141 — enrich.ts (imports, depth 1)
    17: import { genericLangOf } from "../generic.js";

MCP Tools — 1 symbol in 1 file

  • src/mcp/tools.ts:L1-L339 — tools.ts (imports, depth 2)
Test signal per changed area — 1 –

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • Generic Graph — 1 test file changed here: test/generic-extract.test.ts
30 test suites also reference this code

30 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/ask-index.test.ts
  • test/ask.test.ts
  • test/container-extract.test.ts
  • test/covers.test.ts
  • test/graph-enrich-pending.test.ts
  • test/graph-go.test.ts
  • test/graph-incremental.test.ts
  • test/graph-invariants.test.ts
  • test/graph-java.test.ts
  • test/graph-languages.test.ts
  • test/graph-php.test.ts
  • test/graph-posix-paths.test.ts
  • test/graph-python.test.ts
  • test/graph-r-classes.test.ts
  • test/graph-r-phase3.test.ts
  • test/graph-r-phase4.test.ts
  • test/graph-r-phase5.test.ts
  • test/graph-r.test.ts
  • test/graph-references.test.ts
  • test/graph-refresh.test.ts
  • …10 more

⚠️ 1 changed file not in the graph (README.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 4 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
github-actions Bot added a commit that referenced this pull request Aug 25, 2026
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.

Support HTML files

1 participant