Skip to content

feat(cli): configurable env loading (--env-file + dawn.config env)#180

Open
blove wants to merge 11 commits into
mainfrom
feat/configurable-env-loading
Open

feat(cli): configurable env loading (--env-file + dawn.config env)#180
blove wants to merge 11 commits into
mainfrom
feat/configurable-env-loading

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 29, 2026

Summary

dawn dev / dawn verify resolve the .env to load via precedence:

--env-file <path>   (flag)
  → dawn.config.ts `env`
    → default ./.env

Shell-exported vars still win over file contents. This unblocks monorepo apps — a nested app sets env: "../../.env" and loads the workspace-root .env.

  • New optional DawnConfig.env field (local-only; does not affect the deploy artifact).
  • New --env-file <path> flag on dawn dev and dawn verify.
  • New shared resolveEnvPath resolver; dev and verify now agree on which file they read (killed the prior two-code-path drift).
  • loadEnvFile(dir)loadEnvFiles(absPaths) (back-compat wrapper retained); LangSmith auto-trace preserved; shell-wins preserved.
  • Deploy langgraph.json env detection (.env.example.env) unchanged by design.

Researched prior art (LangGraph CLI, Vite, Next, Nx, Turborepo, Node --env-file) → chose declared-path-over-discovery (upward auto-merge is the Nx cautionary tale).

Spec: docs/superpowers/specs/2026-05-29-configurable-env-loading-design.md
Plan: docs/superpowers/plans/2026-05-29-configurable-env-loading.md

Notable implementation notes

  • checkDependencies(appRoot)checkDependencies({ appRoot, envFile? }), now async (loads dawn config); return type unchanged, caller updated.
  • exactOptionalPropertyTypes is on, so optional fields are ?: T | undefined with spread-guarded call sites.
  • dev-command test mirrors the existing real-subprocess harness (asserts Loaded N variable(s) from custom.env in stdout), no mock invented.

Test plan

  • pnpm --filter @dawn-ai/cli test — 174 passing (baseline 159 + 15 new)
  • pnpm --filter @dawn-ai/cli lint && pnpm --filter @dawn-ai/core lint clean
  • pnpm --filter @dawn-ai/core build && pnpm --filter @dawn-ai/cli build green
  • manual: dawn dev in a nested app with env: "../.env" loads the parent file

🤖 Generated with Claude Code

blove and others added 9 commits May 29, 2026 13:09
dawn dev/verify resolve the env file via precedence:
--env-file flag > dawn.config.ts `env` > default ./.env. Shell still
wins over file contents. Unifies dev + verify behind one resolver.
Deploy artifact (langgraph.json env) unchanged — config.env is
local-only. Researched prior art (LangGraph CLI, Vite, Next, Nx,
Turborepo, Node --env-file); chose declared-path-over-discovery.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 tasks: DawnConfig.env field, resolveEnvPath resolver (TDD),
loadEnvFile→loadEnvFiles refactor (TDD), dev-session wiring,
--env-file on dawn dev + verify (TDD), monorepo integration test,
lint/build/test/PR. Deploy artifact untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dawnai Ready Ready Preview, Comment May 29, 2026 9:33pm

Request Review

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes the CLI surface check in scripts/check-docs.mjs, which requires
every long option in the commander registry to be referenced in cli.mdx.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant