@monoes/cli 1.0.9 → 1.2.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/.claude/agents/analysis/graphify/graphify-analyst.md +145 -0
- package/dist/src/commands/init.js +2 -0
- package/dist/src/init/executor.js +36 -0
- package/dist/src/init/mcp-generator.js +10 -0
- package/dist/src/init/types.js +5 -0
- package/dist/src/mcp-tools/graphify-tools.js +564 -0
- package/dist/src/mcp-tools/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: graphify-analyst
|
|
3
|
+
description: "Knowledge graph analyst for codebase architecture and project understanding. Uses graphify's persistent knowledge graph to answer structural questions without reading files — reveals god nodes, community clusters, dependency paths, and cross-component surprises."
|
|
4
|
+
type: graphify-analyst
|
|
5
|
+
color: violet
|
|
6
|
+
priority: high
|
|
7
|
+
triggers:
|
|
8
|
+
- "understand the codebase"
|
|
9
|
+
- "how does * work"
|
|
10
|
+
- "what calls *"
|
|
11
|
+
- "architecture overview"
|
|
12
|
+
- "dependency between"
|
|
13
|
+
- "project structure"
|
|
14
|
+
- "how is * related to"
|
|
15
|
+
- "explain the flow"
|
|
16
|
+
- "what depends on"
|
|
17
|
+
metadata:
|
|
18
|
+
specialization: "Knowledge graph-based codebase analysis"
|
|
19
|
+
requires: "graphify Python package (pip install graphifyy[mcp])"
|
|
20
|
+
capabilities:
|
|
21
|
+
- Zero-file-read architecture understanding via knowledge graph
|
|
22
|
+
- God node identification (most connected core abstractions)
|
|
23
|
+
- Community/subsystem detection and analysis
|
|
24
|
+
- Shortest dependency path between any two components
|
|
25
|
+
- Cross-community surprising connection detection
|
|
26
|
+
- Code vs documentation relationship mapping
|
|
27
|
+
- Confidence-aware edge reasoning (EXTRACTED/INFERRED/AMBIGUOUS)
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Graphify Analyst Agent
|
|
31
|
+
|
|
32
|
+
A specialist in codebase understanding through knowledge graphs. Instead of reading files, this agent queries a persistent, pre-built graph of your entire project — delivering architectural insights in seconds.
|
|
33
|
+
|
|
34
|
+
## When to Use This Agent
|
|
35
|
+
|
|
36
|
+
Use graphify-analyst **instead of reading files** when you need to:
|
|
37
|
+
- Understand how components relate to each other
|
|
38
|
+
- Find the core abstractions of an unfamiliar codebase
|
|
39
|
+
- Trace a dependency chain from A to B
|
|
40
|
+
- Identify which subsystems exist and what belongs to each
|
|
41
|
+
- Detect unexpected coupling between modules
|
|
42
|
+
- Answer "what is the most important class/function/concept here?"
|
|
43
|
+
|
|
44
|
+
## Workflow
|
|
45
|
+
|
|
46
|
+
### Step 1 — Check graph exists
|
|
47
|
+
```
|
|
48
|
+
mcp__monobrain__graphify_stats
|
|
49
|
+
```
|
|
50
|
+
If no graph: tell user to run `python -m graphify <project-path>` first.
|
|
51
|
+
|
|
52
|
+
### Step 2 — Get orientation (always start here)
|
|
53
|
+
```
|
|
54
|
+
mcp__monobrain__graphify_god_nodes { topN: 15 }
|
|
55
|
+
```
|
|
56
|
+
The top god nodes ARE the architecture. Everything important will be connected to them.
|
|
57
|
+
|
|
58
|
+
### Step 3 — Query by concept
|
|
59
|
+
```
|
|
60
|
+
mcp__monobrain__graphify_query { question: "authentication", mode: "bfs", depth: 3 }
|
|
61
|
+
```
|
|
62
|
+
Match the question to the user's actual concern. Use `dfs` to trace a specific call path.
|
|
63
|
+
|
|
64
|
+
### Step 4 — Understand subsystems
|
|
65
|
+
```
|
|
66
|
+
mcp__monobrain__graphify_community { communityId: 0 } // largest cluster
|
|
67
|
+
```
|
|
68
|
+
Each community is a logical subsystem. Review all communities to understand module boundaries.
|
|
69
|
+
|
|
70
|
+
### Step 5 — Trace specific dependencies
|
|
71
|
+
```
|
|
72
|
+
mcp__monobrain__graphify_shortest_path { source: "Router", target: "Database" }
|
|
73
|
+
```
|
|
74
|
+
Use to answer "how does X reach Y?" — reveals hidden coupling chains.
|
|
75
|
+
|
|
76
|
+
### Step 6 — Find surprises
|
|
77
|
+
```
|
|
78
|
+
mcp__monobrain__graphify_surprises { topN: 10 }
|
|
79
|
+
```
|
|
80
|
+
Cross-community connections often reveal design smells or important but non-obvious integrations.
|
|
81
|
+
|
|
82
|
+
## Output Format
|
|
83
|
+
|
|
84
|
+
Always structure your response as:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
## Architecture Overview
|
|
88
|
+
[Top god nodes — the core abstractions]
|
|
89
|
+
|
|
90
|
+
## Subsystems / Communities
|
|
91
|
+
[What each community represents]
|
|
92
|
+
|
|
93
|
+
## Key Relationships
|
|
94
|
+
[Most important edges and what they mean]
|
|
95
|
+
|
|
96
|
+
## Surprising Connections
|
|
97
|
+
[Cross-community edges worth noting]
|
|
98
|
+
|
|
99
|
+
## Confidence Notes
|
|
100
|
+
[Which edges are EXTRACTED vs INFERRED vs AMBIGUOUS]
|
|
101
|
+
|
|
102
|
+
## Recommendations
|
|
103
|
+
[Architectural observations, potential improvements]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Confidence Interpretation
|
|
107
|
+
|
|
108
|
+
| Confidence | Meaning | Trust Level |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| EXTRACTED | Explicitly in source (import, call, inheritance) | High — treat as fact |
|
|
111
|
+
| INFERRED | Reasonable deduction with confidence score | Medium — verify if critical |
|
|
112
|
+
| AMBIGUOUS | Uncertain — flagged for review | Low — use as hypothesis only |
|
|
113
|
+
|
|
114
|
+
## Building the Graph
|
|
115
|
+
|
|
116
|
+
If `graphify_stats` shows no graph:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Install
|
|
120
|
+
pip install graphifyy[mcp]
|
|
121
|
+
|
|
122
|
+
# Build graph for current project
|
|
123
|
+
python -m graphify .
|
|
124
|
+
|
|
125
|
+
# Query via MCP (starts stdio server)
|
|
126
|
+
python -m graphify.serve graphify-out/graph.json --mcp
|
|
127
|
+
|
|
128
|
+
# Or rebuild only code changes (fast, no LLM)
|
|
129
|
+
python -m graphify --update .
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Limits
|
|
133
|
+
|
|
134
|
+
- Graph must be built before querying — it does not auto-build
|
|
135
|
+
- Very large codebases (500k+ LOC) may have slow initial builds
|
|
136
|
+
- Doc/paper semantic edges require LLM — code AST edges are free
|
|
137
|
+
- Graph reflects state at build time — use `graphify_build { codeOnly: true }` to refresh after code changes
|
|
138
|
+
|
|
139
|
+
## Integration with Other Agents
|
|
140
|
+
|
|
141
|
+
After graphify-analyst provides architectural context, hand off to:
|
|
142
|
+
- **coder** — for implementation using the architectural understanding
|
|
143
|
+
- **reviewer** — for code review informed by community/dependency context
|
|
144
|
+
- **architect** — for refactoring suggestions based on surprising connections
|
|
145
|
+
- **security-auditor** — for security review focusing on EXTRACTED cross-boundary edges
|
|
@@ -655,6 +655,7 @@ const skillsCommand = {
|
|
|
655
655
|
mcp: false,
|
|
656
656
|
runtime: false,
|
|
657
657
|
claudeMd: false,
|
|
658
|
+
graphify: false,
|
|
658
659
|
},
|
|
659
660
|
skills: {
|
|
660
661
|
all: ctx.flags.all,
|
|
@@ -706,6 +707,7 @@ const hooksCommand = {
|
|
|
706
707
|
mcp: false,
|
|
707
708
|
runtime: false,
|
|
708
709
|
claudeMd: false,
|
|
710
|
+
graphify: false,
|
|
709
711
|
},
|
|
710
712
|
hooks: minimal
|
|
711
713
|
? {
|
|
@@ -283,6 +283,10 @@ export async function executeInit(options) {
|
|
|
283
283
|
}
|
|
284
284
|
// Count enabled hooks
|
|
285
285
|
result.summary.hooksEnabled = countEnabledHooks(options);
|
|
286
|
+
// Build knowledge graph in background (non-blocking)
|
|
287
|
+
if (options.components.graphify) {
|
|
288
|
+
await initKnowledgeGraph(targetDir, result);
|
|
289
|
+
}
|
|
286
290
|
}
|
|
287
291
|
catch (error) {
|
|
288
292
|
result.success = false;
|
|
@@ -290,6 +294,38 @@ export async function executeInit(options) {
|
|
|
290
294
|
}
|
|
291
295
|
return result;
|
|
292
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Spawn a background process to build the @monobrain/graph knowledge graph.
|
|
299
|
+
* Fire-and-forget: init does not wait for the graph build to complete.
|
|
300
|
+
* Non-fatal: if @monobrain/graph is unavailable the step is simply skipped.
|
|
301
|
+
*/
|
|
302
|
+
async function initKnowledgeGraph(targetDir, result) {
|
|
303
|
+
try {
|
|
304
|
+
await import('@monoes/graph');
|
|
305
|
+
const outputDir = path.join(targetDir, '.monobrain', 'graph');
|
|
306
|
+
const { spawn } = await import('child_process');
|
|
307
|
+
const safePath = targetDir.replace(/'/g, "\\'");
|
|
308
|
+
const safeOut = outputDir.replace(/'/g, "\\'");
|
|
309
|
+
const script = `
|
|
310
|
+
import('@monoes/graph').then(({ buildGraph }) =>
|
|
311
|
+
buildGraph('${safePath}', { codeOnly: true, outputDir: '${safeOut}' })
|
|
312
|
+
).then(r => console.log('[graph] built: ' + r.analysis.stats.nodes + ' nodes'))
|
|
313
|
+
.catch(e => console.error('[graph] build failed:', e.message));
|
|
314
|
+
`;
|
|
315
|
+
const child = spawn(process.execPath, ['--input-type=module'], {
|
|
316
|
+
stdio: ['pipe', 'ignore', 'ignore'],
|
|
317
|
+
detached: true,
|
|
318
|
+
cwd: targetDir,
|
|
319
|
+
});
|
|
320
|
+
child.stdin?.write(script);
|
|
321
|
+
child.stdin?.end();
|
|
322
|
+
child.unref();
|
|
323
|
+
result.created.files.push('.monobrain/graph/ (knowledge graph building in background)');
|
|
324
|
+
}
|
|
325
|
+
catch (_err) {
|
|
326
|
+
result.skipped.push('knowledge graph: @monobrain/graph not available');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
293
329
|
/**
|
|
294
330
|
* Merge new settings into existing settings.json
|
|
295
331
|
* Preserves user customizations while adding new features like Agent Teams
|
|
@@ -55,6 +55,16 @@ export function generateMCPConfig(options) {
|
|
|
55
55
|
if (config.ruvSwarm) {
|
|
56
56
|
mcpServers['ruv-swarm'] = createMCPServerEntry(['ruv-swarm', 'mcp', 'start'], { ...npmEnv }, { optional: true });
|
|
57
57
|
}
|
|
58
|
+
// Graphify knowledge graph MCP server (project understanding)
|
|
59
|
+
if (config.graphify) {
|
|
60
|
+
mcpServers['graphify'] = {
|
|
61
|
+
command: 'python',
|
|
62
|
+
args: ['-m', 'graphify.serve', 'graphify-out/graph.json'],
|
|
63
|
+
env: {},
|
|
64
|
+
optional: true,
|
|
65
|
+
description: 'Knowledge graph for codebase understanding — run `python -m graphify <path>` first',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
58
68
|
// Flow Nexus MCP server (cloud features)
|
|
59
69
|
if (config.flowNexus) {
|
|
60
70
|
mcpServers['flow-nexus'] = createMCPServerEntry(['flow-nexus@latest', 'mcp', 'start'], { ...npmEnv }, { optional: true, requiresAuth: true });
|
package/dist/src/init/types.js
CHANGED
|
@@ -56,6 +56,7 @@ export const DEFAULT_INIT_OPTIONS = {
|
|
|
56
56
|
mcp: true,
|
|
57
57
|
runtime: true,
|
|
58
58
|
claudeMd: true,
|
|
59
|
+
graphify: true,
|
|
59
60
|
},
|
|
60
61
|
hooks: {
|
|
61
62
|
preToolUse: true,
|
|
@@ -118,6 +119,7 @@ export const DEFAULT_INIT_OPTIONS = {
|
|
|
118
119
|
monobrain: true,
|
|
119
120
|
ruvSwarm: false,
|
|
120
121
|
flowNexus: false,
|
|
122
|
+
graphify: false,
|
|
121
123
|
autoStart: false,
|
|
122
124
|
port: 3000,
|
|
123
125
|
},
|
|
@@ -156,6 +158,7 @@ export const MINIMAL_INIT_OPTIONS = {
|
|
|
156
158
|
mcp: true,
|
|
157
159
|
runtime: true,
|
|
158
160
|
claudeMd: true,
|
|
161
|
+
graphify: false,
|
|
159
162
|
},
|
|
160
163
|
hooks: {
|
|
161
164
|
...DEFAULT_INIT_OPTIONS.hooks,
|
|
@@ -224,6 +227,7 @@ export const FULL_INIT_OPTIONS = {
|
|
|
224
227
|
mcp: true,
|
|
225
228
|
runtime: true,
|
|
226
229
|
claudeMd: true,
|
|
230
|
+
graphify: true,
|
|
227
231
|
},
|
|
228
232
|
skills: {
|
|
229
233
|
core: true,
|
|
@@ -247,6 +251,7 @@ export const FULL_INIT_OPTIONS = {
|
|
|
247
251
|
monobrain: true,
|
|
248
252
|
ruvSwarm: true,
|
|
249
253
|
flowNexus: true,
|
|
254
|
+
graphify: false,
|
|
250
255
|
autoStart: false,
|
|
251
256
|
port: 3000,
|
|
252
257
|
},
|