| 1277 | |
| 1278 | |
| 1279 | def _print_routing_config(payload: dict[str, object], *, as_json: bool = False) -> None: |
| 1280 | if as_json: |
| 1281 | print(json.dumps(payload, indent=2)) |
| 1282 | return |
| 1283 | print(" Routing Config:") |
| 1284 | print(f" Source: {payload.get('source', 'local-file')}") |
| 1285 | print(f" Editable: {'yes' if payload.get('editable', False) else 'no'}") |
| 1286 | print(f" Default: {payload.get('default_mode', 'auto')}") |
| 1287 | modes = payload.get("modes", {}) |
| 1288 | if not isinstance(modes, dict): |
| 1289 | return |
| 1290 | for mode_name in ("auto", "fast", "best"): |
| 1291 | mode_payload = modes.get(mode_name) |
| 1292 | if not isinstance(mode_payload, dict): |
| 1293 | continue |
| 1294 | tiers = mode_payload.get("tiers", {}) |
| 1295 | if not isinstance(tiers, dict): |
| 1296 | continue |
| 1297 | print(f"\n {mode_name}:") |
| 1298 | for tier_name in ("SIMPLE", "MEDIUM", "COMPLEX"): |
| 1299 | row = tiers.get(tier_name) |
| 1300 | if not isinstance(row, dict): |
| 1301 | continue |
| 1302 | primary = str(row.get("primary", "")) |
| 1303 | fallback = row.get("fallback", []) |
| 1304 | overridden = bool(row.get("overridden", False)) |
| 1305 | selection_mode = str(row.get("selection_mode", "adaptive")) |
| 1306 | suffix = " [override]" if overridden else "" |
| 1307 | label = primary or "Discovery-managed" |
| 1308 | print(f" {tier_name:<10} {label}{suffix}") |
| 1309 | print(f" strategy: {selection_mode}") |
| 1310 | if isinstance(fallback, list) and fallback: |
| 1311 | print(f" fallback: {', '.join(str(item) for item in fallback)}") |
| 1312 | |
| 1313 | |
| 1314 | def _cmd_config(args: list[str]) -> None: |