20 KiB
CLI De-globalize Server URL And Storage Dir
Summary
Make --storage-dir and --server-url command-scoped instead of global so the CLI surface matches the architecture we now have.
This pass should:
- keep only truly global flags in
GlobalArgs - move local-storage selection onto the commands that actually use local storage
- move remote-server selection onto the commands that actually support remote targeting
- remove false affordances from help output, docs, and env-var wiring
This plan is the direct follow-on to 2026-04-05-next-steps-after-cli-mode-removal.md.
Scope Boundaries
In scope:
- de-globalize
--storage-dir/FABRO_STORAGE_DIR - de-globalize
--server-url/FABRO_SERVER_URL - update clap types, parser tests, dispatch signatures, and command help
- keep
modelandexecbehavior consistent with the recent cleanup, but expressed through command-local args - update docs/examples that still show top-level target flags
Out of scope:
- changing server/runtime behavior for
run,model, orexec - adding new remote-capable commands
- making
execserver-owned - changing
[server].base_urlsemantics again - broad config/schema changes outside the CLI arg surface
Problem Frame
The code no longer has a meaningful whole-program “mode”, but the CLI still advertises target-selection flags as if every command can choose between local storage and a remote server.
That is now misleading in several different ways:
- many commands still show
--server-urleven though they never use it - many commands still show
--storage-direven though they do not read local runtime state - docs still describe these flags as global CLI surface area
- help snapshot churn is broader than the real behavior surface because the flags leak into unrelated commands
The goal is not to invent new behavior. The goal is to make the CLI honest about which commands actually support which target-selection controls.
Key Decisions
GlobalArgsremains, but only for true global flags:--json--debug--no-upgrade-check--quiet--verbose
--storage-dirand--server-urlstop being top-level/global clap args entirely.- target-selection args belong to leaf commands, not parent namespaces.
- Rationale: keep natural syntax such as:
fabro run foo.fabro --storage-dir /tmp/fabrofabro model list --server-url https://fabro.example.com/api/v1fabro server start --storage-dir /tmp/fabro
- Avoid awkward parent-namespace syntax like
fabro model --server-url ... list.
- Rationale: keep natural syntax such as:
FABRO_STORAGE_DIRandFABRO_SERVER_URLremain supported, but only for commands that define the corresponding arg.- command-local target syntax becomes the supported surface.
- Old forms like
fabro --server-url ... model listandfabro --storage-dir ... run ...are intentionally removed in this pass.
- Old forms like
- during implementation, temporary duplication between global target args and the new leaf-command args is acceptable.
- Rationale: this refactor touches many commands, so the migration should stay compile-safe until the old global fields are fully unused and can be removed in one cleanup step.
settingskeeps--storage-dir, because it changes the resolved local settings output.settingsdoes not keep--server-url.- Rationale: command-local remote target overrides should not masquerade as merged durable config.
preflightkeeps--storage-dir, because it resolves a local run-oriented settings stack and should continue to allow explicit local storage selection.execkeeps only--server-url.execdoes not need--storage-dir.
model listandmodel testkeep both:--server-urlfor explicit remote server targeting--storage-dirfor explicit local auto-start/storage selection
- the existing
modelconfig/defaulting contract stays intact:- explicit
--server-urlwins - explicit
--storage-dirsuppresses configured[server].base_url - otherwise
modelmay default to configured[server].base_url
- explicit
- the existing
execcontract stays intact:- server routing only happens when the command-local
server_urlvalue is set, whether by CLI flag orFABRO_SERVER_URL - configured
[server].base_urlalone still does not rerouteexec
- server routing only happens when the command-local
fabro modelwith no subcommand remains the convenience alias for default listing behavior.- target overrides are not a compatibility goal for the bare alias in this pass; users should use
fabro model list ...when specifying target args explicitly.
- target overrides are not a compatibility goal for the bare alias in this pass; users should use
Command Matrix
--server-url only
fabro exec
--storage-dir and --server-url
fabro model listfabro model test
--storage-dir only
fabro runfabro createfabro startfabro attachfabro logsfabro resumefabro rewindfabro forkfabro waitfabro diff- hidden
fabro __runner fabro psfabro rmfabro inspectfabro artifact listfabro artifact cpfabro sandbox cpfabro sandbox previewfabro sandbox sshfabro store dumpfabro pr createfabro pr listfabro pr viewfabro pr mergefabro pr closefabro system prunefabro system dffabro server startfabro server stopfabro server status- hidden
fabro server __serve fabro settingsfabro preflight
Neither target arg
fabro validatefabro graphfabro parsefabro doctorfabro installfabro repo initfabro repo deinitfabro workflow listfabro workflow createfabro provider login- hidden
fabro skill install fabro secret getfabro secret listfabro secret setfabro secret rmfabro docsfabro discordfabro completionfabro upgrade- internal analytics/panic commands
Implementation Changes
1. Narrow GlobalArgs and add command-scoped target arg structs
In lib/crates/fabro-cli/src/args.rs:
- add the new command-scoped target arg structs first, while temporarily leaving
storage_dirandserver_urlonGlobalArgs - keep
GlobalArgsas the long-term home only for the true-global output/logging/upgrade-check surface - add small reusable arg structs:
StorageDirArgs { storage_dir: Option<PathBuf> }ServerUrlArgs { server_url: Option<String> }ModelTargetArgs { storage_dir: Option<PathBuf>, server_url: Option<String> }
- keep the
storage_dir/server_urlconflict onModelTargetArgs - keep the existing env bindings:
FABRO_STORAGE_DIRFABRO_SERVER_URL
This temporary duplication is intentional. The crate should continue to compile while commands migrate off GlobalArgs.
Because the target args will now live on leaf commands, convert inline/anonymous clap variants into explicit args structs where needed. The important conversions are:
Exec(AgentArgs)->Exec(ExecArgs)whereExecArgsflattens:ServerUrlArgsfabro_agent::cli::AgentArgs
ModelsCommand::List { ... }->ModelsCommand::List(ModelListArgs)ModelsCommand::Test { ... }->ModelsCommand::Test(ModelTestArgs)RunCommands::Start { run: String }->RunCommands::Start(StartArgs)whereStartArgsflattensStorageDirArgsRunCommands::Attach { run: String }->RunCommands::Attach(AttachArgs)whereAttachArgsflattensStorageDirArgsRunCommands::Runner { ... }->RunCommands::Runner(RunnerArgs)whereRunnerArgsflattensStorageDirArgsServerCommand::Start { ... }->ServerCommand::Start(ServerStartArgs)whereServerStartArgsflattens:StorageDirArgs- the existing
foregroundflag ServeArgs
ServerCommand::Stop { ... }->ServerCommand::Stop(ServerStopArgs)whereServerStopArgsflattensStorageDirArgsServerCommand::Status { ... }->ServerCommand::Status(ServerStatusArgs)whereServerStatusArgsflattensStorageDirArgsServerCommand::Serve { ... }->ServerCommand::Serve(ServerServeArgs)whereServerServeArgsflattens:StorageDirArgs- the existing
record_pathfield ServeArgs
Also flatten StorageDirArgs into the leaf arg types that currently rely on global storage selection, including:
RunArgsLogsArgsDiffArgsResumeArgsRewindArgsForkArgsWaitArgsRunsListArgsRunsRemoveArgsInspectArgsArtifactListArgsArtifactCpArgsCpArgsPreviewArgsSshArgsStoreDumpArgsPrCreateArgsPrListArgsPrViewArgsPrMergeArgsPrCloseArgsRunsPruneArgsDfArgsSettingsArgsPreflightArgs
2. Rework parser and dispatch wiring around leaf-command target args
In lib/crates/fabro-cli/src/main.rs:
- keep
Cli { globals, command }, but with the narrowerGlobalArgs - update dispatch pattern matches to use the new wrapper arg structs:
ExecArgsModelListArgsModelTestArgsStartArgsAttachArgsRunnerArgs
- replace parser tests that assume global target flags with command-local parser tests
Parser behavior to lock down:
fabro run test/simple.fabro --storage-dir /tmp/fabroparsesfabro model list --server-url http://localhost:3000/api/v1parsesfabro exec --server-url http://localhost:3000/api/v1 "prompt"parsesfabro model list --storage-dir /tmp/fabro --server-url http://localhost:3000/api/v1fails with the command-local conflictfabro --server-url http://localhost:3000/api/v1 model listno longer parsesfabro --storage-dir /tmp/fabro run test/simple.fabrono longer parses
These parser assertions belong at the end of the migration, after storage_dir and server_url have actually been removed from GlobalArgs. Before that cleanup step, the old top-level forms will still parse and should not be treated as failures yet.
3. Replace “with globals” settings helpers with explicit local/remote override helpers
The current helper layer in lib/crates/fabro-cli/src/user_config.rs is still shaped around global target args. That should be simplified to explicit command-local override helpers.
In lib/crates/fabro-cli/src/user_config.rs:
- remove or rename the generic helpers that imply target args are global:
user_layer_with_globals(...)load_user_settings_with_globals(...)apply_global_overrides(...)
- replace them with explicit helpers such as:
user_layer_with_storage_dir(storage_dir: Option<&Path>) -> anyhow::Result<ConfigLayer>load_user_settings_with_storage_dir(storage_dir: Option<&Path>) -> anyhow::Result<Settings>exec_server_target(args: &ServerUrlArgs, settings: &Settings) -> Option<ServerTarget>model_server_target(args: &ModelTargetArgs, settings: &Settings) -> Option<ServerTarget>
- keep
build_server_client(...)
Behavior to preserve:
- local-storage commands can still resolve settings with an explicit storage-dir override
modelkeeps its existing defaulting behaviorexeconly resolves a remote target when its command-localserver_urlvalue is set- TLS continues to come from
[server].tlswhen a remote target is selected
4. Repoint command implementations to explicit target args
Update the commands that currently read target selection through GlobalArgs.
In lib/crates/fabro-cli/src/commands/model.rs:
- switch from
GlobalArgs-based target lookup toModelTargetArgs - keep the recent server-canonical behavior unchanged
In lib/crates/fabro-cli/src/commands/exec.rs:
- switch from
GlobalArgs-based target lookup toServerUrlArgs - remove any remaining dependence on
storage_dir - load settings with plain
load_user_settings(), not a storage-dir-aware helperexecdoes not need local storage override semantics anymore- it should then pass
&ServerUrlArgstoexec_server_target(...)
In the local-storage command modules:
- replace
load_user_settings_with_globals(globals)with the explicit storage-dir helper - read
storage_dirfrom the command’s own args struct, not fromglobals
Key files here include:
lib/crates/fabro-cli/src/commands/run/mod.rslib/crates/fabro-cli/src/commands/run/command.rslib/crates/fabro-cli/src/commands/run/logs.rslib/crates/fabro-cli/src/commands/run/resume.rslib/crates/fabro-cli/src/commands/run/rewind.rslib/crates/fabro-cli/src/commands/run/fork.rslib/crates/fabro-cli/src/commands/run/wait.rslib/crates/fabro-cli/src/commands/run/diff.rslib/crates/fabro-cli/src/commands/run/cp.rslib/crates/fabro-cli/src/commands/run/preview.rslib/crates/fabro-cli/src/commands/run/ssh.rslib/crates/fabro-cli/src/commands/runs/list.rslib/crates/fabro-cli/src/commands/runs/rm.rslib/crates/fabro-cli/src/commands/runs/inspect.rslib/crates/fabro-cli/src/commands/artifact/list.rslib/crates/fabro-cli/src/commands/artifact/cp.rslib/crates/fabro-cli/src/commands/store/dump.rslib/crates/fabro-cli/src/commands/pr/*.rslib/crates/fabro-cli/src/commands/system/*.rslib/crates/fabro-cli/src/commands/server/mod.rslib/crates/fabro-cli/src/commands/preflight.rslib/crates/fabro-cli/src/commands/config/mod.rs
Important internal-path detail:
- hidden commands still need explicit local storage wiring
fabro server __servemust keep receiving--storage-dirfromlib/crates/fabro-cli/src/commands/server/start.rs- hidden
fabro __runnershould continue to accept explicit storage-dir selection through its own args struct rather than throughGlobalArgs
5. Make help output and docs reflect the new command contract
In docs/reference/cli.mdx:
- remove
--storage-dirand--server-urlfrom the “Global options” table - add a short “Command-scoped target selection” section or matrix
- update examples to use command-local placement:
fabro model list --server-url ...fabro server start --storage-dir ...
In docs/reference/user-configuration.mdx:
- keep
[server].base_urldocumentation - clarify that it is a default only for commands that support remote server targets
- keep the
model/execasymmetry explicit - update examples away from top-level
fabro --server-url ...
In docs/administration/deploy-server.mdx:
- update “point the CLI at a server” examples to command-local syntax
- clarify that
modelcan use configured[server].base_url, whileexecstill needs explicit--server-url
In docs/reference/run-directory.mdx:
- change “global
--storage-dirflag” wording to command-local run-family wording
Also scan for stale examples in nearby docs and changelog/admin references and update only the ones that would now be actively misleading.
6. Update unit tests, parser tests, and help snapshots
Unit and parser coverage
In lib/crates/fabro-cli/src/main.rs tests:
- replace the old global target-flag parse tests with command-local parse tests
- add the explicit “old global placement no longer parses” cases
In lib/crates/fabro-cli/src/user_config.rs tests:
- update helper tests to use the new arg structs
- preserve coverage for:
execCLI/envserver_urlroutingexecignoring configured[server].base_urlmodelconfigured[server].base_urldefaultingmodelstorage_dirsuppressing configured remote target- TLS inheritance
Integration coverage
Update behavior/help coverage in:
lib/crates/fabro-cli/tests/it/cmd/exec.rslib/crates/fabro-cli/tests/it/cmd/model.rslib/crates/fabro-cli/tests/it/cmd/model_list.rslib/crates/fabro-cli/tests/it/cmd/model_test.rslib/crates/fabro-cli/tests/it/cmd/config.rslib/crates/fabro-cli/tests/it/cmd/run.rslib/crates/fabro-cli/tests/it/cmd/create.rslib/crates/fabro-cli/tests/it/cmd/attach.rslib/crates/fabro-cli/tests/it/cmd/logs.rslib/crates/fabro-cli/tests/it/cmd/resume.rslib/crates/fabro-cli/tests/it/cmd/rewind.rslib/crates/fabro-cli/tests/it/cmd/wait.rslib/crates/fabro-cli/tests/it/cmd/diff.rslib/crates/fabro-cli/tests/it/cmd/runner.rslib/crates/fabro-cli/tests/it/cmd/ps.rslib/crates/fabro-cli/tests/it/cmd/inspect.rslib/crates/fabro-cli/tests/it/cmd/store.rslib/crates/fabro-cli/tests/it/cmd/store_dump.rslib/crates/fabro-cli/tests/it/cmd/artifact_list.rslib/crates/fabro-cli/tests/it/cmd/artifact_cp.rslib/crates/fabro-cli/tests/it/cmd/sandbox_cp.rslib/crates/fabro-cli/tests/it/cmd/sandbox_preview.rslib/crates/fabro-cli/tests/it/cmd/sandbox_ssh.rslib/crates/fabro-cli/tests/it/cmd/pr.rslib/crates/fabro-cli/tests/it/cmd/pr_list.rslib/crates/fabro-cli/tests/it/cmd/pr_view.rslib/crates/fabro-cli/tests/it/cmd/pr_merge.rslib/crates/fabro-cli/tests/it/cmd/pr_close.rslib/crates/fabro-cli/tests/it/cmd/system.rslib/crates/fabro-cli/tests/it/cmd/system_df.rslib/crates/fabro-cli/tests/it/cmd/system_prune.rslib/crates/fabro-cli/tests/it/cmd/server_start.rslib/crates/fabro-cli/tests/it/cmd/server_stop.rslib/crates/fabro-cli/tests/it/cmd/server_status.rslib/crates/fabro-cli/tests/it/cmd/preflight.rslib/crates/fabro-cli/tests/it/cmd/fabro.rs
Behavior scenarios to add or preserve:
execstill routes through the server only when its command-localserver_urlis setmodelstill honors configured[server].base_urlwhen no explicitstorage_diris setmodelcommand-localserver_urlstill overrides configured base URLmodelcommand-localstorage_dirstill forces local behavior- old top-level target-flag placement fails at parse time
For snapshot churn:
- use the repo workflow from
CLAUDE.mdcargo insta pending-snapshots- verify the expected help/output changes
cargo insta accept
Dependencies And Sequencing
Apply the change in this order:
- add the new command-scoped target arg structs in
args.rs, but keepstorage_dirandserver_urlonGlobalArgstemporarily so the crate still compiles during migration - add the new explicit helpers in
user_config.rsalongside the old global-based helpers - repoint
execandmodelto the new target arg structs and helpers - repoint the local-storage and server command modules, plus test harness/env wiring, off
GlobalArgs - remove
storage_dirandserver_urlfromGlobalArgs, then delete the old global-based helper path once it is unused - update parser tests for the final clap shape, then update docs and help snapshots
This ordering keeps the refactor compile-safe: helper and command migration happen before the old global fields are removed, and parser assertions about the old top-level syntax move to the final cleanup step where they become true.
Test Plan
- targeted parser/unit tests:
cargo test -p fabro-cli --lib main::tests -- --nocapturecargo test -p fabro-cli --lib user_config::tests -- --nocapture
- targeted CLI integration tests:
cargo nextest run -p fabro-cli cmd::exec:: --no-fail-fastcargo nextest run -p fabro-cli cmd::model:: cmd::model_list:: cmd::model_test:: cmd::config:: --no-fail-fastcargo nextest run -p fabro-cli cmd::run:: cmd::create:: cmd::attach:: cmd::logs:: cmd::resume:: cmd::rewind:: cmd::wait:: cmd::diff:: cmd::runner:: --no-fail-fastcargo nextest run -p fabro-cli cmd::server_start:: cmd::server_stop:: cmd::server_status:: --no-fail-fast
- broader CLI sweep after targeted coverage is green:
cargo nextest run -p fabro-cli --no-fail-fast
- final verification:
cargo fmt --check --allcargo clippy --workspace --all-targets -- -D warnings
Assumptions And Defaults
- Pre-production status means removing the old global target-flag placement is acceptable; no compatibility shim is required.
FABRO_STORAGE_DIRandFABRO_SERVER_URLremain useful and should stay, but only where the corresponding command actually supports the underlying behavior.- The recent
modelandexecbehavioral contracts are already correct; this pass is about CLI honesty and arg ownership, not product redefinition. - If we later want a broader “remote-capable command matrix” abstraction, it should be built on top of these command-local args rather than by reintroducing misleading global target flags.