Commit Graph

122 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
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
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
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
guyoron1 b35ff3a374 fix(core): route all child-process output decoding through decode_process_output
Review feedback (KuSh): the helper existed but most filter modules still
called String::from_utf8_lossy directly, so non-UTF-8 console output
(e.g. GBK on Chinese-locale Windows) was still mangled for most commands.

Wire decode_process_output through the remaining child-output call sites:
git, go, aws, curl (non-binary paths only — raw binary passthrough for
#1087 is untouched), system read, and discover registry. File-content
decoding (dotnet TRX XML, hook trust snippets) intentionally keeps
from_utf8_lossy since console code pages don't apply there.
2026-08-14 22:00:32 +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
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
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
rtk-release-bot[bot] 120d99fc91 chore(master): release 0.40.0 2026-05-13 19:40:00 +00:00
rtk-release-bot[bot] dad9f16e44 chore(master): release 0.39.0 2026-05-06 15:40:49 +00:00
aesoft 60346e9b87 Merge pull request #1692 from rtk-ai/develop
Next Release
2026-05-06 17:18:35 +02:00
dependabot[bot] 74c1b36f65 build(deps): bump rustls-webpki from 0.103.9 to 0.103.13
Bumps [rustls-webpki](https://github.com/rustls/webpki) from 0.103.9 to 0.103.13.
- [Release notes](https://github.com/rustls/webpki/releases)
- [Commits](https://github.com/rustls/webpki/compare/v/0.103.9...v/0.103.13)

---
updated-dependencies:
- dependency-name: rustls-webpki
  dependency-version: 0.103.13
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-01 13:52:46 +02: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
github-actions[bot] efa8e86c19 chore(master): release 0.36.0 2026-04-13 17:55:56 +00:00
aesoft 314978cd78 Merge pull request #1052 from rtk-ai/develop
Next Release
2026-04-13 19:54:46 +02:00
aesoft 8156081261 fix(telemetry): clean code 2026-04-12 15:28:25 +02:00
github-actions[bot] 76f3b24074 chore(master): release 0.35.0 2026-04-06 10:54:48 +00: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
github-actions[bot] e51be7a022 chore(master): release 0.34.3 2026-04-02 09:05:03 +00:00
aesoft bff0258424 Merge pull request #934 from rtk-ai/develop
fix(refacto): wrappers for standardization, exit codes lexer tokenizer, constants, code clean
2026-04-02 11:04:16 +02:00
aesoft 5af18f87ae Merge branch 'develop' into refacto-folders-and-documentation 2026-03-30 19:29:34 +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 7fd221f446 fix(standardize): git+kube sub wrappers run_filtered 2026-03-30 17:58:01 +02:00
github-actions[bot] 51939a50de chore(master): release 0.34.2 2026-03-30 13:13:33 +00:00
github-actions[bot] ad5a155e45 chore(master): release 0.34.1 2026-03-28 21:11:03 +00:00
aesoft 33195cc686 fix(telemetry): docs + real info from "rtk init -g" 2026-03-28 14:14:13 +01:00
github-actions[bot] 153f9e0459 chore(master): release 0.34.0 2026-03-26 18:10:56 +00:00
github-actions[bot] d6425c311d chore(master): release 0.33.1 2026-03-25 12:08:28 +00:00
Patrick szymkowiak 0649e974fb fix: hook security + stderr redirects + version bump (#807)
* fix(hook): respect Claude Code deny/ask permission rules on rewrite
* fix(permissions): check deny rules before rewrite + flush stdout
* fix(permissions): support *:* and leading/middle wildcards
* fix: strip trailing stderr redirects before rewrite matching (#530)
* chore: bump version to 0.33.0

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-25 11:37:02 +01:00