Skip to content

refactor: make infer config userspace-first - #682

Merged
edenreich merged 5 commits into
mainfrom
fix/issue-680
Jun 29, 2026
Merged

edenreich merged 5 commits into
mainfrom
fix/issue-680

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Flip infer configuration to a userspace-first model. infer init now seeds the full
configuration baseline to ~/.infer/ so it is shared across every project, and a project's
./.infer/ carries only the settings it overrides. A project config.yaml is merged onto
the home one key-by-key, so a repo commits just its genuine overrides and inherits everything
else from the userspace baseline.

Resolves #680.

Motivation

Previously infer init wrote the full config set into each project's ./.infer/, so every
repo duplicated configuration that is really the same across all of a user's projects
(keybindings, prompts, gateway/model defaults, ...). Now you set up once in ~/.infer/ and reuse
it everywhere; a project commits only what it genuinely changes.

Behavior changes

Before After
infer init target project ./.infer/ (full set) home ~/.infer/ (full baseline)
Project scope the default infer init --project (overrides only)
--userspace flag opt in to home removed (home is the default)
config.yaml resolution project file replaces home project file merges onto home (per key)
config set default target project (full file) home; --project writes a sparse override

The same --userspace -> --project flip applies to the config, keybindings, mcp, and
agents commands.

What's in this PR

infer init scope (cmd/init.go)

  • Drop --userspace, add --project. The default now seeds the full baseline to ~/.infer/;
    --project seeds only the project-overridable files into ./.infer/ as a sparse scaffold.
  • Userspace-only files (keybindings, reminders, channels, heartbeat, computer_use, memory) are
    always seeded to ~/.infer/ and created only-if-absent (new createFileIfAbsent / fileExists
    helpers), so a later --project init never clobbers them, and the "Created:" output only lists
    files that were actually written.
  • .env.example is now project-only scaffolding (createProjectEnvExample).
  • New createSparseConfigScaffold writes a minimal, commented project config.yaml.

Layered config merge (cmd/root.go)

  • New loadLayeredConfig reads ~/.infer/config.yaml as the base layer, then MergeInConfigs
    the project ./.infer/config.yaml (or ./config.yaml) on top. Net precedence:
    defaults < home < project < flags < env. A project that omits config.yaml inherits home
    wholesale, and a single file is never merged onto itself.

Sparse writes (cmd/config_getset.go, internal/utils/config.go)

  • config set writes to ~/.infer/ by default; --project writes a sparse override (only
    the changed key) into ./.infer/ via the new WriteViperConfigSparse. Both files stay sparse,
    so the merged/effective config is never written back.

Remove the sandbox-merge workaround (cmd/config.go, config/config.go)

  • The real key-by-key merge makes the old mergeGlobalSandboxDirs / Config.MergeSandboxDirectories
    hack obsolete; both are removed, along with config/sandbox_merge_test.go.

Flag rename (cmd/config.go, cmd/keybindings.go, cmd/mcp.go, cmd/agents.go)

  • --userspace -> --project (GetUserspaceFlag -> GetProjectFlag), inverting the default so
    writes target the home baseline unless --project is passed.

Web auto-init callers (internal/web/pty_manager.go, internal/web/remote_installer.go)

  • infer init --userspace -> plain infer init.

Tests

  • Rewrote cmd/init_test.go for the default-home / --project behavior; added
    cmd/userspace_first_test.go covering the home+project merge and the sparse config set --project
    write; removed the obsolete config/sandbox_merge_test.go.

Breaking changes

  • The --userspace flag is removed from init, config, keybindings, mcp, and agents.
    ~/.infer/ is now the default write target; use --project for project-scoped writes.
  • infer init with no flags now writes to ~/.infer/ instead of ./.infer/.

Not included / follow-up

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title fix: resolve #680 feat: make infer config userspace-first Jun 29, 2026
@edenreich
edenreich marked this pull request as ready for review June 29, 2026 07:55
@edenreich
edenreich requested a review from a team as a code owner June 29, 2026 07:55
Comment thread cmd/config_getset.go Resolved
Comment thread cmd/init_test.go Resolved
Comment thread cmd/userspace_first_test.go Resolved
Co-authored-by: Eden Reich <[email protected]>
@edenreich edenreich changed the title feat: make infer config userspace-first refactor: make infer config userspace-first Jun 29, 2026
@edenreich
edenreich merged commit 1e77e42 into main Jun 29, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-680 branch June 29, 2026 08:05
inference-gateway-releaser Bot added a commit that referenced this pull request Jun 30, 2026
## [0.126.0](v0.125.0...v0.126.0) (2026-06-30)

### 🚀 Features

* add persistent memory tool for agent ([#679](#679)) ([a487b13](a487b13))
* **agent:** interactive subagent management and unified background-work tracking ([#684](#684)) ([343e083](343e083))

### 🐛 Bug Fixes

* **chat:** bind opt+backspace and ctrl+backspace to delete-word-backward ([#697](#697)) ([173fe83](173fe83)), closes [#689](#689) [#576](#576)
* **a2a:** retain completed background tasks in /tasks ([#691](#691)) ([#701](#701)) ([43b8e13](43b8e13))
* **autocomplete:** surface arguments for one-of/all-optional tool schemas ([#698](#698)) ([655b2e4](655b2e4))

### ♻️ Code Refactoring

* add .gitignore by default to the projects dir ([4717deb](4717deb))
* enable memory by default ([86c2158](86c2158))
* make infer config userspace-first ([#682](#682)) ([1e77e42](1e77e42)), closes [#680](#680)
* **tui:** single event-loop ingress - one notifier, no self-rescheduling pollers ([#700](#700)) ([2ab8854](2ab8854))
* standardize comment punctuation by replacing em dashes with hyphens ([78f53a8](78f53a8))

### 📚 Documentation

* fix docs/ drift found by the README-to-codebase audit ([#687](#687)) ([413047a](413047a)), closes [#572](#572) [#686](#686)
* sync README and reference docs with the codebase ([#685](#685)) ([c328423](c328423)), closes [#572](#572) [#684](#684) [#684](#684)

### 👷 CI/CD

* **deps:** update CLAUDE workflow to version 0.14.5 ([eaba2b3](eaba2b3))

### 🧹 Maintenance

* add .infer to .gitignore ([08ef319](08ef319))
* **deps:** bump infer CLI v0.124.0 -> v0.125.0, infer-action v0.19.0 -> v0.19.1 ([#681](#681)) ([e9e7e21](e9e7e21))
* remove agent definitions ([4f7fd7d](4f7fd7d))
* remove unused configuration and shortcut files ([4c611db](4c611db))
* update claude-code to 2.1.191 ([729e81c](729e81c))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.126.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Make config userspace-first: infer init defaults to home, projects hold only overrides

1 participant