@hasna/terminal 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +29 -12
- package/package.json +1 -1
- package/src/ai.ts +50 -36
- package/src/cli.tsx +29 -12
- package/src/context-hints.ts +89 -0
- package/src/discover.ts +238 -0
- package/src/economy.ts +53 -0
- package/src/output-store.ts +65 -0
- package/src/providers/index.ts +4 -4
- package/src/sessions-db.ts +81 -0
- package/temp/rtk/.claude/agents/code-reviewer.md +221 -0
- package/temp/rtk/.claude/agents/debugger.md +519 -0
- package/temp/rtk/.claude/agents/rtk-testing-specialist.md +461 -0
- package/temp/rtk/.claude/agents/rust-rtk.md +511 -0
- package/temp/rtk/.claude/agents/technical-writer.md +355 -0
- package/temp/rtk/.claude/commands/diagnose.md +352 -0
- package/temp/rtk/.claude/commands/test-routing.md +362 -0
- package/temp/rtk/.claude/hooks/bash/pre-commit-format.sh +16 -0
- package/temp/rtk/.claude/hooks/rtk-rewrite.sh +70 -0
- package/temp/rtk/.claude/hooks/rtk-suggest.sh +152 -0
- package/temp/rtk/.claude/rules/cli-testing.md +526 -0
- package/temp/rtk/.claude/skills/issue-triage/SKILL.md +348 -0
- package/temp/rtk/.claude/skills/issue-triage/templates/issue-comment.md +134 -0
- package/temp/rtk/.claude/skills/performance.md +435 -0
- package/temp/rtk/.claude/skills/pr-triage/SKILL.md +315 -0
- package/temp/rtk/.claude/skills/pr-triage/templates/review-comment.md +71 -0
- package/temp/rtk/.claude/skills/repo-recap.md +206 -0
- package/temp/rtk/.claude/skills/rtk-tdd/SKILL.md +78 -0
- package/temp/rtk/.claude/skills/rtk-tdd/references/testing-patterns.md +124 -0
- package/temp/rtk/.claude/skills/security-guardian.md +503 -0
- package/temp/rtk/.claude/skills/ship.md +404 -0
- package/temp/rtk/.github/workflows/benchmark.yml +34 -0
- package/temp/rtk/.github/workflows/dco-check.yaml +12 -0
- package/temp/rtk/.github/workflows/release-please.yml +51 -0
- package/temp/rtk/.github/workflows/release.yml +343 -0
- package/temp/rtk/.github/workflows/security-check.yml +135 -0
- package/temp/rtk/.github/workflows/validate-docs.yml +78 -0
- package/temp/rtk/.release-please-manifest.json +3 -0
- package/temp/rtk/ARCHITECTURE.md +1491 -0
- package/temp/rtk/CHANGELOG.md +640 -0
- package/temp/rtk/CLAUDE.md +605 -0
- package/temp/rtk/CONTRIBUTING.md +199 -0
- package/temp/rtk/Cargo.lock +1668 -0
- package/temp/rtk/Cargo.toml +64 -0
- package/temp/rtk/Formula/rtk.rb +43 -0
- package/temp/rtk/INSTALL.md +390 -0
- package/temp/rtk/LICENSE +21 -0
- package/temp/rtk/README.md +386 -0
- package/temp/rtk/README_es.md +159 -0
- package/temp/rtk/README_fr.md +197 -0
- package/temp/rtk/README_ja.md +159 -0
- package/temp/rtk/README_ko.md +159 -0
- package/temp/rtk/README_zh.md +167 -0
- package/temp/rtk/ROADMAP.md +15 -0
- package/temp/rtk/SECURITY.md +217 -0
- package/temp/rtk/TEST_EXEC_TIME.md +102 -0
- package/temp/rtk/build.rs +57 -0
- package/temp/rtk/docs/AUDIT_GUIDE.md +432 -0
- package/temp/rtk/docs/FEATURES.md +1410 -0
- package/temp/rtk/docs/TROUBLESHOOTING.md +309 -0
- package/temp/rtk/docs/filter-workflow.md +102 -0
- package/temp/rtk/docs/images/gain-dashboard.jpg +0 -0
- package/temp/rtk/docs/tracking.md +583 -0
- package/temp/rtk/hooks/opencode-rtk.ts +39 -0
- package/temp/rtk/hooks/rtk-awareness.md +29 -0
- package/temp/rtk/hooks/rtk-rewrite.sh +61 -0
- package/temp/rtk/hooks/test-rtk-rewrite.sh +442 -0
- package/temp/rtk/install.sh +124 -0
- package/temp/rtk/release-please-config.json +10 -0
- package/temp/rtk/scripts/benchmark.sh +592 -0
- package/temp/rtk/scripts/check-installation.sh +162 -0
- package/temp/rtk/scripts/install-local.sh +37 -0
- package/temp/rtk/scripts/rtk-economics.sh +137 -0
- package/temp/rtk/scripts/test-all.sh +561 -0
- package/temp/rtk/scripts/test-aristote.sh +227 -0
- package/temp/rtk/scripts/test-tracking.sh +79 -0
- package/temp/rtk/scripts/update-readme-metrics.sh +32 -0
- package/temp/rtk/scripts/validate-docs.sh +73 -0
- package/temp/rtk/src/aws_cmd.rs +880 -0
- package/temp/rtk/src/binlog.rs +1645 -0
- package/temp/rtk/src/cargo_cmd.rs +1727 -0
- package/temp/rtk/src/cc_economics.rs +1157 -0
- package/temp/rtk/src/ccusage.rs +340 -0
- package/temp/rtk/src/config.rs +187 -0
- package/temp/rtk/src/container.rs +855 -0
- package/temp/rtk/src/curl_cmd.rs +134 -0
- package/temp/rtk/src/deps.rs +268 -0
- package/temp/rtk/src/diff_cmd.rs +367 -0
- package/temp/rtk/src/discover/mod.rs +274 -0
- package/temp/rtk/src/discover/provider.rs +388 -0
- package/temp/rtk/src/discover/registry.rs +2022 -0
- package/temp/rtk/src/discover/report.rs +202 -0
- package/temp/rtk/src/discover/rules.rs +667 -0
- package/temp/rtk/src/display_helpers.rs +402 -0
- package/temp/rtk/src/dotnet_cmd.rs +1771 -0
- package/temp/rtk/src/dotnet_format_report.rs +133 -0
- package/temp/rtk/src/dotnet_trx.rs +593 -0
- package/temp/rtk/src/env_cmd.rs +204 -0
- package/temp/rtk/src/filter.rs +462 -0
- package/temp/rtk/src/filters/README.md +52 -0
- package/temp/rtk/src/filters/ansible-playbook.toml +34 -0
- package/temp/rtk/src/filters/basedpyright.toml +47 -0
- package/temp/rtk/src/filters/biome.toml +45 -0
- package/temp/rtk/src/filters/brew-install.toml +37 -0
- package/temp/rtk/src/filters/composer-install.toml +40 -0
- package/temp/rtk/src/filters/df.toml +16 -0
- package/temp/rtk/src/filters/dotnet-build.toml +64 -0
- package/temp/rtk/src/filters/du.toml +16 -0
- package/temp/rtk/src/filters/fail2ban-client.toml +15 -0
- package/temp/rtk/src/filters/gcc.toml +49 -0
- package/temp/rtk/src/filters/gcloud.toml +22 -0
- package/temp/rtk/src/filters/hadolint.toml +24 -0
- package/temp/rtk/src/filters/helm.toml +29 -0
- package/temp/rtk/src/filters/iptables.toml +27 -0
- package/temp/rtk/src/filters/jj.toml +28 -0
- package/temp/rtk/src/filters/jq.toml +24 -0
- package/temp/rtk/src/filters/make.toml +41 -0
- package/temp/rtk/src/filters/markdownlint.toml +24 -0
- package/temp/rtk/src/filters/mix-compile.toml +27 -0
- package/temp/rtk/src/filters/mix-format.toml +15 -0
- package/temp/rtk/src/filters/mvn-build.toml +44 -0
- package/temp/rtk/src/filters/oxlint.toml +43 -0
- package/temp/rtk/src/filters/ping.toml +63 -0
- package/temp/rtk/src/filters/pio-run.toml +40 -0
- package/temp/rtk/src/filters/poetry-install.toml +50 -0
- package/temp/rtk/src/filters/pre-commit.toml +35 -0
- package/temp/rtk/src/filters/ps.toml +16 -0
- package/temp/rtk/src/filters/quarto-render.toml +41 -0
- package/temp/rtk/src/filters/rsync.toml +48 -0
- package/temp/rtk/src/filters/shellcheck.toml +27 -0
- package/temp/rtk/src/filters/shopify-theme.toml +29 -0
- package/temp/rtk/src/filters/skopeo.toml +45 -0
- package/temp/rtk/src/filters/sops.toml +16 -0
- package/temp/rtk/src/filters/ssh.toml +44 -0
- package/temp/rtk/src/filters/stat.toml +34 -0
- package/temp/rtk/src/filters/swift-build.toml +41 -0
- package/temp/rtk/src/filters/systemctl-status.toml +33 -0
- package/temp/rtk/src/filters/terraform-plan.toml +35 -0
- package/temp/rtk/src/filters/tofu-fmt.toml +16 -0
- package/temp/rtk/src/filters/tofu-init.toml +38 -0
- package/temp/rtk/src/filters/tofu-plan.toml +35 -0
- package/temp/rtk/src/filters/tofu-validate.toml +17 -0
- package/temp/rtk/src/filters/trunk-build.toml +39 -0
- package/temp/rtk/src/filters/ty.toml +50 -0
- package/temp/rtk/src/filters/uv-sync.toml +37 -0
- package/temp/rtk/src/filters/xcodebuild.toml +99 -0
- package/temp/rtk/src/filters/yamllint.toml +25 -0
- package/temp/rtk/src/find_cmd.rs +598 -0
- package/temp/rtk/src/format_cmd.rs +386 -0
- package/temp/rtk/src/gain.rs +723 -0
- package/temp/rtk/src/gh_cmd.rs +1651 -0
- package/temp/rtk/src/git.rs +2012 -0
- package/temp/rtk/src/go_cmd.rs +592 -0
- package/temp/rtk/src/golangci_cmd.rs +254 -0
- package/temp/rtk/src/grep_cmd.rs +288 -0
- package/temp/rtk/src/gt_cmd.rs +810 -0
- package/temp/rtk/src/hook_audit_cmd.rs +283 -0
- package/temp/rtk/src/hook_check.rs +171 -0
- package/temp/rtk/src/init.rs +1859 -0
- package/temp/rtk/src/integrity.rs +537 -0
- package/temp/rtk/src/json_cmd.rs +231 -0
- package/temp/rtk/src/learn/detector.rs +628 -0
- package/temp/rtk/src/learn/mod.rs +119 -0
- package/temp/rtk/src/learn/report.rs +184 -0
- package/temp/rtk/src/lint_cmd.rs +694 -0
- package/temp/rtk/src/local_llm.rs +316 -0
- package/temp/rtk/src/log_cmd.rs +248 -0
- package/temp/rtk/src/ls.rs +324 -0
- package/temp/rtk/src/main.rs +2482 -0
- package/temp/rtk/src/mypy_cmd.rs +389 -0
- package/temp/rtk/src/next_cmd.rs +241 -0
- package/temp/rtk/src/npm_cmd.rs +236 -0
- package/temp/rtk/src/parser/README.md +267 -0
- package/temp/rtk/src/parser/error.rs +46 -0
- package/temp/rtk/src/parser/formatter.rs +336 -0
- package/temp/rtk/src/parser/mod.rs +311 -0
- package/temp/rtk/src/parser/types.rs +119 -0
- package/temp/rtk/src/pip_cmd.rs +302 -0
- package/temp/rtk/src/playwright_cmd.rs +479 -0
- package/temp/rtk/src/pnpm_cmd.rs +573 -0
- package/temp/rtk/src/prettier_cmd.rs +221 -0
- package/temp/rtk/src/prisma_cmd.rs +482 -0
- package/temp/rtk/src/psql_cmd.rs +382 -0
- package/temp/rtk/src/pytest_cmd.rs +384 -0
- package/temp/rtk/src/read.rs +217 -0
- package/temp/rtk/src/rewrite_cmd.rs +50 -0
- package/temp/rtk/src/ruff_cmd.rs +402 -0
- package/temp/rtk/src/runner.rs +271 -0
- package/temp/rtk/src/summary.rs +297 -0
- package/temp/rtk/src/tee.rs +405 -0
- package/temp/rtk/src/telemetry.rs +248 -0
- package/temp/rtk/src/toml_filter.rs +1655 -0
- package/temp/rtk/src/tracking.rs +1416 -0
- package/temp/rtk/src/tree.rs +209 -0
- package/temp/rtk/src/tsc_cmd.rs +259 -0
- package/temp/rtk/src/utils.rs +432 -0
- package/temp/rtk/src/verify_cmd.rs +47 -0
- package/temp/rtk/src/vitest_cmd.rs +385 -0
- package/temp/rtk/src/wc_cmd.rs +401 -0
- package/temp/rtk/src/wget_cmd.rs +260 -0
- package/temp/rtk/tests/fixtures/dotnet/build_failed.txt +11 -0
- package/temp/rtk/tests/fixtures/dotnet/format_changes.json +31 -0
- package/temp/rtk/tests/fixtures/dotnet/format_empty.json +1 -0
- package/temp/rtk/tests/fixtures/dotnet/format_success.json +12 -0
- package/temp/rtk/tests/fixtures/dotnet/test_failed.txt +18 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "rtk"
|
|
3
|
+
version = "0.29.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
authors = ["Patrick Szymkowiak"]
|
|
6
|
+
description = "Rust Token Killer - High-performance CLI proxy to minimize LLM token consumption"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
homepage = "https://www.rtk-ai.app"
|
|
9
|
+
repository = "https://github.com/rtk-ai/rtk"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
keywords = ["cli", "llm", "token", "filter", "productivity"]
|
|
12
|
+
categories = ["command-line-utilities", "development-tools"]
|
|
13
|
+
|
|
14
|
+
[dependencies]
|
|
15
|
+
clap = { version = "4", features = ["derive"] }
|
|
16
|
+
anyhow = "1.0"
|
|
17
|
+
ignore = "0.4"
|
|
18
|
+
walkdir = "2"
|
|
19
|
+
regex = "1"
|
|
20
|
+
lazy_static = "1.4"
|
|
21
|
+
serde = { version = "1", features = ["derive"] }
|
|
22
|
+
serde_json = { version = "1", features = ["preserve_order"] }
|
|
23
|
+
colored = "2"
|
|
24
|
+
dirs = "5"
|
|
25
|
+
rusqlite = { version = "0.31", features = ["bundled"] }
|
|
26
|
+
toml = "0.8"
|
|
27
|
+
chrono = "0.4"
|
|
28
|
+
thiserror = "1.0"
|
|
29
|
+
tempfile = "3"
|
|
30
|
+
sha2 = "0.10"
|
|
31
|
+
ureq = "2"
|
|
32
|
+
hostname = "0.4"
|
|
33
|
+
flate2 = "1.0"
|
|
34
|
+
quick-xml = "0.37"
|
|
35
|
+
|
|
36
|
+
[build-dependencies]
|
|
37
|
+
toml = "0.8"
|
|
38
|
+
|
|
39
|
+
[dev-dependencies]
|
|
40
|
+
|
|
41
|
+
[profile.release]
|
|
42
|
+
opt-level = 3
|
|
43
|
+
lto = true
|
|
44
|
+
codegen-units = 1
|
|
45
|
+
panic = "abort"
|
|
46
|
+
strip = true
|
|
47
|
+
|
|
48
|
+
# cargo-deb configuration
|
|
49
|
+
[package.metadata.deb]
|
|
50
|
+
maintainer = "Patrick Szymkowiak"
|
|
51
|
+
copyright = "2024 Patrick Szymkowiak"
|
|
52
|
+
license-file = ["LICENSE", "0"]
|
|
53
|
+
extended-description = "rtk filters and compresses command outputs before they reach your LLM context, saving 60-90% of tokens."
|
|
54
|
+
section = "utility"
|
|
55
|
+
priority = "optional"
|
|
56
|
+
assets = [
|
|
57
|
+
["target/release/rtk", "usr/bin/", "755"],
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
# cargo-generate-rpm configuration
|
|
61
|
+
[package.metadata.generate-rpm]
|
|
62
|
+
assets = [
|
|
63
|
+
{ source = "target/release/rtk", dest = "/usr/bin/rtk", mode = "755" },
|
|
64
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# typed: false
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Homebrew formula for rtk - Rust Token Killer
|
|
5
|
+
# To install: brew tap rtk-ai/tap && brew install rtk
|
|
6
|
+
class Rtk < Formula
|
|
7
|
+
desc "High-performance CLI proxy to minimize LLM token consumption"
|
|
8
|
+
homepage "https://www.rtk-ai.app"
|
|
9
|
+
version "0.1.0"
|
|
10
|
+
license "MIT"
|
|
11
|
+
|
|
12
|
+
on_macos do
|
|
13
|
+
on_intel do
|
|
14
|
+
url "https://github.com/rtk-ai/rtk/releases/download/v#{version}/rtk-x86_64-apple-darwin.tar.gz"
|
|
15
|
+
sha256 "PLACEHOLDER_SHA256_INTEL"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
on_arm do
|
|
19
|
+
url "https://github.com/rtk-ai/rtk/releases/download/v#{version}/rtk-aarch64-apple-darwin.tar.gz"
|
|
20
|
+
sha256 "PLACEHOLDER_SHA256_ARM"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
on_linux do
|
|
25
|
+
on_intel do
|
|
26
|
+
url "https://github.com/rtk-ai/rtk/releases/download/v#{version}/rtk-x86_64-unknown-linux-gnu.tar.gz"
|
|
27
|
+
sha256 "PLACEHOLDER_SHA256_LINUX_INTEL"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
on_arm do
|
|
31
|
+
url "https://github.com/rtk-ai/rtk/releases/download/v#{version}/rtk-aarch64-unknown-linux-gnu.tar.gz"
|
|
32
|
+
sha256 "PLACEHOLDER_SHA256_LINUX_ARM"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def install
|
|
37
|
+
bin.install "rtk"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
test do
|
|
41
|
+
assert_match "rtk #{version}", shell_output("#{bin}/rtk --version")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# RTK Installation Guide - For AI Coding Assistants
|
|
2
|
+
|
|
3
|
+
## ⚠️ Name Collision Warning
|
|
4
|
+
|
|
5
|
+
**There are TWO completely different projects named "rtk":**
|
|
6
|
+
|
|
7
|
+
1. ✅ **Rust Token Killer** (this project) - LLM token optimizer
|
|
8
|
+
- Repos: `rtk-ai/rtk`
|
|
9
|
+
- Has `rtk gain` command for token savings stats
|
|
10
|
+
|
|
11
|
+
2. ❌ **Rust Type Kit** (reachingforthejack/rtk) - DIFFERENT PROJECT
|
|
12
|
+
- Rust codebase query tool and type generator
|
|
13
|
+
- **DO NOT install if you want token optimization**
|
|
14
|
+
|
|
15
|
+
## Pre-Installation Check (REQUIRED)
|
|
16
|
+
|
|
17
|
+
**AI assistants should ALWAYS verify if RTK is already installed before attempting installation.**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Check if RTK is installed
|
|
21
|
+
rtk --version
|
|
22
|
+
|
|
23
|
+
# CRITICAL: Verify it's the Token Killer (not Type Kit)
|
|
24
|
+
rtk gain # Should show token savings stats, NOT "command not found"
|
|
25
|
+
|
|
26
|
+
# Check installation path
|
|
27
|
+
which rtk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If `rtk gain` works, you have the **correct** RTK installed. **DO NOT reinstall**. Skip to "Project Initialization".
|
|
31
|
+
|
|
32
|
+
If `rtk gain` fails but `rtk --version` succeeds, you have the **wrong** RTK (Type Kit). Uninstall and reinstall the correct one (see below).
|
|
33
|
+
|
|
34
|
+
## Installation (only if RTK not available or wrong RTK installed)
|
|
35
|
+
|
|
36
|
+
### Step 0: Uninstall Wrong RTK (if needed)
|
|
37
|
+
|
|
38
|
+
If you accidentally installed Rust Type Kit:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cargo uninstall rtk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Quick Install (Linux/macOS)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
After installation, **verify you have the correct rtk**:
|
|
51
|
+
```bash
|
|
52
|
+
rtk gain # Must show token savings stats (not "command not found")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Alternative: Manual Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# From rtk-ai repository (NOT reachingforthejack!)
|
|
59
|
+
cargo install --git https://github.com/rtk-ai/rtk
|
|
60
|
+
|
|
61
|
+
# OR (if published and correct on crates.io)
|
|
62
|
+
cargo install rtk
|
|
63
|
+
|
|
64
|
+
# ALWAYS VERIFY after installation
|
|
65
|
+
rtk gain # MUST show token savings, not "command not found"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
⚠️ **WARNING**: `cargo install rtk` from crates.io might install the wrong package. Always verify with `rtk gain`.
|
|
69
|
+
|
|
70
|
+
## Project Initialization
|
|
71
|
+
|
|
72
|
+
### Which mode to choose?
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Do you want RTK active across ALL Claude Code projects?
|
|
76
|
+
│
|
|
77
|
+
├─ YES → rtk init -g (recommended)
|
|
78
|
+
│ Hook + RTK.md (~10 tokens in context)
|
|
79
|
+
│ Commands auto-rewritten transparently
|
|
80
|
+
│
|
|
81
|
+
├─ YES, minimal → rtk init -g --hook-only
|
|
82
|
+
│ Hook only, nothing added to CLAUDE.md
|
|
83
|
+
│ Zero tokens in context
|
|
84
|
+
│
|
|
85
|
+
└─ NO, single project → rtk init
|
|
86
|
+
Local CLAUDE.md only (137 lines)
|
|
87
|
+
No hook, no global effect
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Recommended: Global Hook-First Setup
|
|
91
|
+
|
|
92
|
+
**Best for: All projects, automatic RTK usage**
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
rtk init -g
|
|
96
|
+
# → Installs hook to ~/.claude/hooks/rtk-rewrite.sh
|
|
97
|
+
# → Creates ~/.claude/RTK.md (10 lines, meta commands only)
|
|
98
|
+
# → Adds @RTK.md reference to ~/.claude/CLAUDE.md
|
|
99
|
+
# → Prompts: "Patch settings.json? [y/N]"
|
|
100
|
+
# → If yes: patches + creates backup (~/.claude/settings.json.bak)
|
|
101
|
+
|
|
102
|
+
# Automated alternatives:
|
|
103
|
+
rtk init -g --auto-patch # Patch without prompting
|
|
104
|
+
rtk init -g --no-patch # Print manual instructions instead
|
|
105
|
+
|
|
106
|
+
# Verify installation
|
|
107
|
+
rtk init --show # Check hook is installed and executable
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Token savings**: ~99.5% reduction (2000 tokens → 10 tokens in context)
|
|
111
|
+
|
|
112
|
+
**What is settings.json?**
|
|
113
|
+
Claude Code's hook registry. RTK adds a PreToolUse hook that rewrites commands transparently. Without this, Claude won't invoke the hook automatically.
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
Claude Code settings.json rtk-rewrite.sh RTK binary
|
|
117
|
+
│ │ │ │
|
|
118
|
+
│ "git status" │ │ │
|
|
119
|
+
│ ──────────────────►│ │ │
|
|
120
|
+
│ │ PreToolUse trigger │ │
|
|
121
|
+
│ │ ───────────────────►│ │
|
|
122
|
+
│ │ │ rewrite command │
|
|
123
|
+
│ │ │ → rtk git status │
|
|
124
|
+
│ │◄────────────────────│ │
|
|
125
|
+
│ │ updated command │ │
|
|
126
|
+
│ │ │
|
|
127
|
+
│ execute: rtk git status │
|
|
128
|
+
│ ─────────────────────────────────────────────────────────────►│
|
|
129
|
+
│ │ filter
|
|
130
|
+
│ "3 modified, 1 untracked ✓" │
|
|
131
|
+
│◄──────────────────────────────────────────────────────────────│
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Backup Safety**:
|
|
135
|
+
RTK backs up existing settings.json before changes. Restore if needed:
|
|
136
|
+
```bash
|
|
137
|
+
cp ~/.claude/settings.json.bak ~/.claude/settings.json
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Alternative: Local Project Setup
|
|
141
|
+
|
|
142
|
+
**Best for: Single project without hook**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cd /path/to/your/project
|
|
146
|
+
rtk init # Creates ./CLAUDE.md with full RTK instructions (137 lines)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Token savings**: Instructions loaded only for this project
|
|
150
|
+
|
|
151
|
+
### Upgrading from Previous Version
|
|
152
|
+
|
|
153
|
+
#### From old 137-line CLAUDE.md injection (pre-0.22)
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
rtk init -g # Automatically migrates to hook-first mode
|
|
157
|
+
# → Removes old 137-line block
|
|
158
|
+
# → Installs hook + RTK.md
|
|
159
|
+
# → Adds @RTK.md reference
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### From old hook with inline logic (pre-0.24) — ⚠️ Breaking Change
|
|
163
|
+
|
|
164
|
+
RTK 0.24.0 replaced the inline command-detection hook (~200 lines) with a **thin delegator** that calls `rtk rewrite`. The binary now contains the rewrite logic, so adding new commands no longer requires a hook update.
|
|
165
|
+
|
|
166
|
+
The old hook still works but won't benefit from new rules added in future releases.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Upgrade hook to thin delegator
|
|
170
|
+
rtk init --global
|
|
171
|
+
|
|
172
|
+
# Verify the new hook is active
|
|
173
|
+
rtk init --show
|
|
174
|
+
# Should show: ✅ Hook: ... (thin delegator, up to date)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Common User Flows
|
|
178
|
+
|
|
179
|
+
### First-Time User (Recommended)
|
|
180
|
+
```bash
|
|
181
|
+
# 1. Install RTK
|
|
182
|
+
cargo install --git https://github.com/rtk-ai/rtk
|
|
183
|
+
rtk gain # Verify (must show token stats)
|
|
184
|
+
|
|
185
|
+
# 2. Setup with prompts
|
|
186
|
+
rtk init -g
|
|
187
|
+
# → Answer 'y' when prompted to patch settings.json
|
|
188
|
+
# → Creates backup automatically
|
|
189
|
+
|
|
190
|
+
# 3. Restart Claude Code
|
|
191
|
+
# 4. Test: git status (should use rtk)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### CI/CD or Automation
|
|
195
|
+
```bash
|
|
196
|
+
# Non-interactive setup (no prompts)
|
|
197
|
+
rtk init -g --auto-patch
|
|
198
|
+
|
|
199
|
+
# Verify in scripts
|
|
200
|
+
rtk init --show | grep "Hook:"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Conservative User (Manual Control)
|
|
204
|
+
```bash
|
|
205
|
+
# Get manual instructions without patching
|
|
206
|
+
rtk init -g --no-patch
|
|
207
|
+
|
|
208
|
+
# Review printed JSON snippet
|
|
209
|
+
# Manually edit ~/.claude/settings.json
|
|
210
|
+
# Restart Claude Code
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Temporary Trial
|
|
214
|
+
```bash
|
|
215
|
+
# Install hook
|
|
216
|
+
rtk init -g --auto-patch
|
|
217
|
+
|
|
218
|
+
# Later: remove everything
|
|
219
|
+
rtk init -g --uninstall
|
|
220
|
+
|
|
221
|
+
# Restore backup if needed
|
|
222
|
+
cp ~/.claude/settings.json.bak ~/.claude/settings.json
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Installation Verification
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Basic test
|
|
229
|
+
rtk ls .
|
|
230
|
+
|
|
231
|
+
# Test with git
|
|
232
|
+
rtk git status
|
|
233
|
+
|
|
234
|
+
# Test with pnpm (fork only)
|
|
235
|
+
rtk pnpm list
|
|
236
|
+
|
|
237
|
+
# Test with Vitest (feat/vitest-support branch only)
|
|
238
|
+
rtk vitest run
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Uninstalling
|
|
242
|
+
|
|
243
|
+
### Complete Removal (Global Installations Only)
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Complete removal (global installations only)
|
|
247
|
+
rtk init -g --uninstall
|
|
248
|
+
|
|
249
|
+
# What gets removed:
|
|
250
|
+
# - Hook: ~/.claude/hooks/rtk-rewrite.sh
|
|
251
|
+
# - Context: ~/.claude/RTK.md
|
|
252
|
+
# - Reference: @RTK.md line from ~/.claude/CLAUDE.md
|
|
253
|
+
# - Registration: RTK hook entry from settings.json
|
|
254
|
+
|
|
255
|
+
# Restart Claude Code after uninstall
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**For Local Projects**: Manually remove RTK block from `./CLAUDE.md`
|
|
259
|
+
|
|
260
|
+
### Binary Removal
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# If installed via cargo
|
|
264
|
+
cargo uninstall rtk
|
|
265
|
+
|
|
266
|
+
# If installed via package manager
|
|
267
|
+
brew uninstall rtk # macOS Homebrew
|
|
268
|
+
sudo apt remove rtk # Debian/Ubuntu
|
|
269
|
+
sudo dnf remove rtk # Fedora/RHEL
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Restore from Backup (if needed)
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
cp ~/.claude/settings.json.bak ~/.claude/settings.json
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Essential Commands
|
|
279
|
+
|
|
280
|
+
### Files
|
|
281
|
+
```bash
|
|
282
|
+
rtk ls . # Compact tree view
|
|
283
|
+
rtk read file.rs # Optimized reading
|
|
284
|
+
rtk grep "pattern" . # Grouped search results
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Git
|
|
288
|
+
```bash
|
|
289
|
+
rtk git status # Compact status
|
|
290
|
+
rtk git log -n 10 # Condensed logs
|
|
291
|
+
rtk git diff # Optimized diff
|
|
292
|
+
rtk git add . # → "ok ✓"
|
|
293
|
+
rtk git commit -m "msg" # → "ok ✓ abc1234"
|
|
294
|
+
rtk git push # → "ok ✓ main"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Pnpm (fork only)
|
|
298
|
+
```bash
|
|
299
|
+
rtk pnpm list # Dependency tree (-70% tokens)
|
|
300
|
+
rtk pnpm outdated # Available updates (-80-90%)
|
|
301
|
+
rtk pnpm install pkg # Silent installation
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Tests
|
|
305
|
+
```bash
|
|
306
|
+
rtk test cargo test # Failures only (-90%)
|
|
307
|
+
rtk vitest run # Filtered Vitest output (-99.6%)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Statistics
|
|
311
|
+
```bash
|
|
312
|
+
rtk gain # Token savings
|
|
313
|
+
rtk gain --graph # With ASCII graph
|
|
314
|
+
rtk gain --history # With command history
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Validated Token Savings
|
|
318
|
+
|
|
319
|
+
### Production T3 Stack Project
|
|
320
|
+
| Operation | Standard | RTK | Reduction |
|
|
321
|
+
|-----------|----------|-----|-----------|
|
|
322
|
+
| `vitest run` | 102,199 chars | 377 chars | **-99.6%** |
|
|
323
|
+
| `git status` | 529 chars | 217 chars | **-59%** |
|
|
324
|
+
| `pnpm list` | ~8,000 tokens | ~2,400 | **-70%** |
|
|
325
|
+
| `pnpm outdated` | ~12,000 tokens | ~1,200-2,400 | **-80-90%** |
|
|
326
|
+
|
|
327
|
+
### Typical Claude Code Session (30 min)
|
|
328
|
+
- **Without RTK**: ~150,000 tokens
|
|
329
|
+
- **With RTK**: ~45,000 tokens
|
|
330
|
+
- **Savings**: **70% reduction**
|
|
331
|
+
|
|
332
|
+
## Troubleshooting
|
|
333
|
+
|
|
334
|
+
### RTK command not found after installation
|
|
335
|
+
```bash
|
|
336
|
+
# Check PATH
|
|
337
|
+
echo $PATH | grep -o '[^:]*\.cargo[^:]*'
|
|
338
|
+
|
|
339
|
+
# Add to PATH if needed (~/.bashrc or ~/.zshrc)
|
|
340
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
341
|
+
|
|
342
|
+
# Reload shell
|
|
343
|
+
source ~/.bashrc # or source ~/.zshrc
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### RTK command not available (e.g., vitest)
|
|
347
|
+
```bash
|
|
348
|
+
# Check branch
|
|
349
|
+
cd /path/to/rtk
|
|
350
|
+
git branch
|
|
351
|
+
|
|
352
|
+
# Switch to feat/vitest-support if needed
|
|
353
|
+
git checkout feat/vitest-support
|
|
354
|
+
|
|
355
|
+
# Reinstall
|
|
356
|
+
cargo install --path . --force
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Compilation error
|
|
360
|
+
```bash
|
|
361
|
+
# Update Rust
|
|
362
|
+
rustup update stable
|
|
363
|
+
|
|
364
|
+
# Clean and recompile
|
|
365
|
+
cargo clean
|
|
366
|
+
cargo build --release
|
|
367
|
+
cargo install --path . --force
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Support and Contributing
|
|
371
|
+
|
|
372
|
+
- **Website**: https://www.rtk-ai.app
|
|
373
|
+
- **Contact**: contact@rtk-ai.app
|
|
374
|
+
- **Troubleshooting**: See [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) for common issues
|
|
375
|
+
- **GitHub issues**: https://github.com/rtk-ai/rtk/issues
|
|
376
|
+
- **Pull Requests**: https://github.com/rtk-ai/rtk/pulls
|
|
377
|
+
|
|
378
|
+
⚠️ **If you installed the wrong rtk (Type Kit)**, see [TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md#problem-rtk-gain-command-not-found)
|
|
379
|
+
|
|
380
|
+
## AI Assistant Checklist
|
|
381
|
+
|
|
382
|
+
Before each session:
|
|
383
|
+
|
|
384
|
+
- [ ] Verify RTK is installed: `rtk --version`
|
|
385
|
+
- [ ] If not installed → follow "Install from fork"
|
|
386
|
+
- [ ] If project not initialized → `rtk init`
|
|
387
|
+
- [ ] Use `rtk` for ALL git/pnpm/test/vitest commands
|
|
388
|
+
- [ ] Check savings: `rtk gain`
|
|
389
|
+
|
|
390
|
+
**Golden Rule**: AI coding assistants should ALWAYS use `rtk` as a proxy for shell commands that generate verbose output (git, pnpm, npm, cargo test, vitest, docker, kubectl).
|
package/temp/rtk/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Patrick Szymkowiak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|