Load a folder's `.env` only after the folder is trusted

DO
2h ago
+664-74

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 .env is 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 .env loads 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 .env cannot 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 .env is skipped, pointing at /trust after No.
  • Headless, piped, and pax -p/pax --web runs load the .env only 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 .env is loaded only within the folder's trust scope (its repository); a .env above the repository is skipped, even if the folder is trusted, and the skip notice only names .env files that trusting the folder would load.
  • A .env can no longer move Pax's own folders: values it sets for XDG_CONFIG_HOME, XDG_STATE_HOME, HOME, and USERPROFILE are 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 .env sets (such as CLAI_MODEL) apply from the next start after first trusting the folder.
  • CLAI_NO_SPLASH in a .env no longer affects the splash, which starts before the .env loads.
  • Migration: start pax in the folder and answer Yes (or enter /trust yes), or export the variables in your environment.