Repository navigation
feat(parsers): add PowerShell language support - #350
Merged
e91d82c73 merged 1 commit intoJun 29, 2026
Merged
Conversation
Route .ps1/.psm1 files through a dedicated tree-sitter mapping so PowerShell users get function/class/method/property/enum-aware chunks instead of the generic UNKNOWN text fallback (which only emits ~2 untyped chunks per file). The grammar already ships with tree-sitter-language-pack, so this wires it via the existing _LanguagePackWrapper path (no new dependency), mirroring matlab/swift. The mapping routes ChunkType purely on the "kind" metadata and never exposes the raw node_type: PowerShell's class_method_definition / class_property_definition node types both contain the substring "class", which the router's `"class" in node_type` check would otherwise mis-route to ChunkType.CLASS. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Collaborator
|
Clean, minimal PowerShell support that follows the established patterns. Support for DATA sections and |
ofriw
added a commit
that referenced
this pull request
Jul 6, 2026
…CP read-only, and fixes Merge main into matryoshka-fix-6-26. main changes incorporated: - DuckDB compaction with atomic swap (#339) - PowerShell (#350) and Metal (#351) language parsers - MCP --read-only flag (#329) - Research per-step timing (#355) - Various fixes: websearch late-completion guard, quickresearch orphan cleanup, token literal counting, claude-cli auto-updater - openai_compatible in factory's supported_providers() Conflict resolution: chunkhound/services/realtime_indexing_service.py was deleted on main (dead code, no production callers). The branch's ModuleType __class__ hack + its test were removed to match.
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.
What
Adds first-class PowerShell support to ChunkHound.
.ps1/.psm1files nowroute through a dedicated tree-sitter mapping that emits
function/class/method/property/enum-aware chunks instead of falling through to
the generic
UNKNOWNtext parser.Why
On
main, PowerShell files are unsupported:detect_languagereturnsLanguage.UNKNOWNand a.ps1file yields only a couple of untyped fallbackchunks. PowerShell users (and AI assistants searching their codebases) get no
function/class/method structure to search against. This change gives them the
same typed, semantically-aware chunking every other supported language already
enjoys.
How
The PowerShell grammar already ships with
tree-sitter-language-pack, so nonew pip dependency is needed. It is wired via the existing
_LanguagePackWrapperpath (_get_lang("powershell")), exactly likematlab/swift/objc.New
PowerShellMapping(chunkhound/parsers/mappings/powershell.py) maps thereal grammar node types:
function_statementfunctionandfilter)class_statementclass_method_definitionclass_property_definitionenum_statementLandmine handled: the router in
universal_parsercheckselif kind == "class" or "class" in node_type. Bothclass_method_definitionandclass_property_definitioncontain thesubstring
"class", so exposing the rawnode_typewould mis-route methodsand properties to
ChunkType.CLASS. The mapping therefore routes on thekindmetadata only and never setsnode_type.Touchpoints
chunkhound/core/types/common.py—Language.POWERSHELL;.ps1/.psm1in the detection extension map; added to
is_programming_languageandsupports_classes.chunkhound/parsers/parser_factory.py— language-pack wrapper, mappingimport,
LANGUAGE_CONFIGSentry,EXTENSION_TO_LANGUAGEentries.chunkhound/parsers/mappings/powershell.py— new mapping.chunkhound/parsers/mappings/__init__.py— export.tests/test_powershell_mapping.py; PowerShell samples added totest_parsers.py,test_language_extensions.py,test_e2e_chunk_size_constraints.py,test_qa_deterministic.py.Evidence (before → after)
1. Routing flips (wiring proof)
2. Typed chunks (behavior proof)
mainonly emits a couple of untyped fallback chunks for a.ps1. On thisbranch, parsing through the real parser
(
create_parser(Language.POWERSHELL).parse_content(...)) yields:The new contract test (
tests/test_powershell_mapping.py) assertsChunkType.FUNCTION == "Get-Foo",ChunkType.CLASS == "Widget",ChunkType.METHOD == "Spin",ChunkType.PROPERTY == "Size"— typed symbols theUNKNOWN fallback cannot produce, so the test fails on
mainand passes here.3. CLI end-to-end (real pipeline)
Quality gate
pytest tests/test_powershell_mapping.py tests/test_language_extensions.py tests/test_parsers.py— 145 passedpytest tests/test_smoke.py -n auto— 18 passed (mandatory gate)ruff checkon changed files — clean (the only remaining ruff hits arepre-existing import-ordering issues already present on
main)mypy chunkhound/parsers/mappings/powershell.py— cleanNote on the new-language coverage tests
Languageenum members are guarded by coverage tests(
test_qa_deterministic,test_e2e_chunk_size_constraints,test_parsers) that require a sample for every language; PowerShell sampleswere added to each. Pre-existing, unrelated full-suite failures on this machine
(node/
tests/site/*build tests,git tagdocs-version contract tests, and amakefile chunk-size assertion) reproduce identically on clean
mainand arenot touched by this change.
Notes / scope
.psd1(data manifests) is intentionally not routed to the PS grammar —.ps1and.psm1are the script extensions that benefit from code-awarechunking.
under the generic cAST greedy-merge, identical to every other language — this
is existing chunking behavior, not PowerShell-specific.