Skip to content

feat(qmd): tree-sitter AST break points for code files - #100

Merged
fjh2333 merged 1 commit into
mainfrom
feat/issue-99-ast-break-points
Oct 29, 2026
Merged

fjh2333 merged 1 commit into
mainfrom
feat/issue-99-ast-break-points

Conversation

@fjh2333

@fjh2333 fjh2333 commented Oct 29, 2026

Copy link
Copy Markdown
Member

Changes

  • New ast feature on qmd (default on; forwarded by qmd-cli) with chunk::ast: detect_language (11 extensions → 6 languages, case-insensitive, qmd:// paths) and ast_break_points. LANGUAGE_QUERIES copied verbatim (ast.ts:94-151); upstream scores; highest score per position; sorted. Unsupported, empty and invalid input returns no break points.
  • Grammars pinned to the exact versions upstream installs: tree-sitter-typescript =0.23.2 (also used for JavaScript, as upstream does), tree-sitter-python/-go =0.25.0, tree-sitter-rust =0.24.0, on tree-sitter 0.26.13 (upstream web-tree-sitter 0.26.12).
  • Positions are converted from tree-sitter byte offsets to UTF-16 indices, the unit web-tree-sitter's startIndex reports, so non-ASCII files match upstream exactly.
  • qmd-cli/qmd-mcp depend on qmd with explicit features (llama), so --no-default-features drops tree-sitter.
  • Not ported: extractSymbols (upstream stub with no callers) and the grammar-load repair message (grammars are statically linked, so that failure cannot happen).
  • Remaining P5 test gaps: named-index daemon data, named + default daemons side by side, --daemon over stale and foreign-PID pidfiles, single EOF message, EPIPE on stderr, encodeQmdPath.

Related issue

Closes #99

How it was tested

  • scripts/gen_ast_golden.ts recorded upstream getASTBreakPoints on 18 files (every extension and capture kind, invalid syntax, empty, CJK, emoji, markdown, unknown extension); in-crate replay has zero mismatches.
  • 25 ported ast.test.ts cases + UTF-16 conversion tests; 7 new P5 gap tests.
  • just all green; cargo deny clean; qmd and qmd-cli build with --no-default-features. No new unsafe in our code.
  • Release binary size is unchanged in this PR because chunk::ast has no callers yet; P6.2 will report the measured delta.

Adds the `ast` feature (default on) with `chunk::ast`: language
detection for upstream's 11 extensions, LANGUAGE_QUERIES copied
verbatim, upstream scores and strictly-highest dedup per position.
Grammars are pinned to the exact versions upstream installs
(typescript 0.23.2 — also used for JavaScript — python/go 0.25.0,
rust 0.24.0) on the tree-sitter 0.26 runtime. Positions are converted
from tree-sitter byte offsets to UTF-16 indices, which is what
web-tree-sitter's startIndex reports, so non-ASCII files match too.

A new upstream-recorded golden (18 files: every extension and capture,
invalid syntax, empty, CJK, emoji, markdown, unknown extension)
replays with zero mismatches. qmd-cli/qmd-mcp now depend on qmd with
explicit features so `--no-default-features` really drops tree-sitter.

Also folds in the remaining P5 test gaps: named-index daemon data,
named + default daemons side by side, --daemon over stale and foreign
pidfiles, single EOF breadcrumb, EPIPE on stderr, encodeQmdPath.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fjh2333 fjh2333 self-assigned this Oct 29, 2026
@fjh2333 fjh2333 added enhancement New feature or request rust Pull requests that update rust code labels Oct 29, 2026
@fjh2333
fjh2333 merged commit a9b58ed into main Oct 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(qmd): tree-sitter AST break points for code files

1 participant