Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

Merge remote-tracking branch 'origin/rcc/sandbox' into integration/dori-cleanroom

YeonGyu-Kim1d4c8a8f507c
diff --cc rust/crates/commands/src/lib.rs
index 5aa63a30,59fbb692..5090d0e3
--- a/rust/crates/commands/src/lib.rs
+++ b/rust/crates/commands/src/lib.rs
@@@ -60,9 -51,14 +60,16 @@@ const SLASH_COMMAND_SPECS: &[SlashComma
argument_hint: None,
resume_supported: true,
},
+ SlashCommandSpec {
+ name: "sandbox",
++ aliases: &[],
+ summary: "Show sandbox isolation status",
+ argument_hint: None,
+ resume_supported: true,
+ },
SlashCommandSpec {
name: "compact",
+ aliases: &[],
summary: "Compact local session history",
argument_hint: None,
resume_supported: true,
@@@ -229,24 -141,8 +236,25 @@@
pub enum SlashCommand {
Help,
Status,
+ Sandbox,
Compact,
+ Bughunter {
+ scope: Option<String>,
+ },
+ Commit,
+ Pr {
+ context: Option<String>,
+ },
+ Issue {
+ context: Option<String>,
+ },
+ Ultraplan {
+ task: Option<String>,
+ },
+ Teleport {
+ target: Option<String>,
+ },
+ DebugToolCall,
Model {
model: Option<String>,
},
@@@ -300,24 -186,8 +308,25 @@@ impl SlashCommand
Some(match command {
"help" => Self::Help,
"status" => Self::Status,
+ "sandbox" => Self::Sandbox,
"compact" => Self::Compact,
+ "bughunter" => Self::Bughunter {
+ scope: remainder_after_command(trimmed, command),
+ },
+ "commit" => Self::Commit,
+ "pr" => Self::Pr {
+ context: remainder_after_command(trimmed, command),
+ },
+ "issue" => Self::Issue {
+ context: remainder_after_command(trimmed, command),
+ },
+ "ultraplan" => Self::Ultraplan {
+ task: remainder_after_command(trimmed, command),
+ },
+ "teleport" => Self::Teleport {
+ target: remainder_after_command(trimmed, command),
+ },
+ "debug-tool-call" => Self::DebugToolCall,
"model" => Self::Model {
model: parts.next().map(ToOwned::to_owned),
},
@@@ -1181,13 -287,7 +1190,14 @@@ pub fn handle_slash_command
session: session.clone(),
}),
SlashCommand::Status
+ | SlashCommand::Bughunter { .. }
+ | SlashCommand::Commit
+ | SlashCommand::Pr { .. }
+ | SlashCommand::Issue { .. }
+ | SlashCommand::Ultraplan { .. }
+ | SlashCommand::Teleport { .. }
+ | SlashCommand::DebugToolCall
+ | SlashCommand::Sandbox
| SlashCommand::Model { .. }
| SlashCommand::Permissions { .. }
| SlashCommand::Clear { .. }
@@@ -1287,41 -316,7 +1297,42 @@@ mod tests
fn parses_supported_slash_commands() {
assert_eq!(SlashCommand::parse("/help"), Some(SlashCommand::Help));
assert_eq!(SlashCommand::parse(" /status "), Some(SlashCommand::Status));
+ assert_eq!(SlashCommand::parse("/sandbox"), Some(SlashCommand::Sandbox));
+ assert_eq!(
+ SlashCommand::parse("/bughunter runtime"),
+ Some(SlashCommand::Bughunter {
+ scope: Some("runtime".to_string())
+ })
+ );
+ assert_eq!(SlashCommand::parse("/commit"), Some(SlashCommand::Commit));
+ assert_eq!(
+ SlashCommand::parse("/pr ready for review"),
+ Some(SlashCommand::Pr {
+ context: Some("ready for review".to_string())
+ })
+ );
+ assert_eq!(
+ SlashCommand::parse("/issue flaky test"),
+ Some(SlashCommand::Issue {
+ context: Some("flaky test".to_string())
+ })
+ );
+ assert_eq!(
+ SlashCommand::parse("/ultraplan ship both features"),
+ Some(SlashCommand::Ultraplan {
+ task: Some("ship both features".to_string())
+ })
+ );
+ assert_eq!(
+ SlashCommand::parse("/teleport conversation.rs"),
+ Some(SlashCommand::Teleport {
+ target: Some("conversation.rs".to_string())
+ })
+ );
+ assert_eq!(
+ SlashCommand::parse("/debug-tool-call"),
+ Some(SlashCommand::DebugToolCall)
+ );
assert_eq!(
SlashCommand::parse("/model claude-opus"),
Some(SlashCommand::Model {
@@@ -1416,14 -383,8 +1427,15 @@@
assert!(help.contains("works with --resume SESSION.json"));
assert!(help.contains("/help"));
assert!(help.contains("/status"));
+ assert!(help.contains("/sandbox"));
assert!(help.contains("/compact"));
+ assert!(help.contains("/bughunter [scope]"));
+ assert!(help.contains("/commit"));
+ assert!(help.contains("/pr [context]"));
+ assert!(help.contains("/issue [context]"));
+ assert!(help.contains("/ultraplan [task]"));
+ assert!(help.contains("/teleport <symbol-or-path>"));
+ assert!(help.contains("/debug-tool-call"));
assert!(help.contains("/model [model]"));
assert!(help.contains("/permissions [read-only|workspace-write|danger-full-access]"));
assert!(help.contains("/clear [--confirm]"));
@@@ -1436,14 -397,8 +1448,15 @@@
assert!(help.contains("/version"));
assert!(help.contains("/export [file]"));
assert!(help.contains("/session [list|switch <session-id>]"));
- assert_eq!(slash_command_specs().len(), 16);
- assert_eq!(resume_supported_slash_commands().len(), 12);
++ assert!(help.contains("/sandbox"));
+ assert!(help.contains(
+ "/plugin [list|install <path>|enable <name>|disable <name>|uninstall <id>|update <id>]"
+ ));
+ assert!(help.contains("aliases: /plugins, /marketplace"));
+ assert!(help.contains("/agents"));
+ assert!(help.contains("/skills"));
- assert_eq!(slash_command_specs().len(), 25);
- assert_eq!(resume_supported_slash_commands().len(), 13);
++ assert_eq!(slash_command_specs().len(), 27);
++ assert_eq!(resume_supported_slash_commands().len(), 14);
}
#[test]
@@@ -1490,22 -445,7 +1503,23 @@@
let session = Session::new();
assert!(handle_slash_command("/unknown", &session, CompactionConfig::default()).is_none());
assert!(handle_slash_command("/status", &session, CompactionConfig::default()).is_none());
+ assert!(handle_slash_command("/sandbox", &session, CompactionConfig::default()).is_none());
+ assert!(
+ handle_slash_command("/bughunter", &session, CompactionConfig::default()).is_none()
+ );
+ assert!(handle_slash_command("/commit", &session, CompactionConfig::default()).is_none());
+ assert!(handle_slash_command("/pr", &session, CompactionConfig::default()).is_none());
+ assert!(handle_slash_command("/issue", &session, CompactionConfig::default()).is_none());
+ assert!(
+ handle_slash_command("/ultraplan", &session, CompactionConfig::default()).is_none()
+ );
+ assert!(
+ handle_slash_command("/teleport foo", &session, CompactionConfig::default()).is_none()
+ );
+ assert!(
+ handle_slash_command("/debug-tool-call", &session, CompactionConfig::default())
+ .is_none()
+ );
assert!(
handle_slash_command("/model claude", &session, CompactionConfig::default()).is_none()
);
diff --cc rust/crates/rusty-claude-cli/src/main.rs
index 66ed9e74,eb5333b3..c588ebaa
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@@ -26,14 -20,12 +26,18 @@@ use commands::
render_slash_command_help, resume_supported_slash_commands, slash_command_specs, SlashCommand,
};
use compat_harness::{extract_manifest, UpstreamPaths};
-use render::{Spinner, TerminalRenderer};
+use init::initialize_repo;
+use plugins::{PluginManager, PluginManagerConfig};
+use render::{MarkdownStreamState, Spinner, TerminalRenderer};
use runtime::{
clear_oauth_credentials, generate_pkce_pair, generate_state, load_system_prompt,
- parse_oauth_callback_request_target, resolve_sandbox_status, save_oauth_credentials, ApiClient,
- ApiRequest, AssistantEvent, CompactionConfig, ConfigLoader, ConfigSource, ContentBlock,
- ConversationMessage, ConversationRuntime, MessageRole, OAuthAuthorizationRequest,
+ parse_oauth_callback_request_target, save_oauth_credentials, ApiClient, ApiRequest,
+ AssistantEvent, CompactionConfig, ConfigLoader, ConfigSource, ContentBlock,
+ ConversationMessage, ConversationRuntime, MessageRole, OAuthAuthorizationRequest, OAuthConfig,
++ parse_oauth_callback_request_target, resolve_sandbox_status, save_oauth_credentials,
++ ApiClient, ApiRequest, AssistantEvent, CompactionConfig, ConfigLoader, ConfigSource,
++ ContentBlock, ConversationMessage, ConversationRuntime, MessageRole,
++ OAuthAuthorizationRequest, OAuthConfig,
OAuthTokenExchangeRequest, PermissionMode, PermissionPolicy, ProjectContext, RuntimeError,
Session, TokenUsage, ToolError, ToolExecutor, UsageTracker,
};
@@@ -1209,34 -1104,10 +1226,38 @@@ impl LiveCli
self.print_status();
false
}
+ SlashCommand::Bughunter { scope } => {
+ self.run_bughunter(scope.as_deref())?;
+ false
+ }
+ SlashCommand::Commit => {
+ self.run_commit()?;
+ true
+ }
+ SlashCommand::Pr { context } => {
+ self.run_pr(context.as_deref())?;
+ false
+ }
+ SlashCommand::Issue { context } => {
+ self.run_issue(context.as_deref())?;
+ false
+ }
+ SlashCommand::Ultraplan { task } => {
+ self.run_ultraplan(task.as_deref())?;
+ false
+ }
+ SlashCommand::Teleport { target } => {
+ self.run_teleport(target.as_deref())?;
+ false
+ }
+ SlashCommand::DebugToolCall => {
+ self.run_debug_tool_call()?;
+ false
+ }
+ SlashCommand::Sandbox => {
+ Self::print_sandbox_status();
+ false
+ }
SlashCommand::Compact => {
self.compact()?;
false
@@@ -4279,8 -2701,8 +4359,8 @@@ mod tests
assert_eq!(
names,
vec![
- "help", "status", "compact", "clear", "cost", "config", "memory", "init", "diff",
- "version", "export", "agents", "skills",
+ "help", "status", "sandbox", "compact", "clear", "cost", "config", "memory",
- "init", "diff", "version", "export",
++ "init", "diff", "version", "export", "agents", "skills",
]
);
}
@@@ -4677,322 -2974,25 +4758,336 @@@
#[test]
fn tool_rendering_helpers_compact_output() {
let start = format_tool_call_start("read_file", r#"{"path":"src/main.rs"}"#);
- assert!(start.contains("Tool call"));
+ assert!(start.contains("read_file"));
assert!(start.contains("src/main.rs"));
- let done = format_tool_result("read_file", r#"{"contents":"hello"}"#, false);
- assert!(done.contains("Tool `read_file`"));
- assert!(done.contains("contents"));
+ let done = format_tool_result(
+ "read_file",
+ r#"{"file":{"filePath":"src/main.rs","content":"hello","numLines":1,"startLine":1,"totalLines":1}}"#,
+ false,
+ );
+ assert!(done.contains("📄 Read src/main.rs"));
+ assert!(done.contains("hello"));
+ }
+
+ #[test]
+ fn tool_rendering_truncates_large_read_output_for_display_only() {
+ let content = (0..200)
+ .map(|index| format!("line {index:03}"))
+ .collect::<Vec<_>>()
+ .join("\n");
+ let output = json!({
+ "file": {
+ "filePath": "src/main.rs",
+ "content": content,
+ "numLines": 200,
+ "startLine": 1,
+ "totalLines": 200
+ }
+ })
+ .to_string();
+
+ let rendered = format_tool_result("read_file", &output, false);
+
+ assert!(rendered.contains("line 000"));
+ assert!(rendered.contains("line 079"));
+ assert!(!rendered.contains("line 199"));
+ assert!(rendered.contains("full result preserved in session"));
+ assert!(output.contains("line 199"));
+ }
+
+ #[test]
+ fn tool_rendering_truncates_large_bash_output_for_display_only() {
+ let stdout = (0..120)
+ .map(|index| format!("stdout {index:03}"))
+ .collect::<Vec<_>>()
+ .join("\n");
+ let output = json!({
+ "stdout": stdout,
+ "stderr": "",
+ "returnCodeInterpretation": "completed successfully"
+ })
+ .to_string();
+
+ let rendered = format_tool_result("bash", &output, false);
+
+ assert!(rendered.contains("stdout 000"));
+ assert!(rendered.contains("stdout 059"));
+ assert!(!rendered.contains("stdout 119"));
+ assert!(rendered.contains("full result preserved in session"));
+ assert!(output.contains("stdout 119"));
+ }
+
+ #[test]
+ fn tool_rendering_truncates_generic_long_output_for_display_only() {
+ let items = (0..120)
+ .map(|index| format!("payload {index:03}"))
+ .collect::<Vec<_>>();
+ let output = json!({
+ "summary": "plugin payload",
+ "items": items,
+ })
+ .to_string();
+
+ let rendered = format_tool_result("plugin_echo", &output, false);
+
+ assert!(rendered.contains("plugin_echo"));
+ assert!(rendered.contains("payload 000"));
+ assert!(rendered.contains("payload 040"));
+ assert!(!rendered.contains("payload 080"));
+ assert!(!rendered.contains("payload 119"));
+ assert!(rendered.contains("full result preserved in session"));
+ assert!(output.contains("payload 119"));
+ }
+
+ #[test]
+ fn tool_rendering_truncates_raw_generic_output_for_display_only() {
+ let output = (0..120)
+ .map(|index| format!("raw {index:03}"))
+ .collect::<Vec<_>>()
+ .join("\n");
+
+ let rendered = format_tool_result("plugin_echo", &output, false);
+
+ assert!(rendered.contains("plugin_echo"));
+ assert!(rendered.contains("raw 000"));
+ assert!(rendered.contains("raw 059"));
+ assert!(!rendered.contains("raw 119"));
+ assert!(rendered.contains("full result preserved in session"));
+ assert!(output.contains("raw 119"));
+ }
+
+ #[test]
+ fn ultraplan_progress_lines_include_phase_step_and_elapsed_status() {
+ let snapshot = InternalPromptProgressState {
+ command_label: "Ultraplan",
+ task_label: "ship plugin progress".to_string(),
+ step: 3,
+ phase: "running read_file".to_string(),
+ detail: Some("reading rust/crates/rusty-claude-cli/src/main.rs".to_string()),
+ saw_final_text: false,
+ };
+
+ let started = format_internal_prompt_progress_line(
+ InternalPromptProgressEvent::Started,
+ &snapshot,
+ Duration::from_secs(0),
+ None,
+ );
+ let heartbeat = format_internal_prompt_progress_line(
+ InternalPromptProgressEvent::Heartbeat,
+ &snapshot,
+ Duration::from_secs(9),
+ None,
+ );
+ let completed = format_internal_prompt_progress_line(
+ InternalPromptProgressEvent::Complete,
+ &snapshot,
+ Duration::from_secs(12),
+ None,
+ );
+ let failed = format_internal_prompt_progress_line(
+ InternalPromptProgressEvent::Failed,
+ &snapshot,
+ Duration::from_secs(12),
+ Some("network timeout"),
+ );
+
+ assert!(started.contains("planning started"));
+ assert!(started.contains("current step 3"));
+ assert!(heartbeat.contains("heartbeat"));
+ assert!(heartbeat.contains("9s elapsed"));
+ assert!(heartbeat.contains("phase running read_file"));
+ assert!(completed.contains("completed"));
+ assert!(completed.contains("3 steps total"));
+ assert!(failed.contains("failed"));
+ assert!(failed.contains("network timeout"));
+ }
+
+ #[test]
+ fn describe_tool_progress_summarizes_known_tools() {
+ assert_eq!(
+ describe_tool_progress("read_file", r#"{"path":"src/main.rs"}"#),
+ "reading src/main.rs"
+ );
+ assert!(
+ describe_tool_progress("bash", r#"{"command":"cargo test -p rusty-claude-cli"}"#)
+ .contains("cargo test -p rusty-claude-cli")
+ );
+ assert_eq!(
+ describe_tool_progress("grep_search", r#"{"pattern":"ultraplan","path":"rust"}"#),
+ "grep `ultraplan` in rust"
+ );
+ }
+
+ #[test]
+ fn push_output_block_renders_markdown_text() {
+ let mut out = Vec::new();
+ let mut events = Vec::new();
+ let mut pending_tool = None;
+
+ push_output_block(
+ OutputContentBlock::Text {
+ text: "# Heading".to_string(),
+ },
+ &mut out,
+ &mut events,
+ &mut pending_tool,
+ false,
+ )
+ .expect("text block should render");
+
+ let rendered = String::from_utf8(out).expect("utf8");
+ assert!(rendered.contains("Heading"));
+ assert!(rendered.contains('\u{1b}'));
+ }
+
+ #[test]
+ fn push_output_block_skips_empty_object_prefix_for_tool_streams() {
+ let mut out = Vec::new();
+ let mut events = Vec::new();
+ let mut pending_tool = None;
+
+ push_output_block(
+ OutputContentBlock::ToolUse {
+ id: "tool-1".to_string(),
+ name: "read_file".to_string(),
+ input: json!({}),
+ },
+ &mut out,
+ &mut events,
+ &mut pending_tool,
+ true,
+ )
+ .expect("tool block should accumulate");
+
+ assert!(events.is_empty());
+ assert_eq!(
+ pending_tool,
+ Some(("tool-1".to_string(), "read_file".to_string(), String::new(),))
+ );
+ }
+
+ #[test]
+ fn response_to_events_preserves_empty_object_json_input_outside_streaming() {
+ let mut out = Vec::new();
+ let events = response_to_events(
+ MessageResponse {
+ id: "msg-1".to_string(),
+ kind: "message".to_string(),
+ model: "claude-opus-4-6".to_string(),
+ role: "assistant".to_string(),
+ content: vec![OutputContentBlock::ToolUse {
+ id: "tool-1".to_string(),
+ name: "read_file".to_string(),
+ input: json!({}),
+ }],
+ stop_reason: Some("tool_use".to_string()),
+ stop_sequence: None,
+ usage: Usage {
+ input_tokens: 1,
+ output_tokens: 1,
+ cache_creation_input_tokens: 0,
+ cache_read_input_tokens: 0,
+ },
+ request_id: None,
+ },
+ &mut out,
+ )
+ .expect("response conversion should succeed");
+
+ assert!(matches!(
+ &events[0],
+ AssistantEvent::ToolUse { name, input, .. }
+ if name == "read_file" && input == "{}"
+ ));
+ }
+
+ #[test]
+ fn response_to_events_preserves_non_empty_json_input_outside_streaming() {
+ let mut out = Vec::new();
+ let events = response_to_events(
+ MessageResponse {
+ id: "msg-2".to_string(),
+ kind: "message".to_string(),
+ model: "claude-opus-4-6".to_string(),
+ role: "assistant".to_string(),
+ content: vec![OutputContentBlock::ToolUse {
+ id: "tool-2".to_string(),
+ name: "read_file".to_string(),
+ input: json!({ "path": "rust/Cargo.toml" }),
+ }],
+ stop_reason: Some("tool_use".to_string()),
+ stop_sequence: None,
+ usage: Usage {
+ input_tokens: 1,
+ output_tokens: 1,
+ cache_creation_input_tokens: 0,
+ cache_read_input_tokens: 0,
+ },
+ request_id: None,
+ },
+ &mut out,
+ )
+ .expect("response conversion should succeed");
+
+ assert!(matches!(
+ &events[0],
+ AssistantEvent::ToolUse { name, input, .. }
+ if name == "read_file" && input == "{\"path\":\"rust/Cargo.toml\"}"
+ ));
+ }
+
+ #[test]
+ fn response_to_events_ignores_thinking_blocks() {
+ let mut out = Vec::new();
+ let events = response_to_events(
+ MessageResponse {
+ id: "msg-3".to_string(),
+ kind: "message".to_string(),
+ model: "claude-opus-4-6".to_string(),
+ role: "assistant".to_string(),
+ content: vec![
+ OutputContentBlock::Thinking {
+ thinking: "step 1".to_string(),
+ signature: Some("sig_123".to_string()),
+ },
+ OutputContentBlock::Text {
+ text: "Final answer".to_string(),
+ },
+ ],
+ stop_reason: Some("end_turn".to_string()),
+ stop_sequence: None,
+ usage: Usage {
+ input_tokens: 1,
+ output_tokens: 1,
+ cache_creation_input_tokens: 0,
+ cache_read_input_tokens: 0,
+ },
+ request_id: None,
+ },
+ &mut out,
+ )
+ .expect("response conversion should succeed");
+
+ assert!(matches!(
+ &events[0],
+ AssistantEvent::TextDelta(text) if text == "Final answer"
+ ));
+ assert!(!String::from_utf8(out).expect("utf8").contains("step 1"));
}
}
+
+ #[cfg(test)]
+ mod sandbox_report_tests {
+ use super::format_sandbox_report;
+
+ #[test]
+ fn sandbox_report_renders_expected_fields() {
+ let report = format_sandbox_report(&runtime::SandboxStatus::default());
+ assert!(report.contains("Sandbox"));
+ assert!(report.contains("Enabled"));
+ assert!(report.contains("Filesystem mode"));
+ assert!(report.contains("Fallback reason"));
+ }
+ }