Commit Graph

269 Commits

Author SHA1 Message Date
Patrick szymkowiak 09979cf297 fix(grep): close subprocess stdin to prevent memory leak (#897)
When RTK runs via Claude Code's PreToolUse hook, grep/rg subprocesses
inherit the hook's open stdin pipe. They block waiting for EOF and never
terminate, accumulating memory unboundedly (reported: 514GB on 96GB Mac,
kernel panic).

Fix: set stdin(Stdio::null()) on both rg and grep fallback commands so
subprocesses get immediate EOF instead of inheriting the parent pipe.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-02 17:21:48 +02:00
aesoft bae7930119 fix(review): PR #934 2026-03-31 20:43:59 +02:00
Florian BRUNIAUX 13e37bf7a8 ci: enforce test presence on new/modified filter modules
Add check-test-presence.sh script and CI job that fails if any *_cmd.rs
file added or modified in a PR is missing a #[cfg(test)] block.

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

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
2026-03-31 12:02:53 +02:00
Florian BRUNIAUX 7e6452c543 Merge pull request #528 from ousamabenyounes/fix/rtk-disabled-warning
warn: emit stderr warning on RTK_DISABLED=1 (#508)
2026-03-31 11:37:24 +02:00
aesoft 5af18f87ae Merge branch 'develop' into refacto-folders-and-documentation 2026-03-30 19:29:34 +02:00
Adrien Eppling d75e864f20 fix(rules): add wc RtkRule with pattern field for develop compat
Aligns with PR #884 (wc rewrite support) already on develop.
2026-03-30 19:26:44 +02:00
aesoft 75bd607d55 Merge pull request #904 from rtk-ai/refacto-folders-and-documentation
fix(refacto-p1): unified cmds execution flow  (+ rm dead code)
2026-03-30 18:43:54 +02:00
Adrien Eppling 0a8b8fd069 fix(review): address PR #910 review feedback
- container.rs: warn on kubectl JSON parse failure instead of silent fallback
- runner.rs: fix savings inflation when filter_stdout_only by tracking stdout only
- README.md: document automod behavior in module registration step
2026-03-30 18:13:39 +02:00
Adrien Eppling f3217a467b fix(registry): quoted env prefix + inline regex cleanup + routing docs
- ENV_PREFIX now handles FOO="bar baz", FOO='val', escaped quotes
- Move 6 inline lazy_static regex to module level
- Merge rewrite_head_numeric + rewrite_tail_lines → rewrite_line_range
- Consolidate head/tail call sites in rewrite_segment
- Add rewrite pipeline documentation to TECHNICAL.md
- Rewrite discover README as concept/flow documentation
- Add lexer-based tokenizer for shell command parsing

Co-Authored-By: Andrew Hundt <ATHundt@gmail.com>
2026-03-30 17:58:03 +02:00
aesoft 08aabb95c3 fix(standardize): merge pattern into rues 2026-03-30 17:58:02 +02:00
aesoft 7fd221f446 fix(standardize): git+kube sub wrappers run_filtered 2026-03-30 17:58:01 +02:00
aesoft 234909d2c7 fix(automod): add auto discovery for cmds 2026-03-30 17:58:00 +02:00
aesoft e48485adc6 fix(cmds): more covering for run_filtered 2026-03-30 17:57:59 +02:00
aesoft aabc0167bc fix(cleaning): constant extract 2026-03-30 17:57:57 +02:00
aesoft ba9fa345f3 fix(cmds): migrate remaining exit_code to exit_code_from_output 2026-03-30 17:55:15 +02:00
Adrien Eppling c1c56f24d7 style: fix cargo fmt in ls.rs assert macros
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 15:02:17 +02:00
aesoft 495a152059 fix(emots): replace 📊 with "Summary:" 2026-03-30 14:41:21 +02:00
Florian BRUNIAUX c54afe3da8 Merge pull request #884 from manulqwerty/fix/hook-rewrite-wc 2026-03-30 10:22:55 +02:00
aesoft 48ec28d531 fix(go): align go tool golangci-lint with Result<i32> 2026-03-29 14:08:45 +02:00
aesoft 23c0b7e433 fix(cloud): reuse early exit for edge case 2026-03-29 13:40:57 +02:00
aesoft 078ad1d503 fix(cmds): add run_filtered wrapper to remaining cmd 2026-03-29 13:40:57 +02:00
aesoft 6878819798 fix: remove dead code 2026-03-29 13:40:56 +02:00
aesoft 32ff4663cd fix(cmds): exit code unified return code flow 2026-03-29 13:40:54 +02:00
aesoft 77a0951433 fix(cmds): shared cmd execution flow + clean & update docs
shared cmd exec flow and also removed some notes in technical docs (does not belong here)
2026-03-29 13:40:10 +02:00
aesoft 2d2f199983 Merge pull request #883 from rtk-ai/hotfix/telemetry-salt-hash
fix(security): salt device hash for telemetry
2026-03-28 14:00:26 +01:00
aesoft 8ab0f3da47 Merge pull request #706 from shwoop/go-tool-golangci
feat(go): Support golangci-lint via go tool
2026-03-28 11:47:57 +01:00
aesoft 8e42120ea3 fix(security): set 0600 permissions on salt file 2026-03-28 10:46:08 +01:00
Florian BRUNIAUX 9b9075cbb1 Merge pull request #847 from MauroDeryckere/fix/cat-flag-rewrite
Correct fix. cat flags like -A/-v/-e have no rtk read equivalent — skipping rewrite is the right behavior. cat -n correctly preserved. Well tested.
2026-03-28 02:07:23 +01:00
Florian BRUNIAUX a0d6874f7b Merge pull request #677 from TechWizard9999/fix/cargo-clippy-show-error-details
LGTM after code review. truncate() correctly imported, error_details block placed before rule frequency table, test covers the main case. Minor duplication for error[Exxxx] style but not a bug.
2026-03-28 01:57:32 +01:00
Florian BRUNIAUX 5a0144d185 Merge pull request #763 from mvanhorn/osc/759-include-finished-line-in-cargo-output
Correct. The Finished line carries useful signal (build time + profile). Defensive implementation with Option fallback.
2026-03-28 01:50:18 +01:00
Florian BRUNIAUX 0a5d5d5392 Merge pull request #650 from tobwen/fix/psql-disable-help-flag
Correct fix. disable_help_flag = true is the right pattern for passthrough commands — consistent with other commands in the codebase.
2026-03-28 01:49:32 +01:00
Florian BRUNIAUX da67c3e46a Merge pull request #562 from yogasw/fix/gain-history-utc-to-local-time
Correct fix. UTC timestamps in a local CLI history view is a UX bug — chrono::Local is already a dependency.
2026-03-28 01:48:40 +01:00
shwoop 8f985a22d1 feat(go): Support golangci-lint via go tool
As of go v1.24, tools such as golanci-lint can be managed via the mod
file and called directly on the go binary via the tool subcommand.

When called via tools, we now apply the same logic to compact the
results as in the directly called command.

Signed-off-by: shwoop <monkey.mambo.al.ferguson@gmail.com>
2026-03-27 19:53:39 +01:00
aesoft 699f68236b fix(telemetry): cache salt in-process 2026-03-27 19:36:41 +01:00
aesoft f7ec883a78 fix(telemetry): docs + real info from "rtk init -g" 2026-03-27 19:28:43 +01:00
Manuel LOpez 099a8f3e6d fix(hook): rewrite wc commands to rtk wc 2026-03-27 19:19:35 +01:00
aesoft 60cba0f5d8 fix(security): salt device hash for telemetry 2026-03-27 19:17:00 +01:00
Mauro Deryckere 2fce6bfee7 fix(rewrite): skip cat rewrite when incompatible flags are present
cat flags like -v, -A, -e, -t, -s have different semantics than
rtk read flags (-v means verbose, -n means line numbers). Blindly
forwarding flags caused incorrect behavior (e.g. cat -A file →
rtk read -A file which fails).

Only skip rewrite for incompatible flags. cat -n (line numbers) maps
correctly to rtk read -n, so it is still rewritten for token savings.
Plain `cat file` continues to rewrite to `rtk read file` as before.
2026-03-27 09:13:26 +01:00
Yoga Setiawan 140e1f5958 fix(gain): convert history timestamps from UTC to local timezone 2026-03-27 14:43:34 +07:00
Roopesh def3424eb4 fix(cargo): show clippy error details in compact output
Signed-off-by: Roopesh <roopesh1724989@gmail.com>
2026-03-27 07:18:50 +05:30
Ousama Ben Younes 6fe769cf00 refactor(ls): remove unnecessary entries.clone() in pipe branch
Avoids one allocation since entries is not used after the if/else.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
2026-03-26 19:15:44 +00:00
Ousama Ben Younes 3e1f75a8d5 fix(ls): suppress summary line when stdout is piped
rtk ls | wc -l returned N+2 instead of N because the summary line
(📊 X files, Y dirs) and blank line were always written to stdout.

Now uses std::io::stdout().is_terminal() to suppress the summary
when piped, following standard Unix convention (ls, grep, find all
do this).

Fixes #482

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
2026-03-26 19:15:44 +00:00
Ousama Ben Younes 4ce95a321f test: add subprocess test for RTK_DISABLED=1 stderr warning
Verifies that `rtk rewrite "RTK_DISABLED=1 git status"` emits the
warning on stderr, not just that rewrite_command returns None.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
2026-03-26 19:03:09 +00:00
Ousama Ben Younes 08d1abc4a8 warn: emit stderr warning when RTK_DISABLED=1 is detected
When the rewrite hook sees RTK_DISABLED=1, it now prints a warning to
stderr before skipping the rewrite. This educates AI agents to stop
overusing the bypass — a real session showed 30% of commands using
RTK_DISABLED=1 unnecessarily, dropping savings from ~65% to 48%.

The warning is on stderr (not stdout) so it doesn't affect command
output or piping. The bypass still works exactly as before.

Fixes #508

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
2026-03-26 19:03:09 +00:00
Matt Van Horn 72b1e592d9 fix: include Finished line in cargo build success output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 11:58:29 -07:00
aesoft d9be630bef Merge branch 'develop' of https://github.com/rtk-ai/rtk into refacto-folders-and-documentation 2026-03-26 18:11:34 +01:00
Florian BRUNIAUX 23f4fee2a7 chore: fix fmt + add CHANGELOG entries for truncation fixes
- Run cargo fmt on diff_cmd.rs and init.rs (line length violations)
- Add Unreleased section to CHANGELOG.md with the two bug fixes
  from this PR (required by doc review CI gate)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
2026-03-26 10:06:43 +01:00
Florian BRUNIAUX 6a5ae1484b fix(merge): resolve conflict with develop in diff_cmd.rs
Keep truncation accuracy fix (HEAD) — accurate overflow counts in
condense_unified_diff. Drop test_condense_unified_no_truncation from
develop (incompatible). Add test_no_truncation_large_diff and
test_long_lines_not_truncated from develop (test compute_diff, no conflict).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 09:49:45 +01:00
patrick szymkowiak 599ad25deb Merge pull request #767 from zerone0x/fix/issue-765-swift-test
fix: rewrite swift test commands
2026-03-26 09:21:56 +01:00
Florian BRUNIAUX 185fb97061 fix(git): replace vague truncation markers with exact counts
Two silent truncation bugs in git.rs:

1. compact_diff: hunk truncation showed "... (truncated)" with no count.
   An LLM had no way to know if 5 or 450 lines were dropped. Replace
   with "... (N lines truncated)" by tracking hunk_skipped separately
   from hunk_shown — flush the count at each hunk/file boundary.

2. filter_log_output: commit body beyond 3 lines was silently dropped.
   A 20-line body explaining a breaking change would show 3 lines with
   no indicator that 17 were omitted. Now appends "[+N lines omitted]"
   when body_omitted > 0.

Adds 2 RED-then-GREEN tests to lock in the new behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
2026-03-25 22:30:22 +01:00