Commit Graph

66 Commits

Author SHA1 Message Date
dependabot[bot] 806c0df361 build(deps): bump actions/github-script from 7.1.0 to 9.0.0
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.1.0 to 9.0.0.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/f28e40c7f34bde8b3046d885e986cb6290c5673b...3a2844b7e9c422d3c10d287c895573f7108da1b3)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: 9.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-09 00:30:42 +00: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
Nicolas Le Cam e53ec1cf18 Merge pull request #3707 from alvins82/omp-shared
feat(omp)!: add Oh My Pi (OMP) support
2026-09-05 01:54:17 +02:00
Nicolas Le Cam 84f629d719 Merge pull request #3773 from KuSh/fix/golangci-lint-benchmark
fix(ci): unbreak the golangci-lint benchmark row
2026-09-04 18:50:43 +02:00
aesoft faaece0efd Increase operations per run in stale.yml 2026-09-03 17:22:18 +02:00
Nicolas Le Cam 4db7b15946 ci: install golangci-lint v2 instead of the abandoned v1 line
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest` resolves
on the unversioned module path, which stops at v1.64.8 (March 2025, the last v1).
v2 is published under /v2, so `@latest` never moved.

Since runners picked up Go 1.27, that pinned v1.64.8 fails before it lints
anything -- its vendored go/types rejects the newer export data:

  could not load export data: internal error in importing "internal/goarch"
  (export data version 4 is greater than maximum supported version 2)

It writes 628 bytes to stderr, leaves stdout empty and exits 3, which is the
157-token benchmark row that turns the job red.

Reproduced in golang:1.27 and verified there: the /v2 path installs v2.13.2 and
lints the benchmark fixture cleanly. `@latest` is kept deliberately -- the /v2 in
the path is what carries the fix, and a future major would publish under /v3
rather than being picked up silently. This is also the only configuration in
which RTK's v2 output branch is exercised at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 14:58:55 +02:00
patrick 3ffc297c0d ci: use GitHub App token, run weekly instead of daily
Per review: permissions: {} + actions/create-github-app-token, same
pattern as cd.yml/release.yml/pr-target-check.yml, instead of relying
on the default GITHUB_TOKEN. Cron moved from daily to weekly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-29 08:01:38 +02:00
alvins82 157d5c2205 fix: close ownership lifecycle review gaps 2026-08-29 15:28:09 +12:00
patrick 53ebde31b4 ci: add stale bot for issues and PRs (90d stale, +7d close)
Config mirrors facebook/react's actions/stale setup, adapted to rtk's
label taxonomy for exemptions (bug, enhancement, area:security,
P0-critical, P1-high, DONE_REVIEW, good first issue, help wanted).

Context: #348 originally scoped a stale bot out of its triage-automation
plan ("oldest item is 17 days, no staleness problem yet" — true in March
2026 at 51 open PRs). At current volume (1049 open PRs), 253 have had no
activity in 90+ days, 182 of those with zero labels at all — the
assumption in #348 no longer holds.

Thresholds are a starting point (React's numbers), open to tuning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-28 15:47:58 +02:00
Adrien Eppling cdfb14c0f0 fix(cicd): git app token for next release 2026-07-27 18:56:25 +02:00
Adrien Eppling 6e34bbaa98 fix(cicd): next release pr target fork compatibel 2026-07-01 11:14:54 +02:00
aesoft 9cc4937dac fix(security): harden installer checksum, filter-trust, meta-command fallthrough 2026-06-12 14:01:04 +02:00
aesoft e132896d3f fix(cicd): MIT to Apache 2.0 2026-05-25 21:42:07 +02:00
Adrien Eppling 0c6a838594 fix(cicd): set release-please target-branch to master [skip ci] 2026-05-13 21:33:11 +02:00
aesoft 7e418fd664 Update pr-target-check.yml 2026-05-13 19:01:37 +02:00
aesoft 26b96ec6c4 fix(security): pin workflow actions to SHA, clean up tempfile on failure 2026-05-13 17:13:44 +02:00
aesoft cd6ac2f47a fix(security): replace insecure tmp, lock git workflow perm 2026-05-13 15:42:11 +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
aesoft 4ebda52f5a fix(cicd): pr-target clean msg + git app token
inform user how to solve CI pr-target failing check
2026-05-08 11:00:50 +02:00
aesoft bf24972e7d Merge pull request #1462 from rtk-ai/cicd-auto-next-release
feat(cicd): add auto next release parser
2026-05-05 09:28:25 +02:00
aesoft b1233ab3fb fix(cicd): match allowed repo list in pr bodies
for next release body auto write

create a regex with pipes of list of allowed repo to be matched

added allowed_repos in cicd env
2026-05-04 21:11:13 +02:00
aesoft 02cf39ee9e hotfix(cicd): git app token for artefact 2026-04-29 19:22:06 +02:00
aesoft 9d18229b30 hotfix(cicd): authorize dispatch for release please + git app for bump 2026-04-29 19:10:22 +02:00
aesoft d1467e2e9b hotfix(cicd): add git app token for release please 2026-04-29 18:47:29 +02:00
aesoft 88d9f6a0d9 fix(filters): benchmark ci update + fix stream filter quality 2026-04-24 18:54:29 +02:00
aesoft f3e33f3887 feat(cicd): add auto next release parser
Create Next Release PR and set up the description with fix / feat PRs and issues to be closed
2026-04-22 21:12:30 +02:00
aesoft 8857e1725e fix(cicd): semgrep use docker (git action archived) 2026-04-10 13:25:01 +02:00
aesoft 4a228208e3 feat(cicd): enforce cicd sast & package check
- semgrep for sast check by yml rules
- dependabot for package detection
- update CICD doc
- clippy -D unsafe_code hard fail
2026-04-10 13:10:01 +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
Patrick szymkowiak 32c67e0132 fix(cicd): use dev- prefix for pre-release tags to avoid polluting release-please
Pre-release tags on develop used v* prefix (e.g. v0.33.1-rc.60) which
release-please interpreted as the latest version, causing it to generate
wrong release versions. Changed to dev- prefix (e.g. dev-0.34.0-rc.61)
so release-please only sees stable v* tags.

Cleaned up: 42 RC releases and tags deleted.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-25 12:47:18 +01:00
aesoft 3b94b602ed fix(cicd): explicit fetch tag 2026-03-22 00:30:37 +01:00
aesoft 15366678ad fix(cicd): pre-release correct tag
Was using develop ancestor -> wrong behavior because version happen on master branch
2026-03-22 00:29:53 +01:00
aesoft da999c8364 Update ci.yml 2026-03-21 17:16:33 +01:00
aesoft 865749438e fix(cicd): missing doc
Signed-off-by: aesoft <43991222+aeppling@users.noreply.github.com>
2026-03-20 08:29:58 +01:00
aesoft 53bc81e9e6 fix(cicd): gete release like tag for pre-release
added script to act like release please (release please flag was unclear)
added workflow dispatch event + dev like for prelease debug
guards for workflow_dispatch (limit to push master for release events)

Signed-off-by: aesoft <43991222+aeppling@users.noreply.github.com>
2026-03-20 08:26:58 +01:00
patrick szymkowiak 8fae5b067d Release v0.31.0 — develop → master (#666)
* fix: P1 exit codes, grep regex perf, SQLite WAL (#631)

* fix: P1 exit codes, grep regex perf, SQLite concurrency

Exit code propagation (same pattern as existing modules):
- wget_cmd: run() and run_stdout() now exit on failure
- container: docker_logs, kubectl_pods/services/logs now check
  status before parsing JSON (was showing "No pods found" on error)
- pnpm_cmd: replace bail!() with eprint + process::exit in
  run_list and run_install

Performance:
- grep_cmd: compile context regex once before loop instead of
  per-line in clean_line() (was N compilations per grep call)

Data integrity:
- tracking: add PRAGMA journal_mode=WAL and busy_timeout=5000
  to prevent SQLite corruption with concurrent Claude Code instances

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: address review findings on P1 fixes

- tracking: WAL pragma non-fatal (NFS/read-only compat)
- wget: forward raw stderr on failure, track raw==raw (no fake savings)
- container: remove stderr shadow in docker_logs, add empty-stderr
  guard on all 4 new exit code paths for consistency with prisma pattern

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: raise output caps for P0 bugs (#617, #618, #620) (#630)

* fix: raise output caps for grep, git status, and parser fallback (#617, #618, #620)

- grep: per-file match cap 10 → 25, global max 50 → 200
- git status: file list caps 5/5/3 → 15/15/10
- parser fallback: truncate 500 → 2000 chars across all modules

These P0 bugs caused LLM retry loops when RTK returned less signal
than the raw command, making RTK worse than not using it.

Fixes #617, #618, #620

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: update README example and add truncation tests for modified/untracked

- parser/README.md: update example from 500 → 2000 to match code
- git.rs: add test_format_status_modified_truncation (cap 15)
- git.rs: add test_format_status_untracked_truncation (cap 10)

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* refactor: extract output caps into [limits] config section

Move hardcoded caps into config.toml so users can tune them:

  [limits]
  grep_max_results = 200      # global grep match limit
  grep_max_per_file = 25      # per-file match limit
  status_max_files = 15       # staged/modified file list cap
  status_max_untracked = 10   # untracked file list cap
  passthrough_max_chars = 2000 # parser fallback truncation

All 8 modules now read from config::limits() instead of hardcoded
values. Defaults unchanged from previous commit.

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* feat(.claude): add /rtk-triage skill — cross-analysis of PRs and issues (#662)

* feat(.claude): add /rtk-triage skill — orchestrated PR+issue cross-analysis

New skill that runs issue-triage + pr-triage in parallel then produces
a cross-analysis layer that neither skill can do individually:

- Double coverage detection: identifies when 2+ PRs target the same issue
  (via body scan + file overlap), recommends which to keep/close
- Security gap detection: for security review issues, maps each finding
  to a PR (or flags it as uncovered)
- P0/P1 bugs without PR: groups by pattern to suggest sprint batching
- Our dirty PRs: identifies probable cause (conflict with sibling PR,
  needs rebase, missing linked issue)

Output is saved automatically to claudedocs/RTK-YYYY-MM-DD.md.

Usage: /rtk-triage           (French, auto-save)
       /rtk-triage en        (English output)

Signed-off-by: Florian Bruniaux <florian@bel-etage.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>

* docs(architecture): update module count to 66

Sync ARCHITECTURE.md with current main.rs state.
Previous count (60) was stale since several modules were added
(dotnet_cmd, dotnet_format_report, dotnet_trx, npm_cmd, gt_cmd, etc.).

Signed-off-by: Florian Bruniaux <florian@bel-etage.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>

---------

Signed-off-by: Florian Bruniaux <florian@bel-etage.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>

* fix: subcommand routing drops unrecognized subcommands (#600) (#601)

- git stash: pass unknown subcommands (save, branch, clear) through
  instead of silently falling back to git stash push
- git branch: add --show-current, --set-upstream-to, --format, --sort
  to flag detection so they don't get overridden by -a injection
- pip: replace bail!() with passthrough for unknown subcommands
  (freeze, download, wheel, etc.)

Fixes #600

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: resolve cargo fmt + 54 clippy warnings blocking CI (#663)

cargo fmt diffs in config.rs, git.rs, playwright_cmd.rs were failing
the fmt CI check, which cascaded to block clippy/test/security on
PRs #632, #635, #638. Also fixes all clippy warnings: dead code
annotations, iterator simplifications, assert patterns, and
unnecessary allocations.

Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: discover absolute paths + git global options (#485, #163) (#518)

* fix: discover classifies absolute paths like /usr/bin/grep (#485)

Normalize absolute binary paths before classification:
/usr/bin/grep → grep, /bin/ls → ls, /usr/local/bin/git → git

Adds strip_absolute_path() helper + 5 tests.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: discover and rewrite support git global options -C, --no-pager, etc. (#163)

Strip git global options (-C <path>, -c <key=val>, --git-dir, --work-tree,
--no-pager, --no-optional-locks, --bare, --literal-pathspecs) before
classification so git -C /tmp status is recognized as rtk git.

Rewrite preserves global options: git -C /tmp status → rtk git -C /tmp status

Adds GIT_GLOBAL_OPT lazy_static regex + strip_git_global_opts() helper + 6 tests.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: prevent double `--` separator in cargo clippy with -p flags (#519)

When running `rtk cargo clippy -p my-crate -- -D warnings`, Clap with
`trailing_var_arg = true` preserves the `--` in parsed args when flags
precede it. `restore_double_dash()` then added a second `--`, producing
`cargo clippy -p my-crate -- -- -D warnings`. This caused rustc to
interpret `-D` as a filename instead of a lint flag.

Fix: skip restoration when args already contain `--` (Clap preserved it).

Fixes #496

Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* ci: add PR template + target branch check (#521)

- PR template reminds contributors to target develop
- CI workflow labels PRs targeting master with 'wrong-base' and posts a comment
- Excludes develop→master PRs (maintainer releases)

Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: prevent rtk read from corrupting JSON/YAML/data files (#522)

Add Language::Data variant for data formats (JSON, YAML, TOML, XML, CSV, etc.)
with empty comment patterns to prevent comment stripping. AggressiveFilter
falls back to MinimalFilter for data files.

Fixes #464

Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* fix: skip rewriting find/fd in pipes to preserve xargs compatibility (#439) (#563)

rtk find outputs a grouped format incompatible with pipe consumers
like xargs, grep, wc, sort. Skip rewrite when find/fd is followed
by a pipe, preserving native one-per-line output.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: add hint when git diff is truncated + fix --no-compact passthrough (#427) (#564)

When compact_diff truncates output, append a hint line so Claude knows
how to get the full diff: [full diff: rtk git diff --no-compact]

Also fix --no-compact flag being passed to git (causing usage error)
and remove decorative emoji from compact_diff output.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: propagate exit codes in git diff, status+args, commit, and branch (#632)

4 P1 bugs where git exit codes were swallowed:
- git diff: failure silently printed empty stat output
- git status (with args): failure was filtered instead of propagated
- git commit: failure printed "FAILED" but returned Ok(()) breaking pre-commit hooks
- git branch (list mode): failure was silently ignored

All now follow the established pattern: eprint stderr, track raw==raw, process::exit(code).

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* feat: add 5 new TOML filters (ollama, nx, gradle, spring-boot, jira) (#635)

* feat: add 5 new TOML built-in filters (ollama, nx, gradle, spring-boot, jira)

New filters for commands not covered by Rust modules:
- ollama: strip ANSI spinners, keep final text response (#624)
- nx: strip Nx monorepo noise, keep build results (#444)
- gradle/gradlew: strip UP-TO-DATE tasks, keep build summary (#147)
- spring-boot: strip banner and verbose logs, keep startup/errors (#147)
- jira: strip blanks, truncate wide columns (#524)

All 5 filters pass inline tests via rtk verify (123/123).
Updated builtin filter count: 47 -> 52.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* feat: add 5 more TOML filters (turbo, mise, just, task, yadm)

New filters for task runners and git wrapper:
- turbo: strip cache/Tasks/Duration noise, keep task output (#531)
- mise: strip install/download progress, keep task results (#607)
- just: strip blanks and recipe headers, keep output (#607)
- task: strip task headers and up-to-date lines, keep results (#607)
- yadm: strip hint lines, compact git-like output (#567)

All verified with fake binaries through catch-all TOML engine.
137/137 TOML tests pass, 934 Rust tests pass.
Updated builtin filter count: 52 -> 57.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

* fix: replace emojis with plain text in git status output (#603) (#638)

Git status output used emojis (📌, 📝, , , ⚠️) that confuse
non-Claude LLMs (GPT, etc.) causing retry loops. Replace with plain
text labels (branch:, modified:, staged:, untracked:, conflicts:).

Also add "clean — nothing to commit" when working tree is clean,
so LLMs understand the repo state without ambiguity.

Before: 📌 master
After:  branch: master
        clean — nothing to commit

Fixes #603

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>

---------

Signed-off-by: Patrick <patrick@rtk.ai>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Signed-off-by: Florian Bruniaux <florian@bel-etage.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Signed-off-by: Patrick <patrick@rtk-ai.com>
Co-authored-by: Florian BRUNIAUX <florian@bruniaux.com>
Co-authored-by: Ben Younes <benyounes.ousama@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 09:19:11 +01:00
aesoft 191ea9af9f fix(cicd-docs): some logs to understand what is happening when check docs 2026-03-13 15:35:26 +01:00
aesoft c6b7db2e5a fix: failing context for doc analyze -> cat from files 2026-03-13 15:29:02 +01:00
aesoft de710f4ea3 fix(cicd-docs): add agent reviewer + some contribute guidelines 2026-03-13 15:08:24 +01:00
aesoft 5da5db222d fix(cicd): clippy - do not treat warn as error 2026-03-13 13:29:54 +01:00
aesoft 6303e9530a fix(cicd): Clean cicd, rework depends and add pre-release
- Cleaned all files for a more reusable cicd
- Added pre-release on develop
- Added jobs dependencies to gain time (avoid running all if mandatory fail)
- Add CICD.md documentation
2026-03-13 13:24:46 +01:00
patrick szymkowiak 6e61c2447c fix: remove version check from validate-docs CI (#476) (#543)
Release-please bumps Cargo.toml but not docs, causing the version
grep to fail after every release. The check adds no value since docs
don't need to track the exact patch version.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-12 18:54:34 +01:00
aesoft e6ce6e6a14 Merge branch 'master' into doc/add-contributing 2026-03-06 14:31:21 +01:00
patrick szymkowiak 6099bb8d25 ci: add Discord notification on release (#375)
Sends an embed with version, release notes, and link to the GitHub
release page via the RTK_DISCORD_RELEASE webhook secret.
2026-03-06 13:05:46 +01:00
aesoft 33cc14e780 Create dco-check.yaml 2026-03-05 17:41:11 +01:00
patrick szymkowiak baff6a2334 feat: anonymous telemetry ping (1/day, opt-out) (#334)
* feat: add anonymous telemetry ping (1/day, opt-out)

Fire-and-forget daily ping to track active installs for BPI metrics.
- SHA-256 device hash (hostname:user), no PII
- Opt-out: RTK_TELEMETRY_DISABLED=1 or config.toml [telemetry] enabled=false
- Token injected at compile time via option_env!, not in source
- 23h throttle via marker file, 2s timeout, non-blocking thread

* ci: inject RTK_TELEMETRY_TOKEN at build time in release workflow

All 3 build jobs (binary, DEB, RPM) now receive the token from
GitHub secrets so option_env!() compiles it into release binaries.

* refactor: externalize telemetry URL via option_env!(RTK_TELEMETRY_URL)

URL and token are both injected at compile time — no hardcoded
server address in source code. Builds without the env var simply
skip telemetry silently.
2026-03-05 15:34:49 +01:00
Florian BRUNIAUX f447a3d5b1 feat: rtk rewrite — single source of truth for LLM hook rewrites (#241)
* feat: add `rtk rewrite` command — single source of truth for hook rewrites

Implements `rtk rewrite <cmd>` as the canonical rewrite engine for all
LLM hook integrations (Claude Code, Gemini CLI, future tools).

- Add `rewrite_prefixes` field to `RtkRule` in discover/registry.rs
- Add public `rewrite_command()` with compound command support (&&, ||, ;, |)
- Add `rewrite_segment()`, `rewrite_compound()`, `strip_word_prefix()` helpers
- Handle already-rtk commands (exit 0, identical output)
- Handle unsupported/ignored commands (exit 1, no output)
- Add 20 unit tests covering all branches and edge cases
- Create `src/rewrite_cmd.rs` thin CLI wrapper
- Register `Commands::Rewrite` in main.rs
- Simplify `.claude/hooks/rtk-rewrite.sh` from 357 → 60 lines

Hooks no longer need duplicate mapping logic — a single
`REWRITTEN=$(rtk rewrite "$CMD") || exit 0` handles everything.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: fix version references and module count for 0.22.2

- README.md, CLAUDE.md, ARCHITECTURE.md: 0.20.1 → 0.22.2
- ARCHITECTURE.md: module count 48 → 51 (added rewrite_cmd + 2 from master)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: update hook coverage check to verify registry (not hook script)

Since PR #241, the hook delegates to `rtk rewrite` — command mappings
live in src/discover/registry.rs, not the bash hook script.

Update the "Verify hook coverage" CI step to:
- Check that the hook calls `rtk rewrite` (new architecture)
- Check that registry.rs has rewrite_prefixes for all Python/Go commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: support single `&` background operator in compound rewrites

Per feedback from @xDelph: AI agents increasingly use `cmd1 & cmd2`
for parallel execution. This commit adds support alongside existing
`&&`, `||`, `;`, and `|` operators.

Changes:
- rewrite_compound: add match arm for single `&` (after `&&` check)
- rewrite_command: add `" & "` to has_compound detection
- init: show "installed/updated" vs "already up to date" so users
  know whether rtk init changed the hook on re-run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add Python/Go commands to rewrite registry

Add `ruff`, `pytest`, `pip`, `go`, and `golangci-lint` to both
PATTERNS and RULES in registry.rs so the CI coverage check passes
and `rtk rewrite` correctly identifies these commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update version reference to 0.23.0 in README

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update version reference to 0.23.0 in CLAUDE.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update version and module count to 0.23.0/52 in ARCHITECTURE.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address P0 review feedback on rtk-rewrite PR

P0.1 - Replace 218-line bash hook with 58-line thin delegating hook.
  All rewrite logic now lives exclusively in `rtk rewrite` (Rust registry).
  `rtk init` installs the thin hook via include_str!.

P0.2 - Fix `head -20 file` crash at runtime.
  Generic prefix replacement produced `rtk read -20 file` (invalid clap args).
  Now translates `head -N file` → `rtk read file --max-lines N` and skips
  unsupported head flags (e.g. -c) by returning exit 1.

P0.3 - Add version guard in hook for rtk < 0.23.0.
  Prints a warning to stderr instead of silently doing nothing.

Also adds missing registry entries vs old hook:
  - gh release, cargo install
  - docker run/exec/build, kubectl describe/apply
  - tree, diff

474 tests pass, 0 clippy warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: cargo fmt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(discover): extract rules/patterns into rules.rs

Per aeppling review: registry.rs was too large (~1500 lines).
Extract all static data into src/discover/rules.rs:
- RtkRule struct (with pub fields)
- PATTERNS const array
- RULES const array
- IGNORED_PREFIXES and IGNORED_EXACT const arrays

registry.rs now contains only logic + tests.
rules.rs is the single place to add a new command mapping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update version reference to 0.24.0 in README

* docs: update version references to 0.24.0 in CLAUDE.md and ARCHITECTURE.md

* fix(discover): add aws and psql to rewrite registry

rtk aws and rtk psql modules exist since PR #216 but were missing
from the registry rules — rewrite was silently skipping them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(discover): exhaustive regression tests for rewrite registry

Cover all command categories added in PR #241 and missing from
the previous test suite:
- aws / psql (PR #216 modules, gap detected during non-reg run)
- Python: ruff, pytest, python -m pytest, pip, uv pip
- Go: go test/build/vet, golangci-lint
- JS/TS: vitest, pnpm vitest, prisma, prettier, pnpm list
- Compound operators: || and ; rewrites, 4-segment chains,
  mixed supported/unsupported segments, all-unsupported → None
- sudo prefix rewrite, env var prefix rewrite
- find with native flags
- Registry invariants: PATTERNS/RULES aligned, all rules valid,
  all patterns are valid regex

Before: 559 tests. After: 607 tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(migration): document breaking change + detect outdated hook in rtk config

CHANGELOG [Unreleased]:
- Migration required: rtk init --global needed after upgrade
- Documents upgrade path and explains no immediate breakage

rtk init --show / rtk config now detects old hook (inline if-else)
vs new thin delegator (rtk rewrite) and prints actionable warning:

  ⚠️  Hook: ~/.claude/hooks/rtk-rewrite.sh (outdated — inline logic, not thin delegator)
     → Run `rtk init --global` to upgrade to the single source of truth hook

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update hook references for thin delegator (0.24.0)

- ARCHITECTURE.md: fix hook description (shell script → thin delegator)
- INSTALL.md: add upgrade path for old hook users (pre-0.24 breaking change)
- SECURITY.md: add registry.rs + hook files to Tier 1 critical files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(arch): fix module count 52→55, add aws/psql/rewrite to module map

Adds aws_cmd, psql_cmd (PR #216) and rewrite_cmd (this PR) to the
Complete Module Map table. Updates total from 52 to 55 to match main.rs.

Fixes CI validate-docs.sh module count mismatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: fix hook coverage check to search rules.rs instead of registry.rs

After the PR #241 refactor, rewrite_prefixes constants moved from
registry.rs to rules.rs. Update grep to search the whole discover/
directory so it finds them in the right file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 14:20:01 +01:00
Vincent Vanackere 3b84b33e3c ci: replace x86_64-unknown-linux-gnu with musl target for static binaries (#267)
The current x86_64-unknown-linux-gnu release binary dynamically links against glibc, which causes failures on systems with an older glibc version:

rtk: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.39' not found (required by rtk)

Replace the x86_64-unknown-linux-gnu build target with x86_64-unknown-linux-musl, producing a fully statically-linked binary with no libc dependency.

Fixes rtk-ai/rtk#265 - binary fails on systems with old glibc.
2026-02-28 18:38:52 +01:00
Florian BRUNIAUX 5a68839486 docs: comprehensive v0.15.1 documentation update for Python/Go support
Complete documentation overhaul for RTK v0.15.1 Python and Go support
across all user-facing and technical documentation.

## Changes

### Critical (P0)
- **CLAUDE.md**: Added maintenance warning, CHANGELOG reference, hook
  coverage section, corrected module count (46 modules)
- **Hooks**: Added Python/Go rewrites (ruff, pytest, pip, go, golangci-lint)
- **CI Validation**: New workflow validates doc consistency on every PR

### User Documentation (P1)
- **README.md**: Added Python/Go Stack section, updated command tables,
  added benchmarks, explicit v0.15.1 mention

### Technical Documentation (P2)
- **ARCHITECTURE.md**: Updated metadata (v0.15.1, 2026-02-12), added
  Python/Go modules to organization table, 3 new filtering strategies
  (JSON/TEXT Dual, State Machine, NDJSON), complete Python & Go
  Module Architecture section

## Validation
-  All docs mention version 0.15.1
-  Module count consistent (46 across all docs)
-  All Python/Go commands documented
-  Hook rewrites present and tested
-  scripts/validate-docs.sh passes

## Impact
- Prevents documentation drift (CI validation)
- Claude Code immediately uses Python/Go via hooks
- Clear architecture guidance for contributors
- 375 lines added across 6 files

Closes #[issue-number-if-any]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 11:21:52 +01:00
Florian BRUNIAUX 50bb4943f7 fix: improve CI reliability and hook coverage (#95)
* feat(cargo): aggregate test output into single line (#83)

Problem: `cargo test` shows 24+ summary lines even when all pass.
An LLM only needs to know IF something failed, not 24x "ok".

Before (24 lines):
```
✓ test result: ok. 2 passed; 0 failed; ...
✓ test result: ok. 0 passed; 0 failed; ...
... (x24)
```

After (1 line):
```
✓ cargo test: 137 passed (24 suites, 1.45s)
```

Changes:
- Add AggregatedTestResult struct with regex parsing
- Merge multiple test summaries when all pass
- Format: "N passed, M ignored, P filtered out (X suites, Ys)"
- Fallback to original behavior if parsing fails
- Failures still show full details (no aggregation)

Tests: 6 new + 1 modified, covering all cases:
- Multi-suite aggregation
- Single suite (singular "suite")
- Zero tests
- With ignored/filtered out
- Failures → no aggregation (detail preserved)
- Regex fallback

Closes #83

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(ci): prevent Python/Go benchmark sections from being silently skipped

**Problem:**
Python and Go benchmark sections were silently skipped in CI because
the RTK repository doesn't contain pyproject.toml or go.mod files.
The sections only ran when these project files existed.

**Solution:**
1. Create temporary fixtures with minimal project structure:
   - Python: pyproject.toml + sample.py + test_sample.py
   - Go: go.mod + main.go + main_test.go
2. Resolve RTK to absolute path to work after cd into temp dirs
3. Install required tools in CI workflow:
   - Python: ruff, pytest
   - Go: stable version + golangci-lint

**Impact:**
- Python/Go sections now appear in CI benchmark output
- Self-contained fixtures ensure consistent benchmarking
- No dependency on RTK project structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(hooks): add missing RTK command rewrites

Add 8 missing command rewrites to rtk-rewrite.sh and rtk-suggest.sh:
- cargo check/install/fmt
- tree, find, diff
- head → rtk read (with --max-lines transformation)
- wget

Fixes BSD sed compatibility for head transformation by using literal
spaces instead of \s+ (which doesn't work on macOS).

Impact: ~18.2K tokens saved on previously missed commands discovered
by `rtk discover`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-13 08:46:01 +01:00