Skip to content

rtk discover overcounts shell-wrapper parser fallbacks as top unhandled commands #1459

Open

Description

@princepal9120

Summary

rtk discover / unhandled-command reporting appears to overcount shell-wrapper activity as real missing commands when command telemetry falls back to parsed_cmd.type="unknown".

In practice, this surfaces high-volume pseudo-commands like:

  • $B goto
  • $B screenshot
  • $B responsive
  • $B snapshot
  • $B console
  • eval "$(...)"
  • [ / if [
  • python3 << 'PYEOF'
  • rev-parse

These are not all independent end-user commands that RTK should necessarily support directly. Many are:

  1. wrapper-script internals,
  2. multi-line shell programs,
  3. shell builtins / syntax fragments, or
  4. commands already rewritten or orchestrated by higher-level tooling.

The result is a noisy OP UNHANDLED COMMANDS report that looks like actionable product gaps, but is often just parser fallback noise.

Concrete example

On April 22, 2026, one local session produced this top-unhandled summary:

Command Count
$B goto 62
# Check 36
eval "$(.. 36
$B screenshot 25
[ 21
# Test 19
python3 << 16
$B responsive 13
$B snapshot 12
'^RXRESUME_API_KEY=' 12
gstack-update-check 11
if [ 9
null 9
eval 8
$B console 7
rev-parse 7

This strongly suggests the aggregation layer is counting parser fallbacks / shell fragments instead of meaningful top-level commands.

Evidence

I inspected local Codex session JSONL output and found cases where complex shell invocations are stored as parsed_cmd: [{"type":"unknown", ...}] even when the underlying command is clearly a wrapper script or structured shell program.

Representative examples from local session logs:

  • multi-line shell wrapper using git rev-parse, gstack-slug, find, tail, etc. recorded as one parsed_cmd.type="unknown"
  • omx explore --prompt ... recorded as parsed_cmd.type="unknown"

That means a downstream summarizer can easily misclassify wrapper-generated activity as “top unhandled commands”.

Expected

Unhandled-command reporting should focus on meaningful top-level commands that represent actual RTK support gaps.

It should avoid or down-rank:

  • shell builtins / syntax fragments ([, if [, heredoc markers)
  • wrapper-private env-var assignments / grep patterns
  • comment lines / sentinels (# Check, # Test)
  • higher-level orchestrator internals that should be attributed to their parent tool rather than counted as standalone missing commands
  • giant multi-line shell programs that parser fallback marks as unknown

Actual

These parser fallbacks are surfaced as if they were genuine missing commands, which creates a misleading “top unhandled commands” list.

Likely root cause

There seems to be a mismatch between:

  1. raw exec telemetry / parser fallback (parsed_cmd.type="unknown"), and
  2. the analytics layer that builds the unhandled-command summary.

If the analytics layer treats every unknown parse as a candidate missing command without filtering shell syntax / wrappers / orchestrator internals, false positives are inevitable.

Relation to existing issues

This feels adjacent to, but distinct from:

Those issues focus on command coverage and pre-hook vs post-hook classification.

This issue is narrower: even before support classification, the parser/aggregation layer appears to emit low-quality “commands” that should never make it into the user-facing top-unhandled list.

Potential fixes

A few possible approaches:

  1. Filter obvious shell syntax / fragments before adding entries to unhandled summaries.
  2. Collapse wrapper internals under a parent command when the invocation is clearly generated by a wrapper/orchestrator.
  3. Treat parsed_cmd.type="unknown" as low-confidence unless it resolves to a simple single command token.
  4. Add heuristics for heredocs, comments, env assignments, and multi-line scripts so they do not become first-class “commands”.
  5. Show confidence or source kind in discover output (explicit command vs parser fallback vs wrapper-derived).

Why this matters

Without filtering, rtk discover can send users toward the wrong action:

  • opening feature requests for shell syntax,
  • assuming RTK misses commands it should not claim to support directly,
  • or overlooking real product gaps hidden beneath wrapper-noise.

Environment

  • Observed on: April 22, 2026
  • Client context: Codex / OMX / gstack-heavy shell-wrapper workflows
  • OS: macOS
  • Repo involved in wrapper activity: mixed local automation + browse wrappers

Activity

  1. added
    bug
    effort-medium
    filter-quality
    on Apr 22, 2026
  2. pszymkowiak commented on Apr 22, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 87%

    Summary

    rtk discover's unhandled-command report includes shell syntax fragments, heredocs, wrapper internals, and parser fallbacks (parsed_cmd.type=unknown) as if they were genuine missing commands, producing a misleading top-unhandled list.

    📁 Relevant files
    • src/discover/aggregator.rs
    • src/telemetry/parser.rs
    • src/discover/report.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. aibeshkov commented on Nov 3, 2026

    @aibeshkov

    Another case of the same overcount: wrapper scripts that already call rtk internally.

    My agents use small wrappers instead of raw gh/ssh/git push (they add a per-session token, an allowlist of subcommands, and run the real CLI outside the agent's sandbox). Each one ends with exec rtk gh "$@", exec rtk ssh ... or rtk git .... rtk gain counts those calls, but rtk discover sees only the wrapper name and lists them under "TOP UNHANDLED COMMANDS":

    wrapper calls in 30 days what it runs
    kgh 19,308 exec rtk gh "$@"
    kssh 5,879 exec rtk ssh ...
    kpush 2,279 rtk git ...

    That is 27,466 of 253,914 Bash commands, so the reported adoption is 45.2% while the real share is about 56% (rtk 1.1.0).

    Possible fix: let users declare such wrappers (e.g. [discover] rtk_wrappers = ["kgh", "kssh"] in config), or have rtk record the parent command name when it is invoked from a script, so discover can match the two.

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

    area:clibugeffort-mediumfilter-qualityhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions