Summary
try_codegraph_init(force=True) rebuilds the index by removing .codegraph/
with shutil.rmtree and then running codegraph init. In the default install
this never takes effect, yet the run still prints codegraph index built.
oh-my-openagent makes .codegraph a symlink into
~/.omo/codegraph/projects/, and shutil.rmtree refuses to remove a symlink —
the OSError is swallowed by ignore_errors=True. codegraph init then sees an
index already there and no-ops. Both steps do nothing.
Measured
Two projects, both def alpha(), each indexed once. Change the source to
def beta(), then call try_codegraph_init(force=True):
.codegraph is a real directory index = ['beta'] -> rebuilt
.codegraph is a symlink index = ['alpha'] -> not rebuilt
A real incremental run (edit source → commit → --incremental) produced correct
output, but what corrected the index was not the rebuild — it was the codegraph
daemon: [CodeGraph MCP] Auto-synced 1 file(s). The index FM-Agent analyses is
not the one it builds.
The path is reached whenever an index already exists and force=True: full runs
from the second onwards, incremental mode, entry-func mode. Separately, the
rmtree runs unconditionally, so a rebuild that does not happen leaves nothing
behind and nothing rolls it back.
Proposal
Replace rmtree + init with codegraph index — the command codegraph provides
for exactly this ("Rebuild the full index from scratch, same result as a fresh
init"), with no manual deletion. Measured on the same setup: a symlinked, stale
['alpha'] index becomes ['beta'].
Summary
try_codegraph_init(force=True)rebuilds the index by removing.codegraph/with
shutil.rmtreeand then runningcodegraph init. In the default installthis never takes effect, yet the run still prints
codegraph index built.oh-my-openagent makes
.codegrapha symlink into~/.omo/codegraph/projects/, andshutil.rmtreerefuses to remove a symlink —the
OSErroris swallowed byignore_errors=True.codegraph initthen sees anindex already there and no-ops. Both steps do nothing.
Measured
Two projects, both
def alpha(), each indexed once. Change the source todef beta(), then calltry_codegraph_init(force=True):A real incremental run (edit source → commit →
--incremental) produced correctoutput, but what corrected the index was not the rebuild — it was the codegraph
daemon:
[CodeGraph MCP] Auto-synced 1 file(s). The index FM-Agent analyses isnot the one it builds.
The path is reached whenever an index already exists and
force=True: full runsfrom the second onwards, incremental mode, entry-func mode. Separately, the
rmtreeruns unconditionally, so a rebuild that does not happen leaves nothingbehind and nothing rolls it back.
Proposal
Replace
rmtree+initwithcodegraph index— the command codegraph providesfor exactly this ("Rebuild the full index from scratch, same result as a fresh
init"), with no manual deletion. Measured on the same setup: a symlinked, stale
['alpha']index becomes['beta'].