Skip to content

Bash command wrappers / prefixes (sudo, npx, rtk, …) are misclassified #657

Description

@athoune

Bash command wrappers / prefixes (sudo, npx, rtk, …) are misclassified

Problem

When an AI agent prefixes its bash commands with a wrapper tool, all those commands get lumped under the wrapper name in CodeBurn's bashBreakdown. For example, an agent that runs every command through a prefix like rtk (or sudo, npx, etc.) produces entries like this:

Raw command Currently classified as Should be
rtk git push rtk git
rtk npm install rtk npm
sudo apt update sudo apt
npx vitest --run npx vitest

This makes the bash command breakdown and the optimize detectors (which look at bash output waste) much less useful when a prefix is in use, because the actual tool being invoked is invisible.

The cause is in src/bash-utils.tsextractBashCommands takes basename() of the first non-env-var token without considering that the token might be a known wrapper that delegates to a real command.

Proposed solution

Add a set of known command wrappers in bash-utils.ts and skip past them during extraction:

const COMMAND_PREFIXES = new Set([
  'sudo', 'doas',       // privilege elevation
  'npx', 'bunx', 'dx',  // package runners
  'time',               // timing wrapper
  'nice', 'nohup', 'stdbuf', // process control
  'rtk',                // user-land command prefix
])

The skip only activates when there is a next token (a bare rtk or sudo without a following command is kept as-is).

Scope

The change is localised to bash-utils.ts — the same function is called by every provider (40+ call sites across all parsers), so the improvement applies universally.

Tests

  • rtk git status['git']
  • sudo npm install['npm']
  • npx vitest --run['vitest']
  • DEBUG=1 rtk git status['git'] (env var + prefix combined)
  • sudo npx vitest --run['vitest'] (nested prefixes)
  • rtk git add . && rtk git commit -m "msg"['git', 'git'] (chained)
  • rtk alone → ['rtk'] (standalone prefix kept)
  • Existing tests unchanged: npm install && git push['npm', 'git']

Prior art

The function already skips leading VAR=value assignments and filters out cd / true / false. The prefix skip is a natural extension of the same pattern.

I have a working branch with the changes and all tests passing. Happy to open a PR if the approach sounds right.

Additional context

  • CodeBurn version: 0.9.15
  • This affects all providers that go through extractBashCommands (Claude, Cursor, OpenCode, Gemini, Codex, Copilot, and 15+ more)
  • The rtk prefix is used by some agent configurations; sudo, npx, bunx etc. affect anyone whose agent uses privilege elevation or package runners

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions