[Bug] Untrusted-directory error says NANOCODER_TRUST_DIRECTORY=1 bypasses the check "for this run", but it trusts the directory permanently
Description
When nanocoder run refuses an untrusted directory, the message says to "Pass --trust-directory or set NANOCODER_TRUST_DIRECTORY=1 to bypass the disclaimer for this run." That is true for --trust-directory, but not for the environment variable. With NANOCODER_TRUST_DIRECTORY=1 the directory is saved to trustedDirectories and stays trusted. A CI user who exports the variable globally, believing it applies to one run, permanently trusts every checkout it touches. The daemon's message already describes this correctly.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 5c2e693)
- Provider: Ollama
- Model: qwen2.5:1.5b
Steps to Reproduce
- In a new git project that has never been trusted, run
nanocoder run "hi". - Run
NANOCODER_TRUST_DIRECTORY=1 nanocoder run "Reply with the single word OK". - Look at
trustedDirectoriesinnanocoder-preferences.json. - Run
nanocoder run "Reply with the single word OK"again, without the variable. - For comparison, in another new project run
nanocoder --trust-directory run "Reply with the single word OK"and checktrustedDirectoriesagain.
Expected Behavior
The message explains what each option does: --trust-directory applies to this run only, and NANOCODER_TRUST_DIRECTORY=1 saves the directory as trusted.
Actual Behavior
Step 1 prints (the --json output has the same text):
Directory <path> is not trusted. Pass --trust-directory or set NANOCODER_TRUST_DIRECTORY=1 to bypass the disclaimer for this run.
Step 2 prints [plain] Marked <path> as trusted (NANOCODER_TRUST_DIRECTORY=1). and the directory is now listed in trustedDirectories. Step 4 runs without any variable. Step 5 does not add the second project, so the flag really is per run.
Suggested Fix
- Change both messages in
source/plain/shell.ts(the--jsonone at line 135 and the text one at line 141), and reuse the wording fromsource/daemon/cli.ts:160-165:--trust-directory"for this run only (set NANOCODER_TRUST_DIRECTORY=1 to persist it instead)". - Add a test that fails if the message says "for this run" about the environment variable while the variable saves the directory.
source/plain/shell.spec.tsalready checks for the "not trusted" text (lines 512 and 862).
Additional Context
- Docs already describe it correctly (
docs/getting-started/index.md, around lines 221-231). - Open PR #1421 changes the daemon trust messages only and does not touch these two.
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
hey @addyCooks, @akramcodez, i would like to work on this issue could please assign this to me.
plan - i'd like to take this. I'll update both untrusted-directory messages in plain/shell.ts (text and --json) to say --trust-directory applies to this run only and NANOCODER_TRUST_DIRECTORY=1 trusts the directory permanently, matching the daemon's wording
Assigned it to you, go for it!