Repository navigation
Conversation
Adds 5 TOML filters for the Pulumi CLI, matching the existing OpenTofu/ Ansible/Terraform TOML-based pattern. Filters strip known noise (header banners, View Live URLs, policy pack loading, @ progress spinners, intermediate creating/updating/deleting rows, Duration, Node.js stack trace frames) while preserving resource change rows, policy violations, diagnostics, outputs, and summaries. Measured savings on a real neo-migration AWS project (~30 resources, Pulumi Cloud backend): pulumi up 65.8%, pulumi destroy 72.3%, preview --refresh 40.7%, refresh 34.9%, stack 29.3%. Lower savings on already- compact output (clean preview ~9%) because remaining content is signal per the correctness-over-compression design philosophy. Registers matching RtkRule in src/discover/rules.rs so the rewrite hook transparently proxies `pulumi <subcmd>` through `rtk pulumi`. Bumps BUILTIN_TOML filter count 59 -> 64 and updates the expected-filter list and concat-discoverability test. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Revert CHANGELOG.md (release-please CICD generates from commit msg) - Narrow pulumi-stack match_command to explicit subcommand whitelist (bare stack, ls, output, history, select, init, rm, rename, tag, unselect, change-secrets-provider). Excludes export (JSON state) and graph (DOT), which now passthrough unfiltered. - Lower savings_pct 70 -> 45 (measured mean across 5 subcommands). Populate subcmd_savings with measured values: up=66, destroy=72, refresh=35, preview=25, stack=29. JSON-safety (self-found during review validation): - All 5 pulumi subcommands support -j/--json; Rust regex crate has no lookahead so match_command can't negatively exclude --json. - Remove max_lines from all 5 filters; strip patterns don't match JSON structure so JSON passes through unfiltered. - Remove ^\\s*\\}\\s*$ strip pattern (was targeting Node.js stack trace trailers, but also matched legitimate JSON closing braces). Verified on neo-migration stack: - pulumi stack ls/output/history/export, preview --json, stack graph: byte-identical with RTK_NO_TOML=1 baseline (filter transparent). - Human-readable preview still compresses (~20% on clean state). - 10/10 inline pulumi tests pass; 1449/0 full cargo test suite. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mplate output The helm filter had `max_lines = 40` which silently truncates output from commands like `helm template` that legitimately produce hundreds of lines of YAML manifests. This caused CI/CD pipelines to apply incomplete sets of manifests (only first ~40 lines). Other filter settings (strip_ansi, strip_lines_matching for blanks and glog warnings, truncate_lines_at for individual line length) provide sufficient output hygiene without capping total line count. Added regression test verifying multi-document YAML output is preserved in full without truncation. Fixes rtk-ai#1626
There was a problem hiding this comment.
Pull request overview
This PR improves the command-rewrite registry so hook rewrites to rtk grep normalize common grep/rg flag orderings (notably moving compatible flags after <pattern> <path>), reducing clap parse failures and preserving intended searches for common flag shapes.
Changes:
- Add a
grep/rg-specific rewrite path that shell-splits the command, recognizes a set of supported flags, and reorders them into anrtk grep <pattern> [path] <extra_args...>form. - Introduce shell-quoting for rewritten args to produce a safely re-runnable command string.
- Add unit tests covering normalized flag order,
--globnormalization, and conservative skipping for$PATTERN/ empty quoted patterns.
|
cc @pszymkowiak @aeppling — CLA is now signed, PR should be unblocked for review. @pszymkowiak this PR sits in the same hook-rewrite area you recently merged in #1718; the change here is the grep/rg flag-normalization half discussed in #1604/#1833/#1824. I kept it deliberately narrow: it normalizes common grep/rg flag placement before |
59d89be to
41f3551
Compare
|
Addressed the Copilot review points in the latest push:
I also added regression coverage for both cases. |
Replaces the stateless src/filters/mvn-build.toml (4 phases, 50-line cap) with
a Rust module under src/cmds/jvm/mvn_cmd.rs handling all common Maven lifecycle
phases with stateful Surefire/Failsafe block collapse.
Why TOML couldn't do this: the dominant noise on a healthy Maven project is
expected-exception stack traces inside passing tests (assertThrows). Collapsing
these requires deciding to drop a block based on its closing
`Tests run: N, Failures: 0, Errors: 0` line — a stateful decision the TOML DSL
cannot express.
Measured savings on synthetic full-shape fixtures (~1100 lines each, gzipped):
- mvn test: 3 422 tok → 36 tok (98.9% savings)
- mvn install: 3 460 tok → 85 tok (97.5% savings)
Coverage:
| Phase | Filter |
|------------------------------------|----------------------------------------|
| test, integration-test | filter_surefire (block collapse) |
| compile, test-compile | filter_compile (ERROR + indent + dedup)|
| package, install, verify, deploy | filter_package (compile + surefire) |
| clean, site, plugin goals, version | passthrough |
Key behaviours:
- ANSI strip first in every filter (real Maven output contains colour escapes).
- English-footer guard: if no `BUILD SUCCESS`/`BUILD FAILURE` line is present,
return ANSI-stripped raw input unchanged — protects non-English locales.
- Verbose bypass: `-X`, `--debug`, `-e`, `--errors` skip filtering.
- Stack-frame deny-list strips framework frames (`at org.junit.`, `at java.util.`,
`at sun.reflect.`, etc.); user-code frames (any other prefix) preserved.
- Duration normalisation (`Time elapsed: 2.341 s` → `Time elapsed: T s`) for
deterministic test output.
- Wrapper detection: `./mvnw` / `mvnw.cmd` via string-literal `Command::new`
(semgrep-safe); falls back to `resolved_command("mvn")`.
Hook regex changes (src/discover/rules.rs):
- Adds wrapper prefixes (./mvnw, mvnw.cmd, mvnw).
- Adds test, integration-test, verify, deploy to the alternation.
- Drops clean + site so bare invocations bypass RTK entirely (0 overhead).
- Lazy quantifier skips flags before the goal (`mvn -B clean install` now
rewrites correctly; previously failed because the regex required the goal
as the first token after `mvn`).
- Drops subcmd_savings (lazy match captures first phase, which would mis-tier
`clean install` to clean); uses flat 82.0.
Tests:
- 33 unit tests in mvn_cmd.rs (phase detection, footer guard, framework deny,
duration normalisation, ERROR continuation, WARNING dedup, install/jar lines).
- 2 inline savings assertions on gzipped synthetic full fixtures (~3 KB each)
using flate2 already in Cargo.toml. Run as part of standard `cargo test --all`.
- 12 classifier/rewrite tests in src/discover/registry.rs under new Maven
section.
Files changed:
- ADD src/cmds/jvm/mvn_cmd.rs (~810 LoC incl. tests)
- ADD src/cmds/jvm/README.md (documents whitelist omission decision)
- ADD tests/fixtures/mvn_*_raw.txt (6 inline) + 2 .gz synthetic full fixtures
- MOD src/main.rs (1 use, 1 Commands variant, 1 dispatch arm)
- MOD src/discover/rules.rs (replace mvn entry)
- MOD src/discover/registry.rs (12 classifier tests)
- MOD src/core/toml_filter.rs (drop mvn-build from expected-filters list,
adjust the 2 count assertions)
- DEL src/filters/mvn-build.toml
Fixtures are entirely synthetic — generic `com.example.app.*` package names and
`com.example:myapp` Maven coordinates. Same SHAPE as real Maven output (block
structure, ANSI codes, framework stack frames, BUILD footer, plugin banners)
without any project-identifying content.
Integrity-check whitelist: Commands::Mvn is intentionally omitted from
is_operational_command at src/main.rs:2455-2501, matching the gradle precedent
(Commands::Gradlew also omitted). The whitelist is opt-in by design per the
comment at L2452-2454 — filter modules invoked through an already-verified
hook do not need a second integrity check on their own dispatch path.
Documented in src/cmds/jvm/README.md.
Out-of-scope (follow-ups noted in module + README):
- Parallel mode `-T2C` (interleaved blocks across threads).
- Plugin goals (`mvn dependency:tree`, `mvn versions:*`).
- `mvnw.bat` legacy wrapper (Maven Wrapper 3.x emits `.cmd`).
BREAKING CHANGE: `rtk mvn <args>` output format changed. Previously: TOML
filter strips INFO/Downloading lines and caps at 50 lines. Now: state-machine
filter with Surefire block collapse + locale guard + verbose bypass. Different
output shape; significantly better savings tier; behaviour is otherwise a
superset (all previously-handled cases still handled, plus test/verify/etc.).
CLOSE regex previously required ` - in ` (single-dash, Surefire 2.x). Surefire 3.x emits ` -- in ` (double-dash), so close lines never matched on Maven 3.9 default toolchains: blocks stayed open, every new `[INFO] Running …` flushed the prior block as kept, and real-world savings dropped to ~27% on commons-cli. Changes: - CLOSE separator widened to `\s+--?\s+in ` (matches 2.x and 3.x). - CLOSE prefix widened to `INFO|ERROR|WARNING` (3.x emits WARNING for classes whose only tests are skipped). - `filter_surefire` and `filter_package` gain a `failure_trail` flag: Surefire 3.x emits the exception class and stack frames *after* the CLOSE line; keep them (stripping framework frames) until the next blank line. Without this, the failing-test signal was silently dropped. Fixtures replaced with output from a real `apache/commons-cli` build in `maven:3.9-eclipse-temurin-21`. Synthetic 2.x shape removed; 2.x compat locked by a dedicated unit test using the single-dash separator. Measured token savings on commons-cli fixtures: - `mvn test` (full): 1896 -> 38 tokens (98.0%) - `mvn install` (full): 2021 -> 78 tokens (96.1%) Refs: pszymkowiak review on PR rtk-ai#1956
`normalise()` rewrote real `Time elapsed: N s` and `Total time: N s` values to `T s` in the shipped output. That was only ever useful for keeping snapshot tests deterministic and never belonged in production: test perf signal is exactly the kind of data the LLM needs to spot a regression, and there are no insta snapshots in this module to protect. - Remove `normalise()` and its `TIME_DURATION` / `TOTAL_TIME` regexes. - All `filter_surefire`, `filter_compile`, `filter_package` emit sites pass the raw line through. - Renamed and inverted `surefire_normalises_durations` → `surefire_preserves_real_durations`: asserts `2.341 s` and `Total time: 4.567 s` survive filtering. Refs: pszymkowiak review on PR rtk-ai#1956 (E.1)
Under `mvn -q`, Maven 3.x suppresses all `[INFO]` lines: no `BUILD SUCCESS` footer, no `[INFO] Running` markers, no module banners. The existing surefire/compile/package filters all key off the English-footer guard and `[INFO] Running`/CLOSE state machine, so under `-q` they fell through and shipped the raw output unchanged (0% savings on PR rtk-ai#1956 reviewer's measurement). Reviewer (@pszymkowiak on PR rtk-ai#1956) listed `-q` handling in the path-to-merge as "worth a note or handling". This commit implements the handling. Behavior captured from `mvn -q test` on Maven 3.9.9 + Surefire 3.5.5 with JUnit 5: - Green run emits ZERO bytes — filter returns empty output. - Failure run emits ~27 lines: per-class CLOSE line, exception + stack trace, `[ERROR] Failures:` summary, aggregate `[ERROR] Tests run: N, Failures: F, ...`, and the `[ERROR] Failed to execute goal` terminator, followed by a ~10-line `[ERROR] See .../[Help 1].../Re-run Maven .../To see the full stack trace .../For more information ...` boilerplate block pointing at log files and help URLs. `filter_quiet` keeps the failure-signal lines and the user-code stack frames; drops the framework frames (existing deny-list) and the post-failure boilerplate block. Routing: `is_quiet` checks argv for `-q` or `--quiet`. When set, `run()` short-circuits the phase-based filter selection and routes non-passthrough phases to `filter_quiet`. Passthrough phases (`clean`, `site`, plugin goals) remain passthrough under `-q`. Measured savings on the captured fail fixture: 51.1% (174 -> 85 tokens). Green run: 0 -> 0 (no overhead). Safety net: unclassified `[ERROR]` lines are kept rather than dropped — better to leak a line than hide signal. Tests added (7): - `quiet_detects_short_flag` / `quiet_detects_long_flag` / `quiet_does_not_match_unrelated_flags` for `is_quiet`. - `quiet_green_run_is_empty` — empty input contract. - `quiet_fail_strips_framework_and_boilerplate` — kept-list and drop-list assertions on the real fixture. - `savings_mvn_quiet_fail` — >=50% savings target on the fixture. - `quiet_unknown_error_line_kept_as_safety_net` — unclassified `[ERROR]` not silently dropped. New fixture: `tests/fixtures/mvn_quiet_fail_raw.txt` (27 lines, 770 bytes) captured from a real `mvn -q test` run against a JUnit 5 / Surefire 3.5.5 project with one failing test.
When `mvn test` fails at the compile step before Surefire runs, the `[ERROR]` block's indented `symbol:` / `location:` / `^` continuation lines were being dropped. `filter_surefire` had no `keep_continuation` state, unlike `filter_compile:302` and `filter_package:408`. Add the missing state machine: reset in the RUNNING branch, set on each kept `[ERROR]` line (except `Tests run:` / `Failures:` / `Errors:` headers — same predicate as `filter_package:402-405`), and pass through indented continuation lines before the outside-block keep-list check. Fixture `mvn_test_compile_fail_slice_raw.txt` captures the `mvn test` slice for a project with a deliberate `cannot find symbol` in a `src/main/java` source. New tests: - `surefire_keeps_compile_continuation_on_test_phase` — the bug. - `package_still_keeps_compile_error_continuation_after_refactor` — drift guard on the `install`/`verify` path.
`filter_surefire` and `filter_package` had a ~30-line duplicated state
machine for Surefire/Failsafe per-class blocks (RUNNING / in-block
buffer / CLOSE branching / failure-trail). The duplication is what let
the P0 continuation bug land — the fix had to be applied in only one of
the two filters.
Introduce `SurefireBlock` owning that inner machine: PLUGIN_BANNER skip,
RUNNING (with prior-block flush on truncated output), in-block
buffering, CLOSE detection, and the post-close failure-trail with
framework-frame stripping.
Each `step()` returns `SurefireStep::{Consumed, FailingClose, Passthrough}`.
The `FailingClose` arm defers the actual write to the caller via
`commit_failing()` — this is the seam Commit D will use to enforce the
`mvn_max_failures` cap without duplicating the cap logic.
Outside-block keep logic stays inside each filter unchanged
(`MODULE_BANNER || keep_outside_block`, `[WARNING]` dedup, the
`keep_continuation` flag from Commit A). Byte-identical filter output —
all existing `surefire_*` / `package_*` / token-savings tests pass.
The previous free helpers `flush_block_as_keep` and `emit_block` are
removed; their behaviour now lives in `SurefireBlock::flush_open_block_as_keep`
and `SurefireBlock::commit_failing`.
In a reactor build (parent pom with `<modules>`), Maven appends a
`Reactor Summary for <root>` block at the end listing each module's
status:
[INFO] Reactor Summary for multi-module-skeleton 1.0.0-SNAPSHOT:
[INFO]
[INFO] multi-module-skeleton ...... SUCCESS [ 0.353 s]
[INFO] child-a .................... SUCCESS [ 1.676 s]
[INFO] child-b .................... FAILURE [ 0.940 s]
`filter_surefire` / `filter_package` were dropping these rows because
`keep_outside_block` only keeps `[INFO]` lines that match a specific
prefix (`Building`, `Installing`, `Total time:`, etc.). The per-module
status rows match none of them.
Add a `REACTOR_SUMMARY` regex and `reactor_summary_keep` helper that
toggles a flag on the header and clears it on `BUILD SUCCESS` /
`BUILD FAILURE`. While the flag is set the helper returns `true` so
the rows survive — including `[WARNING]` (activated-profile notices)
and the in-summary horizontal rule. Caller invokes the helper before
`keep_outside_block` so the clears-flag side effect runs regardless
of `||` short-circuit.
Fixtures captured against a hand-rolled 2-module skeleton checked in
under `tests/fixtures/multi-module-skeleton/` (parent pom + child-a
+ child-b with `Empty.java` stubs). The fail fixture is captured by
temporarily replacing child-b's `Empty.java` with one that references
a `BogusType` symbol. Reproducible from the committed skeleton.
`filter_surefire` / `filter_package` emitted unbounded output on builds with hundreds of failures — the per-class failing blocks (with their post-close exception trail) plus every `[ERROR] ClassA.test:N …` entry in the `[ERROR] Failures:` summary were all kept. Other RTK filters (git/cargo/lint) already cap with `... +N more` tails; bring mvn in line. Add `LimitsConfig::mvn_max_failures` (default 25, matching the `grep_max_per_file: 25` convention in the same struct; `0` = opt out) and wire it into two cap sites: 1. Failing-class blocks. The shared `SurefireBlock::step()` machine yields `FailingClose` once per failing class; the outer loop now commits the first N and calls a new `drop_failing()` for the rest. `drop_failing()` enables a `drop_trail` flag so the post-close per-test subline, exception, and user frames are consumed silently until the next blank line. After the loop, if any were dropped, `\n... +N more failing test classes\n` is appended. 2. `[ERROR] Failures:` summary block. New `FailuresSummaryCap` helper tracks the header, caps `[ERROR] ` entries at the same limit, and pre-emits `\n... +N more failures\n` immediately before the aggregate `[ERROR] Tests run: …` line. Tail wording follows the existing repo convention — no `[INFO]` prefix, no parenthetical hint (`cargo_cmd.rs:1035` uses the same `\n... +N more failures\n` verbatim). Tests: - `surefire_caps_failing_blocks_emits_tail` — synthetic 5-failure fixture with `cap = 3`; asserts blocks 1-3 emitted, 4-5 dropped, tail emitted. - `surefire_cap_zero_disables_capping` — same fixture with `cap = 0`; all 5 blocks kept, no tail. - `failures_summary_block_is_capped` — 5-entry summary with `cap = 3`; asserts entries 1-3 kept, 4-5 dropped, tail emitted *before* the aggregate. Behaviour-change note: the default cap of 25 means users without a custom config get a bounded output for the first time. Existing fixtures all have <25 failures so no current test diffs.
Three small reviewer-suggested cleanups:
- `[WARNING] ` prefix slicing in `filter_compile` / `filter_package`
was written defensively as `&line["[WARNING] ".len().min(line.len())..]`.
Both call sites are already gated by `line.starts_with("[WARNING]")`
so the `min` is dead defence. Use `strip_prefix(...).unwrap_or(line)`
which reads identically to the rest of the module.
- `SurefireBlock` and `SurefireStep::FailingClose` now borrow lines
from the post-ANSI-strip `String` (`Vec<&'a str>` / `Option<&'a str>`
/ `&'a str` close), tied to the `stripped` local in
`filter_surefire_with_cap` / `filter_package_with_cap`. No
`.to_string()` allocations on the hot per-line path; the slice
fixtures' savings tests are unaffected and the gzipped full-fixture
tests still hit ≥90%/≥85%.
- New `surefire_handles_crlf_line_endings` and
`package_handles_crlf_line_endings` tests assert byte-equality
between an LF-filtered fixture and a CRLF-converted-then-LF-normalised
one. Catches the class of bug where exact-equality line checks
silently miss CRLF input because `str::lines()` strips `\n` but
keeps trailing `\r`.
`develop`'s Cargo.lock has its rtk-package entry pinned at `0.36.0` while `Cargo.toml` says `0.34.3` — the lock is internally stale on develop. When `cargo build` ran on this branch it re-pinned the lock to `0.34.3` to match `Cargo.toml`, producing the diff the reviewer flagged on PR rtk-ai#1956. Revert the lock to `develop`'s baseline so the PR's committed diff no longer touches Cargo.lock. `cargo build` will rewrite the working-tree lock on every invocation; that's a local artifact, not part of the committed PR.
The generic AWS handler (used for subcommands outside the hardcoded
specialized list) called json_cmd::filter_json_string, which extracts
a type-only schema and discards every value.
$ rtk aws backup describe-global-settings --output json
{
GlobalSettings:
{
isCrossAccountBackupEnabled: string,
isDelegatedAdministratorEnabled: string,
isMpaEnabled: string
}
LastUpdateTime: string
}
Callers got the schema instead of the data they asked for.
Swap to json_cmd::filter_json_compact, which preserves values while
still applying depth, string-length, and array-size truncation:
$ rtk aws backup describe-global-settings --output json
{
GlobalSettings:
{
isCrossAccountBackupEnabled: "false",
isDelegatedAdministratorEnabled: "false",
isMpaEnabled: "false"
}
LastUpdateTime: "2026-05-28T09:52:17.525000+02:00"
}
Affects every AWS subcommand not on the hardcoded list (backup,
route53, kms, ssm, apigateway, ...) when output is valid JSON
(explicit `--output json` or auto-injected for describe-/list-/get-/scan).
`rtk curl <binary-url>` silently corrupted any binary download (tarballs, zip, png, pdf, ELF, ...) because the response body was captured via `String::from_utf8_lossy` in `core::stream::exec_capture`. Every non-UTF-8 byte got replaced with U+FFFD (3 bytes: 0xEF 0xBF 0xBD), so gzip magic 1f 8b 08 00 arrived at downstream consumers as 1f ef bf bd 08 00 and `tar -xzf` complained "not in gzip format". Now `rtk curl` runs `Command::output()` directly to keep stdout as `Vec<u8>`, then checks `std::str::from_utf8(&bytes).is_err()`. If the response is not valid UTF-8 (i.e. the lossy conversion would corrupt it), raw bytes are written through to stdout via `write_all` and tracking is recorded as passthrough (0% savings — token counts over binary content have no meaning). The text/JSON code path is unchanged. Verified live on 18 real binary formats (rtk's own release artifacts, ripgrep, bat, fd, hyperfine, gh, tokei, kubectl ELF 51MB, rustup-init 20MB, W3C PDF, ISO 9899 PDF 4MB, GitHub avatar PNG, Wikimedia GIF, WebP sample, MP3/MP4/WAV samples) — all byte-identical to raw curl. 10 text regression tests (JSON/HTML/Markdown/Cargo.toml/RFC) confirm the text path keeps its existing behavior. Closes rtk-ai#1087
Next Release
…master--components--rtk chore(master): release 0.42.3
|
Independent datapoint + a note on rebasing, in case it helps move this along. The problem is live and high-volume. Pulling my own
A heads-up on staleness. I checked out this branch and built it locally; it reports So there's real overlap between this PR and what's already merged. It's probably worth rebasing onto Happy to re-test the rebased branch against my real failing-grep corpus (the shapes above) and report back if that's useful. |
Register RTK with Factory Droid so shell commands the agent runs are transparently rewritten to their token-saving `rtk` equivalents. - `rtk init --agent droid`: install a native PreToolUse hook into ~/.factory/settings.json (matcher "Execute"); supports global (-g) and project scope, the FACTORY_HOME override, idempotent install with backup + atomic write, and a clean uninstall round-trip. - `rtk hook droid`: process Droid's PreToolUse payload (BOM strip, stdin cap, JSON-parse fallback), mirroring the existing provider hooks. - Deny verdict steps aside (no output) so Droid's native deny handling fires, matching Claude/Cursor/Copilot and the PermissionVerdict::Deny contract. - Rewrites are auto-allowed: Droid only applies a hook's updatedInput when the decision is "allow", so we mirror run_cursor to avoid silently dropping the rewrite (and its savings) on the default verdict.
Droid 0.140.0 applies a PreToolUse hook's updatedInput regardless of the permission decision (verified empirically + via binary decompile), so the forced permissionDecision:"allow" was unnecessary. Worse, Droid resolves the decision as the first hook result carrying one (no deny-over-allow priority), so an unconditional allow could suppress another PreToolUse hook's deny/ask and bypass Droid's native prompt. Now omit permissionDecision by default and only assert allow on an explicit allow rule, mirroring process_claude_payload. The rewrite still lands via Droid's decision-independent "updated input result" path. Updated the inaccurate comment and the test that required allow.
Adopt the decide_from_verdict/HookDecision flow introduced on develop so the Droid handler gains the same safety behavior as Claude/Cursor/Copilot: commands with substitution or file redirects now Defer (no rewrite) instead of being rewritten, and deny/allow/ask mapping is shared instead of reimplemented. Also removes an unwrap() in the response builder. Claude-Session: https://claude.ai/code/session_01Vp4p5YroP2cfFvThhQE4Rv
Adversarial verification against Droid v0.164.0 (shipped code + docs) found two broken assumptions in the original integration: - Droid's canonical hooks file is hooks.json (root event map, no wrapper); the hooks key of settings.json is only a fallback that hooks.json shadows per event key. Droid's own /hooks UI writes hooks.json, so an RTK entry in settings.json silently dies as soon as the user adds any PreToolUse hook there. Install now targets the file whose PreToolUse array Droid actually reads (live hooks.json > live settings.json fallback > create canonical hooks.json), migrates stale copies, and uninstall sweeps root hooks.json, legacy hooks/hooks.json, and settings.json. - The config-home env var is FACTORY_HOME_OVERRIDE (replaces $HOME, with .factory appended), not FACTORY_HOME pointing at the config dir. Also corrects the 'legacy Bash matcher' comment (Droid never had a Bash tool; the acceptance is purely defensive) and records that the omit-permissionDecision rewrite path is confirmed in v0.164.0: decisions resolve as find(first result with a decision) and updatedInput applies via a separate path even when no decision is set. Claude-Session: https://claude.ai/code/session_01Vp4p5YroP2cfFvThhQE4Rv
The Droid hook consulted Claude Code's settings (Host::Claude), leaking
one agent's permission config into another: a Bash(...) allow rule in
~/.claude/settings.json could auto-allow commands in Droid, bypassing
its native prompt.
Add permissions::Host::Droid backed by ~/.factory/settings.json
(honoring $FACTORY_HOME_OVERRIDE as a home-dir override, matching the
shipped Droid CLI):
- commandAllowlist -> Allow: the rewrite carries permissionDecision
"allow", exactly the verdict Droid would emit natively.
- commandDenylist (always confirm) and commandBlocklist (never runs)
-> Deny: RTK steps aside entirely so Droid's native confirm/block
fires on the original command. Rewriting first would dodge Droid's
own pattern matching ("rtk git log" no longer matches a "git log"
denylist entry).
- Built-in defaults are mirrored from the shipped Droid CLI (verified
against v0.153.1); a user list replaces its default outright, same
as Droid's own accessor.
Also trims the wire-format comment per review feedback.
Verified live against droid 0.153.1: git status/git log rewrite and
auto-run at --auto low via the default allowlist; a denylisted git log
is left untouched and natively refused; uninstall round-trip clean.
Claude-Session: https://claude.ai/code/session_015CvKLxKMnmcvwY5CjHVTF5
Propagates the README Droid documentation to docs/guide/getting-started/supported-agents.md per review feedback: frontmatter description, agents table row, and an installation section covering hooks.json placement and Droid-native permission handling. Claude-Session: https://claude.ai/code/session_015CvKLxKMnmcvwY5CjHVTF5
When context flags (-A/-B/-C) are used, grep prints -- between non-adjacent match blocks. parse_match_line() returned None for this separator, and both output paths silently dropped it, merging distinct matches into one contiguous block. Fixes rtk-ai#2795
Native grep only prints -- between non-adjacent match blocks when -A/-B/-C context is requested. The grouped output path was inserting -- on any line-number gap unconditionally, so `rtk grep -rn todo` invented separators between every match that grep never emits. Gate the insertion on has_context_flag() which checks for -A/-B/-C and their long-form equivalents.
fix(grep): preserve -- separator between non-adjacent match blocks
chore(docs): add core contributor
…scopes Drop the hardcoded mirrors of Droid's built-in command lists and stop emitting permissionDecision entirely. RTK now steps aside only on explicit commandDenylist/commandBlocklist entries, unioned across all four settings scopes (user + project, settings.json + settings.local.json); every other command is rewritten via updatedInput and the decision is left to Droid's native flow. Verified against Droid CLI 0.153.1: updatedInput is applied after Droid's own permission evaluation of the original command, so native allowlist decisions are unaffected and deny entries fire natively. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SpSp3Arj7fG1XJYhXoCMGC
…ld-failure-2419 fix(cargo): surface --message-format=json build errors instead of "compiled"
fix(ccusage): accept `period` key from current ccusage
…pport feat: add git checkout support
feat(hooks): add Factory Droid integration
chore(docs): clean contributing outdated
…rtk-path fix: detect absolute rtk path in Claude hook settings
|
@aeppling, could you review this when you have time? You recently merged #2859 and #2748 in the same registry path.
|
|
Thanks for this, and for the careful test plan. Issue #1824 was fixed by #2641, shipped in v0.43: rg is now rewritten to rtk rg and grep to rtk grep with your arguments forwarded untouched, so flag ordering no longer needs normalizing, and #2333 hardened rtk grep's own argument parsing on top of that. I ran the six commands from your test plan against the current develop build, plus -L, -o and -E variants, and they all rewrite and execute correctly. Closing as covered, but please comment or reopen if you see a shape that still breaks. |
Summary
grep/rgflags before routing hook rewrites tortk grep, so agent-generated searches stop producing clap parse failures for supported shapes.-rn,-A/-B/-C,-E,-i,-o,-c,-l/-L, and-g/--globby moving compatible flags after thertk greppositionals.Fixes #1824.
Partially addresses #1833 by reducing hook-rewrite fallbacks for common grep/rg flag shapes.
Refs #1604, #236.
Test plan
cargo fmt --all --checkcargo clippy --all-targets -- -D warningscargo testtarget/debug/rtk hook check 'grep -n -A 40 begin{abstract} /tmp/file.tex'->rtk grep 'begin{abstract}' /tmp/file.tex -A 40target/debug/rtk hook check 'grep -ic warning /tmp/bib.log'->rtk grep warning /tmp/bib.log -i -ctarget/debug/rtk hook check 'rg -n "Project Guidelines" --glob CLAUDE.md .'->rtk grep "Project Guidelines" . --glob CLAUDE.mdtarget/debug/rtk hook check 'rg --version'-> no rewritetarget/debug/rtk hook check 'rg "$PATTERN" src'-> no rewritetarget/debug/rtk hook check "rg '' src"-> no rewriteLocal environment used for manual verification: macOS 26.5 (build 25F71), arm64, Apple M4. CI is expected to cover the repository's broader platform matrix.
Notes
This intentionally stays scoped to rewrite normalization. It does not attempt to redesign
rtk grep, changefind, or close the non-existent-subcommand portion of #1604.For #1833 specifically, this PR reduces fallback/parse failures in the hook-generated command path, but it does not fully extend the
rtk grepargument parser, implement the GNU-grep literal-Fpreservation rule when-Eis absent, or resolve the directrtk grep -l/--max-lencollision.