You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/env.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,8 @@ Opt-in portable bundle mode:
35
35
- Set `controlPlane.secrets.storePlaintextInBackend=true` in project config when you want `plain_env` values mirrored into the configured backend alongside secret values.
36
36
- In that mode, the backend copy becomes the portable source of truth and `.hack/.env` becomes a compatibility materialization target.
37
37
- This works best with the repo-relative `encrypted_file` backend, because the encrypted file plus key can move with the repo onboarding flow.
38
+
- Optional env overlays can then be selected with `--env=<name>`, which layers `.hack/.env.<name>` and backend-scoped values on top of the base `.hack/.env` values.
39
+
- Projects can set `defaultEnvConfig` (or `default_env_config`) in `.hack/hack.config.json` so `hack up`, `hack env`, and related commands automatically use that overlay unless `--env=base` is passed.
38
40
39
41
Current status:
40
42
@@ -66,6 +68,36 @@ See `docs/plans/2026-03-13-env-portability-and-secret-management-design.md` for
66
68
-`process.env` (ambient fallback): supplies `plain_env` values when `.hack/.env` is missing a key.
- Optional project default: `"defaultEnvConfig": "qa"` in `.hack/hack.config.json`
80
+
81
+
Resolution order:
82
+
83
+
1. selected overlay value (`--env=qa` or `defaultEnvConfig`)
84
+
2. base value
85
+
3.`process.env` fallback for `plain_env`
86
+
87
+
Secret-backed overlay values are stored in the configured backend under env-scoped keys, so one encrypted backend can carry base plus multiple overlays together.
88
+
89
+
Use `--env=base` to bypass the configured default overlay and operate on the base env only.
90
+
91
+
## Migrating older repos
92
+
93
+
For older repos that only used `.hack/.env`:
94
+
95
+
1. Keep `.hack/hack.env.json` as the base contract.
"Portable plaintext bundling is disabled. Legacy .hack/.env values stay machine-local until controlPlane.secrets.storePlaintextInBackend=true and values are re-saved with hack env set.",
1509
+
};
1510
+
}
1511
+
1512
+
if(!cfg.defaultEnvConfig){
1513
+
return{
1514
+
name: "env mode",
1515
+
status: "ok",
1516
+
message: "Base env only (.hack/.env + bundled backend)",
1517
+
};
1518
+
}
1519
+
1520
+
constoverlayPath=resolveEnvFilePath({
1521
+
projectDir: ctx.projectDir,
1522
+
envName: cfg.defaultEnvConfig,
1523
+
});
1524
+
constoverlayExists=awaitpathExists(overlayPath);
1525
+
return{
1526
+
name: "env mode",
1527
+
status: overlayExists ? "ok" : "warn",
1528
+
message: overlayExists
1529
+
? `defaultEnvConfig=${cfg.defaultEnvConfig} overlays ${overlayPath} on top of .hack/.env`
1530
+
: `defaultEnvConfig=${cfg.defaultEnvConfig} is set, but ${overlayPath} does not exist yet; base env will still apply`,
0 commit comments