fix(cli): --read-only silently dropped when --cwd follows it - #198
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Open
fix(cli): --read-only silently dropped when --cwd follows it#198Vyacheslav-Tomashevskiy wants to merge 1 commit into
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Conversation
A --cwd anywhere on the command line reloads the config and calls _apply_config(), which unconditionally rewrites READ_ONLY_MODE, APPROVE_SHELL and LLAMA_URL from the config/env defaults. Flags parsed before that --cwd are wiped. trashclaw --read-only --cwd ~/project -> read-only OFF The model is then handed write_file, edit_file, patch_file, run_command and git_commit in a session the user asked to be an audit. Remember what the flags set and re-apply it after each reload, so flag order stops mattering. Project config still applies to anything the CLI did not set. Adds tests/test_cli_flags.py (no LLM server needed).
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.
The bug
--read-onlyis documented as the safe-first-run switch ("blocks write, shell, commit, and clipboard-copy tools"). It stops working as soon as a--cwdfollows it on the command line:main()handles--cwdby reloading the project config, and_apply_config()unconditionally rewritesREAD_ONLY_MODE,APPROVE_SHELLandLLAMA_URLfrom the config/env defaults — so every flag parsed before that--cwdis thrown away.--read-onlysets the global at parse time, then the reload sets it straight back to"0".Consequence: the agent is handed
write_file,edit_file,patch_file,run_commandandgit_commitin a session the user explicitly asked to be an audit, with no warning. Same mechanism silently drops--url(prompts go to the default endpoint instead of the one you named) and--auto-shell.Reproduced before and after
Driving the real
main()withagent_turnstubbed, on a clean checkout ofmain:--read-only--read-only --cwd P--cwd P --read-only--url http://box:9999 --cwd Phttp://localhost:8080With this patch all rows behave like the first one.
The fix
Remember what the flags asked for and re-apply it after each config reload, so flag order stops mattering. Project config still wins for anything the CLI did not set — a
.trashclaw.jsonwithread_only: trueand no flags still enables read-only (covered by a test).Tests
New
tests/test_cli_flags.py— pytest + stdlib only, no LLM server contacted (agent_turnis stubbed,-epath). Three cases: read-only survives in both flag orders and both--cwdspellings;--url/--auto-shellsurvive; project config still applies.3 passed.assert False is True,'http://localhost:8080' == 'http://box:9999') — non-vacuous.326 passed, 4 failed; those same 4 (test_metal_gpux3,test_wordcount_base64::test_count_file) fail identically on unpatchedmainon this Linux host, so this PR adds no new failures.The existing read-only tests only exercise
_read_only_blocked()with the global monkeypatched, which is why the CLI wiring was never covered.RTC:
RTCd1554f0f35576faf01d386a6be1c947f560dd0b7