feat(cli): warn at boot when a bypass permission mode is active - #522
Open
RonenMars wants to merge 1 commit into
Open
feat(cli): warn at boot when a bypass permission mode is active#522RonenMars wants to merge 1 commit into
RonenMars wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #473. The README half of that issue is #518 — this PR is only the piece that PR cannot carry, since it is docs-only and
[skip-ci].Why a boot warning
Disclosure is not the weak point. The first-run prompt already offers only
acceptEditsandmanual, so a bypass mode is never something you reach by tapping through setup. The auto-resume prompt already says agents can start without you present, and defaults to no.The gap is the flag path.
--default-permission-mode bypassPermissions,--claude-flag permissionMode=…, and a hand-editedserver.yamlare all set once and then forgotten, and none of them says anything afterwards. Someone who reads a doc, copies a flag, and moves on never sees the README again — but they boot the server every day.So: one warning at every boot while a bypass mode is active, where the person running it will actually see it.
What changed
effectivePermissionMode(flags, fallback)insrc/claude-flags.tsresolves what sessions will really spawn with, mirroring the precedenceStreamerServer.spawnFlagOverrides()applies —claudeFlags.permissionModewins over the--default-permission-modefallback.cli/index.tswarns when that mode is dangerous, reusing the existingisDangerousPermissionMode()predicate rather than adding a second definition of "dangerous".Why the helper is extracted rather than inlined
The failure mode is a warning that stays silent while
claude_flags: {"permissionMode":"bypassPermissions"}is what actually reaches argv. Reading only the fallback would do exactly that, and nothing would ever surface it — a warning that fails open is worse than none, because its silence reads as safety.cli/index.tscallsprogram.parse()at module scope, so the guard is not testable in place. Extracting the precedence is what makes it assertable.Verification
npm run lintexits 0.__tests__/claude-flags.test.ts→ 28 passed.Positive control: inverting the precedence (
fallback ?? flags?.permissionMode) turned exactly one test red — the precedence case — and restoring it returned 28/28. The assertion is not vacuous.