Commit 78e068b
fix: support non-interactive hack global trust and hack doctor --fix
Field report: `hack global trust` presented a clack select/confirm an
agent couldn't drive without a TTY, and `hack doctor --fix` opened a
guided remediation flow with no non-interactive path at all — it never
imported the interactivity convention (src/lib/interactivity.ts) and
routed every prompt through a local confirmOrThrow() wrapper around raw
clack confirm()/isCancel(), which would hang or misbehave under
HACK_NO_INTERACTIVE.
hack global trust (src/commands/global.ts):
- ensureMacTrustCaddyLocalCa's confirmSafe flips from "decline" to
"accept-default" so non-interactive runs proceed with the documented
default (trust), per the command's whole purpose.
- Before running `sudo security add-trusted-cert`, check `sudo -n true`
first; if sudo would prompt for a password, skip the keychain step
with a note instead of hanging.
- globalTrust() now prepares the host TLS trust env (bundle + launchctl
setenv for Bun/Node/curl/git) regardless of whether the System
keychain step ran, since browser trust and CLI-tool trust are
independent — previously a declined/skipped keychain step silently
skipped the trust-env write too.
hack doctor --fix (src/commands/doctor.ts):
- Replaced confirmOrThrow (raw clack confirm/isCancel, no non-interactive
handling) and two more raw confirm()/isCancel() call sites with
doctorConfirm(), built on confirmSafe.
- Safe remediations (stale daemon pid/socket cleanup, docker network
create, mutagen install, tickets git repair, regenerating managed
Caddy/CoreDNS files, legacy env file cleanup) use "accept-default" so
they apply automatically under --no-interactive.
- Destructive/system-level steps (macOS System keychain repair via
`hack global trust`, dnsmasq sudo restart + DNS cache flush) use
"decline" and print a single summary note listing what was skipped
and the interactive command to run them.
- Fixed a latent bug: plain `--fix` (without --migrate-env-config) was
passing `migrateEnvConfig: true` to runDoctorFix whenever
`args.options.fix` was set, unconditionally running env-migration
prompts; it now only migrates when --migrate-env-config is passed.
Tests: tests/global-command.macos.test.ts covers global trust under
--no-interactive with passwordless and password-required sudo, plus an
existing decline-path test updated for the trust-env/keychain
decoupling. New tests/doctor-fix-noninteractive.test.ts covers a
stale-daemon-pid fixture reaching the safe repair without prompting and
the mac-keychain destructive step being skipped and reported.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent c3958bb commit 78e068b
4 files changed
Lines changed: 570 additions & 40 deletions
File tree
- src/commands
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
604 | 608 | | |
605 | 609 | | |
606 | 610 | | |
607 | | - | |
| 611 | + | |
608 | 612 | | |
609 | 613 | | |
610 | 614 | | |
| |||
2359 | 2363 | | |
2360 | 2364 | | |
2361 | 2365 | | |
| 2366 | + | |
2362 | 2367 | | |
2363 | | - | |
| 2368 | + | |
2364 | 2369 | | |
2365 | 2370 | | |
2366 | 2371 | | |
| |||
2408 | 2413 | | |
2409 | 2414 | | |
2410 | 2415 | | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
2411 | 2437 | | |
2412 | 2438 | | |
2413 | 2439 | | |
| |||
2457 | 2483 | | |
2458 | 2484 | | |
2459 | 2485 | | |
2460 | | - | |
| 2486 | + | |
2461 | 2487 | | |
2462 | 2488 | | |
2463 | 2489 | | |
| |||
2493 | 2519 | | |
2494 | 2520 | | |
2495 | 2521 | | |
2496 | | - | |
| 2522 | + | |
2497 | 2523 | | |
2498 | 2524 | | |
2499 | 2525 | | |
| |||
2544 | 2570 | | |
2545 | 2571 | | |
2546 | 2572 | | |
2547 | | - | |
| 2573 | + | |
2548 | 2574 | | |
2549 | 2575 | | |
2550 | 2576 | | |
| |||
2592 | 2618 | | |
2593 | 2619 | | |
2594 | 2620 | | |
2595 | | - | |
| 2621 | + | |
2596 | 2622 | | |
2597 | 2623 | | |
2598 | 2624 | | |
| |||
2794 | 2820 | | |
2795 | 2821 | | |
2796 | 2822 | | |
2797 | | - | |
| 2823 | + | |
2798 | 2824 | | |
2799 | 2825 | | |
2800 | 2826 | | |
| |||
2804 | 2830 | | |
2805 | 2831 | | |
2806 | 2832 | | |
2807 | | - | |
| 2833 | + | |
2808 | 2834 | | |
2809 | 2835 | | |
2810 | 2836 | | |
| |||
2850 | 2876 | | |
2851 | 2877 | | |
2852 | 2878 | | |
2853 | | - | |
| 2879 | + | |
2854 | 2880 | | |
2855 | 2881 | | |
2856 | 2882 | | |
| |||
2873 | 2899 | | |
2874 | 2900 | | |
2875 | 2901 | | |
2876 | | - | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
2877 | 2915 | | |
2878 | 2916 | | |
| 2917 | + | |
2879 | 2918 | | |
2880 | | - | |
| 2919 | + | |
2881 | 2920 | | |
2882 | 2921 | | |
| 2922 | + | |
2883 | 2923 | | |
2884 | | - | |
2885 | | - | |
| 2924 | + | |
| 2925 | + | |
2886 | 2926 | | |
2887 | 2927 | | |
2888 | 2928 | | |
2889 | 2929 | | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
2890 | 2946 | | |
2891 | 2947 | | |
2892 | 2948 | | |
| |||
2899 | 2955 | | |
2900 | 2956 | | |
2901 | 2957 | | |
2902 | | - | |
| 2958 | + | |
2903 | 2959 | | |
2904 | 2960 | | |
2905 | 2961 | | |
| |||
2910 | 2966 | | |
2911 | 2967 | | |
2912 | 2968 | | |
2913 | | - | |
| 2969 | + | |
2914 | 2970 | | |
2915 | 2971 | | |
2916 | 2972 | | |
| |||
2919 | 2975 | | |
2920 | 2976 | | |
2921 | 2977 | | |
2922 | | - | |
| 2978 | + | |
2923 | 2979 | | |
2924 | 2980 | | |
2925 | 2981 | | |
| |||
2969 | 3025 | | |
2970 | 3026 | | |
2971 | 3027 | | |
2972 | | - | |
| 3028 | + | |
2973 | 3029 | | |
2974 | 3030 | | |
2975 | 3031 | | |
| |||
3041 | 3097 | | |
3042 | 3098 | | |
3043 | 3099 | | |
3044 | | - | |
| 3100 | + | |
3045 | 3101 | | |
3046 | 3102 | | |
3047 | 3103 | | |
| |||
3063 | 3119 | | |
3064 | 3120 | | |
3065 | 3121 | | |
3066 | | - | |
| 3122 | + | |
3067 | 3123 | | |
3068 | | - | |
| 3124 | + | |
3069 | 3125 | | |
| 3126 | + | |
3070 | 3127 | | |
3071 | 3128 | | |
3072 | 3129 | | |
| |||
3131 | 3188 | | |
3132 | 3189 | | |
3133 | 3190 | | |
3134 | | - | |
3135 | | - | |
| 3191 | + | |
| 3192 | + | |
3136 | 3193 | | |
| 3194 | + | |
3137 | 3195 | | |
3138 | | - | |
3139 | | - | |
3140 | | - | |
3141 | 3196 | | |
3142 | 3197 | | |
3143 | 3198 | | |
| |||
3330 | 3385 | | |
3331 | 3386 | | |
3332 | 3387 | | |
3333 | | - | |
| 3388 | + | |
3334 | 3389 | | |
3335 | 3390 | | |
3336 | 3391 | | |
3337 | | - | |
3338 | | - | |
3339 | | - | |
3340 | 3392 | | |
3341 | 3393 | | |
3342 | 3394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
2724 | 2727 | | |
2725 | 2728 | | |
2726 | 2729 | | |
2727 | | - | |
2728 | | - | |
2729 | | - | |
2730 | | - | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
2731 | 2743 | | |
2732 | 2744 | | |
2733 | 2745 | | |
| |||
3330 | 3342 | | |
3331 | 3343 | | |
3332 | 3344 | | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
3333 | 3355 | | |
3334 | 3356 | | |
3335 | 3357 | | |
3336 | 3358 | | |
3337 | 3359 | | |
3338 | 3360 | | |
3339 | 3361 | | |
3340 | | - | |
| 3362 | + | |
3341 | 3363 | | |
3342 | 3364 | | |
3343 | 3365 | | |
| |||
3365 | 3387 | | |
3366 | 3388 | | |
3367 | 3389 | | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
3368 | 3398 | | |
3369 | 3399 | | |
3370 | 3400 | | |
| |||
0 commit comments