4 Commits

20 changed files with 96 additions and 34 deletions

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"say hi in 3 words","type":"text"}],"role":"user"},{"blocks":[{"text":"Hey there, friend!","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":1954,"output_tokens":8}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"Explain what Rust is in exactly 3 sentences.","type":"text"}],"role":"user"},{"blocks":[{"text":"Rust is a systems programming language focused on safety, speed, and concurrency, designed to provide memory safety without relying on a garbage collector. It achieves this through its ownership system, which enforces strict rules about how memory is accessed and shared at compile time, eliminating entire classes of bugs like data races and dangling pointers. Rust has gained widespread adoption for building performance-critical software such as operating systems, game engines, web browsers, and command-line tools.","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":2383,"output_tokens":102}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"Say hello","type":"text"}],"role":"user"},{"blocks":[{"text":"Hello! 👋 How can I help you today?","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":2958,"output_tokens":16}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"Read the file Cargo.toml and tell me the package name","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\n<tool_use>\nfind_file\n{\"pattern\": \"Cargo.toml\", \"path\": \"/home/bellman/Workspace/clawd-code\"}\n</tool_use>\n\nLet me find the relevant Cargo.toml file(s) in the project.\n\n<tool_use>\nbash\n{\"command\": \"find /home/bellman/Workspace/clawd-code -name 'Cargo.toml' -maxdepth 4 | head -20\"}\n</tool_use>\n\n<tool_use>\nread_file\n{\"file_path\": \"/home/bellman/Workspace/clawd-code/rust/Cargo.toml\"}\n</tool_use>\n\n<tool_use>\nread_file\n{\"file_path\": \"/home/bellman/Workspace/clawd-code/rust/crates/rusty-claude-cli/Cargo.toml\"}\n</tool_use>\n\nHere are the Cargo.toml files found:\n\n1. **Workspace root** (`rust/Cargo.toml`) — This is a virtual workspace manifest (no `[package]` section). It lists members:\n - `crates/rusty-claude-cli`\n - `crates/rusty-claude-core`\n\n2. **CLI crate** (`rust/crates/rusty-claude-cli/Cargo.toml`) — The package name is:\n\n > **`rusty-claude-cli`** (version `0.1.0`)","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":3074,"output_tokens":352}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"hello","type":"text"}],"role":"user"},{"blocks":[{"text":"Hello! I'm Claude, an AI assistant built on Anthropic's Claude Agent SDK. I'm here to help you with software engineering tasks in your","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":141,"output_tokens":32}},{"blocks":[{"text":"who are you?","type":"text"}],"role":"user"},{"blocks":[{"text":"I'm Claude, an AI assistant built on Anthropic's Claude Agent SDK. I'm designed to help you with software engineering tasks, and I'm currently","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":182,"output_tokens":32}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"build","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\nI'll build the Rust project.\n\n<tool_use>\n<server_name>shell</server_name>\n<tool_name","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":1963,"output_tokens":32}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"hello","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\nHello! 👋 How can I help you today? I see you're working in a Rust project (`rusty-claude-cli`) with some changes to the argument parsing in `main.rs` — specifically loading the model from config with a fallback to a default. \n\nWhat would you like to work on?","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":324,"output_tokens":73}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[{"blocks":[{"text":"--dangerously-skip-permissions","type":"text"}],"role":"user"},{"blocks":[{"text":"\n\nI see you're working in the `rusty-claude-cli` project. The git diff shows a simplification of the `max_tokens_for_model` function - collapsing sonnet/haiku/default cases into a single `else` branch returning 64,000.\n\nHow can I help you today? What would you like to work on?","type":"text"}],"role":"assistant","usage":{"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"input_tokens":2126,"output_tokens":81}}],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -0,0 +1 @@
{"messages":[],"version":1}

View File

@@ -311,9 +311,6 @@ impl AnthropicClient {
request: &MessageRequest,
) -> Result<reqwest::Response, ApiError> {
let request_url = format!("{}/v1/messages", self.base_url.trim_end_matches('/'));
let resolved_base_url = self.base_url.trim_end_matches('/');
eprintln!("[anthropic-client] resolved_base_url={resolved_base_url}");
eprintln!("[anthropic-client] request_url={request_url}");
let request_builder = self
.http
.post(&request_url)
@@ -321,16 +318,6 @@ impl AnthropicClient {
.header("content-type", "application/json");
let mut request_builder = self.auth.apply(request_builder);
eprintln!(
"[anthropic-client] headers x-api-key={} authorization={} anthropic-version={ANTHROPIC_VERSION} content-type=application/json",
if self.auth.api_key().is_some() {
"[REDACTED]"
} else {
"<absent>"
},
self.auth.masked_authorization_header()
);
request_builder = request_builder.json(request);
request_builder.send().await.map_err(ApiError::from)
}

View File

@@ -35,7 +35,13 @@ use serde_json::json;
use tools::{execute_tool, mvp_tool_specs, ToolSpec};
const DEFAULT_MODEL: &str = "claude-opus-4-6";
const DEFAULT_MAX_TOKENS: u32 = 32;
fn max_tokens_for_model(model: &str) -> u32 {
if model.contains("opus") {
32_000
} else {
64_000
}
}
const DEFAULT_DATE: &str = "2026-03-31";
const DEFAULT_OAUTH_CALLBACK_PORT: u16 = 4545;
const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -186,6 +192,10 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
permission_mode = parse_permission_mode_arg(&flag[18..])?;
index += 1;
}
"--dangerously-skip-permissions" => {
permission_mode = PermissionMode::DangerFullAccess;
index += 1;
}
"--allowedTools" | "--allowed-tools" => {
let value = args
.get(index + 1)
@@ -263,7 +273,7 @@ fn resolve_model_alias(model: &str) -> &str {
match model {
"opus" => "claude-opus-4-6",
"sonnet" => "claude-sonnet-4-6",
"haiku" => "claude-haiku-3-5-20241022",
"haiku" => "claude-haiku-4-5-20251213",
_ => model,
}
}
@@ -1046,7 +1056,7 @@ impl LiveCli {
.with_base_url(api::read_base_url());
let request = MessageRequest {
model: self.model.clone(),
max_tokens: DEFAULT_MAX_TOKENS,
max_tokens: max_tokens_for_model(&self.model),
messages: vec![InputMessage {
role: "user".to_string(),
content: vec![InputContentBlock::Text {
@@ -1970,7 +1980,7 @@ impl ApiClient for AnthropicRuntimeClient {
fn stream(&mut self, request: ApiRequest) -> Result<Vec<AssistantEvent>, RuntimeError> {
let message_request = MessageRequest {
model: self.model.clone(),
max_tokens: DEFAULT_MAX_TOKENS,
max_tokens: max_tokens_for_model(&self.model),
messages: convert_messages(&request.messages),
system: (!request.system_prompt.is_empty()).then(|| request.system_prompt.join("\n\n")),
tools: self.enable_tools.then(|| {
@@ -2089,28 +2099,74 @@ fn slash_command_completion_candidates() -> Vec<String> {
}
fn format_tool_call_start(name: &str, input: &str) -> String {
let parsed: serde_json::Value =
serde_json::from_str(input).unwrap_or(serde_json::Value::String(input.to_string()));
let detail = match name {
"bash" | "Bash" => parsed
.get("command")
.and_then(|v| v.as_str())
.map(|cmd| truncate_for_summary(cmd, 120))
.unwrap_or_default(),
"read_file" | "Read" => parsed
.get("file_path")
.or_else(|| parsed.get("path"))
.and_then(|v| v.as_str())
.unwrap_or("?")
.to_string(),
"write_file" | "Write" => {
let path = parsed
.get("file_path")
.or_else(|| parsed.get("path"))
.and_then(|v| v.as_str())
.unwrap_or("?");
let lines = parsed
.get("content")
.and_then(|v| v.as_str())
.map(|c| c.lines().count())
.unwrap_or(0);
format!("{path} ({lines} lines)")
}
"edit_file" | "Edit" => {
let path = parsed
.get("file_path")
.or_else(|| parsed.get("path"))
.and_then(|v| v.as_str())
.unwrap_or("?");
path.to_string()
}
"glob_search" | "Glob" => parsed
.get("pattern")
.and_then(|v| v.as_str())
.unwrap_or("?")
.to_string(),
"grep_search" | "Grep" => parsed
.get("pattern")
.and_then(|v| v.as_str())
.unwrap_or("?")
.to_string(),
"web_search" | "WebSearch" => parsed
.get("query")
.and_then(|v| v.as_str())
.unwrap_or("?")
.to_string(),
_ => summarize_tool_payload(input),
};
let border = "".repeat(name.len() + 6);
format!(
"Tool call
Name {name}
Input {}",
summarize_tool_payload(input)
"\x1b[38;5;245m╭─ \x1b[1;36m{name}\x1b[0;38;5;245m ─╮\x1b[0m\n\x1b[38;5;245m│\x1b[0m {detail}\n\x1b[38;5;245m╰{border}\x1b[0m"
)
}
fn format_tool_result(name: &str, output: &str, is_error: bool) -> String {
let status = if is_error { "error" } else { "ok" };
format!(
"### Tool `{name}`
- Status: {status}
- Output:
```json
{}
```
",
prettify_tool_payload(output)
)
let icon = if is_error {
"\x1b[1;31m✗\x1b[0m"
} else {
"\x1b[1;32m✓\x1b[0m"
};
let summary = truncate_for_summary(output.trim(), 200);
format!("{icon} \x1b[38;5;245m{name}:\x1b[0m {summary}")
}
fn summarize_tool_payload(payload: &str) -> String {
@@ -2338,6 +2394,7 @@ fn print_help_to(out: &mut impl Write) -> io::Result<()> {
out,
" --permission-mode MODE Set read-only, workspace-write, or danger-full-access"
)?;
writeln!(out, " --dangerously-skip-permissions Skip all permission checks")?;
writeln!(out, " --allowedTools TOOLS Restrict enabled tools (repeatable; comma-separated aliases supported)")?;
writeln!(
out,