@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.
Files changed (112) hide show
  1. package/README.md +36 -9
  2. package/dist/cli/ai-context.js +298 -1
  3. package/dist/cli/analyze.js +19 -2
  4. package/dist/cli/index.js +33 -12
  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/cli/tool.js +73 -33
  11. package/dist/config/ignore-service.js +3 -0
  12. package/dist/core/cgdb/pool-adapter.js +130 -20
  13. package/dist/core/graphstore/cgdb-row-source.js +3 -2
  14. package/dist/core/group/bridge-db.js +42 -10
  15. package/dist/core/ingestion/parsing-processor.js +7 -1
  16. package/dist/core/ingestion/pipeline-phases/parse-impl.js +4 -0
  17. package/dist/core/ingestion/workers/parse-worker.js +1 -1
  18. package/dist/core/ingestion/workers/worker-pool.d.ts +14 -1
  19. package/dist/core/ingestion/workers/worker-pool.js +33 -17
  20. package/dist/core/run-analyze.d.ts +20 -0
  21. package/dist/core/run-analyze.js +225 -1
  22. package/dist/core/search/bm25-index.d.ts +0 -11
  23. package/dist/core/search/bm25-index.js +7 -84
  24. package/dist/core/search/hybrid-search.js +11 -3
  25. package/dist/mcp/local/local-backend.d.ts +2 -0
  26. package/dist/mcp/local/local-backend.js +235 -18
  27. package/dist/mcp/resources.js +2 -2
  28. package/dist/server/api.d.ts +14 -2
  29. package/dist/server/api.js +90 -7
  30. package/dist/server/mcp-http.d.ts +22 -0
  31. package/dist/server/mcp-http.js +21 -2
  32. package/dist/server/web-dashboard.d.ts +28 -0
  33. package/dist/server/web-dashboard.js +61 -0
  34. package/dist/web/assets/agent-D5lb0zXz.js +1089 -0
  35. package/dist/web/assets/architectureDiagram-EMZXCZ2Q-CZtc99v_.js +36 -0
  36. package/dist/web/assets/blockDiagram-IGV67L2C-BtoUp-6Y.js +132 -0
  37. package/dist/web/assets/c4Diagram-DFAF54RM-C4Hl3J2U.js +10 -0
  38. package/dist/web/assets/chunk-3GS5O3IE-DkUjU0WD.js +231 -0
  39. package/dist/web/assets/chunk-3YCYZ6SJ-CQkVgT_z.js +1 -0
  40. package/dist/web/assets/chunk-7RZVMHOQ-BitYcNVR.js +338 -0
  41. package/dist/web/assets/chunk-AEOMTBSW-BgTIXPsY.js +1 -0
  42. package/dist/web/assets/chunk-H3VCZNTA-Cx5XV_aC.js +13 -0
  43. package/dist/web/assets/chunk-HN6EAY2L-BBnyTNdB.js +1 -0
  44. package/dist/web/assets/chunk-KSICW3F5-BYzvDLNI.js +15 -0
  45. package/dist/web/assets/chunk-O5ABG6QK-dHwHzA6n.js +1 -0
  46. package/dist/web/assets/chunk-PK6DOVAG-CvsEnugt.js +206 -0
  47. package/dist/web/assets/chunk-RWUO3TPN-BgRTY0_k.js +1 -0
  48. package/dist/web/assets/chunk-TBF5ZNIQ-DL5stGM1.js +1 -0
  49. package/dist/web/assets/chunk-TU3PZOEN-RLyvLcv-.js +1 -0
  50. package/dist/web/assets/classDiagram-PPOCWD7C-DTr8QIOf.js +1 -0
  51. package/dist/web/assets/classDiagram-v2-23LJLIIU-DTr8QIOf.js +1 -0
  52. package/dist/web/assets/context-builder-22jU3V56.js +16 -0
  53. package/dist/web/assets/cose-bilkent-PNC4W37J-DVhePRYg.js +1 -0
  54. package/dist/web/assets/dagre-E77IOHMT-Dzx0A6ZU.js +4 -0
  55. package/dist/web/assets/diagram-H7BISOXX-CC9pRew1.js +43 -0
  56. package/dist/web/assets/diagram-JC5VWROH-Bau_i9tf.js +24 -0
  57. package/dist/web/assets/diagram-LXUTUG65-D9_FM2Gt.js +10 -0
  58. package/dist/web/assets/diagram-WEHSV5V5-BMlayouL.js +24 -0
  59. package/dist/web/assets/erDiagram-GCSMX5X6-C3dhDFA8.js +85 -0
  60. package/dist/web/assets/flowDiagram-OTCZ4VVT-CWSFWmhr.js +162 -0
  61. package/dist/web/assets/ganttDiagram-MUNLMDZQ-D3a67Yol.js +292 -0
  62. package/dist/web/assets/gitGraphDiagram-3HKGZ4G3-7jmry-vM.js +106 -0
  63. package/dist/web/assets/index-BgeqpYgd.js +1415 -0
  64. package/dist/web/assets/index-CT0GtFLZ.css +1 -0
  65. package/dist/web/assets/infoDiagram-MN7RKWGX-G7lhP0Ib.js +2 -0
  66. package/dist/web/assets/ishikawaDiagram-YMYX4NHK-DUoJvNP2.js +70 -0
  67. package/dist/web/assets/journeyDiagram-SO5T7YLQ-RMFPNNqz.js +139 -0
  68. package/dist/web/assets/kanban-definition-LJHFXRCJ-BzpDs1K9.js +89 -0
  69. package/dist/web/assets/katex-GD7MH7QM-DBQvrix-.js +261 -0
  70. package/dist/web/assets/mindmap-definition-2EUWGEK5-Bk0O4roa.js +96 -0
  71. package/dist/web/assets/pieDiagram-3IATQBI2-DKU7kpgS.js +30 -0
  72. package/dist/web/assets/quadrantDiagram-E256RVCF-BY0TGWCS.js +7 -0
  73. package/dist/web/assets/requirementDiagram-M5DCFWZL-DLHOVTSv.js +84 -0
  74. package/dist/web/assets/sankeyDiagram-L3NBLAOT-DVMj5rX2.js +10 -0
  75. package/dist/web/assets/sequenceDiagram-ZOUHS735-CJC73bV-.js +157 -0
  76. package/dist/web/assets/stateDiagram-MLPALWAM-BCFyESls.js +1 -0
  77. package/dist/web/assets/stateDiagram-v2-B5LQ5ZB2-DahzzIca.js +1 -0
  78. package/dist/web/assets/timeline-definition-5SPVSISX-TRSDRgPw.js +120 -0
  79. package/dist/web/assets/vennDiagram-IE5QUKF5-DNy7HRBM.js +34 -0
  80. package/dist/web/assets/wardley-RL74JXVD-BCRCBASE-B-eZEzf9.js +161 -0
  81. package/dist/web/assets/wardleyDiagram-XU3VSMPF-BP-r1xzR.js +20 -0
  82. package/dist/web/assets/xychartDiagram-ZHJ5623Y-Dr9r7a35.js +7 -0
  83. package/dist/web/codragraph-logo-512.png +0 -0
  84. package/dist/web/codragraph-logo.png +0 -0
  85. package/dist/web/favicon.png +0 -0
  86. package/dist/web/index.html +36 -0
  87. package/hooks/claude/codragraph-hook.cjs +18 -110
  88. package/hooks/claude/pre-tool-use.sh +6 -1
  89. package/package.json +3 -1
  90. package/scripts/build.js +62 -4
  91. package/scripts/patch-tree-sitter-swift.cjs +0 -1
  92. package/skills/codragraph-cli.md +1 -1
  93. package/vendor/leiden/index.cjs +272 -285
  94. package/vendor/leiden/utils.cjs +264 -274
  95. package/dist/_shared/lbug/schema-constants.d.ts +0 -16
  96. package/dist/_shared/lbug/schema-constants.d.ts.map +0 -1
  97. package/dist/_shared/lbug/schema-constants.js +0 -67
  98. package/dist/_shared/lbug/schema-constants.js.map +0 -1
  99. package/dist/core/graphstore/lbug-row-source.d.ts +0 -19
  100. package/dist/core/graphstore/lbug-row-source.js +0 -141
  101. package/dist/core/lbug/content-read.d.ts +0 -46
  102. package/dist/core/lbug/content-read.js +0 -64
  103. package/dist/core/lbug/csv-generator.d.ts +0 -29
  104. package/dist/core/lbug/csv-generator.js +0 -492
  105. package/dist/core/lbug/lbug-adapter.d.ts +0 -176
  106. package/dist/core/lbug/lbug-adapter.js +0 -1320
  107. package/dist/core/lbug/pool-adapter.d.ts +0 -93
  108. package/dist/core/lbug/pool-adapter.js +0 -550
  109. package/dist/core/lbug/schema.d.ts +0 -62
  110. package/dist/core/lbug/schema.js +0 -502
  111. package/dist/mcp/core/lbug-adapter.d.ts +0 -5
  112. package/dist/mcp/core/lbug-adapter.js +0 -5
@@ -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
- var currentWeight = map.get(community);
14
+ var currentWeight = map.get(community);
15
15
 
16
- if (typeof currentWeight === 'undefined') currentWeight = 0;
16
+ if (typeof currentWeight === 'undefined') currentWeight = 0;
17
17
 
18
- currentWeight += weight;
18
+ currentWeight += weight;
19
19
 
20
- map.set(community, currentWeight);
20
+ map.set(community, currentWeight);
21
21
  }
22
22
 
23
23
  function UndirectedLeidenAddenda(index, options) {
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;
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
- var index = this.index;
59
+ var index = this.index;
60
60
 
61
- var n, i, c, b, o;
61
+ var n, i, c, b, o;
62
62
 
63
- n = 0;
64
- o = 0;
63
+ n = 0;
64
+ o = 0;
65
65
 
66
- for (i = 0; i < index.C; i++) {
67
- c = index.counts[i];
66
+ for (i = 0; i < index.C; i++) {
67
+ c = index.counts[i];
68
68
 
69
- if (c !== 0) {
70
- this.communitiesBounds[o++] = n;
71
- n += c;
72
- this.communitiesOffsets[i] = n;
73
- }
74
- }
69
+ if (c !== 0) {
70
+ this.communitiesBounds[o++] = n;
71
+ n += c;
72
+ this.communitiesOffsets[i] = n;
73
+ }
74
+ }
75
75
 
76
- this.communitiesBounds[o] = n;
76
+ this.communitiesBounds[o] = n;
77
77
 
78
- o = 0;
78
+ o = 0;
79
79
 
80
- for (i = 0; i < index.C; i++) {
81
- b = index.belongings[i];
82
- o = --this.communitiesOffsets[b];
83
- this.nodesSortedByCommunities[o] = i;
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
- this.B = index.C - index.U;
87
- this.C = index.C;
86
+ this.B = index.C - index.U;
87
+ this.C = index.C;
88
88
  };
89
89
 
90
90
  UndirectedLeidenAddenda.prototype.communities = function () {
91
- var communities = new Array(this.B);
91
+ var communities = new Array(this.B);
92
92
 
93
- var i, j, community, start, stop;
93
+ var i, j, community, start, stop;
94
94
 
95
- for (i = 0; i < this.B; i++) {
96
- start = this.communitiesBounds[i];
97
- stop = this.communitiesBounds[i + 1];
98
- community = [];
95
+ for (i = 0; i < this.B; i++) {
96
+ start = this.communitiesBounds[i];
97
+ stop = this.communitiesBounds[i + 1];
98
+ community = [];
99
99
 
100
- for (j = start; j < stop; j++) {
101
- community.push(j);
102
- }
100
+ for (j = start; j < stop; j++) {
101
+ community.push(j);
102
+ }
103
103
 
104
- communities[i] = community;
105
- }
104
+ communities[i] = community;
105
+ }
106
106
 
107
- return communities;
107
+ return communities;
108
108
  };
109
109
 
110
110
  UndirectedLeidenAddenda.prototype.mergeNodesSubset = function (start, stop) {
111
- var index = this.index;
112
- var currentMacroCommunity =
113
- index.belongings[this.nodesSortedByCommunities[start]];
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
- var totalNodeWeight = 0;
115
+ var totalNodeWeight = 0;
117
116
 
118
- var i, j, w;
119
- var ei, el, et;
117
+ var i, j, w;
118
+ var ei, el, et;
120
119
 
121
- // Initializing singletons
122
- for (j = start; j < stop; j++) {
123
- i = this.nodesSortedByCommunities[j];
120
+ // Initializing singletons
121
+ for (j = start; j < stop; j++) {
122
+ i = this.nodesSortedByCommunities[j];
124
123
 
125
- this.belongings[i] = i;
126
- this.nonSingleton[i] = 0;
127
- this.degrees[i] = 0;
128
- totalNodeWeight += index.loops[i] / 2;
124
+ this.belongings[i] = i;
125
+ this.nonSingleton[i] = 0;
126
+ this.degrees[i] = 0;
127
+ totalNodeWeight += index.loops[i] / 2;
129
128
 
130
- this.communityWeights[i] = index.loops[i];
131
- this.externalEdgeWeightPerCommunity[i] = 0;
129
+ this.communityWeights[i] = index.loops[i];
130
+ this.externalEdgeWeightPerCommunity[i] = 0;
132
131
 
133
- ei = index.starts[i];
134
- el = index.starts[i + 1];
132
+ ei = index.starts[i];
133
+ el = index.starts[i + 1];
135
134
 
136
- for (; ei < el; ei++) {
137
- et = index.neighborhood[ei];
138
- w = index.weights[ei];
135
+ for (; ei < el; ei++) {
136
+ et = index.neighborhood[ei];
137
+ w = index.weights[ei];
139
138
 
140
- this.degrees[i] += w;
139
+ this.degrees[i] += w;
141
140
 
142
- if (index.belongings[et] !== currentMacroCommunity) continue;
141
+ if (index.belongings[et] !== currentMacroCommunity) continue;
143
142
 
144
- totalNodeWeight += w;
145
- this.externalEdgeWeightPerCommunity[i] += w;
146
- this.communityWeights[i] += w;
147
- }
148
- }
143
+ totalNodeWeight += w;
144
+ this.externalEdgeWeightPerCommunity[i] += w;
145
+ this.communityWeights[i] += w;
146
+ }
147
+ }
149
148
 
150
- var microDegrees = this.externalEdgeWeightPerCommunity.slice();
149
+ var microDegrees = this.externalEdgeWeightPerCommunity.slice();
151
150
 
152
- var s, ri, ci;
153
- var order = stop - start;
151
+ var s, ri, ci;
152
+ var order = stop - start;
154
153
 
155
- var degree,
156
- bestCommunity,
157
- qualityValueIncrement,
158
- maxQualityValueIncrement,
159
- totalTransformedQualityValueIncrement,
160
- targetCommunity,
161
- targetCommunityDegree,
162
- targetCommunityWeight;
154
+ var degree,
155
+ bestCommunity,
156
+ qualityValueIncrement,
157
+ maxQualityValueIncrement,
158
+ totalTransformedQualityValueIncrement,
159
+ targetCommunity,
160
+ targetCommunityDegree,
161
+ targetCommunityWeight;
163
162
 
164
- var r, lo, hi, mid, chosenCommunity;
163
+ var r, lo, hi, mid, chosenCommunity;
165
164
 
166
- ri = this.random(start, stop - 1);
165
+ ri = this.random(start, stop - 1);
167
166
 
168
- for (s = start; s < stop; s++, ri++) {
169
- j = start + (ri % order);
167
+ for (s = start; s < stop; s++, ri++) {
168
+ j = start + (ri % order);
170
169
 
171
- i = this.nodesSortedByCommunities[j];
170
+ i = this.nodesSortedByCommunities[j];
172
171
 
173
- if (this.nonSingleton[i] === 1) {
174
- continue;
175
- }
172
+ if (this.nonSingleton[i] === 1) {
173
+ continue;
174
+ }
176
175
 
177
- if (
178
- this.externalEdgeWeightPerCommunity[i] <
179
- this.communityWeights[i] *
180
- (totalNodeWeight / 2 - this.communityWeights[i]) *
181
- this.resolution
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
- this.communityWeights[i] = 0;
187
- this.externalEdgeWeightPerCommunity[i] = 0;
183
+ this.communityWeights[i] = 0;
184
+ this.externalEdgeWeightPerCommunity[i] = 0;
188
185
 
189
- neighboringCommunities.clear();
190
- neighboringCommunities.set(i, 0);
186
+ neighboringCommunities.clear();
187
+ neighboringCommunities.set(i, 0);
191
188
 
192
- degree = 0;
189
+ degree = 0;
193
190
 
194
- ei = index.starts[i];
195
- el = index.starts[i + 1];
191
+ ei = index.starts[i];
192
+ el = index.starts[i + 1];
196
193
 
197
- for (; ei < el; ei++) {
198
- et = index.neighborhood[ei];
194
+ for (; ei < el; ei++) {
195
+ et = index.neighborhood[ei];
199
196
 
200
- if (index.belongings[et] !== currentMacroCommunity) continue;
197
+ if (index.belongings[et] !== currentMacroCommunity) continue;
201
198
 
202
- w = index.weights[ei];
199
+ w = index.weights[ei];
203
200
 
204
- degree += w;
201
+ degree += w;
205
202
 
206
- addWeightToCommunity(neighboringCommunities, this.belongings[et], w);
207
- }
203
+ addWeightToCommunity(neighboringCommunities, this.belongings[et], w);
204
+ }
208
205
 
209
- bestCommunity = i;
210
- maxQualityValueIncrement = 0;
211
- totalTransformedQualityValueIncrement = 0;
206
+ bestCommunity = i;
207
+ maxQualityValueIncrement = 0;
208
+ totalTransformedQualityValueIncrement = 0;
212
209
 
213
- for (ci = 0; ci < neighboringCommunities.size; ci++) {
214
- targetCommunity = neighboringCommunities.dense[ci];
215
- targetCommunityDegree = neighboringCommunities.vals[ci];
216
- targetCommunityWeight = this.communityWeights[targetCommunity];
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
- if (
219
- this.externalEdgeWeightPerCommunity[targetCommunity] >=
220
- targetCommunityWeight *
221
- (totalNodeWeight / 2 - targetCommunityWeight) *
222
- this.resolution
223
- ) {
224
- qualityValueIncrement =
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
- if (qualityValueIncrement > maxQualityValueIncrement) {
232
- bestCommunity = targetCommunity;
233
- maxQualityValueIncrement = qualityValueIncrement;
234
- }
223
+ if (qualityValueIncrement > maxQualityValueIncrement) {
224
+ bestCommunity = targetCommunity;
225
+ maxQualityValueIncrement = qualityValueIncrement;
226
+ }
235
227
 
236
- if (qualityValueIncrement >= 0)
237
- totalTransformedQualityValueIncrement += Math.exp(
238
- qualityValueIncrement / this.randomness
239
- );
240
- }
228
+ if (qualityValueIncrement >= 0)
229
+ totalTransformedQualityValueIncrement += Math.exp(
230
+ qualityValueIncrement / this.randomness,
231
+ );
232
+ }
241
233
 
242
- this.cumulativeIncrement[ci] = totalTransformedQualityValueIncrement;
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
- chosenCommunity = neighboringCommunities.dense[hi];
261
- } else {
262
- chosenCommunity = bestCommunity;
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
- this.communityWeights[chosenCommunity] += degree + index.loops[i];
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
- if (chosenCommunity !== i) {
287
- this.belongings[i] = chosenCommunity;
288
- this.nonSingleton[chosenCommunity] = 1;
289
- this.C--;
290
- }
291
- }
292
-
293
- var microCommunities = this.neighboringCommunities;
294
- microCommunities.clear();
295
-
296
- for (j = start; j < stop; j++) {
297
- i = this.nodesSortedByCommunities[j];
298
- microCommunities.set(this.belongings[i], 1);
299
- }
300
-
301
- return microCommunities.dense.slice(0, microCommunities.size);
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
- this.groupByCommunities();
295
+ this.groupByCommunities();
306
296
 
307
- this.macroCommunities = new Array(this.B);
297
+ this.macroCommunities = new Array(this.B);
308
298
 
309
- var i, start, stop, mapping;
299
+ var i, start, stop, mapping;
310
300
 
311
- var bounds = this.communitiesBounds;
301
+ var bounds = this.communitiesBounds;
312
302
 
313
- for (i = 0; i < this.B; i++) {
314
- start = bounds[i];
315
- stop = bounds[i + 1];
303
+ for (i = 0; i < this.B; i++) {
304
+ start = bounds[i];
305
+ stop = bounds[i + 1];
316
306
 
317
- mapping = this.mergeNodesSubset(start, stop);
318
- this.macroCommunities[i] = mapping;
319
- }
307
+ mapping = this.mergeNodesSubset(start, stop);
308
+ this.macroCommunities[i] = mapping;
309
+ }
320
310
  };
321
311
 
322
312
  UndirectedLeidenAddenda.prototype.split = function () {
323
- var index = this.index;
324
- var isolates = this.neighboringCommunities;
313
+ var index = this.index;
314
+ var isolates = this.neighboringCommunities;
325
315
 
326
- isolates.clear();
316
+ isolates.clear();
327
317
 
328
- var i, community, isolated;
318
+ var i, community, isolated;
329
319
 
330
- for (i = 0; i < index.C; i++) {
331
- community = this.belongings[i];
320
+ for (i = 0; i < index.C; i++) {
321
+ community = this.belongings[i];
332
322
 
333
- if (i !== community) continue;
323
+ if (i !== community) continue;
334
324
 
335
- isolated = index.isolate(i, this.degrees[i]);
336
- isolates.set(community, isolated);
337
- }
325
+ isolated = index.isolate(i, this.degrees[i]);
326
+ isolates.set(community, isolated);
327
+ }
338
328
 
339
- for (i = 0; i < index.C; i++) {
340
- community = this.belongings[i];
329
+ for (i = 0; i < index.C; i++) {
330
+ community = this.belongings[i];
341
331
 
342
- if (i === community) continue;
332
+ if (i === community) continue;
343
333
 
344
- isolated = isolates.get(community);
345
- index.move(i, this.degrees[i], isolated);
346
- }
334
+ isolated = isolates.get(community);
335
+ index.move(i, this.degrees[i], isolated);
336
+ }
347
337
 
348
- var j, macro;
338
+ var j, macro;
349
339
 
350
- for (i = 0; i < this.macroCommunities.length; i++) {
351
- macro = this.macroCommunities[i];
340
+ for (i = 0; i < this.macroCommunities.length; i++) {
341
+ macro = this.macroCommunities[i];
352
342
 
353
- for (j = 0; j < macro.length; j++) macro[j] = isolates.get(macro[j]);
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
- var index = this.index;
359
- this.refinePartition();
360
- this.split();
348
+ var index = this.index;
349
+ this.refinePartition();
350
+ this.split();
361
351
 
362
- var newLabels = index.zoomOut();
352
+ var newLabels = index.zoomOut();
363
353
 
364
- var macro, leader, follower;
354
+ var macro, leader, follower;
365
355
 
366
- var i, j;
356
+ var i, j;
367
357
 
368
- for (i = 0; i < this.macroCommunities.length; i++) {
369
- macro = this.macroCommunities[i];
370
- leader = newLabels[macro[0]];
358
+ for (i = 0; i < this.macroCommunities.length; i++) {
359
+ macro = this.macroCommunities[i];
360
+ leader = newLabels[macro[0]];
371
361
 
372
- for (j = 1; j < macro.length; j++) {
373
- follower = newLabels[macro[j]];
374
- index.expensiveMove(follower, leader);
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
- var index = this.index;
370
+ var index = this.index;
381
371
 
382
- var i;
372
+ var i;
383
373
 
384
- for (i = 0; i < index.C; i++) {
385
- if (index.counts[i] > 1) return false;
386
- }
374
+ for (i = 0; i < index.C; i++) {
375
+ if (index.counts[i] > 1) return false;
376
+ }
387
377
 
388
- return true;
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"}