Skip to content

auto_index/auto_watch doesn't follow OpenCode's /cd directory change #2821

Closed as not planned

Description

@cycle2zhou

Environment

  • codebase-memory-mcp 0.12.1, OpenCode (MCP profile: --tool-profile=analysis)
  • auto_index=true, auto_watch=true

Repro

  1. Start OpenCode from $HOME (or any non-target dir).
  2. Run /cd (keybind session.cd).
  3. Query index_status for the new project.

Expected

The new directory is auto-indexed and watched, as if OpenCode started there.

Actual

Nothing is indexed or watched. index_status reports
"watched": false, "reason": "not_session_project".

Root cause

  1. cbm roots auto_index/auto_watch at the MCP session's startup directory, not
    the client's cwd (fix(watcher): show watch state in index_status, correct auto-sync docs (#2167) #2348: "only watches the project an open MCP session is
    rooted in"). /cd changes the session dir without restarting the MCP process,
    so cbm never re-roots.
  2. The plugin cbm-augment.ts reads ctx.directory once at server() init
    (~line 42) and only hooks tool.execute.after + experimental.session.compacting
    — nothing observes a directory change. OpenCode's plugin API also exposes
    directory only as a static load-time value and has no directory-change event.

Suggested direction

Detect session-directory changes (via the plugin or the MCP server) and re-root
auto_index/auto_watch + index_repository for the new root.

Related

Activity

  1. cycle2zhou commented on Oct 28, 2026

    @cycle2zhou
    Author

    Closing after verifying on cbm 0.12.1 + OpenCode.

    The root-cause hypothesis here ("/cd doesn't restart the MCP process, so cbm never re-roots") is incorrect: /cd DOES spawn a new MCP connection (new initialize handshake → new cbm server process), so auto_index/auto_watch follow the new directory. Verified after /cd into klume and tds-connector: both were auto-indexed and watched=true.

    The actual not_session_project symptom is $HOME sensitive-path protection:
    daemon.workspace.skipped operation=watch/auto_index_discovery
    detail=/Users/cycle:_path_is_a_home,_credential,_system,_or_application-install_directory.
    Starting OpenCode from $HOME skips auto_index/watch for the home dir by design (not a /cd bug).

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

    editor/integrationEditor compatibility and CLI integrationux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions