How to Update the Graph Module in Hivemind: Build, Pull, and Automate
To update the graph module in Hivemind, run hivemind graph build to rebuild from source, or hivemind graph pull to download the latest cloud snapshot, and use hivemind graph init to automate updates via Git hooks.
The graph module in the activeloopai/hivemind repository maintains a searchable snapshot of your codebase symbols, enabling AI agents to query your project structure through virtual filesystem paths like ~/.deeplake/memory/graph/index.md. When you modify source code—adding functions, renaming classes, or restructuring files—you must update the graph module to reflect these changes. This guide demonstrates how to rebuild snapshots locally, pull pre-built snapshots from the cloud, and automate the entire process.
Understanding the Graph Lifecycle
The graph module operates through four distinct phases that move data from your source tree to the virtual filesystem.
Build – Walks your project, runs language extractors, and writes a snapshot. This logic resides in runBuildCommand within [src/commands/graph.ts](https://github.com/activeloopai/hivemind/blob/main/src/commands/graph.ts) (lines 12–45, 78–126).
Push – Optionally uploads the snapshot to the cloud after a successful build. The pushSnapshot function (lines 508–514) handles this when you are authenticated with hivemind login.
Pull – Downloads the latest cloud snapshot for the current HEAD. This is implemented in runPullCommand in [src/commands/graph.ts](https://github.com/activeloopai/hivemind/blob/main/src/commands/graph.ts) (lines 442–472).
VFS Read – Synthesizes responses for agent queries like cat ~/.deeplake/memory/graph/index.md without touching the physical filesystem. The entry point is tryGraphRead in [src/graph/graph-command.ts](https://github.com/activeloopai/hivemind/blob/main/src/graph/graph-command.ts) (lines 1–126), which delegates to handleGraphVfs in [src/graph/vfs-handler.ts](https://github.com/activeloopai/hivemind/blob/main/src/graph/vfs-handler.ts) (lines 56–156).
Snapshots live under ~/.hivemind/graphs/<repo-key>/snapshots/ as defined in [src/graph/snapshot.ts](https://github.com/activeloopai/hivemind/blob/main/src/graph/snapshot.ts). The background worker in [src/hooks/graph-pull-worker.ts](https://github.com/activeloopai/hivemind/blob/main/src/hooks/graph-pull-worker.ts) watches for changes and refreshes the in-memory view.
Update the Graph Module Locally
To update the graph module after modifying your code, rebuild the snapshot from the current working tree.
Run the build command:
hivemind graph build
You can specify a different project root:
hivemind graph build --cwd /path/to/your/project
According to the source code in src/commands/graph.ts, this command executes discoverSourceFiles (lines 382–424) to find source files, runs extractFile to parse symbols, caches the results, and finally calls writeSnapshot to persist the data. The builder also queries Git context via readGitCommit and readGitBranch (lines 99–125) to tag the snapshot with the current HEAD.
Update the Graph Module from the Cloud
If a teammate has already built a snapshot for the current commit, avoid redundant extraction by pulling their snapshot.
Run the pull command:
hivemind graph pull
For a different repository:
hivemind graph pull --cwd /other/project
The runPullCommand function (lines 442–472) checks the Deeplake "codebase" table to determine if a newer snapshot exists. If the local snapshot is outdated, it downloads and writes the new version via writeSnapshot logic. This requires prior authentication via hivemind login.
Automate Graph Updates with Git Hooks
Manual updates are error-prone. Automate the process by installing a post-commit hook that rebuilds the graph after every commit.
Install the hook:
hivemind graph init
This installs a managed block in .git/hooks/post-commit through installPostCommitHook in [src/graph/git-hook-install.ts](https://github.com/activeloopai/hivemind/blob/main/src/graph/git-hook-install.ts). The hook runs hivemind graph build --trigger post-commit asynchronously, ensuring commits never block your workflow.
To remove automation:
hivemind graph uninstall
This cleans the hook while leaving existing snapshots intact.
Verify Your Graph Updates
After building or pulling, confirm the update by querying the virtual filesystem:
# Show repository index
cat ~/.deeplake/memory/graph/index.md
# Search for symbols containing "auth"
cat ~/.deeplake/memory/graph/find/auth
# Display details of the first match
cat ~/.deeplake/memory/graph/show/1
These commands are parsed by parseReadTargetPath and dispatched through tryGraphRead in src/graph/graph-command.ts.
Summary
- Rebuild locally with
hivemind graph buildto extract symbols from your current working tree. - Download from cloud with
hivemind graph pullto fetch pre-built snapshots for the current HEAD. - Automate updates by running
hivemind graph initto install a post-commit Git hook. - Remove automation with
hivemind graph uninstallwhen manual control is preferred. - Verify updates by querying paths like
~/.deeplake/memory/graph/index.mdthrough the VFS.
Frequently Asked Questions
How do I update the graph module without rebuilding everything?
Use hivemind graph pull to download the latest snapshot that a teammate has already built and pushed to the cloud. This bypasses the extraction phase entirely and is faster than local rebuilding.
Where does Hivemind store graph snapshots locally?
Snapshots are stored under ~/.hivemind/graphs/<repo-key>/snapshots/ as defined in src/graph/snapshot.ts. The VFS reads from this location to serve paths like ~/.deeplake/memory/graph/index.md without accessing the physical project files.
What is the difference between hivemind graph build and hivemind graph init?
hivemind graph build performs a one-time extraction of your codebase symbols, while hivemind graph init installs a permanent Git hook that automatically runs hivemind graph build after every commit to keep the graph synchronized.
Can I automate graph updates in CI/CD pipelines?
Yes, run hivemind graph build in your CI pipeline after checkout to generate fresh snapshots for deployment, or run hivemind graph pull to retrieve cached snapshots if your build agents have hivemind login credentials configured.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →