ultracode 5.4.0 → 5.6.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/dist/chunks/analysis-tool-handlers-GH5FDEWW.js +817 -0
- package/dist/chunks/analysis-tool-handlers-IXP4MWZX.js +817 -0
- package/dist/chunks/analysis-tool-handlers-LC2BTQYK.js +13 -0
- package/dist/chunks/analysis-tool-handlers-QYFKQPFL.js +817 -0
- package/dist/chunks/autodoc-tool-handlers-2HF6ERYN.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-4OGQJ7C3.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-N736CB56.js +138 -0
- package/dist/chunks/autodoc-tool-handlers-NQYBY6U4.js +1112 -0
- package/dist/chunks/branch-tool-handlers-KW3H4FJK.js +276 -0
- package/dist/chunks/branch-tool-handlers-QOUDZKJ2.js +276 -0
- package/dist/chunks/branch-tool-handlers-RB2U36KI.js +2 -0
- package/dist/chunks/branch-tool-handlers-ZHJM6PDK.js +276 -0
- package/dist/chunks/chunk-2Z6OQPYC.js +656 -0
- package/dist/chunks/chunk-3MQ7LRPN.js +322 -0
- package/dist/chunks/chunk-4W6QYGXZ.js +10 -0
- package/dist/chunks/chunk-533NFGUG.js +1 -0
- package/dist/chunks/chunk-5NUPOPWM.js +1 -0
- package/dist/chunks/chunk-AK4HIPA2.js +322 -0
- package/dist/chunks/chunk-B3H5NS3I.js +656 -0
- package/dist/chunks/chunk-DPTZHDST.js +4 -0
- package/dist/chunks/chunk-E5HQWLU5.js +322 -0
- package/dist/chunks/chunk-EOH25B5P.js +572 -0
- package/dist/chunks/chunk-ESV6F6E3.js +3179 -0
- package/dist/chunks/chunk-FPELPFER.js +924 -0
- package/dist/chunks/chunk-G6J42I55.js +161 -0
- package/dist/chunks/chunk-GCQE7ZYW.js +1 -0
- package/dist/chunks/chunk-GTIF6MOX.js +1 -0
- package/dist/chunks/chunk-I6STSSAK.js +2 -0
- package/dist/chunks/chunk-J2WBGTK2.js +4697 -0
- package/dist/chunks/chunk-KAYOX5EB.js +4697 -0
- package/dist/chunks/chunk-KPMTACOT.js +656 -0
- package/dist/chunks/chunk-L376GZ44.js +3179 -0
- package/dist/chunks/chunk-LCTOTHDA.js +15 -0
- package/dist/chunks/chunk-LEDJ7GVQ.js +316 -0
- package/dist/chunks/chunk-LH4OUKNZ.js +277 -0
- package/dist/chunks/chunk-O6IE2MEZ.js +161 -0
- package/dist/chunks/chunk-OEXPCY3F.js +316 -0
- package/dist/chunks/chunk-OMXOLFDN.js +924 -0
- package/dist/chunks/chunk-PLPBXWOU.js +3179 -0
- package/dist/chunks/chunk-PWLE5DN2.js +572 -0
- package/dist/chunks/chunk-PY43JPWL.js +447 -0
- package/dist/chunks/chunk-Q3B4EB7A.js +15 -0
- package/dist/chunks/chunk-Q5LPVLXA.js +337 -0
- package/dist/chunks/chunk-QIRZHZK2.js +5 -0
- package/dist/chunks/chunk-ROQ27LSL.js +924 -0
- package/dist/chunks/chunk-S5Q7BD6J.js +572 -0
- package/dist/chunks/chunk-SAMX3HJQ.js +337 -0
- package/dist/chunks/chunk-SV3WKUNV.js +1 -0
- package/dist/chunks/chunk-TCHCDCDO.js +167 -0
- package/dist/chunks/chunk-TR3HS7U6.js +316 -0
- package/dist/chunks/chunk-TUWE6FCW.js +167 -0
- package/dist/chunks/chunk-TVOTA7EE.js +277 -0
- package/dist/chunks/chunk-VS44D772.js +337 -0
- package/dist/chunks/chunk-WIE3G5ES.js +167 -0
- package/dist/chunks/chunk-XG3ACLWR.js +5 -0
- package/dist/chunks/chunk-XJ2Z5QQO.js +1 -0
- package/dist/chunks/chunk-XK2NY7RB.js +277 -0
- package/dist/chunks/chunk-Y4F7NZFZ.js +4700 -0
- package/dist/chunks/chunk-YS75L3ZS.js +161 -0
- package/dist/chunks/chunk-ZVG5HHI3.js +15 -0
- package/dist/chunks/dev-agent-DDDIVWOF.js +1 -0
- package/dist/chunks/dev-agent-E2VCFKXN.js +1624 -0
- package/dist/chunks/dev-agent-KJNSU5KQ.js +1624 -0
- package/dist/chunks/dev-agent-NDERYIPV.js +1624 -0
- package/dist/chunks/faiss-provider-7R4BQDIV.js +12 -0
- package/dist/chunks/faiss-provider-7ZFRSDN5.js +12 -0
- package/dist/chunks/faiss-provider-SXB7FTLB.js +1 -0
- package/dist/chunks/faiss-provider-TKLBEUSH.js +12 -0
- package/dist/chunks/file-tool-handlers-5DODQXGF.js +1027 -0
- package/dist/chunks/file-tool-handlers-KGHLE4KR.js +1027 -0
- package/dist/chunks/file-tool-handlers-KTOQ4NFS.js +12 -0
- package/dist/chunks/file-tool-handlers-V4SFUDQB.js +1027 -0
- package/dist/chunks/graph-metrics-tool-handlers-3AV4X4ZY.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-3VMDQHJ6.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-BZ6E6YHF.js +1 -0
- package/dist/chunks/graph-metrics-tool-handlers-IYBGSXL7.js +65 -0
- package/dist/chunks/graph-storage-factory-2CQ2RPDV.js +13 -0
- package/dist/chunks/graph-storage-factory-C5SMMYL6.js +13 -0
- package/dist/chunks/graph-storage-factory-EEO2V3GJ.js +1 -0
- package/dist/chunks/graph-storage-factory-WBCTXP34.js +13 -0
- package/dist/chunks/history-tool-handlers-AS7OQFZI.js +1 -0
- package/dist/chunks/history-tool-handlers-FSNJYXV2.js +208 -0
- package/dist/chunks/history-tool-handlers-JZAH4EIQ.js +208 -0
- package/dist/chunks/history-tool-handlers-KCSCXZ7T.js +208 -0
- package/dist/chunks/incremental-updater-A2EL4QXU.js +14 -0
- package/dist/chunks/incremental-updater-EQIKBVY2.js +14 -0
- package/dist/chunks/incremental-updater-JFGRPH3B.js +14 -0
- package/dist/chunks/incremental-updater-S5BAAGHP.js +1 -0
- package/dist/chunks/indexer-agent-ASKY7JPG.js +1 -0
- package/dist/chunks/indexer-agent-NKAOF323.js +21 -0
- package/dist/chunks/indexer-agent-PJN5IOKQ.js +21 -0
- package/dist/chunks/indexer-agent-WRJFWKZX.js +21 -0
- package/dist/chunks/indexing-pipeline-D4P2O72Z.js +249 -0
- package/dist/chunks/indexing-pipeline-L7C543N4.js +1 -0
- package/dist/chunks/indexing-pipeline-NHPRN3AB.js +249 -0
- package/dist/chunks/indexing-pipeline-ZAXCZU22.js +249 -0
- package/dist/chunks/layered-faiss-provider-62CNW54X.js +1 -0
- package/dist/chunks/layered-faiss-provider-O7L77GFX.js +12 -0
- package/dist/chunks/layered-faiss-provider-RVHLHLPK.js +12 -0
- package/dist/chunks/layered-faiss-provider-YT7EDIJI.js +12 -0
- package/dist/chunks/merge-agent-3RF7VFF5.js +2481 -0
- package/dist/chunks/merge-agent-JCKTCBCE.js +2481 -0
- package/dist/chunks/merge-agent-VCL7OXPN.js +2481 -0
- package/dist/chunks/merge-agent-ZGK24WVF.js +11 -0
- package/dist/chunks/merge-tool-handlers-GV2LOIKU.js +277 -0
- package/dist/chunks/merge-tool-handlers-TYDWU5X2.js +277 -0
- package/dist/chunks/merge-tool-handlers-U7X2ZO2M.js +1 -0
- package/dist/chunks/merge-tool-handlers-YH62ZLPJ.js +277 -0
- package/dist/chunks/pattern-tool-handlers-76NF5JDS.js +13 -0
- package/dist/chunks/pattern-tool-handlers-IJAGEIVD.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-VA5WYA62.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-WQ6UBMJS.js +1549 -0
- package/dist/chunks/query-agent-36ADGCFZ.js +1 -0
- package/dist/chunks/query-agent-H22CR5N5.js +191 -0
- package/dist/chunks/query-agent-K2UGZS4M.js +191 -0
- package/dist/chunks/query-agent-YJCEHOXD.js +191 -0
- package/dist/chunks/semantic-agent-AC7CBEDE.js +6381 -0
- package/dist/chunks/semantic-agent-HK5X6CKU.js +6381 -0
- package/dist/chunks/semantic-agent-KONIKEGW.js +6381 -0
- package/dist/chunks/semantic-agent-LH6IZ2L7.js +137 -0
- package/dist/chunks/semantic-tool-handlers-5LMSH2U7.js +3 -0
- package/dist/chunks/semantic-tool-handlers-735UMO7Y.js +817 -0
- package/dist/chunks/semantic-tool-handlers-BNUYPP7X.js +817 -0
- package/dist/chunks/semantic-tool-handlers-MYZPEUD2.js +817 -0
- package/dist/chunks/snapshot-tool-handlers-6SIHZT2F.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-DS4P3KOT.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-JYHRFPC7.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-YEHMAT3L.js +1 -0
- package/dist/chunks/storage-paths-A3C7WHHG.js +8 -0
- package/dist/chunks/storage-paths-HDYH7WPM.js +1 -0
- package/dist/chunks/storage-paths-IMFRHBWF.js +8 -0
- package/dist/chunks/storage-paths-P3PUSMUD.js +8 -0
- package/dist/chunks/taint-tool-handlers-CWESOOMQ.js +68 -0
- package/dist/chunks/taint-tool-handlers-OG3NVVP3.js +1 -0
- package/dist/chunks/taint-tool-handlers-ON3G3FA7.js +68 -0
- package/dist/chunks/taint-tool-handlers-P4P5J6DB.js +68 -0
- package/dist/chunks/tracing-tool-handlers-4BDCXTZZ.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-6FPNM7HX.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-LQTQ5SKK.js +89 -0
- package/dist/chunks/tracing-tool-handlers-XRQX2DTS.js +3935 -0
- package/dist/chunks/validation-tool-handlers-DZUG7KYY.js +2 -0
- package/dist/chunks/validation-tool-handlers-O6TGFSH5.js +555 -0
- package/dist/chunks/validation-tool-handlers-RREUYKIR.js +555 -0
- package/dist/chunks/validation-tool-handlers-XPWSMS37.js +555 -0
- package/dist/index.js +13 -13
- package/dist/roslyn-addon/.build-hash +1 -1
- package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
- package/dist/roslyn-addon/ILGPU.dll +0 -0
- package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
- package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { init_storage_paths, storage_paths_exports, getProjectHash, getCurrentGitBranch, getProjectDir } from './chunk-XK2NY7RB.js';
|
|
2
|
+
import { init_logging, log } from './chunk-VCCBEJQ5.js';
|
|
3
|
+
import { __toCommonJS } from './chunk-NAQKA54E.js';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
// src/semantic/faiss/base-branch-detector.ts
|
|
9
|
+
init_logging();
|
|
10
|
+
init_storage_paths();
|
|
11
|
+
var BASE_BRANCH_CANDIDATES = ["main", "master", "dev", "develop", "trunk"];
|
|
12
|
+
var BASE_META_FILENAME = "faiss-base.meta.json";
|
|
13
|
+
function getBaseMetaPath(projectPath) {
|
|
14
|
+
return join(getProjectDir(projectPath), BASE_META_FILENAME);
|
|
15
|
+
}
|
|
16
|
+
function getBaseMetaPathByHash(projectHash) {
|
|
17
|
+
const { getProjectsDir } = (init_storage_paths(), __toCommonJS(storage_paths_exports));
|
|
18
|
+
return join(getProjectsDir(), projectHash, BASE_META_FILENAME);
|
|
19
|
+
}
|
|
20
|
+
function loadBaseMetadata(projectPath) {
|
|
21
|
+
const metaPath = getBaseMetaPath(projectPath);
|
|
22
|
+
if (!existsSync(metaPath)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const data = readFileSync(metaPath, "utf-8");
|
|
27
|
+
return JSON.parse(data);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
log.w("BASE_DETECT", "meta_read_fail", { path: metaPath, err: String(error) });
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function saveBaseMetadata(projectPath, metadata) {
|
|
34
|
+
const metaPath = getBaseMetaPath(projectPath);
|
|
35
|
+
try {
|
|
36
|
+
writeFileSync(metaPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
37
|
+
log.d("BASE_DETECT", "meta_saved", { branch: metadata.baseBranch, path: metaPath });
|
|
38
|
+
} catch (error) {
|
|
39
|
+
log.e("BASE_DETECT", "meta_save_fail", { path: metaPath, err: String(error) });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getLocalBranches(projectPath) {
|
|
43
|
+
try {
|
|
44
|
+
const output = execSync("git branch --list", {
|
|
45
|
+
cwd: projectPath,
|
|
46
|
+
encoding: "utf-8",
|
|
47
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
48
|
+
windowsHide: true
|
|
49
|
+
});
|
|
50
|
+
return output.split("\n").map((line) => line.trim().replace(/^\* /, "")).filter((name) => name.length > 0);
|
|
51
|
+
} catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getRemoteDefaultBranch(projectPath) {
|
|
56
|
+
try {
|
|
57
|
+
const ref = execSync("git symbolic-ref refs/remotes/origin/HEAD", {
|
|
58
|
+
cwd: projectPath,
|
|
59
|
+
encoding: "utf-8",
|
|
60
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
61
|
+
windowsHide: true
|
|
62
|
+
}).trim();
|
|
63
|
+
const parts = ref.split("/");
|
|
64
|
+
return parts[parts.length - 1] || null;
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function detectBaseBranch(projectPath) {
|
|
70
|
+
const projectHash = getProjectHash(projectPath);
|
|
71
|
+
const metaPath = getBaseMetaPath(projectPath);
|
|
72
|
+
log.d("BASE_DETECT", "start", {
|
|
73
|
+
projectPath,
|
|
74
|
+
projectHash,
|
|
75
|
+
metaPath,
|
|
76
|
+
metaExists: existsSync(metaPath)
|
|
77
|
+
});
|
|
78
|
+
const existingMeta = loadBaseMetadata(projectPath);
|
|
79
|
+
if (existingMeta?.baseBranch) {
|
|
80
|
+
log.d("BASE_DETECT", "using_existing", {
|
|
81
|
+
project: projectHash,
|
|
82
|
+
branch: existingMeta.baseBranch
|
|
83
|
+
});
|
|
84
|
+
return existingMeta.baseBranch;
|
|
85
|
+
}
|
|
86
|
+
const remoteDefault = getRemoteDefaultBranch(projectPath);
|
|
87
|
+
if (remoteDefault) {
|
|
88
|
+
log.d("BASE_DETECT", "using_remote_default", {
|
|
89
|
+
project: projectHash,
|
|
90
|
+
branch: remoteDefault
|
|
91
|
+
});
|
|
92
|
+
return remoteDefault;
|
|
93
|
+
}
|
|
94
|
+
const localBranches = getLocalBranches(projectPath);
|
|
95
|
+
for (const candidate of BASE_BRANCH_CANDIDATES) {
|
|
96
|
+
if (localBranches.includes(candidate)) {
|
|
97
|
+
log.d("BASE_DETECT", "using_common_name", {
|
|
98
|
+
project: projectHash,
|
|
99
|
+
branch: candidate
|
|
100
|
+
});
|
|
101
|
+
return candidate;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const currentBranch = getCurrentGitBranch(projectPath);
|
|
105
|
+
if (currentBranch) {
|
|
106
|
+
log.d("BASE_DETECT", "using_current", {
|
|
107
|
+
project: projectHash,
|
|
108
|
+
branch: currentBranch
|
|
109
|
+
});
|
|
110
|
+
return currentBranch;
|
|
111
|
+
}
|
|
112
|
+
log.w("BASE_DETECT", "no_git_repo", { project: projectHash });
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function createInitialBaseMetadata(projectPath, branchName, dimensions, vectorCount = 0) {
|
|
116
|
+
const metadata = {
|
|
117
|
+
baseBranch: branchName,
|
|
118
|
+
vectorCount,
|
|
119
|
+
createdAt: Date.now(),
|
|
120
|
+
updatedAt: Date.now(),
|
|
121
|
+
dimensions,
|
|
122
|
+
indexType: "hnsw"
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
const commit = execSync("git rev-parse --short HEAD", {
|
|
126
|
+
cwd: projectPath,
|
|
127
|
+
encoding: "utf-8",
|
|
128
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
129
|
+
windowsHide: true
|
|
130
|
+
}).trim();
|
|
131
|
+
if (commit) {
|
|
132
|
+
metadata.baseCommit = commit;
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
saveBaseMetadata(projectPath, metadata);
|
|
137
|
+
log.i("BASE_DETECT", "base_created", {
|
|
138
|
+
project: getProjectHash(projectPath),
|
|
139
|
+
branch: branchName,
|
|
140
|
+
vectors: vectorCount,
|
|
141
|
+
dimensions
|
|
142
|
+
});
|
|
143
|
+
return metadata;
|
|
144
|
+
}
|
|
145
|
+
function updateBaseMetadata(projectPath, vectorCount, commit) {
|
|
146
|
+
const existing = loadBaseMetadata(projectPath);
|
|
147
|
+
if (!existing) {
|
|
148
|
+
log.w("BASE_DETECT", "update_no_existing", { project: getProjectHash(projectPath) });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
existing.vectorCount = vectorCount;
|
|
152
|
+
existing.updatedAt = Date.now();
|
|
153
|
+
if (commit) {
|
|
154
|
+
existing.baseCommit = commit;
|
|
155
|
+
}
|
|
156
|
+
saveBaseMetadata(projectPath, existing);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { createInitialBaseMetadata, detectBaseBranch, getBaseMetaPathByHash, loadBaseMetadata, updateBaseMetadata };
|
|
160
|
+
//# sourceMappingURL=chunk-YS75L3ZS.js.map
|
|
161
|
+
//# sourceMappingURL=chunk-YS75L3ZS.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getProjectContext } from './chunk-TUWE6FCW.js';
|
|
2
|
+
|
|
3
|
+
// src/shared/indexing-context.ts
|
|
4
|
+
function getCurrentIndexingDirectory() {
|
|
5
|
+
return getProjectContext().getCurrentProject();
|
|
6
|
+
}
|
|
7
|
+
function setCurrentIndexingDirectory(directory) {
|
|
8
|
+
if (directory) {
|
|
9
|
+
getProjectContext().switchProject(directory);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { getCurrentIndexingDirectory, setCurrentIndexingDirectory };
|
|
14
|
+
//# sourceMappingURL=chunk-ZVG5HHI3.js.map
|
|
15
|
+
//# sourceMappingURL=chunk-ZVG5HHI3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-MTWE62OK.js';import {a as a$4}from'./chunk-QIRZHZK2.js';import {a as a$2}from'./chunk-YIOHS5R6.js';import'./chunk-6MFITFK4.js';import'./chunk-BLAZ5QEI.js';import {e,f,b as b$2,c as c$2}from'./chunk-WZJJIJJU.js';export{a as ALL_SUPPORTED_EXTENSIONS}from'./chunk-WZJJIJJU.js';import {a as a$6}from'./chunk-WUCFSFZP.js';import {a as a$7}from'./chunk-PWZ3AMZA.js';import {a as a$3,b as b$1}from'./chunk-GTIF6MOX.js';import'./chunk-XJ2Z5QQO.js';import {a as a$5}from'./chunk-7YC4KTAW.js';import {b}from'./chunk-V5VLOVE7.js';import {c as c$3,f as f$1}from'./chunk-3HWOZJ5W.js';import {h,d}from'./chunk-PY43JPWL.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-I6STSSAK.js';import {I,v}from'./chunk-SV3WKUNV.js';import {c,b as b$3}from'./chunk-PZF7YC35.js';import'./chunk-F3VMUQ7O.js';import'./chunk-QZQIPXIR.js';import {c as c$1}from'./chunk-AIZJT6AG.js';import'./chunk-NWQZW3Y6.js';import {g,a as a$1,b as b$4}from'./chunk-KXUWGHHN.js';import'./chunk-2KIPXYOB.js';import'./chunk-OG62YNVF.js';import {R,I as I$1}from'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import'./chunk-DXB73IDG.js';import {statSync,readFileSync,existsSync}from'fs';import {cpus}from'os';import {extname,basename,dirname}from'path';g();R();I();c();R();var Be=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".go",".rs",".java",".kt",".kts",".cs",".csx",".c",".cpp",".cc",".cxx",".h",".hpp",".swift",".tpl"];function fe(R){let t=[],r=[];for(let n of R){let i=extname(n).toLowerCase();Be.includes(i)?t.push(n):r.push(n);}return I$1.i("DEVAGENT","reindex_breakdown",{supported:t.length,heuristic:r.length,supportedSample:t.slice(0,3).map(n=>{let i=n.split(/[\\/]/);return i[i.length-1]})}),{supportedFiles:t,otherFiles:r}}e();var Ke=()=>new Promise(R=>setImmediate(R));function qe(){let R=b$4();return {maxConcurrency:R.devAgent?.maxConcurrency??3,memoryLimit:R.devAgent?.memoryLimit??256,priority:R.devAgent?.priority??7}}var ye=class extends b{parserAgent=null;indexerAgent=null;indexBatchSize;defaultBatchSize;defaultMaxConcurrency;defaultMemoryLimit;resourceMixin=new a;indexingLock=Promise.resolve();constructor(t){let r=qe();super("dev",{maxConcurrency:r.maxConcurrency,memoryLimit:r.memoryLimit,priority:r.priority}),this.defaultMaxConcurrency=this.capabilities.maxConcurrency,this.defaultMemoryLimit=this.capabilities.memoryLimit,this.defaultBatchSize=100,this.indexBatchSize=this.defaultBatchSize;}getIndexerAgent(){return this.indexerAgent}async onInitialize(){try{let t=a$1.getInstance();if(this.defaultBatchSize=t.getDevIndexBatchSize(),this.indexBatchSize=this.defaultBatchSize,t.shouldUseParser())try{this.parserAgent=new a$2,await this.parserAgent.initialize(),I$1.i("DEVAGENT","parser_init_ok");}catch(s){I$1.w("DEVAGENT","parser_unavail",{err:String(s)}),this.parserAgent=null;}let n=a$3()||process.cwd();I$1.i("DEVAGENT","indexer_ctx",{dir:n}),this.indexerAgent=new a$4,await this.indexerAgent.initialize();let i=v(n);h(n,i),I$1.i("DEVAGENT","global_ctx_set",{dir:n,branch:i}),I$1.i("DEVAGENT","indexer_init_ok"),this.tryEagerRoslynStart(n);}catch(t){throw I$1.e("DEVAGENT","subagent_init_fail",{err:String(t)}),t}a$5.subscribe(this.id,"task:implementation",async t=>{let r=t.data;if(r.targetAgent==="dev-agent"){let n={id:r.taskId,type:"implementation",priority:r.priority||5,payload:r,createdAt:Date.now()};await this.process(n);}}),a$5.subscribe(this.id,"resources:adjusted",t=>this.handleResourceAdjustment(t)),a$5.subscribe(this.id,"indexer:files:changed",async t=>{let r=t.data;r.files&&r.files.length>0&&r.source?.startsWith("git-watcher")&&(I$1.d("DEVAGENT","file_change_evt",{cnt:r.files.length,src:r.source}),await this.handleIncrementalReindex(r.files,r.repositoryPath));}),I$1.i("DEVAGENT","init_ready");}canProcessTask(t){return t.type==="index"||t.type==="implementation"||t.type==="refactor"||t.type==="dev"||t.type==="parse"}async handleMessage(t){I$1.d("DEVAGENT","recv_msg",{from:t.from,type:t.type});}async processTask(t){I$1.d("DEVAGENT","proc_task",{id:t.id,type:t.type});try{switch(t.type){case "index":return await this.handleIndexTask(t);case "implementation":return await this.handleImplementationTask(t);case "refactor":return await this.handleRefactorTask(t);case "parse":return await this.handleParseTask(t);default:return await this.delegateTask(t)}}catch(r){throw I$1.e("DEVAGENT","task_error",{err:String(r)}),r}}async handleIndexTask(t){let r=this.indexingLock,n;this.indexingLock=new Promise(s=>{n=s;}),await r;let i=t.payload;I$1.i("DEVAGENT","index_start",{dir:i.directory});try{if(!this.indexerAgent)throw new Error("Indexer agent not initialized");let s=v(i.directory);h(i.directory,s),this.indexerAgent.setProjectContext(i.directory),b$1(i.directory),I$1.d("DEVAGENT","set_ctx",{dir:i.directory,branch:s});let h$1={status:"started",directory:i.directory,incremental:i.incremental||!1,excludePatterns:i.excludePatterns||[],batchMode:i.batchMode||!1,timestamp:Date.now(),filesProcessed:0,entitiesExtracted:0,relationshipsCreated:0};a$5.publish("indexing:started",h$1,this.id);let m=await this.performRealIndexing(i);return {...h$1,...m,status:"completed",message:`Real indexing completed for ${i.directory}`}}finally{n();}}async handleImplementationTask(t){let r=t.payload;return I$1.i("DEVAGENT","impl_start",{desc:r.description||"task"}),{status:"completed",taskId:t.id,implementation:{description:r.description,targetAgent:"dev-agent",completed:true,timestamp:Date.now()}}}async handleRefactorTask(t){let r=t.payload;return I$1.i("DEVAGENT","refactor_start",{target:r.target||"code"}),{status:"completed",taskId:t.id,refactoring:{target:r.target,suggestions:[],completed:true,timestamp:Date.now()}}}async handleParseTask(t){let n=t.payload.filePath;if(!n)throw new Error("Parse task requires filePath in payload");if(I$1.d("DEVAGENT","parse_file",{file:n}),!this.parserAgent)return I$1.w("DEVAGENT","parser_unavail_empty"),{filePath:n,entities:[],relationships:[],error:"Parser not initialized",timestamp:Date.now()};try{let i=await this.parserAgent.parseFile(n,{});return I$1.d("DEVAGENT","parsed_ok",{file:n,cnt:i.entities?.length||0}),{filePath:n,entities:i.entities||[],relationships:i.relationships||[],timestamp:Date.now()}}catch(i){return I$1.e("DEVAGENT","parse_err",{file:n,err:String(i)}),{filePath:n,entities:[],relationships:[],error:String(i),timestamp:Date.now()}}}async delegateTask(t){return I$1.d("DEVAGENT","delegate_task",{id:t.id}),{status:"delegated",taskId:t.id,message:`Task ${t.id} delegated for processing`,timestamp:Date.now()}}async prepareIncrementalDiff(t,r){let n=await d(),i=await n.getAllIndexedFiles(),s=[];if(i.size===0)return {filesToProcess:t,deletedEntityIds:s,earlyReturn:null};let h=[],m=[],u=[];for(let o of t){let l=o.replace(/\\/g,"/"),p=i.get(l);if(p===void 0)m.push(o);else try{statSync(o).mtimeMs>p&&h.push(o);}catch{}}let E=new Set(t.map(o=>o.replace(/\\/g,"/")));for(let[o]of i)E.has(o)||u.push(o);if(u.length>0){I$1.i("DEVAGENT","Invalidating deleted files",{deleted:u.length});for(let o of u)try{let l=await n.deleteEntitiesByFilePath(o);s.push(...l),await n.deleteFileInfo(o);}catch(l){I$1.w("DEVAGENT","Failed to invalidate file",{file:o,error:l.message});}}for(let o of h)try{await n.deleteFileInfo(o);}catch{}let d$1=[...h,...m];return I$1.i("DEVAGENT","Smart incremental",{total:r,changed:h.length,new:m.length,deleted:u.length,toProcess:d$1.length,entitiesDeleted:s.length}),d$1.length===0?{filesToProcess:[],deletedEntityIds:s,earlyReturn:{filesProcessed:0,entitiesExtracted:0,relationshipsCreated:0,incrementalStats:{changedFiles:0,newFiles:0,deletedFiles:u.length,skippedFiles:r,deletedEntities:s.length}}}:{filesToProcess:d$1,deletedEntityIds:s,earlyReturn:null}}async initEmbeddingPipeline(t,r){if(t.provider==="llamacpp"){let{llamacppEmbeddingManager:n}=await import('./llamacpp-server-manager-UWVQUMVT.js'),{loadSemanticConfig:i,getDataDir:s}=await import('./config-paths-KTZQTAY2.js'),{existsSync:h,readdirSync:m}=await import('fs'),{join:u}=await import('path'),d=i()?.embedding?.llamacpp;if(d&&!n.getState().isRunning){let o=s(),l=[u(o,"hf-cache","multilingual-e5-base-Q8_0.gguf"),u(o,"llamacpp","models","multilingual-e5-base-Q8_0.gguf"),u(o,"models","multilingual-e5-base-Q8_0.gguf")],p=null;for(let a of l)if(h(a)){p=a;break}if(!p){let a=u(o,"hf-cache");if(h(a))try{let A=m(a).find(C=>C.endsWith(".gguf"));A&&(p=u(a,A));}catch{}}p&&(I$1.i("DEVAGENT","Starting llama-server for workers...",{port:8085,model:p}),await n.ensureRunning({modelPath:p,mode:"embedding",port:8085,contextSize:d.context_size||512,nGpuLayers:d.n_gpu_layers??99})?I$1.i("DEVAGENT","llama-server ready for workers"):I$1.w("DEVAGENT","llama-server start failed - embeddings may not work"));}}if(t.centralizedEmbeddings&&this.parserAgent)try{let{EmbeddingGenerator:n}=await import('./embedding-generator-3WPDCLZY.js'),{buildEmbeddingGeneratorOptions:i}=await import('./provider-config-SKCYXCWZ.js'),{loadSemanticConfig:s}=await import('./config-paths-KTZQTAY2.js'),{getConfig:h}=await import('./yaml-config-Z7563LIX.js'),m=s(),u=h(),E=i(t.provider,t.modelName,t.batchSize,m,u),d=new n(E),o=9e4;try{await Promise.race([d.initialize(),new Promise((l,p)=>setTimeout(()=>p(new Error(`TEI init timeout after ${o}ms`)),o))]);}catch(l){I$1.w("DEVAGENT","Centralized EmbeddingGenerator init timeout/fail, indexing will proceed without embeddings",{err:l.message});}await this.parserAgent.setEmbeddingGenerator(d),I$1.i("DEVAGENT","Centralized EmbeddingGenerator configured",{provider:t.provider,model:t.modelName});}catch(n){I$1.e("DEVAGENT","Failed to initialize centralized EmbeddingGenerator",{error:n.message});}}async initVectorProvider(t,r){if(!this.parserAgent)return;let{getProjectHash:n,getCurrentGitBranchOrDefault:i}=await import('./storage-paths-HDYH7WPM.js'),m=a$1.getInstance().getEmbeddingConfig().useLayeredIndex,u=n(t.directory),E=i(t.directory),d=null;try{if(m){let{getLayeredFaissProvider:o}=await import('./layered-faiss-provider-62CNW54X.js'),l=o();"initialize"in l&&typeof l.initialize=="function"&&(I$1.d("DEVAGENT","Initializing LayeredFaissProvider",{dir:t.directory,projectHash:u,branch:E}),await l.initialize(t.directory,u,E)),d=l;}else {let{initializeFaissProvider:o}=await import('./faiss-provider-SXB7FTLB.js'),l=await o();l&&(await l.setProjectContext(u,E),d=l);}}catch(o){I$1.w("DEVAGENT","Failed to get vector provider",{error:String(o)});}if(d){if(I$1.d("DEVAGENT","vector_provider_branch",{branch:E,layered:m}),this.parserAgent.setVectorProvider(d),I$1.i("DEVAGENT","Vector provider configured",{projectHash:u,dir:t.directory,layered:m}),r.length>0)try{let o=r.map(l=>l.startsWith("ent:")?l:`ent:${l}`);await d.remove(o),I$1.i("DEVAGENT","Removed embeddings for changed/deleted files",{count:o.length});}catch(o){I$1.w("DEVAGENT","Failed to remove embeddings",{error:o.message});}}else I$1.w("DEVAGENT","Vector provider not available - embeddings will not be saved");}async postIndexingCleanup(t,r,n,i,s,h,m){s.embFlush_start=Date.now()-i,s.commit_start=Date.now()-i;let u=(async()=>{if(!this.parserAgent)return;let d=this.parserAgent.getAccumulator();if(!d)return;let o=d.getPendingCount();if(o>0){I$1.i("DEVAGENT","Flushing pending embeddings to FAISS",{pending:o});try{let p=await d.flush();I$1.i("DEVAGENT","Embeddings flushed to FAISS",{flushed:p});}catch(p){I$1.e("DEVAGENT","Failed to flush embeddings",{error:p.message});}}let l=d.getStats();I$1.i("DEVAGENT","Embedding accumulator stats",{accumulated:l.accumulated,flushed:l.flushed,flushCount:l.flushCount,totalBytes:l.totalBytes});})(),E=(async()=>{try{let o=(await d()).getLibSQLAdapter?.();if(o?.createGraphCommit){let l=await o.createGraphCommit(`Index: ${r} files`);l&&I$1.i("DEVAGENT","graph_commit_created",{commit:l.slice(0,8),files:r,entities:n}),o.pruneAndGC?.(20)?.catch?.(p=>I$1.w("DEVAGENT","prune_gc_fail",{err:String(p)}));}}catch(d){I$1.w("DEVAGENT","graph_commit_failed",{error:d.message});}})();if(await Promise.all([u,E]),s.embFlush_end=Date.now()-i,s.commit_end=Date.now()-i,s.keepalive_start=Date.now()-i,this.parserAgent)try{let d=this.parserAgent.getTotalMemoryMB();I$1.i("DEVAGENT","Switching to keepalive mode (spawning ONE worker for incremental updates)",{memoryMB:d}),await this.parserAgent.enableKeepaliveMode();let o=this.parserAgent.getTotalMemoryMB();I$1.i("DEVAGENT","Keepalive mode enabled, ready for incremental updates",{memoryBeforeMB:d,memoryAfterMB:o}),I$1.flush();}catch(d){I$1.w("DEVAGENT","Failed to enable keepalive mode, falling back to shutdown",{error:d.message});try{await this.parserAgent.shutdown(),this.parserAgent=null;}catch{}}s.keepalive_end=Date.now()-i,c$1(true)&&I$1.i("DEVAGENT","gc_after_index");}buildPerfSummary(t,r,n,i,s,h,m,u){t.total=Date.now()-u,I$1.i("DEVAGENT","PERF_SUMMARY",{collectFiles:(t.collectFiles_end??0)-(t.collectFiles_start??0),destroyPools:(t.destroyPools_end??0)-(t.destroyPools_start??0),preSpawn:(t.preSpawn_end??0)-(t.preSpawn_start??0),parsing:(t.parsing_end??0)-(t.parsing_start??0),flush:(t.flush_end??0)-(t.flush_start??0),dataFiles:(t.dataFiles_end??0)-(t.dataFiles_start??0),swaggerLink:(t.swaggerLink_end??0)-(t.swaggerLink_start??0),embFlush:(t.embFlush_end??0)-(t.embFlush_start??0),keepalive:(t.keepalive_end??0)-(t.keepalive_start??0),total:t.total});}async performRealIndexing(t){let r=t.directory,n=t.excludePatterns||[],i=Date.now(),s={};I$1.i("DEVAGENT","Starting indexing",{directory:r,excludePatternsCount:n.length,samplePatterns:n.slice(0,5)});let h=t.incremental===true;s.collectFiles_start=Date.now()-i;let m=f(r,{excludePatterns:n,agentId:this.id}),u=null;!h&&this.parserAgent&&(s.preSpawnPrepare_start=Date.now()-i,u=(async()=>{I$1.i("DEVAGENT","Destroying existing worker pools for full reindex (parallel with collectFiles)"),await this.parserAgent.destroyWorkerPools(),await this.parserAgent.setPoolMode("per-language");let c=a$6();return c&&(this.parserAgent.setEmbeddingConfig(c),I$1.i("DEVAGENT","Embedding config passed to parser",{provider:c.provider,model:c.modelName})),{embeddingConfig:c}})());let E=await m,d=E.files;s.collectFiles_end=Date.now()-i,I$1.i("DEVAGENT","Files collected",{count:d.length,ms:s.collectFiles_end-s.collectFiles_start});let o=null;u&&(o=await u,s.preSpawnPrepare_end=Date.now()-i,I$1.i("DEVAGENT","PreSpawn preparation done (parallel)",{ms:s.preSpawnPrepare_end-s.preSpawnPrepare_start}));let l=[];if(h&&d.length>0){let c=await this.prepareIncrementalDiff(d,E.files.length);if(l=c.deletedEntityIds,c.earlyReturn)return I$1.i("DEVAGENT","No files changed, skipping indexing"),c.earlyReturn;d=c.filesToProcess;}let p=[],a=[];for(let c of d){let D=extname(c).toLowerCase();b$2(D)?p.push(c):a.push(c);}I$1.i("DEVAGENT","Files separated",{codeFiles:p.length,dataFiles:a.length});let f$1=process.env.MCP_DEBUG_MODE==="1",A=1/0;I$1.i("DEVAGENT","parser_batch",{files:p.length});let C=f$1?{batchSize:Math.max(1,Math.min(3,A)),useCache:false}:{},G=0,N=0,_=0,z=this.indexerAgent?.getIndexingStats()??{entitiesIndexed:0,relationshipsCreated:0},S=null;this.parserAgent&&(h?(await this.parserAgent.setPoolMode("universal"),I$1.i("DEVAGENT","Pool mode configured",{mode:"universal",isIncremental:h})):I$1.i("DEVAGENT","Pool mode configured",{mode:"per-language",isIncremental:h}));let T=o?.embeddingConfig??a$6();if(this.parserAgent&&T){h&&(this.parserAgent.setEmbeddingConfig(T),I$1.i("DEVAGENT","Embedding config passed to parser",{provider:T.provider,model:T.modelName}));let c=this.initEmbeddingPipeline(T,t);this.parserAgent&&this.parserAgent.setStreamingMode(true),!h&&p.length>0&&(s.preSpawn_start=Date.now()-i,S=this.parserAgent.preSpawnPools(p)),await c,await this.initVectorProvider(t,l);}let B=new Set,$=0,ee=0;this.parserAgent&&this.indexerAgent&&(this.parserAgent.setStreamingMode(true,(c,D,P,O)=>{if(!c.filePath||!c.entities||c.entities.length===0)return;B.add(c.filePath);let I=Date.now();this.indexerAgent.queueForIndexing(c.entities,c.filePath,c.relationships||[]),$+=Date.now()-I,ee++;}),I$1.i("DEVAGENT","Streaming mode enabled (batch accumulator)")),S&&(await S,s.preSpawn_end=Date.now()-i),s.parsing_start=Date.now()-i;let H=0,W=0,j=0,Q=p;for(let c=0;c<Q.length;c+=A){let D=Q.slice(c,Math.min(c+A,Q.length));try{if(this.parserAgent){let P={};for(let x of D){let v=extname(x).toLowerCase()||"(no ext)";P[v]=(P[v]||0)+1;}I$1.i("DEVAGENT","Sending batch to parser",{batchSize:D.length,batchIndex:c,extensions:P});let O={id:`parse-${Date.now()}-${c}`,type:"parse:batch",priority:8,payload:{files:D,options:C},createdAt:Date.now()},I=Date.now(),g=await this.parserAgent.process(O),w=Date.now()-I;H+=w;let y=Date.now();I$1.i("DEVAGENT","Parser batch completed",{batchSent:D.length,resultsReceived:g?.length||0,batchIndex:c,parseMs:w,filesPerSec:Math.round(D.length/w*1e3)}),I$1.flush();let V=0,b=0,te=0,M=0;for(let x of g||[])x?.filePath&&V++,Array.isArray(x?.entities)&&(x.entities.length>0?(b++,M+=x.entities.length):te++);I$1.d("DEVAGENT","batch_parse_analysis",{batch:c,results:g?.length||0,withPath:V,withEnts:b,empty:te,total:M});let F=new Map;for(let x of g||[]){let v=x?.filePath;if(!v)continue;let Z=F.get(v)??{entities:[],relationships:[]};if(Array.isArray(x.entities)&&Z.entities.push(...x.entities),Array.isArray(x.relationships))for(let L of x.relationships)L?.from&&L.to&&L.type&&Z.relationships.push({from:L.from,to:L.to,type:L.type,targetFile:v});F.set(v,Z);}let K=0,we=0;for(let x of g||[])Array.isArray(x?.relationships)&&x.relationships.length>0&&(we++,K+=x.relationships.length);I$1.d("DEVAGENT","batch_rels",{batch:c,withRels:we,total:K}),I$1.i("DEVAGENT","Files ready for indexing",{uniqueFiles:F.size,batchIndex:c,totalEntities:M,totalRelationships:K}),I$1.d("DEVAGENT","batch_summary",{batch:c,sent:D.length,results:g?.length||0,unique:F.size}),W+=Date.now()-y;let ke=Date.now(),Ie=8,oe=Array.from(F.entries()).filter(([x])=>!B.has(x));oe.length>0&&I$1.i("DEVAGENT","Post-batch indexing (non-streamed files)",{total:F.size,alreadyStreamed:B.size,remaining:oe.length});let X=[],le=0;for(let[x,v]of oe){let Z={id:`index-entities-${Date.now()}-${c}-${x}`,type:"index:entities",priority:7,payload:{entities:v.entities,relationships:v.relationships,filePath:x},createdAt:Date.now()},L=(async()=>{try{return {result:await this.indexerAgent?.enqueue(Z),error:null}}catch(Y){return I$1.w("DEVAGENT","index_file_fail",{file:x,err:Y.message}),{result:null,error:Y}}})();if(X.push(L),le++,le>=Ie){let Y=await Promise.all(X);for(let{result:ce}of Y)ce&&(G+=ce.entitiesIndexed||0,N+=ce.relationshipsCreated||0,_+=1);X=[],le=0,await Ke();}}if(X.length>0){let x=await Promise.all(X);for(let{result:v}of x)v&&(G+=v.entitiesIndexed||0,N+=v.relationshipsCreated||0,_+=1);}j+=Date.now()-ke;}else {let P=[],O=[];for(let g of D){let w=extname(g).toLowerCase(),y=basename(g),V=y.replace(/\.[^/.]+$/,""),b=w.slice(1)||y,te=b$2(w),M=c$2(w)||c$2("."+y.toLowerCase());if(!te&&!M)continue;let F,K;if(M)try{K=readFileSync(g,"utf-8"),F=b$3(K);}catch{}P.push({name:y,type:"file",filePath:g,language:b,location:{start:{line:1,column:0,index:0},end:{line:1,column:0,index:0}},metadata:{language:b,path:g,isDataFile:M,contentHash:F}}),!M&&(P.push({name:V,type:"module",filePath:g,language:b,location:{start:{line:1,column:0,index:0},end:{line:100,column:0,index:0}},metadata:{language:b,moduleType:"file"}}),b==="py"&&/^[A-Z]/.test(V)&&P.push({name:V,type:"class",filePath:g,language:"python",location:{start:{line:5,column:0,index:0},end:{line:50,column:0,index:0}},metadata:{language:"python",visibility:"public"}}),(b==="kt"||b==="kts"||b==="java")&&/^[A-Z]/.test(V)&&P.push({name:V,type:"class",filePath:g,language:b==="java"?"java":"kotlin",location:{start:{line:5,column:0,index:0},end:{line:50,column:0,index:0}},metadata:{language:b,visibility:"public"}}),(b==="js"||b==="ts")&&!g.includes(".test.")&&!g.includes(".spec.")&&P.push({name:"export_default",type:"function",filePath:g,language:b==="ts"?"typescript":"javascript",location:{start:{line:10,column:0,index:0},end:{line:30,column:0,index:0}},metadata:{language:b,exported:!0}}));}for(let g of P)if(g.type==="file"){let w=P.find(y=>y.type==="module"&&y.filePath===g.filePath);w&&O.push({from:g.name,to:w.name,type:"contains"});}for(let g of P)if(g.type==="module"){let w=P.filter(y=>(y.type==="class"||y.type==="function")&&y.filePath===g.filePath);for(let y of w)O.push({from:g.name,to:y.name,type:y.type==="class"?"defines_class":"defines_function",sourceFile:g.filePath});}for(let g of P)if(g.type==="class"){let w=P.filter(y=>y.type==="function"&&y.filePath===g.filePath);for(let y of w)O.push({from:g.name,to:y.name,type:"has_method",sourceFile:g.filePath});}let I=new Map;for(let g of P){if(!g.filePath)continue;let w=I.get(g.filePath)??{entities:[],relationships:[]};w.entities.push(g),I.set(g.filePath,w);}for(let g of O){let w=g.sourceFile||null;if(!w)continue;let y=I.get(w)??{entities:[],relationships:[]};y.relationships.push({from:g.from,to:g.to,type:g.type,targetFile:g.targetFile}),I.set(w,y);}for(let[g,w]of I.entries()){if(!w.entities.length)continue;let y={id:`index-entities-${Date.now()}-${c}-${g}`,type:"index:entities",priority:7,payload:{entities:w.entities,relationships:w.relationships,filePath:g},createdAt:Date.now()};try{let b=await this.indexerAgent?.process(y);b&&(G+=b.entitiesIndexed||0,N+=b.relationshipsCreated||0,_+=1);}catch(V){I$1.w("DEVAGENT","idx_fail",{file:g,err:String(V)});}}}}catch(P){I$1.e("DEVAGENT","batch_err",{batch:c,cnt:D.length,err:P instanceof Error?P.message:String(P)});}((c+A)%500===0||c+A>=Q.length)&&I$1.i("DEVAGENT","progress",{done:_,total:Q.length});}s.parsing_end=Date.now()-i;let k=(s.parsing_end??0)-(s.parsing_start??0),Ae=Math.max(0,H-$);I$1.i("DEVAGENT","PARSING_PHASE_BREAKDOWN",{totalMs:k,workerParseMs:H,streamingQueueMs:$,streamingCallbacks:ee,estimatedPureWorkerMs:Ae,mainProcessMs:W,mainIndexMs:j,overheadMs:k-H-W-j,pureWorkerPct:k>0?`${Math.round(Ae/k*100)}%`:"0%",streamingPct:k>0?`${Math.round($/k*100)}%`:"0%",mainProcessPct:k>0?`${Math.round(W/k*100)}%`:"0%",mainIndexPct:k>0?`${Math.round(j/k*100)}%`:"0%"}),this.parserAgent&&this.parserAgent.setStreamingMode(false),s.flush_start=Date.now()-i;let se=0,ae=0;if(this.indexerAgent){let c=this.indexerAgent.getPendingBatchStats();c.files>0&&I$1.i("DEVAGENT","Flushing remaining batch accumulator",c),await this.indexerAgent.flushPendingBatch();let D=this.indexerAgent.getIndexingStats();se=D.entitiesIndexed-z.entitiesIndexed,ae=D.relationshipsCreated-z.relationshipsCreated,I$1.i("DEVAGENT","Streaming mode disabled, code parsing complete",{streamedFiles:B.size,deltaEntities:se,deltaRelationships:ae});}if(G=se,N=ae,_+=B.size,s.flush_end=Date.now()-i,a.length>0){s.dataFiles_start=Date.now()-i;let c=await this.processDataFilesParallel(a);G+=c.entities,_+=c.files,s.dataFiles_end=Date.now()-i;}s.swaggerLink_start=Date.now()-i;try{let{resolveSwaggerLinks:c}=await import('./indexing-pipeline-L7C543N4.js'),D=await c();D>0&&(N+=D,I$1.i("DEVAGENT","swagger_links_created",{count:D}));}catch(c){I$1.w("DEVAGENT","swagger_link_skip",{error:c.message});}return s.swaggerLink_end=Date.now()-i,s.indexing_end=Date.now()-i,I$1.i("DEVAGENT","index_done",{files:_,total:d.length,entities:G,rels:N,totalMs:s.indexing_end}),I$1.i("DEVAGENT","=== ALL BATCH PROCESSING COMPLETE ===",{totalBatches:Math.ceil(p.length/A),codeFiles:p.length,dataFiles:a.length,filesProcessed:_,totalEntities:G,totalRelationships:N,perfTimings:s}),I$1.flush(),await this.postIndexingCleanup(p,_,G,i,s,A,a),this.buildPerfSummary(s,p,a,_,G,N,A,i),{filesProcessed:_,entitiesExtracted:G,relationshipsCreated:N,totalFiles:d.length,perfTimings:s}}handleResourceAdjustment(t){this.resourceMixin.handleResourceAdjustment.call(this,t);}adjustConcurrency(t){let r=Math.max(1,Math.min(this.defaultMaxConcurrency*2,Math.floor(t)));this.capabilities.maxConcurrency!==r&&(I$1.d("DEVAGENT","adj_concurrency",{from:this.capabilities.maxConcurrency,to:r}),this.capabilities.maxConcurrency=r);}adjustBatchSize(t){let r=Math.max(.5,Math.min(2,t/this.defaultMemoryLimit)),n=Math.max(10,Math.round(this.defaultBatchSize*r));this.indexBatchSize!==n&&(I$1.d("DEVAGENT","adj_batch",{from:this.indexBatchSize,to:n}),this.indexBatchSize=n);}tryEagerRoslynStart(t){let r=t,n=null;for(let i=0;i<5&&(n=c$3(r),!n);i++){let s=dirname(r);if(s===r)break;r=s;}n&&(I$1.i("DEVAGENT","roslyn_eager_start",{sln:n}),f$1(n).then(i=>{i?I$1.i("DEVAGENT","roslyn_eager_ready",{sln:n}):I$1.w("DEVAGENT","roslyn_eager_fail",{sln:n});}).catch(i=>{I$1.w("DEVAGENT","roslyn_eager_error",{sln:n,err:String(i)});}));}async handleIncrementalReindex(t,r){if(!this.parserAgent||!this.indexerAgent){I$1.w("DEVAGENT","skip_reindex_no_agents");return}let n=Date.now();I$1.i("DEVAGENT","incr_reindex_start",{files:t.length});let{supportedFiles:i,otherFiles:s}=fe(t);if(i.length===0&&s.length===0){I$1.i("DEVAGENT","no_files_to_reindex");return}let h=[],m=[];for(let a of t)existsSync(a)?h.push(a):m.push(a);try{if(m.length>0){let a=await d();for(let f of m)try{await a.deleteEntitiesByFilePath(f),await a.deleteFileInfo(f);}catch{}I$1.i("DEVAGENT","incr_cleanup",{deleted:m.length,existing:h.length});}}catch(a){I$1.w("DEVAGENT","incr_cleanup_fail",{error:a.message});}let{supportedFiles:u,otherFiles:E}=fe(h),d$1=0,o=0,l=a$6();if(l&&this.parserAgent){this.parserAgent.setEmbeddingConfig(l),I$1.d("DEVAGENT","incr_embedding_config",{provider:l.provider});let A=a$1.getInstance().getEmbeddingConfig().useLayeredIndex,C=r||a$3()||process.cwd(),{getProjectHash:G,getCurrentGitBranchOrDefault:N}=await import('./storage-paths-HDYH7WPM.js'),_=G(C),z=N(C);try{if(A){let{getLayeredFaissProvider:S}=await import('./layered-faiss-provider-62CNW54X.js'),T=S();"initialize"in T&&typeof T.initialize=="function"&&await T.initialize(C,_,z),this.parserAgent.setVectorProvider(T),I$1.i("DEVAGENT","incr_vector_provider",{branch:z,layered:!0});}else {let{initializeFaissProvider:S}=await import('./faiss-provider-SXB7FTLB.js'),T=await S();T&&(await T.setProjectContext(_,z),this.parserAgent.setVectorProvider(T),I$1.i("DEVAGENT","incr_vector_provider",{branch:z,layered:!1}));}}catch(S){I$1.w("DEVAGENT","incr_vector_provider_fail",{error:String(S)});}if(I$1.d("DEVAGENT","incr_embedding_config",{provider:l.provider,centralized:l.centralizedEmbeddings,batchSize:l.batchSize}),l.centralizedEmbeddings)try{let{EmbeddingGenerator:S}=await import('./embedding-generator-3WPDCLZY.js'),{buildEmbeddingGeneratorOptions:T}=await import('./provider-config-SKCYXCWZ.js'),{loadSemanticConfig:B}=await import('./config-paths-KTZQTAY2.js'),{getConfig:$}=await import('./yaml-config-Z7563LIX.js'),ee=B(),H=$(),W=T(l.provider,l.modelName,l.batchSize,ee,H),j=new S(W);await j.initialize(),await this.parserAgent.setEmbeddingGenerator(j),I$1.i("DEVAGENT","incr_embedding_generator",{provider:l.provider,model:l.modelName});}catch(S){I$1.w("DEVAGENT","incr_embedding_generator_fail",{error:S.message});}}if(u.length>0)try{I$1.i("DEVAGENT","incr_parseBatch_start",{files:u.length});let a=await this.parserAgent.parseBatch(u,{});I$1.i("DEVAGENT","incr_parseBatch_done",{files:u.length,results:a.length});for(let f of a)if(f.entities&&f.entities.length>0)try{this.indexerAgent.queueForIndexing(f.entities,f.filePath,f.relationships),d$1++;}catch(A){I$1.e("DEVAGENT","queue_fail",{file:f.filePath,err:String(A)}),o++;}}catch(a){I$1.e("DEVAGENT","batch_parse_fail",{files:u.length,err:String(a)}),o+=u.length;}for(let a of E)try{let f=a$7(a);f.entities.length>0&&(this.indexerAgent.queueForIndexing(f.entities,a,f.relationships),d$1++);}catch(f){I$1.e("DEVAGENT","heuristic_fail",{file:a,err:String(f)}),o++;}try{let a=await this.indexerAgent.flushPendingBatch();I$1.i("DEVAGENT","incr_batch_flush",{entities:a.entities,relationships:a.relationships,files:a.files});}catch(a){I$1.e("DEVAGENT","incr_flush_fail",{err:String(a)});}let p=Date.now()-n;if(I$1.i("DEVAGENT","incr_reindex_done",{success:d$1,errors:o,deleted:m.length,ms:p}),this.parserAgent){let a=this.parserAgent.getAccumulator();if(a){let f=a.getPendingCount();if(f>0){I$1.i("DEVAGENT","Flushing incremental embeddings to FAISS",{pending:f});try{let A=await a.flush();I$1.i("DEVAGENT","Incremental embeddings flushed",{flushed:A});}catch(A){I$1.e("DEVAGENT","Failed to flush incremental embeddings",{error:A.message});}}try{if(a$1.getInstance().getEmbeddingConfig().useLayeredIndex){let{getLayeredFaissProvider:N}=await import('./layered-faiss-provider-62CNW54X.js'),_=N();"save"in _&&typeof _.save=="function"&&(await _.save(),I$1.i("DEVAGENT","Saved layered FAISS index after incremental"));}}catch(A){I$1.w("DEVAGENT","Failed to save FAISS index after incremental",{error:A.message});}}}try{let f=(await d()).getLibSQLAdapter?.();if(f?.createGraphCommit&&d$1>0){let A=await f.createGraphCommit(`Incremental: ${d$1} files`);A&&I$1.i("DEVAGENT","incr_commit_created",{commit:A.slice(0,8),files:d$1}),f.pruneAndGC?.(20)?.catch?.(C=>I$1.w("DEVAGENT","incr_prune_gc_fail",{err:String(C)}));}}catch(a){I$1.w("DEVAGENT","incr_commit_failed",{error:a.message});}if(this.parserAgent)try{await this.parserAgent.killIfMemoryHigh(1024)&&(this.parserAgent=null,I$1.i("DEVAGENT","Parser workers killed (memory > 1GB after incremental)"));}catch{}c$1(true)&&I$1.d("DEVAGENT","gc_after_incremental"),a$5.publish("indexer:incremental:complete",{filesProcessed:d$1,errors:o,elapsedMs:p,source:"dev-agent"},this.id),d().then(a=>a.runGenerationGC()).then(a=>{(a.entities>0||a.tokens>0)&&I$1.i("DEVAGENT","gen_gc_complete",a);}).catch(a=>I$1.w("DEVAGENT","gen_gc_fail",{error:a.message}));}async processDataFilesParallel(t){if(t.length===0||!this.indexerAgent)return {entities:0,files:0};let r=Date.now();I$1.i("DEVAGENT","Processing data files in PARALLEL",{count:t.length});let n=Math.max(32,cpus().length*4),i=[];for(let E=0;E<t.length;E+=n){let d=t.slice(E,E+n),o=await Promise.all(d.map(async l=>{try{return a$7(l)}catch{return null}}));for(let l of o)l&&l.entities.length>0&&i.push(l);}let s=Math.max(32,cpus().length*2),h=0,m=0;for(let E=0;E<i.length;E+=s){let o=i.slice(E,E+s).map(async p=>{try{return {entities:(await this.indexerAgent.indexEntities(p.entities,p.filePath,p.relationships)).entitiesIndexed,success:!0}}catch{return {entities:0,success:false}}}),l=await Promise.all(o);for(let p of l)p.success&&(h+=p.entities,m++);}let u=Date.now()-r;return I$1.i("DEVAGENT","Data files processed in PARALLEL",{files:m,entities:h,elapsedMs:u,filesPerSec:Math.round(m/u*1e3)}),{entities:h,files:m}}getEmbeddingStats(){return this.parserAgent?.getEmbeddingPoolStats?.()??null}async onShutdown(){I$1.i("DEVAGENT","shutdown_start"),this.parserAgent&&await this.parserAgent.shutdown(),this.indexerAgent&&await this.indexerAgent.shutdown();}},vt=new ye;export{ye as DevAgent,vt as devAgent};
|