Commit Graph

1146 Commits

Author SHA1 Message Date
aesoft d8c550eefb Merge pull request #2333 from KuSh/grep_arg_parsing
fix(grep): stabilize argument parsing — trailing_var_arg, -v invert-match, --version passthrough, safe rg invocation
dev-0.43.0-rc.276
2026-06-14 18:23:19 +02:00
Nicolas Le Cam 307b557383 feat(grep): sort content alphabetically 2026-06-14 15:31:20 +02:00
Nicolas Le Cam 34aac6ed95 refactor(grep): extract parse_cluster to make cluster parsing directly testable
The left-to-right scanning logic now lives entirely in parse_cluster(), which
returns a ClusterResult enum (Boolean or ValueTaking). extract_pattern_path
just dispatches on the result — no loop logic inline.

parse_cluster() is the only place that touches cluster bytes, so the full
contract is testable in isolation:

  parse_cluster("ecarrot") → ValueTaking { prefix: None, flag: 'e', inline: "carrot" }
  parse_cluster("rne")     → ValueTaking { prefix: Some("n"), flag: 'e', inline: "" }
  parse_cluster("g*.rs")   → ValueTaking { prefix: None, flag: 'g', inline: "*.rs" }
  parse_cluster("rn")      → Boolean(Some("n"))

strip_r() remains as the focused r/R-stripping helper used internally by
parse_cluster (and tested directly to document the "carrot"→"caot" danger).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 15:29:21 +02:00
Nicolas Le Cam 8d29f75833 fix(grep): restore strip_r as explicit testable helper + pre-existing clippy fix
The left-to-right cluster scan now calls strip_r() at emit time on the
accumulated flag-letter prefix (raw_prefix), never on inline value bytes.
This makes the safety contract explicit and testable: strip_r("carrot")
produces "caot", documenting exactly why it must not touch value bytes.

Also fix pre-existing unused-mut in aws_cmd.rs (has_output_flag).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 15:29:21 +02:00
Nicolas Le Cam b7d93b509e fix(grep): left-to-right cluster scan, long value flags, format passthrough
Five regressions on grep_arg_parsing vs develop:

- `-ecarrot` matched "caot" — strip_r was applied to the inline value bytes.
  Fix: scan cluster left-to-right; stop at first value-taking letter and
  treat the remainder as the inline value without r/R stripping.

- `-g*.rs` glob became `*.s` — same root cause, inline glob value r-stripped.

- `--glob '*.md'` took `*.md` as a path — no VALUE_FLAGS_LONG existed; the
  value token fell through to the positional collector.
  Fix: add VALUE_FLAGS_LONG covering all rg long flags that take a value.

- `--max-count 1 fn file` took `1` as the pattern — same missing long flag.

- VALUE_FLAGS_SHORT expanded: add t/T (--type/--type-not), d (--max-depth),
  M (--max-columns) so inline short forms and space-separated forms parse
  correctly without mis-routing values to patterns or paths.

- --regexp (long form of -e) now routes to patterns like -e does.

- has_format_flag: add --count-matches, --json, --passthru, --files so
  these output-format modes get passthrough treatment instead of silent
  "0 matches in 0 files".

2183 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 11:44:32 +02:00
Nicolas Le Cam 7d6255f0e0 fix(grep): code and test cleanup 2026-06-11 01:54:36 +02:00
Nicolas Le Cam acb3a2d5cd fix(grep): handle value-taking flags in tail position of short clusters
A combined cluster like -rne PATTERN or -rA 2 had the last flag's
value consumed only if the cluster was exactly 2 chars. Longer
clusters (e.g. -rne) fell through to process_flag, which stripped
-r and emitted -ne — then -e ended up in flags without a value,
causing rg to error.

New unified short-flag handler: for any single-dash cluster, inspect
the last byte. If it is -e or a VALUE_FLAGS_SHORT member, strip the
r/R chars from the prefix, emit the prefix as a flag (if non-empty),
and consume the next token as the value (pattern for -e, flag value
otherwise). Long flags (--foo) are still routed through process_flag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 00:23:25 +02:00
Nicolas Le Cam c40b3ef9db fix(grep): fix value-taking flags, -rN clusters, multi-path, and -e patterns
Four bugs in `extract_pattern_path` caused `rtk grep` to misparse
common invocations:

- `-A 2 error src` → `2` was taken as the pattern (value-taking
  flags not recognised)
- `-rn foo src` → `n` leaked to rg as `--replace` value (only
  standalone `-r` was stripped, not combined clusters like `-rn`)
- `TODO src tests` → second path silently dropped (only one path
  kept)
- `-i x agent -g '*.md'` → rg regex error (`*.md` became positional
  before `-g` could consume it)

New implementation:
- `VALUE_FLAGS_SHORT`: explicit byte-set of 2-char flags that consume
  one following token (`A`, `B`, `C`, `g`, `f`, `j`, `m`)
- `process_flag()`: strips `r`/`R` from any single-dash cluster,
  drops `--recursive`; replaces the old inline `if arg == "-r"` loop
- `extract_pattern_path` returns `(Vec<String>, Vec<String>, Vec<String>)`
  (patterns, paths, flags) — no more `Option<String>` for pattern
- `-e` values collected separately; if any `-e` is present, all
  positionals are paths; otherwise first positional is the pattern
- All patterns forwarded to rg as `-e` flags (BRE `\|`→`|` inline)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 00:16:57 +02:00
Nicolas Le Cam 84616d131d fix(grep): stabilize argument parsing 2026-06-10 23:38:54 +02:00
Nicolas Le Cam 6785a6c769 fix: minor print_manual_instructions regression dev-0.43.0-rc.272 2026-06-09 21:51:23 +02:00
Nicolas Le Cam c59a76375a review: cleanup code, comments and uneeded undocumented RTK_CLAUDE_DIR now that we have CLAUDE_CONFIG_DIR 2026-06-09 21:51:23 +02:00
Christian C. Berclaz 9671d9ea7e refactor(init): address review feedback on CLAUDE_CONFIG_DIR PR
- restore migration Outdated check in hook_check (binary registered +
  legacy script present still reports Outdated until cleanup)
- add error context to resolve_claude_dir call sites (provider, integrity)
- use CLAUDE_DIR const instead of literal in telemetry + provider test
- simplify settings_path construction in print_manual_instructions

Refs #2087
2026-06-09 21:51:23 +02:00
Christian C. Berclaz 05de9d366a fix(init): respect CLAUDE_CONFIG_DIR for global paths
rtk init -g ignored CLAUDE_CONFIG_DIR and always targeted ~/.claude.
Honor the env var Claude Code uses to relocate its config directory.

Priority: RTK_CLAUDE_DIR > CLAUDE_CONFIG_DIR > $HOME/.claude.
Empty values are treated as unset. Manual-step instructions now
print the resolved path instead of a hardcoded ~/.claude.

All callsites that previously hardcoded home.join(CLAUDE_DIR) now use
the shared resolve_claude_dir(): hook_check (rtk gain), integrity
(rtk verify), telemetry, and discover (rtk discover).

Closes #633
2026-06-09 21:51:23 +02:00
aesoft 047f4545ce Merge pull request #1956 from vdufloth/feat/mvn-rust-module
feat(mvn)!: Rust module replacing TOML filter, adds test phase support
dev-0.43.0-rc.271
2026-06-08 13:41:34 +02:00
Vinicius Dufloth f8bc856078 style(mvn): align overflow tail with canonical '… +N more {label}' shape
Match the join_with_overflow convention (ellipsis char, '+N more' label)
used by container, aws, gh and glab so the LLM sees one consistent
overflow style. The tee '[full output: …]' recovery hint already comes
from core tee_and_hint via RunOptions::with_tee, so capped failure output
carries the canonical recovery path unchanged.
2026-06-07 14:36:46 -03:00
Vinicius Dufloth 3c0ee949d4 refactor(mvn): bind failure cap to truncate::CAP_WARNINGS, drop config knob
Replace the per-filter LimitsConfig::mvn_max_failures field with a local
const MAX_MVN_FAILING_CLASSES = CAP_WARNINGS, matching the canonical cap
binding used by pytest/rspec/rake/runner. Align cap = 0 semantics with the
core policy (summary-only: no blocks emitted, tail still counts) instead
of the old opt-out meaning, so the future config surface lands without a
special case.
2026-06-07 14:35:41 -03:00
Vinicius Dufloth f026cfd750 Merge branch 'develop' into feat/mvn-rust-module 2026-06-07 14:30:38 -03:00
aesoft 63a76dedff Merge pull request #1645 from KuaaMU/master
fix(filters): remove max_lines cap from helm filter that truncates template output
dev-0.42.4-rc.270
2026-06-07 15:36:42 +02:00
aesoft 9574007f77 Merge pull request #2135 from dessite/fix/aws-json-preserves-values-for-unsupported-subcommands
fix(aws): preserve values in JSON output for unsupported subcommands
2026-06-07 15:32:47 +02:00
aesoft 35273c2dc1 Merge pull request #2181 from rtk-ai/fix/curl-binary-passthrough-1087
fix(curl): passthrough binary downloads to prevent UTF-8 corruption (#1087)
dev-0.42.4-rc.268
2026-06-07 15:20:08 +02:00
Vinicius Dufloth df76528dd3 fix(mvn): strip post-failure help boilerplate in non-quiet mode
filter_quiet already dropped the help block Maven emits after
'Failed to execute goal' (See ..., -> [Help 1], Re-run Maven, help
URLs, bare [ERROR] dividers); the non-quiet paths kept it via the
[ERROR] catch-alls — keep_outside_block for test/package and
filter_compile's own [ERROR] branch.

Promote QUIET_BOILER_PREFIXES to a shared BOILER_PREFIXES (+
is_boilerplate(), which also covers the bare [ERROR] divider lines,
matching filter_quiet's existing drop) and reject boilerplate before
each [ERROR] catch-all. The list deliberately keeps the resume hint
([ERROR] After correcting the problems... / [ERROR]   mvn <args>
-rf :module) — actionable signal for resuming a multi-module build —
and the Failed to execute goal terminator.

keep_continuation hygiene (defensive parity, not a demonstrated bug):
filter_surefire only reset the flag inside its kept branch, so a
dropped [ERROR] line would leave it stale and a following indented
line could be wrongly kept. No committed fixture exhibits the leak;
add the same end-of-loop fall-through reset filter_package already
has. filter_compile resets on its new boilerplate drop path.

Multifail-slice savings rise from 19.9% to 42.3%; threshold pinned
at >=30% to match the reactor-fail precedent. README: document the
stripping and drop the stale duration-normalisation bullet (that
behaviour was removed in 77e28d0).
2026-06-06 11:12:10 -03:00
Vinicius Dufloth be28a51179 fix(ci): pin fixture line endings, harden CRLF tests
test (windows-latest) failed on the two CRLF tests: with no
.gitattributes, the Windows runner's core.autocrlf=true checks fixtures
out with CRLF, include_str! embeds \r\n, and the tests'
replace('\n', "\r\n") synthesis produces \r\r\n. str::lines() strips
only the final \r\n of each pair, leaving a stray \r that $-anchored
regexes (MODULE_BANNER, BUILD_FOOT) reject — dropping the module banner
and BUILD SUCCESS in the CRLF leg only. Real Maven CRLF output (single
\r\n) was always handled; only the synthesized double-CR leg broke.

Root-cause fix: tests/fixtures/** -text — fixtures are byte-exact
filter inputs; eol conversion must never touch them. Defense-in-depth:
the two CRLF tests normalize the embedded fixture back to LF before
synthesizing, so they stay correct even on checkouts without
attributes (zip downloads, pre-existing autocrlf clones).

Also fixes the test doc comment, which claimed str::lines() keeps the
trailing \r of a \r\n pair — it strips it; the hazard is the doubled
\r\r\n, not single CRLF.
2026-06-06 11:07:46 -03:00
Vinicius Dufloth 1050cfeadc fix(mvn): re-arm failure trail on per-test sublines
Surefire 3.x emits one blank-separated detail block per failing test
under a single class close line. The trail previously ended at the
first blank line and never re-armed, so failures after the first lost
their exception message (unindented -> dropped) and leaked the full
junit/jdk framework stack (indented -> kept by keep_continuation).

SurefireBlock now remembers the trail's keep/drop decision when it
ends at a blank line (trail_rearm) and re-enters the trail on the next
per-test subline with the same decision — a capped class drops all its
per-test blocks, not just the first. Any other non-blank line disarms
re-entry; RUNNING/commit/drop clear it so an unrelated class can never
inherit the decision. Extra blanks between per-test blocks stay armed.

Per-test sublines use '<<< ERROR!' for thrown (non-assertion)
exceptions — accept both markers via a shared is_per_test_subline()
(also reused by filter_quiet, which already re-armed correctly), and
widen the CLOSE regex to tolerate an ERROR! marker defensively
(Surefire 3.5.5 emits FAILURE! even for errors-only classes, per the
fixture capture; detection keys off the counts, not the marker).

Fixture captured from real Maven 3.9.9 / Surefire 3.5.5 output against
the new tests/fixtures/multifail-skeleton/ (CalcTest: assertion failure
+ thrown exception in one class; BoomTest: errors-only class). A
byte-exact pin locks the single-failure path unchanged.
2026-06-06 11:05:05 -03:00
aesoft 0a630fe9ac Merge pull request #2289 from rtk-ai/refacto/strip-output-decorators
refacto(cmds): strip decorator noise from filter output
dev-0.42.4-rc.267
2026-06-05 18:31:39 +02:00
Adrien Eppling 16d6599b4c refacto(cmds): strip decorator noise from filter output
Separator lines (═══, ---) and an emoji status marker cost tokens
without adding signal for the LLM — RTK output must never add noise
over raw. Semantic labels are kept; the emoji is swapped for plain
monochrome unicode.
2026-06-05 17:41:53 +02:00
aesoft 98108bfcd7 Merge pull request #2288 from rtk-ai/chore/merge-master-into-develop
chore: merge master into develop
dev-0.43.0-rc.264
2026-06-05 17:14:38 +02:00
Adrien Eppling a1ef0ef036 chore: merge master into develop (security port + release bump) 2026-06-05 17:13:31 +02:00
aesoft e1cd274ab9 Merge pull request #2286 from rtk-ai/fix/cve-permission-hardening-port
fix(security): port permission hardening from master + Copilot CLI adaptation
dev-0.43.0-rc.263
2026-06-05 17:07:52 +02:00
Adrien Eppling 66d66b1fe6 fix: semgrep markers on test-fixture sensitive paths 2026-06-05 16:20:08 +02:00
Adrien Eppling 7a985c7b22 test(hook): Copilot CLI acceptance tests 2026-06-05 16:03:00 +02:00
aesoft f525ceecf4 fix(openclaw): no execSync to avoid async dangerous cmds 2026-06-05 14:03:49 +02:00
aesoft e16aa26162 fix(permissions): >&file redirect no allow + scope Gemini/Cursor config 2026-06-05 14:03:48 +02:00
aesoft f88b6bec13 fix(permissions): project-first config lookup for Gemini/Cursor 2026-06-05 14:03:46 +02:00
aesoft 4c9b14ef54 refacto(permissions): fmt 2026-06-05 14:03:45 +02:00
aesoft 1ccf6e3da7 fix(permissions): add test for cursor and gemini settings perm 2026-06-05 14:03:44 +02:00
aesoft a4bb55efa9 fix(permissions): cursor and gemini use correct permissions settings file
-
2026-06-05 14:03:42 +02:00
aesoft 952245d39d fix(permissions): never auto-allow not evaluable + defer to the agent
- Decompose compound commands for permission checks (newline, background &, subshell `( )`) in addition to &&, ||, ;, | so hidden segments are checked.
- `contains_unattestable_construct`: flag command/process substitution and file-target redirects (fd-dup `2>&1` and /dev/null exempt) — RTK can't decompose these, so they are never auto-allowed.
- Route every host hook (Claude, VS Code, Gemini, Cursor, Copilot CLI) through a single decision flow. Precedence: Deny → (defer if unattestable) → Allow → Ask → Default. Auto-allow only on a positive Allow; otherwise defer to the host's own engine.
- Gemini: ask_user instead of hardcoded allow. Cursor: empty `{}` delegation, since permission:"ask" is not enforced on its sandboxed shell.
2026-06-05 14:02:06 +02:00
aesoft c873e19b0d Merge pull request #2283 from rtk-ai/release-please--branches--master--components--rtk
chore(master): release 0.42.2
v0.42.2
2026-06-05 12:57:30 +02:00
rtk-release-bot[bot] 4be04e0bdc chore(master): release 0.42.2 2026-06-05 10:48:27 +00:00
aesoft e1bc0bd9d0 Merge commit from fork
fix(permissions): never auto-allow not evaluable cmds, defer to hosts
2026-06-05 12:47:41 +02:00
aesoft ce362970e5 fix(permissions): >&file redirect no allow + scope Gemini/Cursor config 2026-06-03 20:56:44 +02:00
aesoft 084fa84e9a fix(permissions): project-first config lookup for Gemini/Cursor 2026-06-03 18:55:00 +02:00
aesoft 86ebbb3c5e refacto(permissions): fmt 2026-06-03 18:28:20 +02:00
aesoft f181184b40 fix(permissions): add test for cursor and gemini settings perm 2026-06-03 18:20:37 +02:00
aesoft 6ab149ba3e fix(permissions): cursor and gemini use correct permissions settings file
-
2026-06-03 18:15:19 +02:00
aesoft cdcdb6863a fix(permissions): never auto-allow not evaluable + defer to the agent
- Decompose compound commands for permission checks (newline, background &, subshell `( )`) in addition to &&, ||, ;, | so hidden segments are checked.
- `contains_unattestable_construct`: flag command/process substitution and file-target redirects (fd-dup `2>&1` and /dev/null exempt) — RTK can't decompose these, so they are never auto-allowed.
- Route every host hook (Claude, VS Code, Gemini, Cursor, Copilot CLI) through a single decision flow. Precedence: Deny → (defer if unattestable) → Allow → Ask → Default. Auto-allow only on a positive Allow; otherwise defer to the host's own engine.
- Gemini: ask_user instead of hardcoded allow. Cursor: empty `{}` delegation, since permission:"ask" is not enforced on its sandboxed shell.
2026-06-03 17:57:29 +02:00
aesoft 4f4a6a02ae Merge pull request #1266 from shalk/fix/commit-multibyte-panic-rebased
fix(git): fix panic on multibyte chars in commit output
dev-0.43.0-rc.260
2026-06-03 17:20:40 +02:00
aesoft 57e935094b Merge pull request #2239 from KuSh/1669-restore_double_dash-fix
fix(grep): command token duplication in output withsame value filename or positional arg
dev-0.43.0-rc.259
2026-06-03 15:55:22 +02:00
aesoft f490ab7819 Merge pull request #2240 from rtk-ai/release-please--branches--master--components--rtk
chore(master): release 0.42.1
v0.42.1
2026-06-03 14:43:24 +02:00
rtk-release-bot[bot] 9664e27038 chore(master): release 0.42.1 2026-06-03 12:37:40 +00:00