// ============================================
// date : 2026-05-20, Modifier : Marauder, task : 권한/플러그인 CLI/멀티 에이전트 진단 문구 추가
// date : 2026-05-21, Modifier : HoRi0506, task : 설치 점검 권고/재시작 문구 구분 보강
// ============================================
use crate::PUBLIC_ENTRY_LABEL;
use serde_json::Value;
fn config_surface_statuses_line(payload: &Value) -> Option<String> {
let surfaces = payload
.pointer("/configSurfaceReadiness/surfaces")
.and_then(Value::as_array)?;
let optional_missing_count = payload
.pointer("/configSurfaceReadiness/optional_missing_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let blocking = payload
.pointer("/configSurfaceReadiness/blocking")
.and_then(Value::as_bool)
.unwrap_or(true);
let default_backed = payload
.pointer("/configSurfaceReadiness/default_backed")
.and_then(Value::as_bool)
.unwrap_or(false);
let status_for = |surface_id: &str| {
surfaces
.iter()
.find(|surface| surface.get("surface").and_then(Value::as_str) == Some(surface_id))
.and_then(|surface| surface.get("status").and_then(Value::as_str))
.unwrap_or("unknown")
};
Some(format!(
"{} config surfaces: registry={} shared_config_version={} category_routing={} fallback_policy={} concurrency={} prompt_sections={} directory_rule_injection={} hook_settings={} lsp_runtime={} custom_agent_sync={} generated_defaults={} optional_missing={} default_backed={} blocking={}",
env!("CARGO_PKG_VERSION"),
status_for("registry"),
status_for("shared_config_version"),
status_for("category_routing"),
status_for("fallback_policy"),
status_for("concurrency"),
status_for("prompt_sections"),
status_for("directory_rule_injection"),
status_for("hook_settings"),
status_for("lsp_runtime"),
status_for("custom_agent_sync"),
status_for("generated_defaults_version"),
optional_missing_count,
default_backed,
blocking,
))
}
fn update_parity_line(payload: &Value) -> Option<String> {
let parity = payload
.get("updateParity")
.filter(|value| value.is_object())?;
let package_version = parity
.pointer("/package/version")
.and_then(Value::as_str)
.unwrap_or("unknown");
let binary_status = parity
.pointer("/package/binary_status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let shared_config_version = parity
.pointer("/shared_config_version/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let generated_defaults = parity
.pointer("/generated_defaults/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let plugin_cache = parity
.pointer("/plugin_cache/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let marketplace = parity
.pointer("/plugin_marketplace/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let cap_skill = parity
.pointer("/cap_skill/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let cap_continuity = parity
.pointer("/cap_continuity/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let custom_agents = parity
.pointer("/managed_custom_agents/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let role_defaults = parity
.pointer("/role_defaults/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let concurrency = parity
.pointer("/concurrency/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let hooks = parity
.pointer("/hooks/state")
.and_then(Value::as_str)
.unwrap_or("unknown");
let restart = parity
.pointer("/restart_guidance/restart_required")
.and_then(Value::as_bool)
.unwrap_or(false);
let restart_requirement = parity
.pointer("/restart_guidance/restart_requirement")
.and_then(Value::as_str)
.unwrap_or(if restart { "required" } else { "not-required" });
let cache_reload = parity
.pointer("/restart_guidance/cache_reload_required")
.and_then(Value::as_bool)
.unwrap_or(false);
let cache_reload_requirement = parity
.pointer("/restart_guidance/cache_reload_requirement")
.and_then(Value::as_str)
.unwrap_or(if cache_reload {
"required"
} else {
"not-required"
});
let guidance = parity
.pointer("/restart_guidance/summary")
.and_then(Value::as_str)
.unwrap_or("unknown");
Some(format!(
"Update parity: package={package_version} binary={binary_status} shared_config_version={shared_config_version} generated_defaults={generated_defaults} plugin_cache={plugin_cache} marketplace={marketplace} cap_skill={cap_skill} cap_continuity={cap_continuity} custom_agents={custom_agents} role_defaults={role_defaults} concurrency={concurrency} hooks={hooks} restart={restart} restart_requirement={restart_requirement} cache_reload={cache_reload} cache_reload_requirement={cache_reload_requirement} guidance=\"{guidance}\""
))
}
fn concurrency_surface(payload: &Value) -> Option<&Value> {
payload
.pointer("/configSurfaceReadiness/surfaces")
.and_then(Value::as_array)?
.iter()
.find(|surface| surface.get("surface").and_then(Value::as_str) == Some("concurrency"))
}
fn concurrency_readiness_label(status: &str) -> &'static str {
match status {
"current" => "ready",
"optional_missing" => "ready_with_defaults",
"stale" => "migration_recommended",
"missing" => "missing",
"conflict" => "conflict",
_ => "unknown",
}
}
fn concurrency_readiness_line(payload: &Value) -> Option<String> {
let explicit = payload
.get("concurrencyReadiness")
.filter(|value| value.is_object());
let surface = concurrency_surface(payload);
let status = explicit
.and_then(|value| value.get("status").and_then(Value::as_str))
.or_else(|| surface.and_then(|value| value.get("status").and_then(Value::as_str)))?;
let readiness = explicit
.and_then(|value| value.get("readiness").and_then(Value::as_str))
.unwrap_or_else(|| concurrency_readiness_label(status));
let source = explicit
.and_then(|value| value.get("source").and_then(Value::as_str))
.or_else(|| surface.and_then(|value| value.get("source").and_then(Value::as_str)))
.unwrap_or("configSurfaceReadiness.concurrency");
let summary = explicit
.and_then(|value| value.get("summary").and_then(Value::as_str))
.or_else(|| surface.and_then(|value| value.get("summary").and_then(Value::as_str)))
.unwrap_or("Concurrency config surface is unavailable.");
Some(format!(
"Concurrency readiness: status={status} readiness={readiness} source={source} summary=\"{summary}\""
))
}
fn config_setup_guidance_line(payload: &Value) -> Option<String> {
let guidance = payload.pointer("/configSurfaceReadiness/setup_guidance")?;
let dry_run = guidance
.get("dry_run")
.and_then(Value::as_str)
.unwrap_or("ccc setup --dry-run");
let rollback = guidance
.get("rollback")
.and_then(Value::as_str)
.unwrap_or("ccc setup --rollback-config <backup_path>");
let backup = guidance
.get("backup")
.and_then(Value::as_str)
.unwrap_or("unknown");
let restart = guidance
.get("restart")
.and_then(Value::as_str)
.unwrap_or("unknown");
Some(format!(
"Config setup safeguards: dry_run=\"{dry_run}\" backup={backup} rollback=\"{rollback}\" restart={restart}"
))
}
fn graph_context_readiness_line(payload: &Value) -> Option<String> {
let readiness = payload
.pointer("/graphContextReadiness/readiness")?
.as_str()?;
let graphify_state = payload
.pointer("/graphContextReadiness/graphify_state")
.and_then(Value::as_str)
.unwrap_or("fallback");
let setup_state = payload
.pointer("/graphContextReadiness/setup_policy/state")
.and_then(Value::as_str)
.unwrap_or("fallback");
let opt_in = payload
.pointer("/graphContextReadiness/opt_in")
.and_then(Value::as_bool)
.unwrap_or(false);
let check_install_status = payload
.pointer("/graphContextReadiness/check_install_status")
.and_then(Value::as_str)
.unwrap_or("warning");
let reason = payload
.pointer("/graphContextReadiness/reason")
.and_then(Value::as_str)
.unwrap_or("unknown");
let fallback = payload
.pointer("/graphContextReadiness/fallback")
.and_then(Value::as_str)
.or_else(|| {
payload
.pointer("/graphContextReadiness/fallback_when_unavailable")
.and_then(Value::as_str)
})
.unwrap_or("none");
Some(format!(
"Graph context: state={graphify_state} setup={setup_state} opt_in={opt_in} readiness={readiness} check_install={check_install_status} reason={reason} fallback={fallback} completion={}",
payload
.pointer("/graphContextReadiness/inventory_evidence/status")
.and_then(Value::as_str)
.unwrap_or("unknown")
))
}
fn lsp_server_availability_line(payload: &Value) -> Option<String> {
let lsp = payload
.get("lspRuntimeReadiness")
.filter(|value| value.is_object())?;
let server_summary = |server: &str| {
let available = lsp
.pointer(&format!("/language_servers/{server}/available"))
.and_then(Value::as_bool)
.unwrap_or(false);
let package_hint = lsp
.pointer(&format!("/language_servers/{server}/package_hint"))
.and_then(Value::as_str)
.or_else(|| {
lsp.pointer(&format!("/server_availability/{server}/package_hint"))
.and_then(Value::as_str)
})
.unwrap_or("unknown");
format!("{server}_available={available} {server}_package_hint=\"{package_hint}\"")
};
let fallback = lsp
.get("safe_fallback")
.and_then(Value::as_str)
.unwrap_or("no_lsp_runtime_requests_when_unavailable_or_deferred");
Some(format!(
"LSP servers: {} {} fallback={fallback}",
server_summary("rust"),
server_summary("typescript_javascript")
))
}
fn memory_readiness_line(payload: &Value) -> Option<String> {
let memory = payload
.get("memoryReadiness")
.filter(|value| value.is_object())?;
let status = memory
.get("available")
.and_then(Value::as_bool)
.map(|available| if available { "available" } else { "missing" })
.unwrap_or("unknown");
let configured = memory
.get("configured")
.and_then(Value::as_bool)
.unwrap_or(false);
let enabled = memory
.get("enabled")
.and_then(Value::as_bool)
.unwrap_or(false);
let stale = memory
.get("stale")
.and_then(Value::as_bool)
.unwrap_or(false);
let readiness = match (status, configured, enabled, stale) {
("missing", false, _, _) => "unconfigured",
("available", _, _, true) => "stale",
("available", true, true, false) => "ready",
("available", true, false, false) => "off",
("available", false, _, false) => "unconfigured",
("missing", true, _, _) => "unavailable",
_ => "unknown",
};
let install_status = match readiness {
"ready" => "ok",
"unconfigured" | "off" => "advisory",
"stale" | "unavailable" => "warning",
_ => "unknown",
};
let fallback = memory
.pointer("/tolaria/available")
.and_then(Value::as_bool)
.map(|enabled| {
if enabled {
"tolaria_mirror"
} else {
"workspace_store"
}
})
.unwrap_or_else(|| {
if configured {
"workspace_store"
} else {
"preview_before_write"
}
});
let reason = memory
.get("reason")
.and_then(Value::as_str)
.or_else(|| memory.pointer("/tolaria/reason").and_then(Value::as_str))
.unwrap_or("unknown");
let captain_instruction_status = memory
.get("captain_instruction_status")
.and_then(Value::as_str)
.unwrap_or("unavailable");
let negative_evidence_count = memory
.pointer("/negative_evidence/entry_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let ui_visual_evidence_count = memory
.pointer("/ui_visual_evidence/entry_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let ui_visual_optional = memory
.pointer("/ui_visual_evidence/optional")
.and_then(Value::as_bool)
.unwrap_or(true);
let oracle_read_only = memory
.pointer("/ui_visual_evidence/oracle_policy/oracle_read_only")
.and_then(Value::as_bool)
.unwrap_or(true);
let negative_categories = memory
.pointer("/negative_evidence/category_counts")
.and_then(Value::as_object)
.map(|counts| {
[
"repeated_wrong_claims",
"stale_runtime_proof",
"failed_validation",
"routing_drift",
"missing_evidence",
]
.iter()
.map(|category| {
let count = counts.get(*category).and_then(Value::as_u64).unwrap_or(0);
format!("{category}:{count}")
})
.collect::<Vec<_>>()
.join(",")
})
.unwrap_or_else(|| "none".to_string());
let prompt_injection = memory
.pointer("/negative_evidence/ordinary_prompt_injection")
.and_then(Value::as_bool)
.unwrap_or(false);
let runtime_parity_claimed = memory
.pointer("/negative_evidence/runtime_parity_policy/active_runtime_parity_claimed")
.and_then(Value::as_bool)
.unwrap_or(false);
let tolaria_status = memory
.pointer("/tolaria/available")
.and_then(Value::as_bool)
.map(|available| {
if available {
"available"
} else {
"unavailable"
}
})
.unwrap_or("unknown");
Some(format!(
"Memory readiness: status={status} install_status={install_status} readiness={readiness} fallback={fallback} configured={configured} enabled={enabled} stale={stale} tolaria={tolaria_status} captain_instruction_status={captain_instruction_status} negative_evidence={negative_evidence_count} negative_categories={negative_categories} prompt_injection={prompt_injection} runtime_parity_claimed={runtime_parity_claimed} ui_visual_evidence={ui_visual_evidence_count} ui_visual_optional={ui_visual_optional} oracle_read_only={oracle_read_only} reason={reason}"
))
}
fn hooks_readiness_line(payload: &Value) -> Option<String> {
let hooks = payload
.get("hooksReadiness")
.filter(|value| value.is_object())?;
let user_prompt_submit = hooks.pointer("/per_hook/UserPromptSubmit");
let user_prompt_submit_text = user_prompt_submit
.map(|hook| {
let warning = if hook
.get("state")
.and_then(Value::as_str)
== Some("trusted_but_disabled")
{
" warning=trusted_hash present but enabled=true missing_or_false; inactive until enabled=true and restart"
} else {
""
};
format!(
" UserPromptSubmit={} state_key={} asset_present={} source_loadable={} plugin_hooks_feature_enabled={} trusted_hash_present={} enabled_flag_present={} active_after_restart={}{}",
hook.get("state")
.and_then(Value::as_str)
.unwrap_or("unknown"),
hook.get("state_key")
.and_then(Value::as_str)
.unwrap_or("unknown"),
hook.get("asset_present")
.and_then(Value::as_bool)
.unwrap_or(false),
hook.get("source_loadable")
.and_then(Value::as_bool)
.unwrap_or(false),
hook.get("plugin_hooks_feature_enabled")
.and_then(Value::as_bool)
.unwrap_or(false),
hook.get("trusted_hash_present")
.and_then(Value::as_bool)
.unwrap_or(false),
hook.get("enabled_flag_present")
.and_then(Value::as_bool)
.unwrap_or(false),
hook.get("active_after_restart")
.and_then(Value::as_bool)
.unwrap_or(false),
warning
)
})
.unwrap_or_default();
let schema_status = hooks
.pointer("/schema_compatibility/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let schema_scope = hooks
.pointer("/schema_compatibility/validator_scope")
.and_then(Value::as_str)
.unwrap_or("unknown");
let schema_events = hooks
.pointer("/schema_compatibility/checks")
.and_then(Value::as_array)
.map(|checks| {
checks
.iter()
.map(|check| {
format!(
"{}:{}={}",
check
.get("event")
.and_then(Value::as_str)
.unwrap_or("unknown"),
check
.get("output_schema")
.and_then(Value::as_str)
.unwrap_or("unknown"),
check
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown")
)
})
.collect::<Vec<_>>()
.join(",")
})
.unwrap_or_else(|| "unknown".to_string());
Some(format!(
"Codex hooks: state={} readiness={} runtime={} fallback={} schema_compatibility={} schema_scope={} schema_events=[{}] reason={}{}",
hooks
.get("state")
.and_then(Value::as_str)
.unwrap_or("unknown"),
hooks
.get("readiness")
.and_then(Value::as_str)
.unwrap_or("unknown"),
hooks
.get("runtime_path")
.and_then(Value::as_str)
.unwrap_or("ccc_fallback"),
hooks
.get("fallback")
.and_then(Value::as_str)
.unwrap_or("ccc_cli_mcp_status_fan_in"),
schema_status,
schema_scope,
schema_events,
hooks
.get("reason")
.and_then(Value::as_str)
.unwrap_or("unknown"),
user_prompt_submit_text
))
}
fn command_budget_route_modularity_line(payload: &Value) -> Option<String> {
let check = payload
.get("commandBudgetRouteModularity")
.filter(|value| value.is_object())?;
let status = check
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let cap_lines = check
.pointer("/cap_skill/line_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let cap_line_max = check
.pointer("/cap_skill/line_max")
.and_then(Value::as_u64)
.unwrap_or(0);
let cap_words = check
.pointer("/cap_skill/word_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let cap_word_max = check
.pointer("/cap_skill/word_max")
.and_then(Value::as_u64)
.unwrap_or(0);
let ssl_count = check
.get("ssl_manifest_checks")
.and_then(Value::as_array)
.map(Vec::len)
.unwrap_or(0);
let route_status = check
.pointer("/route_modularity/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let problems = check
.get("problem_count")
.and_then(Value::as_u64)
.unwrap_or(0);
Some(format!(
"Command budget / route modularity: status={status} cap_lines={cap_lines}/{cap_line_max} cap_words={cap_words}/{cap_word_max} ssl_manifests={ssl_count} route_modularity={route_status} problems={problems}"
))
}
fn plugin_cli_parity_line(payload: &Value) -> Option<String> {
let parity = payload
.get("pluginCliParity")
.filter(|value| value.is_object())?;
Some(format!(
"Plugin CLI parity: status={} marketplace_mentions_ccc={} plugin_mentions_ccc={} installed={} enabled={} command=\"codex plugin list\"",
parity
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown"),
parity
.get("marketplace_mentions_ccc")
.and_then(Value::as_bool)
.unwrap_or(false),
parity
.get("plugin_mentions_ccc")
.and_then(Value::as_bool)
.unwrap_or(false),
parity
.get("plugin_installed")
.and_then(Value::as_bool)
.unwrap_or(false),
parity
.get("plugin_enabled")
.and_then(Value::as_bool)
.unwrap_or(false),
))
}
fn permission_profile_line(payload: &Value) -> Option<String> {
let profile = payload
.get("permissionProfile")
.filter(|value| value.is_object())?;
let root_count = profile
.get("effective_workspace_roots")
.and_then(Value::as_array)
.map(Vec::len)
.unwrap_or(0);
Some(format!(
"Permission/profile roots: status={} role={} profile={} sandbox={} effective_roots={} host_sandbox_reported_by_codex={}",
profile
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown"),
profile
.get("current_role")
.and_then(Value::as_str)
.unwrap_or("unknown"),
profile
.get("configured_profile")
.and_then(Value::as_str)
.unwrap_or("null"),
profile
.get("sandbox_mode")
.and_then(Value::as_str)
.unwrap_or("unknown"),
root_count,
profile
.get("host_sandbox_reported_by_codex")
.and_then(Value::as_bool)
.unwrap_or(false),
))
}
fn multi_agent_runtime_contract_line(payload: &Value) -> Option<String> {
let contract = payload
.get("multiAgentRuntimeContract")
.filter(|value| value.is_object())?;
Some(format!(
"Multi-agent runtime: status={} namespace={} description_cap={}/{} service_tier_overrides={} fan_in={}",
contract
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown"),
contract
.get("tool_namespace")
.and_then(Value::as_str)
.unwrap_or("ccc"),
contract
.get("model_visible_description_cap_chars")
.and_then(Value::as_u64)
.unwrap_or(0),
contract
.get("hard_description_cap_chars")
.and_then(Value::as_u64)
.unwrap_or(0),
contract
.get("service_tier_override_count")
.and_then(Value::as_u64)
.unwrap_or(0),
contract
.pointer("/fan_in_implications/fan_in_barrier_semantics")
.and_then(Value::as_str)
.unwrap_or("unknown"),
))
}
fn setup_migration_deltas_line(payload: &Value) -> Option<String> {
let deltas = payload
.get("setupMigrationDeltas")
.or_else(|| {
payload
.pointer("/installSurfaceVisibility/components/ccc_config/setup_migration_deltas")
})
.filter(|value| value.is_object())?;
let status = deltas
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let action = deltas
.get("action_status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let changed = deltas
.get("changed_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let migrated = deltas
.get("migrated_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let backfilled = deltas
.get("backfilled_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let preserved_overrides = deltas
.get("preserved_override_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let family_statuses = deltas
.get("families")
.and_then(Value::as_array)
.map(|families| {
families
.iter()
.map(|family| {
format!(
"{}={}",
family
.get("family")
.and_then(Value::as_str)
.unwrap_or("unknown"),
family
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown")
)
})
.collect::<Vec<_>>()
.join(" ")
})
.unwrap_or_default();
Some(format!(
"Setup migration deltas: status={status} action={action} changed={changed} migrated={migrated} backfilled={backfilled} preserved_overrides={preserved_overrides} {family_statuses}"
))
}
fn optional_string<'a>(value: &'a Value, pointer: &str) -> &'a str {
value
.pointer(pointer)
.and_then(Value::as_str)
.unwrap_or("unknown")
}
pub(crate) fn create_check_install_text(payload: &Value) -> String {
let status = payload
.get("status")
.and_then(Value::as_str)
.unwrap_or("warning");
let version = payload
.get("packageVersion")
.and_then(Value::as_str)
.unwrap_or(env!("CARGO_PKG_VERSION"));
let entry = payload
.get("publicEntryLabel")
.and_then(Value::as_str)
.unwrap_or(PUBLIC_ENTRY_LABEL);
let registration = payload
.get("registrationStatus")
.and_then(Value::as_str)
.unwrap_or("unknown");
let config = payload
.get("configStatus")
.and_then(Value::as_str)
.unwrap_or_else(|| {
if payload
.get("configExists")
.and_then(Value::as_bool)
.unwrap_or(false)
{
"canonical-current"
} else {
"missing"
}
});
let config_action = payload
.get("configActionStatus")
.and_then(Value::as_str)
.unwrap_or("skipped");
let config_restart = payload
.get("configRestartStatus")
.and_then(Value::as_str)
.unwrap_or("not-required");
let config_backup = payload
.get("configBackupStatus")
.and_then(Value::as_str)
.unwrap_or("not-required");
let skill = payload
.get("capSkillStatus")
.and_then(Value::as_str)
.unwrap_or("unknown");
let surface = payload
.pointer("/installSurfaceVisibility/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let surface_restart = payload
.pointer("/installSurfaceVisibility/restart_required")
.and_then(Value::as_bool)
.map(|required| if required { "required" } else { "not-required" })
.unwrap_or("unknown");
let custom_agents = payload
.get("customAgentStatus")
.and_then(Value::as_str)
.unwrap_or("unknown");
let registry_health = payload
.pointer("/skillRegistryHealth/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let registry_available = payload
.pointer("/skillRegistryHealth/available_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let registry_total = payload
.pointer("/skillRegistryHealth/agent_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let contract_status = payload
.pointer("/executionContractRegistry/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let contract_count = payload
.pointer("/executionContractRegistry/role_count")
.and_then(Value::as_u64)
.unwrap_or(0);
let plugin_status = payload
.pointer("/pluginDiscovery/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let plugin_severity = payload
.pointer("/pluginDiscovery/diagnostic_severity")
.and_then(Value::as_str)
.unwrap_or("unknown");
let plugin_missing = payload
.pointer("/pluginDiscovery/missing")
.and_then(Value::as_array)
.map(|values| {
values
.iter()
.filter_map(Value::as_str)
.collect::<Vec<_>>()
.join(",")
})
.unwrap_or_default();
let plugin_stale = payload
.pointer("/pluginDiscovery/stale")
.and_then(Value::as_array)
.map(|values| {
values
.iter()
.filter_map(Value::as_str)
.collect::<Vec<_>>()
.join(",")
})
.unwrap_or_default();
let discovery_surface_summary = payload
.pointer("/pluginDiscoverySurfaces/summary")
.and_then(Value::as_str)
.map(str::to_string)
.or_else(|| {
let marketplace = payload
.pointer("/pluginMarketplaceDiscovery/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let stale_paths = payload
.pointer("/legacyBundleCleanup/stalePathCount")
.and_then(Value::as_u64)
.unwrap_or(0);
let active_restart = if payload
.pointer("/installSurfaceVisibility/restart_required")
.and_then(Value::as_bool)
.unwrap_or(false)
{
"required"
} else {
"not-required"
};
let cache_reload = if payload
.pointer("/pluginDiscovery/restart_required")
.and_then(Value::as_bool)
.unwrap_or(false)
|| payload
.pointer("/pluginMarketplaceDiscovery/restart_required")
.and_then(Value::as_bool)
.unwrap_or(false)
{
"required"
} else {
"not-required"
};
Some(format!(
"Discovery surfaces: status={plugin_status} marketplace={marketplace} plugin_cache={plugin_status} cap_skill={skill} stale_paths={stale_paths} restart={active_restart} cache_reload={cache_reload}"
))
})
.unwrap_or_else(|| {
"Discovery surfaces: status=unknown marketplace=unknown plugin_cache=unknown cap_skill=unknown stale_paths=0 restart=unknown cache_reload=unknown".to_string()
});
let cap_continuity_status = payload
.pointer("/capContinuity/status")
.and_then(Value::as_str)
.unwrap_or("unknown");
let cap_continuity_resume = payload
.pointer("/capContinuity/resume_command_template")
.and_then(Value::as_str)
.unwrap_or("$cap continue <run_id>");
let cap_continuity_path = payload
.pointer("/capContinuity/cap_skill_path")
.and_then(Value::as_str)
.unwrap_or("unknown");
let cap_auto_restart = payload
.pointer("/capContinuity/automatic_restart")
.and_then(Value::as_bool)
.unwrap_or(false);
let cap_slash_execution = payload
.pointer("/capContinuity/slash_command_execution")
.and_then(Value::as_bool)
.unwrap_or(false);
let mut lines = vec![
format!(
"CCC install check: status={status} version={version} entry={entry} registration={registration} config={config} config_action={config_action} config_restart={config_restart} skill={skill}"
),
format!(
"Install surface: status={surface} restart={surface_restart} mcp={registration} skill={skill} custom_agents={custom_agents}"
),
format!(
"Skill registry: status={registry_health} available={registry_available}/{registry_total}"
),
format!(
"Plugin discovery: status={plugin_status} severity={plugin_severity} missing=[{plugin_missing}] stale=[{plugin_stale}]"
),
discovery_surface_summary,
format!(
"$cap continuity: status={cap_continuity_status} path={cap_continuity_path} resume=\"{cap_continuity_resume}\" automatic_restart={cap_auto_restart} slash_execution={cap_slash_execution}"
),
format!("Execution contracts: status={contract_status} roles={contract_count}"),
];
if let Some(line) = config_surface_statuses_line(payload) {
lines.push(line);
}
if let Some(line) = update_parity_line(payload) {
lines.push(line);
}
if let Some(line) = concurrency_readiness_line(payload) {
lines.push(line);
}
if let Some(line) = setup_migration_deltas_line(payload) {
lines.push(line);
}
if let Some(line) = graph_context_readiness_line(payload) {
lines.push(line);
}
if let Some(lsp) = payload
.get("lspRuntimeReadiness")
.filter(|value| value.is_object())
{
lines.push(format!(
"LSP runtime: readiness={} execution={} usable={} completion={} blocking=false",
lsp.get("readiness")
.and_then(Value::as_str)
.unwrap_or("unknown"),
lsp.get("runtime_execution")
.and_then(Value::as_str)
.unwrap_or("unknown"),
lsp.get("surface_usable")
.and_then(Value::as_bool)
.unwrap_or(false),
lsp.pointer("/inventory_evidence/status")
.and_then(Value::as_str)
.unwrap_or("unknown")
));
}
if let Some(line) = lsp_server_availability_line(payload) {
lines.push(line);
}
if let Some(line) = memory_readiness_line(payload) {
lines.push(line);
}
if let Some(line) = hooks_readiness_line(payload) {
lines.push(line);
}
if let Some(line) = command_budget_route_modularity_line(payload) {
lines.push(line);
}
if let Some(line) = plugin_cli_parity_line(payload) {
lines.push(line);
}
if let Some(line) = permission_profile_line(payload) {
lines.push(line);
}
if let Some(line) = multi_agent_runtime_contract_line(payload) {
lines.push(line);
}
if let Some(diagnostics) = payload
.get("pathShadowDiagnostics")
.filter(|value| value.is_object())
{
lines.push(format!(
"PATH shadowing: severity={} advisory_only={} classification={} shell_ccc={} cargo_candidate={} cargo_version={} current_exe={} legacy_binary={} legacy_shadows_cargo={}",
optional_string(diagnostics, "/diagnostic_severity"),
diagnostics
.get("advisory_only")
.and_then(Value::as_bool)
.unwrap_or(false),
optional_string(diagnostics, "/legacyPathClassification"),
optional_string(diagnostics, "/shellResolvedCcc"),
optional_string(diagnostics, "/cargoBinaryCandidate"),
optional_string(diagnostics, "/cargoBinaryCandidateVersion"),
optional_string(diagnostics, "/currentExe"),
optional_string(diagnostics, "/legacyBinaryCandidate"),
diagnostics
.get("legacyShadowsCargo")
.and_then(Value::as_bool)
.unwrap_or(false)
));
lines.push(
diagnostics
.get("summary")
.and_then(Value::as_str)
.unwrap_or("No PATH shadowing summary available.")
.to_string(),
);
if diagnostics.get("status").and_then(Value::as_str) == Some("warning") {
lines.push(
diagnostics
.get("recommendation")
.and_then(Value::as_str)
.unwrap_or(
"Run ~/.cargo/bin/ccc setup, put ~/.cargo/bin earlier in PATH, or demote the legacy ccc binary.",
)
.to_string(),
);
}
}
if let Some(cleanup) = payload
.get("legacyDirectRegistrationCleanup")
.filter(|value| value.is_object())
{
lines.push(format!(
"Legacy cleanup: status={} direct_mcp={} standalone_cap={}",
cleanup
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown"),
cleanup
.get("legacy_direct_mcp_servers_ccc_present")
.and_then(Value::as_bool)
.unwrap_or(false),
cleanup
.get("standalone_skills_cap_present")
.and_then(Value::as_bool)
.unwrap_or(false)
));
}
if let Some(cleanup) = payload
.get("legacyBundleCleanup")
.filter(|value| value.is_object())
{
let stale_paths = cleanup
.get("stalePaths")
.and_then(Value::as_array)
.map(|values| {
values
.iter()
.filter_map(Value::as_str)
.collect::<Vec<_>>()
.join(", ")
})
.unwrap_or_default();
lines.push(format!(
"Legacy bundle cleanup: status={} severity={} advisory_only={} blocking={} stale_paths={}",
cleanup
.get("status")
.and_then(Value::as_str)
.unwrap_or("unknown"),
cleanup
.get("diagnostic_severity")
.and_then(Value::as_str)
.unwrap_or("unknown"),
cleanup
.get("advisory_only")
.and_then(Value::as_bool)
.unwrap_or(false),
cleanup
.get("blocking")
.and_then(Value::as_bool)
.unwrap_or(false),
cleanup
.get("stalePathCount")
.and_then(Value::as_u64)
.unwrap_or(0)
));
if !stale_paths.is_empty() {
lines.push(format!("Legacy bundle cleanup paths: {stale_paths}"));
}
}
lines.extend([
format!(
"Expected MCP launch: {} {}",
payload
.get("expectedLaunchCommand")
.and_then(Value::as_str)
.unwrap_or("unknown"),
payload
.get("expectedLaunchArgs")
.and_then(Value::as_array)
.map(|values| values
.iter()
.filter_map(Value::as_str)
.collect::<Vec<_>>()
.join(" "))
.unwrap_or_default()
),
payload
.get("registrationSummary")
.and_then(Value::as_str)
.unwrap_or("No registration summary available.")
.to_string(),
payload
.get("configSummary")
.and_then(Value::as_str)
.unwrap_or("No config summary available.")
.to_string(),
format!("Config backup: status={config_backup}"),
]);
if let Some(line) = config_setup_guidance_line(payload) {
lines.push(line);
}
lines.extend([
payload
.get("capSkillSummary")
.and_then(Value::as_str)
.unwrap_or("No $cap summary available.")
.to_string(),
payload
.get("customAgentSummary")
.and_then(Value::as_str)
.unwrap_or("No custom-agent summary available.")
.to_string(),
]);
lines.join("\n")
}