Skip to content

rtk ast-grep: Windows absolute paths never parse, so the filter degrades to a full passthrough with no savings #4017

Open

Description

@KuSh

Follow-up from #3857.

MATCH_LINE_RE in src/cmds/system/ast_grep_cmd.rs is ^(?P<file>[^:]+):(?P<line>\d+):(?P<content>.*)$. [^:]+ cannot cross the colon in a Windows drive letter, so a line like

C:\src\a.rs:12:static X: Y = foo();

never matches: after C: the next token must be digits and it is \src\a.rs. ast-grep echoes paths exactly as they were given on the command line (confirmed on Linux: an absolute path argument produces absolute paths in the output), so any invocation naming an absolute path on Windows produces output where no line parses.

Since #3857 this is safe — unparsed_signal() returns the output untouched rather than keeping whichever lines happen to parse — but it means rtk ast-grep does nothing at all for those users: 0% reduction, on exactly the invocation shape an agent is most likely to generate.

Relative-path invocations are unaffected (src\a.rs:12: parses fine). The same applies to any POSIX path containing a colon.

search.rs sidesteps this entirely for grep/rg by forcing --null and parsing ^([^\x00]+)\x00(\d+)([:-]) (search.rs:287). ast-grep has no --null equivalent in plain mode, so the fix probably means anchoring on the last :<digits>: on the line rather than the first, or accepting an optional [A-Za-z]: drive prefix.

Verified: regex behaviour checked directly against all three path shapes; path echoing confirmed with ast-grep 0.45.3 in Docker (node:22-trixie-slim, LC_ALL=C). The Windows leg is inferred from those two facts rather than executed on a Windows runner.

Activity

  1. rtk-wshm-sync-bot commented on Sep 13, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 88%

    Summary

    MATCH_LINE_RE in ast_grep_cmd.rs can't parse Windows drive-letter (or colon-containing POSIX) paths, silently degrading rtk ast-grep to a full passthrough with no token savings; fix by anchoring on the last :<digits>: or accepting an optional drive prefix.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/system/ast_grep_cmd.rs

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

  2. added a commit that references this issue on Nov 30, 2026
    360027e
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions