Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(ingestion): Astro at the Full tier via a byte-scanned TS projection (#3164)
nightiousfcfc90f508c1
diff --git a/README.md b/README.mdindex e8a9c1f69..5764d13f2 100644--- a/README.md+++ b/README.md@@ -126,7 +126,7 @@ the page that answers it.| You ask | Repowise gives you ||---|---|| *How does checkout work in this repo?* | A cited answer built from the call graph and the generated docs, in one call. [Search and answers](docs/layers/WIKI.md) |-| *What calls this function, and what does it call?* | A call graph across 26 parsed languages, every edge stamped with how it was resolved and how far to trust it, plus traced execution flows from each entry point. [The graph](docs/layers/GRAPH.md) |+| *What calls this function, and what does it call?* | A call graph across 27 parsed languages, every edge stamped with how it was resolved and how far to trust it, plus traced execution flows from each entry point. [The graph](docs/layers/GRAPH.md) || *Can I get docs for this codebase?* | A wiki for every module and file, rendered from the code's structure with no key, or written by a model when you choose. It updates incrementally after each commit. [Docs](docs/layers/WIKI.md) || *Which of our docs are wrong?* | Markdown checked against the tree: every reference to a file or symbol the code no longer has, with the line to edit. [Doc drift](docs/layers/DOC_DRIFT.md) || *Why is it built this way?* | Decisions mined from ADRs, `# WHY:` comments, commit and PR history and your agent sessions, each tied to the code it governs and flagged when it goes stale. [Decisions](docs/layers/DECISIONS.md) |@@ -245,7 +245,7 @@ Five layers, one index:| Layer | What it contributes ||---|---|-| **1. Graph** | File and symbol dependencies across 26 AST-parsed languages, confidence-stamped call resolution, communities, centrality, cycles and execution flows |+| **1. Graph** | File and symbol dependencies across 27 AST-parsed languages, confidence-stamped call resolution, communities, centrality, cycles and execution flows || **2. Git history** | Hotspots, ownership, co-change, bus factor and bug-fix history: behavioural signals static analysis cannot see || **3. Docs** | A wiki for every module and file, hybrid search, and your own markdown checked against the tree for claims the code no longer supports || **4. Decisions** | Architectural rationale from ADRs, inline markers, commits, PRs and agent sessions, each claim traced to evidence |@@ -471,7 +471,7 @@ repository and the cross-repo graph current.## Supported languages-**26 languages parsed to an AST, 40 on a five-rung ladder, framework-aware where an+**27 languages parsed to an AST, 41 on a five-rung ladder, framework-aware where anecosystem handler exists.** Every language ships in the open-source distribution.<p>@@ -481,6 +481,7 @@ ecosystem handler exists.** Every language ships in the open-source distribution<img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=flat-square&logo=javascript&logoColor=black" alt="JavaScript" /><img src="https://img.shields.io/badge/Svelte-FF3E00?style=flat-square&logo=svelte&logoColor=white" alt="Svelte" /><img src="https://img.shields.io/badge/Vue-42B883?style=flat-square&logo=vuedotjs&logoColor=white" alt="Vue" />+ <img src="https://img.shields.io/badge/Astro-BC52EE?style=flat-square&logo=astro&logoColor=white" alt="Astro" /><img src="https://img.shields.io/badge/Java-ED8B00?style=flat-square&logo=openjdk&logoColor=white" alt="Java" /><img src="https://img.shields.io/badge/Kotlin-7F52FF?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin" /><img src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go" />@@ -513,7 +514,7 @@ ecosystem handler exists.** Every language ships in the open-source distribution| Rung | Languages | What you get ||---|---|---|-| **Full** (13) | Python · TypeScript · JavaScript · Svelte · Vue · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers |+| **Full** (14) | Python · TypeScript · JavaScript · Svelte · Vue · Astro · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers || **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | All of the above except the full health suite, within the language-specific ceilings in the full matrix || **Partial** (2) | Luau / Roblox · Razor / Blazor | Luau: AST symbols and `require()` resolution, Rojo and `.luaurc` aware. Razor: component symbols, `@code` and component-tag call edges, C# health markers; no import resolution yet || **Lightweight** (6) | Clojure · Haskell · Lean 4 · Erlang · HTML · QML | A real file-to-file import graph, and no symbol-level claims |diff --git a/ROADMAP.md b/ROADMAP.mdindex 2fb98ebc5..b8eb2b134 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -34,7 +34,7 @@ Languages land on a five-rung ladder rather than a yes/no list, because "do yousupport X" has five different useful answers. Each rung is defined, with what itbuys you, in[docs/layers/LANGUAGE_SUPPORT.md](docs/layers/LANGUAGE_SUPPORT.md). Today that-ladder covers **40 languages, 26 of them parsed to a full AST**.+ladder covers **41 languages, 27 of them parsed to a full AST**.### New languagesdiff --git a/docs/README.md b/docs/README.mdindex 7af52e243..3d8557686 100644--- a/docs/README.md+++ b/docs/README.md@@ -34,7 +34,7 @@ For a map of every layer and how they feed each other, read| [agent/DISTILL.md](agent/DISTILL.md) | Compress noisy command output before your agent reads it || [agent/LENS.md](agent/LENS.md) | Lens in the Claude Code plugin: the spinner, change review, Flow and the `/lens` map shown while Claude works || [layers/GRAPH.md](layers/GRAPH.md) | The dependency graph, and how much to trust each edge |-| [layers/LANGUAGE_SUPPORT.md](layers/LANGUAGE_SUPPORT.md) | What works per language: 26 parsed to a full AST, 40 on the support ladder |+| [layers/LANGUAGE_SUPPORT.md](layers/LANGUAGE_SUPPORT.md) | What works per language: 27 parsed to a full AST, 41 on the support ladder |### Find what to fix firstdiff --git a/docs/architecture/code-health.md b/docs/architecture/code-health.mdindex 265a642d7..37372f67d 100644--- a/docs/architecture/code-health.md+++ b/docs/architecture/code-health.md@@ -783,8 +783,8 @@ held-out sample and carries 0.7; SQLAlchemy, with under 30 held-out labels, stay0.4. `unbounded_read_reduced_in_memory` (Python) flags an unlimited query whose rowsare deduplicated per key in code.-**Dialects.** `perf/dialects/` registers 12 dialects over 18 language tags (TS/JS-also serve Vue and Svelte script blocks; C# serves Razor). C shares the C++ grammar+**Dialects.** `perf/dialects/` registers 12 dialects over 19 language tags (TS/JS+also serve Vue, Svelte and Astro script blocks; C# serves Razor). C shares the C++ grammarbut has no perf dialect. A language without one emits nothing.**Soundness.** Dynamic dispatch, monkeypatching and callbacks-as-values produce nodiff --git a/docs/architecture/dead-code.md b/docs/architecture/dead-code.mdindex eafedd159..13d743d3c 100644--- a/docs/architecture/dead-code.md+++ b/docs/architecture/dead-code.md@@ -162,7 +162,7 @@ points (`__init__.py`, `__main__.py`, `conftest.py`, `manage.py`, `wsgi.py`,`asgi.py`, `setup.py`, `main.go`), build files (Gradle, Maven, CMake,Makefiles, Meson, Bazel, MSBuild, `build.rs`, bundler configs), shell scripts,files a CI workflow, task file, manifest or script names by path, framework-routes (Next.js, SvelteKit, Nuxt, Remix, ASP.NET minimal APIs, Blazor and+routes (Next.js, SvelteKit, Nuxt, Remix, Astro, ASP.NET minimal APIs, Blazor andRazor code-behind), test layouts, generated code (protoc, Qt, Bison/Flex, SWIG,Cython, Roslyn `*.g.cs`, Dart `*.g.dart`, `**/generated/**`), reflectiveloading (Alembic and Django migrations, EF configurations, COM classdiff --git a/docs/architecture/language-support.md b/docs/architecture/language-support.mdindex 35d02f605..ad2b9b572 100644--- a/docs/architecture/language-support.md+++ b/docs/architecture/language-support.md@@ -593,7 +593,7 @@ with different words.## Multi-language files (the SFC pattern)-Some file types hold more than one language. A `.svelte` or `.vue` component is+Some file types hold more than one language. A `.svelte`, `.vue` or `.astro` component isTS/JS in its `<script>` blocks, framework-flavoured HTML in its markup, and CSSin `<style>`. The markup grammars parse the file but return each `<script>` bodyas one opaque `raw_text` node, so a `.scm` query against them captures no symbol,@@ -642,13 +642,13 @@ the regions are found by walking the bytes. The blanking, fencing, cachingand offset invariants are shared; adding a markup language means adding a`Locator`, not a second copy of the walker.-| | Svelte | Vue | Razor |-|---|---|---|---|-| Grammar | `tree-sitter-svelte` | `tree-sitter-html` | none; byte scan, projected to C# |-| Expression nodes | `svelte_raw_text` under `expression` / `if_start` / `key_start` / `html_tag` | `attribute_value` inside `quoted_attribute_value`; `{{ … }}` scanned inside `text` | brace-matched `@code { }`, `@functions { }`, `@{ }` interiors |-| Fence bytes | the surrounding `{` `}` | the surrounding `"` or `'` | the surrounding `{` `}` |-| Skipped binding forms | `{#each}`, `{#await}` heads | `v-for`, `v-slot` / `#default` | `@using`, `@inject`, `@bind`, `@on*`, `@model`, inline `@expr` |-| Non-component tags | the `svelte:*` namespace | `<KeepAlive>`, `<Transition>`, `<RouterView>`, … in either spelling | lowercase elements; anything inside `@* *@` or `<!-- -->` |+| | Svelte | Vue | Razor | Astro |+|---|---|---|---|---|+| Grammar | `tree-sitter-svelte` | `tree-sitter-html` | none; byte scan, projected to C# | none; byte scan, projected to TS |+| Expression nodes | `svelte_raw_text` under `expression` / `if_start` / `key_start` / `html_tag` | `attribute_value` inside `quoted_attribute_value`; `{{ … }}` scanned inside `text` | brace-matched `@code { }`, `@functions { }`, `@{ }` interiors | the `---` frontmatter and every JS `<script>` body (plain, `is:inline`, `type="module"`, `define:vars`); markup `{expr}` is blanked |+| Fence bytes | the surrounding `{` `}` | the surrounding `"` or `'` | the surrounding `{` `}` | the `>` of each `<script>` opening tag |+| Skipped binding forms | `{#each}`, `{#await}` heads | `v-for`, `v-slot` / `#default` | `@using`, `@inject`, `@bind`, `@on*`, `@model`, inline `@expr` | markup `{expr}` |+| Non-component tags | the `svelte:*` namespace | `<KeepAlive>`, `<Transition>`, `<RouterView>`, … in either spelling | lowercase elements; anything inside `@* *@` or `<!-- -->` | lowercase elements, `<Fragment>`; anything inside `<!-- -->` or a `<script>` |There is no `tree-sitter-vue` on PyPI. The HTML grammar parses a Vue SFC cleanlyanyway, because `<template>`, `<script>` and `<style>` are ordinary elements to@@ -666,6 +666,12 @@ ceiling is that the C# body lands at top level with no enclosing class, so`@code` members are call targets rather than symbols, and every directive isblanked, which is why a Razor file carries no import edges.+Astro has no grammar on PyPI either, so its locator is a byte scan too, projecting+into TypeScript: the leading `---` frontmatter and every JS `<script>` body keep+their bytes, a `<script>` whose `type` is data (`application/ld+json`) or that+sits in an HTML comment is blanked, and PascalCase tags mint component call edges.+Frontmatter imports are ordinary ESM, so an Astro file does carry import edges.+**Plain HTML deliberately has no locator.** It reuses the same grammar but notthe projection, and the distinction is the point: a projection exists to turn a`<script>` block into analysable TypeScript, which is worth it when that block is@@ -691,8 +697,6 @@ thing that names a component) and `<Foo />` instantiation call edges (viarun the filename and the tag through the *same* normaliser, so `back-to-top.vue`and `<back-to-top />` cannot disagree about the name `BackToTop`.-The same steps would fit Astro components; only the locator changes.----## Extensions and import resolutiondiff --git a/docs/business/COMMERCIAL.md b/docs/business/COMMERCIAL.mdindex 73302715f..ec51f4454 100644--- a/docs/business/COMMERCIAL.md+++ b/docs/business/COMMERCIAL.md@@ -42,7 +42,7 @@ scale, in a regulated or security-sensitive environment**:All of the following ship in `pip install repowise` today, free for internal use.- **[Five intelligence layers](../layers/INTELLIGENCE_LAYERS.md)**: Graph- (tree-sitter AST across 26 languages, two-tier dependency graph, call+ (tree-sitter AST across 27 languages, two-tier dependency graph, callresolution, heritage extraction, Leiden communities, PageRank / betweenness /SCC), Git (hotspots, ownership, co-change pairs, bus factor, significantcommits, contributor profiles, module health), Documentation (a wiki page per@@ -100,12 +100,12 @@ All of the following ship in `pip install repowise` today, free for internal use## 3. First-class language coverage-Repowise parses **26 languages to a full AST** and places **40 on a five-rung+Repowise parses **27 languages to a full AST** and places **41 on a five-rungladder**, so "do you support X" gets the rung as its answer rather than a yes or ano. Both numbers matter and neither is worth quoting alone.-The 26 are the top three rungs. At **Full tier sit 13** (Python, TypeScript,-JavaScript, Svelte, Vue, Java, Kotlin, Go, Rust, C++, **C#**, Scala, and Ruby) with+The 27 are the top three rungs. At **Full tier sit 14** (Python, TypeScript,+JavaScript, Svelte, Vue, Astro, Java, Kotlin, Go, Rust, C++, **C#**, Scala, and Ruby) withAST parsing, import resolution, named bindings, call resolution, heritageextraction, multi-project workspace resolvers, framework-aware edges, per-languagedynamic-hint extractors, and code-health markers. A further **11 at Good tier** (C,diff --git a/docs/layers/GRAPH.md b/docs/layers/GRAPH.mdindex fa69a10de..9ebc6c7f2 100644--- a/docs/layers/GRAPH.md+++ b/docs/layers/GRAPH.md@@ -10,7 +10,7 @@ an optional upgrade for wiki prose, so the graph is reproducible.<p><img src="https://img.shields.io/badge/17-edge_types-3178C6?style=flat-square&labelColor=0A0A0A" alt="17 edge types" /><img src="https://img.shields.io/badge/39-resolution_origins-059669?style=flat-square&labelColor=0A0A0A" alt="39 resolution origins" />- <img src="https://img.shields.io/badge/26-full--AST_languages-F59520?style=flat-square&labelColor=0A0A0A" alt="26 full-AST languages" />+ <img src="https://img.shields.io/badge/27-full--AST_languages-F59520?style=flat-square&labelColor=0A0A0A" alt="27 full-AST languages" /><img src="https://img.shields.io/badge/0-LLM_calls-1E293B?style=flat-square&labelColor=0A0A0A" alt="zero LLM calls" /></p>@@ -269,7 +269,7 @@ and a 1-10 architecture score; see- The graph keeps one node per overload set, so on Java and C# a call can landon the wrong overload. On C#, plan against the compiler figure (0.73 to 0.92),not the hand-graded 30 of 30.-- Precision is published for ten of the 26 full-AST languages. Go, TypeScript,+- Precision is published for ten of the 27 full-AST languages. Go, TypeScript,Java, C#, C, C++, Rust and Python have a compiler or analyser answer key;Kotlin and Swift have the hand-graded sample only, at 30 rows each.- Read a precision figure together with its recall. Two tools post higherdiff --git a/docs/layers/INTELLIGENCE_LAYERS.md b/docs/layers/INTELLIGENCE_LAYERS.mdindex 47ae40636..514444a57 100644--- a/docs/layers/INTELLIGENCE_LAYERS.md+++ b/docs/layers/INTELLIGENCE_LAYERS.md@@ -21,7 +21,7 @@ few optional extras, and never switches a layer on.## 1. Graph: what is connected to what-Every file, symbol, import and call in the repository, parsed from an AST in 26+Every file, symbol, import and call in the repository, parsed from an AST in 27languages. Each call edge is stamped with how it was resolved (one of 39 namedresolution origins) and how far to trust it, across 17 edge types. Communities,centrality, cycles and execution flows from each entry point are computed on top.@@ -36,7 +36,7 @@ code through graph edges.| Dead code | Unreachable files, unused exports, unused packages, by confidence tier | [DEAD_CODE.md](DEAD_CODE.md) || Inferred test links | Which tests reach a file, without a coverage report | [TEST_INTELLIGENCE.md](TEST_INTELLIGENCE.md) || Cross-repo contracts | HTTP, gRPC, topic and OpenAPI contracts matched between repositories, with breaking-change detection | [WORKSPACES.md](../scale/WORKSPACES.md) |-| Language coverage | What each of the 40 supported languages gets | [LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md) |+| Language coverage | What each of the 41 supported languages gets | [LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md) |## 2. Git history: where change and breakage concentratediff --git a/docs/layers/LANGUAGE_SUPPORT.md b/docs/layers/LANGUAGE_SUPPORT.mdindex a385ab75f..f3d54d2fe 100644--- a/docs/layers/LANGUAGE_SUPPORT.md+++ b/docs/layers/LANGUAGE_SUPPORT.md@@ -1,6 +1,6 @@# Language Support-**26 languages parsed to a full AST, 40 on the five-rung support ladder, and+**27 languages parsed to a full AST, 41 on the five-rung support ladder, andframework-aware edges where an ecosystem handler exists.** Every language landson one rung, and the rung tells you which parts of the pipeline produce realoutput for it. Files in any other language still appear in the wiki and are@@ -10,7 +10,7 @@ resolution and health markers are all static.<p><strong>Full tier </strong><img src="https://img.shields.io/badge/Python-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python" /> <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /> <img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=flat-square&logo=javascript&logoColor=black" alt="JavaScript" /> <img src="https://img.shields.io/badge/Svelte-FF3E00?style=flat-square&logo=svelte&logoColor=white" alt="Svelte" />- <img src="https://img.shields.io/badge/Vue-42B883?style=flat-square&logo=vuedotjs&logoColor=white" alt="Vue" /> <img src="https://img.shields.io/badge/Java-ED8B00?style=flat-square&logo=openjdk&logoColor=white" alt="Java" /> <img src="https://img.shields.io/badge/Kotlin-7F52FF?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin" /> <img src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go" />+ <img src="https://img.shields.io/badge/Vue-42B883?style=flat-square&logo=vuedotjs&logoColor=white" alt="Vue" /> <img src="https://img.shields.io/badge/Astro-BC52EE?style=flat-square&logo=astro&logoColor=white" alt="Astro" /> <img src="https://img.shields.io/badge/Java-ED8B00?style=flat-square&logo=openjdk&logoColor=white" alt="Java" /> <img src="https://img.shields.io/badge/Kotlin-7F52FF?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin" /> <img src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go" /><img src="https://img.shields.io/badge/Rust-000000?style=flat-square&logo=rust&logoColor=white" alt="Rust" /> <img src="https://img.shields.io/badge/C++-00599C?style=flat-square&logo=cplusplus&logoColor=white" alt="C++" /> <img src="https://img.shields.io/badge/C%23-512BD4?style=flat-square&logo=csharp&logoColor=white" alt="C#" /> <img src="https://img.shields.io/badge/Scala-DC322F?style=flat-square&logo=scala&logoColor=white" alt="Scala" /><img src="https://img.shields.io/badge/Ruby-CC342D?style=flat-square&logo=ruby&logoColor=white" alt="Ruby" /></p>@@ -35,15 +35,15 @@ resolution and health markers are all static.| Tier | Languages | What you get ||------|-----------|--------------|-| **Full** (13) | Python, TypeScript, JavaScript, Svelte, Vue, Java, Kotlin, Go, Rust, C++, C#, Scala, Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers |+| **Full** (14) | Python, TypeScript, JavaScript, Svelte, Vue, Astro, Java, Kotlin, Go, Rust, C++, C#, Scala, Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers || **Good** (11) | C, Swift, PHP, Dart, Object Pascal, COBOL, GDScript, VB.NET, Elixir, F#, Objective-C | Everything above except the full health suite. Dart, Object Pascal and PHP get health markers; C, Swift, F# and Objective-C get the complexity-derived ones; the rest get none yet || **Partial** (2) | Luau / Roblox, Razor / Blazor | Luau: AST symbols and `require()` resolution (Rojo and `.luaurc` aware), no health markers. Razor: a component symbol per file, call edges from `@code` blocks and component tags, C# health markers, no import edges yet || **Lightweight** (6) | Clojure, Haskell, Lean 4, Erlang, HTML, QML | A real file-to-file import graph, no symbol-level claims || **Structural** (8) | R, Zig, Julia, Elm, OCaml, Crystal, Nim, D | Git history only: blame, hotspots, co-change. No AST parsing |-Tree-sitter parsing covers the first three rungs: those are the **26 languages+Tree-sitter parsing covers the first three rungs: those are the **27 languagesparsed to a full AST**. The bottom two rungs come from git history and import-extraction, and all five together make the **40** on the ladder.+extraction, and all five together make the **41** on the ladder.[SQL / dbt](#sql--dbt) and [shell](#shell) sit outside the ladder, becauseneither fits a rung: SQL gets symbols and health markers but no call graph, and@@ -143,7 +143,7 @@ build files: tsconfig path aliases and workspaces, Maven and Gradle reactors,`pubspec.yaml`, `project.godot` and so on. The table per language is in[architecture/language-support.md](../architecture/language-support.md#extensions-and-import-resolution).-`.svelte`, `.vue` and Razor files are projected into TypeScript or C# at the+`.svelte`, `.vue`, `.astro` and Razor files are projected into TypeScript or C# at thesame byte offsets, so they get that language's queries and health markers andevery line number points at the real source. How the projection works:[architecture/language-support.md](../architecture/language-support.md#multi-language-files-the-sfc-pattern).@@ -219,7 +219,7 @@ This table is why a language is Full and not Good.|----------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|| Python | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ || TypeScript / JavaScript | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| Svelte, Vue | ✅ | ✅ | ✅ | no | no | ✅ | ✅ |+| Svelte, Vue, Astro | ✅ | ✅ | ✅ | no | no | ✅ | ✅ || Java | ✅ | ✅ | ✅ | no | no | ✅ | ✅ || Go | ✅ | n/a | ✅ | no | no | ✅ | ✅ || Rust, C++, C# | ✅ | ✅ | ✅ | no | no | ✅ | ✅ |diff --git a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py b/packages/core/src/repowise/core/analysis/dead_code/analyzer.pyindex b888df9c4..43821ca63 100644--- a/packages/core/src/repowise/core/analysis/dead_code/analyzer.py+++ b/packages/core/src/repowise/core/analysis/dead_code/analyzer.py@@ -382,7 +382,7 @@ _TS_JS_IMPORTABLE_KINDS: frozenset[str] = frozenset({"constant", "variable"})# Single-file-component languages: the whole file is one component, so their# exports behave unlike an ordinary module's — see _non_importable_kinds.-_SFC_LANGUAGES: frozenset[str] = frozenset({"svelte", "vue"})+_SFC_LANGUAGES: frozenset[str] = frozenset({"svelte", "vue", "astro"})# Every kind an SFC component prop can take, plus "class" for the synthetic# component symbol itself — see _non_importable_kinds.diff --git a/packages/core/src/repowise/core/analysis/dead_code/constants.py b/packages/core/src/repowise/core/analysis/dead_code/constants.pyindex 52fd8d13f..446f52a70 100644--- a/packages/core/src/repowise/core/analysis/dead_code/constants.py+++ b/packages/core/src/repowise/core/analysis/dead_code/constants.py@@ -678,6 +678,13 @@ _NEVER_FLAG_PATTERNS: tuple[str, ...] = ("*/+layout.server.ts","*/+server.ts","*/+error.svelte",+ # Astro file-based routes: every page under src/pages is a route, and a+ # .ts/.js/.mjs file there is an endpoint (``robots.txt.ts``, ``api/[id].json.ts``).+ "*src/pages/*.astro",+ # shortcut: exempts src/pages/*.{ts,js,mjs} in every repo, not only Astro ones, and _-prefixed non-routes (fnmatch ``*`` crosses ``/``), gate on an Astro stack signal or filter in code if a repo reports hidden dead code.+ "*src/pages/*.ts",+ "*src/pages/*.js",+ "*src/pages/*.mjs",# ESM declaration outputs in dist trees."*/dist/*.d.ts",# ---- JVM (Java + Kotlin) conventions ---------------------------------diff --git a/packages/core/src/repowise/core/analysis/health/complexity/languages.py b/packages/core/src/repowise/core/analysis/health/complexity/languages.pyindex 903005897..e02c880cc 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/languages.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/languages.py@@ -1377,6 +1377,7 @@ LANGUAGE_MAPS: dict[str, LanguageNodeMap] = {# ingestion/sfc_source.py), so the TS node map applies verbatim."svelte": _TS,"vue": _TS,+ "astro": _TS,# Razor reaches the walker as a C# buffer (its ``@code`` / ``@{ }``# regions projected by the same sfc_source seam), so the C# node map# applies verbatim.diff --git a/packages/core/src/repowise/core/analysis/health/dataflow/dialects/__init__.py b/packages/core/src/repowise/core/analysis/health/dataflow/dialects/__init__.pyindex 3824d5ad9..8ec96915b 100644--- a/packages/core/src/repowise/core/analysis/health/dataflow/dialects/__init__.py+++ b/packages/core/src/repowise/core/analysis/health/dataflow/dialects/__init__.py@@ -40,6 +40,7 @@ _REGISTER: tuple[tuple[str, BaseDefUseDialect], ...] = (# SFC <script> blocks are TS/JS and reach the pass as a TS buffer.("svelte", _ts_js.DIALECT),("vue", _ts_js.DIALECT),+ ("astro", _ts_js.DIALECT),("javascript", _ts_js.DIALECT),("jsx", _ts_js.DIALECT),("java", _java.DIALECT),diff --git a/packages/core/src/repowise/core/analysis/health/perf/dialects/__init__.py b/packages/core/src/repowise/core/analysis/health/perf/dialects/__init__.pyindex ed51d1665..2f94c35b7 100644--- a/packages/core/src/repowise/core/analysis/health/perf/dialects/__init__.py+++ b/packages/core/src/repowise/core/analysis/health/perf/dialects/__init__.py@@ -38,6 +38,7 @@ _REGISTER: tuple[tuple[str, BasePerfDialect], ...] = (# SFC <script> blocks are TS/JS and reach the pass as a TS buffer.("svelte", _ts_js.DIALECT),("vue", _ts_js.DIALECT),+ ("astro", _ts_js.DIALECT),("javascript", _ts_js.DIALECT),("jsx", _ts_js.DIALECT),("java", _java.DIALECT),diff --git a/packages/core/src/repowise/core/generation/editor_files/tech_stack.py b/packages/core/src/repowise/core/generation/editor_files/tech_stack.pyindex 502dd6b49..c2dd31dcd 100644--- a/packages/core/src/repowise/core/generation/editor_files/tech_stack.py+++ b/packages/core/src/repowise/core/generation/editor_files/tech_stack.py@@ -23,6 +23,7 @@ _NODE_FRAMEWORKS: dict[str, tuple[str, str]] = {"react": ("React", "framework"),"vue": ("Vue.js", "framework"),"svelte": ("Svelte", "framework"),+ "astro": ("Astro", "framework"),"@angular/core": ("Angular", "framework"),"express": ("Express", "framework"),"fastify": ("Fastify", "framework"),diff --git a/packages/core/src/repowise/core/generation/layers.py b/packages/core/src/repowise/core/generation/layers.pyindex 58fdd311a..a83232c5f 100644--- a/packages/core/src/repowise/core/generation/layers.py+++ b/packages/core/src/repowise/core/generation/layers.py@@ -53,7 +53,7 @@ _LAYER_HINTS: tuple[tuple[str, frozenset[str]], ...] = (# helpers or a Django `views/` package are not a frontend._UI_LAYER = "UI"_UI_EXTENSIONS = frozenset(- {".tsx", ".jsx", ".vue", ".svelte", ".html", ".htm", ".css", ".scss", ".sass", ".less"}+ {".tsx", ".jsx", ".vue", ".svelte", ".astro", ".html", ".htm", ".css", ".scss", ".sass", ".less"})# Layers that observe or support the runtime stack rather than participate indiff --git a/packages/core/src/repowise/core/generation/onboarding/grounding.py b/packages/core/src/repowise/core/generation/onboarding/grounding.pyindex e7cc3fa97..9758ee70e 100644--- a/packages/core/src/repowise/core/generation/onboarding/grounding.py+++ b/packages/core/src/repowise/core/generation/onboarding/grounding.py@@ -77,6 +77,7 @@ _CODE_EXTENSIONS = frozenset("clj","vue","svelte",+ "astro","m","mm",}diff --git a/packages/core/src/repowise/core/ingestion/extractors/bindings/__init__.py b/packages/core/src/repowise/core/ingestion/extractors/bindings/__init__.pyindex 0c6b74120..7e38fac71 100644--- a/packages/core/src/repowise/core/ingestion/extractors/bindings/__init__.py+++ b/packages/core/src/repowise/core/ingestion/extractors/bindings/__init__.py@@ -42,6 +42,7 @@ _DISPATCH: dict[str, Callable[[Node, str], tuple[list[str], list[NamedBinding]]]# A component's <script> imports are ordinary ESM."svelte": extract_ts_js_bindings,"vue": extract_ts_js_bindings,+ "astro": extract_ts_js_bindings,"go": extract_go_bindings,"rust": extract_rust_bindings,"java": extract_java_bindings,diff --git a/packages/core/src/repowise/core/ingestion/extractors/docstrings.py b/packages/core/src/repowise/core/ingestion/extractors/docstrings.pyindex fc3e736e2..842fbd95b 100644--- a/packages/core/src/repowise/core/ingestion/extractors/docstrings.py+++ b/packages/core/src/repowise/core/ingestion/extractors/docstrings.py@@ -119,7 +119,7 @@ def extract_module_docstring(root: Node, src: str, lang: str) -> str | None:"future_import_statement",):break- elif lang in ("typescript", "javascript", "svelte", "vue"):+ elif lang in ("typescript", "javascript", "svelte", "vue", "astro"):# Look for leading /** ... */ commentfor child in root.children:if child.type == "comment":@@ -326,7 +326,7 @@ def extract_symbol_docstring(def_node: Node, src: str, lang: str) -> str | None:return Nonereturn None- elif lang in ("typescript", "javascript", "svelte", "vue"):+ elif lang in ("typescript", "javascript", "svelte", "vue", "astro"):return find_preceding_jsdoc(def_node, src)elif lang == "go":diff --git a/packages/core/src/repowise/core/ingestion/extractors/heritage/__init__.py b/packages/core/src/repowise/core/ingestion/extractors/heritage/__init__.pyindex 5f1a0ac9f..51c309876 100644--- a/packages/core/src/repowise/core/ingestion/extractors/heritage/__init__.py+++ b/packages/core/src/repowise/core/ingestion/extractors/heritage/__init__.py@@ -53,6 +53,7 @@ HERITAGE_EXTRACTORS: dict[str, Callable[..., None]] = {"javascript": _extract_ts_js_heritage,"svelte": _extract_ts_js_heritage,"vue": _extract_ts_js_heritage,+ "astro": _extract_ts_js_heritage,"java": _extract_java_heritage,"go": _extract_go_heritage,"rust": _extract_rust_heritage,diff --git a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/__init__.py b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/__init__.pyindex f39bd9c4e..59ecce921 100644--- a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/__init__.py+++ b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/__init__.py@@ -54,6 +54,7 @@ _SYNTHETIC_PROVIDERS: dict[str, list[_Provider]] = {"c": [cpp_macro_synthetic_symbols],"svelte": [sfc_component_symbols],"vue": [sfc_component_symbols],+ "astro": [sfc_component_symbols],# A .razor/.cshtml file *is* the component: the name comes from the# filename (PascalCase by convention), same as Svelte/Vue."razor": [sfc_component_symbols],diff --git a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/sfc_component.py b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/sfc_component.pyindex 19ff1e9e4..339de4aac 100644--- a/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/sfc_component.py+++ b/packages/core/src/repowise/core/ingestion/extractors/synthetic_symbols/sfc_component.py@@ -49,11 +49,12 @@ def _razor_name(path: PurePosixPath) -> str:return path.stem-_NAMERS = {"svelte": _svelte_name, "vue": _vue_name, "razor": _razor_name}+# Astro takes Vue's rule: ``back-to-top.astro`` is written ``<BackToTop />``.+_NAMERS = {"svelte": _svelte_name, "vue": _vue_name, "razor": _razor_name, "astro": _vue_name}def sfc_component_symbols(root: Node, src: str, file_info: FileInfo) -> list[Symbol]:- """Return the single component symbol for a ``.svelte`` / ``.vue`` / ``.razor`` file."""+ """Return the single component symbol for a ``.svelte`` / ``.vue`` / ``.razor`` / ``.astro`` file."""path = PurePosixPath(file_info.path)if not path.stem:return []diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/remix.py b/packages/core/src/repowise/core/ingestion/framework_edges/remix.pyindex e71c47dc7..b22359c07 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/remix.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/remix.py@@ -30,9 +30,10 @@ if TYPE_CHECKING:_SVELTE_ROUTE_RE = re.compile(r"/\+(?:page|layout|server|error)[.\w]*\.(ts|tsx|js|mjs|svelte)$")_ASTRO_PAGE_RE = re.compile(r"(?:^|/)src/pages/")-# SvelteKit's +page.svelte / +layout.svelte are convention routes in their own-# right, so components count here alongside their .ts/.js siblings.-_ROUTE_LANGUAGES = ("typescript", "javascript", "svelte")+# SvelteKit's +page.svelte / +layout.svelte and Astro's src/pages/*.astro are+# convention routes in their own right, so components count here alongside+# their .ts/.js siblings.+_ROUTE_LANGUAGES = ("typescript", "javascript", "svelte", "astro")def _is_convention_route(path: str) -> bool:diff --git a/packages/core/src/repowise/core/ingestion/language_configs.py b/packages/core/src/repowise/core/ingestion/language_configs.pyindex c5b17e704..4571659c8 100644--- a/packages/core/src/repowise/core/ingestion/language_configs.py+++ b/packages/core/src/repowise/core/ingestion/language_configs.py@@ -694,6 +694,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {# copying keeps them from drifting apart.LANGUAGE_CONFIGS["svelte"] = LANGUAGE_CONFIGS["typescript"]LANGUAGE_CONFIGS["vue"] = LANGUAGE_CONFIGS["typescript"]+LANGUAGE_CONFIGS["astro"] = LANGUAGE_CONFIGS["typescript"]# Razor projects its C# regions (``@code`` / ``@{ }`` blocks) into a C## buffer through the same sfc_source seam, so the C# config applies verbatim.LANGUAGE_CONFIGS["razor"] = LANGUAGE_CONFIGS["csharp"]diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py b/packages/core/src/repowise/core/ingestion/languages/specs/__init__.pyindex 929bbc2f8..b725bcad1 100644--- a/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py+++ b/packages/core/src/repowise/core/ingestion/languages/specs/__init__.py@@ -12,6 +12,7 @@ from __future__ import annotationsfrom ..spec import LanguageSpecfrom .asciidoc import SPEC as _ASCIIDOC+from .astro import SPEC as _ASTROfrom .c import SPEC as _Cfrom .clojure import SPEC as _CLOJUREfrom .cobol import SPEC as _COBOL@@ -80,6 +81,7 @@ ALL_SPECS: tuple[LanguageSpec, ...] = (# registry built so far, so typescript's grammar has to be loaded first._SVELTE,_VUE,+ _ASTRO,_GO,_RUST,_JAVA,diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/astro.py b/packages/core/src/repowise/core/ingestion/languages/specs/astro.pynew file mode 100644index 000000000..654b63059--- /dev/null+++ b/packages/core/src/repowise/core/ingestion/languages/specs/astro.py@@ -0,0 +1,33 @@+"""LanguageSpec for astro.++An ``.astro`` component is parsed as TypeScript: ``sfc_source`` blanks the+markup and ``<style>`` so the ``---`` frontmatter and every ``<script>`` body+sit at byte-identical offsets in a valid TS buffer. Hence+``shares_grammar_with`` and ``scm_file`` both point at typescript. There is no+tree-sitter-astro on PyPI, so the regions are located by a byte scan, as for+Razor.+"""++from ..spec import LanguageSpec+from .typescript import SPEC as _TS++SPEC = LanguageSpec(+ tag="astro",+ display_name="Astro",+ import_support="full",+ test_infixes=(".test.", ".spec."),+ extensions=frozenset({".astro"}),+ shares_grammar_with="typescript",+ scm_file="typescript.scm",+ heritage_node_types=_TS.heritage_node_types,+ manifest_files=("package.json", "astro.config.mjs", "astro.config.ts"),+ # Framework config, not a package declaration — package.json is the root.+ build_config_manifests=("astro.config.mjs", "astro.config.ts"),+ lock_files=_TS.lock_files,+ blocked_dirs=("node_modules", ".astro", "dist"),+ # The frontmatter and scripts are TypeScript, filtered like a sibling .ts file.+ builtin_calls=_TS.builtin_calls,+ builtin_parents=_TS.builtin_parents,+ builtin_types=_TS.builtin_types,+ color_hex="#BC52EE",+)diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.pyindex 089b75ec3..88ebc4c04 100644--- a/packages/core/src/repowise/core/ingestion/models.py+++ b/packages/core/src/repowise/core/ingestion/models.py@@ -25,6 +25,7 @@ LanguageTag = Literal[# Single-file components — parsed as TypeScript via sfc_source."svelte","vue",+ "astro","go","rust","java",diff --git a/packages/core/src/repowise/core/ingestion/parser.py b/packages/core/src/repowise/core/ingestion/parser.pyindex 933b4a769..83fa7ef70 100644--- a/packages/core/src/repowise/core/ingestion/parser.py+++ b/packages/core/src/repowise/core/ingestion/parser.py@@ -157,10 +157,10 @@ QUERIES_DIR = Path(__file__).parent / "queries"# it would misfire on the parent lexical_declaration kind mapping._MODULE_ANCHORED_NODE_TYPES = frozenset({"assignment", "variable_declarator"})-# Languages whose source reaches the parser as TypeScript/JavaScript. The two+# Languages whose source reaches the parser as TypeScript/JavaScript. The# SFC tags are here because ``sfc_source`` projects their <script> blocks into# a TS buffer at identical offsets, so every TS/JS code path applies verbatim.-_TS_JS_LANGUAGES = ("typescript", "javascript", "svelte", "vue")+_TS_JS_LANGUAGES = ("typescript", "javascript", "svelte", "vue", "astro")# Languages whose query defines the ``@reference.*`` captures. Every other# language would only scan the whole match list to find nothing, so the checkdiff --git a/packages/core/src/repowise/core/ingestion/resolvers/__init__.py b/packages/core/src/repowise/core/ingestion/resolvers/__init__.pyindex 593340546..a580e99e3 100644--- a/packages/core/src/repowise/core/ingestion/resolvers/__init__.py+++ b/packages/core/src/repowise/core/ingestion/resolvers/__init__.py@@ -43,6 +43,7 @@ _RESOLVERS: dict[str, ResolverFn] = {# SvelteKit ``$lib`` alias it now understands for .ts/.js files too."svelte": resolve_ts_js_import,"vue": resolve_ts_js_import,+ "astro": resolve_ts_js_import,"go": resolve_go_import,"rust": resolve_rust_import,"cpp": resolve_cpp_import,diff --git a/packages/core/src/repowise/core/ingestion/return_types.py b/packages/core/src/repowise/core/ingestion/return_types.pyindex 239173323..c11a4decd 100644--- a/packages/core/src/repowise/core/ingestion/return_types.py+++ b/packages/core/src/repowise/core/ingestion/return_types.py@@ -138,7 +138,7 @@ def normalize_return_type(raw: str, language: str) -> str | None:"""value = raw.strip()- if language in ("typescript", "javascript", "svelte", "vue"):+ if language in ("typescript", "javascript", "svelte", "vue", "astro"):value = _NULLISH_UNION.sub("", value).strip()if language == "csharp":value = value.removeprefix("global::").rstrip("?").strip()diff --git a/packages/core/src/repowise/core/ingestion/sfc_source.py b/packages/core/src/repowise/core/ingestion/sfc_source.pyindex dd6b81ef3..29a2d25f9 100644--- a/packages/core/src/repowise/core/ingestion/sfc_source.py+++ b/packages/core/src/repowise/core/ingestion/sfc_source.py@@ -1,8 +1,9 @@"""Single-file-component source preparation.-A ``.svelte``, ``.vue`` or ``.razor`` file is more than one language in one-file: ``<script>`` blocks hold TS/JS, the markup is a framework-flavoured-HTML, and ``@code`` / ``@{ }`` regions hold C#. The markup grammars parse+A ``.svelte``, ``.vue``, ``.razor`` or ``.astro`` file is more than one+language in one file: ``<script>`` blocks (and Astro's ``---`` frontmatter)+hold TS/JS, the markup is a framework-flavoured HTML, and ``@code`` /+``@{ }`` regions hold C#. The markup grammars parsethe file but hand each ``<script>`` body back as one opaque ``raw_text``node, so a ``.scm`` query run against them captures no symbol, no import andno call.@@ -29,7 +30,7 @@ Only the *region-location* step differs per language, so it lives behind:data:`_LOCATORS`; the blanking, fencing, caching and offset invariants areshared. Adding a markup language means adding a :class:`Locator`, not a secondcopy of the walker: grammar-backed for Svelte and Vue, byte-scanned for-Razor, which has no usable tree-sitter grammar (see the ``razor`` locator).+Razor and Astro, which have no usable tree-sitter grammar (see their locators).Binding forms are deliberately skipped rather than kept: Svelte's``{#each items as item}`` and ``{#await}`` heads, and Vue's ``v-for="item in@@ -47,6 +48,7 @@ a :class:`Locator`, no-op unless the language matches.from __future__ import annotations+import refrom collections.abc import Callablefrom functools import lru_cachefrom typing import TYPE_CHECKING, NamedTuple@@ -110,13 +112,15 @@ _SPACE = 0x20_SEMICOLON = 0x3B_OPEN_BRACE = 0x7B_CLOSE_BRACE = 0x7D+_CLOSE_ANGLE = 0x3E_DOUBLE_QUOTE = 0x22_SINGLE_QUOTE = 0x27# Only a byte the scan pointed at *and* that is a real delimiter is ever# rewritten to ``;`` — never a byte that turned out to be part of a kept-# expression. Svelte fences with braces, Vue with attribute quotes.-_FENCE_BYTES = frozenset({_OPEN_BRACE, _CLOSE_BRACE, _DOUBLE_QUOTE, _SINGLE_QUOTE})+# expression. Svelte fences with braces, Vue with attribute quotes, Astro with+# the ``>`` of a script's opening tag.+_FENCE_BYTES = frozenset({_OPEN_BRACE, _CLOSE_BRACE, _DOUBLE_QUOTE, _SINGLE_QUOTE, _CLOSE_ANGLE})class SfcScan(NamedTuple):@@ -144,7 +148,7 @@ class Locator(NamedTuple):Two shapes are supported. A **grammar-backed** locator (Svelte, Vue)parses the file with a tree-sitter markup grammar and ``visit`` walks- every node. A **byte-scanned** locator (Razor) has ``grammar_module`` /+ every node. A **byte-scanned** locator (Razor, Astro) has ``grammar_module`` /``visit`` left as None and ``byte_scan`` instead walks the raw bytes;there is no usable ``tree-sitter-razor`` on PyPI, and an HTML grammaractively mis-parses Razor (``List<Order>`` reads as an HTML element).@@ -159,7 +163,7 @@ class Locator(NamedTuple):# Maps a raw markup tag name to the component name it instantiates, or# None when the tag is not a user component.component_name: Callable[[str], str | None] | None = None- # Byte-scanned locators (Razor): called once with the raw source bytes;+ # Byte-scanned locators (Razor, Astro): called once with the raw source bytes;# appends ``(start, end)`` spans / terminator offsets / ``(name, line)``# component tags to ``state`` exactly like a grammar walk would.byte_scan: Callable[[bytes, dict], None] | None = None@@ -379,7 +383,6 @@ _RAZOR_BLOCK_OPENERS = (b"code", b"functions", b"{")# Razor expression inside ``<!-- -->`` still runs, so only the tag pass skips# them._RAZOR_COMMENT_CLOSE = b"*@"-_HTML_COMMENT_OPEN = b"<!--"_HTML_COMMENT_CLOSE = b"-->"@@ -554,39 +557,33 @@ def _razor_byte_scan(source: bytes, state: dict) -> None:# Skip any ``<`` inside a C# region or a Razor comment: ``List<Order>`` is# a generic type argument, ``a < b`` is a comparison, and a commented-out# tag renders nothing. HTML comments are jumped over for the same reason.- hidden = tuple(state["spans"]) + tuple(comments)+ _byte_scan_tags(source, [*state["spans"], *comments], _razor_component_name, state)- def _is_hidden(offset: int) -> bool:- return any(start <= offset < end for start, end in hidden)+_MARKUP_TAG = re.compile(rb"<(?:!--|([\w.]+))")+++def _byte_scan_tags(+ source: bytes,+ hidden: list[tuple[int, int]],+ name_of: Callable[[str], str | None],+ state: dict,+) -> None:+ """Record ``(name, line)`` for each component tag, skipping ``hidden`` and HTML comments."""pos = 0- while True:- lt = source.find(b"<", pos)- if lt < 0:- break- if _is_hidden(lt):- pos = lt + 1+ while (tag := _MARKUP_TAG.search(source, pos)) is not None:+ pos = tag.end()+ if any(start <= tag.start() < end for start, end in hidden):continue- if source.startswith(_HTML_COMMENT_OPEN, lt):- close = source.find(_HTML_COMMENT_CLOSE, lt + len(_HTML_COMMENT_OPEN))+ if tag.group(1) is None:+ close = source.find(_HTML_COMMENT_CLOSE, pos)pos = len(source) if close < 0 else close + len(_HTML_COMMENT_CLOSE)continue- name_start = lt + 1- name_end = name_start- while name_end < len(source) and (- source[name_end : name_end + 1].isalnum()- or source[name_end : name_end + 1] in (b"_", b".")- ):- name_end += 1- if name_end > name_start:- # A namespace-qualified tag (``<Shared.Grid />``) instantiates the- # last dotted segment.- raw = source[name_start:name_end].decode("utf-8", errors="replace")- name = _razor_component_name(raw.rsplit(".", 1)[-1])- if name:- line = source.count(b"\n", 0, lt) + 1- state["tags"].append((name, line))- pos = lt + 1+ # A namespace-qualified tag (``<Shared.Grid />``) instantiates the last+ # dotted segment.+ name = name_of(tag.group(1).decode("utf-8").rsplit(".", 1)[-1])+ if name:+ state["tags"].append((name, source.count(b"\n", 0, tag.start()) + 1))def _razor_component_name(name: str) -> str | None:@@ -602,6 +599,107 @@ def _razor_component_name(name: str) -> str | None:return name+# ---------------------------------------------------------------------------+# Astro+# ---------------------------------------------------------------------------++# The ``---`` fence opens the file after an optional BOM and any whitespace, as+# in Astro's compiler (``FrontmatterInitial``). Astro also closes on an+# indented ``---`` or one right after a ``;`` / ``}`` on the same line; a+# ``// ---`` divider comment matches neither.+# shortcut: a ``---`` line inside a template literal closes the block early+# (Astro reads strings); fine until a real file does that.+_ASTRO_FRONTMATTER = re.compile(+ rb"\A(?:\xef\xbb\xbf)?\s*---[ \t]*\r?\n(.*?)(?:^[ \t]*|(?<=[;}]))---[ \t]*\r?$",+ re.DOTALL | re.MULTILINE,+)+# ``<!--`` and a markup ``{/* */}`` hide text that may mention ``<script>``; a+# bare ``/*`` is not a comment in markup (``accept="audio/*"``). A ``<style>``+# body is hidden whole, which covers its CSS comments. Case-sensitive: Astro+# reads ``<Script>`` as a component. Attribute values may hold ``>`` (``=>``);+# any other start tag is consumed whole, so ``<script>`` in its values is skipped.+# shortcut: a ``{...}`` value nested 3+ braces deep is not read as an opener;+# widen the brace group once a real file does that.+# shortcut: a ``<script>`` in a JS string of a child ``{...}`` expression still+# opens one (``{cond && <script>}`` must); read JS strings once a real file does that.+_ASTRO_OPENER = re.compile(+ rb"(<!--|\{/\*)|<(?:(script|style)|[A-Za-z][\w.-]*)(?=[\s/>])"+ rb"((?:\"[^\"]*(?:\"|\Z)|'[^']*(?:'|\Z)|\{(?:[^{}]|\{[^{}]*\})*\}|[^>\"'{])*)(?:>|\Z)"+)+_ASTRO_COMMENT_CLOSE = {b"<!--": _HTML_COMMENT_CLOSE, b"{/*": b"*/"}+# An unterminated body runs to EOF (``\Z``).+_ASTRO_CLOSE = {+ b"script": re.compile(rb"</script\s*>|\Z", re.IGNORECASE),+ b"style": re.compile(rb"</style\s*>|\Z", re.IGNORECASE),+}+_ASTRO_SCRIPT_TYPE = re.compile(rb"""(?<![\w.-])type\s*=(?!=)\s*["']?([^"'\s>]+)""", re.IGNORECASE)+# A ``<script>`` with any other ``type`` (``application/ld+json``) holds data.+_ASTRO_JS_TYPES = frozenset(+ {b"module", b"text/javascript", b"application/javascript", b"text/typescript"}+)+++def _astro_byte_scan(source: bytes, state: dict) -> None:+ """Locate the frontmatter, ``<script>`` bodies and component tags of ``.astro`` bytes.++ The leading ``---`` frontmatter and every JS ``<script>`` body (plain,+ ``is:inline``, ``type="module"``, ``define:vars``) project as TypeScript.+ Markup ``{expr}`` and ``<style>`` are blanked, and a ``<script>`` inside an+ HTML or ``{/* */}`` comment or a ``<style>`` body is skipped. PascalCase+ tags in the markup mint component call edges, as for Svelte.+ """+ markup_start = 0+ frontmatter = _ASTRO_FRONTMATTER.match(source)+ if frontmatter:+ state["spans"].append(frontmatter.span(1))+ markup_start = frontmatter.end()+ hidden = _astro_record_scripts(source, markup_start, state)++ # shortcut: a TS generic inside a markup {expr} (``Array<Foo>``) or a tag inside a+ # string reads as a tag; fine until a false component edge shows up in a real repo.+ _byte_scan_tags(source, [*state["spans"], *hidden], _astro_component_name, state)+++def _astro_record_scripts(source: bytes, pos: int, state: dict) -> list[tuple[int, int]]:+ """Record JS ``<script>`` bodies from ``pos`` on; return the comment, script and style ranges."""+ hidden: list[tuple[int, int]] = []+ while (opener := _ASTRO_OPENER.search(source, pos)) is not None:+ if opener.group(1) is not None:+ close_bytes = _ASTRO_COMMENT_CLOSE[opener.group(1)]+ close = source.find(close_bytes, opener.end())+ end = len(source) if close < 0 else close + len(close_bytes)+ hidden.append((opener.start(), end))+ pos = end+ continue+ tag, attrs = opener.group(2), opener.group(3)+ # shortcut: a <script src="./x.ts"> mints no import, so a file loaded+ # only that way reads as unreachable; emit an Import as+ # lightweight_imports/html.py does once a site needs it.+ if tag is None or attrs.rstrip().endswith(b"/"): # another tag, or <script src="..." />+ pos = opener.end()+ continue+ close_match = _ASTRO_CLOSE[tag].search(source, opener.end())+ end = close_match.start()+ if _astro_is_js_script(tag, attrs):+ state["spans"].append((opener.end(), end))+ state["terminators"].append(opener.end() - 1)+ hidden.append((opener.start(), end))+ pos = close_match.end()+ return hidden+++def _astro_is_js_script(tag: bytes, attrs: bytes) -> bool:+ if tag != b"script":+ return False+ script_type = _ASTRO_SCRIPT_TYPE.search(attrs)+ return script_type is None or script_type.group(1).lower() in _ASTRO_JS_TYPES+++def _astro_component_name(name: str) -> str | None:+ """``<Header />`` instantiates a component; ``<div>`` and ``<Fragment>`` do not."""+ return None if name == "Fragment" else _razor_component_name(name)++# ---------------------------------------------------------------------------# Registry# ---------------------------------------------------------------------------@@ -638,6 +736,9 @@ _LOCATORS: dict[str, Locator] = {component_name=_razor_component_name,byte_scan=_razor_byte_scan,),+ # No tree-sitter-astro on PyPI: the ``---`` frontmatter and ``<script>``+ # bodies are byte-scanned and project as TypeScript.+ "astro": Locator(byte_scan=_astro_byte_scan),}@@ -681,7 +782,7 @@ def _cached_scan(language: str, source: bytes) -> SfcScan:locator = _LOCATORS[language]state: dict = {"spans": [], "terminators": [], "tags": []}- # Byte-scanned locator (Razor): no markup grammar exists, so the raw+ # Byte-scanned locator (Razor, Astro): no markup grammar exists, so the raw# bytes are scanned directly. There is no tree to carry a parse-error# flag, and a byte scan cannot mis-parse, so ``has_error`` stays False.if locator.byte_scan is not None:diff --git a/packages/core/src/repowise/core/ingestion/tsconfig_resolver.py b/packages/core/src/repowise/core/ingestion/tsconfig_resolver.pyindex 4d9543fce..143ff8a33 100644--- a/packages/core/src/repowise/core/ingestion/tsconfig_resolver.py+++ b/packages/core/src/repowise/core/ingestion/tsconfig_resolver.py@@ -514,7 +514,7 @@ def wire_tsconfig_resolver("""# Svelte counts: a SvelteKit app's aliases live in its tsconfig, and a# .svelte component's imports go through the same TS/JS resolver.- _ts_langs = {"typescript", "javascript", "svelte", "vue"}+ _ts_langs = {"typescript", "javascript", "svelte", "vue", "astro"}# We duck-type graph_builder to avoid circular imports. It has ._parsed_files.parsed_files = graph_builder._parsed_files.values()diff --git a/packages/core/src/repowise/core/pipeline/phases/ingestion.py b/packages/core/src/repowise/core/pipeline/phases/ingestion.pyindex 69854f752..993cb97a3 100644--- a/packages/core/src/repowise/core/pipeline/phases/ingestion.py+++ b/packages/core/src/repowise/core/pipeline/phases/ingestion.py@@ -614,7 +614,7 @@ async def _run_ingestion(# Only runs when the repo has TS/JS files. On large TS monorepos the# resolver indexes hundreds of tsconfig files up-front; without a phase# label this shows up as a silent gap right after parsing.- _ts_langs = {"typescript", "javascript", "svelte", "vue"}+ _ts_langs = {"typescript", "javascript", "svelte", "vue", "astro"}if any(pf.file_info.language in _ts_langs for pf in parsed_files):if progress:progress.on_phase_start("tsconfig", None)diff --git a/tests/unit/dead_code/test_convention_never_flag.py b/tests/unit/dead_code/test_convention_never_flag.pyindex f83d60cb6..eba61001d 100644--- a/tests/unit/dead_code/test_convention_never_flag.py+++ b/tests/unit/dead_code/test_convention_never_flag.py@@ -52,6 +52,23 @@ def test_js_tool_convention_files_are_never_flagged(path):assert not _unreachable(path)+ "path",+ [+ # Astro pages and endpoints: routed by their path under src/pages, never imported.+ "src/pages/index.astro",+ "apps/web/src/pages/blog/[slug].astro",+ "src/pages/robots.txt.ts",+ "apps/site/src/pages/api/products/[id].json.ts",+ "src/pages/rss.xml.js",+ "src/pages/feed.json.mjs",+ ],+)+def test_astro_routes_are_never_flagged(path):+ assert never_flag_match(path)+ assert not _unreachable(path)++@pytest.mark.parametrize("path",[@@ -78,6 +95,8 @@ def test_python_startup_hooks_are_never_flagged(path):"src/httpproxy.ts","src/mysitecustomize.py","src/sitecustomize_helpers.py",+ "src/lib/pages/format.ts", # a pages dir outside src/pages routes nothing+ "src/components/Header.astro",],)def test_near_misses_stay_flaggable(path):diff --git a/tests/unit/ingestion/test_astro_extractors.py b/tests/unit/ingestion/test_astro_extractors.pynew file mode 100644index 000000000..3d6d507fb--- /dev/null+++ b/tests/unit/ingestion/test_astro_extractors.py@@ -0,0 +1,266 @@+"""Astro end-to-end extraction: symbols, imports, calls, health, dead code."""++from __future__ import annotations++import time+from datetime import datetime++import pytest++from repowise.core.ingestion.models import EXTENSION_TO_LANGUAGE, FileInfo+from repowise.core.ingestion.parser import ASTParser+from repowise.core.ingestion.sfc_source import prepare_source, scan++_PAGE = b"""---+import Header from '../components/Header.astro';+import { formatDate } from '../lib/format';++export const prerender = true;++export async function getStaticPaths() {+ return [{ params: { slug: 'a' } }];+}++const title = formatDate(new Date());+---+<html>+ <body>+ <Header title={title} />+ <p>{title}</p>+ </body>+</html>+<script>+ function toggleMenu() {+ document.body.classList.toggle('open');+ }+</script>+<style>+ .open { color: red; }+</style>+"""+++def _file(path: str = "src/pages/index.astro", size: int = len(_PAGE)) -> FileInfo:+ return FileInfo(+ path=path,+ abs_path=f"/repo/{path}",+ language="astro",+ size_bytes=size,+ git_hash="",+ last_modified=datetime.now(),+ is_test=False,+ is_config=False,+ is_api_contract=False,+ is_entry_point=False,+ )++[email protected](scope="module")+def parser() -> ASTParser:+ return ASTParser()++[email protected](scope="module")+def parsed(parser: ASTParser):+ return parser.parse_file(_file(), _PAGE)+++def test_astro_extension_is_indexed() -> None:+ assert EXTENSION_TO_LANGUAGE[".astro"] == "astro"+++class TestProjection:+ def test_markup_and_style_are_blanked(self) -> None:+ prepared = prepare_source("astro", _PAGE)+ assert b"<html>" not in prepared+ assert b"color: red" not in prepared+ assert b"---" not in prepared++ @pytest.mark.parametrize(+ "opener",+ [+ b"<script is:inline>",+ b'<script type="module">',+ b"<script define:vars={{ a }}>",+ b'<script data-type="x">',+ b"<script define:vars={{ dark: theme.type === 'dark' }}>",+ ],+ )+ def test_every_js_script_variant_is_kept(self, opener: bytes) -> None:+ src = opener + b"\n const kept = 1;\n</script>\n"+ assert b"const kept = 1;" in prepare_source("astro", src)++ def test_data_and_commented_scripts_are_blanked(self) -> None:+ src = (+ b'<script type="application/ld+json">{"@type": "Thing"}</script>\n'+ b"<!-- <script>const dead = 1;</script> -->\n"+ b"{/* the emitted <script> sits here */}\n"+ b"<style>/* <script>const css = 1;</script> */</style>\n"+ )+ assert prepare_source("astro", src).strip() == b""++ def test_a_markup_glob_or_self_closing_style_hides_no_script(self) -> None:+ src = (+ b'<input accept="audio/*" />\n<style is:global />\n'+ b"<script>\n function later() {}\n</script>\n"+ )+ assert b"function later() {}" in prepare_source("astro", src)++ @pytest.mark.parametrize(+ "tag",+ [+ b'<div title={"<script>const fake = 1;</script>"} />',+ b'<div title="<script>const fake = 1;</script>">',+ b'<Code code={`<script>const fake = 1;</script>`} lang="html" />',+ ],+ )+ def test_a_script_inside_an_attribute_value_is_not_an_opener(self, tag: bytes) -> None:+ assert b"fake" not in prepare_source("astro", tag)+++_CARD = b"import Card from './Card.astro';"+++# Expected imports and tags are what Astro's compiler (@astrojs/compiler-rs+# 0.4.1) reads from the same bytes; a dotted tag keeps its last segment.+ ("src", "imports", "tags"),+ [+ pytest.param(b"---\n" + _CARD + b"\n---\n<Card />", ["./Card.astro"], ["Card"], id="plain"),+ pytest.param(+ b"---\n" + _CARD + b"---\n<Card />", ["./Card.astro"], ["Card"], id="same-line"+ ),+ pytest.param(+ b"---\n" + _CARD + b"\n ---\n<Card />", ["./Card.astro"], ["Card"], id="indented"+ ),+ pytest.param(+ b"\xef\xbb\xbf---\n" + _CARD + b"\n---\n<Card />", ["./Card.astro"], ["Card"], id="bom"+ ),+ pytest.param(+ b"\n---\n" + _CARD + b"\n---\n<Card />", ["./Card.astro"], ["Card"], id="leading-blank"+ ),+ pytest.param(+ b"---\r\n"+ + _CARD+ + b"\r\n---\r\n<Card />\r\n<script>\r\nconst x = 1;\r\n</script>\r\n",+ ["./Card.astro"],+ ["Card"],+ id="crlf",+ ),+ pytest.param(b"---\n---\n<Card />", [], ["Card"], id="empty"),+ pytest.param(+ b"---\n// ----------\n" + _CARD + b"\n---\n<Card />",+ ["./Card.astro"],+ ["Card"],+ id="divider-comment",+ ),+ pytest.param(+ b"---\n" + _CARD + b"\nconst p: Promise<Post[]> = f();\n---\n<Card />",+ ["./Card.astro"],+ ["Card"],+ id="frontmatter-generic",+ ),+ pytest.param(+ b'<Script src="x"><Card /></Script>', [], ["Script", "Card"], id="pascal-script"+ ),+ pytest.param(b"<script-loader><Card /></script-loader>", [], ["Card"], id="script-dash"),+ pytest.param(+ b'<script type="application/ld+json" set:html={JSON.stringify(xs.map((i) => ({ n: i })))} />'+ b"\n<Card />",+ [],+ ["Card"],+ id="arrow-in-attr",+ ),+ pytest.param(b"<!-- <Card /> -->{/* <Other /> */}<Real />", [], ["Real"], id="comments"),+ pytest.param(b"<Icons.Star />", [], ["Star"], id="dotted"),+ pytest.param(b"<Fragment><Card /></Fragment>", [], ["Card"], id="fragment"),+ ],+)+def test_matches_the_astro_compiler(parser, src: bytes, imports: list, tags: list) -> None:+ result = parser.parse_file(_file(size=len(src)), src)+ assert [i.module_path for i in result.imports] == imports+ assert [name for name, _line in scan("astro", src).component_tags] == tags+ assert result.parse_errors == []+ prepared = prepare_source("astro", src)+ assert (len(prepared), prepared.count(b"\n")) == (len(src), src.count(b"\n"))+++def test_an_unterminated_script_runs_to_eof() -> None:+ src = b"<script>\nconst a = 1;\n<Card />"+ assert scan("astro", src).component_tags == ()+ assert b"const a = 1;" in prepare_source("astro", src)+++def test_an_unclosed_quote_scans_in_linear_time() -> None:+ start = time.perf_counter()+ prepare_source("astro", b'<a "' * 20_000)+ assert time.perf_counter() - start < 1+++def test_a_script_does_not_run_into_the_frontmatter(parser) -> None:+ # No ``;`` after ``Astro.props``: unfenced, the IIFE reads as a call on it.+ src = b"---\nconst { t } = Astro.props\n---\n<script>(function () { function setTheme() {} })()</script>"+ result = parser.parse_file(_file(size=len(src)), src)+ assert ({s.name for s in result.symbols}, result.calls) == ({"setTheme", "Pages"}, [])+++class TestSymbols:+ def test_frontmatter_and_script_symbols_at_their_source_lines(self, parsed) -> None:+ lines = {s.name: s.start_line for s in parsed.symbols if s.name != "Pages"}+ assert lines == {"prerender": 5, "getStaticPaths": 7, "title": 11, "toggleMenu": 20}++ def test_the_file_itself_becomes_a_component_symbol(self, parsed) -> None:+ # ``index`` defers to its directory, as for Vue.+ page = [s for s in parsed.symbols if s.name == "Pages"]+ assert len(page) == 1+ assert page[0].kind == "class"+ assert page[0].start_line == 1++ def test_a_kebab_file_is_named_as_its_tag(self, parser) -> None:+ src = b"<button>Top</button>\n"+ result = parser.parse_file(_file("src/components/back-to-top.astro", len(src)), src)+ assert [s.name for s in result.symbols] == ["BackToTop"]++ def test_frontmatter_exports(self, parsed) -> None:+ assert set(parsed.exports) == {"prerender", "getStaticPaths", "Pages"}++ def test_no_parse_errors_on_a_well_formed_page(self, parsed) -> None:+ assert parsed.parse_errors == []+++class TestImports:+ def test_named_bindings_are_extracted(self, parsed) -> None:+ fmt = next(i for i in parsed.imports if i.module_path == "../lib/format")+ assert [b.local_name for b in fmt.bindings] == ["formatDate"]+++class TestCalls:+ def test_frontmatter_calls_are_extracted(self, parsed) -> None:+ assert "formatDate" in {c.target_name for c in parsed.calls}++ def test_markup_component_tags_become_calls(self, parsed) -> None:+ header = [c for c in parsed.calls if c.target_name == "Header"]+ assert [c.line for c in header] == [15]+++class TestCodeHealth:+ def test_complexity_is_measured_on_the_frontmatter(self) -> None:+ from repowise.core.analysis.health.complexity.walker import walk_file++ result = walk_file("/repo/src/pages/index.astro", "astro", _PAGE)+ assert next(f for f in result.functions if f.name == "getStaticPaths").start_line == 7++ def test_perf_and_dataflow_dialects_are_registered(self) -> None:+ from repowise.core.analysis.health.dataflow.dialects import DEFUSE_DIALECTS+ from repowise.core.analysis.health.perf.dialects import PERF_DIALECTS++ assert "astro" in PERF_DIALECTS+ assert "astro" in DEFUSE_DIALECTS+++class TestDeadCode:+ def test_framework_exports_are_never_flagged_as_unused(self) -> None:+ # `prerender` / `getStaticPaths` are read by Astro, never imported by name.+ from repowise.core.analysis.dead_code.analyzer import _non_importable_kinds++ assert {"constant", "variable", "function", "class"} <= _non_importable_kinds("astro")diff --git a/tests/unit/ingestion/test_language_capabilities.py b/tests/unit/ingestion/test_language_capabilities.pyindex e33506d78..01baf14d4 100644--- a/tests/unit/ingestion/test_language_capabilities.py+++ b/tests/unit/ingestion/test_language_capabilities.py@@ -157,6 +157,9 @@ class TestParityGoldens:# ---------------------------------------------------------------------------_FULL = {+ # astro projects its frontmatter and <script> bodies to TypeScript+ # through the same SFC pass as svelte, so its imports are ordinary ESM.+ "astro","c","cpp","csharp",diff --git a/tests/unit/ingestion/test_ts_framework_edges.py b/tests/unit/ingestion/test_ts_framework_edges.pyindex cfcfc0334..2c5ecd8d9 100644--- a/tests/unit/ingestion/test_ts_framework_edges.py+++ b/tests/unit/ingestion/test_ts_framework_edges.py@@ -119,6 +119,24 @@ class TestRemixConvention:add_framework_edges(graph, parsed, ctx, tech_stack=["remix"])assert not graph.has_edge("app/routes/foo.test.tsx", "utils/auth.ts")+ def test_astro_page_links_to_helper(self, tmp_path: Path) -> None:+ (tmp_path / "src" / "lib").mkdir(parents=True)+ (tmp_path / "src" / "lib" / "db.ts").write_text("export const db = {};\n")+ (tmp_path / "src" / "pages").mkdir()+ page = tmp_path / "src" / "pages" / "index.astro"+ page.write_text("---\nimport { db } from '../lib/db';\n---\n<p>{db}</p>\n")+ parsed = _build_parsed(tmp_path)+ rel = "src/pages/index.astro"+ parsed[rel] = ASTParser().parse_file(+ _file_info(rel, str(page.resolve()), "astro"), page.read_bytes()+ )+ graph = nx.DiGraph()+ for p in parsed:+ graph.add_node(p)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=[])+ assert graph.has_edge(rel, "src/lib/db.ts")+class TestTrpc:def test_procedure_query_links_handler(self, tmp_path: Path) -> None: