Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4467296bd1 | ||
|
|
55d8dc9def | ||
|
|
ffbc8863ff |
No files matched your search
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.29.0"
|
||||
".": "0.30.0"
|
||||
}
|
||||
@@ -5,6 +5,40 @@ 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.30.0](https://github.com/rtk-ai/rtk/compare/v0.29.0...v0.30.0) (2026-03-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add rtk session command for adoption overview ([be67d66](https://github.com/rtk-ai/rtk/commit/be67d660100c06a0751c08d943dc884ad5bff6a3))
|
||||
* add rtk session command for adoption overview ([12d44c4](https://github.com/rtk-ai/rtk/commit/12d44c4068d7d4f65d5bd7551af29ab5a2352ed1)), closes [#487](https://github.com/rtk-ai/rtk/issues/487)
|
||||
* add worktree slash commands for isolated development ([#364](https://github.com/rtk-ai/rtk/issues/364)) ([ab83e79](https://github.com/rtk-ai/rtk/commit/ab83e7933ebc26ca76f843d33285729875efb913))
|
||||
* Claude Code tooling — 2 agents, 7 commands, 2 rules, 4 skills ([#491](https://github.com/rtk-ai/rtk/issues/491)) ([7b7a5ae](https://github.com/rtk-ai/rtk/commit/7b7a5ae4b6d23fbb882ed7d5e815e2ed0672c46c))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 6 critical bugs — exit codes, unwrap, lazy regex ([#626](https://github.com/rtk-ai/rtk/issues/626)) ([3005ebd](https://github.com/rtk-ai/rtk/commit/3005ebd0ad07912ae919687f6d3d49482aabaeac))
|
||||
* align 7 TOML filter tests with on_empty behavior ([04ed6d8](https://github.com/rtk-ai/rtk/commit/04ed6d8c314dcbf86b147903b5a7f1cd956dc980))
|
||||
* align 7 TOML filter tests with on_empty behavior ([9a499b9](https://github.com/rtk-ai/rtk/commit/9a499b9714e97a553d5603680ab1f843034acf28))
|
||||
* **cicd-docs:** add agent reviewer + some contribute guidelines ([de710f4](https://github.com/rtk-ai/rtk/commit/de710f4ea30c333130c46f8a2e2c5b6b9edd4889))
|
||||
* **cicd-docs:** some logs to understand what is happening when check docs ([191ea9a](https://github.com/rtk-ai/rtk/commit/191ea9af9f99ee78d74385fe1952ce83045e4afe))
|
||||
* **cicd:** Clean cicd, rework depends and add pre-release ([d24a765](https://github.com/rtk-ai/rtk/commit/d24a7650e26aca89224a3ec5d263f1ce7c7121d6))
|
||||
* **cicd:** Clean cicd, rework depends and add pre-release ([6303e95](https://github.com/rtk-ai/rtk/commit/6303e9530a379a8e3939e6c122ab4cf07cb16751))
|
||||
* **cicd:** clippy - do not treat warn as error ([5da5db2](https://github.com/rtk-ai/rtk/commit/5da5db222d9927394995ccaeb3afc103e80c22bd))
|
||||
* failing context for doc analyze -> cat from files ([c6b7db2](https://github.com/rtk-ai/rtk/commit/c6b7db2e5a6cd9a05262e934b4fc7a44c699c3b0))
|
||||
* git log --oneline regression drops commits ([#619](https://github.com/rtk-ai/rtk/issues/619)) ([8e85d67](https://github.com/rtk-ai/rtk/commit/8e85d676d78b12d2c421bb892f93971fc222fb39))
|
||||
* improve adoption metric by detecting hook-rewritten commands ([eb8a2c4](https://github.com/rtk-ai/rtk/commit/eb8a2c4a71072870fca4b64e90189a4453acff84))
|
||||
* normalize binlogs CRLF ([5344af9](https://github.com/rtk-ai/rtk/commit/5344af9a51f06b5dc42692e42c948ff11a3173c6))
|
||||
* preserve commit body in git log output ([e189bbb](https://github.com/rtk-ai/rtk/commit/e189bbbe749120eda4d98a2130937269d8c0e92a))
|
||||
* preserve first line of commit body in git log output ([c3416eb](https://github.com/rtk-ai/rtk/commit/c3416eb45f2f97297ec149d296a6a500697d302b))
|
||||
* remove version check from validate-docs CI ([#476](https://github.com/rtk-ai/rtk/issues/476)) ([#543](https://github.com/rtk-ai/rtk/issues/543)) ([6e61c24](https://github.com/rtk-ai/rtk/commit/6e61c2447cc03af94220ce6ce83686f155e18086))
|
||||
* split chained commands in adoption metric ([127f85c](https://github.com/rtk-ai/rtk/commit/127f85c02efd52a64e461005fa142d05f81615f8))
|
||||
* support git -C <path> in rewrite registry ([c916bab](https://github.com/rtk-ai/rtk/commit/c916bab33ae9760b234fd720c944a849141f0d2e)), closes [#555](https://github.com/rtk-ai/rtk/issues/555)
|
||||
* test-all.sh aborts when gt not installed ([#500](https://github.com/rtk-ai/rtk/issues/500)) ([#544](https://github.com/rtk-ai/rtk/issues/544)) ([26f5473](https://github.com/rtk-ai/rtk/commit/26f547371798ad32aed3569965303bc4857789ed))
|
||||
* trust boundary followup — TOML key typo + missing meta commands ([#625](https://github.com/rtk-ai/rtk/issues/625)) ([8d8e188](https://github.com/rtk-ai/rtk/commit/8d8e188705e5784829693a83b2076d6118154764))
|
||||
* windows path fix for git tests ([0a904e2](https://github.com/rtk-ai/rtk/commit/0a904e264d58f8f4b5f10e37ec3b11f717458fe0))
|
||||
|
||||
## [0.29.0](https://github.com/rtk-ai/rtk/compare/v0.28.2...v0.29.0) (2026-03-12)
|
||||
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -892,7 +892,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rtk"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rtk"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
edition = "2021"
|
||||
authors = ["Patrick Szymkowiak"]
|
||||
description = "Rust Token Killer - High-performance CLI proxy to minimize LLM token consumption"
|
||||
|
||||
@@ -16,8 +16,6 @@ pub struct Config {
|
||||
pub telemetry: TelemetryConfig,
|
||||
#[serde(default)]
|
||||
pub hooks: HooksConfig,
|
||||
#[serde(default)]
|
||||
pub limits: LimitsConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
@@ -96,39 +94,6 @@ impl Default for TelemetryConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct LimitsConfig {
|
||||
/// Max total grep results to show (default: 200)
|
||||
pub grep_max_results: usize,
|
||||
/// Max matches per file in grep output (default: 25)
|
||||
pub grep_max_per_file: usize,
|
||||
/// Max staged/modified files shown in git status (default: 15)
|
||||
pub status_max_files: usize,
|
||||
/// Max untracked files shown in git status (default: 10)
|
||||
pub status_max_untracked: usize,
|
||||
/// Max chars for parser passthrough fallback (default: 2000)
|
||||
pub passthrough_max_chars: usize,
|
||||
}
|
||||
|
||||
impl Default for LimitsConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
grep_max_results: 200,
|
||||
grep_max_per_file: 25,
|
||||
status_max_files: 15,
|
||||
status_max_untracked: 10,
|
||||
passthrough_max_chars: 2000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get limits config. Falls back to defaults if config can't be loaded.
|
||||
pub fn limits() -> LimitsConfig {
|
||||
Config::load()
|
||||
.map(|c| c.limits)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Check if telemetry is enabled in config. Returns None if config can't be loaded.
|
||||
pub fn telemetry_enabled() -> Option<bool> {
|
||||
Config::load().ok().map(|c| c.telemetry.enabled)
|
||||
|
||||
@@ -183,19 +183,6 @@ fn docker_logs(args: &[String], _verbose: u8) -> Result<()> {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
let raw = format!("{}\n{}", stdout, stderr);
|
||||
|
||||
if !output.status.success() {
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track(
|
||||
&format!("docker logs {}", container),
|
||||
"rtk docker logs",
|
||||
&raw,
|
||||
&raw,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let analyzed = crate::log_cmd::run_stdin_str(&raw);
|
||||
let rtk = format!("🐳 Logs for {}:\n{}", container, analyzed);
|
||||
println!("{}", rtk);
|
||||
@@ -221,15 +208,6 @@ fn kubectl_pods(args: &[String], _verbose: u8) -> Result<()> {
|
||||
let raw = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
let mut rtk = String::new();
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track("kubectl get pods", "rtk kubectl pods", &raw, &raw);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let json: serde_json::Value = match serde_json::from_str(&raw) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
@@ -328,15 +306,6 @@ fn kubectl_services(args: &[String], _verbose: u8) -> Result<()> {
|
||||
let raw = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
let mut rtk = String::new();
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track("kubectl get svc", "rtk kubectl svc", &raw, &raw);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let json: serde_json::Value = match serde_json::from_str(&raw) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
@@ -412,21 +381,6 @@ fn kubectl_logs(args: &[String], _verbose: u8) -> Result<()> {
|
||||
|
||||
let output = cmd.output().context("Failed to run kubectl logs")?;
|
||||
let raw = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track(
|
||||
&format!("kubectl logs {}", pod),
|
||||
"rtk kubectl logs",
|
||||
&raw,
|
||||
&raw,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let analyzed = crate::log_cmd::run_stdin_str(&raw);
|
||||
let rtk = format!("☸️ Logs for {}:\n{}", pod, analyzed);
|
||||
println!("{}", rtk);
|
||||
|
||||
+28
-111
@@ -1,4 +1,3 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::resolved_command;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -112,21 +111,6 @@ fn run_diff(
|
||||
let output = cmd.output().context("Failed to run git diff")?;
|
||||
let stat_stdout = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
let raw = stat_stdout.to_string();
|
||||
timer.track(
|
||||
&format!("git diff {}", args.join(" ")),
|
||||
&format!("rtk git diff {}", args.join(" ")),
|
||||
&raw,
|
||||
&raw,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
if verbose > 0 {
|
||||
eprintln!("Git diff summary:");
|
||||
}
|
||||
@@ -608,46 +592,33 @@ fn format_status_output(porcelain: &str) -> String {
|
||||
}
|
||||
|
||||
// Build summary
|
||||
let limits = config::limits();
|
||||
let max_files = limits.status_max_files;
|
||||
let max_untracked = limits.status_max_untracked;
|
||||
|
||||
if staged > 0 {
|
||||
output.push_str(&format!("✅ Staged: {} files\n", staged));
|
||||
for f in staged_files.iter().take(max_files) {
|
||||
for f in staged_files.iter().take(5) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if staged_files.len() > max_files {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
staged_files.len() - max_files
|
||||
));
|
||||
if staged_files.len() > 5 {
|
||||
output.push_str(&format!(" ... +{} more\n", staged_files.len() - 5));
|
||||
}
|
||||
}
|
||||
|
||||
if modified > 0 {
|
||||
output.push_str(&format!("📝 Modified: {} files\n", modified));
|
||||
for f in modified_files.iter().take(max_files) {
|
||||
for f in modified_files.iter().take(5) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if modified_files.len() > max_files {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
modified_files.len() - max_files
|
||||
));
|
||||
if modified_files.len() > 5 {
|
||||
output.push_str(&format!(" ... +{} more\n", modified_files.len() - 5));
|
||||
}
|
||||
}
|
||||
|
||||
if untracked > 0 {
|
||||
output.push_str(&format!("❓ Untracked: {} files\n", untracked));
|
||||
for f in untracked_files.iter().take(max_untracked) {
|
||||
for f in untracked_files.iter().take(3) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if untracked_files.len() > max_untracked {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
untracked_files.len() - max_untracked
|
||||
));
|
||||
if untracked_files.len() > 3 {
|
||||
output.push_str(&format!(" ... +{} more\n", untracked_files.len() - 3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,20 +680,6 @@ fn run_status(args: &[String], verbose: u8, global_args: &[String]) -> Result<()
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
if !output.status.success() {
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
let raw = stdout.to_string();
|
||||
timer.track(
|
||||
&format!("git status {}", args.join(" ")),
|
||||
&format!("rtk git status {}", args.join(" ")),
|
||||
&raw,
|
||||
&raw,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
if verbose > 0 || !stderr.is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
@@ -902,14 +859,13 @@ fn run_commit(args: &[String], verbose: u8, global_args: &[String]) -> Result<()
|
||||
"ok (nothing to commit)",
|
||||
);
|
||||
} else {
|
||||
eprintln!("FAILED: git commit");
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
eprintln!("{}", stderr);
|
||||
}
|
||||
if !stdout.trim().is_empty() {
|
||||
eprint!("{}", stdout);
|
||||
eprintln!("{}", stdout);
|
||||
}
|
||||
timer.track(&original_cmd, "rtk git commit", &raw_output, &raw_output);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,20 +1103,6 @@ fn run_branch(args: &[String], verbose: u8, global_args: &[String]) -> Result<()
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let raw = stdout.to_string();
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track(
|
||||
&format!("git branch {}", args.join(" ")),
|
||||
&format!("rtk git branch {}", args.join(" ")),
|
||||
&raw,
|
||||
&raw,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let filtered = filter_branch_output(&stdout);
|
||||
println!("{}", filtered);
|
||||
|
||||
@@ -1748,48 +1690,23 @@ A added.rs
|
||||
|
||||
#[test]
|
||||
fn test_format_status_output_truncation() {
|
||||
// Test that >15 staged files show "... +N more"
|
||||
let mut porcelain = String::from("## main\n");
|
||||
for i in 1..=20 {
|
||||
porcelain.push_str(&format!("M file{}.rs\n", i));
|
||||
}
|
||||
let result = format_status_output(&porcelain);
|
||||
assert!(result.contains("✅ Staged: 20 files"));
|
||||
// Test that >5 staged files show "... +N more"
|
||||
let porcelain = r#"## main
|
||||
M file1.rs
|
||||
M file2.rs
|
||||
M file3.rs
|
||||
M file4.rs
|
||||
M file5.rs
|
||||
M file6.rs
|
||||
M file7.rs
|
||||
"#;
|
||||
let result = format_status_output(porcelain);
|
||||
assert!(result.contains("✅ Staged: 7 files"));
|
||||
assert!(result.contains("file1.rs"));
|
||||
assert!(result.contains("file15.rs"));
|
||||
assert!(result.contains("... +5 more"));
|
||||
assert!(!result.contains("file16.rs"));
|
||||
assert!(!result.contains("file20.rs"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_status_modified_truncation() {
|
||||
// Test that >15 modified files show "... +N more"
|
||||
let mut porcelain = String::from("## main\n");
|
||||
for i in 1..=20 {
|
||||
porcelain.push_str(&format!(" M file{}.rs\n", i));
|
||||
}
|
||||
let result = format_status_output(&porcelain);
|
||||
assert!(result.contains("📝 Modified: 20 files"));
|
||||
assert!(result.contains("file1.rs"));
|
||||
assert!(result.contains("file15.rs"));
|
||||
assert!(result.contains("... +5 more"));
|
||||
assert!(!result.contains("file16.rs"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_status_untracked_truncation() {
|
||||
// Test that >10 untracked files show "... +N more"
|
||||
let mut porcelain = String::from("## main\n");
|
||||
for i in 1..=15 {
|
||||
porcelain.push_str(&format!("?? file{}.rs\n", i));
|
||||
}
|
||||
let result = format_status_output(&porcelain);
|
||||
assert!(result.contains("❓ Untracked: 15 files"));
|
||||
assert!(result.contains("file1.rs"));
|
||||
assert!(result.contains("file10.rs"));
|
||||
assert!(result.contains("... +5 more"));
|
||||
assert!(!result.contains("file11.rs"));
|
||||
assert!(result.contains("file5.rs"));
|
||||
assert!(result.contains("... +2 more"));
|
||||
assert!(!result.contains("file6.rs"));
|
||||
assert!(!result.contains("file7.rs"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::{resolved_command, truncate};
|
||||
use anyhow::{Context, Result};
|
||||
@@ -107,7 +106,7 @@ fn filter_golangci_json(output: &str) -> String {
|
||||
return format!(
|
||||
"golangci-lint (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
truncate(output, 500)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+15
-22
@@ -1,4 +1,3 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::resolved_command;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -78,13 +77,6 @@ pub fn run(
|
||||
let mut by_file: HashMap<String, Vec<(usize, String)>> = HashMap::new();
|
||||
let mut total = 0;
|
||||
|
||||
// Compile context regex once (instead of per-line in clean_line)
|
||||
let context_re = if context_only {
|
||||
Regex::new(&format!("(?i).{{0,20}}{}.*", regex::escape(pattern))).ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
for line in stdout.lines() {
|
||||
let parts: Vec<&str> = line.splitn(3, ':').collect();
|
||||
|
||||
@@ -99,7 +91,7 @@ pub fn run(
|
||||
};
|
||||
|
||||
total += 1;
|
||||
let cleaned = clean_line(content, max_line_len, context_re.as_ref(), pattern);
|
||||
let cleaned = clean_line(content, max_line_len, context_only, pattern);
|
||||
by_file.entry(file).or_default().push((line_num, cleaned));
|
||||
}
|
||||
|
||||
@@ -118,8 +110,7 @@ pub fn run(
|
||||
let file_display = compact_path(file);
|
||||
rtk_output.push_str(&format!("📄 {} ({}):\n", file_display, matches.len()));
|
||||
|
||||
let per_file = config::limits().grep_max_per_file;
|
||||
for (line_num, content) in matches.iter().take(per_file) {
|
||||
for (line_num, content) in matches.iter().take(10) {
|
||||
rtk_output.push_str(&format!(" {:>4}: {}\n", line_num, content));
|
||||
shown += 1;
|
||||
if shown >= max_results {
|
||||
@@ -127,8 +118,8 @@ pub fn run(
|
||||
}
|
||||
}
|
||||
|
||||
if matches.len() > per_file {
|
||||
rtk_output.push_str(&format!(" +{}\n", matches.len() - per_file));
|
||||
if matches.len() > 10 {
|
||||
rtk_output.push_str(&format!(" +{}\n", matches.len() - 10));
|
||||
}
|
||||
rtk_output.push('\n');
|
||||
}
|
||||
@@ -152,14 +143,16 @@ pub fn run(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clean_line(line: &str, max_len: usize, context_re: Option<&Regex>, pattern: &str) -> String {
|
||||
fn clean_line(line: &str, max_len: usize, context_only: bool, pattern: &str) -> String {
|
||||
let trimmed = line.trim();
|
||||
|
||||
if let Some(re) = context_re {
|
||||
if let Some(m) = re.find(trimmed) {
|
||||
let matched = m.as_str();
|
||||
if matched.len() <= max_len {
|
||||
return matched.to_string();
|
||||
if context_only {
|
||||
if let Ok(re) = Regex::new(&format!("(?i).{{0,20}}{}.*", regex::escape(pattern))) {
|
||||
if let Some(m) = re.find(trimmed) {
|
||||
let matched = m.as_str();
|
||||
if matched.len() <= max_len {
|
||||
return matched.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,7 +216,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clean_line() {
|
||||
let line = " const result = someFunction();";
|
||||
let cleaned = clean_line(line, 50, None, "result");
|
||||
let cleaned = clean_line(line, 50, false, "result");
|
||||
assert!(!cleaned.starts_with(' '));
|
||||
assert!(cleaned.len() <= 50);
|
||||
}
|
||||
@@ -247,7 +240,7 @@ mod tests {
|
||||
fn test_clean_line_multibyte() {
|
||||
// Thai text that exceeds max_len in bytes
|
||||
let line = " สวัสดีครับ นี่คือข้อความที่ยาวมากสำหรับทดสอบ ";
|
||||
let cleaned = clean_line(line, 20, None, "ครับ");
|
||||
let cleaned = clean_line(line, 20, false, "ครับ");
|
||||
// Should not panic
|
||||
assert!(!cleaned.is_empty());
|
||||
}
|
||||
@@ -255,7 +248,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clean_line_emoji() {
|
||||
let line = "🎉🎊🎈🎁🎂🎄 some text 🎃🎆🎇✨";
|
||||
let cleaned = clean_line(line, 15, None, "text");
|
||||
let cleaned = clean_line(line, 15, false, "text");
|
||||
assert!(!cleaned.is_empty());
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,4 +1,3 @@
|
||||
use crate::config;
|
||||
use crate::mypy_cmd;
|
||||
use crate::ruff_cmd;
|
||||
use crate::tracking;
|
||||
@@ -235,7 +234,7 @@ fn filter_eslint_json(output: &str) -> String {
|
||||
return format!(
|
||||
"ESLint output (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
truncate(output, 500)
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -327,7 +326,7 @@ fn filter_pylint_json(output: &str) -> String {
|
||||
return format!(
|
||||
"Pylint output (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
truncate(output, 500)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -306,7 +306,7 @@ enum Commands {
|
||||
#[arg(short = 'l', long, default_value = "80")]
|
||||
max_len: usize,
|
||||
/// Max results to show
|
||||
#[arg(short, long, default_value = "200")]
|
||||
#[arg(short, long, default_value = "50")]
|
||||
max: usize,
|
||||
/// Show only match context (not full line)
|
||||
#[arg(short, long)]
|
||||
|
||||
@@ -70,7 +70,7 @@ impl OutputParser for VitestParser {
|
||||
)
|
||||
} else {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_output(input, 2000))
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -89,18 +89,12 @@ pub trait OutputParser: Sized {
|
||||
let result = Self::parse(input);
|
||||
if result.tier() > max_tier {
|
||||
// Force degradation to passthrough if exceeds max tier
|
||||
return ParseResult::Passthrough(truncate_passthrough(input));
|
||||
return ParseResult::Passthrough(truncate_output(input, 500));
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// Truncate output using configured passthrough limit
|
||||
pub fn truncate_passthrough(output: &str) -> String {
|
||||
let max_chars = crate::config::limits().passthrough_max_chars;
|
||||
truncate_output(output, max_chars)
|
||||
}
|
||||
|
||||
/// Truncate output to max length with ellipsis
|
||||
pub fn truncate_output(output: &str, max_chars: usize) -> String {
|
||||
let chars: Vec<char> = output.chars().collect();
|
||||
|
||||
@@ -5,7 +5,7 @@ use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::parser::{
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_passthrough, FormatMode, OutputParser,
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_output, FormatMode, OutputParser,
|
||||
ParseResult, TestFailure, TestResult, TokenFormatter,
|
||||
};
|
||||
|
||||
@@ -110,7 +110,7 @@ impl OutputParser for PlaywrightParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -6,7 +6,7 @@ use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
|
||||
use crate::parser::{
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_passthrough, Dependency,
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_output, Dependency,
|
||||
DependencyState, FormatMode, OutputParser, ParseResult, TokenFormatter,
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ impl OutputParser for PnpmListParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ impl OutputParser for PnpmOutdatedParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,8 +307,7 @@ fn run_list(depth: usize, args: &[String], verbose: u8) -> Result<()> {
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
eprint!("{}", stderr);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
anyhow::bail!("pnpm list failed: {}", stderr);
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
@@ -432,8 +431,7 @@ fn run_install(packages: &[String], args: &[String], verbose: u8) -> Result<()>
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
if !output.status.success() {
|
||||
eprint!("{}", stderr);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
anyhow::bail!("pnpm install failed: {}", stderr);
|
||||
}
|
||||
|
||||
let combined = format!("{}{}", stdout, stderr);
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::{resolved_command, truncate};
|
||||
use anyhow::{Context, Result};
|
||||
@@ -122,7 +121,7 @@ pub fn filter_ruff_check_json(output: &str) -> String {
|
||||
return format!(
|
||||
"Ruff check (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
truncate(output, 500)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,12 +251,6 @@ impl Tracker {
|
||||
}
|
||||
|
||||
let conn = Connection::open(&db_path)?;
|
||||
// WAL mode + busy_timeout for concurrent access (multiple Claude Code instances).
|
||||
// Non-fatal: NFS/read-only filesystems may not support WAL.
|
||||
let _ = conn.execute_batch(
|
||||
"PRAGMA journal_mode=WAL;
|
||||
PRAGMA busy_timeout=5000;",
|
||||
);
|
||||
conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS commands (
|
||||
id INTEGER PRIMARY KEY,
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::parser::{
|
||||
emit_degradation_warning, emit_passthrough_warning, extract_json_object, truncate_passthrough,
|
||||
emit_degradation_warning, emit_passthrough_warning, extract_json_object, truncate_output,
|
||||
FormatMode, OutputParser, ParseResult, TestFailure, TestResult, TokenFormatter,
|
||||
};
|
||||
use crate::tracking;
|
||||
@@ -88,7 +88,7 @@ impl OutputParser for VitestParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-20
@@ -41,16 +41,10 @@ pub fn run(url: &str, args: &[String], verbose: u8) -> Result<()> {
|
||||
println!("{}", msg);
|
||||
timer.track(&format!("wget {}", url), "rtk wget", &raw_output, &msg);
|
||||
} else {
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track(
|
||||
&format!("wget {}", url),
|
||||
"rtk wget",
|
||||
&raw_output,
|
||||
&raw_output,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
let error = parse_error(&stderr, &stdout);
|
||||
let msg = format!("⬇️ {} FAILED: {}", compact_url(url), error);
|
||||
println!("{}", msg);
|
||||
timer.track(&format!("wget {}", url), "rtk wget", &raw_output, &msg);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -109,16 +103,10 @@ pub fn run_stdout(url: &str, args: &[String], verbose: u8) -> Result<()> {
|
||||
);
|
||||
} else {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
if !stderr.trim().is_empty() {
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
timer.track(
|
||||
&format!("wget -O - {}", url),
|
||||
"rtk wget -o",
|
||||
&stderr,
|
||||
&stderr,
|
||||
);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
let error = parse_error(&stderr, "");
|
||||
let msg = format!("⬇️ {} FAILED: {}", compact_url(url), error);
|
||||
println!("{}", msg);
|
||||
timer.track(&format!("wget -O - {}", url), "rtk wget -o", &stderr, &msg);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user