Skip to content

fix: authoritative env detection (config import, not regex) (#17) - #19

Merged
lex00 merged 1 commit into
mainfrom
fix/env-detection-authoritative
Jul 13, 2026
Merged

lex00 merged 1 commit into
mainfrom
fix/env-detection-authoritative

Conversation

@lex00

@lex00 lex00 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #17. The env picker showed only (source) for real projects — the regex parse of chant.config.ts missed shapes it didn't anticipate.

Fix

Detect by importing the project's chant.config.ts and reading the actual config object (behold runs under tsx, so .ts transpiles). Handles export default { … }, defineConfig(…), and … satisfies ChantConfig. The text parse stays as a fallback when the import can't run; empty otherwise.

Also logs the detected environments/lexicons on boot, so an empty picker is diagnosable:

  detected: environments [prod]  lexicons [aws, temporal]

Verified live

  • example → environments [prod], lexicons [aws]
  • example-writes (typed config: import type … satisfies TemporalChantConfig) → [prod], [aws, temporal]

tsc --noEmit clean; 32 tests pass (added a wrapper/satisfies-shape case).

If a picker is still (source)-only after this, the boot log will show (none declared) — that means the project's config has no literal environments, not a behold bug.

The env picker showed only (source) for real projects: the regex parse missed
config shapes it didn't anticipate. Import the project's chant.config.ts and read
the actual config object instead — behold runs under tsx, so .ts transpiles, and
this handles export default {…}, defineConfig(…), and `satisfies ChantConfig`.
Regex parse stays as a fallback when the import can't run; empty otherwise.

Also log the detected environments/lexicons on boot so an empty picker is
diagnosable at a glance.

Verified: example → [prod]/[aws]; example-writes (typed temporal config) →
[prod]/[aws,temporal]. tsc clean; 32 tests (+1 wrapper-shape case).
@lex00
lex00 merged commit 9823b4a into main Jul 13, 2026
1 check passed
@lex00
lex00 deleted the fix/env-detection-authoritative branch July 13, 2026 19:42
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