Skip to content

feat: per-profile env vars via .env file and YAML env block#3

Open
hummuscience wants to merge 1 commit into
Digital-Threads:masterfrom
hummuscience:feat/per-profile-env
Open

feat: per-profile env vars via .env file and YAML env block#3
hummuscience wants to merge 1 commit into
Digital-Threads:masterfrom
hummuscience:feat/per-profile-env

Conversation

@hummuscience
Copy link
Copy Markdown

Adds two ways to inject environment variables into the spawned CLI on aimux run <profile> and aimux auth login <profile>:

  • <profile>/.env — dotenv file in the profile dir (good for secrets; parser supports KEY=value, export prefix, comments, single/double quotes, and basic escapes inside double quotes)
  • env: map under the profile in config.yaml (good for non-secret toggles; overrides .env on key conflict)

Both sources are merged and passed alongside CLAUDE_CONFIG_DIR. This unlocks env-driven Claude Code modes (Microsoft Foundry, Bedrock, Vertex, custom proxies) per profile without touching the launching shell. README documents the Microsoft Foundry recipe.

Tests cover the dotenv parser, the merge precedence, and that profile env actually flows through buildRunParams.

Adds two ways to inject environment variables into the spawned CLI on
`aimux run <profile>` and `aimux auth login <profile>`:

- `<profile>/.env` — dotenv file in the profile dir (good for secrets;
  parser supports `KEY=value`, `export` prefix, comments, single/double
  quotes, and basic escapes inside double quotes)
- `env:` map under the profile in `config.yaml` (good for non-secret
  toggles; overrides `.env` on key conflict)

Both sources are merged and passed alongside `CLAUDE_CONFIG_DIR`. This
unlocks env-driven Claude Code modes (Microsoft Foundry, Bedrock,
Vertex, custom proxies) per profile without touching the launching
shell. README documents the Microsoft Foundry recipe.

Tests cover the dotenv parser, the merge precedence, and that profile
env actually flows through `buildRunParams`.
Copy link
Copy Markdown

@shahinyanm1-work shahinyanm1-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid PR — parser is tight, tests cover the right paths, README recipe makes the feature self-explanatory. Approving with a couple of small notes; nothing blocking.

Small parser bug

Inline comments after a quoted value don't get stripped. FOO="bar" # comment ends up as "bar" # comment because the strip-comment branch is skipped when the value starts with a quote, and then the strip-quotes branch bails because the last char isn't a quote either. Probably worth handling, or at least noting in the README — quoted-value users will hit this sooner or later.

Documentation nit

The parser doesn't do ${VAR} interpolation and doesn't support multi-line values. Both are fine for the dotenv-as-secrets use case, but worth one line in the README so people don't expect full dotenv-expand behavior.

Security hygiene (optional)

The README tells people to chmod 600 .env. Could be worth a runtime warning when aimux run sees a profile .env with mode > 0600 — same way docker complains about loose key permissions. Not a blocker, just an "easy win later" item.

Everything else looks good — process.env merge, CLAUDE_CONFIG_DIR override order, is_source handling, validation in config.ts, and the auth-login path all do the right thing.

Copy link
Copy Markdown
Member

@Shahinyanm Shahinyanm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid PR — parser is tight, tests cover the right paths, README recipe makes the feature self-explanatory. Approving with a couple of small notes; nothing blocking.

Small parser bug

Inline comments after a quoted value don't get stripped. FOO="bar" # comment ends up as "bar" # comment because the strip-comment branch is skipped when the value starts with a quote, and the strip-quotes branch bails because the last char isn't a quote either. Worth handling, or at least noting in the README — quoted-value users will hit this sooner or later.

Documentation nit

Parser doesn't do ${VAR} interpolation and doesn't support multi-line values. Both fine for the dotenv-as-secrets use case, but worth one line in the README so people don't expect full dotenv-expand behavior.

Security hygiene (optional)

README tells people to chmod 600 .env. Could be worth a runtime warning when aimux run sees a profile .env with mode > 0600 — same way docker complains about loose key permissions. Not a blocker, easy follow-up.

Everything else looks good — process.env merge, CLAUDE_CONFIG_DIR override order, is_source handling, validation in config.ts, and the auth-login path all do the right thing.

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.

3 participants