Skip to content

fix: shell commands silently broken — run() used execFileSync without shell#46

Closed
TerminalGravity wants to merge 6 commits intomainfrom
fix/session-health-diff-stat
Closed

fix: shell commands silently broken — run() used execFileSync without shell#46
TerminalGravity wants to merge 6 commits intomainfrom
fix/session-health-diff-stat

Conversation

@TerminalGravity
Copy link
Copy Markdown
Collaborator

Problem

run() in lib/git.ts uses execFileSync (no shell), but 11 tool files were passing shell syntax to it:

  • Pipes: git diff --stat | tail -1
  • Redirects: git status --porcelain 2>/dev/null
  • Logical operators: ... || echo ''
  • Non-git commands: find tests ... | wc -l

These all silently broke — |, tail, -1, 2>/dev/null etc. were passed as literal git arguments, causing git to either error (caught silently) or return wrong results.

Fix

  • Added shellRun() in lib/git.ts — uses execSync with shell interpretation for commands that genuinely need shell features
  • Updated all 11 affected tool files to use shellRun() for shell-syntax commands
  • Fixed session-health.ts to use array args + JS last-line extraction instead of pipe

Files changed

11 files, 52 insertions, 25 deletions. Build + all 62 tests pass.

… and contracts

The README references .preflight/ config extensively but there were no
concrete example files to copy. This adds a ready-to-use examples/.preflight/
directory with annotated config.yml, triage.yml, and contracts/api.yml,
plus a README explaining how to use them.
Created examples/USAGE_EXAMPLES.md with 8 real-world scenarios showing
what each tool looks like in practice: preflight_check catching vague
prompts, scope_work creating execution plans, enrich_agent_task for
sub-agents, sharpen_followup resolving ambiguity, session health checks,
semantic history search, weekly scorecards, and prompt grading.

Added link to usage examples in README nav bar.
- Reorder options: npx (zero install) → npm global → clone
- Add -y flag to npx for non-interactive use
- Explain what CLAUDE_PROJECT_DIR enables
- Note that .mcp.json paths must be absolute
- Use 'absolute' in path placeholders to prevent confusion
- Export scorePrompt for testability
- 11 tests for prompt scoring: grades, specificity, scope, actionability, done conditions
- 8 tests for pattern matching: keyword overlap, case insensitivity, formatting
- All 62 tests passing
run() uses execFileSync without a shell, so pipes (|), redirects (2>/dev/null),
and logical operators (||) were silently broken — args like '|' and 'tail' were
passed as git arguments instead of being interpreted as shell syntax.

Added shellRun() that uses execSync with shell interpretation for commands that
need pipes/redirects. Updated 11 tool files that were affected.

Also fixed session-health.ts 'git diff --stat | tail -1' to use array args
and manual last-line extraction instead of shell pipe.
@TerminalGravity
Copy link
Copy Markdown
Collaborator Author

Superseded by newer PRs.

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.

1 participant