2026-03-20 14:17:09 +01:00
|
|
|
#!/usr/bin/env bash
|
2026-01-28 23:03:49 +01:00
|
|
|
set -e
|
|
|
|
|
|
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
|
|
|
# Use local release build if available, otherwise fall back to installed rtk
|
|
|
|
|
if [ -f "./target/release/rtk" ]; then
|
|
|
|
|
RTK="$(cd "$(dirname ./target/release/rtk)" && pwd)/$(basename ./target/release/rtk)"
|
|
|
|
|
elif command -v rtk &> /dev/null; then
|
|
|
|
|
RTK="$(command -v rtk)"
|
|
|
|
|
else
|
|
|
|
|
echo "Error: rtk not found. Run 'cargo build --release' or install rtk."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
BENCH_DIR="$(pwd)/scripts/benchmark"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Mode local : générer les fichiers debug
|
|
|
|
|
if [ -z "$CI" ]; then
|
|
|
|
|
rm -rf "$BENCH_DIR"
|
|
|
|
|
mkdir -p "$BENCH_DIR/unix" "$BENCH_DIR/rtk" "$BENCH_DIR/diff"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Nom de fichier safe
|
|
|
|
|
safe_name() {
|
|
|
|
|
echo "$1" | tr ' /' '_-' | tr -cd 'a-zA-Z0-9_-'
|
|
|
|
|
}
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# Fonction pour compter les tokens (~4 chars = 1 token)
|
|
|
|
|
count_tokens() {
|
|
|
|
|
local input="$1"
|
|
|
|
|
local len=${#input}
|
|
|
|
|
echo $(( (len + 3) / 4 ))
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Compteurs globaux
|
|
|
|
|
TOTAL_UNIX=0
|
|
|
|
|
TOTAL_RTK=0
|
|
|
|
|
TOTAL_TESTS=0
|
|
|
|
|
GOOD_TESTS=0
|
|
|
|
|
FAIL_TESTS=0
|
|
|
|
|
SKIP_TESTS=0
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Fonction de benchmark — une ligne par test
|
2026-01-28 23:03:49 +01:00
|
|
|
bench() {
|
|
|
|
|
local name="$1"
|
|
|
|
|
local unix_cmd="$2"
|
|
|
|
|
local rtk_cmd="$3"
|
|
|
|
|
|
|
|
|
|
unix_out=$(eval "$unix_cmd" 2>/dev/null || true)
|
|
|
|
|
rtk_out=$(eval "$rtk_cmd" 2>/dev/null || true)
|
|
|
|
|
|
|
|
|
|
unix_tokens=$(count_tokens "$unix_out")
|
|
|
|
|
rtk_tokens=$(count_tokens "$rtk_out")
|
|
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
local icon=""
|
|
|
|
|
local tag=""
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
if [ -z "$rtk_out" ]; then
|
|
|
|
|
icon="❌"
|
|
|
|
|
tag="FAIL"
|
|
|
|
|
FAIL_TESTS=$((FAIL_TESTS + 1))
|
|
|
|
|
TOTAL_UNIX=$((TOTAL_UNIX + unix_tokens))
|
|
|
|
|
TOTAL_RTK=$((TOTAL_RTK + unix_tokens))
|
|
|
|
|
elif [ "$rtk_tokens" -ge "$unix_tokens" ] && [ "$unix_tokens" -gt 0 ]; then
|
|
|
|
|
icon="⚠️"
|
|
|
|
|
tag="SKIP"
|
|
|
|
|
SKIP_TESTS=$((SKIP_TESTS + 1))
|
|
|
|
|
TOTAL_UNIX=$((TOTAL_UNIX + unix_tokens))
|
|
|
|
|
TOTAL_RTK=$((TOTAL_RTK + unix_tokens))
|
2026-01-28 23:03:49 +01:00
|
|
|
else
|
2026-02-03 15:38:17 +01:00
|
|
|
icon="✅"
|
|
|
|
|
tag="GOOD"
|
|
|
|
|
GOOD_TESTS=$((GOOD_TESTS + 1))
|
|
|
|
|
TOTAL_UNIX=$((TOTAL_UNIX + unix_tokens))
|
|
|
|
|
TOTAL_RTK=$((TOTAL_RTK + rtk_tokens))
|
2026-01-28 23:03:49 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
if [ "$tag" = "FAIL" ]; then
|
|
|
|
|
printf "%s %-24s │ %-40s │ %-40s │ %6d → %6s (--)\n" \
|
|
|
|
|
"$icon" "$name" "$unix_cmd" "$rtk_cmd" "$unix_tokens" "-"
|
2026-01-28 23:03:49 +01:00
|
|
|
else
|
2026-02-03 15:38:17 +01:00
|
|
|
if [ "$unix_tokens" -gt 0 ]; then
|
|
|
|
|
local pct=$(( (unix_tokens - rtk_tokens) * 100 / unix_tokens ))
|
|
|
|
|
else
|
|
|
|
|
local pct=0
|
|
|
|
|
fi
|
|
|
|
|
printf "%s %-24s │ %-40s │ %-40s │ %6d → %6d (%+d%%)\n" \
|
|
|
|
|
"$icon" "$name" "$unix_cmd" "$rtk_cmd" "$unix_tokens" "$rtk_tokens" "$pct"
|
2026-01-28 23:03:49 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Fichiers debug en local uniquement
|
|
|
|
|
if [ -z "$CI" ]; then
|
|
|
|
|
local filename=$(safe_name "$name")
|
|
|
|
|
local prefix="GOOD"
|
|
|
|
|
[ "$tag" = "FAIL" ] && prefix="FAIL"
|
|
|
|
|
[ "$tag" = "SKIP" ] && prefix="BAD"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
local ts=$(date "+%d/%m/%Y %H:%M:%S")
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
printf "# %s\n> %s\n\n\`\`\`bash\n$ %s\n\`\`\`\n\n\`\`\`\n%s\n\`\`\`\n" \
|
|
|
|
|
"$name" "$ts" "$unix_cmd" "$unix_out" > "$BENCH_DIR/unix/${filename}.md"
|
|
|
|
|
|
|
|
|
|
printf "# %s\n> %s\n\n\`\`\`bash\n$ %s\n\`\`\`\n\n\`\`\`\n%s\n\`\`\`\n" \
|
|
|
|
|
"$name" "$ts" "$rtk_cmd" "$rtk_out" > "$BENCH_DIR/rtk/${filename}.md"
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
echo "# Diff: $name"
|
|
|
|
|
echo "> $ts"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "| Metric | Unix | RTK |"
|
|
|
|
|
echo "|--------|------|-----|"
|
|
|
|
|
echo "| Tokens | $unix_tokens | $rtk_tokens |"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "## Unix"
|
|
|
|
|
echo "\`\`\`"
|
|
|
|
|
echo "$unix_out"
|
|
|
|
|
echo "\`\`\`"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "## RTK"
|
|
|
|
|
echo "\`\`\`"
|
|
|
|
|
echo "$rtk_out"
|
|
|
|
|
echo "\`\`\`"
|
|
|
|
|
} > "$BENCH_DIR/diff/${prefix}-${filename}.md"
|
|
|
|
|
fi
|
|
|
|
|
}
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Section header
|
|
|
|
|
section() {
|
|
|
|
|
echo ""
|
|
|
|
|
echo "── $1 ──"
|
|
|
|
|
}
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# ═══════════════════════════════════════════
|
|
|
|
|
echo "RTK Benchmark"
|
|
|
|
|
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════"
|
|
|
|
|
printf " %-24s │ %-40s │ %-40s │ %s\n" "TEST" "SHELL" "RTK" "TOKENS"
|
|
|
|
|
echo "───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# ls
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "ls"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "ls" "ls -la" "$RTK ls"
|
|
|
|
|
bench "ls src/" "ls -la src/" "$RTK ls src/"
|
2026-02-03 17:05:01 +01:00
|
|
|
bench "ls -l src/" "ls -l src/" "$RTK ls -l src/"
|
|
|
|
|
bench "ls -la src/" "ls -la src/" "$RTK ls -la src/"
|
|
|
|
|
bench "ls -lh src/" "ls -lh src/" "$RTK ls -lh src/"
|
|
|
|
|
bench "ls src/ -l" "ls -l src/" "$RTK ls src/ -l"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "ls -a" "ls -la" "$RTK ls -a"
|
2026-02-03 17:05:01 +01:00
|
|
|
bench "ls multi" "ls -la src/ scripts/" "$RTK ls src/ scripts/"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# read
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "read"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "read" "cat src/main.rs" "$RTK read src/main.rs"
|
|
|
|
|
bench "read -l minimal" "cat src/main.rs" "$RTK read src/main.rs -l minimal"
|
|
|
|
|
bench "read -l aggressive" "cat src/main.rs" "$RTK read src/main.rs -l aggressive"
|
|
|
|
|
bench "read -n" "cat -n src/main.rs" "$RTK read src/main.rs -n"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# find
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "find"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "find *" "find . -type f" "$RTK find '*'"
|
|
|
|
|
bench "find *.rs" "find . -name '*.rs' -type f" "$RTK find '*.rs'"
|
2026-02-03 15:38:17 +01:00
|
|
|
bench "find --max 10" "find . -not -path './target/*' -not -path './.git/*' -type f | head -10" "$RTK find '*' --max 10"
|
|
|
|
|
bench "find --max 100" "find . -not -path './target/*' -not -path './.git/*' -type f | head -100" "$RTK find '*' --max 100"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# git
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "git"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "git status" "git status" "$RTK git status"
|
2026-02-03 15:38:17 +01:00
|
|
|
bench "git log -n 10" "git log -10" "$RTK git log -n 10"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "git log -n 5" "git log -5" "$RTK git log -n 5"
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
bench "git diff" "git diff HEAD~1 2>/dev/null || echo ''" "$RTK git diff HEAD~1"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# grep
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "grep"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "grep fn" "grep -rn 'fn ' src/ || true" "$RTK grep 'fn ' src/"
|
|
|
|
|
bench "grep struct" "grep -rn 'struct ' src/ || true" "$RTK grep 'struct ' src/"
|
|
|
|
|
bench "grep -l 40" "grep -rn 'fn ' src/ || true" "$RTK grep 'fn ' src/ -l 40"
|
|
|
|
|
bench "grep --max 20" "grep -rn 'fn ' src/ | head -20 || true" "$RTK grep 'fn ' src/ --max 20"
|
|
|
|
|
bench "grep -c" "grep -ron 'fn ' src/ || true" "$RTK grep 'fn ' src/ -c"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# json
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "json"
|
2026-01-28 23:03:49 +01:00
|
|
|
cat > /tmp/rtk_bench.json << 'JSONEOF'
|
|
|
|
|
{
|
|
|
|
|
"name": "rtk",
|
|
|
|
|
"version": "0.2.1",
|
|
|
|
|
"config": {
|
|
|
|
|
"debug": false,
|
|
|
|
|
"max_depth": 10,
|
|
|
|
|
"filters": ["node_modules", "target", ".git"]
|
|
|
|
|
},
|
|
|
|
|
"dependencies": {
|
|
|
|
|
"serde": "1.0",
|
|
|
|
|
"clap": "4.0",
|
|
|
|
|
"anyhow": "1.0"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JSONEOF
|
|
|
|
|
bench "json" "cat /tmp/rtk_bench.json" "$RTK json /tmp/rtk_bench.json"
|
|
|
|
|
bench "json -d 2" "cat /tmp/rtk_bench.json" "$RTK json /tmp/rtk_bench.json -d 2"
|
|
|
|
|
rm -f /tmp/rtk_bench.json
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# deps
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "deps"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "deps" "cat Cargo.toml" "$RTK deps"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# env
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "env"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "env" "env" "$RTK env"
|
|
|
|
|
bench "env -f PATH" "env | grep PATH" "$RTK env -f PATH"
|
|
|
|
|
bench "env --show-all" "env" "$RTK env --show-all"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# err
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "err"
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
if command -v cargo &>/dev/null; then
|
|
|
|
|
bench "err cargo build" "cargo build 2>&1 || true" "$RTK err cargo build"
|
|
|
|
|
else
|
|
|
|
|
echo "⏭️ err cargo build (cargo not in PATH, skipped)"
|
|
|
|
|
fi
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# test
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "test"
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
if command -v cargo &>/dev/null; then
|
|
|
|
|
bench "test cargo test" "cargo test 2>&1 || true" "$RTK test cargo test"
|
|
|
|
|
else
|
|
|
|
|
echo "⏭️ test cargo test (cargo not in PATH, skipped)"
|
|
|
|
|
fi
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# log
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "log"
|
|
|
|
|
LOG_FILE="/tmp/rtk_bench_sample.log"
|
2026-01-28 23:03:49 +01:00
|
|
|
cat > "$LOG_FILE" << 'LOGEOF'
|
|
|
|
|
2024-01-15 10:00:01 INFO Application started
|
|
|
|
|
2024-01-15 10:00:02 INFO Loading configuration
|
|
|
|
|
2024-01-15 10:00:03 ERROR Connection failed: timeout
|
|
|
|
|
2024-01-15 10:00:04 ERROR Connection failed: timeout
|
|
|
|
|
2024-01-15 10:00:05 ERROR Connection failed: timeout
|
|
|
|
|
2024-01-15 10:00:06 ERROR Connection failed: timeout
|
|
|
|
|
2024-01-15 10:00:07 ERROR Connection failed: timeout
|
|
|
|
|
2024-01-15 10:00:08 WARN Retrying connection
|
|
|
|
|
2024-01-15 10:00:09 INFO Connection established
|
|
|
|
|
2024-01-15 10:00:10 INFO Processing request
|
|
|
|
|
2024-01-15 10:00:11 INFO Processing request
|
|
|
|
|
2024-01-15 10:00:12 INFO Processing request
|
|
|
|
|
2024-01-15 10:00:13 INFO Request completed
|
|
|
|
|
LOGEOF
|
|
|
|
|
bench "log" "cat $LOG_FILE" "$RTK log $LOG_FILE"
|
2026-02-03 15:38:17 +01:00
|
|
|
rm -f "$LOG_FILE"
|
2026-01-28 23:03:49 +01:00
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# summary
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
section "summary"
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
if command -v cargo &>/dev/null; then
|
|
|
|
|
bench "summary cargo --help" "cargo --help" "$RTK summary cargo --help"
|
|
|
|
|
else
|
|
|
|
|
echo "⏭️ summary cargo --help (cargo not in PATH, skipped)"
|
|
|
|
|
fi
|
|
|
|
|
if command -v rustc &>/dev/null; then
|
|
|
|
|
bench "summary rustc --help" "rustc --help 2>/dev/null || echo 'rustc not found'" "$RTK summary rustc --help"
|
|
|
|
|
else
|
|
|
|
|
echo "⏭️ summary rustc --help (rustc not in PATH, skipped)"
|
|
|
|
|
fi
|
2026-01-28 23:03:49 +01:00
|
|
|
|
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
|
|
|
# ===================
|
|
|
|
|
# cargo
|
|
|
|
|
# ===================
|
|
|
|
|
section "cargo"
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
if command -v cargo &>/dev/null; then
|
|
|
|
|
bench "cargo build" "cargo build 2>&1 || true" "$RTK cargo build"
|
|
|
|
|
bench "cargo test" "cargo test 2>&1 || true" "$RTK cargo test"
|
|
|
|
|
bench "cargo clippy" "cargo clippy 2>&1 || true" "$RTK cargo clippy"
|
|
|
|
|
bench "cargo check" "cargo check 2>&1 || true" "$RTK cargo check"
|
|
|
|
|
else
|
|
|
|
|
echo "⏭️ cargo build/test/clippy/check (cargo not in PATH, skipped)"
|
|
|
|
|
fi
|
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
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# diff
|
|
|
|
|
# ===================
|
|
|
|
|
section "diff"
|
|
|
|
|
bench "diff" "diff Cargo.toml LICENSE 2>&1 || true" "$RTK diff Cargo.toml LICENSE"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# smart
|
|
|
|
|
# ===================
|
|
|
|
|
section "smart"
|
|
|
|
|
bench "smart main.rs" "cat src/main.rs" "$RTK smart src/main.rs"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# wc
|
|
|
|
|
# ===================
|
|
|
|
|
section "wc"
|
|
|
|
|
bench "wc" "wc Cargo.toml src/main.rs" "$RTK wc Cargo.toml src/main.rs"
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# curl
|
|
|
|
|
# ===================
|
|
|
|
|
section "curl"
|
|
|
|
|
if command -v curl &> /dev/null; then
|
|
|
|
|
bench "curl json" "curl -s https://httpbin.org/json" "$RTK curl https://httpbin.org/json"
|
|
|
|
|
bench "curl text" "curl -s https://httpbin.org/robots.txt" "$RTK curl https://httpbin.org/robots.txt"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# wget
|
|
|
|
|
# ===================
|
|
|
|
|
if command -v wget &> /dev/null; then
|
|
|
|
|
section "wget"
|
|
|
|
|
bench "wget" "wget -qO- https://httpbin.org/robots.txt" "$RTK wget https://httpbin.org/robots.txt -O"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-01-29 11:44:52 +01:00
|
|
|
# ===================
|
|
|
|
|
# Modern JavaScript Stack (skip si pas de package.json)
|
|
|
|
|
# ===================
|
|
|
|
|
if [ -f "package.json" ]; then
|
2026-02-03 15:38:17 +01:00
|
|
|
section "modern JS stack"
|
2026-01-29 11:44:52 +01:00
|
|
|
|
|
|
|
|
if command -v tsc &> /dev/null || [ -f "node_modules/.bin/tsc" ]; then
|
|
|
|
|
bench "tsc" "tsc --noEmit 2>&1 || true" "$RTK tsc --noEmit"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if command -v prettier &> /dev/null || [ -f "node_modules/.bin/prettier" ]; then
|
|
|
|
|
bench "prettier --check" "prettier --check . 2>&1 || true" "$RTK prettier --check ."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if command -v eslint &> /dev/null || [ -f "node_modules/.bin/eslint" ]; then
|
|
|
|
|
bench "lint" "eslint . 2>&1 || true" "$RTK lint ."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "next.config.js" ] || [ -f "next.config.mjs" ] || [ -f "next.config.ts" ]; then
|
|
|
|
|
if command -v next &> /dev/null || [ -f "node_modules/.bin/next" ]; then
|
|
|
|
|
bench "next build" "next build 2>&1 || true" "$RTK next build"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "playwright.config.ts" ] || [ -f "playwright.config.js" ]; then
|
|
|
|
|
if command -v playwright &> /dev/null || [ -f "node_modules/.bin/playwright" ]; then
|
|
|
|
|
bench "playwright test" "playwright test 2>&1 || true" "$RTK playwright test"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "prisma/schema.prisma" ]; then
|
|
|
|
|
if command -v prisma &> /dev/null || [ -f "node_modules/.bin/prisma" ]; then
|
|
|
|
|
bench "prisma generate" "prisma generate 2>&1 || true" "$RTK prisma generate"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
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-12 23:11:24 +01:00
|
|
|
|
|
|
|
|
if command -v vitest &> /dev/null || [ -f "node_modules/.bin/vitest" ]; then
|
|
|
|
|
bench "vitest run" "vitest run --reporter=json 2>&1 || true" "$RTK vitest run"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if command -v pnpm &> /dev/null; then
|
|
|
|
|
bench "pnpm list" "pnpm list --depth 0 2>&1 || true" "$RTK pnpm list --depth 0"
|
|
|
|
|
bench "pnpm outdated" "pnpm outdated 2>&1 || true" "$RTK pnpm outdated"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# gh (skip si pas dispo ou pas dans un repo)
|
|
|
|
|
# ===================
|
|
|
|
|
if command -v gh &> /dev/null && git rev-parse --git-dir &> /dev/null; then
|
|
|
|
|
section "gh"
|
|
|
|
|
bench "gh pr list" "gh pr list 2>&1 || true" "$RTK gh pr list"
|
|
|
|
|
bench "gh run list" "gh run list 2>&1 || true" "$RTK gh run list"
|
2026-01-29 11:44:52 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-01-28 23:03:49 +01:00
|
|
|
# ===================
|
|
|
|
|
# docker (skip si pas dispo)
|
|
|
|
|
# ===================
|
|
|
|
|
if command -v docker &> /dev/null; then
|
2026-02-03 15:38:17 +01:00
|
|
|
section "docker"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "docker ps" "docker ps 2>/dev/null || true" "$RTK docker ps"
|
|
|
|
|
bench "docker images" "docker images 2>/dev/null || true" "$RTK docker images"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
|
# kubectl (skip si pas dispo)
|
|
|
|
|
# ===================
|
|
|
|
|
if command -v kubectl &> /dev/null; then
|
2026-02-03 15:38:17 +01:00
|
|
|
section "kubectl"
|
2026-01-28 23:03:49 +01:00
|
|
|
bench "kubectl pods" "kubectl get pods 2>/dev/null || true" "$RTK kubectl pods"
|
|
|
|
|
bench "kubectl services" "kubectl get services 2>/dev/null || true" "$RTK kubectl services"
|
|
|
|
|
fi
|
|
|
|
|
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
# ===================
|
2026-02-13 00:23:53 +01:00
|
|
|
# Python (avec fixtures temporaires)
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
# ===================
|
2026-02-13 00:23:53 +01:00
|
|
|
if command -v python3 &> /dev/null && command -v ruff &> /dev/null && command -v pytest &> /dev/null; then
|
|
|
|
|
section "python"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
|
2026-02-13 00:23:53 +01:00
|
|
|
PYTHON_FIXTURE=$(mktemp -d)
|
|
|
|
|
cd "$PYTHON_FIXTURE"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
|
2026-02-13 00:23:53 +01:00
|
|
|
# pyproject.toml
|
|
|
|
|
cat > pyproject.toml << 'PYEOF'
|
|
|
|
|
[project]
|
|
|
|
|
name = "rtk-bench"
|
|
|
|
|
version = "0.1.0"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
|
2026-02-13 00:23:53 +01:00
|
|
|
[tool.ruff]
|
|
|
|
|
line-length = 88
|
|
|
|
|
PYEOF
|
|
|
|
|
|
|
|
|
|
# sample.py avec quelques issues ruff
|
|
|
|
|
cat > sample.py << 'PYEOF'
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_data(x):
|
|
|
|
|
if x == None: # E711: comparison to None
|
|
|
|
|
return []
|
|
|
|
|
result = []
|
|
|
|
|
for i in range(len(x)): # C416: unnecessary list comprehension
|
|
|
|
|
result.append(x[i] * 2)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def unused_function(): # F841: local variable assigned but never used
|
|
|
|
|
temp = 42
|
|
|
|
|
return None
|
|
|
|
|
PYEOF
|
|
|
|
|
|
|
|
|
|
# test_sample.py
|
|
|
|
|
cat > test_sample.py << 'PYEOF'
|
|
|
|
|
from sample import process_data
|
|
|
|
|
|
|
|
|
|
def test_process_data():
|
|
|
|
|
assert process_data([1, 2, 3]) == [2, 4, 6]
|
|
|
|
|
|
|
|
|
|
def test_process_data_none():
|
|
|
|
|
assert process_data(None) == []
|
|
|
|
|
PYEOF
|
|
|
|
|
|
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
|
|
|
bench "ruff check" "ruff check . 2>&1 || true" "$RTK ruff check ."
|
|
|
|
|
bench "pytest" "pytest -v 2>&1 || true" "$RTK pytest -v"
|
2026-02-13 00:23:53 +01:00
|
|
|
|
|
|
|
|
cd - > /dev/null
|
|
|
|
|
rm -rf "$PYTHON_FIXTURE"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ===================
|
2026-02-13 00:23:53 +01:00
|
|
|
# Go (avec fixtures temporaires)
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
# ===================
|
2026-02-13 00:23:53 +01:00
|
|
|
if command -v go &> /dev/null && command -v golangci-lint &> /dev/null; then
|
|
|
|
|
section "go"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
|
2026-02-13 00:23:53 +01:00
|
|
|
GO_FIXTURE=$(mktemp -d)
|
|
|
|
|
cd "$GO_FIXTURE"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
|
2026-02-13 00:23:53 +01:00
|
|
|
# go.mod
|
|
|
|
|
cat > go.mod << 'GOEOF'
|
|
|
|
|
module bench
|
|
|
|
|
|
|
|
|
|
go 1.21
|
|
|
|
|
GOEOF
|
|
|
|
|
|
|
|
|
|
# main.go
|
|
|
|
|
cat > main.go << 'GOEOF'
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
func Add(a, b int) int {
|
|
|
|
|
return a + b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Multiply(a, b int) int {
|
|
|
|
|
return a * b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
fmt.Println(Add(2, 3))
|
|
|
|
|
fmt.Println(Multiply(4, 5))
|
|
|
|
|
}
|
|
|
|
|
GOEOF
|
|
|
|
|
|
|
|
|
|
# main_test.go
|
|
|
|
|
cat > main_test.go << 'GOEOF'
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
func TestAdd(t *testing.T) {
|
|
|
|
|
result := Add(2, 3)
|
|
|
|
|
if result != 5 {
|
|
|
|
|
t.Errorf("Add(2, 3) = %d; want 5", result)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMultiply(t *testing.T) {
|
|
|
|
|
result := Multiply(4, 5)
|
|
|
|
|
if result != 20 {
|
|
|
|
|
t.Errorf("Multiply(4, 5) = %d; want 20", result)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GOEOF
|
|
|
|
|
|
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
|
|
|
bench "golangci-lint" "golangci-lint run 2>&1 || true" "$RTK golangci-lint run"
|
|
|
|
|
bench "go test" "go test -v 2>&1 || true" "$RTK go test -v"
|
|
|
|
|
bench "go build" "go build ./... 2>&1 || true" "$RTK go build ./..."
|
|
|
|
|
bench "go vet" "go vet ./... 2>&1 || true" "$RTK go vet ./..."
|
2026-02-13 00:23:53 +01:00
|
|
|
|
|
|
|
|
cd - > /dev/null
|
|
|
|
|
rm -rf "$GO_FIXTURE"
|
feat: add Python and Go support (#88)
* 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>
* feat: add Python and Go language support
Implements comprehensive support for Python and Go development tooling
with 70-90% token reduction across all commands.
Python commands (3):
- rtk ruff: Linter/formatter with JSON (check) and text (format) parsing (80%+)
- rtk pytest: Test runner with state machine text parser (90%+)
- rtk pip: Package manager with auto-detect uv (70-85%)
Go commands (4):
- rtk go test: NDJSON streaming parser for interleaved test events (90%+)
- rtk go build: Text filter showing errors only (80%)
- rtk go vet: Text filter for issues (75%)
- rtk golangci-lint: JSON parser grouped by rule (85%)
Architecture:
- Standalone Python commands (mirror lint/prettier pattern)
- Go sub-enum (mirror git/cargo pattern)
- 5 new modules: ruff_cmd, pytest_cmd, pip_cmd, go_cmd, golangci_cmd
- Hook integration in rtk-rewrite.sh for transparent rewrites
- Comprehensive tests (47 new tests, all passing)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(benchmark): add Python and Go commands
Add benchmark sections for Python (ruff, pytest, pip) and Go (go test/build/vet, golangci-lint) to validate >80% token savings in CI pipeline.
Sections conditionally execute based on project markers (pyproject.toml, go.mod) and tool availability.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 21:51:10 +01:00
|
|
|
fi
|
|
|
|
|
|
chore: merge develop into master (#499)
* fix: handle tail rewrites with read tail-lines
* feat: add 32 TOML-filtered commands to hook rewrite rules (#475)
Add rewrite rules for all TOML-filtered commands so the Claude Code
hook automatically rewrites them to `rtk proxy <cmd>`. This ensures
TOML filters apply transparently without manual `rtk` prefixing.
Commands added: ansible-playbook, brew, composer, df, dotnet, du,
fail2ban-client, gcloud, hadolint, helm, iptables, make,
markdownlint, mix, mvn, ping, pio, poetry, pre-commit, ps, quarto,
rsync, shellcheck, shopify, sops, swift, systemctl, terraform, tofu,
trunk, uv, yamllint.
Tests updated to use `htop` as unsupported command example since
terraform is now supported via TOML filter.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: git log --oneline no longer silently truncated to 10 entries (#461) (#478)
Only inject -10 limit when RTK applies its own compact format.
When user provides --oneline/--pretty/--format, respect git's
default behavior (no limit). Also detect -n and --max-count as
user-provided limit flags.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: gh run view --job flag loses its value (#416) (#477)
Add --job and --attempt to flags_with_value in
extract_identifier_and_extra_args() so their values are not
mistaken for the run identifier when placed before it.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: rtk read no longer corrupts JSON files with glob patterns (#464) (#479)
Add Language::Data variant for JSON, YAML, TOML, XML, Markdown, CSV
and other data formats. These files have no comment syntax, so the
MinimalFilter skips comment stripping entirely.
Previously, `packages/*` in package.json was treated as a block
comment start (`/*`), causing everything until the next `*/` to be
stripped — corrupting the JSON structure.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: npm routing, discover cat redirect, proxy quoted args (#480)
* fix: npm routing, discover cat redirect, proxy quoted args (#470, #315, #388)
#470: rtk npm now correctly routes npm subcommands (install, list,
audit, etc.) without injecting "run". Previously, `rtk npm install`
was executed as `npm run install`.
#315: discover no longer counts `cat >`, `cat >>`, `cat |` as missed
savings. These are write/pipe operations with no terminal output to
compress.
#388: rtk proxy now auto-splits a single quoted argument containing
spaces. `rtk proxy 'head -50 file.php'` now works like
`rtk proxy head -50 file.php`.
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: proxy quote-aware split, redirect detection scan all tokens, npm test routing
- Proxy: replace split_whitespace with shell_split() that respects quotes (#388)
e.g. 'git log --format="%H %s"' no longer splits on space inside quotes
- Discover: scan all tokens for redirect operators, not just nth(1) (#315)
e.g. 'cat file.txt > output.txt' now correctly detected as write
- npm: replace tautological test with actual routing logic verification
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add 11 new TOML built-in filters (xcodebuild, jq, basedpyright, ty, skopeo, stat, biome, oxlint, jj, ssh, gcc) (#490)
Closes #484, #483, #449, #448, #428, #283, #316, #195, #271, #333, #87, #376
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* 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>
* fix: use rtk <cmd> instead of rtk proxy for TOML-filtered commands (#507)
- Replace all 32 `rtk proxy <cmd>` rules with `rtk <cmd>` so TOML filters
actually apply (proxy bypasses filters, giving 0% real savings)
- Extract NPM_SUBCOMMANDS to module-level const to prevent test/prod drift
Reported-by: FlorianBruniaux
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: warn when no hook installed + rtk gain hook status + PR #499 fixes
- hook_check: detect missing hook (not just outdated), warn with ⚠️
Only warns if ~/.claude/ exists (Claude Code user) — once per day
- gain: show hook status warning (missing/outdated) in rtk gain output
- ssh.toml: bump max_lines 50→200, truncate_lines_at 120→200 (Florian review)
- git.rs: mark integration test #[ignore] + assert binary exists (Florian review)
- Add HookStatus enum for reuse across gain/diagnostics
Fixes #508, Fixes #509
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: address code review — hook_check edge cases
- status() checks .claude/ existence (no false warning for non-CC users)
- Unreadable hook file returns Outdated not Missing
- Swap marker/warning order (emit warning before touching rate-limit marker)
- Rename misleading test, add end-to-end status() test
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: review iteration 2 — double-warning, case-sensitive test, ssh truncate
- Refactor check_and_warn to delegate to status() (single source of truth)
- Fix double-warning: skip maybe_warn() for `rtk gain` (has its own inline warning)
- Fix git test: case-insensitive assertion for cross-locale compatibility
- ssh.toml: keep truncate_lines_at=120 (terminal width convention)
- Robust mtime handling: unwrap_or(u64::MAX) instead of nested .ok()?
- Test handles all CI environments (no hook, no .claude, hook present)
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: detect and warn RTK_DISABLED=1 overuse (#508)
- discover: count RTK_DISABLED= bypassed commands, report top 5 examples
- gain: lightweight 7-day JSONL scan, warn if >10% commands bypassed
- registry: add has_rtk_disabled_prefix() and strip_disabled_prefix() helpers
- gitignore: add .fastembed_cache/ and .next/
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: preserve trailing newline in tail_lines + add missing test
- apply_line_window() now preserves trailing newline when input has one
- Add test for tail --lines N (space form) rewrite
- Add test for tail_lines without trailing newline
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* fix: respect user-specified git log limits instead of silently truncating
RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names
This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.
Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity
Fixes #461
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle -n N and --max-count=N forms in git log limit parsing
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add structured dotnet support (build/test/restore/format)
Integrate PR #172 by @danielmarbach onto develop:
- MSBuild binlog parser (binary format, gzip, 7-bit varint)
- TRX test result parser (quick-xml)
- Format report JSON parser
- Subcommand routing: build, test, restore, format + passthrough
- Sensitive env var scrubbing (GH_TOKEN, AWS_SECRET_ACCESS_KEY, etc.)
- Fallback to text parsing when binlog unavailable
- 86-93% token savings on real .NET projects
Maintainer fixes applied:
- Removed binlog temp path from output (wastes tokens)
- Dropped hook file changes (incompatible with develop architecture)
- Fixed unused variable warnings
888 tests pass.
Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
* feat: add OpenCode plugin support (#300)
* feat(opencode): add OpenCode plugin support
Add `--opencode` flag to `rtk init` for installing a global OpenCode
plugin that rewrites Bash/shell commands through `rtk rewrite`.
- New plugin: hooks/opencode-rtk.ts (thin delegator to rtk rewrite)
- New init modes: --opencode (OpenCode only), combinable with Claude modes
- Plugin install/update/remove lifecycle with idempotent writes
- Uninstall cleans up OpenCode plugin alongside Claude Code artifacts
- `rtk init --show` reports OpenCode plugin status
- Replace unreachable!() with bail!() in match exhaustiveness guard
* docs: add OpenCode plugin documentation
- README: OpenCode plugin section, install flags, troubleshooting
- TROUBLESHOOTING: OpenCode-specific checklist
- Update init mode table to reflect Claude Code default
---------
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick Szymkowiak <patrick.szymkowiak@rtk-ai.app>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Qingyu Li <2310301201@stu.pku.edu.cn>
Co-authored-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: José Almeida <57680069+zeval@users.noreply.github.com>
2026-03-12 13:49:08 +01:00
|
|
|
# ===================
|
|
|
|
|
# rewrite (verify rewrite works with and without quotes)
|
|
|
|
|
# ===================
|
|
|
|
|
section "rewrite"
|
|
|
|
|
|
|
|
|
|
# bench_rewrite: verifies rewrite produces expected output (not token comparison)
|
|
|
|
|
bench_rewrite() {
|
|
|
|
|
local name="$1"
|
|
|
|
|
local cmd="$2"
|
|
|
|
|
local expected="$3"
|
|
|
|
|
|
|
|
|
|
result=$(eval "$cmd" 2>&1 || true)
|
|
|
|
|
|
|
|
|
|
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
|
|
|
|
|
|
|
|
if [ "$result" = "$expected" ]; then
|
|
|
|
|
printf "✅ %-24s │ %-40s │ %s\n" "$name" "$cmd" "$result"
|
|
|
|
|
GOOD_TESTS=$((GOOD_TESTS + 1))
|
|
|
|
|
else
|
|
|
|
|
printf "❌ %-24s │ %-40s │ got: %s (expected: %s)\n" "$name" "$cmd" "$result" "$expected"
|
|
|
|
|
FAIL_TESTS=$((FAIL_TESTS + 1))
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bench_rewrite "rewrite quoted" "$RTK rewrite 'git status'" "rtk git status"
|
|
|
|
|
bench_rewrite "rewrite unquoted" "$RTK rewrite git status" "rtk git status"
|
|
|
|
|
bench_rewrite "rewrite ls -al" "$RTK rewrite ls -al" "rtk ls -al"
|
|
|
|
|
bench_rewrite "rewrite npm exec" "$RTK rewrite npm exec" "rtk npm exec"
|
|
|
|
|
bench_rewrite "rewrite cargo test" "$RTK rewrite cargo test" "rtk cargo test"
|
|
|
|
|
bench_rewrite "rewrite compound" "$RTK rewrite 'cargo test && git push'" "rtk cargo test && rtk git push"
|
|
|
|
|
|
2026-01-28 23:03:49 +01:00
|
|
|
# ===================
|
|
|
|
|
# Résumé global
|
|
|
|
|
# ===================
|
2026-02-03 15:38:17 +01:00
|
|
|
echo ""
|
|
|
|
|
echo "═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════"
|
|
|
|
|
|
|
|
|
|
if [ "$TOTAL_TESTS" -gt 0 ]; then
|
|
|
|
|
GOOD_PCT=$((GOOD_TESTS * 100 / TOTAL_TESTS))
|
|
|
|
|
if [ "$TOTAL_UNIX" -gt 0 ]; then
|
|
|
|
|
TOTAL_SAVED=$((TOTAL_UNIX - TOTAL_RTK))
|
|
|
|
|
TOTAL_SAVE_PCT=$((TOTAL_SAVED * 100 / TOTAL_UNIX))
|
|
|
|
|
else
|
|
|
|
|
TOTAL_SAVED=0
|
|
|
|
|
TOTAL_SAVE_PCT=0
|
|
|
|
|
fi
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
echo ""
|
|
|
|
|
echo " ✅ $GOOD_TESTS good ⚠️ $SKIP_TESTS skip ❌ $FAIL_TESTS fail $GOOD_TESTS/$TOTAL_TESTS ($GOOD_PCT%)"
|
|
|
|
|
echo " Tokens: $TOTAL_UNIX → $TOTAL_RTK (-$TOTAL_SAVE_PCT%)"
|
|
|
|
|
echo ""
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Fichiers debug en local
|
|
|
|
|
if [ -z "$CI" ]; then
|
|
|
|
|
echo " Debug: $BENCH_DIR/{unix,rtk,diff}/"
|
|
|
|
|
fi
|
|
|
|
|
echo ""
|
2026-01-28 23:03:49 +01:00
|
|
|
|
2026-02-03 15:38:17 +01:00
|
|
|
# Exit code non-zero si moins de 80% good
|
|
|
|
|
if [ "$GOOD_PCT" -lt 80 ]; then
|
|
|
|
|
echo " BENCHMARK FAILED: $GOOD_PCT% good (minimum 80%)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|