mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-05 23:54:50 +08:00
Make claw's REPL feel self-explanatory from analysis through commit
Claw already had the core slash-command and git primitives, but the UX still made users work to discover them, understand current workspace state, and trust what `/commit` was about to do. This change tightens that flow in the same places Codex-style CLIs do: command discovery, live status, typo recovery, and commit preflight/output. The REPL banner and `/help` now surface a clearer starter path, unknown slash commands suggest likely matches, `/status` includes actionable git state, and `/commit` explains what it is staging and committing before and after the model writes the Lore message. I also cleared the workspace's existing clippy blockers so the verification lane can stay fully green. Constraint: Improve UX inside the existing Rust CLI surfaces without adding new dependencies Rejected: Add more slash commands first | discoverability and feedback were the bigger friction points Rejected: Split verification lint fixes into a second commit | user requested one solid commit Confidence: high Scope-risk: moderate Directive: Keep slash discoverability, status reporting, and commit reporting aligned so `/help`, `/status`, and `/commit` tell the same workflow story Tested: cargo fmt --all; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace Not-tested: Manual interactive REPL session against live Anthropic/xAI endpoints
This commit is contained in:
@@ -19,6 +19,7 @@ async fn stream_via_provider<P: Provider>(
|
||||
provider.stream_message(request).await
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ProviderClient {
|
||||
Anthropic(AnthropicClient),
|
||||
|
||||
@@ -296,6 +296,7 @@ impl OpenAiSseParser {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Debug)]
|
||||
struct StreamState {
|
||||
model: String,
|
||||
@@ -497,6 +498,7 @@ impl ToolCallState {
|
||||
self.openai_index + 1
|
||||
}
|
||||
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
fn start_event(&self) -> Result<Option<ContentBlockStartEvent>, ApiError> {
|
||||
let Some(name) = self.name.clone() else {
|
||||
return Ok(None);
|
||||
|
||||
@@ -195,6 +195,7 @@ async fn stream_message_normalizes_text_and_multiple_tool_calls() {
|
||||
assert!(request.body.contains("\"stream\":true"));
|
||||
}
|
||||
|
||||
#[allow(clippy::await_holding_lock)]
|
||||
#[tokio::test]
|
||||
async fn provider_client_dispatches_xai_requests_from_env() {
|
||||
let _lock = env_lock();
|
||||
@@ -389,7 +390,7 @@ fn env_lock() -> std::sync::MutexGuard<'static, ()> {
|
||||
static LOCK: OnceLock<StdMutex<()>> = OnceLock::new();
|
||||
LOCK.get_or_init(|| StdMutex::new(()))
|
||||
.lock()
|
||||
.unwrap_or_else(|poisoned| poisoned.into_inner())
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
struct ScopedEnvVar {
|
||||
|
||||
@@ -57,7 +57,7 @@ fn env_lock() -> std::sync::MutexGuard<'static, ()> {
|
||||
static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
|
||||
LOCK.get_or_init(|| Mutex::new(()))
|
||||
.lock()
|
||||
.unwrap_or_else(|poisoned| poisoned.into_inner())
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
}
|
||||
|
||||
struct EnvVarGuard {
|
||||
|
||||
@@ -394,40 +394,153 @@ pub fn resume_supported_slash_commands() -> Vec<&'static SlashCommandSpec> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn slash_command_category(name: &str) -> &'static str {
|
||||
match name {
|
||||
"help" | "status" | "sandbox" | "model" | "permissions" | "cost" | "resume" | "session"
|
||||
| "version" => "Session & visibility",
|
||||
"compact" | "clear" | "config" | "memory" | "init" | "diff" | "commit" | "pr" | "issue"
|
||||
| "export" | "plugin" => "Workspace & git",
|
||||
"agents" | "skills" | "teleport" | "debug-tool-call" => "Discovery & debugging",
|
||||
"bughunter" | "ultraplan" => "Analysis & automation",
|
||||
_ => "Other",
|
||||
}
|
||||
}
|
||||
|
||||
fn format_slash_command_help_line(spec: &SlashCommandSpec) -> String {
|
||||
let name = match spec.argument_hint {
|
||||
Some(argument_hint) => format!("/{} {}", spec.name, argument_hint),
|
||||
None => format!("/{}", spec.name),
|
||||
};
|
||||
let alias_suffix = if spec.aliases.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(
|
||||
" (aliases: {})",
|
||||
spec.aliases
|
||||
.iter()
|
||||
.map(|alias| format!("/{alias}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)
|
||||
};
|
||||
let resume = if spec.resume_supported {
|
||||
" [resume]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!(" {name:<20} {}{alias_suffix}{resume}", spec.summary)
|
||||
}
|
||||
|
||||
fn levenshtein_distance(left: &str, right: &str) -> usize {
|
||||
if left == right {
|
||||
return 0;
|
||||
}
|
||||
if left.is_empty() {
|
||||
return right.chars().count();
|
||||
}
|
||||
if right.is_empty() {
|
||||
return left.chars().count();
|
||||
}
|
||||
|
||||
let right_chars = right.chars().collect::<Vec<_>>();
|
||||
let mut previous = (0..=right_chars.len()).collect::<Vec<_>>();
|
||||
let mut current = vec![0; right_chars.len() + 1];
|
||||
|
||||
for (left_index, left_char) in left.chars().enumerate() {
|
||||
current[0] = left_index + 1;
|
||||
for (right_index, right_char) in right_chars.iter().enumerate() {
|
||||
let substitution_cost = usize::from(left_char != *right_char);
|
||||
current[right_index + 1] = (current[right_index] + 1)
|
||||
.min(previous[right_index + 1] + 1)
|
||||
.min(previous[right_index] + substitution_cost);
|
||||
}
|
||||
previous.clone_from(¤t);
|
||||
}
|
||||
|
||||
previous[right_chars.len()]
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn suggest_slash_commands(input: &str, limit: usize) -> Vec<String> {
|
||||
let query = input.trim().trim_start_matches('/').to_ascii_lowercase();
|
||||
if query.is_empty() || limit == 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let mut suggestions = slash_command_specs()
|
||||
.iter()
|
||||
.filter_map(|spec| {
|
||||
let best = std::iter::once(spec.name)
|
||||
.chain(spec.aliases.iter().copied())
|
||||
.map(str::to_ascii_lowercase)
|
||||
.map(|candidate| {
|
||||
let prefix_rank =
|
||||
if candidate.starts_with(&query) || query.starts_with(&candidate) {
|
||||
0
|
||||
} else if candidate.contains(&query) || query.contains(&candidate) {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
};
|
||||
let distance = levenshtein_distance(&candidate, &query);
|
||||
(prefix_rank, distance)
|
||||
})
|
||||
.min();
|
||||
|
||||
best.and_then(|(prefix_rank, distance)| {
|
||||
if prefix_rank <= 1 || distance <= 2 {
|
||||
Some((prefix_rank, distance, spec.name.len(), spec.name))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
suggestions.sort_unstable();
|
||||
suggestions
|
||||
.into_iter()
|
||||
.map(|(_, _, _, name)| format!("/{name}"))
|
||||
.take(limit)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn render_slash_command_help() -> String {
|
||||
let mut lines = vec![
|
||||
"Slash commands".to_string(),
|
||||
" Start here /status, /diff, /agents, /skills, /commit".to_string(),
|
||||
" [resume] means the command also works with --resume SESSION.jsonl".to_string(),
|
||||
String::new(),
|
||||
];
|
||||
for spec in slash_command_specs() {
|
||||
let name = match spec.argument_hint {
|
||||
Some(argument_hint) => format!("/{} {}", spec.name, argument_hint),
|
||||
None => format!("/{}", spec.name),
|
||||
};
|
||||
let alias_suffix = if spec.aliases.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(
|
||||
" (aliases: {})",
|
||||
spec.aliases
|
||||
.iter()
|
||||
.map(|alias| format!("/{alias}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)
|
||||
};
|
||||
let resume = if spec.resume_supported {
|
||||
" [resume]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
lines.push(format!(
|
||||
" {name:<20} {}{alias_suffix}{resume}",
|
||||
spec.summary
|
||||
));
|
||||
|
||||
let categories = [
|
||||
"Session & visibility",
|
||||
"Workspace & git",
|
||||
"Discovery & debugging",
|
||||
"Analysis & automation",
|
||||
];
|
||||
|
||||
for category in categories {
|
||||
lines.push(category.to_string());
|
||||
for spec in slash_command_specs()
|
||||
.iter()
|
||||
.filter(|spec| slash_command_category(spec.name) == category)
|
||||
{
|
||||
lines.push(format_slash_command_help_line(spec));
|
||||
}
|
||||
lines.push(String::new());
|
||||
}
|
||||
lines.join("\n")
|
||||
|
||||
lines
|
||||
.into_iter()
|
||||
.rev()
|
||||
.skip_while(String::is_empty)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
.rev()
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -1223,7 +1336,7 @@ mod tests {
|
||||
handle_plugins_slash_command, handle_slash_command, load_agents_from_roots,
|
||||
load_skills_from_roots, render_agents_report, render_plugins_report, render_skills_report,
|
||||
render_slash_command_help, resume_supported_slash_commands, slash_command_specs,
|
||||
DefinitionSource, SkillOrigin, SkillRoot, SlashCommand,
|
||||
suggest_slash_commands, DefinitionSource, SkillOrigin, SkillRoot, SlashCommand,
|
||||
};
|
||||
use plugins::{PluginKind, PluginManager, PluginManagerConfig, PluginMetadata, PluginSummary};
|
||||
use runtime::{CompactionConfig, ContentBlock, ConversationMessage, MessageRole, Session};
|
||||
@@ -1466,7 +1579,12 @@ mod tests {
|
||||
#[test]
|
||||
fn renders_help_from_shared_specs() {
|
||||
let help = render_slash_command_help();
|
||||
assert!(help.contains("Start here /status, /diff, /agents, /skills, /commit"));
|
||||
assert!(help.contains("works with --resume SESSION.jsonl"));
|
||||
assert!(help.contains("Session & visibility"));
|
||||
assert!(help.contains("Workspace & git"));
|
||||
assert!(help.contains("Discovery & debugging"));
|
||||
assert!(help.contains("Analysis & automation"));
|
||||
assert!(help.contains("/help"));
|
||||
assert!(help.contains("/status"));
|
||||
assert!(help.contains("/sandbox"));
|
||||
@@ -1501,6 +1619,13 @@ mod tests {
|
||||
assert_eq!(resume_supported_slash_commands().len(), 14);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn suggests_closest_slash_commands_for_typos_and_aliases() {
|
||||
assert_eq!(suggest_slash_commands("stats", 3), vec!["/status"]);
|
||||
assert_eq!(suggest_slash_commands("/plugns", 3), vec!["/plugin"]);
|
||||
assert_eq!(suggest_slash_commands("zzz", 3), Vec::<String>::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compacts_sessions_via_slash_command() {
|
||||
let mut session = Session::new();
|
||||
|
||||
@@ -170,7 +170,7 @@ where
|
||||
system_prompt,
|
||||
max_iterations: usize::MAX,
|
||||
usage_tracker,
|
||||
hook_runner: HookRunner::from_feature_config(&feature_config),
|
||||
hook_runner: HookRunner::from_feature_config(feature_config),
|
||||
auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(),
|
||||
hook_abort_signal: HookAbortSignal::default(),
|
||||
hook_progress_reporter: None,
|
||||
|
||||
@@ -168,16 +168,23 @@ impl Session {
|
||||
{
|
||||
Self::from_json(&value)?
|
||||
}
|
||||
Err(_) => Self::from_jsonl(&contents)?,
|
||||
Ok(_) => Self::from_jsonl(&contents)?,
|
||||
Err(_) | Ok(_) => Self::from_jsonl(&contents)?,
|
||||
};
|
||||
Ok(session.with_persistence_path(path.to_path_buf()))
|
||||
}
|
||||
|
||||
pub fn push_message(&mut self, message: ConversationMessage) -> Result<(), SessionError> {
|
||||
self.touch();
|
||||
self.messages.push(message.clone());
|
||||
self.append_persisted_message(&message)
|
||||
self.messages.push(message);
|
||||
let persist_result = {
|
||||
let message_ref = self.messages.last().expect("message was just pushed");
|
||||
self.append_persisted_message(message_ref)
|
||||
};
|
||||
if let Err(error) = persist_result {
|
||||
self.messages.pop();
|
||||
return Err(error);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn push_user_text(&mut self, text: impl Into<String>) -> Result<(), SessionError> {
|
||||
@@ -270,8 +277,7 @@ impl Session {
|
||||
let session_id = object
|
||||
.get("session_id")
|
||||
.and_then(JsonValue::as_str)
|
||||
.map(ToOwned::to_owned)
|
||||
.unwrap_or_else(generate_session_id);
|
||||
.map_or_else(generate_session_id, ToOwned::to_owned);
|
||||
let created_at_ms = object
|
||||
.get("created_at_ms")
|
||||
.map(|value| required_u64_from_value(value, "created_at_ms"))
|
||||
@@ -813,7 +819,7 @@ fn normalize_optional_string(value: Option<String>) -> Option<String> {
|
||||
fn current_time_millis() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|duration| duration.as_millis() as u64)
|
||||
.map(|duration| u64::try_from(duration.as_millis()).unwrap_or(u64::MAX))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
@@ -881,7 +887,12 @@ fn cleanup_rotated_logs(path: &Path) -> Result<(), SessionError> {
|
||||
entry_path
|
||||
.file_name()
|
||||
.and_then(|value| value.to_str())
|
||||
.is_some_and(|name| name.starts_with(&prefix) && name.ends_with(".jsonl"))
|
||||
.is_some_and(|name| {
|
||||
name.starts_with(&prefix)
|
||||
&& Path::new(name)
|
||||
.extension()
|
||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("jsonl"))
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -907,7 +918,7 @@ mod tests {
|
||||
use crate::json::JsonValue;
|
||||
use crate::usage::TokenUsage;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[test]
|
||||
@@ -1057,8 +1068,9 @@ mod tests {
|
||||
#[test]
|
||||
fn rotates_and_cleans_up_large_session_logs() {
|
||||
let path = temp_session_path("rotation");
|
||||
fs::write(&path, "x".repeat((super::ROTATE_AFTER_BYTES + 10) as usize))
|
||||
.expect("oversized file should write");
|
||||
let oversized_length =
|
||||
usize::try_from(super::ROTATE_AFTER_BYTES + 10).expect("rotate threshold should fit");
|
||||
fs::write(&path, "x".repeat(oversized_length)).expect("oversized file should write");
|
||||
rotate_session_file_if_needed(&path).expect("rotation should succeed");
|
||||
assert!(
|
||||
!path.exists(),
|
||||
@@ -1086,7 +1098,7 @@ mod tests {
|
||||
std::env::temp_dir().join(format!("runtime-session-{label}-{nanos}.json"))
|
||||
}
|
||||
|
||||
fn rotation_files(path: &PathBuf) -> Vec<PathBuf> {
|
||||
fn rotation_files(path: &Path) -> Vec<PathBuf> {
|
||||
let stem = path
|
||||
.file_stem()
|
||||
.and_then(|value| value.to_str())
|
||||
@@ -1101,7 +1113,10 @@ mod tests {
|
||||
.file_name()
|
||||
.and_then(|value| value.to_str())
|
||||
.is_some_and(|name| {
|
||||
name.starts_with(&format!("{stem}.rot-")) && name.ends_with(".jsonl")
|
||||
name.starts_with(&format!("{stem}.rot-"))
|
||||
&& Path::new(name)
|
||||
.extension()
|
||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("jsonl"))
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -22,7 +22,8 @@ use api::{
|
||||
|
||||
use commands::{
|
||||
handle_agents_slash_command, handle_plugins_slash_command, handle_skills_slash_command,
|
||||
render_slash_command_help, resume_supported_slash_commands, slash_command_specs, SlashCommand,
|
||||
render_slash_command_help, resume_supported_slash_commands, slash_command_specs,
|
||||
suggest_slash_commands, SlashCommand,
|
||||
};
|
||||
use compat_harness::{extract_manifest, UpstreamPaths};
|
||||
use init::initialize_repo;
|
||||
@@ -30,12 +31,11 @@ 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, PromptCacheEvent,
|
||||
OAuthAuthorizationRequest, OAuthConfig,
|
||||
OAuthTokenExchangeRequest, PermissionMode, PermissionPolicy, ProjectContext, RuntimeError,
|
||||
Session, TokenUsage, ToolError, ToolExecutor, UsageTracker,
|
||||
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, PromptCacheEvent,
|
||||
RuntimeError, Session, TokenUsage, ToolError, ToolExecutor, UsageTracker,
|
||||
};
|
||||
use serde_json::json;
|
||||
use tools::GlobalToolRegistry;
|
||||
@@ -323,13 +323,13 @@ fn parse_direct_slash_cli_action(rest: &[String]) -> Result<CliAction, String> {
|
||||
Some(SlashCommand::Help) => Ok(CliAction::Help),
|
||||
Some(SlashCommand::Agents { args }) => Ok(CliAction::Agents { args }),
|
||||
Some(SlashCommand::Skills { args }) => Ok(CliAction::Skills { args }),
|
||||
Some(command) => Err(format!(
|
||||
"unsupported direct slash command outside the REPL: {command_name}",
|
||||
command_name = match command {
|
||||
SlashCommand::Unknown(name) => format!("/{name}"),
|
||||
_ => rest[0].clone(),
|
||||
}
|
||||
)),
|
||||
Some(command) => Err(match command {
|
||||
SlashCommand::Unknown(name) => format_unknown_slash_command_message(&name),
|
||||
_ => format!(
|
||||
"slash command {command_name} is interactive-only. Start `claw` and run it there, or use `claw --resume SESSION.jsonl {command_name}` when the command is marked [resume] in /help.",
|
||||
command_name = rest[0]
|
||||
),
|
||||
}),
|
||||
None => Err(format!("unknown subcommand: {}", rest[0])),
|
||||
}
|
||||
}
|
||||
@@ -670,6 +670,7 @@ struct StatusContext {
|
||||
memory_file_count: usize,
|
||||
project_root: Option<PathBuf>,
|
||||
git_branch: Option<String>,
|
||||
git_summary: GitWorkspaceSummary,
|
||||
sandbox_status: runtime::SandboxStatus,
|
||||
}
|
||||
|
||||
@@ -682,6 +683,59 @@ struct StatusUsage {
|
||||
estimated_tokens: usize,
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_field_names)]
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
struct GitWorkspaceSummary {
|
||||
changed_files: usize,
|
||||
staged_files: usize,
|
||||
unstaged_files: usize,
|
||||
untracked_files: usize,
|
||||
conflicted_files: usize,
|
||||
}
|
||||
|
||||
impl GitWorkspaceSummary {
|
||||
fn is_clean(self) -> bool {
|
||||
self.changed_files == 0
|
||||
}
|
||||
|
||||
fn headline(self) -> String {
|
||||
if self.is_clean() {
|
||||
"clean".to_string()
|
||||
} else {
|
||||
let mut details = Vec::new();
|
||||
if self.staged_files > 0 {
|
||||
details.push(format!("{} staged", self.staged_files));
|
||||
}
|
||||
if self.unstaged_files > 0 {
|
||||
details.push(format!("{} unstaged", self.unstaged_files));
|
||||
}
|
||||
if self.untracked_files > 0 {
|
||||
details.push(format!("{} untracked", self.untracked_files));
|
||||
}
|
||||
if self.conflicted_files > 0 {
|
||||
details.push(format!("{} conflicted", self.conflicted_files));
|
||||
}
|
||||
format!(
|
||||
"dirty · {} files · {}",
|
||||
self.changed_files,
|
||||
details.join(", ")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn format_unknown_slash_command_message(name: &str) -> String {
|
||||
let suggestions = suggest_slash_commands(name, 3);
|
||||
if suggestions.is_empty() {
|
||||
format!("unknown slash command: /{name}. Use /help to list available commands.")
|
||||
} else {
|
||||
format!(
|
||||
"unknown slash command: /{name}. Did you mean {}? Use /help to list available commands.",
|
||||
suggestions.join(", ")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn format_model_report(model: &str, message_count: usize, turns: u32) -> String {
|
||||
format!(
|
||||
"Model
|
||||
@@ -827,6 +881,44 @@ fn parse_git_status_branch(status: Option<&str>) -> Option<String> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_git_workspace_summary(status: Option<&str>) -> GitWorkspaceSummary {
|
||||
let mut summary = GitWorkspaceSummary::default();
|
||||
let Some(status) = status else {
|
||||
return summary;
|
||||
};
|
||||
|
||||
for line in status.lines() {
|
||||
if line.starts_with("## ") || line.trim().is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
summary.changed_files += 1;
|
||||
let mut chars = line.chars();
|
||||
let index_status = chars.next().unwrap_or(' ');
|
||||
let worktree_status = chars.next().unwrap_or(' ');
|
||||
|
||||
if index_status == '?' && worktree_status == '?' {
|
||||
summary.untracked_files += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if index_status != ' ' {
|
||||
summary.staged_files += 1;
|
||||
}
|
||||
if worktree_status != ' ' {
|
||||
summary.unstaged_files += 1;
|
||||
}
|
||||
if (matches!(index_status, 'U' | 'A') && matches!(worktree_status, 'U' | 'A'))
|
||||
|| index_status == 'U'
|
||||
|| worktree_status == 'U'
|
||||
{
|
||||
summary.conflicted_files += 1;
|
||||
}
|
||||
}
|
||||
|
||||
summary
|
||||
}
|
||||
|
||||
fn resolve_git_branch_for(cwd: &Path) -> Option<String> {
|
||||
let branch = run_git_capture_in(cwd, &["branch", "--show-current"])?;
|
||||
let branch = branch.trim();
|
||||
@@ -1188,6 +1280,15 @@ impl LiveCli {
|
||||
|_| "<unknown>".to_string(),
|
||||
|path| path.display().to_string(),
|
||||
);
|
||||
let status = status_context(None).ok();
|
||||
let git_branch = status
|
||||
.as_ref()
|
||||
.and_then(|context| context.git_branch.as_deref())
|
||||
.unwrap_or("unknown");
|
||||
let workspace = status.as_ref().map_or_else(
|
||||
|| "unknown".to_string(),
|
||||
|context| context.git_summary.headline(),
|
||||
);
|
||||
format!(
|
||||
"\x1b[38;5;196m\
|
||||
██████╗██╗ █████╗ ██╗ ██╗\n\
|
||||
@@ -1198,11 +1299,15 @@ impl LiveCli {
|
||||
╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝\x1b[0m \x1b[38;5;208mCode\x1b[0m 🦞\n\n\
|
||||
\x1b[2mModel\x1b[0m {}\n\
|
||||
\x1b[2mPermissions\x1b[0m {}\n\
|
||||
\x1b[2mBranch\x1b[0m {}\n\
|
||||
\x1b[2mWorkspace\x1b[0m {}\n\
|
||||
\x1b[2mDirectory\x1b[0m {}\n\
|
||||
\x1b[2mSession\x1b[0m {}\n\n\
|
||||
Type \x1b[1m/help\x1b[0m for commands · \x1b[2mShift+Enter\x1b[0m for newline",
|
||||
Type \x1b[1m/help\x1b[0m for commands · \x1b[1m/status\x1b[0m for live context · \x1b[1m/diff\x1b[0m then \x1b[1m/commit\x1b[0m to ship · \x1b[2mShift+Enter\x1b[0m for newline",
|
||||
self.model,
|
||||
self.permission_mode.as_str(),
|
||||
git_branch,
|
||||
workspace,
|
||||
cwd,
|
||||
self.session.id,
|
||||
)
|
||||
@@ -1416,7 +1521,7 @@ impl LiveCli {
|
||||
false
|
||||
}
|
||||
SlashCommand::Unknown(name) => {
|
||||
eprintln!("unknown slash command: /{name}");
|
||||
eprintln!("{}", format_unknown_slash_command_message(&name));
|
||||
false
|
||||
}
|
||||
})
|
||||
@@ -1885,12 +1990,19 @@ impl LiveCli {
|
||||
}
|
||||
|
||||
fn run_commit(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let status = git_output(&["status", "--short"])?;
|
||||
if status.trim().is_empty() {
|
||||
println!("Commit\n Result skipped\n Reason no workspace changes");
|
||||
let status = git_output(&["status", "--short", "--branch"])?;
|
||||
let summary = parse_git_workspace_summary(Some(&status));
|
||||
let branch = parse_git_status_branch(Some(&status));
|
||||
if summary.is_clean() {
|
||||
println!("{}", format_commit_skipped_report());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
format_commit_preflight_report(branch.as_deref(), summary)
|
||||
);
|
||||
|
||||
git_status_ok(&["add", "-A"])?;
|
||||
let staged_stat = git_output(&["diff", "--cached", "--stat"])?;
|
||||
let prompt = format!(
|
||||
@@ -1911,13 +2023,12 @@ impl LiveCli {
|
||||
.output()?;
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
|
||||
return Err(format!("git commit failed: {stderr}").into());
|
||||
return Err(format_git_commit_failure(&stderr).into());
|
||||
}
|
||||
|
||||
println!(
|
||||
"Commit\n Result created\n Message file {}\n\n{}",
|
||||
path.display(),
|
||||
message.trim()
|
||||
"{}",
|
||||
format_commit_success_report(branch.as_deref(), summary, &path, &staged_stat, &message,)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -2058,33 +2169,35 @@ fn list_managed_sessions() -> Result<Vec<ManagedSessionSummary>, Box<dyn std::er
|
||||
.map(|duration| duration.as_secs())
|
||||
.unwrap_or_default();
|
||||
let (id, message_count, parent_session_id, branch_name) = Session::load_from_path(&path)
|
||||
.map(|session| {
|
||||
let parent_session_id = session
|
||||
.fork
|
||||
.as_ref()
|
||||
.map(|fork| fork.parent_session_id.clone());
|
||||
let branch_name = session
|
||||
.fork
|
||||
.as_ref()
|
||||
.and_then(|fork| fork.branch_name.clone());
|
||||
(
|
||||
session.session_id,
|
||||
session.messages.len(),
|
||||
parent_session_id,
|
||||
branch_name,
|
||||
)
|
||||
})
|
||||
.unwrap_or_else(|_| {
|
||||
(
|
||||
path.file_stem()
|
||||
.and_then(|value| value.to_str())
|
||||
.unwrap_or("unknown")
|
||||
.to_string(),
|
||||
0,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
});
|
||||
.map_or_else(
|
||||
|_| {
|
||||
(
|
||||
path.file_stem()
|
||||
.and_then(|value| value.to_str())
|
||||
.unwrap_or("unknown")
|
||||
.to_string(),
|
||||
0,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
},
|
||||
|session| {
|
||||
let parent_session_id = session
|
||||
.fork
|
||||
.as_ref()
|
||||
.map(|fork| fork.parent_session_id.clone());
|
||||
let branch_name = session
|
||||
.fork
|
||||
.as_ref()
|
||||
.and_then(|fork| fork.branch_name.clone());
|
||||
(
|
||||
session.session_id,
|
||||
session.messages.len(),
|
||||
parent_session_id,
|
||||
branch_name,
|
||||
)
|
||||
},
|
||||
);
|
||||
sessions.push(ManagedSessionSummary {
|
||||
id,
|
||||
path,
|
||||
@@ -2165,6 +2278,7 @@ fn status_context(
|
||||
let project_context = ProjectContext::discover_with_git(&cwd, DEFAULT_DATE)?;
|
||||
let (project_root, git_branch) =
|
||||
parse_git_status_metadata(project_context.git_status.as_deref());
|
||||
let git_summary = parse_git_workspace_summary(project_context.git_status.as_deref());
|
||||
let sandbox_status = resolve_sandbox_status(runtime_config.sandbox(), &cwd);
|
||||
Ok(StatusContext {
|
||||
cwd,
|
||||
@@ -2174,6 +2288,7 @@ fn status_context(
|
||||
memory_file_count: project_context.instruction_files.len(),
|
||||
project_root,
|
||||
git_branch,
|
||||
git_summary,
|
||||
sandbox_status,
|
||||
})
|
||||
}
|
||||
@@ -2210,15 +2325,26 @@ fn format_status_report(
|
||||
Cwd {}
|
||||
Project root {}
|
||||
Git branch {}
|
||||
Git state {}
|
||||
Changed files {}
|
||||
Staged {}
|
||||
Unstaged {}
|
||||
Untracked {}
|
||||
Session {}
|
||||
Config files loaded {}/{}
|
||||
Memory files {}",
|
||||
Memory files {}
|
||||
Suggested flow /status → /diff → /commit",
|
||||
context.cwd.display(),
|
||||
context
|
||||
.project_root
|
||||
.as_ref()
|
||||
.map_or_else(|| "unknown".to_string(), |path| path.display().to_string()),
|
||||
context.git_branch.as_deref().unwrap_or("unknown"),
|
||||
context.git_summary.headline(),
|
||||
context.git_summary.changed_files,
|
||||
context.git_summary.staged_files,
|
||||
context.git_summary.unstaged_files,
|
||||
context.git_summary.untracked_files,
|
||||
context.session_path.as_ref().map_or_else(
|
||||
|| "live-repl".to_string(),
|
||||
|path| path.display().to_string()
|
||||
@@ -2279,6 +2405,70 @@ fn format_sandbox_report(status: &runtime::SandboxStatus) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
fn format_commit_preflight_report(branch: Option<&str>, summary: GitWorkspaceSummary) -> String {
|
||||
format!(
|
||||
"Commit
|
||||
Result preparing
|
||||
Branch {}
|
||||
Workspace {}
|
||||
Changed files {}
|
||||
Action auto-stage workspace changes and draft Lore commit message",
|
||||
branch.unwrap_or("unknown"),
|
||||
summary.headline(),
|
||||
summary.changed_files,
|
||||
)
|
||||
}
|
||||
|
||||
fn format_commit_skipped_report() -> String {
|
||||
"Commit
|
||||
Result skipped
|
||||
Reason no workspace changes
|
||||
Next /status to inspect context · /diff to inspect repo changes"
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn format_commit_success_report(
|
||||
branch: Option<&str>,
|
||||
summary: GitWorkspaceSummary,
|
||||
message_path: &Path,
|
||||
staged_stat: &str,
|
||||
message: &str,
|
||||
) -> String {
|
||||
let staged_summary = staged_stat.trim();
|
||||
format!(
|
||||
"Commit
|
||||
Result created
|
||||
Branch {}
|
||||
Workspace {}
|
||||
Changed files {}
|
||||
Message file {}
|
||||
|
||||
Staged diff
|
||||
{}
|
||||
|
||||
Lore message
|
||||
{}",
|
||||
branch.unwrap_or("unknown"),
|
||||
summary.headline(),
|
||||
summary.changed_files,
|
||||
message_path.display(),
|
||||
if staged_summary.is_empty() {
|
||||
" <summary unavailable>".to_string()
|
||||
} else {
|
||||
indent_block(staged_summary, 2)
|
||||
},
|
||||
message.trim()
|
||||
)
|
||||
}
|
||||
|
||||
fn format_git_commit_failure(stderr: &str) -> String {
|
||||
if stderr.contains("Author identity unknown") || stderr.contains("Please tell me who you are") {
|
||||
"git commit failed: author identity is not configured. Run `git config user.name \"Your Name\"` and `git config user.email \"you@example.com\"`, then retry /commit.".to_string()
|
||||
} else {
|
||||
format!("git commit failed: {stderr}")
|
||||
}
|
||||
}
|
||||
|
||||
fn render_config_report(section: Option<&str>) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let cwd = env::current_dir()?;
|
||||
let loader = ConfigLoader::default_for(&cwd);
|
||||
@@ -3146,7 +3336,8 @@ fn build_runtime(
|
||||
allowed_tools: Option<AllowedToolSet>,
|
||||
permission_mode: PermissionMode,
|
||||
progress_reporter: Option<InternalPromptProgressReporter>,
|
||||
) -> Result<ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>> {
|
||||
) -> Result<ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>>
|
||||
{
|
||||
let (feature_config, tool_registry) = build_runtime_plugin_state()?;
|
||||
let mut runtime = ConversationRuntime::new_with_features(
|
||||
session,
|
||||
@@ -3286,7 +3477,6 @@ impl AnthropicRuntimeClient {
|
||||
progress_reporter,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn resolve_cli_auth_source() -> Result<AuthSource, Box<dyn std::error::Error>> {
|
||||
@@ -4023,7 +4213,9 @@ fn push_prompt_cache_record(client: &AnthropicClient, events: &mut Vec<Assistant
|
||||
}
|
||||
}
|
||||
|
||||
fn prompt_cache_record_to_runtime_event(record: api::PromptCacheRecord) -> Option<PromptCacheEvent> {
|
||||
fn prompt_cache_record_to_runtime_event(
|
||||
record: api::PromptCacheRecord,
|
||||
) -> Option<PromptCacheEvent> {
|
||||
let cache_break = record.cache_break?;
|
||||
Some(PromptCacheEvent {
|
||||
unexpected: cache_break.unexpected,
|
||||
@@ -4245,18 +4437,19 @@ fn print_help() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
describe_tool_progress, filter_tool_specs, format_compact_report, format_cost_report,
|
||||
format_internal_prompt_progress_line, format_model_report, format_model_switch_report,
|
||||
format_permissions_report,
|
||||
create_managed_session_handle, describe_tool_progress, filter_tool_specs,
|
||||
format_commit_preflight_report, format_commit_skipped_report, format_commit_success_report,
|
||||
format_compact_report, format_cost_report, format_internal_prompt_progress_line,
|
||||
format_model_report, format_model_switch_report, format_permissions_report,
|
||||
format_permissions_switch_report, format_resume_report, format_status_report,
|
||||
format_tool_call_start, format_tool_result, normalize_permission_mode, parse_args,
|
||||
parse_git_status_branch, parse_git_status_metadata_for, permission_policy,
|
||||
format_tool_call_start, format_tool_result, format_unknown_slash_command_message,
|
||||
normalize_permission_mode, parse_args, parse_git_status_branch,
|
||||
parse_git_status_metadata_for, parse_git_workspace_summary, permission_policy,
|
||||
print_help_to, push_output_block, render_config_report, render_diff_report,
|
||||
render_memory_report, render_repl_help, resolve_model_alias, response_to_events,
|
||||
resume_supported_slash_commands, run_resume_command, status_context, CliAction,
|
||||
CliOutputFormat, InternalPromptProgressEvent,
|
||||
render_memory_report, render_repl_help, resolve_model_alias, resolve_session_reference,
|
||||
response_to_events, resume_supported_slash_commands, run_resume_command, status_context,
|
||||
CliAction, CliOutputFormat, GitWorkspaceSummary, InternalPromptProgressEvent,
|
||||
InternalPromptProgressState, SlashCommand, StatusUsage, DEFAULT_MODEL,
|
||||
create_managed_session_handle, resolve_session_reference,
|
||||
};
|
||||
use api::{MessageResponse, OutputContentBlock, Usage};
|
||||
use plugins::{PluginTool, PluginToolDefinition, PluginToolPermission};
|
||||
@@ -4532,7 +4725,16 @@ mod tests {
|
||||
);
|
||||
let error = parse_args(&["/status".to_string()])
|
||||
.expect_err("/status should remain REPL-only when invoked directly");
|
||||
assert!(error.contains("unsupported direct slash command"));
|
||||
assert!(error.contains("interactive-only"));
|
||||
assert!(error.contains("claw --resume SESSION.jsonl /status"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn formats_unknown_slash_command_with_suggestions() {
|
||||
let report = format_unknown_slash_command_message("stats");
|
||||
assert!(report.contains("unknown slash command: /stats"));
|
||||
assert!(report.contains("Did you mean /status?"));
|
||||
assert!(report.contains("Use /help"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -4775,6 +4977,13 @@ mod tests {
|
||||
memory_file_count: 4,
|
||||
project_root: Some(PathBuf::from("/tmp")),
|
||||
git_branch: Some("main".to_string()),
|
||||
git_summary: GitWorkspaceSummary {
|
||||
changed_files: 3,
|
||||
staged_files: 1,
|
||||
unstaged_files: 1,
|
||||
untracked_files: 1,
|
||||
conflicted_files: 0,
|
||||
},
|
||||
sandbox_status: runtime::SandboxStatus::default(),
|
||||
},
|
||||
);
|
||||
@@ -4787,9 +4996,54 @@ mod tests {
|
||||
assert!(status.contains("Cwd /tmp/project"));
|
||||
assert!(status.contains("Project root /tmp"));
|
||||
assert!(status.contains("Git branch main"));
|
||||
assert!(
|
||||
status.contains("Git state dirty · 3 files · 1 staged, 1 unstaged, 1 untracked")
|
||||
);
|
||||
assert!(status.contains("Changed files 3"));
|
||||
assert!(status.contains("Staged 1"));
|
||||
assert!(status.contains("Unstaged 1"));
|
||||
assert!(status.contains("Untracked 1"));
|
||||
assert!(status.contains("Session session.jsonl"));
|
||||
assert!(status.contains("Config files loaded 2/3"));
|
||||
assert!(status.contains("Memory files 4"));
|
||||
assert!(status.contains("Suggested flow /status → /diff → /commit"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_reports_surface_workspace_context() {
|
||||
let summary = GitWorkspaceSummary {
|
||||
changed_files: 2,
|
||||
staged_files: 1,
|
||||
unstaged_files: 1,
|
||||
untracked_files: 0,
|
||||
conflicted_files: 0,
|
||||
};
|
||||
|
||||
let preflight = format_commit_preflight_report(Some("feature/ux"), summary);
|
||||
assert!(preflight.contains("Result preparing"));
|
||||
assert!(preflight.contains("Branch feature/ux"));
|
||||
assert!(preflight.contains("Workspace dirty · 2 files · 1 staged, 1 unstaged"));
|
||||
|
||||
let success = format_commit_success_report(
|
||||
Some("feature/ux"),
|
||||
summary,
|
||||
Path::new("/tmp/message.txt"),
|
||||
" src/main.rs | 4 ++--",
|
||||
"Improve slash command guidance",
|
||||
);
|
||||
assert!(success.contains("Result created"));
|
||||
assert!(success.contains("Message file /tmp/message.txt"));
|
||||
assert!(success.contains("Staged diff"));
|
||||
assert!(success.contains("src/main.rs | 4 ++--"));
|
||||
assert!(success.contains("Lore message"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_skipped_report_points_to_next_steps() {
|
||||
let report = format_commit_skipped_report();
|
||||
assert!(report.contains("Reason no workspace changes"));
|
||||
assert!(report.contains("/status to inspect context"));
|
||||
assert!(report.contains("/diff to inspect repo changes"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -4847,6 +5101,32 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_git_workspace_summary_counts() {
|
||||
let summary = parse_git_workspace_summary(Some(
|
||||
"## feature/ux
|
||||
M src/main.rs
|
||||
M README.md
|
||||
?? notes.md
|
||||
UU conflicted.rs",
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
summary,
|
||||
GitWorkspaceSummary {
|
||||
changed_files: 4,
|
||||
staged_files: 2,
|
||||
unstaged_files: 2,
|
||||
untracked_files: 1,
|
||||
conflicted_files: 1,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
summary.headline(),
|
||||
"dirty · 4 files · 2 staged, 2 unstaged, 1 untracked, 1 conflicted"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_diff_report_shows_clean_tree_for_committed_repo() {
|
||||
let _guard = env_lock();
|
||||
@@ -5051,8 +5331,13 @@ mod tests {
|
||||
|
||||
let resolved = resolve_session_reference("legacy").expect("legacy session should resolve");
|
||||
assert_eq!(
|
||||
resolved.path.canonicalize().expect("resolved path should exist"),
|
||||
legacy_path.canonicalize().expect("legacy path should exist")
|
||||
resolved
|
||||
.path
|
||||
.canonicalize()
|
||||
.expect("resolved path should exist"),
|
||||
legacy_path
|
||||
.canonicalize()
|
||||
.expect("legacy path should exist")
|
||||
);
|
||||
|
||||
std::env::set_current_dir(previous).expect("restore cwd");
|
||||
|
||||
@@ -91,7 +91,10 @@ impl GlobalToolRegistry {
|
||||
Ok(Self { plugin_tools })
|
||||
}
|
||||
|
||||
pub fn normalize_allowed_tools(&self, values: &[String]) -> Result<Option<BTreeSet<String>>, String> {
|
||||
pub fn normalize_allowed_tools(
|
||||
&self,
|
||||
values: &[String],
|
||||
) -> Result<Option<BTreeSet<String>>, String> {
|
||||
if values.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -100,7 +103,11 @@ impl GlobalToolRegistry {
|
||||
let canonical_names = builtin_specs
|
||||
.iter()
|
||||
.map(|spec| spec.name.to_string())
|
||||
.chain(self.plugin_tools.iter().map(|tool| tool.definition().name.clone()))
|
||||
.chain(
|
||||
self.plugin_tools
|
||||
.iter()
|
||||
.map(|tool| tool.definition().name.clone()),
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
let mut name_map = canonical_names
|
||||
.iter()
|
||||
@@ -151,7 +158,8 @@ impl GlobalToolRegistry {
|
||||
.plugin_tools
|
||||
.iter()
|
||||
.filter(|tool| {
|
||||
allowed_tools.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))
|
||||
allowed_tools
|
||||
.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))
|
||||
})
|
||||
.map(|tool| ToolDefinition {
|
||||
name: tool.definition().name.clone(),
|
||||
@@ -174,7 +182,8 @@ impl GlobalToolRegistry {
|
||||
.plugin_tools
|
||||
.iter()
|
||||
.filter(|tool| {
|
||||
allowed_tools.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))
|
||||
allowed_tools
|
||||
.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))
|
||||
})
|
||||
.map(|tool| {
|
||||
(
|
||||
@@ -1809,8 +1818,9 @@ struct ProviderRuntimeClient {
|
||||
}
|
||||
|
||||
impl ProviderRuntimeClient {
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
fn new(model: String, allowed_tools: BTreeSet<String>) -> Result<Self, String> {
|
||||
let model = resolve_model_alias(&model).to_string();
|
||||
let model = resolve_model_alias(&model).clone();
|
||||
let client = ProviderClient::from_model(&model).map_err(|error| error.to_string())?;
|
||||
Ok(Self {
|
||||
runtime: tokio::runtime::Runtime::new().map_err(|error| error.to_string())?,
|
||||
@@ -1822,6 +1832,7 @@ impl ProviderRuntimeClient {
|
||||
}
|
||||
|
||||
impl ApiClient for ProviderRuntimeClient {
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn stream(&mut self, request: ApiRequest) -> Result<Vec<AssistantEvent>, RuntimeError> {
|
||||
let tools = tool_specs_for_allowed_tools(Some(&self.allowed_tools))
|
||||
.into_iter()
|
||||
@@ -2057,7 +2068,9 @@ fn push_prompt_cache_record(client: &ProviderClient, events: &mut Vec<AssistantE
|
||||
}
|
||||
}
|
||||
|
||||
fn prompt_cache_record_to_runtime_event(record: api::PromptCacheRecord) -> Option<PromptCacheEvent> {
|
||||
fn prompt_cache_record_to_runtime_event(
|
||||
record: api::PromptCacheRecord,
|
||||
) -> Option<PromptCacheEvent> {
|
||||
let cache_break = record.cache_break?;
|
||||
Some(PromptCacheEvent {
|
||||
unexpected: cache_break.unexpected,
|
||||
|
||||
Reference in New Issue
Block a user