devsmind-mcp 2.2.0 β†’ 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +234 -527
  2. package/dist/cli/analyze.d.ts +13 -0
  3. package/dist/cli/analyze.js +143 -0
  4. package/dist/cli/analyze.js.map +1 -0
  5. package/dist/cli/index.js +76 -0
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/integrations/memory.d.ts +11 -0
  8. package/dist/cli/integrations/memory.js +156 -0
  9. package/dist/cli/integrations/memory.js.map +1 -0
  10. package/dist/cli/integrations/prompt.d.ts +5 -1
  11. package/dist/cli/integrations/prompt.js +29 -7
  12. package/dist/cli/integrations/prompt.js.map +1 -1
  13. package/dist/cli/integrations/registry.d.ts +35 -0
  14. package/dist/cli/integrations/registry.js +59 -0
  15. package/dist/cli/integrations/registry.js.map +1 -1
  16. package/dist/cli/rule.js +37 -46
  17. package/dist/cli/rule.js.map +1 -1
  18. package/dist/cli/sync.d.ts +7 -0
  19. package/dist/cli/sync.js +40 -7
  20. package/dist/cli/sync.js.map +1 -1
  21. package/dist/cli/workflow.d.ts +8 -0
  22. package/dist/cli/workflow.js +156 -0
  23. package/dist/cli/workflow.js.map +1 -0
  24. package/dist/db/analyze.d.ts +67 -0
  25. package/dist/db/analyze.js +163 -0
  26. package/dist/db/analyze.js.map +1 -0
  27. package/dist/db/database.d.ts +166 -3
  28. package/dist/db/database.js +700 -64
  29. package/dist/db/database.js.map +1 -1
  30. package/dist/db/schema.d.ts +28 -1
  31. package/dist/db/schema.js +34 -0
  32. package/dist/db/schema.js.map +1 -1
  33. package/dist/db/staging.d.ts +4 -0
  34. package/dist/db/staging.js +16 -2
  35. package/dist/db/staging.js.map +1 -1
  36. package/dist/db/workflow-import.d.ts +22 -0
  37. package/dist/db/workflow-import.js +116 -0
  38. package/dist/db/workflow-import.js.map +1 -0
  39. package/dist/mcp/server.d.ts +9 -0
  40. package/dist/mcp/server.js +417 -27
  41. package/dist/mcp/server.js.map +1 -1
  42. package/dist/utils/config.d.ts +2 -0
  43. package/dist/utils/config.js +11 -0
  44. package/dist/utils/config.js.map +1 -1
  45. package/dist/utils/git.d.ts +14 -0
  46. package/dist/utils/git.js +43 -0
  47. package/dist/utils/git.js.map +1 -0
  48. package/dist/utils/scanner.d.ts +7 -0
  49. package/dist/utils/scanner.js +9 -3
  50. package/dist/utils/scanner.js.map +1 -1
  51. package/package.json +1 -1
package/README.md CHANGED
@@ -1,527 +1,234 @@
1
- # 🧠 DevsMind β€” Team AI Brain
2
-
3
- [![NPM Version](https://img.shields.io/npm/v/devsmind-mcp?color=blue)](https://www.npmjs.com/package/devsmind-mcp)
4
- [![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/Abialidr/devsmind/blob/main/LICENSE)
5
- [![Awesome MCP](https://img.shields.io/badge/MCP-Awesome-purple)](https://modelcontextprotocol.io)
6
-
7
- > **The evolutionary collective memory layer for your AI coding agents. Shared across your entire team.**
8
-
9
- AI agents (like Cursor, Cline, Copilot, or Antigravity) lose all context between sessions. Teams repeat the same conversations, new developers ask questions answered months ago, and the same bug gets fixed twice because nobody remembered the first fix.
10
-
11
- Git tells you **WHAT** changed. **DevsMind tells your AI agent WHY it changed, WHO decided it, WHAT requirement it served, and WHAT broke before.**
12
-
13
- ```
14
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
15
- β”‚ DevsMind MCP Server β”‚
16
- β”‚ (installed once globally on machine) β”‚
17
- β”‚ β”‚
18
- β”‚ Stateless. Holds no data. β”‚
19
- β”‚ Receives devmind_path on every call. β”‚
20
- β”‚ Opens .devmind/brain.db at that path. β”‚
21
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
22
- β”‚ devmind_path on every call
23
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
24
- β–Ό β–Ό
25
- c:\work\my-project\.devmind\ c:\work\other-project\.devmind\
26
- brain.db brain.db
27
- (Project A team brain) (Project B team brain)
28
- ```
29
-
30
- ---
31
-
32
- ## πŸš€ Key Features
33
-
34
- * **Function-Level Evolution Graph**: Every class, method, schema, endpoint, or function is mapped with a rich history chain.
35
- * **AI-Written Context Snapshots**: As you work, your AI agent documents the *why, goal, previous state, decision rationale, model, and ticket ID* in real-time.
36
- * **Token-Surgical MCP Interface**: AI can inspect function relationships, histories, and code snapshots *without* reading entire directories or files, reducing token costs by **up to 70%**.
37
- * **Stateless MCP Server**: A single server handles multiple distinct workspaces. The active directory configuration is injected dynamically from the IDE's Workspace Rule.
38
- * **D3.js 2D/3D Interactive Visualizer**: Explore, search, and navigate your code architecture and connection graphs in the browser with stunning force-directed layouts.
39
- * **Git-Native Collaboration**: The database and configuration are committed to Git, enabling seamless context sharing among team members.
40
-
41
- ---
42
-
43
- ## πŸ› οΈ Architecture: The `.devmind/` Directory
44
-
45
- Running `devsmind init` creates a `.devmind/` directory in your workspace. This folder contains the configuration, distributed graph database, and local cache:
46
-
47
- ```
48
- .devmind/
49
- β”œβ”€β”€ config.json ← Project metadata & repository mapping (Committed to Git)
50
- β”œβ”€β”€ .env ← Local developer machine paths (Gitignored)
51
- β”œβ”€β”€ brain.db ← Metadata-only SQLite cache database (Gitignored)
52
- β”œβ”€β”€ history/ ← Distributed change logs & code snapshots as JSON (Committed to Git)
53
- β”‚ └── [id].json
54
- └── graph/ ← Distributed graph structure JSON files (Committed to Git)
55
- └── [repo_name]/
56
- └── [path].json
57
- ```
58
-
59
- ### Flexibility: Where should the brain live?
60
-
61
- DevsMind supports two deployment topologies depending on your team's workflow:
62
-
63
- * **Option A: Inside the workspace/project root directory (Shared with team)**
64
- ```
65
- c:\work\my-project\
66
- β”œβ”€β”€ .devmind\ ← Config and distributed JSON database live here
67
- β”œβ”€β”€ backend-service\
68
- └── frontend-web\
69
- ```
70
- * **Option B: Standalone folder (Fully separated)**
71
- ```
72
- c:\Users\username\brains\my-project\
73
- └── .devmind\ ← Brain is kept separate from code folders
74
- ```
75
-
76
- ---
77
-
78
- ## ⚑ Quick Start
79
-
80
- DevsMind is installed **once per machine**, but there are two different first-time flows depending on whether you're *creating* a brain for a project or *joining* one a teammate already created. Both start with the global install:
81
-
82
- ```bash
83
- npm install -g devsmind-mcp
84
- ```
85
-
86
- The MCP connection and the workspace rule are **per-developer, per-tool** β€” they live in your IDE/CLI's own config files on your machine and are **not** committed to git. So every teammate runs `devsmind mcp` and `devsmind rule` once on their own machine, even when the brain itself is already set up.
87
-
88
- ### πŸ†• A) Starting a new brain (first person on the project)
89
-
90
- ```bash
91
- # 1. Create the brain. Interactive: asks for project name, repos, tech stack,
92
- # which folders to index, etc. Creates the .devmind/ directory.
93
- devsmind init
94
-
95
- # 2. Connect your IDE / CLI to the DevsMind MCP server (guided, per-tool).
96
- # Asks what you're working in (Cursor, VS Code, Claude Code, Codex, …) and
97
- # then either PRINTS the exact snippet to paste, or WRITES/merges the correct
98
- # config file for you (with a preview + confirmation).
99
- devsmind mcp
100
-
101
- # 3. Place the AI workspace rule into your tool's native rules file (guided).
102
- # This is what actually teaches your agent to USE DevsMind (which tools to
103
- # call, when, and the DEVMIND_PATH for this project). Without it the server
104
- # is connected but your agent won't know to use it.
105
- devsmind rule
106
-
107
- # 4. Start the MCP server. Run from the folder containing .devmind (or pass
108
- # --path <devmind_path>). Skip this if you connected via stdio in step 2 β€”
109
- # then your IDE launches the server itself.
110
- devsmind start
111
-
112
- # 5. (Optional, recommended) Index your codebase so the graph actually has
113
- # content to look up. This is the one step unique to a NEW project. It's
114
- # skippable β€” you can instead let the graph "grow as you go" as your agent
115
- # records changes β€” but until the code is indexed (or enough organic usage
116
- # has accumulated) there's little for the agent to query yet.
117
- devsmind index --run --provider gemini --key YOUR_GEMINI_KEY
118
- # (see the `index` / `reindex` reference below for providers, flags, and the
119
- # zero-setup grow-as-you-go alternative)
120
-
121
- # 6. Commit .devmind/ so your team shares the same brain.
122
- git add .devmind && git commit -m "Add DevsMind brain"
123
- ```
124
-
125
- ### πŸ”„ B) Joining / resuming an existing brain (teammate already set it up)
126
-
127
- The `.devmind/` folder is already in the repo β€” **no fresh setup, no indexing.** The committed `config.json` + `graph/` + `history/` are shared, but the `.env` (your developer identity, and in standalone mode your machine's local repo paths) is gitignored, so you still run `devsmind init` once to set up your local side:
128
-
129
- ```bash
130
- # 1. Get the committed brain.
131
- git pull # or: git clone <repo>
132
-
133
- # 2. Set up your machine-local .env. `init` detects the existing brain and,
134
- # instead of creating a new one, just configures this machine: your
135
- # developer name/email, and (standalone mode) the local paths to each repo.
136
- # It does NOT re-create config or re-index the graph.
137
- devsmind init
138
-
139
- # 3. Connect your IDE / CLI (same guided command as above).
140
- devsmind mcp
141
-
142
- # 4. Place the workspace rule for your tool.
143
- devsmind rule
144
-
145
- # 5. Sync the committed graph/ + history/ JSONs into your local brain.db.
146
- # Especially important for stdio setups (VS Code and most CLI tools): the
147
- # editor spawns the server itself and only loads the graph once per process,
148
- # so after every `git pull` run this to pick up teammates' changes.
149
- devsmind sync
150
-
151
- # 6. Start the server (skip if you connected via stdio β€” the IDE runs it).
152
- devsmind start
153
- ```
154
-
155
- That's the whole loop. For what each step actually does under the hood β€” `init`'s full prompt flow, `mcp`/`rule`/`sync` in depth, every `index`/`reindex` flag, provider setup, and benchmarks β€” see the sections below.
156
-
157
- ---
158
-
159
- ## πŸ”Œ Adding DevsMind to your IDE / CLI: `devsmind mcp` & `devsmind rule`
160
-
161
- Both commands are **guided and per-tool**. They ask what you're working in (Cursor, VS Code, Windsurf, Kiro, Antigravity, Claude Code, Codex CLI, Qwen Code CLI, …), then either **print the exact snippet to copy-paste (manual)** or **create/merge the config file for you (automatic)** β€” with a preview and confirmation, never clobbering your existing servers.
162
-
163
- ```bash
164
- # Add the MCP server connection. Picks the right transport per tool
165
- # (stdio for CLI tools, stdio-or-HTTP for IDEs) and the right config file
166
- # + key (mcpServers / servers / [mcp_servers] / serverUrl / httpUrl / url).
167
- devsmind mcp
168
-
169
- # Place the workspace rule in the tool's native rules file
170
- # (.cursor/rules/*.mdc, CLAUDE.md, AGENTS.md, QWEN.md, .github/copilot-instructions.md, …).
171
- # In a pipe or with --print, it just prints the rule (back-compat: `devsmind rule --print > rule.md`).
172
- devsmind rule
173
- ```
174
-
175
- **`devsmind sync`** β€” force the committed `graph/` + `history/` JSONs into your local `brain.db`.
176
- Under `--stdio` (how VS Code and most CLI tools run the server), the editor spawns the process itself and the on-disk graph is only loaded once per process β€” so after a `git pull` your teammates' graph changes won't appear until you re-sync. Run this to apply them without restarting:
177
-
178
- ```bash
179
- devsmind sync
180
- ```
181
-
182
- ---
183
-
184
- ## πŸ“‡ Command Reference: `index` & `reindex`
185
-
186
- Both commands extract code entities ("nodes") via an LLM and resolve connections between them ("edges") via local AST analysis. **`index` is for the first full pass over a codebase; `reindex` is for keeping an already-indexed graph in sync afterward.** They share most flags.
187
-
188
- > You can also index via in-chat agent tools (`index_start`/`index_checkpoint`/`index_continue`/`index_complete`) instead of the CLI β€” but that burns your IDE chat's own token budget for every file, which gets expensive fast on anything beyond a small repo. The CLI (`--run`) does the same extraction in the background for free (aside from your own LLM API key usage) and is the recommended path for a full/initial index.
189
- >
190
- > Neither of these is *required* upfront β€” see [Growing the graph outside of `index`/`reindex`](#growing-the-graph-outside-of-indexreindex) below for the zero-setup "grow-as-you-go" mode. But until the graph actually covers your codebase (via one of these commands, or enough organic grow-as-you-go usage), it's mostly not useful to your AI agent yet β€” there's nothing to look up.
191
-
192
- ### `devsmind index --run`
193
-
194
- Full/initial indexing. Must be run with `--run`, otherwise it just prints instructions for in-chat indexing instead.
195
-
196
- ```bash
197
- devsmind index --run --provider gemini --model gemini-2.5-flash --key YOUR_API_KEY --chunk-size 1500
198
- ```
199
-
200
- | Flag | Description |
201
- |---|---|
202
- | `-p, --path <devmind_path>` | Path to `.devmind` (default: `.devmind` in cwd) |
203
- | `--run` | **Required** to actually start indexing |
204
- | `--provider <provider>` | `gemini` (default) \| `vertex` \| `ollama` |
205
- | `--model <name>` | Model id (default per provider β€” see [Providers & Performance](#providers--performance) below) |
206
- | `--key <api_key>` | API key or service account JSON path (overrides `GEMINI_API_KEY` / `GOOGLE_APPLICATION_CREDENTIALS`) |
207
- | `--url <url>` | Ollama server endpoint (default `http://localhost:11434`) |
208
- | `--chunk-size <lines>` | Max lines per chunk sent to the LLM (default: off β€” whole file in one call) |
209
- | `--chunk-overlap <lines>` | Overlap lines between chunks, only used with `--chunk-size` (default `50`) |
210
- | `--rpm <number>` | Max LLM requests per minute, paced proactively (default: **unthrottled** β€” fires back-to-back, relies on 429 retry/backoff) |
211
- | `--from-scratch` | Wipes ALL nodes, connections, history, and `graph/`/`history/` folders, then reindexes from zero. Prompts for confirmation unless `--yes` is passed |
212
- | `--nodes-only` | Only run Phase 1 (node extraction). No connections touched |
213
- | `--edges-only` | Only run Phase 2 (connection resolution). Wipes and rebuilds connections across all current nodes. Requires nodes to already exist |
214
- | `--repos <names>` | Comma-separated repo names to restrict the run to (standalone mode only) |
215
- | `--yes` | Skip the confirmation prompt for `--from-scratch` |
216
- | `--local-edges` | *Deprecated, no-op.* Connections are always resolved locally via AST now |
217
-
218
- **Valid / invalid combinations** (enforced in code, not just convention):
219
- * ❌ `--nodes-only` + `--edges-only` together β€” mutually exclusive, omit both for a full run.
220
- * ❌ `--from-scratch` + `--edges-only` together β€” nothing to build edges from after a full wipe. Use `--from-scratch --nodes-only`, then `--edges-only` as a separate follow-up run.
221
- * ❌ `--repos` + `--from-scratch` together β€” `--from-scratch` wipes the entire graph, so per-repo scoping doesn't apply.
222
- * βœ… `--repos` composes fine with `--nodes-only` or `--edges-only` (e.g. rebuild edges for just one repo).
223
-
224
- ```bash
225
- devsmind index --run --provider ollama --model qwen2.5-coder
226
- devsmind index --run --provider gemini --key YOUR_KEY --nodes-only
227
- devsmind index --run --edges-only --repos harrir-web,harrir-web-admin
228
- devsmind index --run --provider gemini --key YOUR_KEY --from-scratch --yes
229
- ```
230
-
231
- ### `devsmind reindex`
232
-
233
- Syncs the graph with code changes since the last run. No `--run` flag needed β€” it always executes.
234
-
235
- ```bash
236
- devsmind reindex --provider gemini --key YOUR_API_KEY
237
- ```
238
-
239
- | Flag | Description |
240
- |---|---|
241
- | `-p, --path <devmind_path>` | Path to `.devmind` (default: `.devmind` in cwd) |
242
- | `--provider <provider>` | `gemini` (default) \| `vertex` \| `ollama` |
243
- | `--model <name>` | Model id |
244
- | `--key <api_key>` | API key / service account path |
245
- | `--url <url>` | Ollama endpoint |
246
- | `--chunk-size <lines>` / `--chunk-overlap <lines>` | Same as `index` β€” bump `--chunk-size` (e.g. `3000`) if large files are timing out |
247
- | `--rpm <number>` | Same as `index` β€” unthrottled by default |
248
- | `--fill-gaps` | Gap-fill mode β€” see below |
249
- | `--local-edges` | *Deprecated, no-op* |
250
-
251
- There is no `--from-scratch` / `--nodes-only` / `--edges-only` / `--repos` on `reindex` β€” those are `index`-only.
252
-
253
- **Two selection modes:**
254
-
255
- * **Default (no flags beyond provider/key):** diffs file modification times against the graph's `last_reindex_at` cursor. Only files touched since the last successful reindex get reprocessed. Fast, but a file whose extraction fails partway through is *not* retried automatically on the next run once the cursor moves past it.
256
- * **`--fill-gaps`:** ignores mtimes entirely. Instead it finds every indexable file that currently has **zero nodes** in the graph (never indexed, or dropped by a prior crashed run) and backfills just those. Per-file failures are logged and skipped rather than aborting the whole run β€” safe to re-run repeatedly until the gap list is empty. After backfilling, it rebuilds connections across the *entire* active graph (not just the new nodes) via local AST resolution β€” no LLM cost β€” so edges pointing *into* the newly-added nodes from already-indexed files get picked up too. History and existing nodes are never touched by this rebuild.
257
-
258
- ```bash
259
- devsmind reindex --provider vertex --model gemini-2.5-flash --key sa.json --fill-gaps --rpm 60 --chunk-size 3000
260
- ```
261
-
262
- ### Providers & Performance
263
-
264
- Applies to both `index` and `reindex` β€” same `--provider`/`--model`/`--rpm`/`--chunk-size` flags, same Phase 1 (LLM) vs Phase 2 (local AST) split.
265
-
266
- **Supported providers (`--provider`):**
267
-
268
- | Provider | Auth | Notes |
269
- |---|---|---|
270
- | `gemini` (default) | `--key` or `GEMINI_API_KEY` env var | Default model: `gemini-2.0-flash` |
271
- | `vertex` | `--key` (service account JSON path or inline JSON, or a raw `ya29.` bearer token) or `GOOGLE_APPLICATION_CREDENTIALS` / `VERTEX_API_KEY` / `GEMINI_API_KEY`. Needs `GCP_PROJECT_ID` (or a project id embedded in the service account JSON) | Default model: `gemini-1.5-flash` |
272
- | `ollama` | None β€” local server | Default model: `qwen2.5-coder`. Default endpoint `http://localhost:11434`, override with `--url` |
273
-
274
- **Performance flags:**
275
- * `--local-edges` *(always on, flag is a no-op)*: connection resolution (Phase 2) runs entirely locally via the TypeScript/JavaScript AST parser (with a regex fallback for Python, Go, Java, etc.) β€” instant, offline, free, deterministic. Only Phase 1 (node extraction) calls the LLM.
276
- * `--chunk-size <lines>`: for large-context models, scale this up (e.g. `1500`–`3000`) to process big files in one or two chunks instead of timing out or getting truncated on a single whole-file call.
277
- * `--rpm <number>`: opt-in throttling. Leave unset unless you're hitting a known provider quota.
278
-
279
- **Benchmarks** *(approximate β€” from informal internal testing, not a rigorous accuracy-scoring methodology; your results will vary by repo, prompt, and quota)*:
280
-
281
- | Model | Repo size | Time | Approx. graph accuracy |
282
- |---|---|---|---|
283
- | `qwen2.5-coder:30b` (Ollama, local) | ~1,080 files | ~15 hours | ~50% |
284
- | `gemini-2.5-flash` (cloud) | same repo | ~5 hours | ~90% |
285
-
286
- Takeaway: local models avoid API cost and keep code on-machine, but for anything beyond small/medium repos a cloud flash-tier model is dramatically faster and more accurate for Phase 1 extraction. Phase 2 (edges) is local/free either way.
287
-
288
- ---
289
-
290
- ## πŸ†• `devsmind init` In Depth
291
-
292
- `devsmind init` behaves differently depending on whether a `.devmind/config.json` already exists in the target directory.
293
-
294
- ### First-time setup (no existing config)
295
-
296
- 1. **Project name + mode.** Prompts for a project name, then a choice between:
297
- * **Embedded** β€” the brain lives inside the project's own repo at `<repo>/.devmind`. Repo paths are stored as a relative path (`.`), so cloning the repo anywhere just works β€” no machine-specific config needed.
298
- * **Standalone** β€” the brain lives in its own separate folder (you're prompted for a folder name and parent directory), and can reference *multiple* independent Git repos. Each repo's absolute local path is stored per-developer in `.env` (since paths differ machine to machine).
299
- 2. **Repo configuration.** Embedded mode configures exclusions once for the single repo. Standalone mode loops, letting you add as many repos as you want, each with its own name, local path, and exclusions.
300
- 3. **Exclusions, per repo.** For each repo you get:
301
- * An offer to auto-import the repo's own `.gitignore` patterns.
302
- * An offer to add common non-code config files (lockfiles, `tsconfig.json`, eslint/prettier configs, etc.) if present.
303
- * An interactive file browser to manually toggle folders/files in or out of indexing scope.
304
- 4. **Developer info.** Name and email, pre-filled from `git config user.name` / `user.email` if available. Always written to `.env` (never committed).
305
- 5. **Tech stack auto-detection.** Scans each repo path for `tsconfig.json`, `go.mod`, `pom.xml`, `Cargo.toml`, `requirements.txt`/`pyproject.toml`, and `package.json` dependencies (detects nestjs, express, nextjs, react, vue, fastify, angular, svelte, hono, koa, prisma, typeorm, mongoose). You confirm or manually correct the result.
306
- 6. **Session timeout** (default 60 minutes) and optional **environment URLs** (dev/staging/prod) and **free-text notes** for the AI.
307
- 7. **Files written:**
308
- * `.devmind/config.json` β€” project name, mode, repos, ignored paths, tech stack, environments, notes. **Committed to Git.**
309
- * `.devmind/.env` β€” developer name/email + (standalone mode) each repo's local absolute path. **Gitignored.**
310
- * `.devmind/.gitignore` β€” auto-created to exclude `.env`, `brain.db`, `brain.db-wal`, `brain.db-shm`, `index_scratchpad.json`.
311
- * `.devmind/graph/` and `.devmind/history/` β€” created with `.gitkeep` so Git tracks the (initially empty) directories.
312
- * `.devmind/brain.db` β€” empty SQLite cache, initialized immediately.
313
-
314
- ### Re-running `init` (config already exists)
315
-
316
- This is the **joining-developer / repair flow** β€” it never overwrites the shared `config.json`:
317
-
318
- 1. Checks `.env` for developer name/email; prompts only if missing.
319
- 2. **Embedded mode:** verifies the repo's relative path still resolves and reports any that don't (rare β€” embedded paths are just `.`).
320
- 3. **Standalone mode:** checks every repo's `path_key` in `.env` against the filesystem. Any repo with a missing or now-invalid local path gets prompted for a corrected absolute path; everything else in `.env` (including unrelated keys) is preserved as-is.
321
- 4. Rewrites `.env`, ensures `.gitignore` exists, and re-initializes `brain.db` if needed.
322
-
323
- This is exactly what a new team member runs after `git clone`-ing a project that already has `.devmind/config.json` committed β€” see [Quick Start B) Joining / resuming an existing brain](#-quick-start) above.
324
-
325
- ---
326
-
327
- ## πŸ–₯️ Other CLI Commands
328
-
329
- * **`devsmind start [--stdio] [-p, --port <number>]`** β€” starts the MCP server. Default: HTTP on port `4513`, reachable at `http://localhost:4513/mcp`. Pass `--stdio` for IDEs that manage the server process directly instead of connecting over HTTP.
330
- * **`devsmind view [-p, --path <devmind_path>] [-P, --port <number>]`** β€” opens the interactive D3.js graph visualizer in your browser (see [below](#-interactive-graph-visualizer)).
331
- * **`devsmind prune [-p, --path <devmind_path>]`** β€” interactive terminal tool to review node stats, inspect current code, page through chronological change history, and permanently delete individual nodes or clear all nodes/history.
332
-
333
- ---
334
-
335
- ## πŸ—„οΈ Database Schema: `.devmind/brain.db`
336
-
337
- The local SQLite database (`brain.db`) acts as a metadata cache. The full database schema consists of three tables:
338
-
339
- ### 1. `nodes` (Code Entities)
340
- Contains structural identifiers.
341
- ```sql
342
- CREATE TABLE nodes (
343
- id TEXT PRIMARY KEY, -- e.g., "CartService.applyPromoCode"
344
- type TEXT NOT NULL, -- Taxonomy type (e.g., nest_controller, route_handler)
345
- name TEXT NOT NULL, -- Friendly display name
346
- file_path TEXT NOT NULL, -- Source file path
347
- signature TEXT, -- Param types & return value signature
348
- deprecated INTEGER DEFAULT 0, -- 1 if the node has been deprecated/removed
349
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
350
- );
351
- ```
352
-
353
- ### 2. `node_connections` (Architecture Relationships)
354
- Directional mapping (Many-to-Many). Represents **uses/calls** interactions.
355
- ```sql
356
- CREATE TABLE node_connections (
357
- source_node_id TEXT, -- The node doing the calling
358
- target_node_id TEXT, -- The node being called
359
- PRIMARY KEY (source_node_id, target_node_id),
360
- FOREIGN KEY (source_node_id) REFERENCES nodes (id) ON DELETE CASCADE,
361
- FOREIGN KEY (target_node_id) REFERENCES nodes (id) ON DELETE CASCADE
362
- );
363
- -- Direction: source_node USES target_node
364
- ```
365
-
366
- ### 3. `history` (AI Change Logs)
367
- Holds metadata references to version histories.
368
- ```sql
369
- CREATE TABLE history (
370
- id TEXT PRIMARY KEY, -- UUID of the history block
371
- node_id TEXT NOT NULL, -- Associated node
372
- session_id TEXT NOT NULL, -- Session key
373
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
374
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
375
- code_snapshot TEXT NOT NULL, -- Always empty string (stored in history/[id].json)
376
- reasoning TEXT NOT NULL, -- Always empty string (stored in history/[id].json)
377
- FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
378
- );
379
- ```
380
- > ⏱️ **Session Boundary Rule**: If the AI updates a function, it checks the last history log. If `updated_at` is less than **1 hour ago**, it updates the snapshot and reasoning in-place (same session). If older than 1 hour, it inserts a new history record (new session).
381
- >
382
- > πŸ’Ύ **JSON Storage Note**: In version 2.0.0, the actual code snapshots and AI change reasonings are stored in `.devmind/history/[id].json` to resolve Git merge conflicts, while the SQLite database holds empty strings for `code_snapshot` and `reasoning`.
383
-
384
- ### Growing the graph outside of `index`/`reindex`
385
-
386
- You don't have to run the CLI indexer at all β€” the graph also grows organically as your AI agent works, via the MCP write tools below:
387
- 1. When your AI touches a function, it checks whether a node already exists for it in `brain.db`.
388
- 2. If absent, it creates the node, connects its local import dependencies, and writes the first history snapshot.
389
- 3. The graph grows around whatever files you actively modify.
390
-
391
- This "grow-as-you-go" path needs zero upfront setup and is a reasonable default for small/medium codebases; `index`/`reindex` are for getting full upfront coverage on a whole workspace, including files your AI hasn't touched yet.
392
-
393
- > 🧹 **Pruning & Maintenance**: DevsMind dynamically handles deprecations and renames if function signatures match. For manual cleanup and auditing:
394
- > * `recheck_graph`: Scans code files, marks language primitives, built-ins, or nodes associated with deleted files as deprecated (removing their connections in the graph, but keeping their entries in the database).
395
- > * `get_orphaned_nodes`: Finds disconnected code nodes that have no incoming or outgoing connections to identify dead code or stale records.
396
- >
397
- > ⚠️ **Preservation Over Deletion**: The AI agent will never delete historical context by itself; it preserves all evolution records. The `delete_node` MCP tool is removed.
398
- > * Spurious or missing nodes are **deprecated** (keeping their code history and reasoning intact, but removing active connections in the graph).
399
- > * Use `devsmind prune` (see [Other CLI Commands](#-other-cli-commands)) for interactive manual review and permanent deletion.
400
-
401
- ---
402
-
403
- ## πŸ”Œ MCP Tool Reference
404
-
405
- DevsMind tools are designed with **layered granularity**. The AI only pulls the depth of data it needs, keeping token overhead minimal.
406
-
407
- DevsMind exposes **22 tools** to the AI agent, grouped below by what they're for.
408
-
409
- ### πŸ” Category 1: Discovery & Search
410
- * `get_node_summary`: Returns node type, location, connections count, history counts, and last update. (~50 tokens)
411
- * `list_nodes`: List all nodes matching optional type and file path filters. Useful to discover all entities in a component, package, or directory.
412
- * `search_nodes`: Search node names, identifiers, and reasoning logs matching a query β€” the first stop before any filesystem search.
413
- * `search_code`: Regex or string search over cached codebase code snapshots, returning matches grouped by node ID, file path, and matching lines. Preferred over a raw grep of the filesystem.
414
- * `get_node_graph`: Recursively retrieves connected nodes and relationships up to a specified depth (default: 6). With `direction:"out"` + `include_code:true`, pulls an entire call flow β€” the starting node plus everything it transitively calls, each with live source β€” in a single call. `direction:"in"` finds every caller (impact analysis before a change).
415
- * `get_orphaned_nodes`: Identifies disconnected code nodes in the graph that have no incoming or outgoing connections.
416
- * `get_visualizer_url`: Returns local browser URLs for opening the interactive 2D and 3D graph visualizers.
417
-
418
- ### πŸ“œ Category 2: Code & History
419
- * `get_node_code`: Returns a node's **current** source code, parsed live from its file on disk β€” token-efficient, since it returns only that function/class/route rather than the whole file. Flags drift explicitly: `snapshot_outdated: true` means the graph has fallen behind disk (re-stage it), and `source: "cached"` means the symbol couldn't be located in its file at all (renamed/moved/deleted) and a possibly-stale cached snapshot was returned instead.
420
- * `get_node_history`: Retrieves all history records, code snapshots, and change reasoning logs for a node.
421
- * `get_recent_changes`: Lists nodes modified across the project in the last N hours (default: 24h), with optional downstream impact analysis.
422
- * `get_developer_activity`: Pulls logs and changes authored by a specific team member.
423
- * `get_changes_by_requirement`: Finds all changes linked to a particular ticket or task ID (e.g. `JIRA-402`).
424
- * `search_decisions`: Performs a text search specifically across the architectural/implementation rationale logs.
425
-
426
- ### βš™οΈ Category 3: Code Indexing
427
- * `index_start`: Scans all configured repos, counts files, creates a scratchpad, and starts the codebase indexing session.
428
- * `index_checkpoint`: Saves current indexing progress to the scratchpad to survive context limits (called every ~10 files).
429
- * `index_continue`: Reads the scratchpad and returns exactly where indexing left off to resume after a context reset.
430
- * `index_complete`: Marks the codebase indexing session as fully completed.
431
-
432
- ### ✍️ Category 4: Writes & Mutations
433
- * `stage_change`: Buffers one touched entity (node id + code snapshot + reasoning) to disk **without** writing to the graph yet. Call once per file/entity you changed during a task β€” you do *not* reason about connections here.
434
- * `commit_changes`: Flushes the whole staged buffer in one pass β€” creates/updates every node, writes every history snapshot, then resolves all connections between them (and into the existing graph) via local AST, auto-creating any referenced-but-missing target nodes. Because all nodes exist before edges are resolved, calls between the changed files link correctly regardless of staging order. **Must be called exactly once** after staging, or nothing is written to the graph.
435
- * `rename_node`: Re-keys a node identifier and updates all associated records (connections and history) seamlessly.
436
- * `deprecate_node`: Marks a code node as deprecated, removing its connection mappings while retaining its coding snapshots and reasoning logs in the database.
437
-
438
- > The former `add_node` / `add_connection` tools are removed β€” nodes and edges are now created automatically by `stage_change` + `commit_changes`, so the AI never hand-manages edges. `update_history` (the old single-node write) still works if called directly for backward compatibility, but is no longer advertised to the AI β€” use `stage_change` + `commit_changes` instead.
439
-
440
- ### 🧹 Category 5: Optimization & Maintenance
441
- * `recheck_graph`: Scans the graph to verify file existence and deprecates language primitives, builtins, and nodes associated with missing/deleted files, retaining nodes with active histories.
442
-
443
- ---
444
-
445
- ## 🎨 Interactive Graph Visualizer
446
-
447
- Explore your code graph visually! Start the web app by running:
448
- ```bash
449
- devsmind view
450
- ```
451
- * **2D Visualizer**: D3.js force-directed canvas. Click nodes to see relationships, double-click to center, and inspect details.
452
- * **3D Visualizer**: ThreeJS/WebGL-powered cosmic node landscape. Fly through your architecture, rotating and zooming to trace complex microservice links.
453
-
454
- To query the visualizer URL programmatically from your agent, call `get_visualizer_url`.
455
-
456
- ---
457
-
458
- ## πŸ‘₯ Git Collaboration Workflow
459
-
460
- By placing `.devmind/config.json` and `.devmind/brain.db` in Git, you share the codebase's brain with the entire team.
461
-
462
- ```
463
- Developer A Developer B
464
- ─────────────────── ───────────────────
465
- Adds expired-coupon validation Pulls latest code
466
- AI updates applyPromoCode history AI inspects applyPromoCode
467
- `git commit -am "add validator"` Instantly sees validation logic,
468
- `git push` ───────► [Shared Remote Git] ────────► why it was added, and ticket ID!
469
- ```
470
-
471
- ---
472
-
473
- ## Changelog
474
-
475
- ### Version 2.2.0 (Current Release)
476
- * **`devsmind mcp` β€” Guided, Per-Tool MCP Setup**: Adding DevsMind to an IDE was previously undocumented and manual β€” every tool uses a different config file, location, key, and transport, and you were left to figure yours out. The new `devsmind mcp` command asks what you're working in (Cursor, VS Code/Copilot, Windsurf, Kiro, Google Antigravity, Claude Code, OpenAI Codex CLI, Qwen Code CLI, plus the Antigravity CLI) and then either **prints the exact snippet to paste** (manual mode) or **creates/merges the correct config file for you** (automatic mode) β€” with a preview and confirmation, and merging into any existing servers rather than overwriting them. It picks the best-fit transport per tool (stdio for CLI tools; stdio or HTTP for IDEs) and emits each tool's specific shape: the right top-level key (`mcpServers` vs VS Code's `servers` vs Codex's TOML `[mcp_servers.*]`) and the right remote-endpoint key (`url` vs Windsurf/Antigravity's `serverUrl` vs Qwen's `httpUrl`). Automatic mode includes a `cd`-style folder navigator so you can place project- or global-scoped configs anywhere on disk.
477
- * **`devsmind sync` β€” Force a Graph β†’ `brain.db` Load On Demand**: The disk-to-DB sync (`syncFromDisk()`, which loads the committed `graph/**` + `history/*.json` into the local SQLite cache) only runs once per process, in the DB constructor. Under `--stdio` β€” how VS Code and most CLI tools run the server β€” the editor spawns the process itself and never hits the HTTP routes that would otherwise trigger a fresh sync, so after a `git pull` your teammates' graph changes never reached your local brain without restarting the whole editor. `devsmind sync` applies them explicitly and reports what changed (node / connection / history counts with deltas). Run it after pulling.
478
- * **`devsmind rule` β€” Now Places the Rule For You, Per Tool**: Previously `rule` only dumped the workspace rule to stdout with a generic "paste this somewhere" tip. It now runs the same guided per-tool flow: pick your tool, then either see the exact native rules-file path (manual) or have the rule **written into that file for you** (automatic) β€” `.cursor/rules/devsmind.mdc` (with the required frontmatter), `CLAUDE.md`, `AGENTS.md`, `QWEN.md`, `.github/copilot-instructions.md`, and so on. Shared files get a delimited DevsMind block that updates in place on re-run instead of duplicating. Piped/redirected output and the new `--print` flag still emit the plain rule, so `devsmind rule --print > rule.md` and existing scripts keep working.
479
- * **Interactive Folder Navigator for Paths**: Everywhere the CLI asks for a directory β€” `devsmind init`'s brain location and repository paths, and the automatic-write location in `devsmind mcp` / `devsmind rule` β€” you now get a `cd`-style browser: step into subfolders, go up, or type/paste a path directly (handy for another drive or a far-away folder, with `~` expansion). No more hand-typing and re-typing absolute paths; only existing directories can be confirmed.
480
-
481
- ### Version 2.1.1
482
- * **`get_node_code` Now Reads Live Source From Disk**: Previously this tool served the last *cached* code snapshot from `.devmind/history/`, never touching the source file. If anyone edited code outside the agent's `stage_change` flow β€” a `git pull`, a manual edit, a teammate's commit β€” the agent was handed confidently-wrong code with no warning. It now parses the node's current source straight from its file via the local AST (deterministic, no LLM, no file read into context), and only falls back to the cached snapshot when the symbol genuinely can't be located on disk. Measured against a real 7,300-node production brain, **87% of sampled nodes were serving stale code** under the old behavior.
483
- * **Silent Staleness Is Now Reported**: Because the live source and the stored snapshot are both in hand, comparing them is free. `get_node_code` now returns `snapshot_outdated: true` when the graph has drifted from disk, and `source: "cached"` when a symbol could not be found in its file at all (renamed, moved, deleted, or a non-TS/JS file) β€” so the agent can re-record the node instead of silently trusting a stale answer. Historical snapshots from `get_node_history` are unchanged and still frozen, which is the point of them.
484
- * **Whole Call Flows in a Single Call (`get_node_graph` + `include_code`)**: Tracing a request through ~10 functions previously meant a `get_node_code` round trip per function β€” roughly 21 chat turns, each re-sending the conversation and generating fresh output tokens. `get_node_graph` now accepts `direction` (`"out"` = callees / a call flow, `"in"` = callers / impact analysis, `"both"` = the surrounding neighborhood, the unchanged default) and `include_code: true`, which attaches each node's live source. One call now returns the entry point plus everything it transitively calls, with code β€” collapsing that trace to ~2 turns.
485
- * **Bounded, Non-Silent Truncation**: `include_code` spends a character budget (`code_char_budget`, default 60,000) in breadth-first order, so the nodes nearest the starting point keep their code. Anything dropped still comes back with full metadata, and the response carries `code_chars`, `code_truncated`, and `nodes_without_code` β€” the agent is told exactly what it did *not* receive rather than being left to assume it saw everything.
486
- * **Fixed: `get_node_graph` Returned a Lone Root for Unqualified Node IDs**: The traversal seeded its queue with the raw `node_id` argument while `node_connections` is keyed by the fully-qualified ID. Passing a bare symbol name (e.g. `PaymentController`) resolved the root node but then matched zero edges, silently returning a single disconnected node. It now canonicalizes the root before traversing.
487
- * **Workspace Rule Updated (re-run `devsmind rule`)**: The generated agent rule still taught the old snapshot-first model and had no knowledge of `include_code`, which would have left the flow-tracing win unused. It now directs agents to read code through `get_node_code` instead of the filesystem, to trace flows with a single `direction:"out"` + `include_code:true` call rather than chaining per-function lookups, and to fix drift when `snapshot_outdated` is reported. **Existing users must re-run `devsmind rule` and re-paste it into their IDE to pick this up.**
488
-
489
- ### Version 2.1.0
490
- * **Staged Batch Writes (`stage_change` + `commit_changes`)**: Replaced the per-entity `add_node` / `add_connection` tools with a stage-then-commit flow. As an AI agent works a task across many files, it calls `stage_change` once per touched entity (passing only code + reasoning β€” no manual edge reasoning), buffered to disk so it survives a context reset. A single `commit_changes` then creates every node, writes every history snapshot, and resolves all connections at once via the local AST resolver. Because all nodes exist before any edge is resolved, calls between the changed files link correctly regardless of order β€” eliminating the forward-reference gap that previously required a separate Phase 2. Missing target nodes are auto-created from the AST. `update_history` remains as a single-node one-shot (it now also resolves that node's edges). `add_node` / `add_connection` are removed.
491
- * **Durable Deprecation & Deletion**: Deprecations, prunes, and hard-deletes now persist to the on-disk graph JSONs (and clean up caller files / history JSONs), so they survive a server restart and propagate to teammates via git instead of resurrecting from disk on the next `devsmind start`.
492
- * **Deterministic AST Edge Resolver & Missing-Node Auto-Fill**: Connection resolution now checks references in both directions per node β€” not just "who calls into this node" but also "what does this node itself call out to" β€” and when it finds a reference to something that was never extracted in Phase 1 (an import used but never turned into a node), it deterministically creates that node straight from the AST and immediately re-resolves connections for it and its callers. No LLM call needed, so it's free and runs on every edge-resolution pass automatically. Across ~15 rounds of iterative `--edges-only` testing against real repos, fixing what each round surfaced, this and related resolver fixes raised connection/edge accuracy from **~45% to ~90%** (per internal testing).
493
- * **Node Extraction Accuracy Fixes**: A series of fixes to extraction and taxonomy handling in the indexer raised node-extraction accuracy from **~58% to ~92%** across the same testing rounds (per internal testing).
494
- * **Opt-in Request Throttling (`--rpm`)**: Added `--rpm <number>` to both `index` and `reindex`. Previously, `gemini`/`vertex` runs silently applied a hardcoded default pace (60/30 requests-per-minute); now requests fire back-to-back by default (relying on 429 retry/backoff) and throttling is only applied if you explicitly ask for it β€” meant for known, verified provider quotas.
495
- * **Gap-Fill Reindexing (`--fill-gaps`)**: Added `--fill-gaps` to `reindex`. Instead of the normal mtime-based diff, it finds every indexable file with zero graph nodes (never indexed, or dropped by a prior crashed run) and backfills just those. Per-file extraction failures are logged and skipped instead of aborting the whole run, and connections are rebuilt across the entire graph afterward (local AST resolution, no LLM cost) so edges into the newly-added nodes are captured. Safe to run repeatedly β€” each run only touches what's still actually missing.
496
-
497
- ### Version 2.0.5
498
- * **Local Connection Resolution (`--local-edges`)**: Added local compiler AST connection resolution for TypeScript and JavaScript files, and regex identifier mapping for other languages (Python, Go, Java, etc.). This offloads Phase 2 connection resolution entirely from LLM APIs to the local machine, making edge connection generation instant, offline, and free of API costs.
499
- * **Configurable Indexer Chunk Size (`--chunk-size` and `--chunk-overlap`)**: Exposed chunk size and overlap controls as CLI flags. Users of large-context models (like Gemini 2.5 Flash) can scale chunk sizes to process files in a single pass, accelerating Phase 1 node extraction.
500
-
501
- ### Version 2.0.4
502
- * **Disk-Based History Adaptation & SQL Search Optimization**:
503
- * Restored SQL-based text filtering (e.g. `getDeveloperActivity`, `getChangesByRequirement`, `searchDecisions`, and `searchNodes`) by storing the small `reasoning` text directly in the SQLite `history` table while maintaining the large `code_snapshot` exclusively on disk.
504
- * Fixed `getRecentChanges` and `getAllHistory` to populate reasoning/code from disk-based history files.
505
- * Fixed the `get_node_code` MCP tool to return `null` if the snapshot is empty/whitespace, enabling proper caching behavior for agents.
506
-
507
- ### Version 2.0.2
508
- * **Fully Portable Node IDs & History Metadata**: Resolved the issue where Node IDs and history JSON metadata retained absolute path prefixes or relative dots (`../../`). All Node IDs and history file paths now utilize the environment-independent `{repo_name}/relativePath` format globally, ensuring seamless database synchronization and collaboration across different developers, OS drives, and machine paths.
509
-
510
- ### Version 2.0.1
511
- * **Automatic .gitignore Generation Fix**: Updated the `devsmind init` command to automatically create or update `.devmind/.gitignore` to ignore the local database cache (`brain.db`, `brain.db-wal`, `brain.db-shm`) and CLI index tracker (`index_scratchpad.json`) by default.
512
-
513
- ### Version 2.0.0 (Breaking Release)
514
- * **Git-Friendly Distributed JSON Storage**: Solved Git binary merge conflicts by moving all massive code snapshots and reasoning logs to `.devmind/history/[id].json` and graph structures to `.devmind/graph/[repo_name]/[path].json`. This replaces the monolithic `brain.db` database storage completely.
515
- * **Metadata-Only SQLite Cache**: Compacted the local SQLite database (`brain.db`) to store only structural metadata. Wiped all heavy text blobs, and added `brain.db` to `.gitignore`.
516
- * **Auto-Sync & Reconstruction**: Added startup auto-sync. The database constructor automatically reconstructs your entire local SQLite database from the disk JSONs in less than 2 seconds on startup.
517
- * **Env-Mapped Repo-Relative Paths**: Resolved cross-drive crashes and folder escape issues on Windows. Replaced relative dot paths in JSONs with clean repo placeholders (`{repo_name}/relativePath`) which are resolved dynamically using absolute paths configured in your local `.env` file.
518
- * **Safe Import Transaction Toggles**: Disables foreign key checks during bulk syncing (`syncFromDisk()`) and edge connections (`addConnection()`) to prevent race conditions during out-of-order indexing.
519
-
520
- ### Version 1.2.2
521
- * **Node.js v24 LTS & npm Dependency Conflict Resolution**: Fixed native compilation conflicts (like `better-sqlite3` and `node-gyp` errors) that crashed on Node v24, ensuring DevsMind builds and installs out-of-the-box on both Node v22 and Node v24 environments.
522
-
523
- ---
524
-
525
- ## πŸ“„ License
526
-
527
- DevsMind is released under the [MIT License](LICENSE).
1
+ # 🧠 DevsMind β€” Team AI Brain
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/devsmind-mcp?color=blue)](https://www.npmjs.com/package/devsmind-mcp)
4
+ [![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/Abialidr/devsmind/blob/main/LICENSE)
5
+
6
+ > **The evolutionary collective memory layer for your AI coding agents. Shared across your entire team.**
7
+
8
+ AI agents (like Cursor, Cline, Copilot, or Antigravity) lose all context between sessions. Teams repeat the same conversations, new developers ask questions answered months ago, and the same bug gets fixed twice because nobody remembered the first fix.
9
+
10
+ Git tells you **WHAT** changed. **DevsMind tells your AI agent WHY it changed, WHO decided it, WHAT requirement it served, and WHAT broke before.**
11
+
12
+ ```
13
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
14
+ β”‚ DevsMind MCP Server β”‚
15
+ β”‚ (installed once globally on machine) β”‚
16
+ β”‚ β”‚
17
+ β”‚ Stateless. Holds no data. β”‚
18
+ β”‚ Receives devmind_path on every call. β”‚
19
+ β”‚ Opens .devmind/brain.db at that path. β”‚
20
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
21
+ β”‚ devmind_path on every call
22
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
23
+ β–Ό β–Ό
24
+ c:\work\my-project\.devmind\ c:\work\other-project\.devmind\
25
+ brain.db brain.db
26
+ (Project A team brain) (Project B team brain)
27
+ ```
28
+
29
+ > πŸ“– Looking for the exhaustive version (every flag, every schema field)? See [detailExplanation.md](detailExplanation.md). This file is the fast path.
30
+
31
+ ---
32
+
33
+ ## How it works
34
+
35
+ Run `devsmind init` once per project β†’ creates `.devmind/`. Commit it. Every teammate's agent reads and writes the same graph.
36
+
37
+ ---
38
+
39
+ ## πŸ› οΈ Architecture: The `.devmind/` Directory
40
+
41
+ Running `devsmind init` creates a `.devmind/` directory in your workspace. This folder contains the configuration, distributed graph database, and local cache:
42
+
43
+ ```
44
+ .devmind/
45
+ β”œβ”€β”€ config.json ← Project metadata & repository mapping (Committed to Git)
46
+ β”œβ”€β”€ .env ← Local developer machine paths (Gitignored)
47
+ β”œβ”€β”€ brain.db ← Metadata-only SQLite cache database (Gitignored)
48
+ β”œβ”€β”€ history/ ← Distributed change logs & code snapshots as JSON (Committed to Git)
49
+ β”‚ └── [id].json
50
+ └── graph/ ← Distributed graph structure JSON files (Committed to Git)
51
+ └── [repo_name]/
52
+ └── [path].json
53
+ ```
54
+
55
+ ### Flexibility: Where should the brain live?
56
+
57
+ DevsMind supports two deployment topologies depending on your team's workflow:
58
+
59
+ * **Option A: Inside the workspace/project root directory (Shared with team)**
60
+ ```
61
+ c:\work\my-project\
62
+ β”œβ”€β”€ .devmind\ ← Config and distributed JSON database live here
63
+ β”œβ”€β”€ backend-service\
64
+ └── frontend-web\
65
+ ```
66
+ * **Option B: Standalone folder (Fully separated)**
67
+ ```
68
+ c:\Users\username\brains\my-project\
69
+ └── .devmind\ ← Brain is kept separate from code folders
70
+ ```
71
+
72
+ ---
73
+
74
+ ## πŸš€ Why teams use it
75
+
76
+ | Feature | What it means |
77
+ |---|---|
78
+ | **Function-level history** | Every function/class has a change log β€” not just diffs, but *why* |
79
+ | **Workflow context vault** | Persistent, git-shared timeline for multi-day features β€” solves "context death": an agent resuming days later picks up the full decision history instead of starting from zero |
80
+ | **AI-written context** | Your agent records why/goal/decision/ticket as it works |
81
+ | **Token-cheap lookups** | Agent reads one function via the graph instead of a whole file β€” up to ~70% fewer tokens |
82
+ | **One server, many projects** | Install once globally; each call passes its own project path |
83
+ | **Git-native sharing** | The graph is JSON + SQLite cache, committed like code |
84
+ | **Visual explorer** | `devsmind view` opens a 2D/3D graph of your architecture |
85
+
86
+ ---
87
+
88
+ ## ⚑ Quick Start
89
+
90
+ ```bash
91
+ npm install -g devsmind-mcp
92
+ ```
93
+
94
+ ### Starting a brand-new brain
95
+
96
+ ```bash
97
+ devsmind init # 1. Create .devmind/ β€” interactive: project name, repos, tech stack
98
+ devsmind mcp # 2. Connect your IDE/CLI to the MCP server
99
+ devsmind rule # 3. Paste the workspace rule β€” this is what teaches your agent to actually use it
100
+ devsmind start # 4. Start the server (skip if your IDE launches it via stdio)
101
+ devsmind index --run --provider gemini --key YOUR_KEY # 5. (optional) index the codebase now
102
+ git add .devmind && git commit -m "Add DevsMind brain" # 6. share it
103
+ ```
104
+
105
+ ### Joining a brain a teammate already created
106
+
107
+ ```bash
108
+ git pull # 1. .devmind/ is already in the repo
109
+ devsmind init # 2. sets up YOUR machine only (dev identity, local paths) β€” doesn't touch the shared graph
110
+ devsmind mcp # 3. connect your IDE/CLI
111
+ devsmind rule # 4. paste the workspace rule
112
+ devsmind sync # 5. load teammates' committed changes into your local cache
113
+ devsmind start # 6. start the server (skip if stdio)
114
+ ```
115
+
116
+ > **Already set up, just upgrading?**
117
+ > ```bash
118
+ > npm install -g devsmind-mcp@latest
119
+ > devsmind rule # re-paste β€” the generated rule content changes between releases
120
+ > ```
121
+ > Check the [Changelog](CHANGELOG.md) after upgrading β€” some releases need this re-run, some don't.
122
+
123
+ ---
124
+
125
+ ## πŸ”Œ The three setup commands, and why there are three
126
+
127
+ | Command | Answers | Skip it and… |
128
+ |---|---|---|
129
+ | `devsmind mcp` | Can your agent *reach* the tools at all? | DevsMind tools don't exist from the agent's point of view |
130
+ | `devsmind rule` | Does your agent *know* to use them? | Agent defaults back to grep/raw file reads out of habit |
131
+ | `devsmind memory` *(optional)* | Does that behavior *persist* without re-pasting? | Only matters for a handful of tools with their own agent-writable memory store |
132
+
133
+ `mcp` and `rule` are both guided: pick your tool (Cursor, VS Code, Claude Code, Codex, Windsurf, Kiro, Antigravity, Qwen Code, …), then either copy a printed snippet or let DevsMind write/merge the config file for you.
134
+
135
+ **`devsmind memory`** only writes where it's actually confirmed safe:
136
+
137
+ | Tool | Seeded automatically? |
138
+ |---|---|
139
+ | Claude Code (Auto Memory) | βœ… |
140
+ | Google Antigravity (Skills / `/learn`) | βœ… |
141
+ | Qwen Code CLI | Already covered by `devsmind rule` |
142
+ | Codex CLI, Cursor, Windsurf, Kiro, VS Code Copilot | ❌ β€” prints why + what to do instead |
143
+
144
+ > ⚠️ **`devsmind rule` / `devsmind memory` are not a guarantee, they're a nudge.** Pasting the rule doesn't make an agent use DevsMind every turn for the rest of time β€” on long sessions, agents drift back to their default habits (grep, raw file reads) and quietly stop calling `search_nodes`/`stage_change`/`commit_changes` as context fills up. When you notice that happening, just tell it directly: *"use the DevsMind graph, then stage and commit this."* It's a cheap thing to say and usually the highest-leverage sentence you can add β€” DevsMind's whole value is the code context + the *why* behind it, which plain grep never gives you.
145
+ >
146
+ > **And this part doesn't have a workaround:** if the agent never calls `commit_changes`, that history is gone for good. `devsmind reindex` / `devsmind analyze --fix` can repair the *code graph* (nodes, edges, stale entries) after the fact, but neither one can reconstruct the reasoning, decisions, or workflow steps that were only ever going to be written by the agent, in that turn. Skipped commits don't just leave a gap you can backfill later β€” they silently defeat the entire point of DevsMind.
147
+
148
+ ---
149
+
150
+ ## πŸ“‡ Indexing your codebase: `index` vs `reindex`
151
+
152
+ Both extract code entities via an LLM, then resolve connections locally (free, no LLM). You don't strictly need either β€” the graph also grows "as you go" from your agent's own edits β€” but until something has indexed the codebase, there's little for the agent to look up yet.
153
+
154
+ | | `index --run` | `reindex` |
155
+ |---|---|---|
156
+ | Use for | First full pass | Keeping an already-indexed graph in sync |
157
+ | Flag required | `--run` | none β€” always executes |
158
+ | Selection | Whole repo (or `--nodes-only` / `--edges-only` / `--repos`) | Diffs mtimes since last run, or `--fill-gaps` to backfill zero-node files |
159
+ | Destructive option | `--from-scratch` wipes everything first | β€” |
160
+
161
+ ```bash
162
+ devsmind index --run --provider gemini --key YOUR_KEY
163
+ devsmind reindex --provider gemini --key YOUR_KEY --fill-gaps
164
+ ```
165
+
166
+ **Common flags** (both commands): `--provider gemini|vertex|ollama` Β· `--model <name>` Β· `--key <api_key>` Β· `--chunk-size <lines>` Β· `--rpm <number>` (unthrottled by default).
167
+
168
+ **Providers:**
169
+
170
+ | Provider | Auth | Notes |
171
+ |---|---|---|
172
+ | `gemini` (default) | `--key` or `GEMINI_API_KEY` | fastest, most accurate in testing |
173
+ | `vertex` | service account JSON or bearer token | for teams already on GCP |
174
+ | `ollama` | none β€” local server | free, private, slower and less accurate |
175
+
176
+ Rough benchmark (~1,080-file repo, informal): local Ollama model took ~15h at ~50% accuracy; `gemini-2.5-flash` took ~5h at ~90%. Local avoids API cost; cloud is faster and more accurate for extraction. Edge resolution is local/free either way.
177
+
178
+ ---
179
+
180
+ ## πŸ–₯️ Other commands (cheat sheet)
181
+
182
+ | Command | What it does |
183
+ |---|---|
184
+ | `devsmind start [--stdio] [-p <port>]` | Run the MCP server |
185
+ | `devsmind sync [--analyze] [--fix]` | Pull committed graph changes into your local cache |
186
+ | `devsmind view` | Open the interactive 2D/3D graph visualizer |
187
+ | `devsmind analyze [--fix]` | Zero-AI local health check (god entities, cycles, orphans, dangling edges, dupes, stale attribution…) β€” `--fix` auto-applies only the safe/reversible fixes |
188
+ | `devsmind prune` | Interactive review + permanent delete of nodes/history |
189
+ | `devsmind workflow` | Interactive view of multi-day feature workflows |
190
+ | `devsmind workflow-import <path>` | Import existing flow docs as resumable workflows |
191
+
192
+ ---
193
+
194
+ ## πŸ”Œ MCP tools, grouped by purpose
195
+
196
+ DevsMind exposes ~31 tools to the agent. The ones you'll see referenced most:
197
+
198
+ | Group | Tools |
199
+ |---|---|
200
+ | **Search/discovery** | `search_nodes`, `list_nodes`, `get_node_graph`, `get_orphaned_nodes` |
201
+ | **Read code/history** | `get_node_code`, `get_node_history`, `get_recent_changes`, `search_decisions` |
202
+ | **Write (the important pair)** | `stage_change` (buffer one node), `commit_changes` (flush the buffer, resolve edges) |
203
+ | **Maintenance** | `recheck_graph`, `analyze_graph` |
204
+ | **Multi-day workflows** | `workflow_create`, `workflow_add_step`, `workflow_pause/resume`, `workflow_get_context`, `workflow_search` |
205
+
206
+ Full descriptions and token-cost notes: see [detailExplanation.md Β§ MCP Tool Reference](detailExplanation.md#-mcp-tool-reference).
207
+
208
+ ---
209
+
210
+ ## πŸ—„οΈ Storage model, briefly
211
+
212
+ ```
213
+ .devmind/
214
+ config.json ← project + repo config (committed)
215
+ .env ← your machine's local paths (gitignored)
216
+ brain.db ← SQLite metadata cache (gitignored, rebuilt from JSON on start)
217
+ history/ ← code snapshots + reasoning (committed, one JSON per entry)
218
+ graph/ ← node/connection structure (committed, one JSON per file)
219
+ workflows/ ← multi-day feature timelines (committed)
220
+ ```
221
+
222
+ The JSON files are the source of truth (git-mergeable); `brain.db` is a disposable local cache rebuilt from them on startup. Full 7-table schema: see [detailExplanation.md Β§ Database Schema](detailExplanation.md#-database-schema-devmindbraindb).
223
+
224
+ ---
225
+
226
+ ## Changelog
227
+
228
+ See [CHANGELOG.md](CHANGELOG.md) for what shipped in each release.
229
+
230
+ ---
231
+
232
+ ## πŸ“„ License
233
+
234
+ MIT β€” see [LICENSE](LICENSE).