feat: add BEANS_PATH environment variable support#85
Merged
hmans merged 1 commit intohmans:mainfrom Feb 13, 2026
Merged
Conversation
Add BEANS_PATH environment variable as alternative to --beans-path flag. Precedence: --beans-path flag > BEANS_PATH env var > config file. - Extract resolveBeansPath() function with env var support - Add 8 test cases covering all precedence scenarios - Update flag help text to document env var
c4dc9cf to
5b234ea
Compare
Owner
|
Good change, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
BEANS_PATHenvironment variable as an alternative to the--beans-pathCLI flag for specifying the beans data directory.Motivation
When using beans with git worktrees, it's often desirable to have agents directly use the base checkout's beans directory as a single source of truth across all worktrees.
Why not use existing approaches?
--beans-pathflag - Requires agents to include the flag on every single command invocation, which is error-prone and easy to forget.beans.ymlin worktrees - Creates unwanted modifications that might accidentally get committed or cause merge conflictsWhy an environment variable?
An environment variable is easy to set once, transparent across all beans commands, safe from accidental commits, and follows standard patterns for environment-specific configuration.
Changes
Path Resolution Precedence
The beans path is now resolved in this order:
--beans-pathflag (highest priority) - Explicit user overrideBEANS_PATHenv var (medium priority) - Session/environment settingImplementation
Extracted
resolveBeansPath()function (cmd/root.go):os.Getenv("BEANS_PATH")when flag is emptyUpdated flag help text:
"Path to data directory (overrides config and BEANS_PATH env var)"Tests
8 test cases in
cmd/root_test.go:flag_takes_highest_precedenceflag_overrides_env_varBEANS_PATHis set to invalid pathenv_var_used_when_flag_is_emptyBEANS_PATHis picked up when no flag givenconfig_used_when_flag_and_env_var_are_emptyinvalid_flag_path_returns_errorinvalid_env_var_path_returns_errorinvalid_config_path_returns_init_suggestionbeans initfor config fallbackfile_path_rejected_as_not_a_directoryUsage