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

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

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 → 6 areas can be affected. 15 dependent symbols, depth 2.
Tag: @anirudhkumar-nanonets — 3 of 7 areas · @shhdwi — 3 of 7 areas · @tpoignonec — Graph Processing, Build Context

flowchart TB
  A0(("Graph Processing<br/>8 symbols"))
  A1(("Review Workflow<br/>2 symbols"))
  A2(("Command Line Interface<br/>2 symbols"))
  A3(("Build Context<br/>1 symbol"))
  A4(("Language Server Protocol<br/>1 symbol"))
  AX(("1 smaller area<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0,A1,A2,A3,A4 reached;
  classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
  class AX tail;
Loading
Can be affected Symbols Nearest hop Reached from
Graph Processing 8 src/graph/build.ts:L1-L411 build.ts — imports, depth 1 generic.ts
Review Workflow 2 src/app/brain-build.ts:L1-L428 brain-build.ts — imports, depth 2 generic.ts
Command Line Interface 2 src/cli.ts:L1-L1407 cli.ts — imports, depth 2 generic.ts
Build Context 1 src/context/build.ts:L1-L468 build.ts — imports, depth 2 generic.ts
Language Server Protocol 1 src/graph/lsp/enrich.ts:L1-L141 enrich.ts — imports, depth 1 generic.ts
tools.ts 1 src/mcp/tools.ts:L1-L330 tools.ts — imports, depth 2 generic.ts
Who knows this code — 6 people across 7 areas
Area Who knows it
generic.ts · changed @Mult1Hunter — 1 commit, last 11d ago · @shhdwi — 1 commit, last 15d ago
Graph Processing · affected Buseong Kim — 1 commit, last 11d ago · @tpoignonec — 1 commit, last 15d ago
Review Workflow · affected @anirudhkumar-nanonets — 8 commits, last yesterday
Command Line Interface · affected @anirudhkumar-nanonets — 5 commits, last yesterday
Build Context · affected @tpoignonec — 1 commit, last 15d ago · @shhdwi — 1 commit, last 15d ago
Language Server Protocol · affected @shhdwi — 1 commit, last 15d ago
tools.ts · affected @anirudhkumar-nanonets — 1 commit, last 9d ago · @afeddersen — 1 commit, last 11d ago

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 15 dependent symbols, grouped by area

Graph Processing — 8 symbols in 8 files

  • src/graph/build.ts:L1-L411 — build.ts (imports, depth 1)
  • src/graph/check.ts:L1-L221 — check.ts (imports, depth 1)
  • src/graph/container.ts:L1-L209 — container.ts (imports, depth 1)
  • src/graph/resolve.ts:L1-L658 — resolve.ts (imports, depth 1)
  • src/graph/source-files.ts:L1-L121 — source-files.ts (imports, depth 1)
  • src/graph/fingerprint.ts:L1-L197 — fingerprint.ts (imports, depth 2)
  • src/graph/refresh.ts:L1-L274 — refresh.ts (imports, depth 2)
  • src/graph/workspace.ts:L1-L725 — workspace.ts (imports, depth 2)

Review Workflow — 2 symbols in 2 files

  • src/app/brain-build.ts:L1-L428 — brain-build.ts (imports, depth 2)
  • src/app/review.ts:L1-L174 — review.ts (imports, depth 2)

Command Line Interface — 2 symbols in 2 files

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

Build Context — 1 symbol in 1 file

  • src/context/build.ts:L1-L468 — build.ts (imports, depth 2)

Language Server Protocol — 1 symbol in 1 file

  • src/graph/lsp/enrich.ts:L1-L141 — enrich.ts (imports, depth 1)

tools.ts — 1 symbol in 1 file

  • src/mcp/tools.ts:L1-L330 — 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.ts — 1 test file changed here: test/generic-extract.test.ts
37 test suites also reference this code

37 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/context-only-dir.test.ts
  • test/context.test.ts
  • test/covers.test.ts
  • test/generic-node24-probe.ts
  • test/graph-cross-language.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
  • …17 more

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

graft blast · refs/graft/base...HEAD · depth 2 · 4 changed files

Open the interactive graph → — click an area to see the code that changed, and the line that reaches it.

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
@Frankie-Xu
Frankie-Xu marked this pull request as draft August 26, 2026 09:49
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. Conflict resolution kept the current language list (PHP/Kotlin/Swift stay full-fidelity; Nix stays in the broad list) and added HTML as a file-node-only breadth language. Waiting on CI before marking ready.

github-actions Bot added a commit that referenced this pull request Sep 11, 2026
@Frankie-Xu
Frankie-Xu marked this pull request as ready for review September 11, 2026 12:52
@Frankie-Xu

Copy link
Copy Markdown
Contributor Author

CI is green on current main. Ready for review.

Ercaner1988 added a commit to Ercaner1988/Graft that referenced this pull request Sep 12, 2026
- generic-extract.test.ts: the union merge of trailhq#196, trailhq#200 and trailhq#201 spliced
  their appended tests into one another and left the file unterminated.
  Rebuilt as trailhq#196's file plus trailhq#200's and trailhq#201's appended blocks verbatim.
- The trailhq#139 test asserted that a cached parse failure is replayed without a
  re-parse; trailhq#317 (fixes trailhq#312) deliberately re-parses it instead and did not
  update the test. It now asserts the re-parse and that the error still
  comes back.
- The trailhq#319 symlink test (trailhq#328) needed symlink privilege on Windows. Directory
  links are junctions there, as test/graph-root and test/ingest-fs already
  do, and the file-link case is skipped with a diagnostic when it cannot be
  created.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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