feat(doctor): add legend line and --json output (#348)

The ok/warn/off symbols had no explanation for non-technical users;
--json gives agents and scripts a machine-readable health check.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pnant
2026-06-10 16:00:20 +08:00
committed by GitHub
parent 7015b08063
commit 853e5190e4
3 changed files with 11 additions and 1643 deletions
+10 -3
View File
@@ -89,7 +89,9 @@ def main():
help="Auto-extract ALL platform cookies from browser (chrome/firefox/edge/brave/opera)") help="Auto-extract ALL platform cookies from browser (chrome/firefox/edge/brave/opera)")
# ── doctor ── # ── doctor ──
sub.add_parser("doctor", help="Check platform availability") p_doctor = sub.add_parser("doctor", help="Check platform availability")
p_doctor.add_argument("--json", action="store_true",
help="Output machine-readable JSON instead of the text report")
# ── uninstall ── # ── uninstall ──
p_uninstall = sub.add_parser("uninstall", help="Remove all Agent Reach config, tokens, and skill files") p_uninstall = sub.add_parser("uninstall", help="Remove all Agent Reach config, tokens, and skill files")
@@ -141,7 +143,7 @@ def main():
sys.exit(0) sys.exit(0)
if args.command == "doctor": if args.command == "doctor":
_cmd_doctor() _cmd_doctor(args)
elif args.command == "check-update": elif args.command == "check-update":
_cmd_check_update() _cmd_check_update()
elif args.command == "watch": elif args.command == "watch":
@@ -1335,7 +1337,7 @@ def _cmd_uninstall(args):
print(" npm uninstall -g undici") print(" npm uninstall -g undici")
def _cmd_doctor(): def _cmd_doctor(args=None):
from agent_reach.config import Config from agent_reach.config import Config
from agent_reach.doctor import check_all, format_report from agent_reach.doctor import check_all, format_report
try: try:
@@ -1344,6 +1346,11 @@ def _cmd_doctor():
rprint = print rprint = print
config = Config() config = Config()
results = check_all(config) results = check_all(config)
if args is not None and getattr(args, "json", False):
print(json.dumps(results, ensure_ascii=False, indent=2))
return
rprint(format_report(results)) rprint(format_report(results))
# Auto-install skill if not already present (fixes #154) # Auto-install skill if not already present (fixes #154)
+1
View File
@@ -34,6 +34,7 @@ def format_report(results: Dict[str, dict]) -> str:
lines = [] lines = []
lines.append("[bold cyan]Agent Reach 状态[/bold cyan]") lines.append("[bold cyan]Agent Reach 状态[/bold cyan]")
lines.append("[cyan]" + "=" * 40 + "[/cyan]") lines.append("[cyan]" + "=" * 40 + "[/cyan]")
lines.append("图例:[green]✅[/green] 可用 [yellow][!][/yellow] 已装但需配置/登录 [red][X][/red] 未安装")
ok_count = sum(1 for r in results.values() if r["status"] == "ok") ok_count = sum(1 for r in results.values() if r["status"] == "ok")
total = len(results) total = len(results)
Generated
-1640
View File
File diff suppressed because it is too large Load Diff