70 Commits

Author SHA1 Message Date
Adrien Eppling 7c10f7791c fix(benchmark): ignore the recall hints when counting find entries
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNqtCagEUryc1fgw62APkm
2026-09-08 16:53:02 +02:00
Nicolas Le Cam 84f629d719 Merge pull request #3773 from KuSh/fix/golangci-lint-benchmark
fix(ci): unbreak the golangci-lint benchmark row
2026-09-04 18:50:43 +02:00
Adrien Eppling d952a6b5de fix(benchmark): skip find's disclosure note and tee pointer when counting names
count_find_names and count_find_total treat every unrecognised line as a
row of names. Since find began reporting hidden and gitignored matches, its
output ends with `... (N filtered)` and a `[see remaining: ...]` pointer, so
`rtk find '*' --max 10` counted 19 names (10 + 3 + 6 words) and the
--max cap check failed. Skip both lines, as the header, `+N more` and
`ext:` lines already are.
2026-09-04 10:35:15 +02:00
Matt Van Horn d1a0d9c2c1 fix: address review feedback on classic diff fallback
- Drop the needless borrow at the format_diff_changes call site; with
  warnings = "deny" this was failing cargo clippy --all-targets and
  blocking the clippy job that build, test and release depend on.
- Keep the original both-files dump as the timer.track baseline. The
  synthesized classic diff is empty for identical files, which recorded
  input_tokens = 0 and reported ~0% instead of ~46% in rtk gain --history.
- Un-gate render_file_diff: fold it into render_diff rather than compiling
  a production helper only under cfg(test).
- Update the scripts/test-all.sh assertion to match the real output.
2026-08-31 20:33:33 +02:00
Nicolas Le Cam 475f9ddfc2 Merge pull request #3585 from ousamabenyounes/fix/benchmark-find-max
fix(benchmark): compare find --max against full find, not head -N
2026-08-31 02:34:00 +02:00
Nicolas Le Cam 9b16854975 fix(benchmark): assert the find --max cap, count its baseline once
The full-`find` baseline is identical for every N, so the `--max` rows can
no longer detect a `--max` that stops limiting: a no-op would still score
~51% savings and pass as a WARN. Assert the cap directly instead —
`rtk find --max N` displays exactly min(N, total) names, which fails
whether N sits below or above rtk's default display cap.

Keep a single savings row, since a second row with the same baseline only
added the same token count to TOTAL_UNIX twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-31 02:26:52 +02:00
Nicolas Le Cam eb3f814872 refactor(grep): trim comments and align the siblings of the flag change
Condense the Grep variant and its tests to the comment rules in
CONTRIBUTING.md (explain why, not what), and carry the -l/-t change
through the files that still assumed the old behavior.

- scripts/test-aristote.sh: add -r to the two grep assertions, since
  `grep PATTERN <dir>` exits 2, and move the type filter to `rtk rg`,
  the engine where -t is valid.
- docs/usage/FEATURES.md: extra args go to the engine actually invoked,
  not always to rg; drop the per-row shortcut justifications.
- tests/search_compress_test.rs: guard grep-engine tests on
  grep_available() instead of rg_available(), which skipped them into a
  false green on a box without ripgrep.
- .claude/hooks/rtk-suggest.sh: reverted; the rg -> rtk rg fix is
  correct but belongs in its own PR.

BREAKING CHANGE: `rtk grep --file-type` and its `-t` short are removed.
The option never reached the engine, so it was a silent no-op; `-t` now
flows through, which means `rtk rg -t rust` filters by type while
`rtk grep -t rust` returns grep's own `invalid option -- 't'`. `-l` and
`-m` under `rtk grep` are likewise the native grep flags now rather than
rtk's --max-len and --max.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-31 01:58:35 +02:00
Brandon Harper b3ae7be09e fix(test): make the -t smoke assertion actually gate something
Review caught that my replacement assertion was inert. `assert_fails` passes
on ANY non-zero exit, and the base command already failed for an unrelated
reason:

    $ rtk grep "pub fn" src/
    grep: src/: Is a directory
    exit=2

So it passed whether or not `-t` was handled correctly. I replaced a wrong
assertion with one that cannot fail.

Adding `-r` was not enough either: with `-r` first, trailing_var_arg swallows
`-t` before clap ever sees it, so the mutant still exits 2. The form has to
put `-t` FIRST, use a pattern that MATCHES, and target a single file, so the
only reason the command can fail is `-t` itself. Mutation-proved both ways by
re-adding `--file-type` with `short = 't'`:

    mutant: rtk grep -t rust "fn main" src/main.rs -> exit=0  (assert_fails fires)
    fixed:  rtk grep -t rust "fn main" src/main.rs -> exit=2  (assert_fails passes)

The comment above the assertion records the three ways to make it inert
again, since I hit two of them.

Adding `-r` to the two adjacent assertions fixes them too -- they were red on
develop because `grep PATTERN <dir>` without `-r` exits 2. Both line 260 and
261 were failing, not just 260 as I said earlier.

Corrects two false statements from earlier commit messages in this branch:

  - The FEATURES.md `--line-numbers | -n` row was STALE, not fabricated. The
    option existed from 7d69299 (2026-02-15) until 84616d1 (2026-06-10) --
    the same commit the struct NOTE credits for the -v/-n cleanup. Removing
    the row is still right; my justification was wrong.

  - `scripts/test-all.sh` is not wired into CI, but it is not "referenced
    only from .github/copilot-instructions.md" either. It is a documented
    contributor command: CONTRIBUTING.md:253 and CLAUDE.md:46.
2026-08-30 16:47:36 -06:00
Brandon Harper 901838ddae fix(bench): stop benchmarking a grep command that errors
scripts/benchmark.sh measured `rtk grep -rn 'fn ' src/ -l 40`, intending
--max-len 40. Two problems: `-l` is no longer rtk's short for --max-len, and
the flags sit AFTER the pattern, where trailing_var_arg passes them through
verbatim rather than binding them. So `-l` reached grep as
--files-with-matches and `40` was taken as a filename:

    $ rtk grep -rn 'fn ' src/ -l 40
    src/analytics/gain.rs
    src/analytics/session_cmd.rs
    grep: 40: No such file or directory

The benchmark was timing that error path on develop too -- it is not a
regression from this PR, but --max-len is the option this PR just changed,
and this is its only consumer in the repo.

Now uses the long form, before the pattern, where it binds:

    $ rtk grep --max-len 40 -rn 'fn ' src/    # widest match line: 77
    $ rtk grep -rn 'fn ' src/                 # widest match line: 117

    $ bash -n scripts/benchmark.sh
    syntax OK
2026-08-30 11:22:22 -06:00
Brandon Harper 187228dc50 fix(grep): repair the smoke assertion this PR invalidated
scripts/test-all.sh asserted `rtk grep "pub fn" src/ -t rust` exits 0. That
only held because --file-type swallowed `-t` and never passed it to the
engine, so the assertion was pinning a silent no-op. With --file-type gone,
`-t` reaches GNU grep, which has no such flag:

    $ rtk grep "pub fn" src/ -t rust
    grep: invalid option -- t
    exit=2

Replaced with an assert_fails pinning that rejection, plus an assert_ok
against rg (which does have -t), guarded on rg being installed. Verified:

    rtk grep "pub fn" src/ -t rust  -> exit=2  (assert_fails wants non-zero)
    rtk rg   "pub fn" src/ -t rust  -> exit=0  (assert_ok wants 0)
    $ bash -n scripts/test-all.sh
    syntax OK

Also drops a `--line-numbers | -n` row from the FEATURES.md grep table. No
such option exists on Commands::Grep -- its fields are max_len, max,
context_only, extra_args. The `line_numbers` field at src/main.rs:118
belongs to Read. The row predates this PR but sits in the table it edits.

Note, NOT fixed here as it is pre-existing and unrelated: the adjacent
`assert_ok "rtk grep pattern" rtk grep "pub fn" src/` on the line above
also fails, because grep without -r on a directory exits 2. The smoke
suite is not wired into CI (referenced only from
.github/copilot-instructions.md), which is how it rotted unnoticed.
2026-08-30 11:22:22 -06:00
Nicolas Le Cam 0731055b2f bench: give the go fixture something for the linters to find
The golangci-lint row has never measured the filter. The fixture is clean Go, so
golangci-lint prints an empty report, the raw side counts zero tokens and the row
scores as skipped whatever rtk does -- it read 0 -> 8 for as long as it was green.

Adds five functions that ignore returned errors, which errcheck reports. Verified
in golang:1.27 against golangci-lint v2.13.2, running the fixture exactly as it
appears here:

  golangci-lint   220 -> 35   GOOD (84%)
  go test          30 ->  8   GOOD (73%)   unchanged
  go build          0 ->  0   SKIP         unchanged
  go vet            0 ->  0   SKIP         unchanged

go build, go vet and go test stay clean, so the neighbouring rows keep measuring
what they measured before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 14:58:55 +02:00
Ousama Ben Younes 962554d457 fix(cicd): stop benchmark.sh deleting the tracked scripts/benchmark harness
`BENCH_DIR="$(pwd)/scripts/benchmark"` is a tracked directory: besides the
gitignored `unix/`, `rtk/` and `diff/` output dirs it holds the TypeScript
VM-benchmark harness (`run.ts`, `cleanup.ts`, `rebuild.ts`, `lib/*.ts`,
`cloud-init.yaml`). `rm -rf "$BENCH_DIR"` therefore wiped all 7 tracked files
from the working tree on every local run (`$CI` unset), which is exactly when
a contributor runs the benchmark before pushing.

Wipe only the three gitignored output subdirectories instead. Stale output is
still cleared between runs; the harness survives.

Follow-up to #3430 (rtk-ai/rtk#3430 review).
2026-08-17 15:06:04 +00:00
Ousama Ben Younes 7f6156f3a7 fix(cicd): make benchmark loopback server port-agnostic and cleanup set -e safe
Review follow-up on #3430:

- Bind `python3 -m http.server 0` so the kernel picks a free port and read the
  chosen one from the (unbuffered) server log, instead of hardcoding 8899 which
  fails needlessly when that port is already in use.
- Make `cleanup_net_fixtures` failure-tolerant: it runs from an EXIT trap under
  `set -e`, so `[ -n "$PID" ] && kill ...` aborted the whole handler whenever
  `kill` failed (server already dead), leaking the fixture dir and downloads.
- Give the wget case an explicit skip line instead of silently disappearing.
  wget rejects `file://` ("Unsupported scheme"), so there is no offline URL to
  fall back to when the loopback server is unavailable.

RED (PR HEAD): fixture dir NOT removed when kill fails; server unusable with
8899 taken. GREEN: fixture dir removed; server up on an ephemeral port.
2026-08-17 00:31:16 +00:00
Ousama Ben Younes 4644fa8fa4 fix(benchmark): serve curl/wget fixtures from loopback, drop mockhttp.org
The remaining online calls (curl robots.txt + wget /json on mockhttp.org)
were both a network dependency and non-deterministic. Serve fixed local
fixtures over a loopback http.server so curl and wget get real
Content-Type headers (exercising JSON minification), fully offline. curl
falls back to file:// when python3 is unavailable. Clean up the server,
temp fixtures, and the ./data.json download on exit.
2026-08-16 23:55:25 +00:00
Ousama Ben Younes 4947edaf0e fix(benchmark): avoid negative cargo and curl cases 2026-08-16 23:55:25 +00:00
Ousama Ben Younes 734e04934b fix(benchmark): compare find --max against full find, not head -N
`rtk find --max N` caps how many names are displayed but still scans and
summarizes the whole tree, so its output must be compared against the full
`find` a user would otherwise read. The old baseline piped through `head -N`,
which truncates the raw scan to a different (early-terminated) operation. On
small repos `head -10` produced fewer bytes than rtk's summary header, marking
`find --max 10` as a spurious negative that failed the whole benchmark job.
Dropping `head -N` makes both --max rows compare like-for-like and stable.
2026-08-16 08:34:56 +00:00
Takayuki Maeda 8dd5a3476d fix(benchmark): use stable indexed MockHTTP responses 2026-07-23 18:09:55 +09:00
Takayuki Maeda 6c57836bfb fix(benchmark): use deterministic curl and wget responses 2026-07-23 17:50:59 +09:00
Nicolas Le Cam b52e02b437 chore(scripts): switch benches to mockhttp.org as httpbin.org is struggling at the moment 2026-07-01 13:35:05 +02:00
Adrien Eppling eafadcee00 fix(grep): run the invoked engine instead of substituting rg for grep
- grep runs grep, rg runs rg: drop the substitution, forced --no-ignore-vcs, and BRE-to-rg translation
- add `rtk rg` command (native ripgrep, sharing the same output filter)
- split rewrite rule: grep to rtk grep, rg to rtk rg
- record the agent's real command in tracking (was synthesized as "grep -rn")
- emit nothing on a clean no-match (never-worse parity with the shared guard)
- rename grep_cmd.rs to search.rs, now hosting both engines
- cover engine faithfulness, ignore semantics, and rg savings with issue-referenced tests
- benchmark the grep and rg paths
2026-06-26 14:11:28 +02:00
Adrien Eppling 5a344524e3 test(bench): drop env --show-all (flag removed) 2026-06-24 20:37:04 +02:00
Husam c126d4594b fix(diff): report modified-only diffs and follow diff exit convention
rtk diff treated files whose changes were all classified as modified
(similar lines, e.g. "a: 1" vs "a: 2" in YAML/JSON) as identical,
because the identical check only looked at added/removed counts.
Report any non-empty change set as a difference, and exit 1 when
files differ per diff convention (0 when identical).

Fixes #2364
2026-06-11 17:47:08 +03:00
aesoft e8271848d7 Merge pull request #1368 from ousamabenyounes/fix/issue-1250
fix(install): reject archive with path traversal before extraction (#1250)
2026-05-13 22:08:35 +02:00
aesoft 26b96ec6c4 fix(security): pin workflow actions to SHA, clean up tempfile on failure 2026-05-13 17:13:44 +02:00
aesoft cd6ac2f47a fix(security): replace insecure tmp, lock git workflow perm 2026-05-13 15:42:11 +02:00
aesoft c590bd6932 fix(benchmark): benchmark capture all fd only stream 2026-04-28 20:25:44 +02:00
aesoft e6c2523be1 fix(benchmark): capture all fd for stream cmd benchmark 2026-04-28 20:12:43 +02:00
aesoft e7ae6bf018 fix(benchmark): extract format_diff_changes + remove wrong diff test 2026-04-25 10:32:22 +02:00
aesoft 7e3690a23a fix: remove wrong cicd benchmark + npm test regex 2026-04-25 09:31:46 +02:00
aesoft 88d9f6a0d9 fix(filters): benchmark ci update + fix stream filter quality 2026-04-24 18:54:29 +02:00
Ousama Ben Younes ac9b22c4d9 fix(install): reject archive with path traversal before extraction (#1250)
The installer previously ran `tar -xzf` on the downloaded archive with no
pre-extraction verification. A malicious mirror could ship a tarball with
`../` components or absolute paths and write files anywhere on the user's
filesystem (CWE-22).

Add a pre-extraction check that lists archive contents with `tar -tzf`
and rejects any entry whose name starts with `/` or contains a `..` path
component. The check is POSIX-compliant and adds negligible overhead for
the single-binary RTK release tarball.

Covered by scripts/test-install.sh, which exercises one safe archive
and four crafted malicious archives (leading `..`, absolute path,
mid-path `..`, trailing `..`) plus a regression guard that ensures the
check remains in install.sh.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-17 15:55:32 +00:00
aesoft a1d46f39c2 fix(stream): missing stderr fields 2026-04-16 20:39:01 +02:00
Nicolas Le Cam 45938b2a4d feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood
Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com>
2026-04-12 22:03:39 +02:00
Patrick szymkowiak 87ee81f08b fix(benchmark): address PR review feedback
- Run cargo test directly through testCmd instead of faking results
- Add 60s per-test timeout on vmExec to prevent hung suite
- Make report path configurable via --report flag (default: project root)
- Fix shell injection in testRewrite by escaping single quotes

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-12 11:55:57 +02:00
Patrick szymkowiak 1fbb6d935b feat(benchmark): add Swift ecosystem tests (6 commands + savings)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-12 10:36:37 +02:00
Patrick szymkowiak d13c185aac fix(benchmark): address review feedback from @FlorianBruniaux
- Strict exit codes: cargo/python/go tests expect exact exit codes
  instead of "any" (catches real regressions)
- Binary size limit documented: 8MB for ARM Linux VM vs 5MB x86 stripped
- --phase NaN guard: error message instead of silent no-op
- Verdict: 0 failures = READY, any failure = NOT READY (no more "minor issues" budget)
- rtk err exit code bug tracked in #846

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-12 10:36:37 +02:00
Patrick szymkowiak d22759b8c5 feat(benchmark): add multipass VM integration test suite
Bun/TypeScript orchestrator that creates an Ubuntu 24.04 VM via multipass,
installs all dev tools (Rust, Go, Node, Python, .NET, Terraform, etc.),
builds RTK, and runs 103 tests across 11 phases:

- Cargo quality (fmt, clippy, test)
- 47 Rust built-in commands (git, ls, grep, cargo, pytest, go, tsc...)
- 21 TOML filter commands (df, ps, shellcheck, hadolint, helm...)
- Hook rewrite engine (17 rewrite assertions)
- Exit code preservation
- Token savings verification (avg 81%)
- Pipe compatibility
- Edge cases (unicode, ANSI, empty output)
- Performance (memory < 20MB)
- Concurrency (10 parallel executions)

Usage:
  bun run scripts/benchmark/run.ts           # Full suite (~3 min)
  bun run scripts/benchmark/run.ts --quick   # Skip perf/concurrency
  bun run scripts/benchmark/run.ts --phase 3 # Single phase
  bun run scripts/benchmark/cleanup.ts       # Delete VM
  bun run scripts/benchmark/rebuild.ts       # Fast rebuild

Prerequisites: brew install multipass, bun
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-12 10:36:37 +02:00
Florian BRUNIAUX 13e37bf7a8 ci: enforce test presence on new/modified filter modules
Add check-test-presence.sh script and CI job that fails if any *_cmd.rs
file added or modified in a PR is missing a #[cfg(test)] block.

- New CI job runs with no dependencies (parallel to all other jobs, <10s)
- Uses --diff-filter=AM to catch both added files and test deletions
- --self-test mode for local verification
- Add missing tests to wget_cmd.rs (17 tests) and env_cmd.rs (12 tests)
  covering pure functions: compact_url, format_size, parse_error,
  extract_filename, mask_value, is_lang_var, is_cloud_var, etc.

Fixes the enforcement gap: CONTRIBUTING.md required tests but CI did not
check. Now 34/34 *_cmd.rs modules have #[cfg(test)].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
2026-03-31 12:02:53 +02:00
Florian BRUNIAUX bbe3da642b fix(ci): fix validate-docs.sh broken module count check
Two issues:
1. Module count compared top-level `mod` in main.rs (8) against
   "Total: 64 modules" in ARCHITECTURE.md -- incompatible metrics,
   always fails. Replaced with a simple .rs source file count (informational only).
2. CLAUDE.md check for Python/Go commands was too strict -- these
   commands belong in README.md (user-facing), not CLAUDE.md (Claude Code guidance).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
2026-03-30 18:26:04 +02:00
sveitser bec18c40a2 fix: use /usr/bin/env shebangs for portability across systems 2026-03-26 19:46:28 +01:00
Navid EMAD 15bc0f8d6e feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle) (#724)
* feat(ruby): add Ruby on Rails support (rspec, rubocop, rake, bundle)

Unifies 5 competing PRs (#198, #292, #379, #534, #643) into a single
coherent implementation.

New commands:
- rtk rspec: JSON parsing with text fallback (60%+ savings)
- rtk rubocop: JSON parsing, group by cop/severity (60%+ savings)
- rtk rake test: Minitest state machine parser (85-90% savings)
- rtk bundle install: TOML filter, strip Using lines (90%+ savings)

Shared infrastructure: ruby_exec(), fallback_tail(),
exit_code_from_output(), count_tokens() in utils.rs.

Discover/rewrite rules for rspec, rubocop, rake, rails, bundle
including bundle exec and bin/ variants.

E2E smoke tests (scripts/test-ruby.sh) covering all 4 commands.
56 new unit tests + 4 inline TOML tests. All 1035 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* fix(ruby): use TEST= env var for rake single-file test in smoke tests

Rails' `rake test` ignores positional file args; use `TEST=path` syntax.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* docs(ruby): add Ruby module architecture and update attribution

Integrate ARCHITECTURE.md Ruby Module Architecture section and CLAUDE.md
module table/fork-features from PR #643. Update PR description attribution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

* chore: remove PULL_REQUEST_DESCRIPTION.md from repo

PR description lives on GitHub, no need to track in the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Navid EMAD <navid.emad@yespark.fr>

---------

Signed-off-by: Navid EMAD <navid.emad@yespark.fr>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 15:04:59 +01:00
patrick szymkowiak 26f5473717 fix: test-all.sh aborts when gt not installed (#500) (#544)
Call skip_test instead of nonexistent skip function, consistent
with all other conditional sections (Python, Go, tree, etc.).

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-12 18:57:52 +01:00
patrick szymkowiak 6e61c2447c fix: remove version check from validate-docs CI (#476) (#543)
Release-please bumps Cargo.toml but not docs, causing the version
grep to fail after every release. The check adds no value since docs
don't need to track the exact patch version.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-12 18:54:34 +01:00
patrick szymkowiak cb79b4c701 fix: rtk rewrite accepts multiple args without quotes (#504)
* fix: rtk rewrite accepts multiple args without quotes

`rtk rewrite ls -al` now works the same as `rtk rewrite "ls -al"`.
Previously, args after the command were rejected or caused ENOENT.

Also adds rewrite tests to benchmark.sh to prevent regression.

Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* test: add Clap rewrite tests + fix benchmark false failures

- Add 2 Clap try_parse_from tests for rewrite multi-args (catches the
  KuSh bug at unit test level, not just benchmark)
- Fix git diff benchmark: use HEAD~1 on both sides for fair comparison
- Skip cargo/rustc benchmarks when tools not in PATH instead of false FAIL
- Benchmark: 0 fail, 4 skip (env-dependent), 52 green

Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-11 14:00:28 +01:00
Charles Vien 7fbc4ef4b5 feat(gt): add Graphite CLI support (#290) 2026-03-06 13:59:39 +01:00
patrick szymkowiak 85b0b3eb0b fix: prettier false positive when not installed (#221) (#359)
* fix: prettier reports "All OK" when not installed (#221)

Empty or failed prettier output was incorrectly treated as "all files
formatted". Now detects empty output and non-zero exit code, shows the
actual error message instead of a false positive.

* test: add smoke tests for rewrite, verify, proxy, discover, diff, wc, smart, docker, json edge cases

Covers bug fixes #196, #344, #345, #346, #347 and previously untested
commands. Adds assert_fails helper. 118 assertions total (was 69).

* chore: update benchmark.sh with missing commands and fix paths

- Add cargo (build/test/clippy/check), diff, smart, wc, curl, wget sections
- Fix Python commands: use dedicated rtk ruff/pytest instead of rtk test
- Fix Go commands: use dedicated rtk go/golangci-lint, add go build/vet
- Make BENCH_DIR absolute so debug files work from temp fixture dirs
- Fallback to installed rtk if target/release/rtk not found
2026-03-06 09:40:24 +01:00
Guillaume Deslandes 772b5012ed feat: passthrough fallback when Clap parse fails + review fixes (#200)
* feat: passthrough fallback when Clap parse fails

When RTK cannot parse a command (e.g. `rtk git -C /path status`),
instead of exiting with error code 2, it now falls back to running
the raw command directly. This keeps developer workflows unbroken.

- Replace Cli::parse() with try_parse() + run_fallback()
- Add parse_failures SQLite table for failure analytics
- Add `rtk gain --failures` / `-F` to view failure log
- Fallback preserves stdin/stdout/stderr via Stdio::inherit()
- --help and --version still work normally

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: guard RTK meta-commands from fallback to raw execution

When Clap fails to parse a meta-command like `rtk gain --badtypo`,
show the Clap error directly instead of trying to execute `gain`
as a binary from $PATH. Adds RTK_META_COMMANDS constant listing
gain, discover, learn, init, config, proxy, hook-audit, cc-economics.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: move timer start before command execution in fallback

TimedExecution::start() was called after the command finished,
so all fallback commands showed ~0ms in rtk gain --history.
Now the timer captures actual command runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add cleanup_old() call to record_parse_failure()

The parse_failures table was never cleaned up because only record()
called cleanup_old(). Now parse failures also trigger 90-day retention
cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: strip ANSI codes from Clap error before SQLite storage

Clap errors may contain terminal color codes. Strip them with
utils::strip_ansi() before storing in the parse_failures table
to avoid garbled output and wasted space.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: smoke test cargo test assertion and missing skip_test calls

- cargo test check now matches RTK's filtered output format ("passed")
  in addition to raw "test result:" and "FAILURES"
- Fix undefined `skip` calls to use existing `skip_test` function
  with proper (name, reason) arguments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: fmt upstream files after rebase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update version refs to 0.23.0 and module count to 51

Upstream v0.23.0 release bumped Cargo.toml version and added mypy_cmd
module. Update docs to match for CI validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 10:38:33 +01:00
Florian BRUNIAUX 5a68839486 docs: comprehensive v0.15.1 documentation update for Python/Go support
Complete documentation overhaul for RTK v0.15.1 Python and Go support
across all user-facing and technical documentation.

## Changes

### Critical (P0)
- **CLAUDE.md**: Added maintenance warning, CHANGELOG reference, hook
  coverage section, corrected module count (46 modules)
- **Hooks**: Added Python/Go rewrites (ruff, pytest, pip, go, golangci-lint)
- **CI Validation**: New workflow validates doc consistency on every PR

### User Documentation (P1)
- **README.md**: Added Python/Go Stack section, updated command tables,
  added benchmarks, explicit v0.15.1 mention

### Technical Documentation (P2)
- **ARCHITECTURE.md**: Updated metadata (v0.15.1, 2026-02-12), added
  Python/Go modules to organization table, 3 new filtering strategies
  (JSON/TEXT Dual, State Machine, NDJSON), complete Python & Go
  Module Architecture section

## Validation
-  All docs mention version 0.15.1
-  Module count consistent (46 across all docs)
-  All Python/Go commands documented
-  Hook rewrites present and tested
-  scripts/validate-docs.sh passes

## Impact
- Prevents documentation drift (CI validation)
- Claude Code immediately uses Python/Go via hooks
- Clear architecture guidance for contributors
- 375 lines added across 6 files

Closes #[issue-number-if-any]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 11:21:52 +01:00
Florian BRUNIAUX 50bb4943f7 fix: improve CI reliability and hook coverage (#95)
* feat(cargo): aggregate test output into single line (#83)

Problem: `cargo test` shows 24+ summary lines even when all pass.
An LLM only needs to know IF something failed, not 24x "ok".

Before (24 lines):
```
✓ test result: ok. 2 passed; 0 failed; ...
✓ test result: ok. 0 passed; 0 failed; ...
... (x24)
```

After (1 line):
```
✓ cargo test: 137 passed (24 suites, 1.45s)
```

Changes:
- Add AggregatedTestResult struct with regex parsing
- Merge multiple test summaries when all pass
- Format: "N passed, M ignored, P filtered out (X suites, Ys)"
- Fallback to original behavior if parsing fails
- Failures still show full details (no aggregation)

Tests: 6 new + 1 modified, covering all cases:
- Multi-suite aggregation
- Single suite (singular "suite")
- Zero tests
- With ignored/filtered out
- Failures → no aggregation (detail preserved)
- Regex fallback

Closes #83

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(ci): prevent Python/Go benchmark sections from being silently skipped

**Problem:**
Python and Go benchmark sections were silently skipped in CI because
the RTK repository doesn't contain pyproject.toml or go.mod files.
The sections only ran when these project files existed.

**Solution:**
1. Create temporary fixtures with minimal project structure:
   - Python: pyproject.toml + sample.py + test_sample.py
   - Go: go.mod + main.go + main_test.go
2. Resolve RTK to absolute path to work after cd into temp dirs
3. Install required tools in CI workflow:
   - Python: ruff, pytest
   - Go: stable version + golangci-lint

**Impact:**
- Python/Go sections now appear in CI benchmark output
- Self-contained fixtures ensure consistent benchmarking
- No dependency on RTK project structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(hooks): add missing RTK command rewrites

Add 8 missing command rewrites to rtk-rewrite.sh and rtk-suggest.sh:
- cargo check/install/fmt
- tree, find, diff
- head → rtk read (with --max-lines transformation)
- wget

Fixes BSD sed compatibility for head transformation by using literal
spaces instead of \s+ (which doesn't work on macOS).

Impact: ~18.2K tokens saved on previously missed commands discovered
by `rtk discover`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-13 08:46:01 +01:00
Florian BRUNIAUX ab43e4b823 fix(vitest): robust JSON extraction for pnpm/dotenv prefixes (#92)
* fix(vitest): robust JSON extraction for pnpm/dotenv prefixes

Problem: RTK's vitest parser forces --reporter=json but pnpm/dotenv prepend
non-JSON text to stdout (banners, env messages), causing 100% Tier 1 failure
and useless 500-char passthrough.

Solution:
- Add extract_json_object() to parser/mod.rs (shared utility)
- Algorithm: find "numTotalTests" or first standalone {, brace-balance forward
- VitestParser now tries direct parse → extract+parse → regex → passthrough
- Replace hardcoded Command::new("pnpm") with package_manager_exec("vitest")
- Delete orphan doc comment on line 203

Impact:
- Before: 100% Tier 3 passthrough with pnpm workflows
- After: Tier 1 success with prefixes, maintains 99.5% token savings

Tests:
- 6 tests for extract_json_object (clean, pnpm, dotenv, nested, no-json, strings)
- 3 tests for VitestParser with prefixes
- All 277 tests pass

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* chore(benchmark): add vitest, pnpm, and gh commands

Add benchmarks for recently implemented commands:
- vitest run (PR #92 - JSON extraction fix)
- pnpm list/outdated (PR #6)
- gh pr list/run list (existing gh support)

These commands are now tested in CI to ensure token savings are maintained.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-13 08:46:01 +01:00