devsmind-mcp 1.0.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.
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +105 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.js +626 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/prune.d.ts +3 -0
- package/dist/cli/prune.js +297 -0
- package/dist/cli/prune.js.map +1 -0
- package/dist/cli/rule.d.ts +3 -0
- package/dist/cli/rule.js +157 -0
- package/dist/cli/rule.js.map +1 -0
- package/dist/cli/view.d.ts +4 -0
- package/dist/cli/view.js +107 -0
- package/dist/cli/view.js.map +1 -0
- package/dist/db/database.d.ts +92 -0
- package/dist/db/database.js +479 -0
- package/dist/db/database.js.map +1 -0
- package/dist/db/indexer.d.ts +17 -0
- package/dist/db/indexer.js +103 -0
- package/dist/db/indexer.js.map +1 -0
- package/dist/db/schema.d.ts +23 -0
- package/dist/db/schema.js +38 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +1104 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/visualizer.d.ts +2 -0
- package/dist/mcp/visualizer.js +42 -0
- package/dist/mcp/visualizer.js.map +1 -0
- package/dist/mcp/visualizer_2d.html +635 -0
- package/dist/mcp/visualizer_3d.html +628 -0
- package/dist/utils/config.d.ts +43 -0
- package/dist/utils/config.js +91 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/scanner.d.ts +13 -0
- package/dist/utils/scanner.js +106 -0
- package/dist/utils/scanner.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abialidr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# π§ DevsMind β Team AI Brain
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/devsmind)
|
|
4
|
+
[](https://github.com/Abialidr/devsmind/blob/main/LICENSE)
|
|
5
|
+
[](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 entire brain:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
.devmind/
|
|
49
|
+
βββ config.json β Project metadata & repository mapping (Committed to Git)
|
|
50
|
+
βββ .env β Local developer machine paths (Gitignored)
|
|
51
|
+
βββ brain.db β SQLite database with the knowledge graph (Committed to Git)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Flexibility: Where should the brain live?
|
|
55
|
+
|
|
56
|
+
DevsMind supports two deployment topologies depending on your team's workflow:
|
|
57
|
+
|
|
58
|
+
* **Option A: Inside the workspace/project root directory (Committed to Git, shared with team)**
|
|
59
|
+
```
|
|
60
|
+
c:\work\my-project\
|
|
61
|
+
βββ .devmind\ β Brain lives inside the project root directory
|
|
62
|
+
βββ backend-service\
|
|
63
|
+
βββ frontend-web\
|
|
64
|
+
```
|
|
65
|
+
* **Option B: Standalone folder (Fully separated)**
|
|
66
|
+
```
|
|
67
|
+
c:\Users\username\brains\my-project\
|
|
68
|
+
βββ .devmind\ β Brain is kept separate from code folders
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## β‘ Quick Start
|
|
74
|
+
|
|
75
|
+
### 1. Install DevsMind
|
|
76
|
+
Install the CLI and MCP server globally via npm:
|
|
77
|
+
```bash
|
|
78
|
+
npm install -g devsmind-mcp
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Initialize the Brain & Local Env
|
|
82
|
+
Navigate to your project folder (or workspace root) and run:
|
|
83
|
+
```bash
|
|
84
|
+
devsmind init
|
|
85
|
+
```
|
|
86
|
+
This will guide you through interactive setup questions:
|
|
87
|
+
* **For new installations:** It prompts you for details (Project Name, Architecture, Frameworks, Naming Conventions, and Repo Paths) and automatically generates `.devmind/config.json` (committed), `.devmind/.env` (gitignored), and an empty `.devmind/brain.db`.
|
|
88
|
+
* **For resuming/joining developers:** If `.devmind/config.json` already exists (e.g., pulled from Git), running `devsmind init` will detect it. It will **not** overwrite the shared team configuration; instead, it will only prompt you for missing local details (your name/email and local machine paths for your repositories) and generate/update your local `.devmind/.env` automatically.
|
|
89
|
+
|
|
90
|
+
### 3. Get and Inject the AI Workspace Rule
|
|
91
|
+
Instead of writing a custom prompt from scratch, DevsMind generates a fully customized Workspace Rule containing your project's unique configuration details.
|
|
92
|
+
|
|
93
|
+
Run the following command in your terminal:
|
|
94
|
+
```bash
|
|
95
|
+
devsmind rule
|
|
96
|
+
```
|
|
97
|
+
Or specify an explicit path:
|
|
98
|
+
```bash
|
|
99
|
+
devsmind rule --path C:\work\my-project\.devmind
|
|
100
|
+
```
|
|
101
|
+
This prints a tailored system instruction prompt. Copy and append it to your IDE's workspace rules (e.g., `.cursorrules`, Claude Project instructions, or Antigravity system settings) so your AI agent knows how to read, check, and update the brain during sessions.
|
|
102
|
+
|
|
103
|
+
### 4. Start the Server
|
|
104
|
+
Start the MCP server on your machine:
|
|
105
|
+
```bash
|
|
106
|
+
devsmind start
|
|
107
|
+
```
|
|
108
|
+
By default, this launches an HTTP MCP server listening on port **`4513`**.
|
|
109
|
+
|
|
110
|
+
Configure your AI IDE to connect to:
|
|
111
|
+
`http://localhost:4513/mcp`
|
|
112
|
+
|
|
113
|
+
For IDEs requiring stdio execution, start the server in stdio mode:
|
|
114
|
+
```bash
|
|
115
|
+
devsmind start --stdio
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## πΊοΈ Indexing Modes: Setting Up the Brain
|
|
121
|
+
|
|
122
|
+
You have two options to index your codebase:
|
|
123
|
+
|
|
124
|
+
### Mode 1: Grow-As-You-Go (Zero Upfront Friction)
|
|
125
|
+
No upfront setup required. Just start writing code.
|
|
126
|
+
1. When your AI touches a function, it verifies if a node exists in `brain.db`.
|
|
127
|
+
2. If absent, it creates it, connects its local import dependencies, and writes the first history snapshot.
|
|
128
|
+
3. The graph grows organically around the files you actively modify.
|
|
129
|
+
* *Ideal for:* Small/medium codebases, solo developer hacks, or immediate experimentation.
|
|
130
|
+
|
|
131
|
+
### Mode 2: Upfront Full Index (High Reliability)
|
|
132
|
+
Index the entire workspace upfront so the AI knows every type, schema, and API contract from day one.
|
|
133
|
+
1. Run `/devsmind index` in your IDE chat or run `devsmind index` in the console.
|
|
134
|
+
2. The AI will receive the file list, read the contents recursively, and call `add_node` and `add_connection` for all entities.
|
|
135
|
+
3. It will save progress to a checkpoint scratchpad every 10 files, allowing safe resumption if the session resets.
|
|
136
|
+
|
|
137
|
+
> π‘ **Model-Dependent Indexing**: The speed and quality of indexing depend on the selected AI model. A smarter, more capable model (e.g., Gemini 1.5 Pro, Claude 3.5 Sonnet) will take slightly longer to parse complex syntax and relationships but yields a much more accurate and comprehensive code graph.
|
|
138
|
+
>
|
|
139
|
+
> π§Ή **Pruning & Maintenance**: During active development, DevsMind dynamically handles deprecations and renames if function signatures match. For manual cleanup and auditing, you have access to specialized tools:
|
|
140
|
+
> * `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).
|
|
141
|
+
> * `get_orphaned_nodes`: Finds disconnected code nodes that have no incoming or outgoing connections to identify dead code or stale records.
|
|
142
|
+
>
|
|
143
|
+
> β οΈ **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.
|
|
144
|
+
> * Spurious or missing nodes are **deprecated** (keeping their code history and reasoning intact, but removing active connections in the graph).
|
|
145
|
+
> * An interactive terminal tool is provided to let users review, inspect, and prune nodes:
|
|
146
|
+
> ```bash
|
|
147
|
+
> devsmind prune
|
|
148
|
+
> ```
|
|
149
|
+
> This utility allows you to view node stats, inspect current code, page through chronological change history, and permanently delete individual nodes or clear all nodes/history as desired.
|
|
150
|
+
|
|
151
|
+
* *Ideal for:* Production systems and team collaboration, preventing bugs where AI modifies variables used in undocumented parts of the system.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## ποΈ Database Schema: `.devmind/brain.db`
|
|
156
|
+
|
|
157
|
+
The brain is backed by a local SQLite database containing exactly three tables:
|
|
158
|
+
|
|
159
|
+
### 1. `nodes` (Code Entities)
|
|
160
|
+
Contains structural identifiers. **No code snapshots live here.**
|
|
161
|
+
```sql
|
|
162
|
+
CREATE TABLE nodes (
|
|
163
|
+
id TEXT PRIMARY KEY, -- e.g., "CartService.applyPromoCode"
|
|
164
|
+
type TEXT, -- Taxonomy type (e.g., nest_controller, route_handler)
|
|
165
|
+
name TEXT, -- Friendly display name
|
|
166
|
+
file_path TEXT, -- Source file path
|
|
167
|
+
signature TEXT, -- Param types & return value signature
|
|
168
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
169
|
+
);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 2. `node_connections` (Architecture Relationships)
|
|
173
|
+
Directional mapping (Many-to-Many). Represents **uses/calls** interactions.
|
|
174
|
+
```sql
|
|
175
|
+
CREATE TABLE node_connections (
|
|
176
|
+
source_node_id TEXT, -- The node doing the calling
|
|
177
|
+
target_node_id TEXT, -- The node being called
|
|
178
|
+
PRIMARY KEY (source_node_id, target_node_id),
|
|
179
|
+
FOREIGN KEY (source_node_id) REFERENCES nodes (id) ON DELETE CASCADE,
|
|
180
|
+
FOREIGN KEY (target_node_id) REFERENCES nodes (id) ON DELETE CASCADE
|
|
181
|
+
);
|
|
182
|
+
-- Direction: source_node USES target_node (or target_node IS USED BY source_node)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 3. `history` (AI Change Logs)
|
|
186
|
+
Holds snapshots and the evolutionary story.
|
|
187
|
+
```sql
|
|
188
|
+
CREATE TABLE history (
|
|
189
|
+
id TEXT PRIMARY KEY,
|
|
190
|
+
node_id TEXT, -- Associated node
|
|
191
|
+
session_id TEXT, -- Session key (optional)
|
|
192
|
+
created_at DATETIME, -- When version was opened
|
|
193
|
+
updated_at DATETIME, -- When version was last updated
|
|
194
|
+
code_snapshot TEXT, -- Source code of this entity at this point in time
|
|
195
|
+
reasoning TEXT, -- JSON string of AI-written history logs
|
|
196
|
+
FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
|
|
197
|
+
);
|
|
198
|
+
```
|
|
199
|
+
> β±οΈ **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).
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## π MCP Tool Reference
|
|
204
|
+
|
|
205
|
+
DevsMind tools are designed with **layered granularity**. The AI only pulls the depth of data it needs, keeping token overhead minimal.
|
|
206
|
+
|
|
207
|
+
### π Category 1: Discovery & Structure
|
|
208
|
+
* `get_node_summary`: Returns node type, location, connections count, history counts, and last update. (~50 tokens)
|
|
209
|
+
* `list_nodes`: List all nodes matching optional type and file path filters. Useful to discover all entities in a component, package, or directory.
|
|
210
|
+
* `get_node_graph`: Recursively retrieves connected nodes and relationships up to a specified depth (default: 6).
|
|
211
|
+
* `get_orphaned_nodes`: Identifies disconnected code nodes in the graph that have no incoming or outgoing connections.
|
|
212
|
+
* `get_visualizer_url`: Returns local browser URLs for opening the interactive 2D and 3D graph visualizers.
|
|
213
|
+
|
|
214
|
+
### π Category 2: Code & History
|
|
215
|
+
* `get_node_history`: Retrieves all history records, code snapshots, and change reasoning logs for a node.
|
|
216
|
+
* `get_recent_changes`: Lists nodes modified across the project in the last N hours (Default: 24h).
|
|
217
|
+
* `get_developer_activity`: Pulls logs and changes authored by a specific team member.
|
|
218
|
+
* `get_changes_by_requirement`: Finds all changes linked to a particular ticket or task ID (e.g. `JIRA-402`).
|
|
219
|
+
* `search_decisions`: Performs a text search specifically across the architectural/implementation rationale logs.
|
|
220
|
+
|
|
221
|
+
### βοΈ Category 3: Code Indexing
|
|
222
|
+
* `index_start`: Scans all configured repos, counts files, creates a scratchpad, and starts the codebase indexing session.
|
|
223
|
+
* `index_checkpoint`: Saves current indexing progress to the scratchpad to survive context limits (called every ~10 files).
|
|
224
|
+
* `index_continue`: Reads the scratchpad and returns exactly where indexing left off to resume after a context reset.
|
|
225
|
+
* `index_complete`: Marks the codebase indexing session as fully completed.
|
|
226
|
+
|
|
227
|
+
### βοΈ Category 4: Writes & Mutations
|
|
228
|
+
* `add_node`: Registers a new structure (function, class, endpoint, schema, variable, etc.) in the graph.
|
|
229
|
+
* `add_connection`: Links two structures together as a dependency relationship (`source` uses/calls `target`).
|
|
230
|
+
* `update_history`: Registers a code snapshot and writes history logs (respects the 1h session boundary rule).
|
|
231
|
+
* `rename_node`: Re-keys a node identifier and updates all associated records (connections and history) seamlessly.
|
|
232
|
+
* `deprecate_node`: Marks a code node as deprecated, removing its connection mappings while retaining its coding snapshots and reasoning logs in the database.
|
|
233
|
+
|
|
234
|
+
### π§Ή Category 5: Optimization & Maintenance
|
|
235
|
+
* `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.
|
|
236
|
+
* `search_nodes`: Full-text search (FTS5) index for node names, identifiers, and reasoning logs.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## π¨ Interactive Graph Visualizer
|
|
241
|
+
|
|
242
|
+
Explore your code graph visually! Start the web app by running:
|
|
243
|
+
```bash
|
|
244
|
+
devsmind view
|
|
245
|
+
```
|
|
246
|
+
* **2D Visualizer**: D3.js force-directed canvas. Click nodes to see relationships, double-click to center, and inspect details.
|
|
247
|
+
* **3D Visualizer**: ThreeJS/WebGL-powered cosmic node landscape. Fly through your architecture, rotating and zooming to trace complex microservice links.
|
|
248
|
+
|
|
249
|
+
To query the visualizer URL programmatically from your agent, call `get_visualizer_url`.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## π₯ Git Collaboration Workflow
|
|
254
|
+
|
|
255
|
+
By placing `.devmind/config.json` and `.devmind/brain.db` in Git, you share the codebase's brain with the entire team.
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
Developer A Developer B
|
|
259
|
+
βββββββββββββββββββ βββββββββββββββββββ
|
|
260
|
+
Adds expired-coupon validation Pulls latest code
|
|
261
|
+
AI updates applyPromoCode history AI inspects applyPromoCode
|
|
262
|
+
`git commit -am "add validator"` Instantly sees validation logic,
|
|
263
|
+
`git push` ββββββββΊ [Shared Remote Git] βββββββββΊ why it was added, and ticket ID!
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Joining a Project
|
|
267
|
+
When a new developer joins your team, they onboard instantly:
|
|
268
|
+
1. Clone the project repository (which contains the `.devmind/` folder and `brain.db`).
|
|
269
|
+
2. Install the package globally: `npm install -g devsmind-mcp`
|
|
270
|
+
3. Create their local `.devmind/.env` from `.devmind/.env.example` and update their machine paths.
|
|
271
|
+
4. Add the Workspace Rule to their IDE configuration.
|
|
272
|
+
5. Launch: `devsmind start`
|
|
273
|
+
|
|
274
|
+
The new developer's AI agent now possesses the full architectural context and decision history of your senior team.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## π License
|
|
279
|
+
|
|
280
|
+
DevsMind is released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const init_1 = require("./init");
|
|
6
|
+
const rule_1 = require("./rule");
|
|
7
|
+
const view_1 = require("./view");
|
|
8
|
+
const prune_1 = require("./prune");
|
|
9
|
+
const server_1 = require("../mcp/server");
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name('devsmind')
|
|
13
|
+
.description('DevsMind β Team AI Brain CLI')
|
|
14
|
+
.version('1.0.0', '-v, --version');
|
|
15
|
+
program
|
|
16
|
+
.command('init')
|
|
17
|
+
.description('Initialize a new DevsMind brain or update repository paths')
|
|
18
|
+
.action(async () => {
|
|
19
|
+
try {
|
|
20
|
+
await (0, init_1.handleInit)();
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
console.error(`β Initialization failed: ${err.message}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
program
|
|
28
|
+
.command('start')
|
|
29
|
+
.description(`Start the DevsMind MCP server\n` +
|
|
30
|
+
` Default: HTTP on port ${server_1.DEVSMIND_PORT} (devsβ45, mindβM=13 β 4513)\n` +
|
|
31
|
+
` IDEs connect via: http://localhost:${server_1.DEVSMIND_PORT}/mcp`)
|
|
32
|
+
.option('--stdio', 'Use stdio transport instead of HTTP (for direct IDE process injection)')
|
|
33
|
+
.option('-p, --port <number>', `HTTP port to listen on (default: ${server_1.DEVSMIND_PORT})`, String(server_1.DEVSMIND_PORT))
|
|
34
|
+
.action(async (opts) => {
|
|
35
|
+
if (opts.stdio) {
|
|
36
|
+
// Stdio mode: IDE manages the process directly
|
|
37
|
+
(0, server_1.runStdioMcpServer)();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// HTTP mode: IDE connects over the network
|
|
41
|
+
const port = parseInt(opts.port, 10);
|
|
42
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
43
|
+
console.error(`β Invalid port: ${opts.port}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
await (0, server_1.runHttpMcpServer)(port);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
const msg = err.message;
|
|
51
|
+
if (err.code === 'EADDRINUSE') {
|
|
52
|
+
console.error(`β Port ${port} is already in use. Try: devsmind start --port <other>`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.error(`β MCP Server failed to start: ${msg}`);
|
|
56
|
+
}
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
program
|
|
62
|
+
.command('rule')
|
|
63
|
+
.description('Print the ready-to-paste AI workspace rule for this brain')
|
|
64
|
+
.option('-p, --path <devmind_path>', 'Explicit path to the .devmind directory (auto-detected from cwd by default)')
|
|
65
|
+
.action((opts) => {
|
|
66
|
+
(0, rule_1.handleRule)(opts);
|
|
67
|
+
});
|
|
68
|
+
program
|
|
69
|
+
.command('view')
|
|
70
|
+
.description('Open the interactive D3.js code graph visualizer in your browser')
|
|
71
|
+
.option('-p, --path <devmind_path>', 'Path to the .devmind directory (auto-detected from cwd by default)')
|
|
72
|
+
.option('-P, --port <number>', `HTTP port to listen on (default: ${server_1.DEVSMIND_PORT})`, String(server_1.DEVSMIND_PORT))
|
|
73
|
+
.action(async (opts) => {
|
|
74
|
+
await (0, view_1.handleView)(opts);
|
|
75
|
+
});
|
|
76
|
+
program
|
|
77
|
+
.command('index')
|
|
78
|
+
.description('Kick off the first-time graph indexing of all configured repos')
|
|
79
|
+
.option('-p, --path <devmind_path>', 'Path to the .devmind directory (default: .devmind in cwd)')
|
|
80
|
+
.action((opts) => {
|
|
81
|
+
const devmindPath = opts.path ?? '.devmind';
|
|
82
|
+
const resolved = require('path').resolve(devmindPath);
|
|
83
|
+
console.log(`\nπ§ DevsMind β Graph Indexing`);
|
|
84
|
+
console.log(` Brain : ${resolved}`);
|
|
85
|
+
console.log(`\nπ To index your codebase, tell your AI assistant:\n`);
|
|
86
|
+
console.log(` "Call devsmind.index_start with devmind_path = ${resolved}"`);
|
|
87
|
+
console.log(` "Then read every file it returns and call add_node + add_connection for each entity."`);
|
|
88
|
+
console.log(` "Checkpoint every 10 files. Call index_complete when done."\n`);
|
|
89
|
+
console.log(` Or simply type: /devsmind index in your IDE chat.\n`);
|
|
90
|
+
});
|
|
91
|
+
program
|
|
92
|
+
.command('prune')
|
|
93
|
+
.description('Interactively review, inspect, and permanently prune nodes and history')
|
|
94
|
+
.option('-p, --path <devmind_path>', 'Path to the .devmind directory (auto-detected from cwd by default)')
|
|
95
|
+
.action(async (opts) => {
|
|
96
|
+
try {
|
|
97
|
+
await (0, prune_1.handlePrune)(opts);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
console.error(`β Pruning failed: ${err.message}`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
program.parse(process.argv);
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,iCAAoC;AACpC,iCAAoC;AACpC,iCAAoC;AACpC,mCAAsC;AACtC,0CAAmF;AAEnF,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,8BAA8B,CAAC;KAC3C,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4DAA4D,CAAC;KACzE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,IAAA,iBAAU,GAAE,CAAC;IACrB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,4BAA6B,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CACV,iCAAiC;IACjC,2BAA2B,sBAAa,iCAAiC;IACzE,wCAAwC,sBAAa,MAAM,CAC5D;KACA,MAAM,CAAC,SAAS,EAAE,wEAAwE,CAAC;KAC3F,MAAM,CAAC,qBAAqB,EAAE,oCAAoC,sBAAa,GAAG,EAAE,MAAM,CAAC,sBAAa,CAAC,CAAC;KAC1G,MAAM,CAAC,KAAK,EAAE,IAAuC,EAAE,EAAE;IACxD,IAAI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