Skip to content

Add Config at the composition root #184

Description

@ecalifornica

Part of #183. path-cli only. No library changes. No user-visible changes.

Work

  • Add a Config struct. Extract it one time in run() with figment:
    • Serialized::defaults, then Env.
    • It owns TOOLPATH_CONFIG_DIR, HOME, the harness root variables (XDG_DATA_HOME, COPILOT_HOME, APPDATA), PATHBASE_URL, TOOLPATH_QUERY_EXPLAIN.
    • The env layer emits values as verbatim strings (a small provider wrapping Env). No per-field deserializers.
  • Change config.rs::config_dir() to read from Config, not from env.
  • Change the ~30 provider construction sites to the injection functions that exist today:
    • Convo::new() becomes Convo::with_resolver(...).
    • derive_* wrappers become derive_*_with(...).
    • Commands get a &Config parameter. Command structure does not change.
  • For opencode and copilot, inject the directory (with_data_dir, with_copilot_dir), not the home.
    • Their env reads still exist and win against with_home.
    • The provider issue deletes those reads.
  • Test the env-to-Config mapping with figment::Jail.

PR plan

  • PR 1: Config, figment load, config_dir().
  • Then one PR per command module for its construction sites. The first one adds the run() extraction and passes &Config down.
  • Old and new construction can coexist until the provider issue lands.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions