Skip to content

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

Closed

Description

@edenreich

Summary

infer init currently writes the full config set into a project's ./.infer/, so every repo duplicates config that is
really the same across all of a user's projects (keybindings, prompts, gateway/model defaults, ...).

Flip to a userspace-first model:

  • infer init seeds the global baseline in ~/.infer/ by default.
  • A project's ./.infer/ carries only the settings it overrides — for config.yaml that is a sparse file merged on top
    of the home one, key by key.
  • Files that are inherently personal, machine-, or secret-scoped live only in ~/.infer/ and are never seeded into a
    project.

Net effect: set up once in ~/.infer/, reuse everywhere; a project commits only its genuine overrides.

Behavior change

Today Proposed
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

Per-file classification

Each config file gets a scope label. infer init seeds userspace-only files to ~/.infer/ regardless of --project.

File Scope Rationale
config.yaml project-overridable gateway / model / tools / storage; sparse overlay on home
prompts.yaml project-overridable a project may ship custom agent instructions / tool docs
agents.yaml project-overridable A2A integrations the project depends on
mcp.yaml project-overridable MCP servers the project depends on
hooks.yaml project-overridable project build / test / lint hooks
shortcuts/ project-overridable project chat commands (committed)
skills/ project-overridable project skills (committed)
keybindings.yaml userspace-only personal keyboard preferences
computer_use.yaml userspace-only machine / display settings
heartbeat.yaml userspace-only personal wake-up schedule
reminders.yaml userspace-only personal workflow nudges
channels.yaml userspace-only holds bot tokens / secrets
memory (memory.yaml + store) userspace-only already global today

Approach

  1. infer init scope (cmd/init.go) — drop --userspace, add --project. Default seeds the full baseline to ~/.infer/;
    --project seeds only the project-overridable files (a minimal/empty override scaffold) into ./.infer/. Userspace-only
    files always go to ~/.infer/ (as memory already does). The one-time legacy migration for channels / computer_use
    (a config.yaml block → its own file) should target ~/.infer/.
  2. Sparse merge (cmd/root.go initConfig) — load ~/.infer/config.yaml as the base, then MergeInConfig the project
    ./.infer/config.yaml on top (precedence: defaults < home < project < flags < env). This makes the
    mergeGlobalSandboxDirs / MergeSandboxDirectories workaround (cmd/config.go) obsolete — remove it. Re-check the
    logDir fallback, which keys off V.ConfigFileUsed().
  3. Write target (cmd/config_getset.go, GetUserspaceFlag in cmd/config.go) — flip the default so config set writes to
    home; --project writes a sparse project override (reuse the existing fresh-viper sparse-write logic, pointed at the project
    path). Remove --userspace from config, keybindings, mcp, agents.
  4. Callers — internal/web/pty_manager.go and internal/web/remote_installer.go call infer init --userspace; switch to
    plain infer init.
  5. Docs — rewrite docs/directory-structure.md ("The Two Layers", seeded-files list, commit guidance) and update
    README.md (Configuration Layers + the --userspace examples), docs/commands-reference.md, docs/configuration-reference.md.
    Add the classification table.
  6. Tests — update cmd/init_test.go (default-home + --project; assert userspace-only files never land in the project) and
    cmd/channels_overlay_test.go; add a config.yaml home+project merge test and a config set --project sparse-write test.

Acceptance criteria

  • infer init defaults to ~/.infer/; infer init --project writes a project override layer; --userspace is gone.
  • Userspace-only files (keybindings, computer_use, heartbeat, reminders, channels, memory) are only ever seeded to ~/.infer/.
  • A project config.yaml merges onto the home one key-by-key (sparse overrides work); config set --project writes only the
    changed key.
  • Every config file has a documented scope label (table above).
  • --userspace removed from all commands (init, config, keybindings, mcp, agents) and from the web auto-init callers.
  • Docs and tests updated.

Out of scope

  • Per-key merge for the split-out files — they override at file granularity (omit the file to inherit home). Only
    config.yaml merges per key.
  • Backward compatibility for --userspace — the flag is simply removed.

Activity

  1. added
    refactor
    on Jun 28, 2026
  2. added theissue type on Jun 28, 2026
  3. changed the title [-][TASK] Move userspace configs to home directory[/-] [+][TASK] Move project-space configs to home directory[/+] on Jun 28, 2026
  4. changed the title [-][TASK] Move project-space configs to home directory[/-] [+][TASK] Make config userspace-first: infer init defaults to home, projects hold only overrides[/+] on Jun 28, 2026
  5. moved this to Todo in 2026on Jun 28, 2026
  6. edenreich commented on Jun 28, 2026

    @edenreich
    ContributorAuthor

    @infer /model ollama_cloud/glm-5.2 Can you work on this? use skills from .agents/skills directory to ensure you follow best practices. use /go /cobra-viper

  7. inference-gateway-maintainer commented on Jun 28, 2026

    @inference-gateway-maintainer
    Contributor

    View Job

    Todos

    • Rewrite cmd/init.go — drop --userspace, add --project, default seeds home
    • [~] Update cmd/root.go initConfig for sparse merge (home + project config.yaml), remove mergeGlobalSandboxDirs workaround
    • Update cmd/config.go — remove --userspace, add --project, flip GetUserspaceFlag, remove mergeGlobalSandboxDirs
    • Update cmd/config_getset.go — flip write target to home, --project writes sparse
    • Update cmd/agents.go — remove --userspace, add --project
    • Update cmd/mcp.go — remove --userspace, add --project
    • Update cmd/keybindings.go — remove --userspace, add --project
    • Update web callers (pty_manager.go, remote_installer.go) — switch to plain infer init
    • Update conversation_view.go getConfigType
    • Update tests (init_test.go, channels_overlay_test.go, add merge + sparse-write tests)
    • Update docs (directory-structure.md, README.md, commands-reference.md, configuration-reference.md, agents-configuration.md)
    • Update AGENTS.md / CLAUDE.md
    • Build and verify (go build, go test)

    Pull Request

    #682

    ⚠️ Infer Result: Stopped early

    The agent hit the job's time limit before finishing, so it was stopped to salvage its work. Its committed changes were pushed; the draft pull request is linked above.

    Let me read all the key files mentioned in the issue to understand the full scope.

    Model: ollama_cloud/glm-5.2 · Exit Code: 0 · Duration: -

    Tokens: 8,050,826 in · 71,299 out · 8,122,125 total (107 requests)

    Tool calls: 237 total · 98% success rate

    ⚠️ 5 failed tool call(s)
    • TodoWrite: todos parameter is required and must be an array
    • Edit: old_string not found in file /home/runner/work/cli/cli/cmd/init.go

    Possible matches found:

    Near line 15:
    var initCmd = &cobra.Command{
    Use: "init",
    Short: "Initialize a new project with Inference Gateway CLI",
    Long: `Initialize a new project directory with Inference Gateway CLI configuration.
    This creates the .infer directory with configuration file and additional setup files like .gitignore.

    To generate an AGENTS.md file, use the /init shortcut in interactive chat mode,
    which allows you to see the agent's analysis in real-time.

    This is the recommended command to start working with Inference Gateway CLI in a new project.`,
    RunE: func(cmd *cobra.Command, args []string) error {
    return initializeProject(cmd)
    },
    }

    func init() {
    initCmd.Flags().Bool("overwrite", false, "Overwrite existing files if they already exist")
    initCmd.Flags().Bool("userspace", false, "Initialize configuration in user home directory (~/.infer/)")
    initCmd.Flags().Bool("skip-migrations", false, "Skip running database migrations")
    rootCmd.AddCommand(initCmd)
    }

    func initializeProject(cmd *cobra.Command) error { //nolint:funlen,gocyclo,cyclop
    overwrite, _ := cmd.Flags().GetBool("overwrite")
    userspace, _ := cmd.Flags().GetBool("userspace")
    skipMigrations, _ := cmd.Flags().GetBool("skip-migrations")

    var configPath, gitignorePath, scmShortcutsPath, gitShortcutsPath,
    	mcpShortcutsPath, shellsShortcutsPath, exportShortcutsPath,
    	envShortcutsPath, a2aShortcutsPath, skillsShortcutsPath, mcpPath, keybindingsPath, promptsPath,
    	remindersPath, hooksPath, channelsPath, heartbeatPath, computerUsePath, agentsPath, skillsDirPath,
    	memoryConfigPath string
    
    if userspace {
    	homeDir, err := os.UserHomeDir()
    	if err != nil {
    		return fmt.Errorf("failed to get user home directory: %w", err)
    	}
    	configPath = filepath.Join(homeDir, config.ConfigDirName, config.ConfigFileName)
    	gitignorePath = filepath.Join(homeDir, config.ConfigDirName, config.GitignoreFileName)
    	scmShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "scm.yaml")
    	gitShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "git.yaml")
    	mcpShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "mcp.yaml")
    	shellsShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "shells.yaml")
    	exportShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "export.yaml")
    	envShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "env.yaml")
    	a2aShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "a2a.yaml")
    	skillsShortcutsPath = filepath.Join(homeDir, config.ConfigDirName, "shortcuts", "skills.yaml")
    	mcpPath = filepath.Join(homeDir, config.ConfigDirName, config.MCPFileName)
    	keybindingsPath = filepath.Join(homeDir, config.ConfigDirName, config.KeybindingsFileName)
    	promptsPath = filepath.Join(homeDir, config.ConfigDirName, config.PromptsFileName)
    	remindersPath = filepath.Join(homeDir, config.ConfigDirName, config.RemindersFileName)
    	hooksPath = filepath.Join(homeDir, config.ConfigDirName, config.HooksFileName)
    	channelsPath = filepath.Join(homeDir, config.ConfigDirName, config.ChannelsFileName)
    	heartbeatPath = filepath.Join(homeDir, config.ConfigDirName, config.HeartbeatFileName)
    	computerUsePath = filepath.Join(homeDir, config.ConfigDirName, config.ComputerUseFileName)
    	agentsPath = filepath.Join(homeDir, config.ConfigDirName, config.AgentsFileName)
    	skillsDirPath = filepath.Join(homeDir, config.ConfigDirName, "skills")
    } else {
    	configPath = config.DefaultConfigPath
    	gitignorePath = filepath.Join(config.ConfigDirName, config.GitignoreFileName)
    	scmShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "scm.yaml")
    	gitShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "git.yaml")
    	mcpShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "mcp.yaml")
    	shellsShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "shells.yaml")
    	exportShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "export.yaml")
    	envShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "env.yaml")
    	a2aShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "a2a.yaml")
    	skillsShortcutsPath = filepath.Join(config.ConfigDirName, "shortcuts", "skills.yaml")
    	mcpPath = filepath.Join(config.ConfigDirName, config.MCPFileName)
    	keybindingsPath = config.DefaultKeybindingsPath
    	promptsPath = config.DefaultPromptsPath
    	remindersPath = config.DefaultRemindersPath
    	hooksPath = config.DefaultHooksPath
    	channelsPath = config.DefaultChannelsPath
    	heartbeatPath = config.DefaultHeartbeatPath
    	computerUsePath = config.DefaultComputerUsePath
    	agentsPath = config.DefaultAgentsPath
    	skillsDirPath = filepath.Join(config.ConfigDirName, "skills")
    }
    
    // Memory is a global concern - the store lives in ~/.infer/memory and is shared
    // across every project - so its config file is always seeded in the home
    // directory, regardless of init scope, and is created only when absent (below).
    memHome, err := os.UserHomeDir()
    if err != nil {
    	return fmt.Errorf("failed to get user home directory: %w", err)
    }
    memoryConfigPath = filepath.Join(memHome, config.ConfigDirName, config.MemoryConfigFileName)
    
    if !overwrite {
    	if err := validateFilesNotExist(configPath, gitignorePath, scmShortcutsPath, gitShortcutsPath, mcpShortcutsPath, shellsShortcutsPath, exportShortcutsPath, envShortcutsPath, a2aShortcutsPath, skillsShortcutsPath, mcpPath, keybindingsPath, promptsPath, remindersPath, hooksPath, channelsPath, heartbeatPath, computerUsePath, agentsPath); err != nil {
    		return err
    	}
    }
    

    Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.

    • TodoWrite: todos parameter is required and must be an array
    • Edit: old_string not found in file /home/runner/work/cli/cli/cmd/init.go

    Possible matches found:

    Near line 15:
    var initCmd = &cobra.Command{
    Use: "init",
    Short: "Initialize Inference Gateway CLI configuration",
    Long: `Initialize Inference Gateway CLI configuration in the user home directory (~/.infer/).

    By default, this seeds the full baseline configuration to ~/.infer/ so it is shared
    across all of your projects. Pass --project to create a project-level override layer
    in ./.infer/ instead — only project-overridable files are seeded there as a sparse
    scaffold; personal, machine-, or secret-scoped files always live in ~/.infer/.

    To generate an AGENTS.md file, use the /init shortcut in interactive chat mode,
    which allows you to see the agent's analysis in real-time.

    This is the recommended command to start working with Inference Gateway CLI.`,
    RunE: func(cmd *cobra.Command, args []string) error {
    return initializeProject(cmd)
    },
    }

    func init() {
    initCmd.Flags().Bool("overwrite", false, "Overwrite existing files if they already exist")

    Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.

    • Read: NOT_FOUND

    Triggered by edenreich · Infer Action

  8. moved this from Todo to Done in 2026on Jun 30, 2026
  9. inference-gateway-releaser commented on Jun 30, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.126.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions