Skip to content

bug: .astro extension missing from CODE_EXTENSIONS — Astro projects' SFCs invisible to code sync #709

@johnybradshaw

Description

@johnybradshaw

Summary

.astro files are skipped by gbrain sync --strategy code because the extension isn't in CODE_EXTENSIONS at src/core/sync.ts:46-75. Astro projects (a popular static-site framework — official template count is in the low thousands on GitHub) have most of their app surface in .astro files; gbrain currently treats them as invisible.

Repro

$ find . -name "*.astro" ! -path "*/node_modules/*" | wc -l
253

$ gbrain sync --source <id> --strategy code --no-embed
Found 14 markdown files       # 0 .astro
…
$ gbrain code-def InsightLayout
{ "symbol": "InsightLayout", "count": 0, "results": [] }

(InsightLayout is defined in src/layouts/InsightLayout.astro — invisible to the walker.)

Root cause

src/core/sync.ts:46-75 declares the allowlist:

const CODE_EXTENSIONS = new Set<string>([
  '.ts', '.tsx', '.mts', '.cts',
  '.js', '.jsx', '.mjs', '.cjs',
  '.py', '.rb', '.go', '.rs', '.java', '.cs',
  '.cpp', '.cc', '.cxx', '.hpp', '.hxx', '.hh',
  '.c', '.h',
  '.php', '.swift', '.kt', '.kts', '.scala', '.sc',
  '.lua', '.ex', '.exs', '.elm', '.ml', '.mli',
  '.dart', '.zig', '.sol',
  '.sh', '.bash',
  '.css', '.html', '.htm',
  '.vue',                       // ← Vue SFC supported
  '.json', '.yaml', '.yml', '.toml',
]);

Note .vue is included (Vue single-file components). .astro is the structural equivalent for Astro: a top frontmatter block (TypeScript) plus a JSX-like template body. Same single-file-component shape, same need for code-aware indexing.

The comment at line 35-44 says this allowlist is "kept as-is for now for isAllowedByStrategy fast-path + tests" while detectCodeLanguage is the long-term source of truth — so .astro may also need adding to whatever map detectCodeLanguage uses, depending on which one wins at runtime.

Suggested fix

Add .astro to CODE_EXTENSIONS:

'.vue', '.astro',

Tree-sitter doesn't ship a first-party Astro grammar, but the existing fallback path that handles .vue and .html should chunk .astro reasonably (frontmatter as TS-ish, body as HTML-ish). If a richer parse is wanted later, @astrojs/compiler exposes a tokenizer that returns spans usable by the chunker.

Why it matters

Astro is the framework behind many docs sites and Field-CTO-style personal hubs (this repo is one — bradshaw.cloud). Without .astro support, gbrain code-def / code-refs / code-callers return empty for the bulk of the app code, even after the source-routing bug in #457 is fixed.

Environment

Related

  • bug: code indexing doesn't work as expected (or at all) #457 (source-routing + --strategy code ignored). My v0.28.7 reproduction comment on that issue surfaced this gap as adjacent. Filing separately per the maintainer's labeling cadence — this one is small enough to be a good-first-issue candidate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions