feat(ast/powershell): Support powershell for codegraph#913
Open
weburnit wants to merge 1 commit into
Open
Conversation
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
Adds first-class PowerShell indexing to CodeGraph for scripts and modules:
powershell) —.ps1,.psm1, and.psd1are detected and parsed.tree-sitter-powershell.wasmfromtree-sitter-powershell@0.26.4after ABI/runtime health check.using module,Import-Module, and dot-sourced script imports.What Changed
12 files touched, including 1 vendored WASM grammar:
src/types.ts— addspowershellto theLanguageunion.src/extraction/grammars.ts— maps.ps1/.psm1/.psd1, loads the vendored PowerShell WASM, and adds the display name.src/extraction/languages/powershell.ts(new) — PowerShell extractor for functions, classes, members, enums, imports, command calls, and signatures.src/extraction/languages/index.ts— registers the PowerShell extractor.src/extraction/wasm/tree-sitter-powershell.wasm(new) — vendored ABI-15 tree-sitter grammar.src/extraction/tree-sitter.ts— handles PowerShell enum-member names, module-level assignments, class inheritance, and command/import extraction inside function bodies.src/resolution/import-resolver.ts— resolves PowerShell module/script imports to file nodes.src/resolution/name-matcher.ts— adds case-insensitive exact-name fallback for PowerShell commands and symbols.src/resolution/index.ts— lets the resolver pre-filter accept case-insensitive PowerShell matches.__tests__/extraction.test.ts— adds language detection, symbol extraction, and cross-file resolution coverage.README.md— documents PowerShell in supported languages.CHANGELOG.md— adds an[Unreleased]user-facing entry.Why
PowerShell automation repos are often split across
.psm1modules, dot-sourced.ps1helper scripts, and command-style function calls. Before this change, CodeGraph treated those files as unsupported, so agents had to fall back to file reads and grep to understand script/module flows.This completes the static-processing path for common PowerShell projects: CodeGraph can now find PowerShell entry points, trace calls between functions, and surface module/script dependencies without reading every script by hand.
Design Decisions
tree-sitter-powershell.wasmtree-sitter-wasmsdoes not ship PowerShell; the npm grammar ships a healthy ABI-15 WASM..ps1,.psm1, and.psd1commandAST nodesGet-Thing -Name x), not conventionalcall_expressionsyntax.using module,Import-Module, and dot-sourcing as imports& $cmdor wildcard dot-sourcing are runtime-dynamic; missing an edge is safer than creating a wrong one.Verification
Test Coverage
.ps1,.psm1, and.psd1detect aspowershell;.ps1is accepted as a source file.powershellappears ingetSupportedLanguages().using module/Import-Modulestatic paths.class Child : Base.using module ./Private/Helpers.psm1to the helper module file.find-widgetto functionFind-Widget.Migration
None. PowerShell support is additive. No schema changes and no breaking changes.
Existing projects should re-index to pick up PowerShell files:
For a new PowerShell project: