Native grep only prints -- between non-adjacent match blocks when
-A/-B/-C context is requested. The grouped output path was inserting
-- on any line-number gap unconditionally, so `rtk grep -rn todo`
invented separators between every match that grep never emits.
Gate the insertion on has_context_flag() which checks for -A/-B/-C
and their long-form equivalents.
When context flags (-A/-B/-C) are used, grep prints -- between
non-adjacent match blocks. parse_match_line() returned None for
this separator, and both output paths silently dropped it, merging
distinct matches into one contiguous block.
Fixes#2795
Native Windows has had full auto-rewrite support since v0.37.2 via the
`rtk hook claude` native binary command (no bash/jq/Unix shell). The
README still described the pre-v0.37.2 "CLAUDE.md fallback" behavior,
which is now inaccurate and a recurring source of confusion (#330).
- Rewrite the Windows section: native binary hook is the primary path,
WSL secondary; drop the "limited support / CLAUDE.md fallback" framing
- Add an upgrade note (re-run `rtk init -g` to migrate off rtk-rewrite.sh)
- Add a ripgrep prerequisite note (`rg` on PATH)
- Fix the install note and Supported AI Tools table (bash -> native binary)
Refs #330
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rtk gain --history panicked with "byte index 22 is not a char
boundary" when a tracked command contained non-ASCII text (Cyrillic,
CJK, emoji). The same byte-slicing pattern existed in the --failures
display (top commands, recent failures, timestamp prefix) and in the
session id column of rtk session, all reproduced as real panics.
Replace the ad-hoc byte-based truncations with the shared char-safe
core::utils::truncate() helper, and use .get(..n).unwrap_or() for the
timestamp and session id prefix slices so they fall back to the full
string instead of panicking. Output is byte-identical to the previous
behavior for pure-ASCII data.
Fixes#2787
The rewrite path only needs a yes/no match, not the full compiled pipeline find_matching_filter forces on every not-in-RULES command (~10ms/call saved; selection still uses find_matching_filter in run_fallback).
.claude/rules/cli-testing.md marks token-savings verification as a 🔴
requirement for filters. Add a ≥60% savings assertion over a realistic
paratest run (banner + config + parallel-worker progress → one-line
summary), alongside the existing behavioral tests.
paratest_cmd.rs lacked the mandatory #[cfg(test)] module, failing the
check-test-presence CI gate. Add tests exercising the ParaTest-specific
path in filter_test_runner_output: banner + "Random Seed:" + dot progress
stripped, result summary and failure details preserved.
uv run was listed in both BUILTIN_TRANSPARENT_PREFIXES and RULES,
causing the transparent prefix check to win and return None when the
inner command (e.g. python script.py) wasn't RTK-supported. Now all
uv run commands route through the RULES-based rtk uv path, which
delegates to uv_cmd.rs for filtering.
extract_json_object() used char indices from enumerate() as byte offsets
when slicing the input string. For multi-byte UTF-8 characters (CJK,
emoji), this causes a 'not a char boundary' panic because char index !=
byte offset.
Switch from Vec<char> + enumerate() to char_indices() which yields
correct byte offsets. Add regression tests for CJK values, emoji values,
CJK prefixes, and mixed multi-byte nested JSON.
Fixes#2509
- Fix documentation, Cursor now uses native rust binary hook
- Fix rtk-rewrite.sh shell script to fail on any exit code except 0 and 3
- Test that "continue": true is also present for "permission": "ask" and sync shell rewrite hook
composer_bin_dirs() re-read composer.json and the env on every call; the
rewrite hot path queries it several times per command segment via
normalize_php_tool_command (both classify_command and rewrite_segment_inner).
Resolution is constant for a process, so cache it in a OnceLock.
Matching only "by Sebastian Bergmann" misrouted any LICENSE, composer
metadata, or git log mentioning the author to the phpunit filter. Require
the input to start with "PHPUnit " as well.
Pest has no root `pest.php` file — its bootstrap lives at tests/Pest.php
and its canonical marker is the vendor/bin/pest binary. The root-level
check never matched real Pest projects and false-positived on unrelated
utility files, misrouting PHPUnit-only projects to the Pest filter.
`phpstan -c phpstan.neon analyse src/` put a global option before the
subcommand, so the first-arg-only check missed it and the run fell back
to unfiltered passthrough. Scan all args for analyse/analyze.
Replace the has_custom_format bool with a 3-state ErrorFormat enum so an
explicit `--error-format=json` is preserved without appending a second
`--error-format json`. Strip ANSI in the text fallback for `--ansi`.
filter_phpunit_output matched on raw bytes, so `--colors=always` output
(colorized "OK ("/"FAILURES!"/"Tests:" lines) defeated every anchor and
counts were lost. Strip ANSI first, mirroring the other PHP filters.
Also report PHPUnit errors (thrown exceptions) distinctly from failures
(assertion mismatches) instead of lumping both under "failures".
Interpret all RTK rewrite exit codes and respond appropriately:
- Exit 0 (Allow): auto-apply rewrite
- Exit 1 (Passthrough): no RTK equivalent, pass through unchanged
- Exit 2 (Deny): block the call entirely
- Exit 3 (Ask): rewrite available, require user approval via
requireApproval with allow-once/deny decisions
Uses execFileSync (not execSync) to avoid shell injection. Returns
a [string | null, RewriteVerdict?] tuple from tryRewrite so the
before_tool_call hook can react to each verdict type.
"allow-always" omitted from allowedDecisions because OpenClaw does
not auto-persist approval for plugin hooks — see:
https://docs.openclaw.ai/plugins/plugin-permission-requests#troubleshootingCloses#2202
PHP-CS-Fixer omits the fixers key in dry-run/diff modes (it is optional
in the JSON reporter), so a valid report like {"files":[{"name":"x.php"}]}
failed the whole parse and fell back to raw output. Mark the field
#[serde(default)] so a missing key deserializes to an empty vec.
Wire TOML-covered commands into the transparent hook rewrite path, and make
TOML truncation reversible via the shared tee hints.
Part 1 — hook wiring (#2179):
The hook's rewrite decision only consulted the static RULES table, so a command
covered solely by a TOML filter (jj, jq, just, ssh, ty, nx, turbo, …) was passed
through unfiltered by the hook even though `rtk <cmd>` filtered it directly.
`rewrite_segment_inner` now consults the TOML registry on a RULES miss
(Unsupported) and rewrites to `rtk <cmd>`, which re-enters via run_fallback →
the TOML tier. Guards: honors RTK_NO_TOML, respects the exclude list, never
rewrites Ignored (denylisted) commands, and a collision guard
(is_rtk_reserved_command) prevents rewriting to a name Clap would route to its
own subcommand. RTK_META_COMMANDS moved to core::constants as the shared source.
Part 2 — reversibility:
TOML truncation on success previously dropped lines with a bare "... omitted"
marker and no recovery pointer. apply_filter_with_info now reports a Lossiness
(Tail / Whole / None); run_fallback emits the line-offset tail hint
(`[see remaining: tail -n +N …]`) for a contiguous tail-drop, the full-output
hint otherwise, and — when tee is unavailable — shows the full raw rather than an
unrecoverable marker. Fixes the symmetric <500B failure-path gap and an
inaccurate MIN_TEE_SIZE comment in curl_cmd.
All hosts (claude/gemini/copilot/cursor) and `rtk rewrite` are covered via the
shared rewrite_command. No hook JSON / integrity-hash changes. The mirrored RULES
rows are kept (they feed discover/session/gain metadata). Builds on the approach
of #2226.
Note: the TOML registry load now lands on the Unsupported hook hot path
(~3-8ms native, one-time per process); the Supported path is unaffected. A
match-only RegexSet to cut that cost is a documented follow-up.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>