@codragraph/cli 2.1.1 → 2.1.4

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 (101) hide show
  1. package/README.md +12 -9
  2. package/dist/cli/ai-context.js +1 -1
  3. package/dist/cli/analyze.js +19 -2
  4. package/dist/cli/index.js +2 -1
  5. package/dist/cli/serve.d.ts +1 -0
  6. package/dist/cli/serve.js +3 -1
  7. package/dist/cli/setup.js +36 -19
  8. package/dist/cli/status.d.ts +13 -0
  9. package/dist/cli/status.js +99 -0
  10. package/dist/config/ignore-service.js +2 -0
  11. package/dist/core/graphstore/cgdb-row-source.js +3 -2
  12. package/dist/core/group/bridge-db.js +42 -10
  13. package/dist/core/run-analyze.d.ts +20 -0
  14. package/dist/core/run-analyze.js +201 -0
  15. package/dist/core/search/hybrid-search.js +11 -3
  16. package/dist/mcp/resources.js +2 -2
  17. package/dist/server/api.d.ts +14 -2
  18. package/dist/server/api.js +90 -7
  19. package/dist/server/mcp-http.d.ts +22 -0
  20. package/dist/server/mcp-http.js +21 -2
  21. package/dist/server/web-dashboard.d.ts +28 -0
  22. package/dist/server/web-dashboard.js +61 -0
  23. package/dist/web/assets/agent-D5lb0zXz.js +1089 -0
  24. package/dist/web/assets/architectureDiagram-EMZXCZ2Q-CZtc99v_.js +36 -0
  25. package/dist/web/assets/blockDiagram-IGV67L2C-BtoUp-6Y.js +132 -0
  26. package/dist/web/assets/c4Diagram-DFAF54RM-C4Hl3J2U.js +10 -0
  27. package/dist/web/assets/chunk-3GS5O3IE-DkUjU0WD.js +231 -0
  28. package/dist/web/assets/chunk-3YCYZ6SJ-CQkVgT_z.js +1 -0
  29. package/dist/web/assets/chunk-7RZVMHOQ-BitYcNVR.js +338 -0
  30. package/dist/web/assets/chunk-AEOMTBSW-BgTIXPsY.js +1 -0
  31. package/dist/web/assets/chunk-H3VCZNTA-Cx5XV_aC.js +13 -0
  32. package/dist/web/assets/chunk-HN6EAY2L-BBnyTNdB.js +1 -0
  33. package/dist/web/assets/chunk-KSICW3F5-BYzvDLNI.js +15 -0
  34. package/dist/web/assets/chunk-O5ABG6QK-dHwHzA6n.js +1 -0
  35. package/dist/web/assets/chunk-PK6DOVAG-CvsEnugt.js +206 -0
  36. package/dist/web/assets/chunk-RWUO3TPN-BgRTY0_k.js +1 -0
  37. package/dist/web/assets/chunk-TBF5ZNIQ-DL5stGM1.js +1 -0
  38. package/dist/web/assets/chunk-TU3PZOEN-RLyvLcv-.js +1 -0
  39. package/dist/web/assets/classDiagram-PPOCWD7C-DTr8QIOf.js +1 -0
  40. package/dist/web/assets/classDiagram-v2-23LJLIIU-DTr8QIOf.js +1 -0
  41. package/dist/web/assets/context-builder-22jU3V56.js +16 -0
  42. package/dist/web/assets/cose-bilkent-PNC4W37J-DVhePRYg.js +1 -0
  43. package/dist/web/assets/dagre-E77IOHMT-Dzx0A6ZU.js +4 -0
  44. package/dist/web/assets/diagram-H7BISOXX-CC9pRew1.js +43 -0
  45. package/dist/web/assets/diagram-JC5VWROH-Bau_i9tf.js +24 -0
  46. package/dist/web/assets/diagram-LXUTUG65-D9_FM2Gt.js +10 -0
  47. package/dist/web/assets/diagram-WEHSV5V5-BMlayouL.js +24 -0
  48. package/dist/web/assets/erDiagram-GCSMX5X6-C3dhDFA8.js +85 -0
  49. package/dist/web/assets/flowDiagram-OTCZ4VVT-CWSFWmhr.js +162 -0
  50. package/dist/web/assets/ganttDiagram-MUNLMDZQ-D3a67Yol.js +292 -0
  51. package/dist/web/assets/gitGraphDiagram-3HKGZ4G3-7jmry-vM.js +106 -0
  52. package/dist/web/assets/index-BgeqpYgd.js +1415 -0
  53. package/dist/web/assets/index-CT0GtFLZ.css +1 -0
  54. package/dist/web/assets/infoDiagram-MN7RKWGX-G7lhP0Ib.js +2 -0
  55. package/dist/web/assets/ishikawaDiagram-YMYX4NHK-DUoJvNP2.js +70 -0
  56. package/dist/web/assets/journeyDiagram-SO5T7YLQ-RMFPNNqz.js +139 -0
  57. package/dist/web/assets/kanban-definition-LJHFXRCJ-BzpDs1K9.js +89 -0
  58. package/dist/web/assets/katex-GD7MH7QM-DBQvrix-.js +261 -0
  59. package/dist/web/assets/mindmap-definition-2EUWGEK5-Bk0O4roa.js +96 -0
  60. package/dist/web/assets/pieDiagram-3IATQBI2-DKU7kpgS.js +30 -0
  61. package/dist/web/assets/quadrantDiagram-E256RVCF-BY0TGWCS.js +7 -0
  62. package/dist/web/assets/requirementDiagram-M5DCFWZL-DLHOVTSv.js +84 -0
  63. package/dist/web/assets/sankeyDiagram-L3NBLAOT-DVMj5rX2.js +10 -0
  64. package/dist/web/assets/sequenceDiagram-ZOUHS735-CJC73bV-.js +157 -0
  65. package/dist/web/assets/stateDiagram-MLPALWAM-BCFyESls.js +1 -0
  66. package/dist/web/assets/stateDiagram-v2-B5LQ5ZB2-DahzzIca.js +1 -0
  67. package/dist/web/assets/timeline-definition-5SPVSISX-TRSDRgPw.js +120 -0
  68. package/dist/web/assets/vennDiagram-IE5QUKF5-DNy7HRBM.js +34 -0
  69. package/dist/web/assets/wardley-RL74JXVD-BCRCBASE-B-eZEzf9.js +161 -0
  70. package/dist/web/assets/wardleyDiagram-XU3VSMPF-BP-r1xzR.js +20 -0
  71. package/dist/web/assets/xychartDiagram-ZHJ5623Y-Dr9r7a35.js +7 -0
  72. package/dist/web/codragraph-logo-512.png +0 -0
  73. package/dist/web/codragraph-logo.png +0 -0
  74. package/dist/web/favicon.png +0 -0
  75. package/dist/web/index.html +36 -0
  76. package/hooks/claude/codragraph-hook.cjs +24 -9
  77. package/hooks/claude/pre-tool-use.sh +6 -1
  78. package/package.json +3 -1
  79. package/scripts/build.js +62 -4
  80. package/scripts/patch-tree-sitter-swift.cjs +0 -1
  81. package/skills/codragraph-cli.md +1 -1
  82. package/vendor/leiden/index.cjs +272 -285
  83. package/vendor/leiden/utils.cjs +264 -274
  84. package/dist/_shared/lbug/schema-constants.d.ts +0 -16
  85. package/dist/_shared/lbug/schema-constants.d.ts.map +0 -1
  86. package/dist/_shared/lbug/schema-constants.js +0 -67
  87. package/dist/_shared/lbug/schema-constants.js.map +0 -1
  88. package/dist/core/graphstore/lbug-row-source.d.ts +0 -19
  89. package/dist/core/graphstore/lbug-row-source.js +0 -141
  90. package/dist/core/lbug/content-read.d.ts +0 -46
  91. package/dist/core/lbug/content-read.js +0 -64
  92. package/dist/core/lbug/csv-generator.d.ts +0 -29
  93. package/dist/core/lbug/csv-generator.js +0 -492
  94. package/dist/core/lbug/lbug-adapter.d.ts +0 -176
  95. package/dist/core/lbug/lbug-adapter.js +0 -1320
  96. package/dist/core/lbug/pool-adapter.d.ts +0 -93
  97. package/dist/core/lbug/pool-adapter.js +0 -550
  98. package/dist/core/lbug/schema.d.ts +0 -62
  99. package/dist/core/lbug/schema.js +0 -502
  100. package/dist/mcp/core/lbug-adapter.d.ts +0 -5
  101. package/dist/mcp/core/lbug-adapter.js +0 -5
@@ -29,210 +29,199 @@ var UndirectedLouvainIndex = indices.UndirectedLouvainIndex;
29
29
  var UndirectedLeidenAddenda = utils.UndirectedLeidenAddenda;
30
30
 
31
31
  var DEFAULTS = {
32
- attributes: {
33
- community: 'community',
34
- weight: 'weight'
35
- },
36
- randomness: 0.01,
37
- randomWalk: true,
38
- resolution: 1,
39
- rng: Math.random,
40
- weighted: false
32
+ attributes: {
33
+ community: 'community',
34
+ weight: 'weight',
35
+ },
36
+ randomness: 0.01,
37
+ randomWalk: true,
38
+ resolution: 1,
39
+ rng: Math.random,
40
+ weighted: false,
41
41
  };
42
42
 
43
43
  var EPSILON = 1e-10;
44
44
 
45
- function tieBreaker(
46
- bestCommunity,
47
- currentCommunity,
48
- targetCommunity,
49
- delta,
50
- bestDelta
51
- ) {
52
- if (Math.abs(delta - bestDelta) < EPSILON) {
53
- if (bestCommunity === currentCommunity) {
54
- return false;
55
- } else {
56
- return targetCommunity > bestCommunity;
57
- }
58
- } else if (delta > bestDelta) {
59
- return true;
60
- }
61
-
62
- return false;
45
+ function tieBreaker(bestCommunity, currentCommunity, targetCommunity, delta, bestDelta) {
46
+ if (Math.abs(delta - bestDelta) < EPSILON) {
47
+ if (bestCommunity === currentCommunity) {
48
+ return false;
49
+ } else {
50
+ return targetCommunity > bestCommunity;
51
+ }
52
+ } else if (delta > bestDelta) {
53
+ return true;
54
+ }
55
+
56
+ return false;
63
57
  }
64
58
 
65
59
  function undirectedLeiden(detailed, graph, options) {
66
- var index = new UndirectedLouvainIndex(graph, {
67
- attributes: {
68
- weight: options.attributes.weight
69
- },
70
- keepDendrogram: detailed,
71
- resolution: options.resolution,
72
- weighted: options.weighted
73
- });
74
-
75
- var addenda = new UndirectedLeidenAddenda(index, {
76
- randomness: options.randomness,
77
- rng: options.rng
78
- });
79
-
80
- var randomIndex = createRandomIndex(options.rng);
81
-
82
- // Communities
83
- var currentCommunity, targetCommunity;
84
- var communities = new SparseMap(Float64Array, index.C);
85
-
86
- // Traversal
87
- var queue = new SparseQueueSet(index.C),
88
- start,
89
- end,
90
- weight,
91
- ci,
92
- ri,
93
- s,
94
- i,
95
- j,
96
- l;
97
-
98
- // Metrics
99
- var degree, targetCommunityDegree;
100
-
101
- // Moves
102
- var bestCommunity, bestDelta, deltaIsBetter, delta;
103
-
104
- // Details
105
- var deltaComputations = 0,
106
- nodesVisited = 0,
107
- moves = [],
108
- currentMoves;
109
-
110
- while (true) {
111
- l = index.C;
112
-
113
- currentMoves = 0;
114
-
115
- // Traversal of the graph
116
- ri = options.randomWalk ? randomIndex(l) : 0;
117
-
118
- for (s = 0; s < l; s++, ri++) {
119
- i = ri % l;
120
- queue.enqueue(i);
121
- }
122
-
123
- while (queue.size !== 0) {
124
- i = queue.dequeue();
125
- nodesVisited++;
126
-
127
- degree = 0;
128
- communities.clear();
129
-
130
- currentCommunity = index.belongings[i];
131
-
132
- start = index.starts[i];
133
- end = index.starts[i + 1];
134
-
135
- // Traversing neighbors
136
- for (; start < end; start++) {
137
- j = index.neighborhood[start];
138
- weight = index.weights[start];
139
-
140
- targetCommunity = index.belongings[j];
141
-
142
- // Incrementing metrics
143
- degree += weight;
144
- addWeightToCommunity(communities, targetCommunity, weight);
145
- }
146
-
147
- // Finding best community to move to
148
- bestDelta = index.fastDeltaWithOwnCommunity(
149
- i,
150
- degree,
151
- communities.get(currentCommunity) || 0,
152
- currentCommunity
153
- );
154
- bestCommunity = currentCommunity;
155
-
156
- for (ci = 0; ci < communities.size; ci++) {
157
- targetCommunity = communities.dense[ci];
158
-
159
- if (targetCommunity === currentCommunity) continue;
160
-
161
- targetCommunityDegree = communities.vals[ci];
162
-
163
- deltaComputations++;
164
-
165
- delta = index.fastDelta(
166
- i,
167
- degree,
168
- targetCommunityDegree,
169
- targetCommunity
170
- );
171
-
172
- deltaIsBetter = tieBreaker(
173
- bestCommunity,
174
- currentCommunity,
175
- targetCommunity,
176
- delta,
177
- bestDelta
178
- );
179
-
180
- if (deltaIsBetter) {
181
- bestDelta = delta;
182
- bestCommunity = targetCommunity;
183
- }
184
- }
185
-
186
- if (bestDelta < 0) {
187
- bestCommunity = index.isolate(i, degree);
188
-
189
- if (bestCommunity === currentCommunity) continue;
190
- } else {
191
- if (bestCommunity === currentCommunity) {
192
- continue;
193
- } else {
194
- index.move(i, degree, bestCommunity);
195
- }
196
- }
60
+ var index = new UndirectedLouvainIndex(graph, {
61
+ attributes: {
62
+ weight: options.attributes.weight,
63
+ },
64
+ keepDendrogram: detailed,
65
+ resolution: options.resolution,
66
+ weighted: options.weighted,
67
+ });
68
+
69
+ var addenda = new UndirectedLeidenAddenda(index, {
70
+ randomness: options.randomness,
71
+ rng: options.rng,
72
+ });
73
+
74
+ var randomIndex = createRandomIndex(options.rng);
75
+
76
+ // Communities
77
+ var currentCommunity, targetCommunity;
78
+ var communities = new SparseMap(Float64Array, index.C);
79
+
80
+ // Traversal
81
+ var queue = new SparseQueueSet(index.C),
82
+ start,
83
+ end,
84
+ weight,
85
+ ci,
86
+ ri,
87
+ s,
88
+ i,
89
+ j,
90
+ l;
91
+
92
+ // Metrics
93
+ var degree, targetCommunityDegree;
94
+
95
+ // Moves
96
+ var bestCommunity, bestDelta, deltaIsBetter, delta;
97
+
98
+ // Details
99
+ var deltaComputations = 0,
100
+ nodesVisited = 0,
101
+ moves = [],
102
+ currentMoves;
103
+
104
+ while (true) {
105
+ l = index.C;
106
+
107
+ currentMoves = 0;
108
+
109
+ // Traversal of the graph
110
+ ri = options.randomWalk ? randomIndex(l) : 0;
111
+
112
+ for (s = 0; s < l; s++, ri++) {
113
+ i = ri % l;
114
+ queue.enqueue(i);
115
+ }
116
+
117
+ while (queue.size !== 0) {
118
+ i = queue.dequeue();
119
+ nodesVisited++;
120
+
121
+ degree = 0;
122
+ communities.clear();
123
+
124
+ currentCommunity = index.belongings[i];
125
+
126
+ start = index.starts[i];
127
+ end = index.starts[i + 1];
128
+
129
+ // Traversing neighbors
130
+ for (; start < end; start++) {
131
+ j = index.neighborhood[start];
132
+ weight = index.weights[start];
133
+
134
+ targetCommunity = index.belongings[j];
135
+
136
+ // Incrementing metrics
137
+ degree += weight;
138
+ addWeightToCommunity(communities, targetCommunity, weight);
139
+ }
140
+
141
+ // Finding best community to move to
142
+ bestDelta = index.fastDeltaWithOwnCommunity(
143
+ i,
144
+ degree,
145
+ communities.get(currentCommunity) || 0,
146
+ currentCommunity,
147
+ );
148
+ bestCommunity = currentCommunity;
149
+
150
+ for (ci = 0; ci < communities.size; ci++) {
151
+ targetCommunity = communities.dense[ci];
152
+
153
+ if (targetCommunity === currentCommunity) continue;
154
+
155
+ targetCommunityDegree = communities.vals[ci];
156
+
157
+ deltaComputations++;
158
+
159
+ delta = index.fastDelta(i, degree, targetCommunityDegree, targetCommunity);
160
+
161
+ deltaIsBetter = tieBreaker(
162
+ bestCommunity,
163
+ currentCommunity,
164
+ targetCommunity,
165
+ delta,
166
+ bestDelta,
167
+ );
168
+
169
+ if (deltaIsBetter) {
170
+ bestDelta = delta;
171
+ bestCommunity = targetCommunity;
172
+ }
173
+ }
174
+
175
+ if (bestDelta < 0) {
176
+ bestCommunity = index.isolate(i, degree);
177
+
178
+ if (bestCommunity === currentCommunity) continue;
179
+ } else {
180
+ if (bestCommunity === currentCommunity) {
181
+ continue;
182
+ } else {
183
+ index.move(i, degree, bestCommunity);
184
+ }
185
+ }
197
186
 
198
- currentMoves++;
199
-
200
- // Adding neighbors from other communities to the queue
201
- start = index.starts[i];
202
- end = index.starts[i + 1];
203
-
204
- for (; start < end; start++) {
205
- j = index.neighborhood[start];
206
- targetCommunity = index.belongings[j];
207
-
208
- if (targetCommunity !== bestCommunity) queue.enqueue(j);
209
- }
210
- }
211
-
212
- moves.push(currentMoves);
213
-
214
- if (currentMoves === 0) {
215
- index.zoomOut();
216
- break;
217
- }
218
-
219
- if (!addenda.onlySingletons()) {
220
- // We continue working on the induced graph
221
- addenda.zoomOut();
222
- continue;
223
- }
224
-
225
- break;
226
- }
227
-
228
- var results = {
229
- index: index,
230
- deltaComputations: deltaComputations,
231
- nodesVisited: nodesVisited,
232
- moves: moves
233
- };
234
-
235
- return results;
187
+ currentMoves++;
188
+
189
+ // Adding neighbors from other communities to the queue
190
+ start = index.starts[i];
191
+ end = index.starts[i + 1];
192
+
193
+ for (; start < end; start++) {
194
+ j = index.neighborhood[start];
195
+ targetCommunity = index.belongings[j];
196
+
197
+ if (targetCommunity !== bestCommunity) queue.enqueue(j);
198
+ }
199
+ }
200
+
201
+ moves.push(currentMoves);
202
+
203
+ if (currentMoves === 0) {
204
+ index.zoomOut();
205
+ break;
206
+ }
207
+
208
+ if (!addenda.onlySingletons()) {
209
+ // We continue working on the induced graph
210
+ addenda.zoomOut();
211
+ continue;
212
+ }
213
+
214
+ break;
215
+ }
216
+
217
+ var results = {
218
+ index: index,
219
+ deltaComputations: deltaComputations,
220
+ nodesVisited: nodesVisited,
221
+ moves: moves,
222
+ };
223
+
224
+ return results;
236
225
  }
237
226
 
238
227
  /**
@@ -253,95 +242,93 @@ function undirectedLeiden(detailed, graph, options) {
253
242
  * @return {object}
254
243
  */
255
244
  function leiden(assign, detailed, graph, options) {
256
- if (!isGraph(graph))
257
- throw new Error(
258
- 'graphology-communities-leiden: the given graph is not a valid graphology instance.'
259
- );
260
-
261
- var type = inferType(graph);
262
-
263
- if (type === 'mixed')
264
- throw new Error(
265
- 'graphology-communities-leiden: cannot run the algorithm on a true mixed graph.'
266
- );
267
-
268
- if (type === 'directed')
269
- throw new Error(
270
- 'graphology-communities-leiden: not yet implemented for directed graphs.'
271
- );
272
-
273
- // Attributes name
274
- options = resolveDefaults(options, DEFAULTS);
275
-
276
- // Empty graph case
277
- var c = 0;
278
-
279
- if (graph.size === 0) {
280
- if (assign) {
281
- graph.forEachNode(function (node) {
282
- graph.setNodeAttribute(node, options.attributes.communities, c++);
283
- });
284
-
285
- return;
286
- }
287
-
288
- var communities = {};
289
-
290
- graph.forEachNode(function (node) {
291
- communities[node] = c++;
292
- });
293
-
294
- if (!detailed) return communities;
295
-
296
- return {
297
- communities: communities,
298
- count: graph.order,
299
- deltaComputations: 0,
300
- dendrogram: null,
301
- level: 0,
302
- modularity: NaN,
303
- moves: null,
304
- nodesVisited: 0,
305
- resolution: options.resolution
306
- };
307
- }
308
-
309
- var fn = undirectedLeiden;
310
-
311
- var results = fn(detailed, graph, options);
312
-
313
- var index = results.index;
314
-
315
- // Standard output
316
- if (!detailed) {
317
- if (assign) {
318
- index.assign(options.attributes.community);
319
- return;
320
- }
321
-
322
- return index.collect();
323
- }
324
-
325
- // Detailed output
326
- var output = {
327
- count: index.C,
328
- deltaComputations: results.deltaComputations,
329
- dendrogram: index.dendrogram,
330
- level: index.level,
331
- modularity: index.modularity(),
332
- moves: results.moves,
333
- nodesVisited: results.nodesVisited,
334
- resolution: options.resolution
335
- };
336
-
337
- if (assign) {
338
- index.assign(options.attributes.community);
339
- return output;
340
- }
341
-
342
- output.communities = index.collect();
343
-
344
- return output;
245
+ if (!isGraph(graph))
246
+ throw new Error(
247
+ 'graphology-communities-leiden: the given graph is not a valid graphology instance.',
248
+ );
249
+
250
+ var type = inferType(graph);
251
+
252
+ if (type === 'mixed')
253
+ throw new Error(
254
+ 'graphology-communities-leiden: cannot run the algorithm on a true mixed graph.',
255
+ );
256
+
257
+ if (type === 'directed')
258
+ throw new Error('graphology-communities-leiden: not yet implemented for directed graphs.');
259
+
260
+ // Attributes name
261
+ options = resolveDefaults(options, DEFAULTS);
262
+
263
+ // Empty graph case
264
+ var c = 0;
265
+
266
+ if (graph.size === 0) {
267
+ if (assign) {
268
+ graph.forEachNode(function (node) {
269
+ graph.setNodeAttribute(node, options.attributes.communities, c++);
270
+ });
271
+
272
+ return;
273
+ }
274
+
275
+ var communities = {};
276
+
277
+ graph.forEachNode(function (node) {
278
+ communities[node] = c++;
279
+ });
280
+
281
+ if (!detailed) return communities;
282
+
283
+ return {
284
+ communities: communities,
285
+ count: graph.order,
286
+ deltaComputations: 0,
287
+ dendrogram: null,
288
+ level: 0,
289
+ modularity: NaN,
290
+ moves: null,
291
+ nodesVisited: 0,
292
+ resolution: options.resolution,
293
+ };
294
+ }
295
+
296
+ var fn = undirectedLeiden;
297
+
298
+ var results = fn(detailed, graph, options);
299
+
300
+ var index = results.index;
301
+
302
+ // Standard output
303
+ if (!detailed) {
304
+ if (assign) {
305
+ index.assign(options.attributes.community);
306
+ return;
307
+ }
308
+
309
+ return index.collect();
310
+ }
311
+
312
+ // Detailed output
313
+ var output = {
314
+ count: index.C,
315
+ deltaComputations: results.deltaComputations,
316
+ dendrogram: index.dendrogram,
317
+ level: index.level,
318
+ modularity: index.modularity(),
319
+ moves: results.moves,
320
+ nodesVisited: results.nodesVisited,
321
+ resolution: options.resolution,
322
+ };
323
+
324
+ if (assign) {
325
+ index.assign(options.attributes.community);
326
+ return output;
327
+ }
328
+
329
+ output.communities = index.collect();
330
+
331
+ return output;
345
332
  }
346
333
 
347
334
  /**