Skip to content

[BUG] GeminiClientAdapter ignores project_root/user_scope and writes MCP config under cwd #1296

@imk1t

Description

@imk1t

Describe the bug
GeminiClientAdapter resolves .gemini/settings.json from os.getcwd() instead of the adapter's project_root / scope-aware path context. When callers instantiate the adapter with project_root=..., MCP config is skipped or written under the current process cwd rather than the target project. This breaks non-cwd installs and makes Gemini inconsistent with other repo-local MCP adapters.

To Reproduce
Steps to reproduce the behavior:

  1. From a checkout that is not the target project, run:
    from pathlib import Path
    from tempfile import TemporaryDirectory
    from apm_cli.adapters.client.gemini import GeminiClientAdapter
    
    with TemporaryDirectory() as tmp:
        root = Path(tmp)
        (root / ".gemini").mkdir()
        adapter = GeminiClientAdapter(project_root=root)
        adapter.update_config({"srv": {"command": "node"}})
    
        print("expected exists:", (root / ".gemini" / "settings.json").exists())
        print("actual adapter path:", adapter.get_config_path())
  2. Observe that expected exists is False.
  3. Observe that get_config_path() points at <cwd>/.gemini/settings.json.

Expected behavior
GeminiClientAdapter(project_root=root) should read and write root/.gemini/settings.json. If user scope is supported, user-scope behavior should be explicit and consistent with the target profile rather than silently using cwd.

Environment (please complete the following information):

  • OS: Darwin 25.4.0 arm64
  • Python Version: 3.12.12
  • APM Version: 0.13.0 (9020aca)
  • VSCode Version (if relevant): N/A

Logs
Current code path:

  • src/apm_cli/adapters/client/gemini.py uses Path(os.getcwd()) in get_config_path().
  • update_config() also gates on Path(os.getcwd()) / ".gemini".

Observed local repro:

expected_exists False
adapter_path /Users/ko1/.codex/worktrees/7541/apm/.gemini/settings.json

Additional context
This appears separate from #1266, which covers Gemini stdio env placeholder resolution, and #1062, which covered Gemini opt-in behavior. This issue is specifically about path/scope routing: adapter construction accepts project_root, but Gemini ignores it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions