@codragraph/cli 2.1.1 → 2.1.5
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 +36 -9
- package/dist/cli/ai-context.js +298 -1
- package/dist/cli/analyze.js +19 -2
- package/dist/cli/index.js +33 -12
- package/dist/cli/serve.d.ts +1 -0
- package/dist/cli/serve.js +3 -1
- package/dist/cli/setup.js +36 -19
- package/dist/cli/status.d.ts +13 -0
- package/dist/cli/status.js +99 -0
- package/dist/cli/tool.js +73 -33
- package/dist/config/ignore-service.js +3 -0
- package/dist/core/cgdb/pool-adapter.js +130 -20
- package/dist/core/graphstore/cgdb-row-source.js +3 -2
- package/dist/core/group/bridge-db.js +42 -10
- package/dist/core/ingestion/parsing-processor.js +7 -1
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +4 -0
- package/dist/core/ingestion/workers/parse-worker.js +1 -1
- package/dist/core/ingestion/workers/worker-pool.d.ts +14 -1
- package/dist/core/ingestion/workers/worker-pool.js +33 -17
- package/dist/core/run-analyze.d.ts +20 -0
- package/dist/core/run-analyze.js +225 -1
- package/dist/core/search/bm25-index.d.ts +0 -11
- package/dist/core/search/bm25-index.js +7 -84
- package/dist/core/search/hybrid-search.js +11 -3
- package/dist/mcp/local/local-backend.d.ts +2 -0
- package/dist/mcp/local/local-backend.js +235 -18
- package/dist/mcp/resources.js +2 -2
- package/dist/server/api.d.ts +14 -2
- package/dist/server/api.js +90 -7
- package/dist/server/mcp-http.d.ts +22 -0
- package/dist/server/mcp-http.js +21 -2
- package/dist/server/web-dashboard.d.ts +28 -0
- package/dist/server/web-dashboard.js +61 -0
- package/dist/web/assets/agent-D5lb0zXz.js +1089 -0
- package/dist/web/assets/architectureDiagram-EMZXCZ2Q-CZtc99v_.js +36 -0
- package/dist/web/assets/blockDiagram-IGV67L2C-BtoUp-6Y.js +132 -0
- package/dist/web/assets/c4Diagram-DFAF54RM-C4Hl3J2U.js +10 -0
- package/dist/web/assets/chunk-3GS5O3IE-DkUjU0WD.js +231 -0
- package/dist/web/assets/chunk-3YCYZ6SJ-CQkVgT_z.js +1 -0
- package/dist/web/assets/chunk-7RZVMHOQ-BitYcNVR.js +338 -0
- package/dist/web/assets/chunk-AEOMTBSW-BgTIXPsY.js +1 -0
- package/dist/web/assets/chunk-H3VCZNTA-Cx5XV_aC.js +13 -0
- package/dist/web/assets/chunk-HN6EAY2L-BBnyTNdB.js +1 -0
- package/dist/web/assets/chunk-KSICW3F5-BYzvDLNI.js +15 -0
- package/dist/web/assets/chunk-O5ABG6QK-dHwHzA6n.js +1 -0
- package/dist/web/assets/chunk-PK6DOVAG-CvsEnugt.js +206 -0
- package/dist/web/assets/chunk-RWUO3TPN-BgRTY0_k.js +1 -0
- package/dist/web/assets/chunk-TBF5ZNIQ-DL5stGM1.js +1 -0
- package/dist/web/assets/chunk-TU3PZOEN-RLyvLcv-.js +1 -0
- package/dist/web/assets/classDiagram-PPOCWD7C-DTr8QIOf.js +1 -0
- package/dist/web/assets/classDiagram-v2-23LJLIIU-DTr8QIOf.js +1 -0
- package/dist/web/assets/context-builder-22jU3V56.js +16 -0
- package/dist/web/assets/cose-bilkent-PNC4W37J-DVhePRYg.js +1 -0
- package/dist/web/assets/dagre-E77IOHMT-Dzx0A6ZU.js +4 -0
- package/dist/web/assets/diagram-H7BISOXX-CC9pRew1.js +43 -0
- package/dist/web/assets/diagram-JC5VWROH-Bau_i9tf.js +24 -0
- package/dist/web/assets/diagram-LXUTUG65-D9_FM2Gt.js +10 -0
- package/dist/web/assets/diagram-WEHSV5V5-BMlayouL.js +24 -0
- package/dist/web/assets/erDiagram-GCSMX5X6-C3dhDFA8.js +85 -0
- package/dist/web/assets/flowDiagram-OTCZ4VVT-CWSFWmhr.js +162 -0
- package/dist/web/assets/ganttDiagram-MUNLMDZQ-D3a67Yol.js +292 -0
- package/dist/web/assets/gitGraphDiagram-3HKGZ4G3-7jmry-vM.js +106 -0
- package/dist/web/assets/index-BgeqpYgd.js +1415 -0
- package/dist/web/assets/index-CT0GtFLZ.css +1 -0
- package/dist/web/assets/infoDiagram-MN7RKWGX-G7lhP0Ib.js +2 -0
- package/dist/web/assets/ishikawaDiagram-YMYX4NHK-DUoJvNP2.js +70 -0
- package/dist/web/assets/journeyDiagram-SO5T7YLQ-RMFPNNqz.js +139 -0
- package/dist/web/assets/kanban-definition-LJHFXRCJ-BzpDs1K9.js +89 -0
- package/dist/web/assets/katex-GD7MH7QM-DBQvrix-.js +261 -0
- package/dist/web/assets/mindmap-definition-2EUWGEK5-Bk0O4roa.js +96 -0
- package/dist/web/assets/pieDiagram-3IATQBI2-DKU7kpgS.js +30 -0
- package/dist/web/assets/quadrantDiagram-E256RVCF-BY0TGWCS.js +7 -0
- package/dist/web/assets/requirementDiagram-M5DCFWZL-DLHOVTSv.js +84 -0
- package/dist/web/assets/sankeyDiagram-L3NBLAOT-DVMj5rX2.js +10 -0
- package/dist/web/assets/sequenceDiagram-ZOUHS735-CJC73bV-.js +157 -0
- package/dist/web/assets/stateDiagram-MLPALWAM-BCFyESls.js +1 -0
- package/dist/web/assets/stateDiagram-v2-B5LQ5ZB2-DahzzIca.js +1 -0
- package/dist/web/assets/timeline-definition-5SPVSISX-TRSDRgPw.js +120 -0
- package/dist/web/assets/vennDiagram-IE5QUKF5-DNy7HRBM.js +34 -0
- package/dist/web/assets/wardley-RL74JXVD-BCRCBASE-B-eZEzf9.js +161 -0
- package/dist/web/assets/wardleyDiagram-XU3VSMPF-BP-r1xzR.js +20 -0
- package/dist/web/assets/xychartDiagram-ZHJ5623Y-Dr9r7a35.js +7 -0
- package/dist/web/codragraph-logo-512.png +0 -0
- package/dist/web/codragraph-logo.png +0 -0
- package/dist/web/favicon.png +0 -0
- package/dist/web/index.html +36 -0
- package/hooks/claude/codragraph-hook.cjs +18 -110
- package/hooks/claude/pre-tool-use.sh +6 -1
- package/package.json +3 -1
- package/scripts/build.js +62 -4
- package/scripts/patch-tree-sitter-swift.cjs +0 -1
- package/skills/codragraph-cli.md +1 -1
- package/vendor/leiden/index.cjs +272 -285
- package/vendor/leiden/utils.cjs +264 -274
- package/dist/_shared/lbug/schema-constants.d.ts +0 -16
- package/dist/_shared/lbug/schema-constants.d.ts.map +0 -1
- package/dist/_shared/lbug/schema-constants.js +0 -67
- package/dist/_shared/lbug/schema-constants.js.map +0 -1
- package/dist/core/graphstore/lbug-row-source.d.ts +0 -19
- package/dist/core/graphstore/lbug-row-source.js +0 -141
- package/dist/core/lbug/content-read.d.ts +0 -46
- package/dist/core/lbug/content-read.js +0 -64
- package/dist/core/lbug/csv-generator.d.ts +0 -29
- package/dist/core/lbug/csv-generator.js +0 -492
- package/dist/core/lbug/lbug-adapter.d.ts +0 -176
- package/dist/core/lbug/lbug-adapter.js +0 -1320
- package/dist/core/lbug/pool-adapter.d.ts +0 -93
- package/dist/core/lbug/pool-adapter.js +0 -550
- package/dist/core/lbug/schema.d.ts +0 -62
- package/dist/core/lbug/schema.js +0 -502
- package/dist/mcp/core/lbug-adapter.d.ts +0 -5
- package/dist/mcp/core/lbug-adapter.js +0 -5
package/vendor/leiden/utils.cjs
CHANGED
|
@@ -11,381 +11,371 @@ var SparseMap = require('mnemonist/sparse-map');
|
|
|
11
11
|
var createRandom = require('pandemonium/random').createRandom;
|
|
12
12
|
|
|
13
13
|
function addWeightToCommunity(map, community, weight) {
|
|
14
|
-
|
|
14
|
+
var currentWeight = map.get(community);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
if (typeof currentWeight === 'undefined') currentWeight = 0;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
currentWeight += weight;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
map.set(community, currentWeight);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function UndirectedLeidenAddenda(index, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
options = options || {};
|
|
25
|
+
|
|
26
|
+
var rng = options.rng || Math.random;
|
|
27
|
+
var randomness = 'randomness' in options ? options.randomness : 0.01;
|
|
28
|
+
|
|
29
|
+
this.index = index;
|
|
30
|
+
this.random = createRandom(rng);
|
|
31
|
+
this.randomness = randomness;
|
|
32
|
+
this.rng = rng;
|
|
33
|
+
|
|
34
|
+
var NodesPointerArray = index.counts.constructor;
|
|
35
|
+
var WeightsArray = index.weights.constructor;
|
|
36
|
+
|
|
37
|
+
var order = index.C;
|
|
38
|
+
this.resolution = index.resolution;
|
|
39
|
+
|
|
40
|
+
// Used to group nodes by communities
|
|
41
|
+
this.B = index.C;
|
|
42
|
+
this.C = 0;
|
|
43
|
+
this.communitiesOffsets = new NodesPointerArray(order);
|
|
44
|
+
this.nodesSortedByCommunities = new NodesPointerArray(order);
|
|
45
|
+
this.communitiesBounds = new NodesPointerArray(order + 1);
|
|
46
|
+
|
|
47
|
+
// Used to merge nodes subsets
|
|
48
|
+
this.communityWeights = new WeightsArray(order);
|
|
49
|
+
this.degrees = new WeightsArray(order);
|
|
50
|
+
this.nonSingleton = new Uint8Array(order);
|
|
51
|
+
this.externalEdgeWeightPerCommunity = new WeightsArray(order);
|
|
52
|
+
this.belongings = new NodesPointerArray(order);
|
|
53
|
+
this.neighboringCommunities = new SparseMap(WeightsArray, order);
|
|
54
|
+
this.cumulativeIncrement = new Float64Array(order);
|
|
55
|
+
this.macroCommunities = null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
UndirectedLeidenAddenda.prototype.groupByCommunities = function () {
|
|
59
|
-
|
|
59
|
+
var index = this.index;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
var n, i, c, b, o;
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
n = 0;
|
|
64
|
+
o = 0;
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
for (i = 0; i < index.C; i++) {
|
|
67
|
+
c = index.counts[i];
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
if (c !== 0) {
|
|
70
|
+
this.communitiesBounds[o++] = n;
|
|
71
|
+
n += c;
|
|
72
|
+
this.communitiesOffsets[i] = n;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
this.communitiesBounds[o] = n;
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
o = 0;
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
for (i = 0; i < index.C; i++) {
|
|
81
|
+
b = index.belongings[i];
|
|
82
|
+
o = --this.communitiesOffsets[b];
|
|
83
|
+
this.nodesSortedByCommunities[o] = i;
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
this.B = index.C - index.U;
|
|
87
|
+
this.C = index.C;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
UndirectedLeidenAddenda.prototype.communities = function () {
|
|
91
|
-
|
|
91
|
+
var communities = new Array(this.B);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
var i, j, community, start, stop;
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
for (i = 0; i < this.B; i++) {
|
|
96
|
+
start = this.communitiesBounds[i];
|
|
97
|
+
stop = this.communitiesBounds[i + 1];
|
|
98
|
+
community = [];
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
for (j = start; j < stop; j++) {
|
|
101
|
+
community.push(j);
|
|
102
|
+
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
communities[i] = community;
|
|
105
|
+
}
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
return communities;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
UndirectedLeidenAddenda.prototype.mergeNodesSubset = function (start, stop) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var neighboringCommunities = this.neighboringCommunities;
|
|
111
|
+
var index = this.index;
|
|
112
|
+
var currentMacroCommunity = index.belongings[this.nodesSortedByCommunities[start]];
|
|
113
|
+
var neighboringCommunities = this.neighboringCommunities;
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
var totalNodeWeight = 0;
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
var i, j, w;
|
|
118
|
+
var ei, el, et;
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
// Initializing singletons
|
|
121
|
+
for (j = start; j < stop; j++) {
|
|
122
|
+
i = this.nodesSortedByCommunities[j];
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
this.belongings[i] = i;
|
|
125
|
+
this.nonSingleton[i] = 0;
|
|
126
|
+
this.degrees[i] = 0;
|
|
127
|
+
totalNodeWeight += index.loops[i] / 2;
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
this.communityWeights[i] = index.loops[i];
|
|
130
|
+
this.externalEdgeWeightPerCommunity[i] = 0;
|
|
132
131
|
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
ei = index.starts[i];
|
|
133
|
+
el = index.starts[i + 1];
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
for (; ei < el; ei++) {
|
|
136
|
+
et = index.neighborhood[ei];
|
|
137
|
+
w = index.weights[ei];
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
this.degrees[i] += w;
|
|
141
140
|
|
|
142
|
-
|
|
141
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
totalNodeWeight += w;
|
|
144
|
+
this.externalEdgeWeightPerCommunity[i] += w;
|
|
145
|
+
this.communityWeights[i] += w;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
149
148
|
|
|
150
|
-
|
|
149
|
+
var microDegrees = this.externalEdgeWeightPerCommunity.slice();
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
var s, ri, ci;
|
|
152
|
+
var order = stop - start;
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
var degree,
|
|
155
|
+
bestCommunity,
|
|
156
|
+
qualityValueIncrement,
|
|
157
|
+
maxQualityValueIncrement,
|
|
158
|
+
totalTransformedQualityValueIncrement,
|
|
159
|
+
targetCommunity,
|
|
160
|
+
targetCommunityDegree,
|
|
161
|
+
targetCommunityWeight;
|
|
163
162
|
|
|
164
|
-
|
|
163
|
+
var r, lo, hi, mid, chosenCommunity;
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
ri = this.random(start, stop - 1);
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
for (s = start; s < stop; s++, ri++) {
|
|
168
|
+
j = start + (ri % order);
|
|
170
169
|
|
|
171
|
-
|
|
170
|
+
i = this.nodesSortedByCommunities[j];
|
|
172
171
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
if (this.nonSingleton[i] === 1) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.communityWeights[i] *
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
176
|
+
if (
|
|
177
|
+
this.externalEdgeWeightPerCommunity[i] <
|
|
178
|
+
this.communityWeights[i] * (totalNodeWeight / 2 - this.communityWeights[i]) * this.resolution
|
|
179
|
+
) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
this.communityWeights[i] = 0;
|
|
184
|
+
this.externalEdgeWeightPerCommunity[i] = 0;
|
|
188
185
|
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
neighboringCommunities.clear();
|
|
187
|
+
neighboringCommunities.set(i, 0);
|
|
191
188
|
|
|
192
|
-
|
|
189
|
+
degree = 0;
|
|
193
190
|
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
ei = index.starts[i];
|
|
192
|
+
el = index.starts[i + 1];
|
|
196
193
|
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
for (; ei < el; ei++) {
|
|
195
|
+
et = index.neighborhood[ei];
|
|
199
196
|
|
|
200
|
-
|
|
197
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
201
198
|
|
|
202
|
-
|
|
199
|
+
w = index.weights[ei];
|
|
203
200
|
|
|
204
|
-
|
|
201
|
+
degree += w;
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
addWeightToCommunity(neighboringCommunities, this.belongings[et], w);
|
|
204
|
+
}
|
|
208
205
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
bestCommunity = i;
|
|
207
|
+
maxQualityValueIncrement = 0;
|
|
208
|
+
totalTransformedQualityValueIncrement = 0;
|
|
212
209
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
for (ci = 0; ci < neighboringCommunities.size; ci++) {
|
|
211
|
+
targetCommunity = neighboringCommunities.dense[ci];
|
|
212
|
+
targetCommunityDegree = neighboringCommunities.vals[ci];
|
|
213
|
+
targetCommunityWeight = this.communityWeights[targetCommunity];
|
|
217
214
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
targetCommunityWeight *
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
targetCommunityDegree -
|
|
226
|
-
((degree + index.loops[i]) *
|
|
227
|
-
targetCommunityWeight *
|
|
228
|
-
this.resolution) /
|
|
229
|
-
totalNodeWeight;
|
|
215
|
+
if (
|
|
216
|
+
this.externalEdgeWeightPerCommunity[targetCommunity] >=
|
|
217
|
+
targetCommunityWeight * (totalNodeWeight / 2 - targetCommunityWeight) * this.resolution
|
|
218
|
+
) {
|
|
219
|
+
qualityValueIncrement =
|
|
220
|
+
targetCommunityDegree -
|
|
221
|
+
((degree + index.loops[i]) * targetCommunityWeight * this.resolution) / totalNodeWeight;
|
|
230
222
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
223
|
+
if (qualityValueIncrement > maxQualityValueIncrement) {
|
|
224
|
+
bestCommunity = targetCommunity;
|
|
225
|
+
maxQualityValueIncrement = qualityValueIncrement;
|
|
226
|
+
}
|
|
235
227
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
228
|
+
if (qualityValueIncrement >= 0)
|
|
229
|
+
totalTransformedQualityValueIncrement += Math.exp(
|
|
230
|
+
qualityValueIncrement / this.randomness,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
241
233
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
totalTransformedQualityValueIncrement < Number.MAX_VALUE &&
|
|
247
|
-
totalTransformedQualityValueIncrement < Infinity
|
|
248
|
-
) {
|
|
249
|
-
r = totalTransformedQualityValueIncrement * this.rng();
|
|
250
|
-
lo = -1;
|
|
251
|
-
hi = neighboringCommunities.size + 1;
|
|
252
|
-
|
|
253
|
-
while (lo < hi - 1) {
|
|
254
|
-
mid = (lo + hi) >>> 1;
|
|
255
|
-
|
|
256
|
-
if (this.cumulativeIncrement[mid] >= r) hi = mid;
|
|
257
|
-
else lo = mid;
|
|
258
|
-
}
|
|
234
|
+
this.cumulativeIncrement[ci] = totalTransformedQualityValueIncrement;
|
|
235
|
+
}
|
|
259
236
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
237
|
+
if (
|
|
238
|
+
totalTransformedQualityValueIncrement < Number.MAX_VALUE &&
|
|
239
|
+
totalTransformedQualityValueIncrement < Infinity
|
|
240
|
+
) {
|
|
241
|
+
r = totalTransformedQualityValueIncrement * this.rng();
|
|
242
|
+
lo = -1;
|
|
243
|
+
hi = neighboringCommunities.size + 1;
|
|
264
244
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
ei = index.starts[i];
|
|
268
|
-
el = index.starts[i + 1];
|
|
269
|
-
|
|
270
|
-
for (; ei < el; ei++) {
|
|
271
|
-
et = index.neighborhood[ei];
|
|
272
|
-
|
|
273
|
-
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
274
|
-
|
|
275
|
-
targetCommunity = this.belongings[et];
|
|
276
|
-
|
|
277
|
-
if (targetCommunity === chosenCommunity) {
|
|
278
|
-
this.externalEdgeWeightPerCommunity[chosenCommunity] -=
|
|
279
|
-
microDegrees[et];
|
|
280
|
-
} else {
|
|
281
|
-
this.externalEdgeWeightPerCommunity[chosenCommunity] +=
|
|
282
|
-
microDegrees[et];
|
|
283
|
-
}
|
|
284
|
-
}
|
|
245
|
+
while (lo < hi - 1) {
|
|
246
|
+
mid = (lo + hi) >>> 1;
|
|
285
247
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
248
|
+
if (this.cumulativeIncrement[mid] >= r) hi = mid;
|
|
249
|
+
else lo = mid;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
chosenCommunity = neighboringCommunities.dense[hi];
|
|
253
|
+
} else {
|
|
254
|
+
chosenCommunity = bestCommunity;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.communityWeights[chosenCommunity] += degree + index.loops[i];
|
|
258
|
+
|
|
259
|
+
ei = index.starts[i];
|
|
260
|
+
el = index.starts[i + 1];
|
|
261
|
+
|
|
262
|
+
for (; ei < el; ei++) {
|
|
263
|
+
et = index.neighborhood[ei];
|
|
264
|
+
|
|
265
|
+
if (index.belongings[et] !== currentMacroCommunity) continue;
|
|
266
|
+
|
|
267
|
+
targetCommunity = this.belongings[et];
|
|
268
|
+
|
|
269
|
+
if (targetCommunity === chosenCommunity) {
|
|
270
|
+
this.externalEdgeWeightPerCommunity[chosenCommunity] -= microDegrees[et];
|
|
271
|
+
} else {
|
|
272
|
+
this.externalEdgeWeightPerCommunity[chosenCommunity] += microDegrees[et];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (chosenCommunity !== i) {
|
|
277
|
+
this.belongings[i] = chosenCommunity;
|
|
278
|
+
this.nonSingleton[chosenCommunity] = 1;
|
|
279
|
+
this.C--;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
var microCommunities = this.neighboringCommunities;
|
|
284
|
+
microCommunities.clear();
|
|
285
|
+
|
|
286
|
+
for (j = start; j < stop; j++) {
|
|
287
|
+
i = this.nodesSortedByCommunities[j];
|
|
288
|
+
microCommunities.set(this.belongings[i], 1);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return microCommunities.dense.slice(0, microCommunities.size);
|
|
302
292
|
};
|
|
303
293
|
|
|
304
294
|
UndirectedLeidenAddenda.prototype.refinePartition = function () {
|
|
305
|
-
|
|
295
|
+
this.groupByCommunities();
|
|
306
296
|
|
|
307
|
-
|
|
297
|
+
this.macroCommunities = new Array(this.B);
|
|
308
298
|
|
|
309
|
-
|
|
299
|
+
var i, start, stop, mapping;
|
|
310
300
|
|
|
311
|
-
|
|
301
|
+
var bounds = this.communitiesBounds;
|
|
312
302
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
303
|
+
for (i = 0; i < this.B; i++) {
|
|
304
|
+
start = bounds[i];
|
|
305
|
+
stop = bounds[i + 1];
|
|
316
306
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
307
|
+
mapping = this.mergeNodesSubset(start, stop);
|
|
308
|
+
this.macroCommunities[i] = mapping;
|
|
309
|
+
}
|
|
320
310
|
};
|
|
321
311
|
|
|
322
312
|
UndirectedLeidenAddenda.prototype.split = function () {
|
|
323
|
-
|
|
324
|
-
|
|
313
|
+
var index = this.index;
|
|
314
|
+
var isolates = this.neighboringCommunities;
|
|
325
315
|
|
|
326
|
-
|
|
316
|
+
isolates.clear();
|
|
327
317
|
|
|
328
|
-
|
|
318
|
+
var i, community, isolated;
|
|
329
319
|
|
|
330
|
-
|
|
331
|
-
|
|
320
|
+
for (i = 0; i < index.C; i++) {
|
|
321
|
+
community = this.belongings[i];
|
|
332
322
|
|
|
333
|
-
|
|
323
|
+
if (i !== community) continue;
|
|
334
324
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
325
|
+
isolated = index.isolate(i, this.degrees[i]);
|
|
326
|
+
isolates.set(community, isolated);
|
|
327
|
+
}
|
|
338
328
|
|
|
339
|
-
|
|
340
|
-
|
|
329
|
+
for (i = 0; i < index.C; i++) {
|
|
330
|
+
community = this.belongings[i];
|
|
341
331
|
|
|
342
|
-
|
|
332
|
+
if (i === community) continue;
|
|
343
333
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
334
|
+
isolated = isolates.get(community);
|
|
335
|
+
index.move(i, this.degrees[i], isolated);
|
|
336
|
+
}
|
|
347
337
|
|
|
348
|
-
|
|
338
|
+
var j, macro;
|
|
349
339
|
|
|
350
|
-
|
|
351
|
-
|
|
340
|
+
for (i = 0; i < this.macroCommunities.length; i++) {
|
|
341
|
+
macro = this.macroCommunities[i];
|
|
352
342
|
|
|
353
|
-
|
|
354
|
-
|
|
343
|
+
for (j = 0; j < macro.length; j++) macro[j] = isolates.get(macro[j]);
|
|
344
|
+
}
|
|
355
345
|
};
|
|
356
346
|
|
|
357
347
|
UndirectedLeidenAddenda.prototype.zoomOut = function () {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
348
|
+
var index = this.index;
|
|
349
|
+
this.refinePartition();
|
|
350
|
+
this.split();
|
|
361
351
|
|
|
362
|
-
|
|
352
|
+
var newLabels = index.zoomOut();
|
|
363
353
|
|
|
364
|
-
|
|
354
|
+
var macro, leader, follower;
|
|
365
355
|
|
|
366
|
-
|
|
356
|
+
var i, j;
|
|
367
357
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
358
|
+
for (i = 0; i < this.macroCommunities.length; i++) {
|
|
359
|
+
macro = this.macroCommunities[i];
|
|
360
|
+
leader = newLabels[macro[0]];
|
|
371
361
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
362
|
+
for (j = 1; j < macro.length; j++) {
|
|
363
|
+
follower = newLabels[macro[j]];
|
|
364
|
+
index.expensiveMove(follower, leader);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
377
367
|
};
|
|
378
368
|
|
|
379
369
|
UndirectedLeidenAddenda.prototype.onlySingletons = function () {
|
|
380
|
-
|
|
370
|
+
var index = this.index;
|
|
381
371
|
|
|
382
|
-
|
|
372
|
+
var i;
|
|
383
373
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
374
|
+
for (i = 0; i < index.C; i++) {
|
|
375
|
+
if (index.counts[i] > 1) return false;
|
|
376
|
+
}
|
|
387
377
|
|
|
388
|
-
|
|
378
|
+
return true;
|
|
389
379
|
};
|
|
390
380
|
|
|
391
381
|
exports.addWeightToCommunity = addWeightToCommunity;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LadybugDB schema constants — single source of truth.
|
|
3
|
-
*
|
|
4
|
-
* NODE_TABLES and REL_TYPES define what the knowledge graph can contain.
|
|
5
|
-
* Both CLI and web must agree on these for data compatibility.
|
|
6
|
-
*
|
|
7
|
-
* Full DDL schemas remain in each package's own schema.ts because
|
|
8
|
-
* the CLI uses native LadybugDB and the web uses WASM.
|
|
9
|
-
*/
|
|
10
|
-
export declare const NODE_TABLES: readonly ["File", "Folder", "Function", "Class", "Interface", "Method", "CodeElement", "Community", "Process", "Section", "Struct", "Enum", "Macro", "Typedef", "Union", "Namespace", "Trait", "Impl", "TypeAlias", "Const", "Static", "Variable", "Property", "Record", "Delegate", "Annotation", "Constructor", "Template", "Module", "Route", "Tool"];
|
|
11
|
-
export type NodeTableName = (typeof NODE_TABLES)[number];
|
|
12
|
-
export declare const REL_TABLE_NAME = "CodeRelation";
|
|
13
|
-
export declare const REL_TYPES: readonly ["CONTAINS", "DEFINES", "IMPORTS", "CALLS", "EXTENDS", "IMPLEMENTS", "HAS_METHOD", "HAS_PROPERTY", "ACCESSES", "METHOD_OVERRIDES", "OVERRIDES", "METHOD_IMPLEMENTS", "MEMBER_OF", "STEP_IN_PROCESS", "HANDLES_ROUTE", "FETCHES", "HANDLES_TOOL", "ENTRY_POINT_OF", "WRAPS", "QUERIES"];
|
|
14
|
-
export type RelType = (typeof REL_TYPES)[number];
|
|
15
|
-
export declare const EMBEDDING_TABLE_NAME = "CodeEmbedding";
|
|
16
|
-
//# sourceMappingURL=schema-constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-constants.d.ts","sourceRoot":"","sources":["../../src/lbug/schema-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,WAAW,0VAgCd,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C,eAAO,MAAM,SAAS,iSAqBZ,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,eAAO,MAAM,oBAAoB,kBAAkB,CAAC"}
|