143 Commits

Author SHA1 Message Date
Nicolas Le Cam 7c18567155 chore: migrate to Rust edition 2024
Bump edition 2021 -> 2024. rust-version stays at 1.91, already well above
the 1.85 floor the edition needs; docs/guide/resources/troubleshooting.md
still claimed 1.70+, which is where a failed `cargo install --git` lands.

Four things the edition forces:

- std::env::{set_var,remove_var} are unsafe in 2024 with no safe std
  replacement. Rather than wrap the test call sites in unsafe -- which the
  crate denies and .semgrep.yml flags -- route them through temp-env, a
  dev-only dependency whose closure API is safe and which restores the
  previous value even when the body panics. The hand-rolled CLAUDE_DIR_LOCK
  and PI_DIR_LOCK guards existed only to serialise those mutations and are
  now redundant; CWD_LOCK and TEST_ENV_LOCK stay, they order more than the
  env var itself.

- unsafe_op_in_unsafe_fn is on by default, so the libc calls in the proxy
  signal handler and in stream.rs's relay handler need explicit unsafe
  blocks, scoped to the libc calls themselves.

- `gen` is a reserved keyword, so the closure by that name in diff_cmd.rs
  becomes make_lines.

- Tightened tail-expression temporary scopes let clippy prove the binding in
  setup_test_env is inlinable, so let_and_return now fires there.

if_let_rescope changes when the scrutinee temporary drops in an if let/else.
The two sites in show_claude_config take cargo fix --edition's match rewrite,
which keeps the 2021 drop timing.

rustfmt.toml is kept rather than dropped: cargo fmt passes --edition from
Cargo.toml, but a bare rustfmt invocation has no crate context and falls
back to edition 2015, which cannot parse the let-chains the next commit
introduces. Pinning it there keeps format-on-save and pre-commit hooks in
agreement with CI.

clippy::collapsible_if is allowed crate-wide for now; the follow-up commit
adopts let-chains and removes the allow.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 01:26:43 +02:00
Nicolas Le Cam 70ec493d0d chore: list command modules explicitly instead of via automod
Every ecosystem mod.rs under src/cmds/ generated its module list with
automod::dir!(). rustfmt only follows literal `mod` items and cannot expand
macros, so `cargo fmt` never reached any of those files -- and neither did
CI's `cargo fmt --all -- --check` gate, which has been silently passing
over half the crate.

Demonstrated by appending `fn   __probe( )->u8{let    x=1;x}` to a file
under src/cmds/: with automod, `cargo fmt --all -- --check` reports no
diff; with an explicit `pub mod`, it reports the diff and `cargo fmt --all`
fixes it. The preceding commit had to invoke rustfmt directly for the same
reason; from here `cargo fmt` covers the crate on its own.

Listing modules by hand trades one failure mode for another, so build.rs
now guards the new one: automod compiled any stray .rs file, whereas an
explicit list silently drops a file whose `pub mod` line is forgotten --
never compiled, never linted, tests never run, and check-test-presence.sh
still reporting PASS because it only greps the file for #[cfg(test)]. The
build now fails with the missing declaration named.

Declaring the modules explicitly also exposed clippy::module_inception on
cmds::git::git, which clippy skips inside macro-generated code. git.rs is
renamed to git_cmd.rs, which resolves the lint and matches the convention
its siblings already follow -- diff_cmd, gh_cmd, glab_cmd, gt_cmd. Docs
that point at the module are updated; sample command output that merely
shows a "git.rs" path is left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 01:26:43 +02:00
aesoft 79347d5e0e Merge branch 'master' into develop 2026-09-10 17:25:43 +02:00
Adrien Eppling a53373191d feat(recall): content-addressed recall store with selectable [retriever] mode
sqlite (default) queried by 'rtk recall'; tee (legacy files) and disabled modes retained.
2026-09-08 14:12:15 +02:00
Roopesh ad8cc55cd3 fix(license): use a valid SPDX identifier in package and formula metadata
`Apache 2.0` is not a valid SPDX expression, so `cargo publish` rejects
the manifest and `brew audit` flags the generated formula. Use the
`Apache-2.0` identifier in both places.

The release workflow regenerates `Formula/rtk.rb` on every release, so
its heredoc was overwriting the already-correct value checked in at
`Formula/rtk.rb:10`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 01:51:55 +02:00
rtk-release-bot[bot] 84a652ab05 chore(master): release 0.48.0 2026-09-04 12:42:59 +00:00
rtk-release-bot[bot] bd2c46734c chore(master): release 0.47.0 2026-09-01 18:09:31 +00:00
aesoft cd42c64d1e Merge pull request #3721 from rtk-ai/develop
Next Release
2026-09-01 14:20:56 +02:00
kylehgc 9e7e01d7dd fix(mvn): second review round -- root-lane disarm, per-lane summary tails, opener narrowing, drop insta
Review response for upstream #3199 (KuSh round 2), plus preclear findings.

- Root-lane claims disarm on any fall-through line again (pre-d602a3b
  behavior restored; tagged lanes keep the keyed-only rule). Fixes the
  plain-mvn frame leak on the repo's own fixtures -- filter_compile output
  is byte-identical to base ba7a9ce on mvn_test_fail_slice_raw.txt and
  mvn_test_multifail_slice_raw.txt, pinned by fixture-backed tests. Full
  base A/B: 56/56 outputs identical across all four entry points.
- Failures-summary tails are attributed per lane: dropped moves onto
  SurefireLane, each lane's '+N more failures' tail flushes at that lane's
  own aggregate (or at end-of-stream for truncated input), while the
  reactor-wide entry budget stays shared. A module's tail can no longer be
  collected under another module's header.
- is_lane_opener's [ERROR] arm narrowed to genuine compiler diagnostics
  (FILE_COORD), so [tag] [ERROR] app logs no longer escape a buffered
  block or get re-ordered ahead of it; they route by ownership rules.
- The [ERROR] arm sites only rewrite keep_continuation on the lane's own
  keyed lines, matching every sibling arm/disarm site; interloper sweeps
  now cover both [WARNING] and [ERROR] spellings on all three filters.
- insta removed (first dev-dependency, and .claude/rules/cli-testing.md
  prescribes plain assert_eq! with include_str! fixtures): the four
  snapshots are now expected-output fixtures under tests/fixtures/,
  Cargo.lock drops insta/console/encode_unicode/similar.
- split_lane's no-trailing-space tagged blank pinned by tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-29 15:39:26 -04:00
rtk-release-bot[bot] 36f51239f3 chore(master): release 0.46.0 2026-08-26 18:52:02 +00:00
aesoft 867d31c639 Merge pull request #3544 from rtk-ai/develop
Next Release
2026-08-26 20:50:05 +02:00
kylehgc af3f604f27 Merge remote-tracking branch 'upstream/develop' into feat/mvnd-support-3184-upstream
# Conflicts:
#	Cargo.lock
2026-08-17 10:05:28 -04:00
kylehgc f9b107e0df fix(mvn): make Surefire matching module-prefix aware for mvnd reactors
mvnd builds multi-module reactors in parallel and prefixes per-module log
lines with `[module] `, interleaved line-by-line, while stack traces stay
raw. The Surefire matchers keyed on `[INFO]`/`[ERROR]` at column 0, so in a
parallel reactor a failing class lost its diagnostics: only the reactor
summary and the generic goal error survived.

- `split_lane` classifies on the prefix-stripped view and emits the original
  line, so module identity survives in the output.
- One `SurefireLane` (block machine + keep-continuation + failures-summary
  cap) per module, so a passing close from one module can no longer be
  attributed to another module's open block. Unprefixed raw lines route to
  the lane that most recently opened a block or failure trail.
- `filter_compile` classifies on the stripped view too.

Adds a real captured fixture (`mvnd clean test` on the new
multi-module-fail-skeleton, exit 1, interleaved reactor): the failing class,
its assertion message, the user stack frame, and the summary entry all
survive at 72.1% token savings.

Adds insta snapshot regression tests locking the full filtered output of all
four mvnd fixtures, per docs/contributing/CODING_PRACTICES.md.

Updates the jvm README: the parallel-reactor limit it documented is fixed;
only the `-q` daemon-chatter limit remains.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:03:14 -04:00
guyoron1 f496f59b77 fix(core): decode per line, cover OEM code pages, and centralize on exec_capture
Addresses the inline review on #2717.

decode_process_output
- Decode a line at a time instead of reinterpreting the whole buffer at
  the first bad byte. Valid UTF-8 lines keep their bytes; only lines that
  fail UTF-8 validation go through the code page, so one stray byte no
  longer mangles output that was almost entirely UTF-8. The line is the
  unit because a byte run is not one: GB18030's four-byte sequences embed
  bytes in the ASCII digit range, so any rule that ends a run below 0x80
  splits them. \n cannot appear as a trail byte in any encoding handled
  here, and a process does not switch encoding mid-line.
- A code page result is only accepted when it decodes cleanly, so a UTF-8
  line with a corrupt byte falls back to lossy UTF-8 rather than mojibake.
- Replace the hand-written code page table with the codepage crate, as
  suggested. That also fixes 54936, which was mapped to GBK and now
  correctly resolves to gb18030.
- Add oem_cp for the legacy OEM/DOS pages (437, 850, 852, …) that plain
  cmd.exe still defaults to in many locales. encoding_rs implements only
  WHATWG encodings, so codepage alone returns None for them.
- Fall back to GetACP when GetConsoleOutputCP reports no console, which
  is the piped case rtk normally runs in, and warn once instead of
  falling back to lossy silently.
- Cache the code page lookup in a OnceLock.
- The mapping and the walk take the code page as a parameter, so they are
  compiled and unit-tested on every platform rather than only Windows.

Call sites
- Route the remaining production sites through stream::exec_capture and
  exec_capture_stdin rather than decoding at each one, so future callers
  inherit decoding. git commit keeps inherited stdin via the _stdin
  variant. Test-only sites go back to from_utf8_lossy: they assert on
  rtk's own UTF-8 output, where a console code page has no meaning.
- Decode the streamed path (read_lines_lossy) too — the OEM/ANSI lines
  its comment describes were still going straight to U+FFFD.
- curl keeps its body on from_utf8_lossy: a response body is a network
  payload whose encoding comes from the HTTP charset, not the local
  console, and non-UTF-8 bodies already take the binary passthrough for
  #1087. Only curl's own stderr is code page decoded.

git commit summary parsing
- parse_commit_output sliced from byte 1, which panics when the first
  line starts with a multi-byte character — git prints hook output before
  its summary, and a lossily decoded line starts with a multi-byte
  U+FFFD. Locate the bracket pair with find instead, so both indices are
  character boundaries.

Verified: unit tests for the walk, GBK, gb18030, CP437/850, mixed lines,
truncated input and every byte value; a test pinning that output without
a code page stays byte-identical to from_utf8_lossy; and the Windows-only
lookup cross-compiled for x86_64-pc-windows-msvc.
2026-08-15 08:20:24 +03:00
guy oron 945c3a57b3 fix(core): use windows-sys crate for code page detection, fix CI test
Replace hand-written FFI extern block with windows-sys crate binding
for GetConsoleOutputCP to satisfy semgrep unsafe-block rule. Rewrite
test_decode_process_output_gbk to test encoding logic directly via
codepage_to_encoding(936) instead of relying on the CI runner's
actual console code page (which is not GBK on GitHub Actions).
2026-08-14 21:57:29 +03:00
guy oron 5bd410eb51 fix(core): decode process output using Windows console code page
On Windows with non-UTF-8 console code pages (e.g., GBK for Chinese
locale), child process output is mis-decoded by String::from_utf8_lossy,
producing mojibake. Add decode_process_output() that detects the console
output code page via GetConsoleOutputCP() and decodes with encoding_rs.

Replaces from_utf8_lossy in the core capture paths (exec_capture,
exec_capture_stdin, TOML filter path, proxy streaming path). Module-
specific call sites left for follow-up.

Fixes #2452
2026-08-14 21:57:29 +03:00
rtk-release-bot[bot] b73b621d7c chore(master): release 0.45.0 2026-08-07 09:29:18 +00:00
rtk-release-bot[bot] 981a6561f4 chore(master): release 0.44.2 2026-08-01 15:55:14 +00:00
rtk-release-bot[bot] 062468cd18 chore(master): release 0.44.1 2026-07-28 13:21:12 +00:00
aesoft a7fad1f4f5 Merge pull request #3252 from rtk-ai/develop
Next Release
2026-07-28 15:19:48 +02:00
Takayuki Maeda 5269df7d50 refactor: replace lazy_static with LazyLock 2026-07-28 02:17:04 +09:00
Takayuki Maeda 7fc753d37f chore(deps): update colored to 3.1.1 2026-07-28 01:16:32 +09:00
rtk-release-bot[bot] 50830919f5 chore(master): release 0.44.0 2026-07-26 11:15:29 +00:00
rtk-release-bot[bot] a52a2b2f01 chore(master): release 0.43.0 2026-06-28 08:40:47 +00:00
rtk-release-bot[bot] f1dc9f0558 chore(master): release 0.42.4 2026-06-12 15:19:00 +00:00
rtk-release-bot[bot] 6d89cb8baa chore(master): release 0.42.3 2026-06-05 16:14:46 +00:00
Adrien Eppling a1ef0ef036 chore: merge master into develop (security port + release bump) 2026-06-05 17:13:31 +02:00
rtk-release-bot[bot] 4be04e0bdc chore(master): release 0.42.2 2026-06-05 10:48:27 +00:00
rtk-release-bot[bot] 9664e27038 chore(master): release 0.42.1 2026-06-03 12:37:40 +00:00
patrick szymkowiak 4c278d18c8 Merge pull request #2002 from YOMXXX/feat/msrv-1.91
chore(cargo): declare MSRV via rust-version = "1.91"
2026-06-01 18:44:39 +02:00
aesoft 1875945bf3 fix(pkg): rtk is Apache 2.0 and no MIT 2026-05-25 09:42:06 +02:00
rtk-release-bot[bot] 415fab0611 chore(master): release 0.42.0 2026-05-24 15:34:31 +00:00
rtk-release-bot[bot] 02f76972b4 chore(master): release 0.41.0 2026-05-22 15:57:54 +00:00
李冠辰 6f4519a183 chore(cargo): declare MSRV via rust-version = "1.91"
rtk uses `str::floor_char_boundary()` (src/cmds/system/pipe_cmd.rs:140)
which was stabilized in Rust 1.91.0. Without `rust-version` in
Cargo.toml, packagers on older toolchains hit a confusing
`use of unstable library feature` error from rustc.

With this declaration, cargo gives the expected friendly diagnostic
up-front:

    error: rustc 1.88.0 is not supported by the following packages:
      rtk@0.34.3 requires rustc 1.91

Verified locally by switching toolchains:
- cargo +1.88 check → fails with the new clear MSRV error (intended)
- cargo +1.93 fmt/clippy/test → 1909 passed, zero warnings

Fixes #1402
2026-05-21 08:25:59 +08:00
rtk-release-bot[bot] 120d99fc91 chore(master): release 0.40.0 2026-05-13 19:40:00 +00:00
aesoft 90525ac688 Merge pull request #1747 from rtk-ai/develop
Next Release
2026-05-13 20:54:02 +02:00
Nicolas Le Cam 70b9f385c7 chore(ci): deny warnings and make clippy pass mandatory in ci 2026-05-10 12:44:38 +02:00
rtk-release-bot[bot] dad9f16e44 chore(master): release 0.39.0 2026-05-06 15:40:49 +00:00
rtk-release-bot[bot] 6759e015a2 chore(master): release 0.38.0 2026-04-29 18:32:56 +00:00
github-actions[bot] 0907b998fc chore(master): release 0.37.2 2026-04-20 17:52:14 +00:00
github-actions[bot] 92823bf21d chore(master): release 0.37.1 2026-04-18 13:46:53 +00:00
github-actions[bot] 75bcf9dec6 chore(master): release 0.37.0 2026-04-17 07:45:25 +00:00
aesoft d34389c3d0 fix: P0+P1 fixes from pre-merge review of hook engine
- runner: print captured output on non-zero exit (P0.1)
- main: add hook/pipe to META_COMMANDS (P0.2)
- init: store integrity hash after Gemini script install (P0.3)
- hook_cmd: audit log + permission check for all agent paths (P1.1, P1.2)
- runner: include failure_lines in cargo test summary (P1.5)
- Cargo.toml: remove unconditional libc dep (P1.7)
- init: clean stale settings.json entries during migration (P1.8)
2026-04-16 15:41:20 +02:00
aesoft 906dedd75a Merge remote-tracking branch 'origin/develop' into feat-hook-engine 2026-04-13 21:14:55 +02:00
aesoft 8156081261 fix(telemetry): clean code 2026-04-12 15:28:25 +02:00
aesoft b3936b8e5d fix(stream): stream engine & template + BlockHandler, RegexBlockFilter, signal guard, pipe rewrite 2026-04-09 20:39:30 +02:00
aesoft aa6317fb83 Merge pull request #990 from TropicalDog17/fix/issue-948
fix(ls): filter quality wrong truncation
2026-04-06 16:38:12 +02:00
Adrien Eppling 12e57e870f merge: resolve CHANGELOG.md conflict (develop ← master)
Keep develop's [Unreleased] section on top, followed by master's
released versions (0.34.3, 0.34.2).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 12:36:55 +02:00
Adrien Eppling 33185101fc fix(proxy): kill child process on SIGINT/SIGTERM to prevent orphans
Drop-based ChildGuard doesn't run on signals with panic=abort (release
profile). Register a signal handler that stores the child PID in an
AtomicU32 and kills it on SIGINT/SIGTERM, then re-raises the signal
with default handler for correct exit status propagation.

Fixes orphan processes when rtk proxy is killed by Claude Code, process
managers, or manual kill — the root cause behind issue #897.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-04 19:58:03 +02:00
aesoft 614c64eec2 Update Cargo.toml 2026-04-04 11:08:41 +02:00