Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions crates/tui/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,47 @@ pub fn theme(app: &mut App, arg: Option<&str>) -> CommandResult {
}
}

/// `/slop [query|export]` — inspect or export the slop ledger (#2127).
/// With no arguments, prints a summary. `query` shows filtered results;
/// `export` outputs the full ledger as Markdown.
pub fn slop(_app: &mut App, arg: Option<&str>) -> CommandResult {
let arg = arg.map(str::trim).unwrap_or("");
let ledger = match crate::slop_ledger::SlopLedger::load() {
Ok(l) => l,
Err(e) => return CommandResult::error(format!("Failed to load slop ledger: {e}")),
};

match arg {
"" => CommandResult::message(ledger.summary()),
"query" | "q" => {
if ledger.is_empty() {
return CommandResult::message("Slop ledger is empty.");
}
let mut out = String::new();
for entry in &ledger.query(&Default::default()) {
use std::fmt::Write;
let _ = writeln!(
out,
"[{}] {} ({:?} | {:?}) — {}",
&entry.id[..8],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Slicing &entry.id[..8] directly can panic if the ID is shorter than 8 bytes or sliced on an invalid UTF-8 boundary. Use .get(..8) to safely slice the ID.

                    entry.id.get(..8).unwrap_or(&entry.id),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show id

Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
entry.bucket.as_str(),
entry.severity,
entry.status,
entry.title
);
}
CommandResult::message(out)
}
"export" | "e" => {
let md = ledger.export_markdown(None, None);
CommandResult::message(md)
}
_ => CommandResult::error(format!(
"Unknown /slop action '{arg}'. Use /slop, /slop query, or /slop export."
)),
}
}

/// Manage workspace-level trust and the per-path allowlist.
///
/// Subcommands:
Expand Down
10 changes: 10 additions & 0 deletions crates/tui/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ pub const COMMANDS: &[CommandInfo] = &[
usage: "/cache [count|inspect|warmup]",
description_id: MessageId::CmdCacheDescription,
},
// Slop Ledger (#2127)
CommandInfo {
name: "slop",
aliases: &["canzha"],
usage: "/slop [query|export]",
description_id: MessageId::CmdHelpDescription,
},
];

/// Execute a slash command
Expand Down Expand Up @@ -614,6 +621,9 @@ pub fn execute(cmd: &str, app: &mut App) -> CommandResult {
"balance" => balance::balance(app),
"cache" => debug::cache(app, arg),

// Slop ledger (#2127)
"slop" | "canzha" => config::slop(app, arg),

// ChangeLog command
"change" => change::change(app, arg),
"system" | "xitong" => debug::system_prompt(app),
Expand Down
8 changes: 8 additions & 0 deletions crates/tui/src/core/engine/tool_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ impl Engine {
.with_parallel_tool()
.with_recall_archive_tool();

// SlopLedger: plan mode only gets read-only query + export,
// agent/yolo get the full set including append + update.
builder = if mode == AppMode::Plan {
builder.with_slop_ledger_read_only_tools()
} else {
builder.with_slop_ledger_tools()
};

if mode != AppMode::Plan {
builder = builder
.with_rlm_tool(self.deepseek_client.clone(), self.session.model.clone())
Expand Down
1 change: 1 addition & 0 deletions crates/tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ mod snapshot;
mod task_manager;
#[cfg(test)]
mod test_support;
mod slop_ledger;
mod theme_qa_audit;
mod tools;
mod tui;
Expand Down
Loading
Loading