Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0662776a8 | ||
|
|
0414020d57 | ||
|
|
5b57c4204a |
No files matched your search
@@ -16,6 +16,8 @@ pub struct Config {
|
||||
pub telemetry: TelemetryConfig,
|
||||
#[serde(default)]
|
||||
pub hooks: HooksConfig,
|
||||
#[serde(default)]
|
||||
pub limits: LimitsConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
@@ -94,6 +96,39 @@ 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,6 +183,19 @@ 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);
|
||||
@@ -208,6 +221,15 @@ 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(_) => {
|
||||
@@ -306,6 +328,15 @@ 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(_) => {
|
||||
@@ -381,6 +412,21 @@ 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);
|
||||
|
||||
+111
-28
@@ -1,3 +1,4 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::resolved_command;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -111,6 +112,21 @@ 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:");
|
||||
}
|
||||
@@ -592,33 +608,46 @@ 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(5) {
|
||||
for f in staged_files.iter().take(max_files) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if staged_files.len() > 5 {
|
||||
output.push_str(&format!(" ... +{} more\n", staged_files.len() - 5));
|
||||
if staged_files.len() > max_files {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
staged_files.len() - max_files
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if modified > 0 {
|
||||
output.push_str(&format!("📝 Modified: {} files\n", modified));
|
||||
for f in modified_files.iter().take(5) {
|
||||
for f in modified_files.iter().take(max_files) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if modified_files.len() > 5 {
|
||||
output.push_str(&format!(" ... +{} more\n", modified_files.len() - 5));
|
||||
if modified_files.len() > max_files {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
modified_files.len() - max_files
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if untracked > 0 {
|
||||
output.push_str(&format!("❓ Untracked: {} files\n", untracked));
|
||||
for f in untracked_files.iter().take(3) {
|
||||
for f in untracked_files.iter().take(max_untracked) {
|
||||
output.push_str(&format!(" {}\n", f));
|
||||
}
|
||||
if untracked_files.len() > 3 {
|
||||
output.push_str(&format!(" ... +{} more\n", untracked_files.len() - 3));
|
||||
if untracked_files.len() > max_untracked {
|
||||
output.push_str(&format!(
|
||||
" ... +{} more\n",
|
||||
untracked_files.len() - max_untracked
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,6 +709,20 @@ 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);
|
||||
}
|
||||
@@ -859,13 +902,14 @@ 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() {
|
||||
eprintln!("{}", stderr);
|
||||
eprint!("{}", stderr);
|
||||
}
|
||||
if !stdout.trim().is_empty() {
|
||||
eprintln!("{}", stdout);
|
||||
eprint!("{}", stdout);
|
||||
}
|
||||
timer.track(&original_cmd, "rtk git commit", &raw_output, &raw_output);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,6 +1147,20 @@ 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);
|
||||
|
||||
@@ -1690,23 +1748,48 @@ A added.rs
|
||||
|
||||
#[test]
|
||||
fn test_format_status_output_truncation() {
|
||||
// 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"));
|
||||
// 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"));
|
||||
assert!(result.contains("file1.rs"));
|
||||
assert!(result.contains("file5.rs"));
|
||||
assert!(result.contains("... +2 more"));
|
||||
assert!(!result.contains("file6.rs"));
|
||||
assert!(!result.contains("file7.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"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::{resolved_command, truncate};
|
||||
use anyhow::{Context, Result};
|
||||
@@ -106,7 +107,7 @@ fn filter_golangci_json(output: &str) -> String {
|
||||
return format!(
|
||||
"golangci-lint (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, 500)
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+22
-15
@@ -1,3 +1,4 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::resolved_command;
|
||||
use anyhow::{Context, Result};
|
||||
@@ -77,6 +78,13 @@ 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();
|
||||
|
||||
@@ -91,7 +99,7 @@ pub fn run(
|
||||
};
|
||||
|
||||
total += 1;
|
||||
let cleaned = clean_line(content, max_line_len, context_only, pattern);
|
||||
let cleaned = clean_line(content, max_line_len, context_re.as_ref(), pattern);
|
||||
by_file.entry(file).or_default().push((line_num, cleaned));
|
||||
}
|
||||
|
||||
@@ -110,7 +118,8 @@ pub fn run(
|
||||
let file_display = compact_path(file);
|
||||
rtk_output.push_str(&format!("📄 {} ({}):\n", file_display, matches.len()));
|
||||
|
||||
for (line_num, content) in matches.iter().take(10) {
|
||||
let per_file = config::limits().grep_max_per_file;
|
||||
for (line_num, content) in matches.iter().take(per_file) {
|
||||
rtk_output.push_str(&format!(" {:>4}: {}\n", line_num, content));
|
||||
shown += 1;
|
||||
if shown >= max_results {
|
||||
@@ -118,8 +127,8 @@ pub fn run(
|
||||
}
|
||||
}
|
||||
|
||||
if matches.len() > 10 {
|
||||
rtk_output.push_str(&format!(" +{}\n", matches.len() - 10));
|
||||
if matches.len() > per_file {
|
||||
rtk_output.push_str(&format!(" +{}\n", matches.len() - per_file));
|
||||
}
|
||||
rtk_output.push('\n');
|
||||
}
|
||||
@@ -143,16 +152,14 @@ pub fn run(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clean_line(line: &str, max_len: usize, context_only: bool, pattern: &str) -> String {
|
||||
fn clean_line(line: &str, max_len: usize, context_re: Option<&Regex>, pattern: &str) -> String {
|
||||
let trimmed = line.trim();
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,7 +223,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clean_line() {
|
||||
let line = " const result = someFunction();";
|
||||
let cleaned = clean_line(line, 50, false, "result");
|
||||
let cleaned = clean_line(line, 50, None, "result");
|
||||
assert!(!cleaned.starts_with(' '));
|
||||
assert!(cleaned.len() <= 50);
|
||||
}
|
||||
@@ -240,7 +247,7 @@ mod tests {
|
||||
fn test_clean_line_multibyte() {
|
||||
// Thai text that exceeds max_len in bytes
|
||||
let line = " สวัสดีครับ นี่คือข้อความที่ยาวมากสำหรับทดสอบ ";
|
||||
let cleaned = clean_line(line, 20, false, "ครับ");
|
||||
let cleaned = clean_line(line, 20, None, "ครับ");
|
||||
// Should not panic
|
||||
assert!(!cleaned.is_empty());
|
||||
}
|
||||
@@ -248,7 +255,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_clean_line_emoji() {
|
||||
let line = "🎉🎊🎈🎁🎂🎄 some text 🎃🎆🎇✨";
|
||||
let cleaned = clean_line(line, 15, false, "text");
|
||||
let cleaned = clean_line(line, 15, None, "text");
|
||||
assert!(!cleaned.is_empty());
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
use crate::config;
|
||||
use crate::mypy_cmd;
|
||||
use crate::ruff_cmd;
|
||||
use crate::tracking;
|
||||
@@ -234,7 +235,7 @@ fn filter_eslint_json(output: &str) -> String {
|
||||
return format!(
|
||||
"ESLint output (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, 500)
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -326,7 +327,7 @@ fn filter_pylint_json(output: &str) -> String {
|
||||
return format!(
|
||||
"Pylint output (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, 500)
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+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 = "50")]
|
||||
#[arg(short, long, default_value = "200")]
|
||||
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, 500))
|
||||
ParseResult::Passthrough(truncate_output(input, 2000))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -89,12 +89,18 @@ 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_output(input, 500));
|
||||
return ParseResult::Passthrough(truncate_passthrough(input));
|
||||
}
|
||||
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_output, FormatMode, OutputParser,
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_passthrough, FormatMode, OutputParser,
|
||||
ParseResult, TestFailure, TestResult, TokenFormatter,
|
||||
};
|
||||
|
||||
@@ -110,7 +110,7 @@ impl OutputParser for PlaywrightParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-5
@@ -6,7 +6,7 @@ use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
|
||||
use crate::parser::{
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_output, Dependency,
|
||||
emit_degradation_warning, emit_passthrough_warning, truncate_passthrough, Dependency,
|
||||
DependencyState, FormatMode, OutputParser, ParseResult, TokenFormatter,
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ impl OutputParser for PnpmListParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ impl OutputParser for PnpmOutdatedParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,8 @@ fn run_list(depth: usize, args: &[String], verbose: u8) -> Result<()> {
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
anyhow::bail!("pnpm list failed: {}", stderr);
|
||||
eprint!("{}", stderr);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
@@ -431,7 +432,8 @@ fn run_install(packages: &[String], args: &[String], verbose: u8) -> Result<()>
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
if !output.status.success() {
|
||||
anyhow::bail!("pnpm install failed: {}", stderr);
|
||||
eprint!("{}", stderr);
|
||||
std::process::exit(output.status.code().unwrap_or(1));
|
||||
}
|
||||
|
||||
let combined = format!("{}{}", stdout, stderr);
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
use crate::config;
|
||||
use crate::tracking;
|
||||
use crate::utils::{resolved_command, truncate};
|
||||
use anyhow::{Context, Result};
|
||||
@@ -121,7 +122,7 @@ pub fn filter_ruff_check_json(output: &str) -> String {
|
||||
return format!(
|
||||
"Ruff check (JSON parse failed: {})\n{}",
|
||||
e,
|
||||
truncate(output, 500)
|
||||
truncate(output, config::limits().passthrough_max_chars)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,6 +251,12 @@ 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_output,
|
||||
emit_degradation_warning, emit_passthrough_warning, extract_json_object, truncate_passthrough,
|
||||
FormatMode, OutputParser, ParseResult, TestFailure, TestResult, TokenFormatter,
|
||||
};
|
||||
use crate::tracking;
|
||||
@@ -88,7 +88,7 @@ impl OutputParser for VitestParser {
|
||||
}
|
||||
None => {
|
||||
// Tier 3: Passthrough
|
||||
ParseResult::Passthrough(truncate_output(input, 500))
|
||||
ParseResult::Passthrough(truncate_passthrough(input))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-8
@@ -41,10 +41,16 @@ pub fn run(url: &str, args: &[String], verbose: u8) -> Result<()> {
|
||||
println!("{}", msg);
|
||||
timer.track(&format!("wget {}", url), "rtk wget", &raw_output, &msg);
|
||||
} else {
|
||||
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);
|
||||
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));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -103,10 +109,16 @@ pub fn run_stdout(url: &str, args: &[String], verbose: u8) -> Result<()> {
|
||||
);
|
||||
} else {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
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);
|
||||
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));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user