Skip to content

feat: export UMBEL_RESOLVED_DIR + UMBEL_BUNDLE_VERSION on the bundle run path#23

Merged
vessux merged 1 commit into
mainfrom
worktree-gh17-resolved-env-vars
Jun 11, 2026
Merged

feat: export UMBEL_RESOLVED_DIR + UMBEL_BUNDLE_VERSION on the bundle run path#23
vessux merged 1 commit into
mainfrom
worktree-gh17-resolved-env-vars

Conversation

@vessux

@vessux vessux commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

umbel run <bundle> now exports two vars into claude's spawn env so downstream tools can read the running bundle's identity directly, instead of scraping the --plugin-dir entry off PATH (a fragile dependency on Claude Code's plugin→PATH behavior):

  • UMBEL_RESOLVED_DIR — the resolved cache dir (<cacheRoot>/bundles/<name>-<hash>).
  • UMBEL_BUNDLE_VERSION — the bundle version (0.0.0+<hash>).

To guarantee the version can't drift from what the compiler writes, compile() now returns { cacheDir, version }: the 0.0.0+<hash> string is computed once and used both for plugin.json and the return value (no re-derivation, no second literal). exec.ts destructures it straight into spawnEnv. The vanilla path (execVanilla) is untouched and sets neither var.

Concrete first consumer: a dotfiles ccstatusline widget showing name@version of the active bundle.

Changes

  • src/bundle/compile.tscompile()CompileResult { cacheDir, version }; single source for the version string.
  • src/bundle/exec.ts — set UMBEL_RESOLVED_DIR + UMBEL_BUNDLE_VERSION on the bundle-resolved path.
  • src/run.tsbuildBundle uses .cacheDir.
  • src/args.ts — both vars documented in the --help Env section.

Test plan

  • New unit test asserts the bundle-path spawn env (exec.test.ts), incl. UMBEL_BUNDLE_VERSION == compiled plugin.json version.
  • New run.vanilla-env.test.ts proves the vanilla path sets neither var (scoped spawnSync mock).
  • Help-text assertion in args.test.ts.
  • compile.test.ts updated mechanically for the new return shape.
  • Full suite 351 pass, tsc --noEmit clean, biome check . clean.
  • End-to-end: built CLI + fake claude confirms UMBEL_RESOLVED_DIR = on-disk dir and UMBEL_BUNDLE_VERSION = plugin.json version.

Out of scope (captured as follow-ups)

  • The issue's acceptance loosely says the var equals "the version field in bundle.md", but bundle.md frontmatter carries a bare hash field — the 0.0.0+<hash> version lives in plugin.json (the cited compile.ts line). Implemented to the cited value/line; the bundle.md-vs-plugin.json divergence is filed for discovery.

Closes #17

…run path

prepareBundleInvocation now sets UMBEL_RESOLVED_DIR (the resolved cache dir)
and UMBEL_BUNDLE_VERSION (0.0.0+<hash>) in claude's spawn env, giving
downstream tools a stable source for the running bundle's identity rather
than scraping the --plugin-dir entry off PATH.

compile() returns { cacheDir, version } so the version is sourced from the
same value it writes into plugin.json and the two can't drift. The vanilla
path (execVanilla) is untouched and sets neither var.

Closes #17
@vessux vessux merged commit 8afda9c into main Jun 11, 2026
4 checks passed
@vessux vessux deleted the worktree-gh17-resolved-env-vars branch June 11, 2026 15:56
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.

Export resolved bundle dir + version as env vars (UMBEL_RESOLVED_DIR, UMBEL_BUNDLE_VERSION)

1 participant