Commit Graph

1282 Commits

Author SHA1 Message Date
aesoft 0b28e47af7 Update README.md 2026-07-06 21:01:19 +02:00
aesoft aee61f2f3f chore(docs): add core contributor 2026-07-06 20:58:27 +02:00
aesoft 6871e55358 Merge pull request #2836 from guyoron1/fix/grep-context-separator
fix(grep): preserve -- separator between non-adjacent match blocks
dev-0.44.0-rc.309
2026-07-06 09:57:21 +02:00
guyoron1 34a0f0e5c0 fix(grep): only insert -- separator when context flags are active
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.
2026-07-06 09:21:11 +03:00
guyoron1 cae9b710d4 fix(grep): preserve -- separator between non-adjacent match blocks
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
2026-07-06 09:21:03 +03:00
aesoft 31f9d43d81 Merge pull request #2748 from rtk-ai/feat/toml-filters-in-hook
feat(hook): wire TOML filters + better tee tail hint
dev-0.44.0-rc.308
2026-07-03 16:51:04 +02:00
aesoft 1b38eece9b Merge pull request #2801 from rtk-ai/fix/git-stash-show-diffstat
fix(git): compact git stash show instead of forcing -p
dev-0.44.0-rc.307
2026-07-03 15:22:20 +02:00
Adrien Eppling b619ecfb24 test(git): update stash summary tests for comma-free format 2026-07-03 14:57:47 +02:00
aesoft 6c3d81f970 no commas 2026-07-03 14:06:23 +02:00
Adrien Eppling 0ac5f5c311 fix(git): compress git stash show summary line
Shorten "N files changed, X insertions(+), Y deletions(-)" to "N changed, X +, Y -"; numbers preserved, no signal loss.
2026-07-03 13:39:50 +02:00
aesoft e20076433e Merge pull request #2789 from rtk-ai/fix/analytics-utf8-char-boundary-panic
fix(analytics): truncate display strings on UTF-8 char boundaries
dev-0.44.0-rc.306
2026-07-03 12:24:31 +02:00
Adrien Eppling c9468ee178 fix(analytics): floor prefix slices to char boundary instead of full-string fallback 2026-07-03 12:18:58 +02:00
Adrien Eppling add35e0928 fix(git): compact git stash show instead of forcing -p
Strip the diffstat decorations and cap the file list; savings are measured against the real command, not an inflated -p patch.
2026-07-03 12:14:01 +02:00
aesoft 9f631511ca Merge pull request #2791 from rtk-ai/docs/windows-native-hook
docs(windows): document native binary hook support
dev-0.44.0-rc.305
2026-07-03 11:07:33 +02:00
patrick 129104e388 docs(windows): document native binary hook support
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>
2026-07-02 22:54:40 +02:00
Adrien Eppling 47b22e03a4 fix(analytics): truncate display strings on UTF-8 char boundaries
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
2026-07-02 15:28:41 +02:00
Adrien Eppling 2d487cb947 fix(trust): surface parse errors, skip already-trusted files, fail loudly when non-interactive 2026-07-02 13:35:54 +02:00
Adrien Eppling 315a94398e fix(filter): address review findings in the TOML filter path
Recoverable loss for a fired head/max cut (never a bare marker), schema-gate the hook match set, parse-error probe for trust; + tests.
2026-07-02 13:35:53 +02:00
Adrien Eppling 34c0bcf2da perf(hook): match TOML filters with a match-only RegexSet
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).
2026-07-01 16:35:08 +02:00
Adrien Eppling a4872d9bbf fix(gain): note untrusted custom filters so they can be re-trusted 2026-07-01 15:55:45 +02:00
Adrien Eppling bbeee4c85e docs(trust): fix README to match silent skip; note global-filter migration 2026-07-01 15:41:54 +02:00
Adrien Eppling a9c33e2987 fix(trust): label detected filters as project- or global-scoped 2026-07-01 15:11:17 +02:00
Adrien Eppling e0a83ac824 feat(trust): rtk trust uses the same opt-in prompt as init
Concise filter list + [y/N] (--yes for non-interactive); drops the full-file dump and silent auto-trust. Shared prompt helper with init.
2026-07-01 14:46:38 +02:00
Adrien Eppling 9d3b678242 fix(trust): skip untrusted filters silently on the command path
The warning printed to stderr on every rewritten command, adding tokens; trust is surfaced only in `rtk init`/`rtk trust`.
2026-07-01 14:46:37 +02:00
Nicolas Le Cam b52e02b437 chore(scripts): switch benches to mockhttp.org as httpbin.org is struggling at the moment dev-0.44.0-rc.304 2026-07-01 13:35:05 +02:00
Adrien Eppling 84f952881b docs: document custom filters + trust in the config guide
Move the user-facing trust docs into docs/guide (config) and out of CODING_PRACTICES.
2026-07-01 13:31:51 +02:00
Nicolas Le Cam 32dda24e5b Merge pull request #2751 from guyoron1/fix/cjk-emoji-char-boundary-panic
fix(parser): use byte offsets instead of char indices in extract_json_object
2026-07-01 13:31:19 +02:00
Adrien Eppling 1130a7cafd feat(trust): gate custom filters (project + user-global) + init opt-in flags
Trust-gate both filter files; `rtk init` prompts to enable detected filters, or --trust-filters/--no-trust-filters for scripts.
2026-07-01 13:18:35 +02:00
Nicolas Le Cam 1052c1c702 Merge pull request #1649 from iliaal/feat/php-tooling
feat(php): consolidated PHP tooling (php, artisan, phpunit, phpstan, pest, paratest, ecs, pint)
dev-0.44.0-rc.302
2026-07-01 13:16:49 +02:00
aesoft ce30f378e3 Merge pull request #2771 from rtk-ai/fix/cicd/pr-targer-next-release
fix(cicd): next release pr target fork compatible
2026-07-01 13:15:45 +02:00
Ilia Alshanetsky d67fc28884 test(php): add token-savings assertion to paratest per cli-testing guide
.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.
2026-07-01 06:18:31 -04:00
Ilia Alshanetsky 5e34f61f9c Merge remote-tracking branch 'origin/develop' into feat/php-tooling
# Conflicts:
#	src/main.rs
2026-07-01 06:17:07 -04:00
Ilia Alshanetsky fe755957e1 test(php): add paratest unit tests to satisfy test-presence gate
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.
2026-07-01 06:11:33 -04:00
Adrien Eppling 6e34bbaa98 fix(cicd): next release pr target fork compatibel 2026-07-01 11:14:54 +02:00
guyoron1 28948d9176 Merge branch 'develop' into fix/cjk-emoji-char-boundary-panic 2026-07-01 11:58:22 +03:00
aesoft 8cdc861ede Merge pull request #2768 from guyoron1/fix/uv-transparent-prefix-conflict
fix(uv): remove uv run from transparent prefixes to fix rewrite conflicts
dev-0.44.0-rc.300
2026-07-01 10:52:47 +02:00
guy oron 0632d838ed style: apply rustfmt to BUILTIN_TRANSPARENT_PREFIXES 2026-07-01 11:12:38 +03:00
guy oron 96f94222cb fix(uv): remove uv run from transparent prefixes to fix rewrite conflicts
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.
2026-07-01 11:12:38 +03:00
guy oron 7e42d929e4 fix(uv): pass guard_raw arg to print_with_hint after signature change 2026-07-01 11:12:38 +03:00
guy oron 27f9739b29 fix(parser): use byte offsets instead of char indices in extract_json_object
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
2026-07-01 08:59:36 +03:00
Nicolas Le Cam bd10b002d0 Follow up on #2609:
- 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
2026-06-30 22:18:39 +02:00
aesoft a5f0774d0e Merge pull request #1405 from alexanderkreidich/fix/1379-uv-run-support
feat: add uv run support
2026-06-30 22:16:16 +02:00
Ilia Alshanetsky 5d2928c64e perf(php): cache composer_bin_dirs to avoid per-segment file reads
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.
2026-06-30 08:18:27 -04:00
Ilia Alshanetsky 50a8743041 fix(pipe): anchor phpunit auto-detection to the leading banner
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.
2026-06-30 08:18:27 -04:00
Ilia Alshanetsky 28366ce17b fix(php): drop bogus pest.php check in test-runner detection
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.
2026-06-30 08:18:27 -04:00
Ilia Alshanetsky 7cc46b4676 fix(php): detect phpstan analyse after global flags; avoid duplicate format
`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`.
2026-06-30 08:18:27 -04:00
Ilia Alshanetsky 8825480b7a fix(php): strip ANSI in phpunit filter and split errors from failures
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".
2026-06-30 08:18:27 -04:00
Karol Zalewski 487a2e7b2c fix(openclaw): handle exit code 3 from rtk rewrite
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#troubleshooting

Closes #2202
dev-0.43.1-rc.297
2026-06-30 13:10:12 +02:00
Ilia Alshanetsky 0cc15dc448 fix(php): default pint applied_fixers when key is absent
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.
2026-06-29 19:45:47 -04:00
Adrien Eppling 73b8cb3069 feat(hook): wire TOML filters into the rewrite path + reversible truncation
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>
2026-06-29 15:43:31 +02:00