Skip to content

fix: eliminate shell syntax in git.run() across 8 remaining tools#199

Closed
TerminalGravity wants to merge 1 commit intomainfrom
fix/shell-syntax-all-tools-v2
Closed

fix: eliminate shell syntax in git.run() across 8 remaining tools#199
TerminalGravity wants to merge 1 commit intomainfrom
fix/shell-syntax-all-tools-v2

Conversation

@TerminalGravity
Copy link
Collaborator

Fixes #172

Problem

run() uses execFileSync('git', args) — no shell. 8 tools passed shell operators that silently broke.

Fix

  • New src/lib/shell.ts for commands needing shell interpretation
  • Array-arg run() calls for git commands
  • Native Node.js fs replacing cat/wc/find
  • In-JS filtering replacing grep/head/tail pipes

Tools: verify-completion, token-audit, session-handoff, audit-workspace, sharpen-followup, scope-work, enrich-agent-task, sequence-tasks

Build clean, 43/43 tests pass.

Replace shell-piped commands passed to execFileSync('git', args) with:
- Array-arg run() calls for git commands
- New shell() helper (src/lib/shell.ts) for non-git commands needing pipes
- Native Node.js fs/path for file reads, stat, line counting
- In-JS filtering/slicing instead of grep/head/tail/wc pipes

Affected tools: verify-completion, token-audit, session-handoff,
audit-workspace, sharpen-followup, scope-work, enrich-agent-task,
sequence-tasks

Closes #172
Copy link
Collaborator Author

@TerminalGravity TerminalGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the cleanest approach to #172 — the new shell() helper in lib/shell.ts is the right abstraction for commands that genuinely need shell interpretation (like gh pr list with fallback, or tail -c), while everything else correctly moves to array-arg run() or native Node APIs.

A few things I like:

  • hasCommand() using which via execFileSync instead of command -v through a shell — correct and portable
  • Reading package.json and counting lines via fs instead of shelling out to cat/wc — way more reliable
  • The shell() helper has good timeout handling and captures both stdout+stderr on non-zero exits (important for tsc)
  • Slicing output in JS (.slice(-20)) instead of piping through tail

One minor note: enrich-agent-task.ts still references shellEscape in findRelatedTests (line ~53) but it's no longer needed there since you're building a RegExp, not a shell command. Won't break anything but it's dead logic — could clean it up.

This supersedes #195, #197, and #198 — let's close those once this lands. Ready to merge. 🚀

@TerminalGravity
Copy link
Collaborator Author

Closing — superseded by #204 which covers all remaining tools. Let's consolidate there.

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.

Systematic: shell syntax in git.run() calls across 8+ tools

1 participant