Load a folder's `.env` only after the folder is trusted
- Part of #12983
Pax now loads a folder's .env once the folder is trusted, the same decision that already governs its instruction files and skills:
- Interactively, right after you answer Yes at the trust question, or at once for a folder already saved as trusted.
- Headless (
pax -p,pax --web), only for a folder already saved as trusted. - For any other folder the
.envis skipped, with a one-line notice saying how to trust the folder.
A .env also no longer changes where Pax keeps its own files: values it sets for XDG_CONFIG_HOME, XDG_STATE_HOME, HOME and USERPROFILE (what paths.py reads) are ignored, with a one-line notice. The same variables set in your real environment work as before.
The loading moved from __main__.main() to cli/cli.py (saved decision, before the agent import and settings) and app._decide_trust (after Yes), in a new import-light dotenv_loading.py. Docs (docs/harness/pax.md, README.md, docs/reference.md, AGENTS.md, FILE_MAP.md) say when the .env loads and that it can't move Pax's folders.
[!WARNING]
Compatibility impact: A headless run (pax -p, pax --web) in a folder you never decided about no longer reads its .env, and in a folder you first trust at the prompt, a value only the .env sets (such as CLAI_MODEL) applies from the next start. CLAI_NO_SPLASH in a .env no longer affects the splash, which starts before it loads.
Migration: Start pax in the folder once and answer Yes (or enter /trust yes); the decision is saved and later runs, including headless ones, load the .env. Alternatively, export the variables in your environment.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
š¤ Generated with Claude Code
Summary by cubic
Pax now loads a folder's .env only once the folder is trusted, matching the decision that already governs its instruction files and skills; previously the nearest .env loaded at startup regardless of trust.
- Interactively, the
.envloads right after you answer Yes at the trust question, which names the variables it sets from a bounded preview with no values read (multi-line value bodies are never exposed, including under quoted keys), so a crafted.envcannot stall startup; or immediately for a folder already saved as trusted. If you dismiss the question or answer No, a one-line notice says the.envis skipped, pointing at/trustafter No. - Headless, piped, and
pax -p/pax --webruns load the.envonly for a folder already saved as trusted; any undecided or untrusted folder skips it with a one-line notice on how to trust it. - A
.envis loaded only within the folder's trust scope (its repository); a.envabove the repository is skipped, even if the folder is trusted, and the skip notice only names.envfiles that trusting the folder would load. - A
.envcan no longer move Pax's own folders: values it sets forXDG_CONFIG_HOME,XDG_STATE_HOME,HOME, andUSERPROFILEare ignored; the same variables set in the environment work as before.
Compatibility impact
- A headless run in a folder you never decided about no longer reads its
.env, and values only the.envsets (such asCLAI_MODEL) apply from the next start after first trusting the folder. CLAI_NO_SPLASHin a.envno longer affects the splash, which starts before the.envloads.- Migration: start
paxin the folder and answer Yes (or enter/trust yes), or export the variables in your environment.