feat(plugin:codebase-memory): v0.2.0 — SQLite-direct Cytoscape graph (no daemon, ~30 MB vs 6 GB)#7
Open
SirMinionBot wants to merge 1 commit into
Open
Conversation
…(no daemon) The v0.1.0 plugin (PR #5) embedded the upstream SPA via iframe and required the codebase-memory-mcp binary running on :9749. The binary allocates 50% of system RAM at startup (mem.init budget_mb = total_ram_mb / 2), which OOM-kills on hosts with <12 GB free — fatal on this 11 GB / 0-swap host. This version replaces the iframe with a native Cytoscape.js renderer that reads the binary's own SQLite index files directly via stdlib sqlite3. The binary is no longer required at runtime — only the *.db files it has already written to ~/.cache/codebase-memory-mcp/. Architecture Backend (plugin_api.py) GET /health binary-independent GET /projects with size-based mega-project filter GET /project/{name}/health GET /layout?project=X&max_nodes=N&labels=... Cytoscape-ready graph payload GET /search?q=X FTS5 BM25 GET /code?project=X&qualified_name=Y source snippet Frontend (dist/index.js, dist/style.css) React component, Cytoscape.js 3.30 vendored (dist/vendor/), no SPA iframe. Renders graph in 2D with cose layout, sidebar with project list + search, detail panel on node click. Tests (tests/test_plugin_api.py) 9 pytest cases against a synthetic 4-node/4-edge DB: health shape, project list, layout validation, FTS sanitization, size filter, label filter, 1-hop neighborhood expansion. Runs in ~1.2 s. Performance (codigosinsiesta, 748 nodes / 861 edges / 2.8 MB DB) /health <10 ms /projects <50 ms /layout 19 ms cold, 5 ms warm /search <20 ms /code <10 ms Cytoscape layout on 518 nodes: ~150-300 ms in browser Working-set: ~30 MB (Python + Cytoscape bundle) vs 6 GB for the binary. Size filter: projects with >50k nodes are hidden by default (lobehub at 401k). Override with CBM_MAX_PROJECT_NODES=0. Cross-user: the plugin runs as hermesbot but reads DBs at /home/ibid/.cache/codebase-memory-mcp/ via the path resolved at startup (CBM_DB_DIR or config.yaml plugin block). Backwards-compat: this version keeps the same plugin slug 'codebase-memory' so the existing PR #5 host wiring (manifest, discovery, /api/plugins/codebase-memory/ mount) continues to work. A future v0.3.0 may re-introduce the iframe as a fallback for users who want the upstream 3D renderer; v0.2.0 is the recommended path on memory-constrained hosts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
v0.1.0 (PR #5) embedded the upstream SPA via iframe and required the
codebase-memory-mcpbinary running on :9749. The binary allocates50% of system RAM at startup (
mem.init budget_mb = total_ram_mb / 2)— on this 11 GB / 0-swap host, that OOM-kills within 1 s of
--ui=true.The binary is otherwise excellent: it indexes a repo into a tidy SQLite
DB at
~/.cache/codebase-memory-mcp/<project>.dbwith FTS5 search, andits 13-tool MCP API is well-designed. The 6 GB cost is a property of the
in-memory graph engine, not of the data — the DB file itself is 2.8 MB
for our 748-node project.
What this PR does
Replaces the iframe with a native Cytoscape.js renderer that reads
the binary's SQLite index directly via stdlib
sqlite3. The binaryis no longer required at runtime.
Endpoint shape (mounted at /api/plugins/codebase-memory/)
GET /health— binary-independent health snapshotGET /projects— list DBs with size-based mega-project filter (50k default)GET /project/{name}/health— per-project statsGET /layout?project=X&max_nodes=N&labels=...— Cytoscape-ready graphGET /search?q=X— FTS5 BM25GET /code?project=X&qualified_name=Y— source snippet readPerformance (codigosinsiesta, 748 nodes, 2.8 MB DB)
Working-set: ~30 MB (Python + Cytoscape bundle) vs 6 GB for the binary.
Frontend
codebase-memoryslotdist/vendor/cytoscape.min.js(same pattern asknowledge-graph)Tests
tests/test_plugin_api.py— 9 cases against a synthetic 4-node DB:Compatibility
codebase-memory— existing host wiring unchangedname,label,entry,css,api)versionto 0.2.0upstream 3D SPA again, revert to v0.1.0 or open a v0.3.0 PR with
both modes selectable.
How to verify
Closes #N/A — there's no open issue; this is a follow-up to PR #5
discovered when validating the iframe plugin on the 11 GB host.