Skip to content

feat(config): add named configuration profiles#171

Merged
emal-avala merged 3 commits intomainfrom
feat/config-profiles
Apr 23, 2026
Merged

feat(config): add named configuration profiles#171
emal-avala merged 3 commits intomainfrom
feat/config-profiles

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds named config profiles. `/profile save|load|list|delete` persists `Config` snapshots under `<config_dir>/agent-code/profiles/.toml`. Loading a profile replaces the runtime config wholesale.

Commands:
```
/profile list saved profiles
/profile list (same)
/profile save save current config
/profile load replace runtime config
/profile delete remove
/profile help usage
```

Design notes

  • Full replacement, not merge. Profiles are snapshots. Merging two user-maintained configs is where most "why is this setting ignored?" bugs come from — this keeps the mental model trivial.
  • Env vars on load. `AGENT_CODE_MODEL` / `AGENT_CODE_API_BASE_URL` / API keys from env are NOT re-applied when a profile is loaded (the process keeps using whatever env said at startup; the profile's TOML-declared values override the file, not the env). Documented in the load output so it's not surprising.
  • Name validation is load-bearing. `validate_name` rejects empty, oversize (>64 chars), path separators, `..`, and shell metachars. A malicious or careless name cannot escape the profiles directory.

Files

  • New `crates/lib/src/services/profiles.rs` with `save_profile`, `load_profile`, `list_profiles`, `delete_profile`, `ProfileSummary` (~180 LOC)
  • `crates/lib/src/services/mod.rs` — new `pub mod profiles`
  • `crates/cli/src/commands/mod.rs` — new COMMANDS entry + dispatch + `execute_profile` helper

Test plan

  • `cargo fmt --all` clean
  • `cargo check` passes
  • `cargo clippy --no-deps` clean
  • `cargo test -p agent-code-lib --lib profiles` — 5 tests on name validation (accepts safe names, rejects empty / path escape / special chars / oversize)
  • Manual: `/profile save work` → file at `/agent-code/profiles/work.toml`
  • Manual: `/profile list` shows `work` with its model
  • Manual: `/profile load work` swaps the in-memory config
  • Manual: `/profile save ../etc/passwd` → rejected with a clear error, no file written outside profiles dir

`/profile save|load|list|delete` persists Config snapshots under
<config_dir>/agent-code/profiles/<name>.toml. Loading a profile
replaces the runtime config wholesale — merging two user-maintained
configs is where most "why is this setting ignored?" bugs come from,
so the design is deliberately simple.

New `services::profiles` module with save / load / list / delete +
profile-name validation. Name validation is the load-bearing piece:
rejects empty, oversize, path separators, `..`, shell metachars, so
a malicious or careless name can't escape the profiles directory.

Slash command surface:
  /profile                    list saved profiles
  /profile list               (same)
  /profile save <name>        save current config
  /profile load <name>        replace runtime config
  /profile delete <name>      remove
  /profile help               usage

Env var overrides (AGENT_CODE_MODEL etc.) are NOT re-applied on load
— the runtime process keeps using whatever env said at startup, and
/profile load swaps in the TOML-declared values verbatim. Documented
in the load output so it's not a surprise.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit 75a158b into main Apr 23, 2026
13 of 14 checks passed
@emal-avala emal-avala deleted the feat/config-profiles branch April 23, 2026 00:45
@emal-avala emal-avala mentioned this pull request Apr 23, 2026
4 tasks
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.

1 participant