@holoscript/core 6.0.4 → 7.0.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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,336 +0,0 @@
1
- 'use strict';
2
-
3
- require('../chunk-3SAK5KFL.cjs');
4
- var crypto = require('crypto');
5
-
6
- var DEFAULT_CONFIG = {
7
- semanticThreshold: 0.92,
8
- numHashFunctions: 128,
9
- numBands: 16,
10
- shingleSize: 3,
11
- qualityWeighted: true
12
- };
13
- var DedupFilter = class {
14
- constructor(config) {
15
- this.config = { ...DEFAULT_CONFIG, ...config };
16
- }
17
- /**
18
- * Run full dedup pipeline on a set of items
19
- */
20
- dedup(items) {
21
- const startTime = Date.now();
22
- const removals = [];
23
- const { unique: exactUnique, removals: exactRemovals } = this.exactDedup(items);
24
- removals.push(...exactRemovals);
25
- const { unique: semanticUnique, removals: semanticRemovals } = this.semanticDedup(exactUnique);
26
- removals.push(...semanticRemovals);
27
- const report = {
28
- totalInput: items.length,
29
- exactDuplicates: exactRemovals.length,
30
- semanticDuplicates: semanticRemovals.length,
31
- retained: semanticUnique.length,
32
- removedDetails: removals,
33
- processingTimeMs: Date.now() - startTime
34
- };
35
- return { retained: semanticUnique, report };
36
- }
37
- /**
38
- * Layer 1: Exact dedup via SHA-256 hash
39
- */
40
- exactDedup(items) {
41
- const hashMap = /* @__PURE__ */ new Map();
42
- const removals = [];
43
- for (const item of items) {
44
- const hash = this.sha256(item.content);
45
- const existing = hashMap.get(hash);
46
- if (existing) {
47
- if (this.config.qualityWeighted && (item.quality ?? 0) > (existing.quality ?? 0)) {
48
- removals.push({ removedId: existing.id, keptId: item.id, reason: "exact" });
49
- hashMap.set(hash, item);
50
- } else {
51
- removals.push({ removedId: item.id, keptId: existing.id, reason: "exact" });
52
- }
53
- } else {
54
- hashMap.set(hash, item);
55
- }
56
- }
57
- return { unique: Array.from(hashMap.values()), removals };
58
- }
59
- /**
60
- * Layer 2: Semantic near-dedup via MinHash LSH (Jaccard similarity)
61
- */
62
- semanticDedup(items) {
63
- if (items.length <= 1) return { unique: items, removals: [] };
64
- const removals = [];
65
- const removed = /* @__PURE__ */ new Set();
66
- const signatures = items.map((item) => ({
67
- item,
68
- shingles: this.shingle(item.content),
69
- minhash: this.minhash(this.shingle(item.content))
70
- }));
71
- const bandSize = Math.floor(this.config.numHashFunctions / this.config.numBands);
72
- const candidatePairs = /* @__PURE__ */ new Set();
73
- for (let band = 0; band < this.config.numBands; band++) {
74
- const buckets = /* @__PURE__ */ new Map();
75
- const start = band * bandSize;
76
- const end = start + bandSize;
77
- for (let i = 0; i < signatures.length; i++) {
78
- const bandHash = signatures[i].minhash.slice(start, end).join(",");
79
- const bucket = buckets.get(bandHash) ?? [];
80
- bucket.push(i);
81
- buckets.set(bandHash, bucket);
82
- }
83
- for (const bucket of buckets.values()) {
84
- for (let i = 0; i < bucket.length; i++) {
85
- for (let j = i + 1; j < bucket.length; j++) {
86
- const key = `${Math.min(bucket[i], bucket[j])},${Math.max(bucket[i], bucket[j])}`;
87
- candidatePairs.add(key);
88
- }
89
- }
90
- }
91
- }
92
- for (const pair of candidatePairs) {
93
- const [iStr, jStr] = pair.split(",");
94
- const i = parseInt(iStr, 10);
95
- const j = parseInt(jStr, 10);
96
- if (removed.has(signatures[i].item.id) || removed.has(signatures[j].item.id)) continue;
97
- const similarity = this.jaccardSimilarity(signatures[i].shingles, signatures[j].shingles);
98
- if (similarity >= this.config.semanticThreshold) {
99
- const itemA = signatures[i].item;
100
- const itemB = signatures[j].item;
101
- if (this.config.qualityWeighted && (itemA.quality ?? 0) >= (itemB.quality ?? 0)) {
102
- removed.add(itemB.id);
103
- removals.push({ removedId: itemB.id, keptId: itemA.id, reason: "semantic", similarity });
104
- } else {
105
- removed.add(itemA.id);
106
- removals.push({ removedId: itemA.id, keptId: itemB.id, reason: "semantic", similarity });
107
- }
108
- }
109
- }
110
- const unique = items.filter((item) => !removed.has(item.id));
111
- return { unique, removals };
112
- }
113
- // ---- Private helpers ----
114
- sha256(content) {
115
- return crypto.createHash("sha256").update(content).digest("hex");
116
- }
117
- shingle(text) {
118
- const shingles = /* @__PURE__ */ new Set();
119
- const words = text.toLowerCase().split(/\s+/);
120
- for (let i = 0; i <= words.length - this.config.shingleSize; i++) {
121
- shingles.add(words.slice(i, i + this.config.shingleSize).join(" "));
122
- }
123
- return shingles;
124
- }
125
- minhash(shingles) {
126
- const signature = new Array(this.config.numHashFunctions).fill(Infinity);
127
- for (const shingle of shingles) {
128
- for (let i = 0; i < this.config.numHashFunctions; i++) {
129
- const hash = this.hashWithSeed(shingle, i);
130
- if (hash < signature[i]) {
131
- signature[i] = hash;
132
- }
133
- }
134
- }
135
- return signature;
136
- }
137
- hashWithSeed(value, seed) {
138
- let hash = 2166136261 ^ seed;
139
- for (let i = 0; i < value.length; i++) {
140
- hash ^= value.charCodeAt(i);
141
- hash = Math.imul(hash, 16777619);
142
- }
143
- return hash >>> 0;
144
- }
145
- jaccardSimilarity(a, b) {
146
- let intersection = 0;
147
- for (const item of a) {
148
- if (b.has(item)) intersection++;
149
- }
150
- const union = a.size + b.size - intersection;
151
- return union === 0 ? 0 : intersection / union;
152
- }
153
- };
154
- function createDedupFilter(config) {
155
- return new DedupFilter(config);
156
- }
157
-
158
- // src/codebase/GodFileDetector.ts
159
- var DEFAULT_THRESHOLDS = {
160
- loc_warning: 500,
161
- loc_god: 1e3,
162
- functions_warning: 20,
163
- functions_god: 40,
164
- complexity_god: 50,
165
- imports_god: 30
166
- };
167
- var GodFileDetector = class {
168
- constructor(thresholds) {
169
- this.thresholds = { ...DEFAULT_THRESHOLDS, ...thresholds };
170
- }
171
- /**
172
- * Analyze a file's content and produce metrics + classification
173
- */
174
- analyze(filePath, content) {
175
- const metrics = this.computeMetrics(filePath, content);
176
- const reasons = [];
177
- let classification = "normal";
178
- if (metrics.loc >= this.thresholds.loc_god) {
179
- reasons.push(`LOC ${metrics.loc} >= ${this.thresholds.loc_god} (god file threshold)`);
180
- classification = "god_file";
181
- } else if (metrics.loc >= this.thresholds.loc_warning) {
182
- reasons.push(`LOC ${metrics.loc} >= ${this.thresholds.loc_warning} (warning threshold)`);
183
- classification = "warning";
184
- }
185
- if (metrics.functionCount >= this.thresholds.functions_god) {
186
- reasons.push(
187
- `Functions ${metrics.functionCount} >= ${this.thresholds.functions_god} (god file threshold)`
188
- );
189
- classification = "god_file";
190
- } else if (metrics.functionCount >= this.thresholds.functions_warning) {
191
- reasons.push(
192
- `Functions ${metrics.functionCount} >= ${this.thresholds.functions_warning} (warning threshold)`
193
- );
194
- if (classification !== "god_file") classification = "warning";
195
- }
196
- if (metrics.cyclomaticComplexity >= this.thresholds.complexity_god) {
197
- reasons.push(
198
- `Cyclomatic complexity ${metrics.cyclomaticComplexity} >= ${this.thresholds.complexity_god}`
199
- );
200
- classification = "god_file";
201
- }
202
- if (metrics.importCount >= this.thresholds.imports_god) {
203
- reasons.push(`Imports ${metrics.importCount} >= ${this.thresholds.imports_god}`);
204
- if (classification !== "god_file") classification = "warning";
205
- }
206
- const report = {
207
- filePath,
208
- classification,
209
- metrics,
210
- reasons
211
- };
212
- if (classification === "god_file") {
213
- report.splitPlan = this.suggestSplit(filePath, content, metrics);
214
- }
215
- return report;
216
- }
217
- /**
218
- * Compute metrics for a file
219
- */
220
- computeMetrics(filePath, content) {
221
- const lines = content.split("\n");
222
- const loc = lines.filter((l) => l.trim().length > 0 && !l.trim().startsWith("//")).length;
223
- const functionPattern = /\b(function\s+\w+|(?:async\s+)?(?:get|set)?\s*\w+\s*\(.*\)\s*(?::\s*\w[\w<>,\s|]*\s*)?{|\w+\s*=\s*(?:async\s+)?(?:\(.*\)|[\w]+)\s*=>)/g;
224
- const functionCount = (content.match(functionPattern) || []).length;
225
- const importPattern = /\bimport\s+(?:type\s+)?(?:{[^}]*}|\*\s+as\s+\w+|\w+)\s+from/g;
226
- const importCount = (content.match(importPattern) || []).length;
227
- const exportPattern = /\bexport\s+(?:default\s+)?(?:class|function|const|let|var|interface|type|enum)/g;
228
- const exportCount = (content.match(exportPattern) || []).length;
229
- const classPattern = /\bclass\s+\w+/g;
230
- const classCount = (content.match(classPattern) || []).length;
231
- const complexityPatterns = /\b(if|else if|for|while|do|switch|case|catch|\?\?|&&|\|\||ternary)\b|\?(?!=)/g;
232
- const cyclomaticComplexity = (content.match(complexityPatterns) || []).length + 1;
233
- return {
234
- filePath,
235
- loc,
236
- functionCount,
237
- importCount,
238
- exportCount,
239
- classCount,
240
- cyclomaticComplexity
241
- };
242
- }
243
- /**
244
- * Suggest a virtual split plan for a god file.
245
- * Only splits at top-level declaration boundaries (G.GAP.05 prevention).
246
- */
247
- suggestSplit(filePath, content, metrics) {
248
- const lines = content.split("\n");
249
- const segments = [];
250
- const baseName = filePath.replace(/\.[^.]+$/, "").split(/[/\\]/).pop() || "module";
251
- let currentStart = 0;
252
- let currentType = "module";
253
- let currentName = "";
254
- let symbolCount = 0;
255
- let braceDepth = 0;
256
- for (let i = 0; i < lines.length; i++) {
257
- const line = lines[i];
258
- const trimmed = line.trim();
259
- for (const ch of line) {
260
- if (ch === "{") braceDepth++;
261
- if (ch === "}") braceDepth--;
262
- }
263
- const classMatch = trimmed.match(/^(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/);
264
- if (classMatch && braceDepth <= 1) {
265
- if (i > currentStart + 5) {
266
- segments.push({
267
- suggestedName: currentName || `${baseName}-segment-${segments.length}`,
268
- startLine: currentStart + 1,
269
- endLine: i,
270
- type: currentType,
271
- symbolCount,
272
- description: `Lines ${currentStart + 1}-${i}`
273
- });
274
- }
275
- currentStart = i;
276
- currentType = "class";
277
- currentName = classMatch[1];
278
- symbolCount = 0;
279
- }
280
- if (trimmed.match(/^(?:export\s+)?(?:const|let|var|function|class|interface|type|enum)\s/)) {
281
- symbolCount++;
282
- }
283
- }
284
- if (currentStart < lines.length - 1) {
285
- segments.push({
286
- suggestedName: currentName || `${baseName}-segment-${segments.length}`,
287
- startLine: currentStart + 1,
288
- endLine: lines.length,
289
- type: currentType,
290
- symbolCount,
291
- description: `Lines ${currentStart + 1}-${lines.length}`
292
- });
293
- }
294
- if (segments.length <= 1) {
295
- return this.splitByFunctionGroups(filePath, content, metrics, baseName);
296
- }
297
- return {
298
- originalPath: filePath,
299
- segments,
300
- totalSegments: segments.length
301
- };
302
- }
303
- splitByFunctionGroups(filePath, content, _metrics, baseName) {
304
- const lines = content.split("\n");
305
- const segmentSize = Math.ceil(lines.length / 3);
306
- const segments = [];
307
- for (let i = 0; i < 3; i++) {
308
- const start = i * segmentSize;
309
- const end = Math.min((i + 1) * segmentSize, lines.length);
310
- if (start >= lines.length) break;
311
- segments.push({
312
- suggestedName: `${baseName}-part-${i + 1}`,
313
- startLine: start + 1,
314
- endLine: end,
315
- type: "function-group",
316
- symbolCount: 0,
317
- description: `Lines ${start + 1}-${end}`
318
- });
319
- }
320
- return {
321
- originalPath: filePath,
322
- segments,
323
- totalSegments: segments.length
324
- };
325
- }
326
- };
327
- function createGodFileDetector(thresholds) {
328
- return new GodFileDetector(thresholds);
329
- }
330
-
331
- exports.DedupFilter = DedupFilter;
332
- exports.GodFileDetector = GodFileDetector;
333
- exports.createDedupFilter = createDedupFilter;
334
- exports.createGodFileDetector = createGodFileDetector;
335
- //# sourceMappingURL=index.cjs.map
336
- //# sourceMappingURL=index.cjs.map
@@ -1,331 +0,0 @@
1
- import '../chunk-2CWOLHTE.js';
2
- import { createHash } from 'crypto';
3
-
4
- var DEFAULT_CONFIG = {
5
- semanticThreshold: 0.92,
6
- numHashFunctions: 128,
7
- numBands: 16,
8
- shingleSize: 3,
9
- qualityWeighted: true
10
- };
11
- var DedupFilter = class {
12
- constructor(config) {
13
- this.config = { ...DEFAULT_CONFIG, ...config };
14
- }
15
- /**
16
- * Run full dedup pipeline on a set of items
17
- */
18
- dedup(items) {
19
- const startTime = Date.now();
20
- const removals = [];
21
- const { unique: exactUnique, removals: exactRemovals } = this.exactDedup(items);
22
- removals.push(...exactRemovals);
23
- const { unique: semanticUnique, removals: semanticRemovals } = this.semanticDedup(exactUnique);
24
- removals.push(...semanticRemovals);
25
- const report = {
26
- totalInput: items.length,
27
- exactDuplicates: exactRemovals.length,
28
- semanticDuplicates: semanticRemovals.length,
29
- retained: semanticUnique.length,
30
- removedDetails: removals,
31
- processingTimeMs: Date.now() - startTime
32
- };
33
- return { retained: semanticUnique, report };
34
- }
35
- /**
36
- * Layer 1: Exact dedup via SHA-256 hash
37
- */
38
- exactDedup(items) {
39
- const hashMap = /* @__PURE__ */ new Map();
40
- const removals = [];
41
- for (const item of items) {
42
- const hash = this.sha256(item.content);
43
- const existing = hashMap.get(hash);
44
- if (existing) {
45
- if (this.config.qualityWeighted && (item.quality ?? 0) > (existing.quality ?? 0)) {
46
- removals.push({ removedId: existing.id, keptId: item.id, reason: "exact" });
47
- hashMap.set(hash, item);
48
- } else {
49
- removals.push({ removedId: item.id, keptId: existing.id, reason: "exact" });
50
- }
51
- } else {
52
- hashMap.set(hash, item);
53
- }
54
- }
55
- return { unique: Array.from(hashMap.values()), removals };
56
- }
57
- /**
58
- * Layer 2: Semantic near-dedup via MinHash LSH (Jaccard similarity)
59
- */
60
- semanticDedup(items) {
61
- if (items.length <= 1) return { unique: items, removals: [] };
62
- const removals = [];
63
- const removed = /* @__PURE__ */ new Set();
64
- const signatures = items.map((item) => ({
65
- item,
66
- shingles: this.shingle(item.content),
67
- minhash: this.minhash(this.shingle(item.content))
68
- }));
69
- const bandSize = Math.floor(this.config.numHashFunctions / this.config.numBands);
70
- const candidatePairs = /* @__PURE__ */ new Set();
71
- for (let band = 0; band < this.config.numBands; band++) {
72
- const buckets = /* @__PURE__ */ new Map();
73
- const start = band * bandSize;
74
- const end = start + bandSize;
75
- for (let i = 0; i < signatures.length; i++) {
76
- const bandHash = signatures[i].minhash.slice(start, end).join(",");
77
- const bucket = buckets.get(bandHash) ?? [];
78
- bucket.push(i);
79
- buckets.set(bandHash, bucket);
80
- }
81
- for (const bucket of buckets.values()) {
82
- for (let i = 0; i < bucket.length; i++) {
83
- for (let j = i + 1; j < bucket.length; j++) {
84
- const key = `${Math.min(bucket[i], bucket[j])},${Math.max(bucket[i], bucket[j])}`;
85
- candidatePairs.add(key);
86
- }
87
- }
88
- }
89
- }
90
- for (const pair of candidatePairs) {
91
- const [iStr, jStr] = pair.split(",");
92
- const i = parseInt(iStr, 10);
93
- const j = parseInt(jStr, 10);
94
- if (removed.has(signatures[i].item.id) || removed.has(signatures[j].item.id)) continue;
95
- const similarity = this.jaccardSimilarity(signatures[i].shingles, signatures[j].shingles);
96
- if (similarity >= this.config.semanticThreshold) {
97
- const itemA = signatures[i].item;
98
- const itemB = signatures[j].item;
99
- if (this.config.qualityWeighted && (itemA.quality ?? 0) >= (itemB.quality ?? 0)) {
100
- removed.add(itemB.id);
101
- removals.push({ removedId: itemB.id, keptId: itemA.id, reason: "semantic", similarity });
102
- } else {
103
- removed.add(itemA.id);
104
- removals.push({ removedId: itemA.id, keptId: itemB.id, reason: "semantic", similarity });
105
- }
106
- }
107
- }
108
- const unique = items.filter((item) => !removed.has(item.id));
109
- return { unique, removals };
110
- }
111
- // ---- Private helpers ----
112
- sha256(content) {
113
- return createHash("sha256").update(content).digest("hex");
114
- }
115
- shingle(text) {
116
- const shingles = /* @__PURE__ */ new Set();
117
- const words = text.toLowerCase().split(/\s+/);
118
- for (let i = 0; i <= words.length - this.config.shingleSize; i++) {
119
- shingles.add(words.slice(i, i + this.config.shingleSize).join(" "));
120
- }
121
- return shingles;
122
- }
123
- minhash(shingles) {
124
- const signature = new Array(this.config.numHashFunctions).fill(Infinity);
125
- for (const shingle of shingles) {
126
- for (let i = 0; i < this.config.numHashFunctions; i++) {
127
- const hash = this.hashWithSeed(shingle, i);
128
- if (hash < signature[i]) {
129
- signature[i] = hash;
130
- }
131
- }
132
- }
133
- return signature;
134
- }
135
- hashWithSeed(value, seed) {
136
- let hash = 2166136261 ^ seed;
137
- for (let i = 0; i < value.length; i++) {
138
- hash ^= value.charCodeAt(i);
139
- hash = Math.imul(hash, 16777619);
140
- }
141
- return hash >>> 0;
142
- }
143
- jaccardSimilarity(a, b) {
144
- let intersection = 0;
145
- for (const item of a) {
146
- if (b.has(item)) intersection++;
147
- }
148
- const union = a.size + b.size - intersection;
149
- return union === 0 ? 0 : intersection / union;
150
- }
151
- };
152
- function createDedupFilter(config) {
153
- return new DedupFilter(config);
154
- }
155
-
156
- // src/codebase/GodFileDetector.ts
157
- var DEFAULT_THRESHOLDS = {
158
- loc_warning: 500,
159
- loc_god: 1e3,
160
- functions_warning: 20,
161
- functions_god: 40,
162
- complexity_god: 50,
163
- imports_god: 30
164
- };
165
- var GodFileDetector = class {
166
- constructor(thresholds) {
167
- this.thresholds = { ...DEFAULT_THRESHOLDS, ...thresholds };
168
- }
169
- /**
170
- * Analyze a file's content and produce metrics + classification
171
- */
172
- analyze(filePath, content) {
173
- const metrics = this.computeMetrics(filePath, content);
174
- const reasons = [];
175
- let classification = "normal";
176
- if (metrics.loc >= this.thresholds.loc_god) {
177
- reasons.push(`LOC ${metrics.loc} >= ${this.thresholds.loc_god} (god file threshold)`);
178
- classification = "god_file";
179
- } else if (metrics.loc >= this.thresholds.loc_warning) {
180
- reasons.push(`LOC ${metrics.loc} >= ${this.thresholds.loc_warning} (warning threshold)`);
181
- classification = "warning";
182
- }
183
- if (metrics.functionCount >= this.thresholds.functions_god) {
184
- reasons.push(
185
- `Functions ${metrics.functionCount} >= ${this.thresholds.functions_god} (god file threshold)`
186
- );
187
- classification = "god_file";
188
- } else if (metrics.functionCount >= this.thresholds.functions_warning) {
189
- reasons.push(
190
- `Functions ${metrics.functionCount} >= ${this.thresholds.functions_warning} (warning threshold)`
191
- );
192
- if (classification !== "god_file") classification = "warning";
193
- }
194
- if (metrics.cyclomaticComplexity >= this.thresholds.complexity_god) {
195
- reasons.push(
196
- `Cyclomatic complexity ${metrics.cyclomaticComplexity} >= ${this.thresholds.complexity_god}`
197
- );
198
- classification = "god_file";
199
- }
200
- if (metrics.importCount >= this.thresholds.imports_god) {
201
- reasons.push(`Imports ${metrics.importCount} >= ${this.thresholds.imports_god}`);
202
- if (classification !== "god_file") classification = "warning";
203
- }
204
- const report = {
205
- filePath,
206
- classification,
207
- metrics,
208
- reasons
209
- };
210
- if (classification === "god_file") {
211
- report.splitPlan = this.suggestSplit(filePath, content, metrics);
212
- }
213
- return report;
214
- }
215
- /**
216
- * Compute metrics for a file
217
- */
218
- computeMetrics(filePath, content) {
219
- const lines = content.split("\n");
220
- const loc = lines.filter((l) => l.trim().length > 0 && !l.trim().startsWith("//")).length;
221
- const functionPattern = /\b(function\s+\w+|(?:async\s+)?(?:get|set)?\s*\w+\s*\(.*\)\s*(?::\s*\w[\w<>,\s|]*\s*)?{|\w+\s*=\s*(?:async\s+)?(?:\(.*\)|[\w]+)\s*=>)/g;
222
- const functionCount = (content.match(functionPattern) || []).length;
223
- const importPattern = /\bimport\s+(?:type\s+)?(?:{[^}]*}|\*\s+as\s+\w+|\w+)\s+from/g;
224
- const importCount = (content.match(importPattern) || []).length;
225
- const exportPattern = /\bexport\s+(?:default\s+)?(?:class|function|const|let|var|interface|type|enum)/g;
226
- const exportCount = (content.match(exportPattern) || []).length;
227
- const classPattern = /\bclass\s+\w+/g;
228
- const classCount = (content.match(classPattern) || []).length;
229
- const complexityPatterns = /\b(if|else if|for|while|do|switch|case|catch|\?\?|&&|\|\||ternary)\b|\?(?!=)/g;
230
- const cyclomaticComplexity = (content.match(complexityPatterns) || []).length + 1;
231
- return {
232
- filePath,
233
- loc,
234
- functionCount,
235
- importCount,
236
- exportCount,
237
- classCount,
238
- cyclomaticComplexity
239
- };
240
- }
241
- /**
242
- * Suggest a virtual split plan for a god file.
243
- * Only splits at top-level declaration boundaries (G.GAP.05 prevention).
244
- */
245
- suggestSplit(filePath, content, metrics) {
246
- const lines = content.split("\n");
247
- const segments = [];
248
- const baseName = filePath.replace(/\.[^.]+$/, "").split(/[/\\]/).pop() || "module";
249
- let currentStart = 0;
250
- let currentType = "module";
251
- let currentName = "";
252
- let symbolCount = 0;
253
- let braceDepth = 0;
254
- for (let i = 0; i < lines.length; i++) {
255
- const line = lines[i];
256
- const trimmed = line.trim();
257
- for (const ch of line) {
258
- if (ch === "{") braceDepth++;
259
- if (ch === "}") braceDepth--;
260
- }
261
- const classMatch = trimmed.match(/^(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/);
262
- if (classMatch && braceDepth <= 1) {
263
- if (i > currentStart + 5) {
264
- segments.push({
265
- suggestedName: currentName || `${baseName}-segment-${segments.length}`,
266
- startLine: currentStart + 1,
267
- endLine: i,
268
- type: currentType,
269
- symbolCount,
270
- description: `Lines ${currentStart + 1}-${i}`
271
- });
272
- }
273
- currentStart = i;
274
- currentType = "class";
275
- currentName = classMatch[1];
276
- symbolCount = 0;
277
- }
278
- if (trimmed.match(/^(?:export\s+)?(?:const|let|var|function|class|interface|type|enum)\s/)) {
279
- symbolCount++;
280
- }
281
- }
282
- if (currentStart < lines.length - 1) {
283
- segments.push({
284
- suggestedName: currentName || `${baseName}-segment-${segments.length}`,
285
- startLine: currentStart + 1,
286
- endLine: lines.length,
287
- type: currentType,
288
- symbolCount,
289
- description: `Lines ${currentStart + 1}-${lines.length}`
290
- });
291
- }
292
- if (segments.length <= 1) {
293
- return this.splitByFunctionGroups(filePath, content, metrics, baseName);
294
- }
295
- return {
296
- originalPath: filePath,
297
- segments,
298
- totalSegments: segments.length
299
- };
300
- }
301
- splitByFunctionGroups(filePath, content, _metrics, baseName) {
302
- const lines = content.split("\n");
303
- const segmentSize = Math.ceil(lines.length / 3);
304
- const segments = [];
305
- for (let i = 0; i < 3; i++) {
306
- const start = i * segmentSize;
307
- const end = Math.min((i + 1) * segmentSize, lines.length);
308
- if (start >= lines.length) break;
309
- segments.push({
310
- suggestedName: `${baseName}-part-${i + 1}`,
311
- startLine: start + 1,
312
- endLine: end,
313
- type: "function-group",
314
- symbolCount: 0,
315
- description: `Lines ${start + 1}-${end}`
316
- });
317
- }
318
- return {
319
- originalPath: filePath,
320
- segments,
321
- totalSegments: segments.length
322
- };
323
- }
324
- };
325
- function createGodFileDetector(thresholds) {
326
- return new GodFileDetector(thresholds);
327
- }
328
-
329
- export { DedupFilter, GodFileDetector, createDedupFilter, createGodFileDetector };
330
- //# sourceMappingURL=index.js.map
331
- //# sourceMappingURL=index.js.map
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var chunk72EQECGT_cjs = require('../chunk-72EQECGT.cjs');
6
- require('../chunk-BF2235SI.cjs');
7
- require('../chunk-3SAK5KFL.cjs');
8
-
9
-
10
-
11
- Object.defineProperty(exports, "AgentInferenceCompiler", {
12
- enumerable: true,
13
- get: function () { return chunk72EQECGT_cjs.AgentInferenceCompiler; }
14
- });
15
- Object.defineProperty(exports, "createAgentInferenceCompiler", {
16
- enumerable: true,
17
- get: function () { return chunk72EQECGT_cjs.createAgentInferenceCompiler; }
18
- });
19
- Object.defineProperty(exports, "createPythonAgentInferenceCompiler", {
20
- enumerable: true,
21
- get: function () { return chunk72EQECGT_cjs.createPythonAgentInferenceCompiler; }
22
- });
23
- Object.defineProperty(exports, "default", {
24
- enumerable: true,
25
- get: function () { return chunk72EQECGT_cjs.AgentInferenceExportTarget_default; }
26
- });
27
- //# sourceMappingURL=agent-inference.cjs.map
28
- //# sourceMappingURL=agent-inference.cjs.map
@@ -1,5 +0,0 @@
1
- export { AgentInferenceCompiler, createAgentInferenceCompiler, createPythonAgentInferenceCompiler, AgentInferenceExportTarget_default as default } from '../chunk-XD6IYDUX.js';
2
- import '../chunk-6XSERL6L.js';
3
- import '../chunk-2CWOLHTE.js';
4
- //# sourceMappingURL=agent-inference.js.map
5
- //# sourceMappingURL=agent-inference.js.map