@holoscript/core 6.0.3 → 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.
- package/README.md +40 -40
- package/dist/codebase/index.d.ts +25 -0
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +4 -0
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/index.d.ts +520 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/storage/index.d.ts +24 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +102 -19
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
- package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
- package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
- package/dist/USDZExporter-YA55ZS35.js +0 -707
- package/dist/chunk-26TLYBFD.js +0 -309
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2UX5LRAP.cjs +0 -833
- package/dist/chunk-32TWR3HE.js +0 -70
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-4FCZDTD5.js +0 -610
- package/dist/chunk-4KJ2R7VP.cjs +0 -507
- package/dist/chunk-4SMUJFHL.js +0 -1213
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-65RFOWZI.js +0 -765
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-74YCHHTE.js +0 -1872
- package/dist/chunk-7H5UNJZD.cjs +0 -1973
- package/dist/chunk-7KPI4EKH.cjs +0 -701
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-7N3JIJMT.js +0 -1395
- package/dist/chunk-7X2IEJIE.cjs +0 -2526
- package/dist/chunk-A6GO3DPZ.cjs +0 -1002
- package/dist/chunk-AC4BSHFV.js +0 -765
- package/dist/chunk-AIUXRS74.cjs +0 -3681
- package/dist/chunk-ARNKA274.cjs +0 -130
- package/dist/chunk-AW7WAELW.js +0 -975
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BO2OKHIY.js +0 -6055
- package/dist/chunk-BU5ZAFMC.js +0 -115
- package/dist/chunk-BY3B7ZYV.cjs +0 -457
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-C7BNX4XJ.js +0 -1043
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CMYAWUX3.js +0 -4455
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-CNVM7J3M.js +0 -883
- package/dist/chunk-CO2VM2DK.js +0 -1965
- package/dist/chunk-CQDOF3G7.cjs +0 -1404
- package/dist/chunk-DH5G2JUA.cjs +0 -614
- package/dist/chunk-DIEDKX5B.cjs +0 -660
- package/dist/chunk-DN7UFU63.cjs +0 -172
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-EGIZHYJP.cjs +0 -85
- package/dist/chunk-EJA7G2C4.cjs +0 -428
- package/dist/chunk-ELLQPFAF.js +0 -830
- package/dist/chunk-EMO7HAKJ.cjs +0 -1875
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-EPWRXL6S.js +0 -2522
- package/dist/chunk-EUFLX2PI.js +0 -56956
- package/dist/chunk-F5LVGHNT.js +0 -449
- package/dist/chunk-FEFHPUEM.cjs +0 -6122
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-GC3YU46J.js +0 -762
- package/dist/chunk-H6WMMLQK.cjs +0 -4492
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HBZYCASG.js +0 -4208
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-HHS6FMOU.cjs +0 -3813
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HKCVM6OK.cjs +0 -2237
- package/dist/chunk-HUFNKFA6.js +0 -698
- package/dist/chunk-I3XGTIHM.cjs +0 -1505
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-KDB6BUMB.js +0 -3666
- package/dist/chunk-KUJRR4FJ.js +0 -657
- package/dist/chunk-KYM4XRFG.js +0 -421
- package/dist/chunk-L3Z2HIWJ.cjs +0 -793
- package/dist/chunk-LBPEZQAF.js +0 -2232
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUHGRTZ.js +0 -752
- package/dist/chunk-NKRKT6V2.js +0 -69
- package/dist/chunk-NLPSZT4C.js +0 -630
- package/dist/chunk-NRUB55IT.cjs +0 -771
- package/dist/chunk-NTMZSDXM.cjs +0 -633
- package/dist/chunk-ODGMVILH.js +0 -9662
- package/dist/chunk-PBA6NXCT.cjs +0 -1216
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-PLMYCCA4.js +0 -504
- package/dist/chunk-PPULB4GG.cjs +0 -9728
- package/dist/chunk-PQLGZKMC.cjs +0 -755
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-RE3OKSYF.cjs +0 -424
- package/dist/chunk-RT7LJRSF.cjs +0 -57378
- package/dist/chunk-SPDELRRV.cjs +0 -319
- package/dist/chunk-SUCBB66F.js +0 -229
- package/dist/chunk-TSWTWZ42.cjs +0 -4214
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-V2ILLPHK.cjs +0 -237
- package/dist/chunk-V42NTCFH.js +0 -3645
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-VJVCD5T5.cjs +0 -769
- package/dist/chunk-VK5AXKO3.js +0 -746
- package/dist/chunk-VSXOIUCF.cjs +0 -473
- package/dist/chunk-VZNKJZTT.cjs +0 -749
- package/dist/chunk-W76ETJTI.js +0 -678
- package/dist/chunk-WFJIDI2N.cjs +0 -424
- package/dist/chunk-WN3YF33G.cjs +0 -118
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-WYH4GVZ5.js +0 -1488
- package/dist/chunk-X4YVN7H3.cjs +0 -888
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-XDXZM3ZP.cjs +0 -1046
- package/dist/chunk-XH7SE4HH.cjs +0 -72
- package/dist/chunk-XNMEH2BI.js +0 -126
- package/dist/chunk-XSF76QRU.js +0 -468
- package/dist/chunk-XSUZMPVQ.cjs +0 -682
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-Y5MUAYTO.js +0 -167
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-ZGTGVSTZ.js +0 -422
- package/dist/chunk-ZL6VJ6SN.js +0 -421
- package/dist/cli/holoscript-runner.cjs +0 -2258
- package/dist/cli/holoscript-runner.js +0 -2233
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -29
- package/dist/compiler/agent-inference.js +0 -6
- package/dist/compiler/android-xr.cjs +0 -20
- package/dist/compiler/android-xr.js +0 -10
- package/dist/compiler/android.cjs +0 -21
- package/dist/compiler/android.js +0 -11
- package/dist/compiler/ar.cjs +0 -21
- package/dist/compiler/ar.js +0 -9
- package/dist/compiler/babylon.cjs +0 -18
- package/dist/compiler/babylon.js +0 -12
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -595
- package/dist/compiler/domain-block-utils.js +0 -9
- package/dist/compiler/dtdl.cjs +0 -25
- package/dist/compiler/dtdl.js +0 -9
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -16
- package/dist/compiler/godot.js +0 -10
- package/dist/compiler/incremental.cjs +0 -30
- package/dist/compiler/incremental.js +0 -5
- package/dist/compiler/index.cjs +0 -1522
- package/dist/compiler/index.js +0 -1321
- package/dist/compiler/ios.cjs +0 -21
- package/dist/compiler/ios.js +0 -11
- package/dist/compiler/multi-layer.cjs +0 -27
- package/dist/compiler/multi-layer.js +0 -12
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -16
- package/dist/compiler/openxr.js +0 -10
- package/dist/compiler/playcanvas.cjs +0 -17
- package/dist/compiler/playcanvas.js +0 -11
- package/dist/compiler/r3f.cjs +0 -35
- package/dist/compiler/r3f.js +0 -13
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -22
- package/dist/compiler/sdf.js +0 -10
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -18
- package/dist/compiler/state.js +0 -8
- package/dist/compiler/trait-composition.cjs +0 -27
- package/dist/compiler/trait-composition.js +0 -6
- package/dist/compiler/unity.cjs +0 -16
- package/dist/compiler/unity.js +0 -10
- package/dist/compiler/unreal.cjs +0 -20
- package/dist/compiler/unreal.js +0 -10
- package/dist/compiler/urdf.cjs +0 -46
- package/dist/compiler/urdf.js +0 -10
- package/dist/compiler/usd-physics.cjs +0 -24
- package/dist/compiler/usd-physics.js +0 -7
- package/dist/compiler/visionos.cjs +0 -16
- package/dist/compiler/visionos.js +0 -10
- package/dist/compiler/vrchat.cjs +0 -20
- package/dist/compiler/vrchat.js +0 -10
- package/dist/compiler/vrr.cjs +0 -22
- package/dist/compiler/vrr.js +0 -10
- package/dist/compiler/wasm.cjs +0 -34
- package/dist/compiler/wasm.js +0 -10
- package/dist/compiler/webgpu.cjs +0 -16
- package/dist/compiler/webgpu.js +0 -10
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -67
- package/dist/entries/scripting.js +0 -10
- package/dist/index.cjs +0 -61703
- package/dist/index.js +0 -58652
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/parser.cjs +0 -26
- package/dist/parser.js +0 -9
- package/dist/playwright-7DTEQCBD.cjs +0 -98673
- package/dist/playwright-BIZXMLD2.js +0 -98660
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14331
- package/dist/traits/index.js +0 -12126
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
- package/dist/wot/index.cjs +0 -29
- package/dist/wot/index.js +0 -4
package/dist/codebase/index.cjs
DELETED
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('../chunk-EGIZHYJP.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
|
package/dist/codebase/index.js
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import '../chunk-32TWR3HE.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,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var chunkX4YVN7H3_cjs = require('../chunk-X4YVN7H3.cjs');
|
|
6
|
-
require('../chunk-QHVVVN47.cjs');
|
|
7
|
-
require('../chunk-AIUXRS74.cjs');
|
|
8
|
-
require('../chunk-EGIZHYJP.cjs');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "AgentInferenceCompiler", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return chunkX4YVN7H3_cjs.AgentInferenceCompiler; }
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "createAgentInferenceCompiler", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return chunkX4YVN7H3_cjs.createAgentInferenceCompiler; }
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "createPythonAgentInferenceCompiler", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () { return chunkX4YVN7H3_cjs.createPythonAgentInferenceCompiler; }
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "default", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () { return chunkX4YVN7H3_cjs.AgentInferenceExportTarget_default; }
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=agent-inference.cjs.map
|
|
29
|
-
//# sourceMappingURL=agent-inference.cjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { AgentInferenceCompiler, createAgentInferenceCompiler, createPythonAgentInferenceCompiler, AgentInferenceExportTarget_default as default } from '../chunk-CNVM7J3M.js';
|
|
2
|
-
import '../chunk-QWKUKVRE.js';
|
|
3
|
-
import '../chunk-V42NTCFH.js';
|
|
4
|
-
import '../chunk-32TWR3HE.js';
|
|
5
|
-
//# sourceMappingURL=agent-inference.js.map
|
|
6
|
-
//# sourceMappingURL=agent-inference.js.map
|