fix: Hide -c/--command on min session attach from the CLI help surface - #1071
Conversation
Add `hide = true` to the `#[arg(long, short)]` attribute on `AttachArgs::command` so `-c` / `--command` no longer appear in `min session attach --help`, `-h`, or shell completions. The flag stays functional for existing scripted callers; the option promises a general remote exec it cannot deliver (no PTY, only three daemon commands accepted), so it should not be advertised for discovery. The non-TTY attach error still points stuck callers at `--command`; reword it to frame the flag as a deliberate hidden escape hatch rather than drop the reference, keeping the advice actionable now that the flag is off the help surface.
📝 WalkthroughWalkthroughThe ChangesAttach CLI surface
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
The merge commit c0f9a4f resolved conflicts in crates/minimal/src/lib.rs by taking the pre-merge side, silently reverting two fixes that had landed on main: - #1053 — the `min init` refuse-to-overwrite guard: `InitArgs::force`, the bail on an existing `minimal.toml`, and the Updated/Created wording. Without it `min init` overwrites an existing `minimal.toml` with no backup and no prompt, which is the data loss #1032 was filed for. - #1060 — the `SHELL=/bin/sh` pin on the ssh ProxyCommand and the `SendEnv` forwarding of LANG/LC_*/TZ. Without the pin, attach dies at "banner exchange ... Broken pipe" for any user whose $SHELL is a bare name (fish) or absent from the ssh context. Neither revert was caught by the suite: there is no test for the init guard, and `interactive_attach_requires_a_tty_on_stdin` only asserts the error contains "not a TTY" and "--command", which holds either way. Rebuilt lib.rs from main and reapplied only the intended change, so the diff against main is now exactly the `hide = true` on `AttachArgs::command` plus the non-TTY error reword: +4/-3, was +9/-51. Verified: rustfmt clean; `cargo build -p minimal --locked` ok; `min session attach --help` no longer lists `-c`/`--command` while `--command` still parses; `min init --help` lists `--force` again. `cargo test -p minimal` cannot run on macOS (dev-deps pull minimald -> procfs/caps, Linux-only), so the suite is left to CI. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Corrected: the merge commit was reverting two fixes that landed on
|
| Reverted | What it protected |
|---|---|
f36045f9 #1053 |
InitArgs::force, the bail on an existing minimal.toml, and the Updated/Created wording |
12c81c3f #1060 |
the SHELL=/bin/sh pin on the ssh ProxyCommand, and SendEnv forwarding of LANG/LC_*/TZ |
Consequences had it merged:
min initwould overwrite an existingminimal.tomlwith no backup and no prompt — exactly the data lossmin initdestroys an existingminimal.tomlwith no backup;--no-inputis never read andconfirm()treats EOF as yes #1032 was filed for and fix: refuse to overwrite existing minimal.toml without --force #1053 fixed, reintroduced four commits later.min session attachwould break for any user whose$SHELLis a bare name (fish) or absent from the ssh context. Per feat: always set certain important variables automatically #1060's own comment, ssh execs$SHELLwith no PATH lookup, so the transport dies atbanner exchange … Broken pipe.- Locale and timezone would stop reaching the session.
Verified by fetching the file at both ends of the PR:
MARKER (from #1053 / #1060) base HEAD(before fix)
refusing to overwrite existing 1 0
ssh.env("SHELL", "/bin/sh") 1 0
SendEnv=LANG 1 0
SendEnv=LC_* 1 0
SendEnv=TZ 1 0
Why the green suite did not catch it
The PR body reports cargo test --workspace --locked passing, and that is consistent — no test covers either reverted behaviour:
- There is no test for the
min initoverwrite guard. interactive_attach_requires_a_tty_on_stdinasserts onlyerr.contains("not a TTY") && err.contains("--command"), which holds for the old message, the reworded one, and the reverted one.
So the suite was never going to fail here. Worth adding a test for the init guard, given it has now been broken once and silently re-broken once.
What I changed
Rebuilt crates/minimal/src/lib.rs from origin/main (byte-identical, confirmed by an empty diff) and reapplied only the intended change:
hide = trueonAttachArgs::command— the actual fix for Hidemin session attach-c/--commandfrom the CLI help surface #1062.- The non-TTY error reword, kept as authored. It stays within Hide
min session attach-c/--commandfrom the CLI help surface #1062's scope note ("keep the option functional") and the existing test still passes.
Verification
rustfmt --checkon the changed file — cleancargo build -p minimal --locked—Finished dev profilein 3m05smin session attach --help— no-c/--commandline;min session attach --commandstill errors witha value is required for '--command <COMMAND>', so the flag remains functionalmin init --help—--forceis listed againcargo test -p minimalcannot run on macOS (dev-deps pullminimald→procfs/caps, both Linux-only, exactly as AGENTS.md documents). The suite is left to CI.
For the inbox-patch workflow
This is a merge-conflict-resolution failure, not a bad patch — c4231296, the generated commit, was correct on its own. The failure mode is worth guarding: when the bot merges main into a patch branch and the target file has moved, whole-file resolution reverts everything that landed in between, and the PR body still describes only the intended change. A git diff origin/main --stat sanity check against the expected footprint would have caught it.
hide = true on AttachArgs::command (#1071) was silently reverted by commit 64a0764, an unrelated help-text reformat -- the same collateral-clobber pattern #1071 itself had to repair once already. Restore it, along with the "hidden escape hatch" non-TTY error wording that shipped with it. This PR went the opposite direction from a hidden flag: it documented the full min run/min package build/min check allowlist in docs/concepts/sessions.md, docs/guide/agents.md, and docs/reference/cli-min.md. Since -c/--command is a hidden legacy escape hatch and not a general remote shell, remove those mentions instead of expanding them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…cs (#1110) * docs: name full exec-channel allowlist for session attach -c Three docs stated that the non-interactive `min session attach -c` channel accepts only `min run` invocations. The daemon's exec handler also accepts `min package build [args...]` and `min check [args...]` (crates/minimald/src/exec.rs), so the docs understated the allowlist. List all three accepted forms in cli-min.md, agents.md, and sessions.md. Fixes #1067 * chore: no-op to restart ci * fix: keep session attach -c hidden, restore the dropped hide=true hide = true on AttachArgs::command (#1071) was silently reverted by commit 64a0764, an unrelated help-text reformat -- the same collateral-clobber pattern #1071 itself had to repair once already. Restore it, along with the "hidden escape hatch" non-TTY error wording that shipped with it. This PR went the opposite direction from a hidden flag: it documented the full min run/min package build/min check allowlist in docs/concepts/sessions.md, docs/guide/agents.md, and docs/reference/cli-min.md. Since -c/--command is a hidden legacy escape hatch and not a general remote shell, remove those mentions instead of expanding them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs: stop enumerating the -c/--command allowlist in AGENTS.md too The footgun note still spelled out the exact min run/min package build/min check allowlist, which is itself advertising a hidden flag. Keep the warning (don't treat -c as a general shell) and the source pointer, drop the enumerated command list. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: stop pointing the non-TTY attach error at --command The non-TTY error was still advertising the hidden --command escape hatch to every interactive caller who hit it -- inconsistent with hiding the flag everywhere else. Drop the mention; it only ever fires on the interactive path (command.is_none()), so it was pushing newcomers toward a flag we deliberately don't document. Update the one test that asserted on the old wording. Also drop the AGENTS.md footgun bullet entirely per feedback -- no partial version, just remove it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: gominimal-aw-bot[bot] <281738952+gominimal-aw-bot[bot]@users.noreply.github.com> Co-authored-by: bryan <bryan@minimal.dev> Co-authored-by: Norrie Taylor <norrie@minimal.dev> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Fixes #1062
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKsZxwQ
AttachArgs::commandincrates/minimal/src/lib.rscarried#[arg(long, short)]with nohide, so-c/--commandappeared inmin session attach --help,-h, and shell completions — advertising a general remote exec the flag cannot deliver (no PTY, only three daemon commands accepted). Addinghide = trueremoves it from the visible surface while keeping it functional for existing scripted callers. The one coupled judgment call: the non-TTY attach error inensure_interactive_attach_ttystill names--command; rather than drop the reference (which would strip the only forward path for non-TTY callers and break its existing test), I reworded it to frame the flag as a deliberate hidden escape hatch, keeping the advice actionable and self-contained.Verification
cargo fmt --all --check --manifest-path target/Cargo.toml— clean, no driftcargo clippy --workspace --locked -- -D warnings— 0 warnings, finished okcargo build --workspace --locked— exit 0cargo test --workspace --locked— all suites passed (exit 0), incl.interactive_attach_requires_a_ttyNote
Hide
-c/--commandflag frommin session attachCLI help and remove--forcefrommin init--commandflag onmin session attachas hidden in lib.rs so it no longer appears in help output, but remains functional for scripted callers.--forceflag frommin init;run_init_flownow always overwritesminimal.tomlif it exists, requiring only the--yesflag for non-interactive use.SHELL=/bin/shoverride andSendEnvforwarding ofLANG/LC_*/TZfrom the SSH attach helper; onlyMINIMAL_SESSION_IDcontinues to be forwarded.min initwill overwrite an existingminimal.tomlwithout--force; any callers relying on that guard will no longer be protected.Macroscope summarized c0f9a4f. (Automatic summaries will resume when PR exits draft mode or review begins).
Summary by CodeRabbit
Bug Fixes
--commandflag.CLI Improvements
--commandoption is now hidden from standard help output while remaining available for scripted use.