You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
/usr/bin/env <cmd> not classified or rewritten (130 calls/30d) #83
```
$ echo '{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"/usr/bin/env git status"}}' | contextcrawler hook claude
$ echo "exit $?"
exit 0 # no JSON output → no rewrite
```
Local data shows 130 `env git …` invocations in the last 30 days, all routed raw (mostly from `git status` / `git diff` shells inside Codex).
Root cause
In `src/discover/registry.rs::classify_command`:
`ENV_PREFIX.replace(trimmed, "")` runs first (line 113). Its pattern is `^(?:sudo\s+|env\s+|VAR=val\s+)+` — it matches the literal token `env` only, not the absolute path `/usr/bin/env`.
`strip_absolute_path` runs second (line 120). Only then does the first word become `env`. By that point `ENV_PREFIX` has already been skipped and is not re-applied.
Net result: `env git status` is the input to the rule matcher, which has no rule for a leading `env` token, so it's marked `Unsupported { base_command: "env git" }`. Same defect in `rewrite_command` (uses the same `ENV_PREFIX` -> classify flow).
Fix
Two-line change: re-apply `ENV_PREFIX` after `strip_absolute_path`:
```rust
let cmd_normalized = strip_absolute_path(cmd_clean);
let cmd_normalized = ENV_PREFIX.replace(&cmd_normalized, "").to_string();
let cmd_normalized = strip_git_global_opts(&cmd_normalized);
```
(`strip_absolute_path` already returns owned `String`, so the borrow checker is content.)
`/usr/bin/env` is the standard way Codex CLI and some shell wrappers invoke commands. Fixing this alone recovers ~130 calls/30d in my own data and probably much more in heavy Codex users.
Activity
merge: B env-prefix (#83)
fix(discover): handle /usr/bin/env <cmd> in classify+rewrite (thehoff#83