project-graph-mcp 1.3.0 → 2.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/README.md +223 -17
- package/{AGENT_ROLE.md → docs/examples/AGENT_ROLE.md} +87 -30
- package/{AGENT_ROLE_MINIMAL.md → docs/examples/AGENT_ROLE_MINIMAL.md} +23 -8
- package/package.json +12 -8
- package/src/.project-graph-cache.json +1 -0
- package/src/analysis/analysis-cache.js +7 -0
- package/src/analysis/complexity.js +14 -0
- package/src/analysis/custom-rules.js +36 -0
- package/src/analysis/db-analysis.js +9 -0
- package/src/analysis/dead-code.js +19 -0
- package/src/analysis/full-analysis.js +18 -0
- package/src/analysis/jsdoc-checker.js +24 -0
- package/src/analysis/jsdoc-generator.js +10 -0
- package/src/analysis/large-files.js +11 -0
- package/src/analysis/outdated-patterns.js +12 -0
- package/src/analysis/similar-functions.js +16 -0
- package/src/analysis/test-annotations.js +21 -0
- package/src/analysis/type-checker.js +8 -0
- package/src/analysis/undocumented.js +14 -0
- package/src/cli/cli-handlers.js +4 -0
- package/src/cli/cli.js +5 -0
- package/src/compact/ai-context.js +7 -0
- package/src/compact/compact.js +18 -0
- package/src/compact/compress.js +13 -0
- package/src/compact/ctx-to-jsdoc.js +29 -0
- package/src/compact/doc-dialect.js +30 -0
- package/src/compact/expand.js +37 -0
- package/src/compact/framework-references.js +5 -0
- package/src/compact/instructions.js +3 -0
- package/src/compact/mode-config.js +8 -0
- package/src/compact/validate-pipeline.js +9 -0
- package/src/core/event-bus.js +9 -0
- package/src/core/filters.js +14 -0
- package/src/core/graph-builder.js +12 -0
- package/src/core/parser.js +31 -0
- package/src/core/workspace.js +8 -0
- package/src/lang/lang-go.js +17 -0
- package/src/lang/lang-python.js +12 -0
- package/src/lang/lang-sql.js +23 -0
- package/src/lang/lang-typescript.js +9 -0
- package/src/lang/lang-utils.js +4 -0
- package/src/mcp/mcp-server.js +17 -0
- package/src/mcp/tool-defs.js +3 -0
- package/src/mcp/tools.js +25 -0
- package/src/network/backend-lifecycle.js +19 -0
- package/src/network/backend.js +5 -0
- package/src/network/local-gateway.js +23 -0
- package/src/network/mdns.js +13 -0
- package/src/network/server.js +10 -0
- package/src/network/web-server.js +34 -0
- package/vendor/terser.mjs +49 -0
- package/web/.project-graph-cache.json +1 -0
- package/web/app.js +16 -0
- package/web/components/code-block.js +3 -0
- package/web/components/quick-open.js +5 -0
- package/web/dashboard-state.js +3 -0
- package/web/dashboard.html +27 -0
- package/web/dashboard.js +8 -0
- package/web/highlight.js +13 -0
- package/web/index.html +35 -0
- package/web/panels/ActionBoard/ActionBoard.css.js +1 -0
- package/web/panels/ActionBoard/ActionBoard.js +4 -0
- package/web/panels/ActionBoard/ActionBoard.tpl.js +1 -0
- package/web/panels/EventItem/EventItem.css.js +1 -0
- package/web/panels/EventItem/EventItem.js +4 -0
- package/web/panels/EventItem/EventItem.tpl.js +1 -0
- package/web/panels/ProjectItem/ProjectItem.css.js +1 -0
- package/web/panels/ProjectItem/ProjectItem.js +5 -0
- package/web/panels/ProjectItem/ProjectItem.tpl.js +1 -0
- package/web/panels/ProjectList/ProjectList.css.js +1 -0
- package/web/panels/ProjectList/ProjectList.js +4 -0
- package/web/panels/ProjectList/ProjectList.tpl.js +1 -0
- package/web/panels/SettingsPanel/.project-graph-cache.json +1 -0
- package/web/panels/SettingsPanel/SettingsPanel.css.js +1 -0
- package/web/panels/SettingsPanel/SettingsPanel.js +7 -0
- package/web/panels/SettingsPanel/SettingsPanel.tpl.js +1 -0
- package/web/panels/code-viewer.js +5 -0
- package/web/panels/ctx-panel.js +4 -0
- package/web/panels/dep-graph.js +6 -0
- package/web/panels/file-tree.js +188 -0
- package/web/panels/health-panel.js +3 -0
- package/web/panels/live-monitor.js +3 -0
- package/web/state.js +17 -0
- package/web/style.css +157 -0
- package/references/symbiote-3x.md +0 -834
- package/src/cli-handlers.js +0 -140
- package/src/cli.js +0 -83
- package/src/complexity.js +0 -223
- package/src/custom-rules.js +0 -583
- package/src/db-analysis.js +0 -194
- package/src/dead-code.js +0 -468
- package/src/filters.js +0 -227
- package/src/framework-references.js +0 -177
- package/src/full-analysis.js +0 -174
- package/src/graph-builder.js +0 -299
- package/src/instructions.js +0 -175
- package/src/jsdoc-generator.js +0 -214
- package/src/lang-go.js +0 -285
- package/src/lang-python.js +0 -197
- package/src/lang-sql.js +0 -309
- package/src/lang-typescript.js +0 -190
- package/src/lang-utils.js +0 -124
- package/src/large-files.js +0 -162
- package/src/mcp-server.js +0 -468
- package/src/outdated-patterns.js +0 -295
- package/src/parser.js +0 -452
- package/src/server.js +0 -28
- package/src/similar-functions.js +0 -278
- package/src/test-annotations.js +0 -301
- package/src/tool-defs.js +0 -525
- package/src/tools.js +0 -470
- package/src/undocumented.js +0 -260
- package/src/workspace.js +0 -70
package/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/project-graph-mcp)
|
|
2
2
|
[](https://opensource.org/licenses/MIT)
|
|
3
3
|
[](https://nodejs.org)
|
|
4
|
-
[](https://www.npmjs.com/package/project-graph-mcp)
|
|
5
4
|
|
|
6
5
|
# project-graph-mcp
|
|
7
6
|
|
|
8
|
-
An MCP server that parses your source code into a **10-50x compressed skeleton** — classes, functions, imports, and dependencies in a minified JSON. Agents navigate the graph using `expand`, `deps`, and `usages` without reading irrelevant files.
|
|
7
|
+
An MCP server that parses your source code into a **10-50x compressed skeleton** — classes, functions, imports, and dependencies in a minified JSON. Agents navigate the graph using `expand`, `deps`, and `usages` without reading irrelevant files. The **AI Context Layer** compresses an entire codebase into ~1700 tokens (97% savings) with a single `get_ai_context` call. Supports **monorepo scanning** and **streaming analysis** for large codebases.
|
|
9
8
|
|
|
10
9
|
> [!TIP]
|
|
11
|
-
> **
|
|
10
|
+
> **18 MCP tools.** Add one line to your MCP config and the server downloads itself on the next IDE restart.
|
|
12
11
|
|
|
13
12
|
### Project Skeleton (10-50x compression)
|
|
14
13
|
|
|
@@ -44,27 +43,213 @@ stripStringsAndComments(code, { backtick: true, templateInterpolation: false })
|
|
|
44
43
|
- **Duplicate detection** — finds functionally similar functions by signature + structure similarity
|
|
45
44
|
- **Large file analysis** — candidates for splitting by lines, functions, and exports count
|
|
46
45
|
- **Legacy pattern finder** — outdated code patterns and redundant npm deps (built into Node.js 18+)
|
|
47
|
-
- **
|
|
46
|
+
- **JSDoc consistency** — validates `@param` count/names and `@returns` against AST signatures
|
|
47
|
+
- **Type checking** — optional `tsc --checkJs` wrapper with graceful fallback
|
|
48
|
+
- **Health Score (0-100)** — aggregated result from all checks in one call (`get_full_analysis` or quick `get_analysis_summary`)
|
|
49
|
+
- **Incremental cache** — per-file analysis results cached in `.context/.cache/` with content hashing
|
|
50
|
+
|
|
51
|
+
### AI Context Layer
|
|
52
|
+
|
|
53
|
+
One call loads everything an agent needs to understand a project:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
get_ai_context({ path: "src/" })
|
|
57
|
+
// → { skeleton, docs, totalTokens: 1742, savings: "97%" }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **Code compression** — Terser-minified source with export legend headers (20-55% per file)
|
|
61
|
+
- **Compact Code Mode** — project-wide `compact`/`beautify` (preserves all names, strips comments/whitespace)
|
|
62
|
+
- **Doc Dialect** — compact `.context/` documentation format, auto-generated from AST with `{DESCRIBE}` markers. Descriptions use a **simplified English dialect** — max 80 characters, pipe-separated, with standard abbreviations (`fn/ret/cfg/init/auth/db/msg`):
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
generateJSDoc(t)→e.push,e.join|build /** */ JSDoc block from .ctx signature
|
|
66
|
+
export expandFile(e,n)→beautify,inject|beautify compact JS + inject JSDoc from .ctx
|
|
67
|
+
PATTERNS: Terser beautify|AST walk for injection points|reverse-order insertion
|
|
68
|
+
```
|
|
69
|
+
- **Two-tier `.ctx`** — `.ctx` (machine-generated, AST signatures) + `.ctx.md` (agent notes, TODO, decisions)
|
|
70
|
+
- **Self-enriching** — `@enrich` instructions embedded in `.ctx` files guide any AI agent to fill descriptions
|
|
71
|
+
- **Staleness detection** — `@sig` hashes track structural changes; `check_stale_docs` identifies outdated docs
|
|
72
|
+
- **Merge strategy** — regenerating `.ctx` files preserves existing descriptions
|
|
73
|
+
- **Boot aggregator** — `get_ai_context` combines skeleton + docs + compressed files in one response
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Generate .context/ documentation templates
|
|
77
|
+
npx project-graph-mcp generate-ctx src/
|
|
78
|
+
|
|
79
|
+
# View project docs in compact format
|
|
80
|
+
npx project-graph-mcp docs src/
|
|
81
|
+
|
|
82
|
+
# Compress a single file for AI
|
|
83
|
+
npx project-graph-mcp compress src/core/parser.js
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Two-Tier Context: Overview → Focus
|
|
87
|
+
|
|
88
|
+
Agents don't need full context for every file. The server provides a **progressive loading model**:
|
|
89
|
+
|
|
90
|
+
| Mode | What agent reads | Token cost | Use case |
|
|
91
|
+
|------|-----------------|------------|----------|
|
|
92
|
+
| **Overview** | `get_skeleton()` + compact code | codeTok only | Understand project structure |
|
|
93
|
+
| **Focus** | compact code + `.ctx` for specific files | codeTok + ctxTok (per file) | Deep work on area of interest |
|
|
94
|
+
| **Traditional** | All raw source files | expanded | Reading source directly |
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// 1. Overview: read entire project structure (cheap, no .ctx)
|
|
98
|
+
get_skeleton({ path: "src/" })
|
|
99
|
+
// → Legend, stats, all classes/functions/exports — ~2-5K tokens
|
|
100
|
+
|
|
101
|
+
// 2. Focus: get enriched context ONLY for area of interest
|
|
102
|
+
get_focus_zone({ recentFiles: ["src/core/parser.js", "src/mcp/tools.js"] })
|
|
103
|
+
// → Compact code + .ctx documentation for just those 2 files
|
|
104
|
+
|
|
105
|
+
// 3. Or auto-detect from git diff
|
|
106
|
+
get_focus_zone({ path: ".", useGitDiff: true })
|
|
107
|
+
// → Context for recently changed files only
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Real-world token budget** (45-file project):
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Traditional (raw sources): 64K tok — read everything expanded
|
|
114
|
+
Overview (compact, no .ctx): 47K tok — 27% savings, full project
|
|
115
|
+
Focus (compact + 3 files ctx): 47.6K tok — same savings + semantic descriptions
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Compact code saves **27% on average** (34-38% for typical files) by stripping whitespace and comments while preserving all names. The `.ctx` cost is **per-file** (~200 tok each) and only loaded for the focus area — the agent gets typed signatures and descriptions that the raw source never had.
|
|
119
|
+
|
|
120
|
+
**Per-file metrics breakdown:**
|
|
121
|
+
|
|
122
|
+
| Layer | What | Tokens |
|
|
123
|
+
|-------|------|--------|
|
|
124
|
+
| Code (compact .js) | Minified source, all names preserved | codeTok |
|
|
125
|
+
| Context (.ctx) | AST signatures, types, descriptions | ctxTok |
|
|
126
|
+
| Total (focus mode) | What agent reads when focusing | codeTok + ctxTok |
|
|
127
|
+
| Expanded (beautified) | What a human would read (raw source) | expanded |
|
|
128
|
+
|
|
129
|
+
### Compact Code Architecture
|
|
130
|
+
|
|
131
|
+
Three modes for AI-native codebase editing — configure per project via `.context/config.json`:
|
|
132
|
+
|
|
133
|
+
| Mode | Storage | Agent reads | Agent edits |
|
|
134
|
+
|------|---------|-------------|-------------|
|
|
135
|
+
| **1 — Native Compact** | Minified JS | Files directly | Files directly |
|
|
136
|
+
| **2 — Full Storage** (default) | Formatted JS | `get_compressed_file` | `edit_compressed` |
|
|
137
|
+
| **3 — IDE Virtual** | Minified JS | IDE renders full view | IDE handles mapping |
|
|
138
|
+
|
|
139
|
+
**Mode 2 workflow** (recommended):
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
// 1. Read compressed view (saves 20-55% tokens)
|
|
143
|
+
get_compressed_file({ path: "src/parser.js" })
|
|
144
|
+
|
|
145
|
+
// 2. Edit by symbol name — server finds it via AST
|
|
146
|
+
edit_compressed({
|
|
147
|
+
path: "src/parser.js",
|
|
148
|
+
symbol: "parseFile",
|
|
149
|
+
code: "export async function parseFile(code, filename) { /* new body */ }"
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
// 3. Validate .ctx contracts after editing
|
|
153
|
+
validate_ctx_contracts({ path: "." })
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**`.ctx` typed signatures** — JSDoc types extracted into compact format:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
parseFile(code:string,filename:string)→Promise<ParseResult>→parse,walk|parse JS file into AST
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Set project mode
|
|
164
|
+
npx project-graph-mcp set-mode . 2
|
|
165
|
+
|
|
166
|
+
# Validate .ctx documentation matches source
|
|
167
|
+
npx project-graph-mcp validate-ctx . --strict
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Expand & Validate Pipeline
|
|
171
|
+
|
|
172
|
+
The compact→expand pipeline is **fully reversible**. Verify round-trip integrity:
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
// Expand a compact file back to full formatted + JSDoc
|
|
176
|
+
compact({ action: "expand_file", path: "src/parser.js" })
|
|
177
|
+
|
|
178
|
+
// Expand entire project
|
|
179
|
+
compact({ action: "expand_project", path: ".", dryRun: true })
|
|
180
|
+
|
|
181
|
+
// Validate compact ↔ expand round-trip
|
|
182
|
+
compact({ action: "validate_pipeline", path: ".", strict: true })
|
|
183
|
+
// → Reports any functions in source missing from .ctx
|
|
184
|
+
```
|
|
48
185
|
|
|
49
186
|
### Test Checklists
|
|
50
187
|
|
|
51
|
-
|
|
188
|
+
Test checklists live in `.ctx.md` files (alongside documentation), not in source code:
|
|
189
|
+
|
|
190
|
+
```markdown
|
|
191
|
+
## Tests
|
|
192
|
+
- [ ] POST /api/users with valid data → 201 Created
|
|
193
|
+
- [ ] GET /api/users/:id returns user object
|
|
194
|
+
- [x] DELETE /api/users/:id → 204 No Content
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The agent calls `get_pending_tests`, runs the test, then `mark_test_passed` (which writes `[x]` directly to the `.ctx.md` file). Test state is persistent and survives session restarts.
|
|
198
|
+
|
|
199
|
+
### Monorepo Support
|
|
200
|
+
|
|
201
|
+
`discover_sub_projects` scans standard monorepo directories (`packages/`, `apps/`, `services/`, `modules/`, `libs/`, `plugins/`) for sub-projects with `package.json`. Combined with `parseProject({ recursive: true })`, agents can analyze entire monorepos.
|
|
202
|
+
|
|
203
|
+
### Database Analysis
|
|
204
|
+
|
|
205
|
+
Scan SQL migrations and code for database schema insights:
|
|
52
206
|
|
|
53
207
|
```javascript
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
208
|
+
// Extract schema from SQL/migration files
|
|
209
|
+
db({ action: "schema", path: "src/" })
|
|
210
|
+
|
|
211
|
+
// Find where each table is referenced in code
|
|
212
|
+
db({ action: "table_usage", path: "src/", table: "users" })
|
|
213
|
+
|
|
214
|
+
// Detect tables defined but never queried
|
|
215
|
+
db({ action: "dead_tables", path: "src/" })
|
|
61
216
|
```
|
|
62
217
|
|
|
63
|
-
|
|
218
|
+
### Web Dashboard
|
|
219
|
+
|
|
220
|
+
Every project-graph-mcp instance includes a built-in web UI at `http://localhost:{port}/`:
|
|
221
|
+
|
|
222
|
+
- **Multi-project dashboard** — overview of all registered projects with token metrics
|
|
223
|
+
- **File tree** — navigate project structure
|
|
224
|
+
- **Code viewer** — compact/raw toggle with syntax highlighting and per-file compression stats
|
|
225
|
+
- **Dependency graph** — visual dependency exploration
|
|
226
|
+
- **Health panel** — analysis results
|
|
227
|
+
- **Live monitor** — real-time agent activity via WebSocket
|
|
228
|
+
|
|
229
|
+
With the optional gateway, all projects are accessible under `http://project-graph.local/{project-name}/`.
|
|
230
|
+
|
|
231
|
+
### Compression Metrics
|
|
232
|
+
|
|
233
|
+
Token-level metrics are available project-wide and per-file:
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
// Project-wide: how many tokens for the entire codebase
|
|
237
|
+
// GET /api/compression-stats
|
|
238
|
+
// → { files: 45, codeTok: 47000, ctxTok: 9500, totalTok: 56500 }
|
|
239
|
+
|
|
240
|
+
// Per-file: shown in code viewer header
|
|
241
|
+
// 2054 + 527 ctx = 2581 → 3340 tok (23% savings)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Performance
|
|
245
|
+
|
|
246
|
+
- **Batch concurrency** — `generate_context_docs` processes 5 files in parallel
|
|
247
|
+
- **Quick health check** — `get_analysis_summary` runs only cached per-file metrics (skips expensive cross-file analysis)
|
|
248
|
+
- **Streaming analysis** — `getFullAnalysisStreaming` yields results incrementally as each sub-analysis completes
|
|
64
249
|
|
|
65
250
|
### Custom Rules & Framework References
|
|
66
251
|
|
|
67
|
-
|
|
252
|
+
11 pre-built rulesets (86 rules) for React 18/19, Vue 3, Next.js 15, Express 5, Fastify 5, NestJS 10, TypeScript 5, Node.js 22, and [Symbiote.js](https://github.com/symbiotejs/symbiote.js). The server auto-detects your project type and returns adapted documentation via `get_framework_reference`.
|
|
68
253
|
|
|
69
254
|
Custom project conventions can be added in the `rules/` directory or configured by the agent via `set_custom_rule`.
|
|
70
255
|
|
|
@@ -93,6 +278,19 @@ Add to your IDE's MCP configuration:
|
|
|
93
278
|
|
|
94
279
|
Restart your IDE — project-graph-mcp will be downloaded and started automatically.
|
|
95
280
|
|
|
281
|
+
#### Grouped Tools (v2.0)
|
|
282
|
+
|
|
283
|
+
v2.0 uses 18 domain-grouped tools instead of 49 individual endpoints. Grouped tools use an `action` parameter:
|
|
284
|
+
|
|
285
|
+
```javascript
|
|
286
|
+
navigate({ action: "expand", symbol: "MyClass" })
|
|
287
|
+
analyze({ action: "complexity", path: "src/" })
|
|
288
|
+
docs({ action: "generate", path: ".", scope: "focus" })
|
|
289
|
+
compact({ action: "compact_file", path: "src/parser.js" })
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
10 standalone tools (`get_skeleton`, `get_ai_context`, `invalidate_cache`, etc.) remain unchanged.
|
|
293
|
+
|
|
96
294
|
<details>
|
|
97
295
|
<summary>Where is my MCP config file?</summary>
|
|
98
296
|
|
|
@@ -115,7 +313,7 @@ See **[CONFIGURATION.md](CONFIGURATION.md)** for all supported IDEs (Antigravity
|
|
|
115
313
|
git clone https://github.com/rnd-pro/project-graph-mcp
|
|
116
314
|
cd project-graph-mcp
|
|
117
315
|
# No npm install needed — zero dependencies
|
|
118
|
-
# Use "node /path/to/project-graph-mcp/src/server.js" as the command in MCP config
|
|
316
|
+
# Use "node /path/to/project-graph-mcp/src/network/server.js" as the command in MCP config
|
|
119
317
|
```
|
|
120
318
|
|
|
121
319
|
</details>
|
|
@@ -130,6 +328,12 @@ npx project-graph-mcp deadcode src/ # Find unused code
|
|
|
130
328
|
npx project-graph-mcp complexity src/ # Cyclomatic complexity
|
|
131
329
|
npx project-graph-mcp similar src/ # Find duplicates
|
|
132
330
|
npx project-graph-mcp pending src/ # List pending tests
|
|
331
|
+
npx project-graph-mcp compress src/f.js # Compress file for AI
|
|
332
|
+
npx project-graph-mcp docs src/ # Project docs (doc-dialect)
|
|
333
|
+
npx project-graph-mcp generate-ctx src/ # Generate .context/ docs
|
|
334
|
+
npx project-graph-mcp validate-ctx . # Validate .ctx ↔ source
|
|
335
|
+
npx project-graph-mcp mode . # Show current editing mode
|
|
336
|
+
npx project-graph-mcp set-mode . 2 # Set mode (1/2/3)
|
|
133
337
|
npx project-graph-mcp help # All commands
|
|
134
338
|
```
|
|
135
339
|
|
|
@@ -164,8 +368,10 @@ Best used together with [**agent-pool-mcp**](https://www.npmjs.com/package/agent
|
|
|
164
368
|
|
|
165
369
|
- [CONFIGURATION.md](CONFIGURATION.md) — Setup for all supported IDEs
|
|
166
370
|
- [ARCHITECTURE.md](ARCHITECTURE.md) — Source code structure
|
|
167
|
-
- [AGENT_ROLE.md](AGENT_ROLE.md) — Full system prompt for agents
|
|
168
|
-
- [AGENT_ROLE_MINIMAL.md](AGENT_ROLE_MINIMAL.md) — Minimal variant (agent self-discovers)
|
|
371
|
+
- [AGENT_ROLE.md](docs/examples/AGENT_ROLE.md) — Full system prompt for agents
|
|
372
|
+
- [AGENT_ROLE_MINIMAL.md](docs/examples/AGENT_ROLE_MINIMAL.md) — Minimal variant (agent self-discovers)
|
|
373
|
+
- [GUIDE.md](GUIDE.md) — Comprehensive usage guide with all tools
|
|
374
|
+
- [ROADMAP.md](docs/ROADMAP.md) — Feature roadmap and backlog
|
|
169
375
|
|
|
170
376
|
## Related Projects
|
|
171
377
|
- [agent-pool-mcp](https://github.com/rnd-pro/agent-pool-mcp) — Multi-agent orchestration via Gemini CLI
|
|
@@ -5,27 +5,37 @@ You have access to **Project Graph MCP** — a suite of code analysis and projec
|
|
|
5
5
|
## 🧭 Navigation & Understanding
|
|
6
6
|
| Tool | Purpose |
|
|
7
7
|
|------|---------|
|
|
8
|
-
| `
|
|
9
|
-
| `get_skeleton` | Get code structure (classes, functions, exports) |
|
|
8
|
+
| `get_skeleton` | Get compact code structure (classes, functions, exports) |
|
|
10
9
|
| `expand` | Deep dive into a class or function |
|
|
10
|
+
| `get_focus_zone` | Get enriched context for recently modified files |
|
|
11
|
+
| `get_call_chain` | Find shortest path between two symbols |
|
|
12
|
+
| `usages` | Find all usages of a symbol across the project |
|
|
13
|
+
| `deps` | Get dependency tree for a symbol |
|
|
11
14
|
| `get_agent_instructions` | Get project coding guidelines |
|
|
12
15
|
| `get_framework_reference` | Get framework AI reference (auto-detects or explicit) |
|
|
16
|
+
| `get_usage_guide` | Get full usage guide with examples |
|
|
17
|
+
| `invalidate_cache` | Refresh graph after code changes (MANDATORY after edits) |
|
|
13
18
|
|
|
14
19
|
## 🧪 Testing System
|
|
15
20
|
|
|
16
21
|
| Tool | Purpose |
|
|
17
22
|
|------|---------|
|
|
18
|
-
| `get_pending_tests` | List
|
|
19
|
-
| `mark_test_passed` / `mark_test_failed` |
|
|
23
|
+
| `get_pending_tests` | List `[ ]` checklists from `.ctx.md` files |
|
|
24
|
+
| `mark_test_passed` / `mark_test_failed` | Write `[x]` or `[!]` directly to `.ctx.md` |
|
|
20
25
|
| `get_test_summary` | Progress report |
|
|
26
|
+
| `reset_test_state` | Reset all checklists to `[ ]` |
|
|
21
27
|
|
|
22
|
-
###
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
### How Test Checklists Work
|
|
29
|
+
Tests live in `.ctx.md` files (the "agent zone" of the two-tier documentation), not in source code:
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
# parser.js
|
|
33
|
+
|
|
34
|
+
## Tests
|
|
35
|
+
- [ ] Parse valid JS file with classes and functions
|
|
36
|
+
- [ ] Handle syntax errors gracefully
|
|
37
|
+
- [x] Parse empty file without crash
|
|
38
|
+
```
|
|
29
39
|
|
|
30
40
|
### Browser Testing Workflow (VERIFICATION mode)
|
|
31
41
|
After code changes, you MUST verify UI with this flow:
|
|
@@ -37,20 +47,9 @@ After code changes, you MUST verify UI with this flow:
|
|
|
37
47
|
4. get_test_summary(path) → final report before completing task
|
|
38
48
|
```
|
|
39
49
|
|
|
40
|
-
**Rule**: If `get_pending_tests()` returns items, they MUST be executed
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
/**
|
|
45
|
-
* Delete selected persona
|
|
46
|
-
*
|
|
47
|
-
* @test click: Click delete button on persona card
|
|
48
|
-
* @test click: Confirm in dialog
|
|
49
|
-
* @expect element: Persona removed from list
|
|
50
|
-
* @expect visual: Toast notification appears
|
|
51
|
-
*/
|
|
52
|
-
async onDeletePersona() { ... }
|
|
53
|
-
```
|
|
50
|
+
**Rule**: If `get_pending_tests()` returns items, they MUST be executed before the task is marked complete.
|
|
51
|
+
|
|
52
|
+
> **Note**: Test state is persistent (written to files) and survives agent session restarts.
|
|
54
53
|
|
|
55
54
|
## 🗄️ Database Analysis
|
|
56
55
|
| Tool | Purpose |
|
|
@@ -71,16 +70,72 @@ The graph automatically detects SQL queries in your code:
|
|
|
71
70
|
- Column-level dead code detection is best-effort.
|
|
72
71
|
- ORM-specific patterns (Prisma, Sequelize, Knex query builder) are not yet supported.
|
|
73
72
|
|
|
73
|
+
## 🧠 AI Context Layer
|
|
74
|
+
| Tool | Purpose |
|
|
75
|
+
|------|---------|
|
|
76
|
+
| `get_ai_context` | **Boot**: skeleton + docs + compressed files in one call |
|
|
77
|
+
| `get_compressed_file` | Terser-minified source with export legend |
|
|
78
|
+
| `get_project_docs` | Doc Dialect documentation (auto + manual .context/) |
|
|
79
|
+
| `generate_context_docs` | Generate .context/ templates from AST (batch concurrent) |
|
|
80
|
+
| `check_stale_docs` | Detect outdated .ctx files by @sig hash |
|
|
81
|
+
| `discover_sub_projects` | Find sub-projects in monorepo (packages/apps/services/...) |
|
|
82
|
+
| `get_analysis_summary` | Quick health score — cached metrics only, skips cross-file |
|
|
83
|
+
| `compact_project` | Compact all JS files — strips comments/whitespace (mangle:false) |
|
|
84
|
+
| `beautify_project` | Beautify/expand all JS files — inverse of compact |
|
|
85
|
+
|
|
86
|
+
### AI-First Workflow
|
|
87
|
+
1. **Boot**: `get_ai_context(path)` — loads skeleton + docs (~1700 tokens vs ~60K original)
|
|
88
|
+
2. **Drill**: `expand(symbol)` or `get_compressed_file(file)` — go deeper when needed
|
|
89
|
+
3. **Enrich**: `generate_context_docs(path)` creates `.context/*.ctx` with `{DESCRIBE}` markers. Fill them with compact descriptions.
|
|
90
|
+
|
|
91
|
+
### Doc Dialect Storage (Two-Tier)
|
|
92
|
+
`.context/` mirrors your source tree with two files per source:
|
|
93
|
+
```
|
|
94
|
+
.context/ ← auto-generated (mirror)
|
|
95
|
+
├── project.ctx
|
|
96
|
+
├── parser.ctx ← Machine zone: AST signatures, @sig
|
|
97
|
+
├── parser.ctx.md ← Agent zone: notes, TODO, decisions
|
|
98
|
+
└── utils/
|
|
99
|
+
└── helpers.ctx
|
|
100
|
+
|
|
101
|
+
src/
|
|
102
|
+
├── parser.js
|
|
103
|
+
├── parser.ctx ← colocated override (wins!)
|
|
104
|
+
└── utils/
|
|
105
|
+
└── helpers.js
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Doc Dialect Format
|
|
109
|
+
`.context/` files use a compact pipe-separated format:
|
|
110
|
+
```
|
|
111
|
+
--- parser.js ---
|
|
112
|
+
export parseProject()→resolve,findJSFiles,readFileSync|scans dir, parses all files
|
|
113
|
+
parseFileByExtension()→parseSQL,parsePython,parseGo|routes by extension
|
|
114
|
+
PATTERNS: lang-*.js for non-JS|regex fallback for Python
|
|
115
|
+
EDGE_CASES: Python uses regex, not AST|Go interfaces ≠ classes
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Enrichment Workflow
|
|
119
|
+
| Step | How |
|
|
120
|
+
|------|-----|
|
|
121
|
+
| 1. Generate | `generate_context_docs` creates templates with `{DESCRIBE}` markers + `@sig` hash |
|
|
122
|
+
| 2. Enrich | Delegate to agent-pool: `delegate_task({ skill: "doc-enricher" })` |
|
|
123
|
+
| 3. Monitor | `check_stale_docs` detects when source changes invalidate docs |
|
|
124
|
+
| 4. Update | Regenerate with `overwrite: true` — existing descriptions are preserved |
|
|
125
|
+
|
|
74
126
|
## 🔍 Code Quality Analysis
|
|
75
127
|
| Tool | Purpose |
|
|
76
128
|
|------|---------|
|
|
77
129
|
| `get_full_analysis` | Run ALL checks + Health Score (0-100) |
|
|
130
|
+
| `get_analysis_summary` | Quick health score (cached only, fast) |
|
|
78
131
|
| `get_dead_code` | Find unused functions/classes |
|
|
79
132
|
| `get_undocumented` | Find missing JSDoc |
|
|
80
133
|
| `get_similar_functions` | Detect code duplicates |
|
|
81
134
|
| `get_complexity` | Cyclomatic complexity metrics |
|
|
82
135
|
| `get_large_files` | Files needing split |
|
|
83
136
|
| `get_outdated_patterns` | Legacy patterns + redundant npm deps |
|
|
137
|
+
| `check_jsdoc_consistency` | Validate JSDoc ↔ AST signatures |
|
|
138
|
+
| `check_types` | Optional tsc type checking (requires TypeScript) |
|
|
84
139
|
| `generate_jsdoc` | Auto-generate JSDoc templates |
|
|
85
140
|
|
|
86
141
|
## 🔧 Custom Rules (Configurable)
|
|
@@ -96,11 +151,11 @@ Rules are applied automatically based on:
|
|
|
96
151
|
- Import patterns in source code
|
|
97
152
|
- Code patterns (e.g., `extends Symbiote`)
|
|
98
153
|
|
|
99
|
-
### Pre-built Rulesets (
|
|
154
|
+
### Pre-built Rulesets (86 rules)
|
|
100
155
|
| Ruleset | Rules | Framework |
|
|
101
156
|
|---------|-------|-----------|
|
|
102
157
|
| `symbiote-2x` | 12 | Symbiote.js 2.x |
|
|
103
|
-
| `symbiote-3x` |
|
|
158
|
+
| `symbiote-3x` | 18 | Symbiote.js 3.x |
|
|
104
159
|
| `react-18` | 6 | React 18 |
|
|
105
160
|
| `react-19` | 5 | React 19 (Server Components) |
|
|
106
161
|
| `vue-3` | 5 | Vue 3 Composition API |
|
|
@@ -109,7 +164,7 @@ Rules are applied automatically based on:
|
|
|
109
164
|
| `fastify-5` | 5 | Fastify 5.x |
|
|
110
165
|
| `nestjs-10` | 6 | NestJS 10.x |
|
|
111
166
|
| `typescript-5` | 5 | TypeScript 5.x |
|
|
112
|
-
| `node-22` |
|
|
167
|
+
| `node-22` | 13 | Node.js 22+ |
|
|
113
168
|
|
|
114
169
|
### Creating New Rules
|
|
115
170
|
Read project workflow docs (e.g., `.agent/workflows/symbiote-audit.md`) and use `set_custom_rule`:
|
|
@@ -134,12 +189,14 @@ Read project workflow docs (e.g., `.agent/workflows/symbiote-audit.md`) and use
|
|
|
134
189
|
|------|---------|
|
|
135
190
|
| `get_filters` / `set_filters` | Configure excluded directories |
|
|
136
191
|
| `add_excludes` / `remove_excludes` | Modify exclude list |
|
|
192
|
+
| `reset_filters` | Reset to defaults |
|
|
137
193
|
|
|
138
194
|
## 🚀 Recommended Workflow
|
|
139
195
|
|
|
140
|
-
1. **
|
|
141
|
-
2. **Dive**: `
|
|
196
|
+
1. **Boot**: `get_ai_context` → understand entire project in ~1700 tokens
|
|
197
|
+
2. **Dive**: `expand` / `get_compressed_file` → drill into specific files
|
|
142
198
|
3. **Analyze**: `get_full_analysis` → find issues (Health Score)
|
|
143
199
|
4. **Check Rules**: `check_custom_rules` → framework-specific violations
|
|
144
200
|
5. **Fix**: Address issues by severity (error → warning → info)
|
|
145
201
|
6. **Verify**: `get_pending_tests` → execute in browser → `mark_test_passed/failed` → `get_test_summary`
|
|
202
|
+
7. **Document**: `generate_context_docs` → enrich .ctx files with PATTERNS and EDGE_CASES
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Project Graph MCP
|
|
2
2
|
|
|
3
|
-
You have **Project Graph MCP** tools available — code analysis, project navigation, and framework-specific linting.
|
|
3
|
+
You have **Project Graph MCP** tools available — 45 tools for code analysis, project navigation, monorepo scanning, and framework-specific linting.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
@@ -15,9 +15,11 @@ You have **Project Graph MCP** tools available — code analysis, project naviga
|
|
|
15
15
|
- `expand(symbol)` — Deep dive into class/function (use symbols from skeleton's `L` field)
|
|
16
16
|
- `deps(symbol)` — Dependency tree (imports, usedBy, calls)
|
|
17
17
|
- `usages(symbol)` — Find all usages across project
|
|
18
|
+
- `invalidate_cache` — Refresh graph after code changes
|
|
18
19
|
|
|
19
20
|
### Code Quality
|
|
20
21
|
- `get_full_analysis` — Run ALL checks + Health Score
|
|
22
|
+
- `get_analysis_summary` — Quick health score (cached only, fast)
|
|
21
23
|
- `get_dead_code` — Unused functions/classes
|
|
22
24
|
- `get_undocumented` — Missing JSDoc
|
|
23
25
|
- `get_similar_functions` — Code duplicates
|
|
@@ -25,10 +27,21 @@ You have **Project Graph MCP** tools available — code analysis, project naviga
|
|
|
25
27
|
- `get_large_files` — Files needing split
|
|
26
28
|
- `get_outdated_patterns` — Legacy patterns
|
|
27
29
|
|
|
30
|
+
### AI Context
|
|
31
|
+
- `get_ai_context` — **Boot**: skeleton + docs + compressed files (~97% savings)
|
|
32
|
+
- `get_compressed_file` — Terser-minified source with export legend
|
|
33
|
+
- `get_project_docs` — Doc Dialect documentation (.context/)
|
|
34
|
+
- `generate_context_docs` — Generate .context/ templates with `@sig` staleness hashes
|
|
35
|
+
- `check_stale_docs` — Check which .ctx files need updating
|
|
36
|
+
- `discover_sub_projects` — Find sub-projects in monorepo
|
|
37
|
+
- `compact_project` — Compact all JS files (strips comments/whitespace, preserves names)
|
|
38
|
+
- `beautify_project` — Beautify/expand all JS files (inverse of compact)
|
|
39
|
+
|
|
28
40
|
### Testing
|
|
29
|
-
- `get_pending_tests` — List
|
|
30
|
-
- `mark_test_passed(testId)` / `mark_test_failed(testId, reason)`
|
|
41
|
+
- `get_pending_tests` — List `[ ]` checklists from `.ctx.md` files
|
|
42
|
+
- `mark_test_passed(testId)` / `mark_test_failed(testId, reason)` — writes to `.ctx.md`
|
|
31
43
|
- `get_test_summary` — Progress report
|
|
44
|
+
- `reset_test_state` — Reset all checklists to `[ ]`
|
|
32
45
|
|
|
33
46
|
### Custom Rules
|
|
34
47
|
- `check_custom_rules(path)` — Run framework-specific analysis (auto-detected)
|
|
@@ -40,11 +53,13 @@ You have **Project Graph MCP** tools available — code analysis, project naviga
|
|
|
40
53
|
## Workflow
|
|
41
54
|
|
|
42
55
|
```
|
|
43
|
-
1.
|
|
44
|
-
2.
|
|
45
|
-
3.
|
|
46
|
-
4.
|
|
47
|
-
5.
|
|
56
|
+
1. get_ai_context("src/") → Boot: ~1700 tokens for entire project
|
|
57
|
+
2. expand(symbol) → Drill into specific class/function
|
|
58
|
+
3. get_full_analysis("src/") → Find issues (Health Score)
|
|
59
|
+
4. check_custom_rules("src/") → Framework violations
|
|
60
|
+
5. Fix by severity: error → warning → info
|
|
61
|
+
6. get_pending_tests("src/") → Verification checklist
|
|
62
|
+
7. generate_context_docs("src/")→ Enrich .ctx files
|
|
48
63
|
```
|
|
49
64
|
|
|
50
65
|
## Tips
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "project-graph-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "MCP server for AI agents —
|
|
6
|
-
"main": "src/server.js",
|
|
5
|
+
"description": "MCP server for AI agents — project graph, code quality analysis, visual web explorer. JS, TS, Python, Go.",
|
|
6
|
+
"main": "src/network/server.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"project-graph-mcp": "src/server.js"
|
|
8
|
+
"project-graph-mcp": "src/network/server.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"src/",
|
|
12
|
+
"web/",
|
|
12
13
|
"vendor/",
|
|
13
14
|
"rules/",
|
|
14
|
-
"
|
|
15
|
-
"AGENT_ROLE.md",
|
|
16
|
-
"AGENT_ROLE_MINIMAL.md",
|
|
15
|
+
"docs/",
|
|
17
16
|
"CONFIGURATION.md",
|
|
18
17
|
"README.md",
|
|
19
18
|
"LICENSE"
|
|
20
19
|
],
|
|
21
20
|
"scripts": {
|
|
22
|
-
"start": "node src/server.js",
|
|
21
|
+
"start": "node src/network/server.js",
|
|
23
22
|
"test": "node --test tests/*.test.js"
|
|
24
23
|
},
|
|
25
24
|
"keywords": [
|
|
@@ -45,6 +44,11 @@
|
|
|
45
44
|
"author": "RND-PRO",
|
|
46
45
|
"homepage": "https://github.com/rnd-pro/project-graph-mcp",
|
|
47
46
|
"license": "MIT",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@symbiotejs/symbiote": "^3.2.1",
|
|
49
|
+
"symbiote-node": "^0.2.0",
|
|
50
|
+
"ws": "^8.20.0"
|
|
51
|
+
},
|
|
48
52
|
"engines": {
|
|
49
53
|
"node": ">=18.0.0"
|
|
50
54
|
}
|