Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8e5618e6a |
No files matched your search
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.27.2"
|
||||
".": "0.27.1"
|
||||
}
|
||||
+1
-1
@@ -1488,4 +1488,4 @@ When implementing a new command, consider:
|
||||
|
||||
**Last Updated**: 2026-02-22
|
||||
**Architecture Version**: 2.2
|
||||
**rtk Version**: 0.27.1
|
||||
**rtk Version**: 0.26.0
|
||||
@@ -5,16 +5,6 @@ All notable changes to rtk (Rust Token Killer) will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.27.2](https://github.com/rtk-ai/rtk/compare/v0.27.1...v0.27.2) (2026-03-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* gh pr edit/comment pass correct subcommand to gh ([#332](https://github.com/rtk-ai/rtk/issues/332)) ([799f085](https://github.com/rtk-ai/rtk/commit/799f0856e4547318230fe150a43f50ab82e1cf03))
|
||||
* pass through -R/--repo flag in gh view commands ([#328](https://github.com/rtk-ai/rtk/issues/328)) ([0a1bcb0](https://github.com/rtk-ai/rtk/commit/0a1bcb05e5737311211369dcb92b3f756a6230c6)), closes [#223](https://github.com/rtk-ai/rtk/issues/223)
|
||||
* reduce gh diff / git diff / gh api truncation ([#354](https://github.com/rtk-ai/rtk/issues/354)) ([#370](https://github.com/rtk-ai/rtk/issues/370)) ([e356c12](https://github.com/rtk-ai/rtk/commit/e356c1280da9896195d0dff91e152c5f20347a65))
|
||||
* strip npx/bunx/pnpm prefixes in lint linter detection ([#186](https://github.com/rtk-ai/rtk/issues/186)) ([#366](https://github.com/rtk-ai/rtk/issues/366)) ([27b35d8](https://github.com/rtk-ai/rtk/commit/27b35d84a341622aa4bf686c2ce8867f8feeb742))
|
||||
|
||||
## [0.27.1](https://github.com/rtk-ai/rtk/compare/v0.27.0...v0.27.1) (2026-03-06)
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ This is a fork with critical fixes for git argument parsing and modern JavaScrip
|
||||
|
||||
**Verify correct installation:**
|
||||
```bash
|
||||
rtk --version # Should show "rtk 0.27.1" (or newer)
|
||||
rtk --version # Should show "rtk 0.26.0" (or newer)
|
||||
rtk gain # Should show token savings stats (NOT "command not found")
|
||||
```
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -838,7 +838,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rtk"
|
||||
version = "0.27.2"
|
||||
version = "0.27.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rtk"
|
||||
version = "0.27.2"
|
||||
version = "0.27.1"
|
||||
edition = "2021"
|
||||
authors = ["Patrick Szymkowiak"]
|
||||
description = "Rust Token Killer - High-performance CLI proxy to minimize LLM token consumption"
|
||||
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>Proxy CLI de alto rendimiento que reduce el consumo de tokens LLM en un 60-90%</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/rtk-ai/rtk/actions"><img src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/rtk-ai/rtk/releases"><img src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
<a href="https://discord.gg/pvHdzAec"><img src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"></a>
|
||||
<a href="https://formulae.brew.sh/formula/rtk"><img src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.rtk-ai.app">Sitio web</a> •
|
||||
<a href="#instalacion">Instalar</a> •
|
||||
<a href="docs/TROUBLESHOOTING.md">Solucion de problemas</a> •
|
||||
<a href="ARCHITECTURE.md">Arquitectura</a> •
|
||||
<a href="https://discord.gg/pvHdzAec">Discord</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">English</a> •
|
||||
<a href="README_fr.md">Francais</a> •
|
||||
<a href="README_zh.md">中文</a> •
|
||||
<a href="README_ja.md">日本語</a> •
|
||||
<a href="README_ko.md">한국어</a> •
|
||||
<a href="README_es.md">Espanol</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
rtk filtra y comprime las salidas de comandos antes de que lleguen al contexto de tu LLM. Binario Rust unico, cero dependencias, <10ms de overhead.
|
||||
|
||||
## Ahorro de tokens (sesion de 30 min en Claude Code)
|
||||
|
||||
| Operacion | Frecuencia | Estandar | rtk | Ahorro |
|
||||
|-----------|------------|----------|-----|--------|
|
||||
| `ls` / `tree` | 10x | 2,000 | 400 | -80% |
|
||||
| `cat` / `read` | 20x | 40,000 | 12,000 | -70% |
|
||||
| `grep` / `rg` | 8x | 16,000 | 3,200 | -80% |
|
||||
| `git status` | 10x | 3,000 | 600 | -80% |
|
||||
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
|
||||
| **Total** | | **~118,000** | **~23,900** | **-80%** |
|
||||
|
||||
## Instalacion
|
||||
|
||||
### Homebrew (recomendado)
|
||||
|
||||
```bash
|
||||
brew install rtk
|
||||
```
|
||||
|
||||
### Instalacion rapida (Linux/macOS)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
||||
```
|
||||
|
||||
### Cargo
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/rtk-ai/rtk
|
||||
```
|
||||
|
||||
### Verificacion
|
||||
|
||||
```bash
|
||||
rtk --version # Debe mostrar "rtk 0.27.x"
|
||||
rtk gain # Debe mostrar estadisticas de ahorro
|
||||
```
|
||||
|
||||
## Inicio rapido
|
||||
|
||||
```bash
|
||||
# 1. Instalar hook para Claude Code (recomendado)
|
||||
rtk init --global
|
||||
|
||||
# 2. Reiniciar Claude Code, luego probar
|
||||
git status # Automaticamente reescrito a rtk git status
|
||||
```
|
||||
|
||||
## Como funciona
|
||||
|
||||
```
|
||||
Sin rtk: Con rtk:
|
||||
|
||||
Claude --git status--> shell --> git Claude --git status--> RTK --> git
|
||||
^ | ^ | |
|
||||
| ~2,000 tokens (crudo) | | ~200 tokens | filtro |
|
||||
+-----------------------------------+ +------- (filtrado) ---+----------+
|
||||
```
|
||||
|
||||
Cuatro estrategias:
|
||||
|
||||
1. **Filtrado inteligente** - Elimina ruido (comentarios, espacios, boilerplate)
|
||||
2. **Agrupacion** - Agrega elementos similares (archivos por directorio, errores por tipo)
|
||||
3. **Truncamiento** - Mantiene contexto relevante, elimina redundancia
|
||||
4. **Deduplicacion** - Colapsa lineas de log repetidas con contadores
|
||||
|
||||
## Comandos
|
||||
|
||||
### Archivos
|
||||
```bash
|
||||
rtk ls . # Arbol de directorios optimizado
|
||||
rtk read file.rs # Lectura inteligente
|
||||
rtk find "*.rs" . # Resultados compactos
|
||||
rtk grep "pattern" . # Busqueda agrupada por archivo
|
||||
```
|
||||
|
||||
### Git
|
||||
```bash
|
||||
rtk git status # Estado compacto
|
||||
rtk git log -n 10 # Commits en una linea
|
||||
rtk git diff # Diff condensado
|
||||
rtk git push # -> "ok main"
|
||||
```
|
||||
|
||||
### Tests
|
||||
```bash
|
||||
rtk test cargo test # Solo fallos (-90%)
|
||||
rtk vitest run # Vitest compacto
|
||||
rtk pytest # Tests Python (-90%)
|
||||
rtk go test # Tests Go (-90%)
|
||||
```
|
||||
|
||||
### Build & Lint
|
||||
```bash
|
||||
rtk lint # ESLint agrupado por regla
|
||||
rtk tsc # Errores TypeScript agrupados
|
||||
rtk cargo build # Build Cargo (-80%)
|
||||
rtk ruff check # Lint Python (-80%)
|
||||
```
|
||||
|
||||
### Analiticas
|
||||
```bash
|
||||
rtk gain # Estadisticas de ahorro
|
||||
rtk gain --graph # Grafico ASCII (30 dias)
|
||||
rtk discover # Descubrir ahorros perdidos
|
||||
```
|
||||
|
||||
## Documentacion
|
||||
|
||||
- **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** - Resolver problemas comunes
|
||||
- **[INSTALL.md](INSTALL.md)** - Guia de instalacion detallada
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Arquitectura tecnica
|
||||
|
||||
## Contribuir
|
||||
|
||||
Las contribuciones son bienvenidas. Abre un issue o PR en [GitHub](https://github.com/rtk-ai/rtk).
|
||||
|
||||
Unete a la comunidad en [Discord](https://discord.gg/pvHdzAec).
|
||||
|
||||
## Licencia
|
||||
|
||||
Licencia MIT - ver [LICENSE](LICENSE) para detalles.
|
||||
-197
@@ -1,197 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>Proxy CLI haute performance qui reduit la consommation de tokens LLM de 60-90%</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/rtk-ai/rtk/actions"><img src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/rtk-ai/rtk/releases"><img src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
<a href="https://discord.gg/pvHdzAec"><img src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"></a>
|
||||
<a href="https://formulae.brew.sh/formula/rtk"><img src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.rtk-ai.app">Site web</a> •
|
||||
<a href="#installation">Installer</a> •
|
||||
<a href="docs/TROUBLESHOOTING.md">Depannage</a> •
|
||||
<a href="ARCHITECTURE.md">Architecture</a> •
|
||||
<a href="https://discord.gg/pvHdzAec">Discord</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">English</a> •
|
||||
<a href="README_fr.md">Francais</a> •
|
||||
<a href="README_zh.md">中文</a> •
|
||||
<a href="README_ja.md">日本語</a> •
|
||||
<a href="README_ko.md">한국어</a> •
|
||||
<a href="README_es.md">Espanol</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
rtk filtre et compresse les sorties de commandes avant qu'elles n'atteignent le contexte de votre LLM. Binaire Rust unique, zero dependance, <10ms d'overhead.
|
||||
|
||||
## Economies de tokens (session Claude Code de 30 min)
|
||||
|
||||
| Operation | Frequence | Standard | rtk | Economies |
|
||||
|-----------|-----------|----------|-----|-----------|
|
||||
| `ls` / `tree` | 10x | 2 000 | 400 | -80% |
|
||||
| `cat` / `read` | 20x | 40 000 | 12 000 | -70% |
|
||||
| `grep` / `rg` | 8x | 16 000 | 3 200 | -80% |
|
||||
| `git status` | 10x | 3 000 | 600 | -80% |
|
||||
| `git diff` | 5x | 10 000 | 2 500 | -75% |
|
||||
| `git log` | 5x | 2 500 | 500 | -80% |
|
||||
| `git add/commit/push` | 8x | 1 600 | 120 | -92% |
|
||||
| `cargo test` / `npm test` | 5x | 25 000 | 2 500 | -90% |
|
||||
| **Total** | | **~118 000** | **~23 900** | **-80%** |
|
||||
|
||||
> Estimations basees sur des projets TypeScript/Rust de taille moyenne.
|
||||
|
||||
## Installation
|
||||
|
||||
### Homebrew (recommande)
|
||||
|
||||
```bash
|
||||
brew install rtk
|
||||
```
|
||||
|
||||
### Installation rapide (Linux/macOS)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
||||
```
|
||||
|
||||
### Cargo
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/rtk-ai/rtk
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
```bash
|
||||
rtk --version # Doit afficher "rtk 0.27.x"
|
||||
rtk gain # Doit afficher les statistiques d'economies
|
||||
```
|
||||
|
||||
> **Attention** : Un autre projet "rtk" (Rust Type Kit) existe sur crates.io. Si `rtk gain` echoue, vous avez le mauvais package.
|
||||
|
||||
## Demarrage rapide
|
||||
|
||||
```bash
|
||||
# 1. Installer le hook pour Claude Code (recommande)
|
||||
rtk init --global
|
||||
# Suivre les instructions pour enregistrer dans ~/.claude/settings.json
|
||||
|
||||
# 2. Redemarrer Claude Code, puis tester
|
||||
git status # Automatiquement reecrit en rtk git status
|
||||
```
|
||||
|
||||
Le hook reecrit de maniere transparente les commandes (ex: `git status` -> `rtk git status`) avant execution.
|
||||
|
||||
## Comment ca marche
|
||||
|
||||
```
|
||||
Sans rtk : Avec rtk :
|
||||
|
||||
Claude --git status--> shell --> git Claude --git status--> RTK --> git
|
||||
^ | ^ | |
|
||||
| ~2 000 tokens (brut) | | ~200 tokens | filtre |
|
||||
+-----------------------------------+ +------- (filtre) -----+----------+
|
||||
```
|
||||
|
||||
Quatre strategies appliquees par type de commande :
|
||||
|
||||
1. **Filtrage intelligent** - Supprime le bruit (commentaires, espaces, boilerplate)
|
||||
2. **Regroupement** - Agregat d'elements similaires (fichiers par dossier, erreurs par type)
|
||||
3. **Troncature** - Conserve le contexte pertinent, coupe la redondance
|
||||
4. **Deduplication** - Fusionne les lignes de log repetees avec compteurs
|
||||
|
||||
## Commandes
|
||||
|
||||
### Fichiers
|
||||
```bash
|
||||
rtk ls . # Arbre de repertoires optimise
|
||||
rtk read file.rs # Lecture intelligente
|
||||
rtk read file.rs -l aggressive # Signatures uniquement
|
||||
rtk find "*.rs" . # Resultats compacts
|
||||
rtk grep "pattern" . # Resultats groupes par fichier
|
||||
rtk diff file1 file2 # Diff condense
|
||||
```
|
||||
|
||||
### Git
|
||||
```bash
|
||||
rtk git status # Status compact
|
||||
rtk git log -n 10 # Commits sur une ligne
|
||||
rtk git diff # Diff condense
|
||||
rtk git add # -> "ok"
|
||||
rtk git commit -m "msg" # -> "ok abc1234"
|
||||
rtk git push # -> "ok main"
|
||||
```
|
||||
|
||||
### Tests
|
||||
```bash
|
||||
rtk test cargo test # Echecs uniquement (-90%)
|
||||
rtk vitest run # Vitest compact
|
||||
rtk pytest # Tests Python (-90%)
|
||||
rtk go test # Tests Go (-90%)
|
||||
rtk cargo test # Tests Cargo (-90%)
|
||||
```
|
||||
|
||||
### Build & Lint
|
||||
```bash
|
||||
rtk lint # ESLint groupe par regle
|
||||
rtk tsc # Erreurs TypeScript groupees
|
||||
rtk cargo build # Build Cargo (-80%)
|
||||
rtk cargo clippy # Clippy (-80%)
|
||||
rtk ruff check # Linting Python (-80%)
|
||||
```
|
||||
|
||||
### Conteneurs
|
||||
```bash
|
||||
rtk docker ps # Liste compacte
|
||||
rtk docker logs <container> # Logs dedupliques
|
||||
rtk kubectl pods # Pods compacts
|
||||
```
|
||||
|
||||
### Analytics
|
||||
```bash
|
||||
rtk gain # Statistiques d'economies
|
||||
rtk gain --graph # Graphique ASCII (30 jours)
|
||||
rtk discover # Trouver les economies manquees
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
```toml
|
||||
# ~/.config/rtk/config.toml
|
||||
[tracking]
|
||||
database_path = "/chemin/custom.db"
|
||||
|
||||
[hooks]
|
||||
exclude_commands = ["curl", "playwright"]
|
||||
|
||||
[tee]
|
||||
enabled = true
|
||||
mode = "failures"
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
- **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** - Resoudre les problemes courants
|
||||
- **[INSTALL.md](INSTALL.md)** - Guide d'installation detaille
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Architecture technique
|
||||
|
||||
## Contribuer
|
||||
|
||||
Les contributions sont les bienvenues ! Ouvrez une issue ou une PR sur [GitHub](https://github.com/rtk-ai/rtk).
|
||||
|
||||
Rejoignez la communaute sur [Discord](https://discord.gg/pvHdzAec).
|
||||
|
||||
## Licence
|
||||
|
||||
Licence MIT - voir [LICENSE](LICENSE) pour les details.
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>LLM トークン消費を 60-90% 削減する高性能 CLI プロキシ</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/rtk-ai/rtk/actions"><img src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/rtk-ai/rtk/releases"><img src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
<a href="https://discord.gg/pvHdzAec"><img src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"></a>
|
||||
<a href="https://formulae.brew.sh/formula/rtk"><img src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.rtk-ai.app">ウェブサイト</a> •
|
||||
<a href="#インストール">インストール</a> •
|
||||
<a href="docs/TROUBLESHOOTING.md">トラブルシューティング</a> •
|
||||
<a href="ARCHITECTURE.md">アーキテクチャ</a> •
|
||||
<a href="https://discord.gg/pvHdzAec">Discord</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">English</a> •
|
||||
<a href="README_fr.md">Francais</a> •
|
||||
<a href="README_zh.md">中文</a> •
|
||||
<a href="README_ja.md">日本語</a> •
|
||||
<a href="README_ko.md">한국어</a> •
|
||||
<a href="README_es.md">Espanol</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
rtk はコマンド出力を LLM コンテキストに届く前にフィルタリング・圧縮します。単一の Rust バイナリ、依存関係ゼロ、オーバーヘッド 10ms 未満。
|
||||
|
||||
## トークン節約(30分の Claude Code セッション)
|
||||
|
||||
| 操作 | 頻度 | 標準 | rtk | 節約 |
|
||||
|------|------|------|-----|------|
|
||||
| `ls` / `tree` | 10x | 2,000 | 400 | -80% |
|
||||
| `cat` / `read` | 20x | 40,000 | 12,000 | -70% |
|
||||
| `grep` / `rg` | 8x | 16,000 | 3,200 | -80% |
|
||||
| `git status` | 10x | 3,000 | 600 | -80% |
|
||||
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
|
||||
| **合計** | | **~118,000** | **~23,900** | **-80%** |
|
||||
|
||||
## インストール
|
||||
|
||||
### Homebrew(推奨)
|
||||
|
||||
```bash
|
||||
brew install rtk
|
||||
```
|
||||
|
||||
### クイックインストール(Linux/macOS)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
||||
```
|
||||
|
||||
### Cargo
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/rtk-ai/rtk
|
||||
```
|
||||
|
||||
### 確認
|
||||
|
||||
```bash
|
||||
rtk --version # "rtk 0.27.x" と表示されるはず
|
||||
rtk gain # トークン節約統計が表示されるはず
|
||||
```
|
||||
|
||||
## クイックスタート
|
||||
|
||||
```bash
|
||||
# 1. Claude Code 用フックをインストール(推奨)
|
||||
rtk init --global
|
||||
|
||||
# 2. Claude Code を再起動してテスト
|
||||
git status # 自動的に rtk git status に書き換え
|
||||
```
|
||||
|
||||
## 仕組み
|
||||
|
||||
```
|
||||
rtk なし: rtk あり:
|
||||
|
||||
Claude --git status--> shell --> git Claude --git status--> RTK --> git
|
||||
^ | ^ | |
|
||||
| ~2,000 tokens(生出力) | | ~200 tokens | フィルタ |
|
||||
+-----------------------------------+ +------- (圧縮済)----+----------+
|
||||
```
|
||||
|
||||
4つの戦略:
|
||||
|
||||
1. **スマートフィルタリング** - ノイズを除去(コメント、空白、ボイラープレート)
|
||||
2. **グルーピング** - 類似項目を集約(ディレクトリ別ファイル、タイプ別エラー)
|
||||
3. **トランケーション** - 関連コンテキストを保持、冗長性をカット
|
||||
4. **重複排除** - 繰り返しログ行をカウント付きで統合
|
||||
|
||||
## コマンド
|
||||
|
||||
### ファイル
|
||||
```bash
|
||||
rtk ls . # 最適化されたディレクトリツリー
|
||||
rtk read file.rs # スマートファイル読み取り
|
||||
rtk find "*.rs" . # コンパクトな検索結果
|
||||
rtk grep "pattern" . # ファイル別グループ化検索
|
||||
```
|
||||
|
||||
### Git
|
||||
```bash
|
||||
rtk git status # コンパクトなステータス
|
||||
rtk git log -n 10 # 1行コミット
|
||||
rtk git diff # 圧縮された diff
|
||||
rtk git push # -> "ok main"
|
||||
```
|
||||
|
||||
### テスト
|
||||
```bash
|
||||
rtk test cargo test # 失敗のみ表示(-90%)
|
||||
rtk vitest run # Vitest コンパクト
|
||||
rtk pytest # Python テスト(-90%)
|
||||
rtk go test # Go テスト(-90%)
|
||||
```
|
||||
|
||||
### ビルド & リント
|
||||
```bash
|
||||
rtk lint # ESLint ルール別グループ化
|
||||
rtk tsc # TypeScript エラーグループ化
|
||||
rtk cargo build # Cargo ビルド(-80%)
|
||||
rtk ruff check # Python リント(-80%)
|
||||
```
|
||||
|
||||
### 分析
|
||||
```bash
|
||||
rtk gain # 節約統計
|
||||
rtk gain --graph # ASCII グラフ(30日間)
|
||||
rtk discover # 見逃した節約機会を発見
|
||||
```
|
||||
|
||||
## ドキュメント
|
||||
|
||||
- **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** - よくある問題の解決
|
||||
- **[INSTALL.md](INSTALL.md)** - 詳細インストールガイド
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - 技術アーキテクチャ
|
||||
|
||||
## コントリビュート
|
||||
|
||||
コントリビューション歓迎 で issue または PR を作成してください。
|
||||
|
||||
[Discord](https://discord.gg/pvHdzAec) コミュニティに参加。
|
||||
|
||||
## ライセンス
|
||||
|
||||
MIT ライセンス - 詳細は [LICENSE](LICENSE) を参照。
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>LLM 토큰 소비를 60-90% 줄이는 고성능 CLI 프록시</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/rtk-ai/rtk/actions"><img src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/rtk-ai/rtk/releases"><img src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
<a href="https://discord.gg/pvHdzAec"><img src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"></a>
|
||||
<a href="https://formulae.brew.sh/formula/rtk"><img src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.rtk-ai.app">웹사이트</a> •
|
||||
<a href="#설치">설치</a> •
|
||||
<a href="docs/TROUBLESHOOTING.md">문제 해결</a> •
|
||||
<a href="ARCHITECTURE.md">아키텍처</a> •
|
||||
<a href="https://discord.gg/pvHdzAec">Discord</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">English</a> •
|
||||
<a href="README_fr.md">Francais</a> •
|
||||
<a href="README_zh.md">中文</a> •
|
||||
<a href="README_ja.md">日本語</a> •
|
||||
<a href="README_ko.md">한국어</a> •
|
||||
<a href="README_es.md">Espanol</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
rtk는 명령 출력이 LLM 컨텍스트에 도달하기 전에 필터링하고 압축합니다. 단일 Rust 바이너리, 의존성 없음, 10ms 미만의 오버헤드.
|
||||
|
||||
## 토큰 절약 (30분 Claude Code 세션)
|
||||
|
||||
| 작업 | 빈도 | 표준 | rtk | 절약 |
|
||||
|------|------|------|-----|------|
|
||||
| `ls` / `tree` | 10x | 2,000 | 400 | -80% |
|
||||
| `cat` / `read` | 20x | 40,000 | 12,000 | -70% |
|
||||
| `grep` / `rg` | 8x | 16,000 | 3,200 | -80% |
|
||||
| `git status` | 10x | 3,000 | 600 | -80% |
|
||||
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
|
||||
| **합계** | | **~118,000** | **~23,900** | **-80%** |
|
||||
|
||||
## 설치
|
||||
|
||||
### Homebrew (권장)
|
||||
|
||||
```bash
|
||||
brew install rtk
|
||||
```
|
||||
|
||||
### 빠른 설치 (Linux/macOS)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
||||
```
|
||||
|
||||
### Cargo
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/rtk-ai/rtk
|
||||
```
|
||||
|
||||
### 확인
|
||||
|
||||
```bash
|
||||
rtk --version # "rtk 0.27.x" 표시되어야 함
|
||||
rtk gain # 토큰 절약 통계 표시되어야 함
|
||||
```
|
||||
|
||||
## 빠른 시작
|
||||
|
||||
```bash
|
||||
# 1. Claude Code용 hook 설치 (권장)
|
||||
rtk init --global
|
||||
|
||||
# 2. Claude Code 재시작 후 테스트
|
||||
git status # 자동으로 rtk git status로 재작성
|
||||
```
|
||||
|
||||
## 작동 원리
|
||||
|
||||
```
|
||||
rtk 없이: rtk 사용:
|
||||
|
||||
Claude --git status--> shell --> git Claude --git status--> RTK --> git
|
||||
^ | ^ | |
|
||||
| ~2,000 tokens (원본) | | ~200 tokens | 필터 |
|
||||
+-----------------------------------+ +------- (필터링) -----+----------+
|
||||
```
|
||||
|
||||
네 가지 전략:
|
||||
|
||||
1. **스마트 필터링** - 노이즈 제거 (주석, 공백, 보일러플레이트)
|
||||
2. **그룹화** - 유사 항목 집계 (디렉토리별 파일, 유형별 에러)
|
||||
3. **잘라내기** - 관련 컨텍스트 유지, 중복 제거
|
||||
4. **중복 제거** - 반복 로그 라인을 카운트와 함께 통합
|
||||
|
||||
## 명령어
|
||||
|
||||
### 파일
|
||||
```bash
|
||||
rtk ls . # 최적화된 디렉토리 트리
|
||||
rtk read file.rs # 스마트 파일 읽기
|
||||
rtk find "*.rs" . # 컴팩트한 검색 결과
|
||||
rtk grep "pattern" . # 파일별 그룹화 검색
|
||||
```
|
||||
|
||||
### Git
|
||||
```bash
|
||||
rtk git status # 컴팩트 상태
|
||||
rtk git log -n 10 # 한 줄 커밋
|
||||
rtk git diff # 압축된 diff
|
||||
rtk git push # -> "ok main"
|
||||
```
|
||||
|
||||
### 테스트
|
||||
```bash
|
||||
rtk test cargo test # 실패만 표시 (-90%)
|
||||
rtk vitest run # Vitest 컴팩트
|
||||
rtk pytest # Python 테스트 (-90%)
|
||||
rtk go test # Go 테스트 (-90%)
|
||||
```
|
||||
|
||||
### 빌드 & 린트
|
||||
```bash
|
||||
rtk lint # ESLint 규칙별 그룹화
|
||||
rtk tsc # TypeScript 에러 그룹화
|
||||
rtk cargo build # Cargo 빌드 (-80%)
|
||||
rtk ruff check # Python 린트 (-80%)
|
||||
```
|
||||
|
||||
### 분석
|
||||
```bash
|
||||
rtk gain # 절약 통계
|
||||
rtk gain --graph # ASCII 그래프 (30일)
|
||||
rtk discover # 놓친 절약 기회 발견
|
||||
```
|
||||
|
||||
## 문서
|
||||
|
||||
- **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** - 일반적인 문제 해결
|
||||
- **[INSTALL.md](INSTALL.md)** - 상세 설치 가이드
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - 기술 아키텍처
|
||||
|
||||
## 기여
|
||||
|
||||
기여를 환영합니다! [GitHub](https://github.com/rtk-ai/rtk)에서 issue 또는 PR을 생성해 주세요.
|
||||
|
||||
[Discord](https://discord.gg/pvHdzAec) 커뮤니티에 참여하세요.
|
||||
|
||||
## 라이선스
|
||||
|
||||
MIT 라이선스 - 자세한 내용은 [LICENSE](LICENSE)를 참조하세요.
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://avatars.githubusercontent.com/u/258253854?v=4" alt="RTK - Rust Token Killer" width="500">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<strong>高性能 CLI 代理,将 LLM token 消耗降低 60-90%</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/rtk-ai/rtk/actions"><img src="https://github.com/rtk-ai/rtk/workflows/Security%20Check/badge.svg" alt="CI"></a>
|
||||
<a href="https://github.com/rtk-ai/rtk/releases"><img src="https://img.shields.io/github/v/release/rtk-ai/rtk" alt="Release"></a>
|
||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
||||
<a href="https://discord.gg/pvHdzAec"><img src="https://img.shields.io/discord/1470188214710046894?label=Discord&logo=discord" alt="Discord"></a>
|
||||
<a href="https://formulae.brew.sh/formula/rtk"><img src="https://img.shields.io/homebrew/v/rtk" alt="Homebrew"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.rtk-ai.app">官网</a> •
|
||||
<a href="#安装">安装</a> •
|
||||
<a href="docs/TROUBLESHOOTING.md">故障排除</a> •
|
||||
<a href="ARCHITECTURE.md">架构</a> •
|
||||
<a href="https://discord.gg/pvHdzAec">Discord</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="README.md">English</a> •
|
||||
<a href="README_fr.md">Francais</a> •
|
||||
<a href="README_zh.md">中文</a> •
|
||||
<a href="README_ja.md">日本語</a> •
|
||||
<a href="README_ko.md">한국어</a> •
|
||||
<a href="README_es.md">Espanol</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
rtk 在命令输出到达 LLM 上下文之前进行过滤和压缩。单一 Rust 二进制文件,零依赖,<10ms 开销。
|
||||
|
||||
## Token 节省(30 分钟 Claude Code 会话)
|
||||
|
||||
| 操作 | 频率 | 标准 | rtk | 节省 |
|
||||
|------|------|------|-----|------|
|
||||
| `ls` / `tree` | 10x | 2,000 | 400 | -80% |
|
||||
| `cat` / `read` | 20x | 40,000 | 12,000 | -70% |
|
||||
| `grep` / `rg` | 8x | 16,000 | 3,200 | -80% |
|
||||
| `git status` | 10x | 3,000 | 600 | -80% |
|
||||
| `git diff` | 5x | 10,000 | 2,500 | -75% |
|
||||
| `cargo test` / `npm test` | 5x | 25,000 | 2,500 | -90% |
|
||||
| **总计** | | **~118,000** | **~23,900** | **-80%** |
|
||||
|
||||
## 安装
|
||||
|
||||
### Homebrew(推荐)
|
||||
|
||||
```bash
|
||||
brew install rtk
|
||||
```
|
||||
|
||||
### 快速安装(Linux/macOS)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
||||
```
|
||||
|
||||
### Cargo
|
||||
|
||||
```bash
|
||||
cargo install --git https://github.com/rtk-ai/rtk
|
||||
```
|
||||
|
||||
### 验证
|
||||
|
||||
```bash
|
||||
rtk --version # 应显示 "rtk 0.27.x"
|
||||
rtk gain # 应显示 token 节省统计
|
||||
```
|
||||
|
||||
## 快速开始
|
||||
|
||||
```bash
|
||||
# 1. 为 Claude Code 安装 hook(推荐)
|
||||
rtk init --global
|
||||
|
||||
# 2. 重启 Claude Code,然后测试
|
||||
git status # 自动重写为 rtk git status
|
||||
```
|
||||
|
||||
## 工作原理
|
||||
|
||||
```
|
||||
没有 rtk: 使用 rtk:
|
||||
|
||||
Claude --git status--> shell --> git Claude --git status--> RTK --> git
|
||||
^ | ^ | |
|
||||
| ~2,000 tokens(原始) | | ~200 tokens | 过滤 |
|
||||
+-----------------------------------+ +------- (已过滤)-----+----------+
|
||||
```
|
||||
|
||||
四种策略:
|
||||
|
||||
1. **智能过滤** - 去除噪音(注释、空白、样板代码)
|
||||
2. **分组** - 聚合相似项(按目录分文件,按类型分错误)
|
||||
3. **截断** - 保留相关上下文,删除冗余
|
||||
4. **去重** - 合并重复日志行并计数
|
||||
|
||||
## 命令
|
||||
|
||||
### 文件
|
||||
```bash
|
||||
rtk ls . # 优化的目录树
|
||||
rtk read file.rs # 智能文件读取
|
||||
rtk find "*.rs" . # 紧凑的查找结果
|
||||
rtk grep "pattern" . # 按文件分组的搜索结果
|
||||
```
|
||||
|
||||
### Git
|
||||
```bash
|
||||
rtk git status # 紧凑状态
|
||||
rtk git log -n 10 # 单行提交
|
||||
rtk git diff # 精简 diff
|
||||
rtk git push # -> "ok main"
|
||||
```
|
||||
|
||||
### 测试
|
||||
```bash
|
||||
rtk test cargo test # 仅显示失败(-90%)
|
||||
rtk vitest run # Vitest 紧凑输出
|
||||
rtk pytest # Python 测试(-90%)
|
||||
rtk go test # Go 测试(-90%)
|
||||
```
|
||||
|
||||
### 构建 & 检查
|
||||
```bash
|
||||
rtk lint # ESLint 按规则分组
|
||||
rtk tsc # TypeScript 错误分组
|
||||
rtk cargo build # Cargo 构建(-80%)
|
||||
rtk ruff check # Python lint(-80%)
|
||||
```
|
||||
|
||||
### 容器
|
||||
```bash
|
||||
rtk docker ps # 紧凑容器列表
|
||||
rtk docker logs <container> # 去重日志
|
||||
rtk kubectl pods # 紧凑 Pod 列表
|
||||
```
|
||||
|
||||
### 分析
|
||||
```bash
|
||||
rtk gain # 节省统计
|
||||
rtk gain --graph # ASCII 图表(30 天)
|
||||
rtk discover # 发现遗漏的节省机会
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
- **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** - 解决常见问题
|
||||
- **[INSTALL.md](INSTALL.md)** - 详细安装指南
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - 技术架构
|
||||
|
||||
## 贡献
|
||||
|
||||
欢迎贡献!请在 [GitHub](https://github.com/rtk-ai/rtk) 上提交 issue 或 PR。
|
||||
|
||||
加入 [Discord](https://discord.gg/pvHdzAec) 社区。
|
||||
|
||||
## 许可证
|
||||
|
||||
MIT 许可证 - 详见 [LICENSE](LICENSE)。
|
||||
+44
-60
@@ -4,6 +4,7 @@
|
||||
//! Focuses on extracting essential information from JSON outputs.
|
||||
|
||||
use crate::git;
|
||||
use crate::json_cmd;
|
||||
use crate::tracking;
|
||||
use crate::utils::{ok_confirmation, truncate};
|
||||
use anyhow::{Context, Result};
|
||||
@@ -275,12 +276,6 @@ fn list_prs(args: &[String], _verbose: u8, ultra_compact: bool) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_passthrough_pr_view(extra_args: &[String]) -> bool {
|
||||
extra_args
|
||||
.iter()
|
||||
.any(|a| a == "--json" || a == "--jq" || a == "--web")
|
||||
}
|
||||
|
||||
fn view_pr(args: &[String], _verbose: u8, ultra_compact: bool) -> Result<()> {
|
||||
let timer = tracking::TimedExecution::start();
|
||||
|
||||
@@ -289,12 +284,6 @@ fn view_pr(args: &[String], _verbose: u8, ultra_compact: bool) -> Result<()> {
|
||||
None => return Err(anyhow::anyhow!("PR number required")),
|
||||
};
|
||||
|
||||
// If the user provides --jq or --web, pass through directly.
|
||||
// Note: --json is already handled globally by run() via has_json_flag.
|
||||
if should_passthrough_pr_view(&extra_args) {
|
||||
return run_passthrough_with_extra("gh", &["pr", "view", &pr_number], &extra_args);
|
||||
}
|
||||
|
||||
let mut cmd = Command::new("gh");
|
||||
cmd.args([
|
||||
"pr",
|
||||
@@ -1103,23 +1092,11 @@ fn pr_merge(args: &[String], _verbose: u8) -> Result<()> {
|
||||
}
|
||||
|
||||
fn pr_diff(args: &[String], _verbose: u8) -> Result<()> {
|
||||
// --no-compact: pass full diff through (gh CLI doesn't know this flag, strip it)
|
||||
let no_compact = args.iter().any(|a| a == "--no-compact");
|
||||
let gh_args: Vec<String> = args
|
||||
.iter()
|
||||
.filter(|a| *a != "--no-compact")
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
if no_compact {
|
||||
return run_passthrough_with_extra("gh", &["pr", "diff"], &gh_args);
|
||||
}
|
||||
|
||||
let timer = tracking::TimedExecution::start();
|
||||
|
||||
let mut cmd = Command::new("gh");
|
||||
cmd.args(["pr", "diff"]);
|
||||
for arg in gh_args.iter() {
|
||||
for arg in args {
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
||||
@@ -1138,7 +1115,7 @@ fn pr_diff(args: &[String], _verbose: u8) -> Result<()> {
|
||||
print!("{}", msg);
|
||||
msg.to_string()
|
||||
} else {
|
||||
let compacted = git::compact_diff(&raw, 500);
|
||||
let compacted = git::compact_diff(&raw, 100);
|
||||
println!("{}", compacted);
|
||||
compacted
|
||||
};
|
||||
@@ -1202,10 +1179,47 @@ fn pr_action(action: &str, args: &[String], _verbose: u8) -> Result<()> {
|
||||
}
|
||||
|
||||
fn run_api(args: &[String], _verbose: u8) -> Result<()> {
|
||||
// gh api is an explicit/advanced command — the user knows what they asked for.
|
||||
// Converting JSON to a schema destroys all values and forces Claude to re-fetch.
|
||||
// Passthrough preserves the full response and tracks metrics at 0% savings.
|
||||
run_passthrough("gh", "api", args)
|
||||
let timer = tracking::TimedExecution::start();
|
||||
|
||||
let mut cmd = Command::new("gh");
|
||||
cmd.arg("api");
|
||||
for arg in args {
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
||||
let output = cmd.output().context("Failed to run gh api")?;
|
||||
let raw = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
||||
timer.track("gh api", "rtk gh api", &stderr, &stderr);
|
||||
eprintln!("{}", stderr.trim());
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
// Try to parse as JSON and filter
|
||||
let filtered = match json_cmd::filter_json_string(&raw, 5) {
|
||||
Ok(schema) => {
|
||||
println!("{}", schema);
|
||||
schema
|
||||
}
|
||||
Err(_) => {
|
||||
// Not JSON, print truncated raw output
|
||||
let mut result = String::new();
|
||||
let lines: Vec<&str> = raw.lines().take(20).collect();
|
||||
let joined = lines.join("\n");
|
||||
result.push_str(&joined);
|
||||
print!("{}", joined);
|
||||
if raw.lines().count() > 20 {
|
||||
result.push_str("\n... (truncated)");
|
||||
println!("\n... (truncated)");
|
||||
}
|
||||
result
|
||||
}
|
||||
};
|
||||
|
||||
timer.track("gh api", "rtk gh api", &raw, &filtered);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Pass through a command with base args + extra args, tracking as passthrough.
|
||||
@@ -1418,36 +1432,6 @@ mod tests {
|
||||
assert!(!should_passthrough_run_view(&["--web".into()]));
|
||||
}
|
||||
|
||||
// --- should_passthrough_pr_view tests ---
|
||||
|
||||
#[test]
|
||||
fn test_should_passthrough_pr_view_json() {
|
||||
assert!(should_passthrough_pr_view(&[
|
||||
"--json".into(),
|
||||
"body,comments".into()
|
||||
]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_passthrough_pr_view_jq() {
|
||||
assert!(should_passthrough_pr_view(&["--jq".into(), ".body".into()]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_passthrough_pr_view_web() {
|
||||
assert!(should_passthrough_pr_view(&["--web".into()]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_passthrough_pr_view_default() {
|
||||
assert!(!should_passthrough_pr_view(&[]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_passthrough_pr_view_other_flags() {
|
||||
assert!(!should_passthrough_pr_view(&["--comments".into()]));
|
||||
}
|
||||
|
||||
// --- filter_markdown_body tests ---
|
||||
|
||||
#[test]
|
||||
|
||||
+3
-37
@@ -130,7 +130,7 @@ fn run_diff(
|
||||
let mut final_output = stat_stdout.to_string();
|
||||
if !diff_stdout.is_empty() {
|
||||
println!("\n--- Changes ---");
|
||||
let compacted = compact_diff(&diff_stdout, max_lines.unwrap_or(500));
|
||||
let compacted = compact_diff(&diff_stdout, max_lines.unwrap_or(100));
|
||||
println!("{}", compacted);
|
||||
final_output.push_str("\n--- Changes ---\n");
|
||||
final_output.push_str(&compacted);
|
||||
@@ -250,7 +250,7 @@ fn run_show(
|
||||
if verbose > 0 {
|
||||
println!("\n--- Changes ---");
|
||||
}
|
||||
let compacted = compact_diff(diff_text, max_lines.unwrap_or(500));
|
||||
let compacted = compact_diff(diff_text, max_lines.unwrap_or(100));
|
||||
println!("{}", compacted);
|
||||
final_output.push_str(&format!("\n{}", compacted));
|
||||
}
|
||||
@@ -277,7 +277,7 @@ pub(crate) fn compact_diff(diff: &str, max_lines: usize) -> String {
|
||||
let mut removed = 0;
|
||||
let mut in_hunk = false;
|
||||
let mut hunk_lines = 0;
|
||||
let max_hunk_lines = 30;
|
||||
let max_hunk_lines = 10;
|
||||
|
||||
for line in diff.lines() {
|
||||
if line.starts_with("diff --git") {
|
||||
@@ -1449,40 +1449,6 @@ mod tests {
|
||||
assert!(result.contains("+"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_compact_diff_increased_hunk_limit() {
|
||||
// Build a hunk with 25 changed lines — should NOT be truncated with limit 30
|
||||
let mut diff =
|
||||
"diff --git a/big.rs b/big.rs\n--- a/big.rs\n+++ b/big.rs\n@@ -1,25 +1,25 @@\n"
|
||||
.to_string();
|
||||
for i in 1..=25 {
|
||||
diff.push_str(&format!("+line{}\n", i));
|
||||
}
|
||||
let result = compact_diff(&diff, 500);
|
||||
assert!(
|
||||
!result.contains("... (truncated)"),
|
||||
"25 lines should not be truncated with max_hunk_lines=30"
|
||||
);
|
||||
assert!(result.contains("+line25"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_compact_diff_increased_total_limit() {
|
||||
// Build a diff with 150 output result lines across multiple files — should NOT be cut at 100
|
||||
let mut diff = String::new();
|
||||
for f in 1..=5 {
|
||||
diff.push_str(&format!("diff --git a/file{f}.rs b/file{f}.rs\n--- a/file{f}.rs\n+++ b/file{f}.rs\n@@ -1,20 +1,20 @@\n"));
|
||||
for i in 1..=20 {
|
||||
diff.push_str(&format!("+line{f}_{i}\n"));
|
||||
}
|
||||
}
|
||||
let result = compact_diff(&diff, 500);
|
||||
assert!(
|
||||
!result.contains("more changes truncated"),
|
||||
"5 files × 20 lines should not exceed max_lines=500"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_blob_show_arg() {
|
||||
assert!(is_blob_show_arg("develop:modules/pairs_backtest.py"));
|
||||
|
||||
Reference in new issue
Block a user