fix: broken shell commands in token_audit and what_changed tools - #214
Open
TerminalGravity wants to merge 3 commits into
Open
fix: broken shell commands in token_audit and what_changed tools#214TerminalGravity wants to merge 3 commits into
TerminalGravity wants to merge 3 commits into
Conversation
TerminalGravity
commented
Mar 11, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed. The root cause analysis is spot-on — run() wrapping everything with git prefix makes all those shell-string calls silently fail.
The approach is solid:
shell()helper — clean, timeout-protected, appropriate escape hatch for genuine shell needs- Node
fsreplacements —countLines()andfileBytes()are better than shelling out anyway. No parsing, no injection risk. what-changed.ts— removing the double-git prefix and fixing fallback logic
One thing to watch: shell() returns empty string on failure, same as run(). Fine for now, but if downstream code ever needs to distinguish 'empty output' from 'command failed', we might want an option to throw. Not blocking — can address in the follow-up for the remaining ~8 affected files listed in #215.
README and troubleshooting additions are a nice bonus. LGTM — ready to merge.
This was referenced Mar 11, 2026
Shows 4 concrete scenarios: vague prompt clarification, multi-step scoping, correction pattern matching, and cross-service awareness. Each example includes the prompt, triage classification, and the actual output users can expect.
The README and examples/README.md referenced examples/.preflight/ but the actual config files didn't exist. Added: - config.yml — profile, related projects, thresholds, embeddings - triage.yml — keyword rules and strictness settings - contracts/api.yml — manual contract definition examples All files are heavily commented so users can copy them into their project root and customize without needing to reference the docs.
The tool used run() (which calls execFileSync('git', ...)) for non-git
commands like wc and tail. These would silently fail since 'wc' and 'tail'
were passed as arguments to git, not as separate commands.
Replaced with Node.js APIs:
- countFileLines() using readFileSync for line counting
- getFileSize() using statSync for byte size
- readFileTail() using fs read with offset for large file tailing
- Git calls now use array syntax instead of string with shell redirects
Also removed the now-unused shellEscape helper.
TerminalGravity
force-pushed
the
fix/token-audit-shell-commands
branch
from
March 16, 2026 16:16
1c7aac9 to
acdfb8b
Compare
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.
Problem
run()fromlib/git.tsusesexecFileSync('git', args)— it always prependsgitand doesn't support shell features. Multiple tools were calling it with:run('git diff ...')→ executesgit git diff ...2>/dev/nullpassed as a literal argument to gitrun('wc -l ...')→ executesgit wc -l ...This means
token_auditwas completely non-functional — every command it ran would fail silently and return error strings.Fix
token-audit.ts: Replace shell-dependentrun()calls with NodefsAPIs (countLines,fileBytes) and properrun()array argswhat-changed.ts: Fix double-gitprefix and shell fallback logiclib/git.ts: Addshell()export for cases that genuinely need shell features (pipes, redirects,||fallbacks)Scope
This PR fixes the two worst-affected tools. ~8 other files have the same bug pattern — filing a separate issue for those.