Repository navigation
Parse extensionless Python and Node scripts by their shebang - #52
Open
FredAmartey wants to merge 1 commit into
Open
FredAmartey wants to merge 1 commit into
FredAmartey wants to merge 1 commit into
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.
jevgrep picks a file's language from its extension. An executable script with no extension, such as
bin/toolstarting with#!/usr/bin/env python3, gets the plain-text fallback: no declaration units, no sampled Python preview, no call context and no test-body selection. Repos that ship their CLIs as extensionless scripts lose the structure-aware path for exactly those files.resolveLanguage(path, source)insource.tsis now the one place that decides a file's language, and every extension check in core calls it. The extension still decides first. Only a file with no extension reads its first line: an interpreter namedpython,python3orpython3.Nmeans Python, whether it is a direct path or comes throughenv(which skips env's options, their operands andNAME=VALUEassignments), andnodeornodejsmeans JavaScript. Anything else keeps the text fallback. The preview worker now receives the resolved language instead of the path.Files with an extension send the same requests as before. For an extensionless script that resolves to a language, request contents change the way they already do for the same file with the extension. Request schemas, the
extensionfield and cache keys are unchanged.What a caller sees, one question per repo:
git-filter-repo.py(three runs each). That is no better than main here: main's text chunks also land on the option parser and the filtering method, and output grows from 13 to 37 KB to 48 to 57 KB because whole declarations come back. That size is the existing Python path, not something this change adds.Validation on macOS arm64, Bun 1.3.14, Node 26.7:
test/parser/source.test.tscheck that Python and Node shebang scripts inspect exactly like the same file named.pyor.js. One intest/retrieval.test.tschecks that provider requests and returned evidence match the.pyor.jsfile apart from the path andextensionfield. The fallback table gains cases for no shebang, bash, a shebang below line 1, and a mismatched extension winning.node --experimental-strip-types --test test/parser/*.test.ts: 41 passed.bun test --timeout 30000 ./apps/cli/test ./packages/core/test ./test/discovery.test.ts ./test/evaluator.test.ts ./test/retrieval.test.ts ./test/retrieval-freshness.test.ts: 59 passed, 81 Docker-only skipped.bun run check-typespassed.bun run lint: 0 errors, the one existing warning in@repo/core.oxfmt --checkpassed on the 9 changed files.test:installed.test/skill.test.mjsfails the same way on main on this machine (installer exit 1 instead of 7).