Skip to content

feat(elixir): add Phoenix framework resolver and Elixir import resolution#1229

Open
waseigo wants to merge 9 commits into
colbymchenry:mainfrom
waseigo:feat/elixir-phoenix
Open

feat(elixir): add Phoenix framework resolver and Elixir import resolution#1229
waseigo wants to merge 9 commits into
colbymchenry:mainfrom
waseigo:feat/elixir-phoenix

Conversation

@waseigo

@waseigo waseigo commented Jul 9, 2026

Copy link
Copy Markdown

Elixir alias/import/require/use directives now resolve to the actual files they pull in, so cross-module callers and impact queries work on real Elixir codebases instead of stopping at the import site.

Phoenix router files (router.ex) are now parsed: route definitions link to their controller actions, so "what URL pattern calls this controller method" shows up in callers and flow traces.

Elixir standard library and OTP modules (Kernel, Enum, Map, GenServer, and friends) are now marked as external, so they don't clutter the graph or inflate impact results.

waseigo added 9 commits July 6, 2026 03:45
- The Elixir grammar treats ALL constructs as generic `call` nodes — no distinct node types for def/module/import
- Uses `visitNode` hook with keyword-set dispatch (DEF_CALLS, MODULE_CALLS, IMPORT_CALLS, SKIP_CALLS)
- Supports: def/defp, defguard/defguardp, defdelegate, defmacro/defmacrop, defmodule, defprotocol/defimpl, alias/import/require/use
- Multi-clause def merging (same pattern as `erlang.ts`)
- Pipe `|>` excluded from call edges (data flow)
- `extractFunctionInfo` handles: simple def, guarded def (when), no-parens def, defdelegate
- `extractBareCall` for function body call edges
- Uses `findChildByType(node, type)` helper — Elixir grammar uses type-identified named children, not field-named children
- Also wire `.ex` and `.exs` extensions to `elixir` language, register in WASM grammars and display names
- HEEx grammar built from source (phoenixframework/tree-sitter-heex v0.9.0, ABI 15)
- Vendored WASM at `src/extraction/wasm/tree-sitter-heex.wasm` (33KB)
- HEEx is NOT in tree-sitter-wasms (not on npm) — must be built manually
- Extractor handles: `<.component_name>` tags, `<PascalCase>` components → `component` nodes
- `{expr}` expressions and `<%= directive %>` tags → call edges
- `.heex` extension wired to `heex` language in grammars.ts EXTENSION_MAP, WASM_GRAMMAR_FILES
- Implements `AgentTarget` interface modeled on `codex.ts` (both use TOML MCP config)
- Supports global `~/.grok/config.toml` with `$GROK_HOME` override, and local `.grok/config.toml`
- Uses existing `toml.ts` helpers: `buildTomlTable`, `upsertTomlTable`, `removeTomlTable`
- Cross-platform detection: `command -v` (POSIX), `where` (Windows), file existence fallback
- No permissions concept (like Codex target)
- 12 Elixir extraction tests: defmodule, def/defp, alias imports, calls, pipe skip, defguard, defdelegate, defstruct skip, defprotocol, defimpl, defmacro
- 4 HEEx extraction tests: <.modal> component, <MyComponent> component, {expr} calls, <%= directive %> calls
- All use `extractFromSource()` in-memory helper (standard pattern for all languages)
- Unique file paths per test to avoid multi-clause merge state interference
- README: Elixir in feature bullet (30+ Languages), Supported Languages table row, Grok Build in Supported Agents list (badge + subtitle + installer + quick start + restart + footer)
- CHANGELOG: Entries under `## [Unreleased]` for Elixir language support and Grok Build agent support
- 3 repos: elixir-lang/gen_stage (small, 23 files), phoenixframework/phoenix (medium, 177 files), plausible/analytics (large, 1,186 files)
- Each repo has a cross-file architecture question
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.

1 participant