mirror of
https://github.com/instructkr/claw-code.git
synced 2026-05-18 21:41:26 +08:00
omx(team): auto-checkpoint worker-1 [1]
This commit is contained in:
@@ -331,6 +331,59 @@ fn merge_prompt_with_stdin(prompt: &str, stdin_content: Option<&str>) -> String
|
|||||||
format!("{prompt}\n\n{trimmed}")
|
format!("{prompt}\n\n{trimmed}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn plugin_command_json(
|
||||||
|
action: &str,
|
||||||
|
target: Option<&str>,
|
||||||
|
result: &commands::PluginsCommandResult,
|
||||||
|
report: &plugins::PluginRegistryReport,
|
||||||
|
) -> Value {
|
||||||
|
let failures = report.failures();
|
||||||
|
json!({
|
||||||
|
"kind": "plugin",
|
||||||
|
"action": action,
|
||||||
|
"target": target,
|
||||||
|
"status": if failures.is_empty() { "ok" } else { "degraded" },
|
||||||
|
"message": result.message,
|
||||||
|
"reload_runtime": result.reload_runtime,
|
||||||
|
"plugins": report.summaries().iter().map(plugin_summary_json).collect::<Vec<_>>(),
|
||||||
|
"load_failures": failures.iter().map(plugin_load_failure_json).collect::<Vec<_>>(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn plugin_summary_json(plugin: &plugins::PluginSummary) -> Value {
|
||||||
|
json!({
|
||||||
|
"id": &plugin.metadata.id,
|
||||||
|
"name": &plugin.metadata.name,
|
||||||
|
"version": &plugin.metadata.version,
|
||||||
|
"description": &plugin.metadata.description,
|
||||||
|
"kind": plugin.metadata.kind.to_string(),
|
||||||
|
"source": &plugin.metadata.source,
|
||||||
|
"enabled": plugin.enabled,
|
||||||
|
"lifecycle_state": plugin.lifecycle_state(),
|
||||||
|
"lifecycle": {
|
||||||
|
"configured": !plugin.lifecycle.is_empty(),
|
||||||
|
"init": {
|
||||||
|
"configured": !plugin.lifecycle.init.is_empty(),
|
||||||
|
"command_count": plugin.lifecycle.init.len(),
|
||||||
|
},
|
||||||
|
"shutdown": {
|
||||||
|
"configured": !plugin.lifecycle.shutdown.is_empty(),
|
||||||
|
"command_count": plugin.lifecycle.shutdown.len(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn plugin_load_failure_json(failure: &plugins::PluginLoadFailure) -> Value {
|
||||||
|
json!({
|
||||||
|
"plugin_root": failure.plugin_root.display().to_string(),
|
||||||
|
"kind": failure.kind.to_string(),
|
||||||
|
"source": &failure.source,
|
||||||
|
"lifecycle_state": "load_failed",
|
||||||
|
"error": failure.error().to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), Box<dyn std::error::Error>> {
|
fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let args: Vec<String> = env::args().skip(1).collect();
|
let args: Vec<String> = env::args().skip(1).collect();
|
||||||
match parse_args(&args)? {
|
match parse_args(&args)? {
|
||||||
@@ -5556,19 +5609,19 @@ impl LiveCli {
|
|||||||
let cwd = env::current_dir()?;
|
let cwd = env::current_dir()?;
|
||||||
let payload = plugins_command_payload_for(&cwd, action, target)?;
|
let payload = plugins_command_payload_for(&cwd, action, target)?;
|
||||||
match output_format {
|
match output_format {
|
||||||
CliOutputFormat::Text => println!("{}", payload.message),
|
CliOutputFormat::Text => println!("{}", result.message),
|
||||||
CliOutputFormat::Json => println!(
|
CliOutputFormat::Json => {
|
||||||
"{}",
|
let report = manager.installed_plugin_registry_report()?;
|
||||||
serde_json::to_string_pretty(&json!({
|
println!(
|
||||||
"kind": "plugin",
|
"{}",
|
||||||
"action": action.unwrap_or("list"),
|
serde_json::to_string_pretty(&plugin_command_json(
|
||||||
"target": target,
|
action.unwrap_or("list"),
|
||||||
"status": payload.status,
|
target,
|
||||||
"config_load_error": payload.config_load_error,
|
&result,
|
||||||
"message": payload.message,
|
&report,
|
||||||
"reload_runtime": payload.reload_runtime,
|
))?
|
||||||
}))?
|
);
|
||||||
),
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user