Skip to content

fix: replace shell syntax in run() calls with safe array args#308

Open
TerminalGravity wants to merge 2 commits intomainfrom
fix/shell-syntax-in-run-302
Open

fix: replace shell syntax in run() calls with safe array args#308
TerminalGravity wants to merge 2 commits intomainfrom
fix/shell-syntax-in-run-302

Conversation

@TerminalGravity
Copy link
Collaborator

Fixes #302

run() uses execFileSync('git', ...) without a shell, but 8 tool files were passing strings with shell operators (2>/dev/null, pipes, &&, redirects) that got split on whitespace and passed as literal git args — causing silent failures.

Changes

  • Add exec(), countLines(), countBytes(), headLines() helpers to git.ts
  • Convert all run() calls to use array args for git commands
  • Replace shell pipelines (grep, wc, head, tail) with Node.js equivalents
  • Fix checkpoint.ts to use separate run() calls instead of && chaining
  • Replace command -v with which via exec() helper

Affected files (all 8 from the issue)

  • token-audit.ts
  • enrich-agent-task.ts
  • clarify-intent.ts
  • audit-workspace.ts
  • sharpen-followup.ts
  • session-handoff.ts
  • sequence-tasks.ts
  • checkpoint.ts

All tests pass, tsc --noEmit clean.

The interactive setup wizard (npx preflight-dev init) was buried in a
footnote under Option C, despite being the most user-friendly onboarding
path. Moved it to Option A with a clear description of what it does.
Renumbered remaining options accordingly.
run() uses execFileSync without a shell, so shell operators like
2>/dev/null, pipes, &&, and redirects were passed as literal args,
causing silent failures across 8 tool files.

Changes:
- Add exec(), countLines(), countBytes(), headLines() helpers to git.ts
- Convert all run() calls to use array args for git commands
- Replace shell pipelines (grep, wc, head, tail) with Node.js equivalents
- Fix checkpoint.ts to use separate run() calls instead of && chaining
- Replace 'command -v' with 'which' via exec() helper

Fixes #302
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.

Shell syntax passed to run() across multiple tools

1 participant