mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 22:41:51 +08:00
Enable local image prompts without breaking text-only CLI flows
The Rust CLI now recognizes explicit local image references in prompt text, encodes supported image files as base64, and serializes mixed text/image content blocks for the API. The request conversion path was kept narrow so existing runtime/session structures remain stable while prompt mode and user text conversion gain multimodal support. Constraint: Must support PNG, JPG/JPEG, GIF, and WebP without adding broad runtime abstractions Constraint: Existing text-only prompt behavior and API tool flows must keep working unchanged Rejected: Add only explicit --image CLI flags | does not satisfy auto-detect image refs in prompt text Rejected: Persist native image blocks in runtime session model | broader refactor than needed for prompt support Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep image parsing scoped to outbound user prompt adaptation unless session persistence truly needs multimodal history Tested: cargo fmt --all; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace Not-tested: Live remote multimodal request against Anthropic API
This commit is contained in:
@@ -408,7 +408,7 @@ mod tests {
|
||||
.sum::<i32>();
|
||||
Ok(total.to_string())
|
||||
});
|
||||
let permission_policy = PermissionPolicy::new(PermissionMode::Prompt);
|
||||
let permission_policy = PermissionPolicy::new(PermissionMode::WorkspaceWrite);
|
||||
let system_prompt = SystemPromptBuilder::new()
|
||||
.with_project_context(ProjectContext {
|
||||
cwd: PathBuf::from("/tmp/project"),
|
||||
@@ -487,7 +487,7 @@ mod tests {
|
||||
Session::new(),
|
||||
SingleCallApiClient,
|
||||
StaticToolExecutor::new(),
|
||||
PermissionPolicy::new(PermissionMode::Prompt),
|
||||
PermissionPolicy::new(PermissionMode::WorkspaceWrite),
|
||||
vec!["system".to_string()],
|
||||
);
|
||||
|
||||
@@ -536,7 +536,7 @@ mod tests {
|
||||
session,
|
||||
SimpleApi,
|
||||
StaticToolExecutor::new(),
|
||||
PermissionPolicy::new(PermissionMode::Allow),
|
||||
PermissionPolicy::new(PermissionMode::DangerFullAccess),
|
||||
vec!["system".to_string()],
|
||||
);
|
||||
|
||||
@@ -563,7 +563,7 @@ mod tests {
|
||||
Session::new(),
|
||||
SimpleApi,
|
||||
StaticToolExecutor::new(),
|
||||
PermissionPolicy::new(PermissionMode::Allow),
|
||||
PermissionPolicy::new(PermissionMode::DangerFullAccess),
|
||||
vec!["system".to_string()],
|
||||
);
|
||||
runtime.run_turn("a", None).expect("turn a");
|
||||
|
||||
Reference in New Issue
Block a user