@monoes/monomindcli 1.11.5 → 1.11.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.11.5",
3
+ "version": "1.11.6",
4
4
  "type": "module",
5
5
  "description": "Monomind CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",
@@ -68,7 +68,6 @@
68
68
  "dist",
69
69
  "bin",
70
70
  ".claude",
71
- "bundled-graph",
72
71
  "scripts",
73
72
  "README.md"
74
73
  ],
@@ -1,73 +0,0 @@
1
- import Graph from 'graphology';
2
- // Mirrors upstream graphify's _normalize_id: lowercase + collapse non-alphanumeric to underscores.
3
- function normalizeId(s) {
4
- return s.replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '').toLowerCase();
5
- }
6
- /**
7
- * Build a graphology Graph from extracted nodes and edges.
8
- * Deduplicates nodes by id, merges parallel edges with higher weight.
9
- */
10
- export function buildGraph(extraction) {
11
- const graph = new Graph({ type: 'directed', multi: false });
12
- // Add all nodes — merge attributes if already present (dedup by id)
13
- for (const node of extraction.nodes) {
14
- if (!graph.hasNode(node.id)) {
15
- graph.addNode(node.id, { ...node });
16
- }
17
- else {
18
- graph.mergeNodeAttributes(node.id, { ...node });
19
- }
20
- }
21
- // Build normalized ID lookup to remap mismatched edge endpoints before stubbing.
22
- const normToId = new Map();
23
- graph.forEachNode((id) => {
24
- normToId.set(normalizeId(id), id);
25
- });
26
- // Add edges — skip self-loops, remap via normalization, stub only true externals
27
- for (const edge of extraction.edges) {
28
- let src = edge.source;
29
- let tgt = edge.target;
30
- if (!graph.hasNode(src)) {
31
- const remapped = normToId.get(normalizeId(src));
32
- if (remapped) {
33
- src = remapped;
34
- }
35
- else {
36
- graph.addNode(src, { id: src, label: src, fileType: 'unknown', sourceFile: '' });
37
- normToId.set(normalizeId(src), src);
38
- }
39
- }
40
- if (!graph.hasNode(tgt)) {
41
- const remapped = normToId.get(normalizeId(tgt));
42
- if (remapped) {
43
- tgt = remapped;
44
- }
45
- else {
46
- graph.addNode(tgt, { id: tgt, label: tgt, fileType: 'unknown', sourceFile: '' });
47
- normToId.set(normalizeId(tgt), tgt);
48
- }
49
- }
50
- if (src === tgt)
51
- continue;
52
- try {
53
- graph.addEdge(src, tgt, {
54
- relation: edge.relation,
55
- confidence: edge.confidence,
56
- confidenceScore: edge.confidenceScore,
57
- weight: edge.weight ?? 1,
58
- sourceFile: edge.sourceFile,
59
- sourceLocation: edge.sourceLocation,
60
- });
61
- }
62
- catch {
63
- // Edge already exists — bump its weight
64
- const existing = graph.edge(src, tgt);
65
- if (existing) {
66
- const prev = graph.getEdgeAttribute(existing, 'weight') ?? 1;
67
- graph.setEdgeAttribute(existing, 'weight', prev + 1);
68
- }
69
- }
70
- }
71
- return graph;
72
- }
73
- //# sourceMappingURL=build.js.map
@@ -1,120 +0,0 @@
1
- import Graph from 'graphology';
2
- export async function detectCommunities(graph) {
3
- let louvainFn = null;
4
- try {
5
- const mod = await import('graphology-communities-louvain');
6
- louvainFn = mod.default;
7
- }
8
- catch { /* louvain not available */ }
9
- if (louvainFn) {
10
- try {
11
- const assignment = louvainFn(graph);
12
- for (const [nodeId, communityId] of Object.entries(assignment)) {
13
- graph.setNodeAttribute(nodeId, 'community', communityId);
14
- }
15
- const communities = {};
16
- for (const [nodeId, communityId] of Object.entries(assignment)) {
17
- if (!communities[communityId])
18
- communities[communityId] = [];
19
- communities[communityId].push(nodeId);
20
- }
21
- return splitOversizedCommunities(graph, communities, 0.25, louvainFn);
22
- }
23
- catch { /* fall through */ }
24
- }
25
- return splitOversizedCommunities(graph, fallbackCluster(graph), 0.25, louvainFn);
26
- }
27
- function fallbackCluster(graph) {
28
- const dirMap = new Map();
29
- let nextId = 0;
30
- const communities = {};
31
- graph.forEachNode((id, attrs) => {
32
- const file = attrs.sourceFile || '';
33
- const parts = file.split('/');
34
- const dir = parts.length > 1 ? parts.slice(0, -1).join('/') : 'root';
35
- if (!dirMap.has(dir))
36
- dirMap.set(dir, nextId++);
37
- const cid = dirMap.get(dir);
38
- graph.setNodeAttribute(id, 'community', cid);
39
- if (!communities[cid])
40
- communities[cid] = [];
41
- communities[cid].push(id);
42
- });
43
- return communities;
44
- }
45
- export function cohesionScore(graph, communityNodes) {
46
- const memberSet = new Set(communityNodes);
47
- let totalEdges = 0;
48
- let internalEdges = 0;
49
- graph.forEachEdge((_edge, _attrs, source, target) => {
50
- const srcIn = memberSet.has(source);
51
- const tgtIn = memberSet.has(target);
52
- if (srcIn || tgtIn) {
53
- totalEdges++;
54
- if (srcIn && tgtIn)
55
- internalEdges++;
56
- }
57
- });
58
- return totalEdges === 0 ? 1.0 : internalEdges / totalEdges;
59
- }
60
- export function splitOversizedCommunities(graph, communities, threshold = 0.25, louvainFn = null) {
61
- const maxSize = threshold * graph.order;
62
- const allIds = Object.keys(communities).map(Number);
63
- let nextId = allIds.length > 0 ? Math.max(...allIds) + 1 : 0;
64
- for (const [cidStr, members] of Object.entries(communities)) {
65
- if (members.length <= maxSize)
66
- continue;
67
- const cid = Number(cidStr);
68
- // Attempt topology-based second pass via Louvain on the community subgraph
69
- if (louvainFn && members.length >= 10) {
70
- try {
71
- const memberSet = new Set(members);
72
- const subG = new Graph({ type: 'undirected', multi: false });
73
- for (const nodeId of members)
74
- subG.addNode(nodeId);
75
- graph.forEachEdge((_e, _a, source, target) => {
76
- if (memberSet.has(source) && memberSet.has(target) && source !== target && !subG.hasEdge(source, target))
77
- subG.addEdge(source, target);
78
- });
79
- const subAssignment = louvainFn(subG);
80
- const subCommunityCount = new Set(Object.values(subAssignment)).size;
81
- if (subCommunityCount > 1 && subCommunityCount <= Math.ceil(members.length / 2)) {
82
- const subIdMap = new Map();
83
- const newSubIds = {};
84
- for (const [nodeId, localId] of Object.entries(subAssignment)) {
85
- if (!subIdMap.has(localId))
86
- subIdMap.set(localId, nextId++);
87
- const globalId = subIdMap.get(localId);
88
- graph.setNodeAttribute(nodeId, 'community', globalId);
89
- if (!newSubIds[globalId])
90
- newSubIds[globalId] = [];
91
- newSubIds[globalId].push(nodeId);
92
- }
93
- delete communities[cid];
94
- Object.assign(communities, newSubIds);
95
- continue;
96
- }
97
- }
98
- catch { /* fall through to directory heuristic */ }
99
- }
100
- // Directory heuristic fallback
101
- const subMap = new Map();
102
- const newSubIds = {};
103
- for (const nodeId of members) {
104
- const file = graph.getNodeAttribute(nodeId, 'sourceFile') || '';
105
- const parts = file.split('/');
106
- const parentDir = parts.length > 1 ? parts[parts.length - 2] : 'root';
107
- if (!subMap.has(parentDir))
108
- subMap.set(parentDir, nextId++);
109
- const subId = subMap.get(parentDir);
110
- graph.setNodeAttribute(nodeId, 'community', subId);
111
- if (!newSubIds[subId])
112
- newSubIds[subId] = [];
113
- newSubIds[subId].push(nodeId);
114
- }
115
- delete communities[cid];
116
- Object.assign(communities, newSubIds);
117
- }
118
- return communities;
119
- }
120
- //# sourceMappingURL=cluster.js.map
@@ -1,57 +0,0 @@
1
- {
2
- "name": "@monomind/graph",
3
- "version": "1.4.0",
4
- "type": "module",
5
- "description": "Knowledge graph engine for monomind — AST extraction, graph construction, community detection, and persistent codebase understanding",
6
- "main": "./dist/src/index.js",
7
- "types": "./dist/src/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/src/index.d.ts",
11
- "import": "./dist/src/index.js"
12
- }
13
- },
14
- "files": [
15
- "dist",
16
- "src"
17
- ],
18
- "scripts": {
19
- "build": "tsc",
20
- "test": "vitest run",
21
- "clean": "rm -rf dist"
22
- },
23
- "dependencies": {
24
- "graphology": "^0.25.4",
25
- "graphology-types": "^0.24.7",
26
- "graphology-communities-louvain": "^2.0.1",
27
- "graphology-shortest-path": "^2.0.2",
28
- "graphology-traversal": "^0.3.1",
29
- "graphology-metrics": "^2.4.0",
30
- "chokidar": "^3.6.0"
31
- },
32
- "devDependencies": {
33
- "@types/node": "^20.0.0",
34
- "typescript": "^5.3.0",
35
- "vitest": "^4.1.4"
36
- },
37
- "optionalDependencies": {
38
- "node-tree-sitter": "^0.22.4",
39
- "tree-sitter-typescript": "^0.23.2",
40
- "tree-sitter-javascript": "^0.23.1",
41
- "tree-sitter-python": "^0.23.6",
42
- "tree-sitter-go": "^0.23.4",
43
- "tree-sitter-rust": "^0.23.2",
44
- "tree-sitter-java": "^0.23.5",
45
- "tree-sitter-c": "^0.23.4",
46
- "tree-sitter-cpp": "^0.23.4",
47
- "tree-sitter-ruby": "^0.23.1",
48
- "tree-sitter-c-sharp": "^0.23.1",
49
- "tree-sitter-kotlin": "^0.3.9",
50
- "tree-sitter-swift": "^0.6.1",
51
- "tree-sitter-scala": "^0.23.4",
52
- "tree-sitter-php": "^0.23.11"
53
- },
54
- "publishConfig": {
55
- "access": "public"
56
- }
57
- }