Skip to content

Several tools pass shell syntax to run() which uses execFileSync #89

Closed

Description

@TerminalGravity

Bug

run() in src/lib/git.ts uses execFileSync (no shell). Several tools pass strings with shell operators (||, &&, 2>/dev/null, |) that get split on whitespace and passed as literal git arguments, silently failing.

Fixed in #88: what-changed.ts, checkpoint.ts

Still affected:

  • token-audit.ts — uses wc -l < ..., tail -c via run()
  • verify-completion.ts — uses npx tsc --noEmit 2>&1 | tail via run()
  • enrich-agent-task.ts — uses git ls-files | head | grep via run()
  • scope-work.ts — uses git ls-files | head | grep via run()
  • session-handoff.ts — uses command -v via run()

These need to either:

  1. Use array args with proper fallback logic (like getDiffFiles)
  2. Use a separate execSync with shell: true for non-git commands
  3. Use Node APIs directly (e.g. fs.statSync instead of wc)

Activity

  1. TerminalGravity commented on Mar 4, 2026

    @TerminalGravity
    CollaboratorAuthor

    Good catch documenting all the affected tools. #88 handles what-changed and checkpoint — reviewed and it looks clean.

    For the remaining ones, here's how I'd approach each:

    Use Node APIs directly (best):

    • token-audit.ts — wc -l → fs.readFileSync().split('\n').length, tail -c → Buffer.byteLength
    • session-handoff.ts — command -v → which package or try/catch execFileSync

    Use array args + JS logic:

    • enrich-agent-task.ts / scope-work.ts — git ls-files as array args, then .split('\n').slice(0, N) and .filter() in JS instead of piping to head and grep

    Use execSync with shell: true (last resort):

    • verify-completion.ts — npx tsc --noEmit 2>&1 | tail is genuinely a shell pipeline; either use execSync with shell: true or split into two steps

    I can take the follow-up PR if needed.

  2. TerminalGravity commented on Mar 5, 2026

    @TerminalGravity
    CollaboratorAuthor

    Fixed in a7c6cc5 — all shell-syntax calls now use shellRun() or Node APIs.

  3. added a commit that references this issue on Mar 5, 2026
    e728370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions