Skip to content

fix: broken shell commands — run() passed args as 'git git ...', shell ops as literal args - #243

Open
TerminalGravity wants to merge 2 commits into
mainfrom
fix/shell-command-execution
Open

fix: broken shell commands — run() passed args as 'git git ...', shell ops as literal args#243
TerminalGravity wants to merge 2 commits into
mainfrom
fix/shell-command-execution

Conversation

@TerminalGravity

Copy link
Copy Markdown
Collaborator

Problem

run() in src/lib/git.ts uses execFileSync('git', args) — but 19 call sites across 13 tool files passed strings with a git prefix, shell operators, or non-git commands that all silently failed.

Fix

  • run() now strips leading git prefix and shell operators from string args
  • New shell() function for commands needing real shell features
  • Migrated all 13 affected tool files
  • Added 8 tests

Build passes, all 51 tests pass.

- Remove unused imports across 13 source files
- Remove dead `gitCmd` function from lib/git.ts
- Remove dead `toMarkdown` function from generate-scorecard.ts (superseded by toMarkdownWithBaseline)
- Remove dead `CORRECTION_PATTERNS` constant from generate-scorecard.ts
- Lint warnings reduced from 74 to 47 (0 errors)
- All 43 tests pass, build clean
…tors, add shell() helper

run() uses execFileSync('git', args) but many callers passed:
- 'git diff ...' (doubled to 'git git diff ...')
- '2>/dev/null' (passed as literal git arg)
- '|| fallback' (pipe/or treated as git args)
- Non-git commands like 'find', 'cat', 'wc' (executed as 'git find ...')

All of these silently failed and returned error strings.

Fix:
- run() now strips leading 'git' from string args
- run() strips shell operators (2>/dev/null, ||, |, &&)
- New shell() function for commands needing real shell features
- Migrated 13 tool files to use proper array args or shell()
- Added 8 tests covering the new behavior

Affects: audit-workspace, checkpoint, clarify-intent, enrich-agent-task,
scope-work, sequence-tasks, session-handoff, session-health,
sharpen-followup, token-audit, verify-completion, what-changed

@TerminalGravity TerminalGravity left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed — this is a critical fix. run() was double-prefixing 'git' and passing shell operators as literal args to execFileSync. The cleanShellArgs helper is clean, and adding shell() as an escape hatch for when you actually need pipes/redirects is the right design. Node engine bump to 20+ makes sense here too. ✅ Ship it.

@TerminalGravity TerminalGravity left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed — this is the most critical fix in the batch. The double-git bug (run('git diff ...')execFileSync('git', ['git', 'diff', ...])) was silently breaking commands. The cleanShellArgs helper and new shell() export are clean. Ready to merge.

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