feat(config): expose FORGE_* env vars via :config-env command#2704
Open
chengyixu wants to merge 1 commit intoantinomyhq:mainfrom
Open
feat(config): expose FORGE_* env vars via :config-env command#2704chengyixu wants to merge 1 commit intoantinomyhq:mainfrom
chengyixu wants to merge 1 commit intoantinomyhq:mainfrom
Conversation
Add a discoverable way to browse, inspect, and set all FORGE_* environment variables without manually editing config files. CLI changes: - `forge config get env` lists all known FORGE_* vars with current values, defaults, and descriptions - `forge config get env KEY` shows a single variable's current value - `forge config set env KEY VALUE` writes the value to ~/.forge/.forge.toml and applies it immediately (no restart needed) ZSH changes: - `:config-env` / `:ce` opens an fzf picker of all configurable variables; selecting one prompts for a new value and persists it Implementation: - New `env_registry` module in forge_config with a static catalogue of 40+ FORGE_* variables mapped to their TOML keys, defaults, and descriptions - Values are written to the global .forge.toml config (not .env) for consistency with the existing config system - Type-aware TOML serialization (bool, int, float, string) Fixes antinomyhq#2638 Co-Authored-By: ForgeCode <noreply@forgecode.dev>
| }; | ||
|
|
||
| // Parse the existing TOML document for editing | ||
| let mut doc: toml_edit::DocumentMut = existing.parse().unwrap_or_default(); |
Contributor
There was a problem hiding this comment.
Data Loss: Silent Parse Error Handling
If the existing .forge.toml contains invalid TOML syntax, unwrap_or_default() silently creates an empty document and overwrites the file, destroying all existing configuration.
Fix: Return the parse error instead of silently discarding it:
let mut doc: toml_edit::DocumentMut = existing.parse()
.map_err(|e| anyhow::anyhow!("Failed to parse existing config file: {e}"))?;
Suggested change
| let mut doc: toml_edit::DocumentMut = existing.parse().unwrap_or_default(); | |
| let mut doc: toml_edit::DocumentMut = existing.parse().map_err(|e| anyhow::anyhow!("Failed to parse existing config file: {e}"))?; |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
This comment came from an experimental review—please leave feedback if it was helpful/unhelpful. Learn more about experimental comments here.
Author
|
recheck |
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.
Fixes #2638
Problem
Many Forge configuration knobs (retry limits, HTTP timeouts, tool timeouts, file size limits, tuning parameters) are only discoverable by reading source code. Changing them requires manually editing
.forge.tomlor setting environment variables — there is no in-shell way to list what is configurable or to set a value interactively.Solution
This PR adds a
:config-env(:ce) command and the corresponding CLI plumbing so users can browse, inspect, and set allFORGE_*environment variables without leaving the terminal.CLI changes
forge config get envFORGE_*vars with current values, defaults, and descriptionsforge config get env KEYforge config set env KEY VALUE~/.forge/.forge.tomland applies immediately (no restart)ZSH changes
:config-env/:ce— opens an fzf picker populated byforge config get env; selecting a variable prompts for a new value and callsforge config set envautomaticallybuilt_in_commands.jsonso it appears in:helpand tab completionArchitecture
env_registrymodule inforge_config— a static catalogue mapping eachFORGE_*env var to its TOML key, default value, and description. This is the single source of truth for discoverability.~/.forge/.forge.toml(not.env), consistent with the existing config system andForgeConfig::write()path.std::env::set_varso changes take effect without restarting.Example
Variables exposed
40+
FORGE_*variables covering: tool timeouts, file size limits, search limits, stdout truncation, HTTP/TLS config, retry settings, semantic search parameters, tuning parameters (temperature, top_p, top_k, max_tokens), and more.Files changed
crates/forge_config/src/env_registry.rscrates/forge_config/src/lib.rscrates/forge_main/src/cli.rsEnvvariants toConfigSetFieldandConfigGetFieldcrates/forge_main/src/ui.rshandle_config_env_setandhandle_config_env_gethandlerscrates/forge_main/src/built_in_commands.json:config-envcommandcrates/forge_main/Cargo.tomlforge_configandtoml_editdependenciesshell-plugin/lib/dispatcher.zsh:config-env/:ceto action handlershell-plugin/lib/actions/config.zsh_forge_action_config_envfunction with fzf pickerTest plan
forge_mainlibrary tests passforge_configtests pass (including 4 new env_registry tests)cargo checksucceedsCo-Authored-By: ForgeCode noreply@forgecode.dev