feat(extraction): add Astro language support#585
Open
Detective-XH wants to merge 1 commit into
Open
Conversation
Adds .astro file extraction via tree-sitter-astro (virchau13/tree-sitter-astro,
ABI 14). The grammar's frontmatter_js_block is raw text rather than a parsed
TypeScript AST, so the extractor follows the same re-parse strategy as
SvelteExtractor: the frontmatter content is passed through the TypeScript
tree-sitter extractor with line-number offsets mapped back to .astro coordinates.
Template scanning emits references edges for PascalCase component tags and calls
edges for {expr(...)} invocations.
Validated on three real repos:
- satnaing/astro-paper (60 files): 502 nodes, 1,228 edges — verify-extraction PASS
- onwidget/astrowind (93 files): 747 nodes, 2,030 edges — verify-extraction PASS
- withastro/docs (180 files): 965 nodes, 1,968 edges — verify-extraction PASS
A/B benchmark (headless, Opus, n=1 per arm):
- astro-paper: 53s vs 106s (2× faster), Read 3 vs 6
- astro-docs: 67s vs 125s (46% faster), tool calls 11 vs 46, Read 6 vs 22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.astrofile extraction viatree-sitter-astro(virchau13/tree-sitter-astro, ABI 14, wasm built with emscripten 5.0.7).frontmatter_js_blockis raw text rather than a parsed TypeScript AST, so the extractor re-parses it through the TypeScript tree-sitter extractor and maps line-number offsets back to.astrocoordinates — the same strategy asSvelteExtractor.referencesedges for PascalCase component tags (<MyComponent />) andcallsedges for{expr(...)}invocations.Validation
Extraction — verify-extraction PASS on all three repos:
Unit tests: 7/7 passing (
describe('Astro Extraction')in__tests__/extraction.test.ts)A/B benchmark (headless, Opus, n=1 per arm):
† The astrowind question ("how does Hero receive its props") resolves to a single Glob + Read in both arms — not representative of codegraph's value.
Known gaps (follow-up)
client:loadetc.) — emitsreferencesedges only; does not traverse the child framework's component graphgetCollection()type-level associations cannot be statically tracked[slug].astrodoes not produce aroutenode (could follow SvelteKit resolver pattern)