Keep doctor help machine-discoverable locally (#3184)

Doctor help was already on the local help path in current source, but the exact #702 dogfood surface lacked a focused guard and the JSON help envelope was still too prose-oriented for wrappers. Strengthen the JSON contract while preserving text help.\n\nConstraint: Preserve unrelated dirty rust/Cargo.lock from prior #701 work.\nRejected: Starting runtime/provider/session to inspect doctor semantics | help must be local and credential-free.\nConfidence: high\nScope-risk: narrow\nDirective: Keep doctor help routed through parse_local_help_action and print_help_topic; do not call run_doctor for --help.\nTested: cargo test --manifest-path rust/Cargo.toml -p rusty-claude-cli --test output_format_contract doctor_help -- --nocapture; cargo test --manifest-path rust/Cargo.toml -p rusty-claude-cli --test output_format_contract help -- --nocapture; cargo fmt --manifest-path rust/Cargo.toml --all -- --check; cargo check --manifest-path rust/Cargo.toml -p rusty-claude-cli; timeout 5s cargo run -q --bin claw -- --output-format json doctor --help; timeout 5s cargo run -q --bin claw -- doctor --help.\nNot-tested: full workspace test suite.
This commit is contained in:
Bellman
2026-05-28 13:31:39 +09:00
committed by GitHub
parent 9ac66cbeb3
commit 73d8d6e638
3 changed files with 98 additions and 0 deletions

View File

@@ -7885,10 +7885,51 @@ fn render_export_help_json() -> serde_json::Value {
})
}
fn render_doctor_help_json() -> serde_json::Value {
json!({
"kind": "help",
"action": "help",
"status": "ok",
"topic": "doctor",
"command": "doctor",
"schema_version": "1.0",
"usage": "claw doctor [--output-format <format>]",
"purpose": "diagnose local auth, config, workspace, sandbox, boot preflight, and build metadata",
"formats": ["text", "json"],
"local_only": true,
"requires_credentials": false,
"requires_provider_request": false,
"requires_session_resume": false,
"mutates_workspace": false,
"output_fields": ["kind", "action", "status", "message", "report", "has_failures", "summary", "checks"],
"check_names": ["auth", "config", "install source", "workspace", "boot preflight", "sandbox", "system"],
"status_values": ["ok", "warn", "fail"],
"options": [
{
"name": "--output-format",
"value": "<format>",
"values": ["text", "json"],
"default": "text",
"description": "format for the doctor report or help envelope"
},
{
"name": "--help",
"aliases": ["-h"],
"description": "show help for the doctor command without running diagnostics"
}
],
"related": ["/doctor", "claw --resume latest /doctor"],
"message": render_help_topic(LocalHelpTopic::Doctor),
})
}
fn render_help_topic_json(topic: LocalHelpTopic) -> serde_json::Value {
if topic == LocalHelpTopic::Export {
return render_export_help_json();
}
if topic == LocalHelpTopic::Doctor {
return render_doctor_help_json();
}
json!({
"kind": "help",