ultracode 5.3.0 → 5.5.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 (57) hide show
  1. package/dist/chunks/analysis-tool-handlers-H2RXLDPX.js +817 -0
  2. package/dist/chunks/analysis-tool-handlers-RJZAR6VT.js +817 -0
  3. package/dist/chunks/analysis-tool-handlers-Z2RF24T7.js +13 -0
  4. package/dist/chunks/autodoc-tool-handlers-CV5JEQUA.js +1112 -0
  5. package/dist/chunks/autodoc-tool-handlers-EHTNCH6I.js +1112 -0
  6. package/dist/chunks/autodoc-tool-handlers-MECXQJ2K.js +138 -0
  7. package/dist/chunks/chaos-CO7TOBOJ.js +18 -0
  8. package/dist/chunks/chaos-VM2PXERO.js +1573 -0
  9. package/dist/chunks/chaos-W3XRVJ7K.js +1564 -0
  10. package/dist/chunks/chunk-6K37BWK5.js +439 -0
  11. package/dist/chunks/chunk-EALTCYHZ.js +10 -0
  12. package/dist/chunks/chunk-FTBE7VMY.js +316 -0
  13. package/dist/chunks/chunk-KBW6LRQP.js +322 -0
  14. package/dist/chunks/chunk-NKUHX4CU.js +5 -0
  15. package/dist/chunks/chunk-NZFF4DQ4.js +3179 -0
  16. package/dist/chunks/chunk-RGP5UVQ7.js +3179 -0
  17. package/dist/chunks/chunk-RMZXFGQZ.js +322 -0
  18. package/dist/chunks/chunk-UG44F23Y.js +316 -0
  19. package/dist/chunks/chunk-V2SCB5H5.js +4403 -0
  20. package/dist/chunks/chunk-V6JAQNM3.js +1 -0
  21. package/dist/chunks/chunk-XFGXM4CR.js +4403 -0
  22. package/dist/chunks/dev-agent-JVIGBMHQ.js +1 -0
  23. package/dist/chunks/dev-agent-TRVP5U6N.js +1624 -0
  24. package/dist/chunks/dev-agent-Y5G5WKQ4.js +1624 -0
  25. package/dist/chunks/graph-storage-factory-AYZ57YSL.js +13 -0
  26. package/dist/chunks/graph-storage-factory-GTAIJEI5.js +1 -0
  27. package/dist/chunks/graph-storage-factory-T2WO5QVG.js +13 -0
  28. package/dist/chunks/incremental-updater-KDIQGAUU.js +14 -0
  29. package/dist/chunks/incremental-updater-OJRSTO3Q.js +1 -0
  30. package/dist/chunks/incremental-updater-SBEBH7KF.js +14 -0
  31. package/dist/chunks/indexer-agent-H3QIEL3Z.js +21 -0
  32. package/dist/chunks/indexer-agent-KHF5JMV7.js +21 -0
  33. package/dist/chunks/indexer-agent-SHJD6Z77.js +1 -0
  34. package/dist/chunks/indexing-pipeline-J6Z4BHKF.js +1 -0
  35. package/dist/chunks/indexing-pipeline-OY3337QN.js +249 -0
  36. package/dist/chunks/indexing-pipeline-WCXIDMAP.js +249 -0
  37. package/dist/chunks/merge-agent-LSUBDJB2.js +2481 -0
  38. package/dist/chunks/merge-agent-MJEW3HWU.js +2481 -0
  39. package/dist/chunks/merge-agent-O45OXF33.js +11 -0
  40. package/dist/chunks/merge-tool-handlers-BDSVNQVZ.js +277 -0
  41. package/dist/chunks/merge-tool-handlers-HP7DRBXJ.js +1 -0
  42. package/dist/chunks/merge-tool-handlers-RUJAKE3D.js +277 -0
  43. package/dist/chunks/pattern-tool-handlers-L62W3CXR.js +1549 -0
  44. package/dist/chunks/pattern-tool-handlers-SAHX2CVW.js +13 -0
  45. package/dist/chunks/query-agent-3TWDFIMT.js +191 -0
  46. package/dist/chunks/query-agent-HXQ3BMMF.js +191 -0
  47. package/dist/chunks/query-agent-USMC2GNG.js +1 -0
  48. package/dist/chunks/semantic-agent-MQCAWIAB.js +6381 -0
  49. package/dist/chunks/semantic-agent-NDGR3NAK.js +6381 -0
  50. package/dist/chunks/semantic-agent-S4ZL6GZC.js +137 -0
  51. package/dist/index.js +17 -17
  52. package/dist/roslyn-addon/.build-hash +1 -1
  53. package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
  54. package/dist/roslyn-addon/ILGPU.dll +0 -0
  55. package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
  56. package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
  57. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ export { configureGraphStorage, getGraphStorage, getLibSQLAdapter, handleDatabaseCorruption, initializeGraphStorage, isDatabaseCorruptionError, isStorageReady, resetGraphStorage, setGlobalProjectContext } from './chunk-XFGXM4CR.js';
2
+ import './chunk-HNDYLCWI.js';
3
+ import './chunk-CTXFPNDA.js';
4
+ import './chunk-TJSOOFXA.js';
5
+ import './chunk-AIZUHUK6.js';
6
+ import './chunk-L2X4HRXI.js';
7
+ import './chunk-ZD54CMKT.js';
8
+ import './chunk-HEMJHRHZ.js';
9
+ import './chunk-VCCBEJQ5.js';
10
+ export { DatabaseCorruptionError, SUPPORTED_DIMENSIONS, getEmbeddingColumn, normalizeToSupportedDimension } from './chunk-UN27MREV.js';
11
+ import './chunk-NAQKA54E.js';
12
+ //# sourceMappingURL=graph-storage-factory-AYZ57YSL.js.map
13
+ //# sourceMappingURL=graph-storage-factory-AYZ57YSL.js.map
@@ -0,0 +1 @@
1
+ export{c as configureGraphStorage,d as getGraphStorage,f as getLibSQLAdapter,j as handleDatabaseCorruption,e as initializeGraphStorage,k as isDatabaseCorruptionError,i as isStorageReady,g as resetGraphStorage,h as setGlobalProjectContext}from'./chunk-6K37BWK5.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-3X7W3DL2.js';import'./chunk-GVQNDMAK.js';import'./chunk-PZF7YC35.js';import'./chunk-4BI7EBPQ.js';export{g as DatabaseCorruptionError,b as SUPPORTED_DIMENSIONS,c as getEmbeddingColumn,d as normalizeToSupportedDimension}from'./chunk-F45ISXCP.js';import'./chunk-DXB73IDG.js';
@@ -0,0 +1,13 @@
1
+ export { configureGraphStorage, getGraphStorage, getLibSQLAdapter, handleDatabaseCorruption, initializeGraphStorage, isDatabaseCorruptionError, isStorageReady, resetGraphStorage, setGlobalProjectContext } from './chunk-V2SCB5H5.js';
2
+ import './chunk-HNDYLCWI.js';
3
+ import './chunk-CTXFPNDA.js';
4
+ import './chunk-TJSOOFXA.js';
5
+ import './chunk-AIZUHUK6.js';
6
+ import './chunk-L2X4HRXI.js';
7
+ import './chunk-ZD54CMKT.js';
8
+ import './chunk-HEMJHRHZ.js';
9
+ import './chunk-VCCBEJQ5.js';
10
+ export { DatabaseCorruptionError, SUPPORTED_DIMENSIONS, getEmbeddingColumn, normalizeToSupportedDimension } from './chunk-UN27MREV.js';
11
+ import './chunk-NAQKA54E.js';
12
+ //# sourceMappingURL=graph-storage-factory-T2WO5QVG.js.map
13
+ //# sourceMappingURL=graph-storage-factory-T2WO5QVG.js.map
@@ -0,0 +1,14 @@
1
+ export { detectChanges, extractReferences, extractSections, markDeleted, mergeWithExisting, updateAllModuleDocs, updateModuleDoc, updateReferences } from './chunk-FTBE7VMY.js';
2
+ import './chunk-V2SCB5H5.js';
3
+ import './chunk-HNDYLCWI.js';
4
+ import './chunk-CTXFPNDA.js';
5
+ import './chunk-TJSOOFXA.js';
6
+ import './chunk-AIZUHUK6.js';
7
+ import './chunk-L2X4HRXI.js';
8
+ import './chunk-ZD54CMKT.js';
9
+ import './chunk-HEMJHRHZ.js';
10
+ import './chunk-VCCBEJQ5.js';
11
+ import './chunk-UN27MREV.js';
12
+ import './chunk-NAQKA54E.js';
13
+ //# sourceMappingURL=incremental-updater-KDIQGAUU.js.map
14
+ //# sourceMappingURL=incremental-updater-KDIQGAUU.js.map
@@ -0,0 +1 @@
1
+ export{c as detectChanges,a as extractReferences,b as extractSections,f as markDeleted,e as mergeWithExisting,h as updateAllModuleDocs,g as updateModuleDoc,d as updateReferences}from'./chunk-EALTCYHZ.js';import'./chunk-6K37BWK5.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-3X7W3DL2.js';import'./chunk-GVQNDMAK.js';import'./chunk-PZF7YC35.js';import'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import'./chunk-DXB73IDG.js';
@@ -0,0 +1,14 @@
1
+ export { detectChanges, extractReferences, extractSections, markDeleted, mergeWithExisting, updateAllModuleDocs, updateModuleDoc, updateReferences } from './chunk-UG44F23Y.js';
2
+ import './chunk-XFGXM4CR.js';
3
+ import './chunk-HNDYLCWI.js';
4
+ import './chunk-CTXFPNDA.js';
5
+ import './chunk-TJSOOFXA.js';
6
+ import './chunk-AIZUHUK6.js';
7
+ import './chunk-L2X4HRXI.js';
8
+ import './chunk-ZD54CMKT.js';
9
+ import './chunk-HEMJHRHZ.js';
10
+ import './chunk-VCCBEJQ5.js';
11
+ import './chunk-UN27MREV.js';
12
+ import './chunk-NAQKA54E.js';
13
+ //# sourceMappingURL=incremental-updater-SBEBH7KF.js.map
14
+ //# sourceMappingURL=incremental-updater-SBEBH7KF.js.map
@@ -0,0 +1,21 @@
1
+ export { IndexerAgent } from './chunk-NZFF4DQ4.js';
2
+ import './chunk-JPI46FLQ.js';
3
+ import './chunk-IGUCJL3R.js';
4
+ import './chunk-V2SCB5H5.js';
5
+ import './chunk-HNDYLCWI.js';
6
+ import './chunk-CTXFPNDA.js';
7
+ import './chunk-TJSOOFXA.js';
8
+ import './chunk-AIZUHUK6.js';
9
+ import './chunk-L2X4HRXI.js';
10
+ import './chunk-ZD54CMKT.js';
11
+ import './chunk-HEMJHRHZ.js';
12
+ import './chunk-IMQ6WSJV.js';
13
+ import './chunk-GMVGCSNU.js';
14
+ import './chunk-XV6GNSLC.js';
15
+ import './chunk-F7CKCMXI.js';
16
+ import './chunk-BMHPPH2B.js';
17
+ import './chunk-VCCBEJQ5.js';
18
+ import './chunk-UN27MREV.js';
19
+ import './chunk-NAQKA54E.js';
20
+ //# sourceMappingURL=indexer-agent-H3QIEL3Z.js.map
21
+ //# sourceMappingURL=indexer-agent-H3QIEL3Z.js.map
@@ -0,0 +1,21 @@
1
+ export { IndexerAgent } from './chunk-RGP5UVQ7.js';
2
+ import './chunk-JPI46FLQ.js';
3
+ import './chunk-IGUCJL3R.js';
4
+ import './chunk-XFGXM4CR.js';
5
+ import './chunk-HNDYLCWI.js';
6
+ import './chunk-CTXFPNDA.js';
7
+ import './chunk-TJSOOFXA.js';
8
+ import './chunk-AIZUHUK6.js';
9
+ import './chunk-L2X4HRXI.js';
10
+ import './chunk-ZD54CMKT.js';
11
+ import './chunk-HEMJHRHZ.js';
12
+ import './chunk-IMQ6WSJV.js';
13
+ import './chunk-GMVGCSNU.js';
14
+ import './chunk-XV6GNSLC.js';
15
+ import './chunk-F7CKCMXI.js';
16
+ import './chunk-BMHPPH2B.js';
17
+ import './chunk-VCCBEJQ5.js';
18
+ import './chunk-UN27MREV.js';
19
+ import './chunk-NAQKA54E.js';
20
+ //# sourceMappingURL=indexer-agent-KHF5JMV7.js.map
21
+ //# sourceMappingURL=indexer-agent-KHF5JMV7.js.map
@@ -0,0 +1 @@
1
+ export{a as IndexerAgent}from'./chunk-NKUHX4CU.js';import'./chunk-7YC4KTAW.js';import'./chunk-V5VLOVE7.js';import'./chunk-6K37BWK5.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-3X7W3DL2.js';import'./chunk-GVQNDMAK.js';import'./chunk-PZF7YC35.js';import'./chunk-AIZJT6AG.js';import'./chunk-NWQZW3Y6.js';import'./chunk-KXUWGHHN.js';import'./chunk-2KIPXYOB.js';import'./chunk-OG62YNVF.js';import'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import'./chunk-DXB73IDG.js';
@@ -0,0 +1 @@
1
+ import {f,e,d as d$1}from'./chunk-WZJJIJJU.js';import {d}from'./chunk-6K37BWK5.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-3X7W3DL2.js';import'./chunk-GVQNDMAK.js';import'./chunk-PZF7YC35.js';import {a}from'./chunk-F3VMUQ7O.js';import'./chunk-OG62YNVF.js';import {R as R$1,I}from'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import {a as a$1,f as f$1}from'./chunk-DXB73IDG.js';import {statSync}from'fs';R$1();async function R(e){let{directory:n,excludePatterns:i=[],incremental:s=false,agentId:a}=e;I.i("DEVAGENT","Starting indexing",{directory:n,excludePatternsCount:i.length,samplePatterns:i.slice(0,5)});let d=(await f(n,{excludePatterns:i,agentId:a})).files;return I.i("DEVAGENT","Files collected",{count:d.length}),{directory:n,excludePatterns:i,isIncremental:s,agentId:a,allFiles:d,deletedEntityIds:[]}}async function _(e){if(!e.isIncremental||e.allFiles.length===0)return null;let i=await(await d()).getAllIndexedFiles();if(i.size===0)return {changedFiles:[],newFiles:e.allFiles,deletedFiles:[],unchangedFiles:[]};let s=[],a=[],r=[];for(let o of e.allFiles){let f=o.replace(/\\/g,"/"),g=i.get(f);if(g===void 0)a.push(o);else try{statSync(o).mtimeMs>g?s.push(o):r.push(o);}catch{r.push(o);}}let d$1=new Set(e.allFiles.map(o=>o.replace(/\\/g,"/"))),c=[];for(let[o]of i)d$1.has(o)||c.push(o);return I.i("DEVAGENT","Smart incremental analysis",{total:e.allFiles.length,changed:s.length,new:a.length,deleted:c.length,unchanged:r.length}),{changedFiles:s,newFiles:a,deletedFiles:c,unchangedFiles:r}}async function T(e){if(e.length===0)return [];I.i("DEVAGENT","Invalidating deleted files",{fileCount:e.length});let n=await d(),i=[];for(let s of e)try{let a=await n.deleteEntitiesByFilePath(s);i.push(...a),await n.deleteFileInfo(s);}catch(a$1){let r=a(a$1);I.w("DEVAGENT","Failed to invalidate file",{file:s,error:r.message,stack:r.stack});}return I.i("DEVAGENT","Files invalidated",{entityCount:i.length}),i}async function $(e,n){let i=[...n.changedFiles,...n.deletedFiles],s=await T(i),a=[...n.changedFiles,...n.newFiles];return I.i("DEVAGENT","Files to process after analysis",{toProcess:a.length,entitiesDeleted:s.length}),a.length===0&&I.i("DEVAGENT","No files changed, skipping indexing"),{...e,allFiles:a,deletedEntityIds:s}}function v(e$1){let n=[],i=[],{extname:s}=a$1("path"),{isCodeExtension:a}=(e(),f$1(d$1));for(let r of e$1){let d=s(r).toLowerCase();a(d)?n.push(r):i.push(r);}return I.i("DEVAGENT","Files separated",{codeFiles:n.length,dataFiles:i.length}),{codeFiles:n,dataFiles:i}}async function L(){let e=await d(),n=await e.getAllEntities();if(!n.some(s=>s.metadata?.swaggerType))return 0;I.i("DEVAGENT","swagger_link_start",{totalEntities:n.length});try{let{analyzeSwaggerCodeLinks:s,buildSwaggerRelationships:a}=await import('./swagger-code-linker-2ZCSRI2C.js'),r=s(n);if(r.producers.length+r.consumers.length+r.generatedTypes.length===0)return I.i("DEVAGENT","swagger_link_none"),0;let c=a(r),{nanoid:o}=await import('nanoid'),f=c.map(t=>({id:o(12),fromId:`swagger:${t.fromName}`,toId:`swagger:${t.toName}`,type:t.type,metadata:{...t.metadata,fromFile:t.fromFile,toFile:t.toFile}})),g=new Map;for(let t of n)g.set(t.name,t.id),g.set(`${t.filePath}:${t.name}`,t.id);for(let t of f){let p=t.fromId.replace("swagger:",""),F=t.toId.replace("swagger:",""),E=t.metadata?.fromFile,x=t.metadata?.toFile;if(E){let u=`${E}:${p}`;g.has(u)&&(t.fromId=g.get(u));}if(t.fromId.startsWith("swagger:")&&g.has(p)&&(t.fromId=g.get(p)),x){let u=`${x}:${F}`;g.has(u)&&(t.toId=g.get(u));}t.toId.startsWith("swagger:")&&g.has(F)&&(t.toId=g.get(F));}let h=await e.insertRelationships(f);return I.i("DEVAGENT","swagger_link_done",{producers:r.producers.length,consumers:r.consumers.length,generatedTypes:r.generatedTypes.length,relationshipsCreated:h.processed,configs:r.codegenConfigs}),h.processed}catch(s){return I.w("DEVAGENT","swagger_link_error",{error:s.message}),0}}function z(e){return e.isIncremental&&e.allFiles.length>0}function M(e,n,i,s){return {filesProcessed:n,entitiesExtracted:i,relationshipsCreated:s,totalFiles:e.allFiles.length,deletedEntities:e.deletedEntityIds.length}}export{$ as applyChangeAnalysis,M as buildIndexingResult,T as cleanStaleEntities,_ as detectChangedFiles,R as initializeIndexing,L as resolveSwaggerLinks,v as separateCodeAndDataFiles,z as shouldUseIncrementalMode};
@@ -0,0 +1,249 @@
1
+ import { collectFilesAsync, init_file_extensions, file_extensions_exports } from './chunk-4GYRHAKO.js';
2
+ import { getGraphStorage } from './chunk-V2SCB5H5.js';
3
+ import './chunk-HNDYLCWI.js';
4
+ import './chunk-CTXFPNDA.js';
5
+ import './chunk-TJSOOFXA.js';
6
+ import './chunk-AIZUHUK6.js';
7
+ import './chunk-L2X4HRXI.js';
8
+ import './chunk-ZD54CMKT.js';
9
+ import './chunk-HEMJHRHZ.js';
10
+ import { toError } from './chunk-5WKPA33T.js';
11
+ import './chunk-BMHPPH2B.js';
12
+ import { init_logging, log } from './chunk-VCCBEJQ5.js';
13
+ import './chunk-UN27MREV.js';
14
+ import { __require, __toCommonJS } from './chunk-NAQKA54E.js';
15
+ import { statSync } from 'fs';
16
+
17
+ // src/agents/dev/indexing-pipeline.ts
18
+ init_logging();
19
+ async function initializeIndexing(options) {
20
+ const { directory, excludePatterns = [], incremental = false, agentId } = options;
21
+ log.i("DEVAGENT", "Starting indexing", {
22
+ directory,
23
+ excludePatternsCount: excludePatterns.length,
24
+ samplePatterns: excludePatterns.slice(0, 5)
25
+ });
26
+ const collectResult = await collectFilesAsync(directory, { excludePatterns, agentId });
27
+ const allFiles = collectResult.files;
28
+ log.i("DEVAGENT", "Files collected", { count: allFiles.length });
29
+ return {
30
+ directory,
31
+ excludePatterns,
32
+ isIncremental: incremental,
33
+ agentId,
34
+ allFiles,
35
+ deletedEntityIds: []
36
+ };
37
+ }
38
+ async function detectChangedFiles(context) {
39
+ if (!context.isIncremental || context.allFiles.length === 0) {
40
+ return null;
41
+ }
42
+ const storage = await getGraphStorage();
43
+ const indexedFiles = await storage.getAllIndexedFiles();
44
+ if (indexedFiles.size === 0) {
45
+ return {
46
+ changedFiles: [],
47
+ newFiles: context.allFiles,
48
+ deletedFiles: [],
49
+ unchangedFiles: []
50
+ };
51
+ }
52
+ const changedFiles = [];
53
+ const newFiles = [];
54
+ const unchangedFiles = [];
55
+ for (const file of context.allFiles) {
56
+ const normalizedPath = file.replace(/\\/g, "/");
57
+ const lastIndexed = indexedFiles.get(normalizedPath);
58
+ if (lastIndexed === void 0) {
59
+ newFiles.push(file);
60
+ } else {
61
+ try {
62
+ const stats = statSync(file);
63
+ const mtime = stats.mtimeMs;
64
+ if (mtime > lastIndexed) {
65
+ changedFiles.push(file);
66
+ } else {
67
+ unchangedFiles.push(file);
68
+ }
69
+ } catch {
70
+ unchangedFiles.push(file);
71
+ }
72
+ }
73
+ }
74
+ const currentFilesSet = new Set(context.allFiles.map((file) => file.replace(/\\/g, "/")));
75
+ const deletedFiles = [];
76
+ for (const [indexedPath] of indexedFiles) {
77
+ if (!currentFilesSet.has(indexedPath)) {
78
+ deletedFiles.push(indexedPath);
79
+ }
80
+ }
81
+ log.i("DEVAGENT", "Smart incremental analysis", {
82
+ total: context.allFiles.length,
83
+ changed: changedFiles.length,
84
+ new: newFiles.length,
85
+ deleted: deletedFiles.length,
86
+ unchanged: unchangedFiles.length
87
+ });
88
+ return {
89
+ changedFiles,
90
+ newFiles,
91
+ deletedFiles,
92
+ unchangedFiles
93
+ };
94
+ }
95
+ async function cleanStaleEntities(filesToClean) {
96
+ if (filesToClean.length === 0) {
97
+ return [];
98
+ }
99
+ log.i("DEVAGENT", "Invalidating deleted files", {
100
+ fileCount: filesToClean.length
101
+ });
102
+ const storage = await getGraphStorage();
103
+ const deletedEntityIds = [];
104
+ for (const file of filesToClean) {
105
+ try {
106
+ const ids = await storage.deleteEntitiesByFilePath(file);
107
+ deletedEntityIds.push(...ids);
108
+ await storage.deleteFileInfo(file);
109
+ } catch (error) {
110
+ const err = toError(error);
111
+ log.w("DEVAGENT", "Failed to invalidate file", {
112
+ file,
113
+ error: err.message,
114
+ stack: err.stack
115
+ });
116
+ }
117
+ }
118
+ log.i("DEVAGENT", "Files invalidated", {
119
+ entityCount: deletedEntityIds.length
120
+ });
121
+ return deletedEntityIds;
122
+ }
123
+ async function applyChangeAnalysis(context, analysis) {
124
+ const filesToClean = [...analysis.changedFiles, ...analysis.deletedFiles];
125
+ const deletedEntityIds = await cleanStaleEntities(filesToClean);
126
+ const filesToProcess = [...analysis.changedFiles, ...analysis.newFiles];
127
+ log.i("DEVAGENT", "Files to process after analysis", {
128
+ toProcess: filesToProcess.length,
129
+ entitiesDeleted: deletedEntityIds.length
130
+ });
131
+ if (filesToProcess.length === 0) {
132
+ log.i("DEVAGENT", "No files changed, skipping indexing");
133
+ }
134
+ return {
135
+ ...context,
136
+ allFiles: filesToProcess,
137
+ deletedEntityIds
138
+ };
139
+ }
140
+ function separateCodeAndDataFiles(files) {
141
+ const codeFiles = [];
142
+ const dataFiles = [];
143
+ const { extname } = __require("path");
144
+ const { isCodeExtension } = (init_file_extensions(), __toCommonJS(file_extensions_exports));
145
+ for (const file of files) {
146
+ const ext = extname(file).toLowerCase();
147
+ if (isCodeExtension(ext)) {
148
+ codeFiles.push(file);
149
+ } else {
150
+ dataFiles.push(file);
151
+ }
152
+ }
153
+ log.i("DEVAGENT", "Files separated", {
154
+ codeFiles: codeFiles.length,
155
+ dataFiles: dataFiles.length
156
+ });
157
+ return {
158
+ codeFiles,
159
+ dataFiles
160
+ };
161
+ }
162
+ async function resolveSwaggerLinks() {
163
+ const storage = await getGraphStorage();
164
+ const allEntities = await storage.getAllEntities();
165
+ const hasSwagger = allEntities.some((e) => e.metadata?.["swaggerType"]);
166
+ if (!hasSwagger) {
167
+ return 0;
168
+ }
169
+ log.i("DEVAGENT", "swagger_link_start", { totalEntities: allEntities.length });
170
+ try {
171
+ const { analyzeSwaggerCodeLinks, buildSwaggerRelationships } = await import('./swagger-code-linker-WXUPZZEE.js');
172
+ const analysis = analyzeSwaggerCodeLinks(allEntities);
173
+ const totalLinks = analysis.producers.length + analysis.consumers.length + analysis.generatedTypes.length;
174
+ if (totalLinks === 0) {
175
+ log.i("DEVAGENT", "swagger_link_none");
176
+ return 0;
177
+ }
178
+ const swaggerRelationships = buildSwaggerRelationships(analysis);
179
+ const { nanoid } = await import('nanoid');
180
+ const relationships = swaggerRelationships.map((rel) => ({
181
+ id: nanoid(12),
182
+ fromId: `swagger:${rel.fromName}`,
183
+ toId: `swagger:${rel.toName}`,
184
+ type: rel.type,
185
+ metadata: {
186
+ ...rel.metadata,
187
+ fromFile: rel.fromFile,
188
+ toFile: rel.toFile
189
+ }
190
+ }));
191
+ const entityByName = /* @__PURE__ */ new Map();
192
+ for (const e of allEntities) {
193
+ entityByName.set(e.name, e.id);
194
+ entityByName.set(`${e.filePath}:${e.name}`, e.id);
195
+ }
196
+ for (const rel of relationships) {
197
+ const fromName = rel.fromId.replace("swagger:", "");
198
+ const toName = rel.toId.replace("swagger:", "");
199
+ const fromFile = rel.metadata?.fromFile;
200
+ const toFile = rel.metadata?.toFile;
201
+ if (fromFile) {
202
+ const fileKey = `${fromFile}:${fromName}`;
203
+ if (entityByName.has(fileKey)) {
204
+ rel.fromId = entityByName.get(fileKey);
205
+ }
206
+ }
207
+ if (!rel.fromId.startsWith("swagger:") === false && entityByName.has(fromName)) {
208
+ rel.fromId = entityByName.get(fromName);
209
+ }
210
+ if (toFile) {
211
+ const fileKey = `${toFile}:${toName}`;
212
+ if (entityByName.has(fileKey)) {
213
+ rel.toId = entityByName.get(fileKey);
214
+ }
215
+ }
216
+ if (!rel.toId.startsWith("swagger:") === false && entityByName.has(toName)) {
217
+ rel.toId = entityByName.get(toName);
218
+ }
219
+ }
220
+ const result = await storage.insertRelationships(relationships);
221
+ log.i("DEVAGENT", "swagger_link_done", {
222
+ producers: analysis.producers.length,
223
+ consumers: analysis.consumers.length,
224
+ generatedTypes: analysis.generatedTypes.length,
225
+ relationshipsCreated: result.processed,
226
+ configs: analysis.codegenConfigs
227
+ });
228
+ return result.processed;
229
+ } catch (error) {
230
+ log.w("DEVAGENT", "swagger_link_error", { error: error.message });
231
+ return 0;
232
+ }
233
+ }
234
+ function shouldUseIncrementalMode(context) {
235
+ return context.isIncremental && context.allFiles.length > 0;
236
+ }
237
+ function buildIndexingResult(context, filesProcessed, totalEntities, totalRelationships) {
238
+ return {
239
+ filesProcessed,
240
+ entitiesExtracted: totalEntities,
241
+ relationshipsCreated: totalRelationships,
242
+ totalFiles: context.allFiles.length,
243
+ deletedEntities: context.deletedEntityIds.length
244
+ };
245
+ }
246
+
247
+ export { applyChangeAnalysis, buildIndexingResult, cleanStaleEntities, detectChangedFiles, initializeIndexing, resolveSwaggerLinks, separateCodeAndDataFiles, shouldUseIncrementalMode };
248
+ //# sourceMappingURL=indexing-pipeline-OY3337QN.js.map
249
+ //# sourceMappingURL=indexing-pipeline-OY3337QN.js.map
@@ -0,0 +1,249 @@
1
+ import { collectFilesAsync, init_file_extensions, file_extensions_exports } from './chunk-4GYRHAKO.js';
2
+ import { getGraphStorage } from './chunk-XFGXM4CR.js';
3
+ import './chunk-HNDYLCWI.js';
4
+ import './chunk-CTXFPNDA.js';
5
+ import './chunk-TJSOOFXA.js';
6
+ import './chunk-AIZUHUK6.js';
7
+ import './chunk-L2X4HRXI.js';
8
+ import './chunk-ZD54CMKT.js';
9
+ import './chunk-HEMJHRHZ.js';
10
+ import { toError } from './chunk-5WKPA33T.js';
11
+ import './chunk-BMHPPH2B.js';
12
+ import { init_logging, log } from './chunk-VCCBEJQ5.js';
13
+ import './chunk-UN27MREV.js';
14
+ import { __require, __toCommonJS } from './chunk-NAQKA54E.js';
15
+ import { statSync } from 'fs';
16
+
17
+ // src/agents/dev/indexing-pipeline.ts
18
+ init_logging();
19
+ async function initializeIndexing(options) {
20
+ const { directory, excludePatterns = [], incremental = false, agentId } = options;
21
+ log.i("DEVAGENT", "Starting indexing", {
22
+ directory,
23
+ excludePatternsCount: excludePatterns.length,
24
+ samplePatterns: excludePatterns.slice(0, 5)
25
+ });
26
+ const collectResult = await collectFilesAsync(directory, { excludePatterns, agentId });
27
+ const allFiles = collectResult.files;
28
+ log.i("DEVAGENT", "Files collected", { count: allFiles.length });
29
+ return {
30
+ directory,
31
+ excludePatterns,
32
+ isIncremental: incremental,
33
+ agentId,
34
+ allFiles,
35
+ deletedEntityIds: []
36
+ };
37
+ }
38
+ async function detectChangedFiles(context) {
39
+ if (!context.isIncremental || context.allFiles.length === 0) {
40
+ return null;
41
+ }
42
+ const storage = await getGraphStorage();
43
+ const indexedFiles = await storage.getAllIndexedFiles();
44
+ if (indexedFiles.size === 0) {
45
+ return {
46
+ changedFiles: [],
47
+ newFiles: context.allFiles,
48
+ deletedFiles: [],
49
+ unchangedFiles: []
50
+ };
51
+ }
52
+ const changedFiles = [];
53
+ const newFiles = [];
54
+ const unchangedFiles = [];
55
+ for (const file of context.allFiles) {
56
+ const normalizedPath = file.replace(/\\/g, "/");
57
+ const lastIndexed = indexedFiles.get(normalizedPath);
58
+ if (lastIndexed === void 0) {
59
+ newFiles.push(file);
60
+ } else {
61
+ try {
62
+ const stats = statSync(file);
63
+ const mtime = stats.mtimeMs;
64
+ if (mtime > lastIndexed) {
65
+ changedFiles.push(file);
66
+ } else {
67
+ unchangedFiles.push(file);
68
+ }
69
+ } catch {
70
+ unchangedFiles.push(file);
71
+ }
72
+ }
73
+ }
74
+ const currentFilesSet = new Set(context.allFiles.map((file) => file.replace(/\\/g, "/")));
75
+ const deletedFiles = [];
76
+ for (const [indexedPath] of indexedFiles) {
77
+ if (!currentFilesSet.has(indexedPath)) {
78
+ deletedFiles.push(indexedPath);
79
+ }
80
+ }
81
+ log.i("DEVAGENT", "Smart incremental analysis", {
82
+ total: context.allFiles.length,
83
+ changed: changedFiles.length,
84
+ new: newFiles.length,
85
+ deleted: deletedFiles.length,
86
+ unchanged: unchangedFiles.length
87
+ });
88
+ return {
89
+ changedFiles,
90
+ newFiles,
91
+ deletedFiles,
92
+ unchangedFiles
93
+ };
94
+ }
95
+ async function cleanStaleEntities(filesToClean) {
96
+ if (filesToClean.length === 0) {
97
+ return [];
98
+ }
99
+ log.i("DEVAGENT", "Invalidating deleted files", {
100
+ fileCount: filesToClean.length
101
+ });
102
+ const storage = await getGraphStorage();
103
+ const deletedEntityIds = [];
104
+ for (const file of filesToClean) {
105
+ try {
106
+ const ids = await storage.deleteEntitiesByFilePath(file);
107
+ deletedEntityIds.push(...ids);
108
+ await storage.deleteFileInfo(file);
109
+ } catch (error) {
110
+ const err = toError(error);
111
+ log.w("DEVAGENT", "Failed to invalidate file", {
112
+ file,
113
+ error: err.message,
114
+ stack: err.stack
115
+ });
116
+ }
117
+ }
118
+ log.i("DEVAGENT", "Files invalidated", {
119
+ entityCount: deletedEntityIds.length
120
+ });
121
+ return deletedEntityIds;
122
+ }
123
+ async function applyChangeAnalysis(context, analysis) {
124
+ const filesToClean = [...analysis.changedFiles, ...analysis.deletedFiles];
125
+ const deletedEntityIds = await cleanStaleEntities(filesToClean);
126
+ const filesToProcess = [...analysis.changedFiles, ...analysis.newFiles];
127
+ log.i("DEVAGENT", "Files to process after analysis", {
128
+ toProcess: filesToProcess.length,
129
+ entitiesDeleted: deletedEntityIds.length
130
+ });
131
+ if (filesToProcess.length === 0) {
132
+ log.i("DEVAGENT", "No files changed, skipping indexing");
133
+ }
134
+ return {
135
+ ...context,
136
+ allFiles: filesToProcess,
137
+ deletedEntityIds
138
+ };
139
+ }
140
+ function separateCodeAndDataFiles(files) {
141
+ const codeFiles = [];
142
+ const dataFiles = [];
143
+ const { extname } = __require("path");
144
+ const { isCodeExtension } = (init_file_extensions(), __toCommonJS(file_extensions_exports));
145
+ for (const file of files) {
146
+ const ext = extname(file).toLowerCase();
147
+ if (isCodeExtension(ext)) {
148
+ codeFiles.push(file);
149
+ } else {
150
+ dataFiles.push(file);
151
+ }
152
+ }
153
+ log.i("DEVAGENT", "Files separated", {
154
+ codeFiles: codeFiles.length,
155
+ dataFiles: dataFiles.length
156
+ });
157
+ return {
158
+ codeFiles,
159
+ dataFiles
160
+ };
161
+ }
162
+ async function resolveSwaggerLinks() {
163
+ const storage = await getGraphStorage();
164
+ const allEntities = await storage.getAllEntities();
165
+ const hasSwagger = allEntities.some((e) => e.metadata?.["swaggerType"]);
166
+ if (!hasSwagger) {
167
+ return 0;
168
+ }
169
+ log.i("DEVAGENT", "swagger_link_start", { totalEntities: allEntities.length });
170
+ try {
171
+ const { analyzeSwaggerCodeLinks, buildSwaggerRelationships } = await import('./swagger-code-linker-WXUPZZEE.js');
172
+ const analysis = analyzeSwaggerCodeLinks(allEntities);
173
+ const totalLinks = analysis.producers.length + analysis.consumers.length + analysis.generatedTypes.length;
174
+ if (totalLinks === 0) {
175
+ log.i("DEVAGENT", "swagger_link_none");
176
+ return 0;
177
+ }
178
+ const swaggerRelationships = buildSwaggerRelationships(analysis);
179
+ const { nanoid } = await import('nanoid');
180
+ const relationships = swaggerRelationships.map((rel) => ({
181
+ id: nanoid(12),
182
+ fromId: `swagger:${rel.fromName}`,
183
+ toId: `swagger:${rel.toName}`,
184
+ type: rel.type,
185
+ metadata: {
186
+ ...rel.metadata,
187
+ fromFile: rel.fromFile,
188
+ toFile: rel.toFile
189
+ }
190
+ }));
191
+ const entityByName = /* @__PURE__ */ new Map();
192
+ for (const e of allEntities) {
193
+ entityByName.set(e.name, e.id);
194
+ entityByName.set(`${e.filePath}:${e.name}`, e.id);
195
+ }
196
+ for (const rel of relationships) {
197
+ const fromName = rel.fromId.replace("swagger:", "");
198
+ const toName = rel.toId.replace("swagger:", "");
199
+ const fromFile = rel.metadata?.fromFile;
200
+ const toFile = rel.metadata?.toFile;
201
+ if (fromFile) {
202
+ const fileKey = `${fromFile}:${fromName}`;
203
+ if (entityByName.has(fileKey)) {
204
+ rel.fromId = entityByName.get(fileKey);
205
+ }
206
+ }
207
+ if (!rel.fromId.startsWith("swagger:") === false && entityByName.has(fromName)) {
208
+ rel.fromId = entityByName.get(fromName);
209
+ }
210
+ if (toFile) {
211
+ const fileKey = `${toFile}:${toName}`;
212
+ if (entityByName.has(fileKey)) {
213
+ rel.toId = entityByName.get(fileKey);
214
+ }
215
+ }
216
+ if (!rel.toId.startsWith("swagger:") === false && entityByName.has(toName)) {
217
+ rel.toId = entityByName.get(toName);
218
+ }
219
+ }
220
+ const result = await storage.insertRelationships(relationships);
221
+ log.i("DEVAGENT", "swagger_link_done", {
222
+ producers: analysis.producers.length,
223
+ consumers: analysis.consumers.length,
224
+ generatedTypes: analysis.generatedTypes.length,
225
+ relationshipsCreated: result.processed,
226
+ configs: analysis.codegenConfigs
227
+ });
228
+ return result.processed;
229
+ } catch (error) {
230
+ log.w("DEVAGENT", "swagger_link_error", { error: error.message });
231
+ return 0;
232
+ }
233
+ }
234
+ function shouldUseIncrementalMode(context) {
235
+ return context.isIncremental && context.allFiles.length > 0;
236
+ }
237
+ function buildIndexingResult(context, filesProcessed, totalEntities, totalRelationships) {
238
+ return {
239
+ filesProcessed,
240
+ entitiesExtracted: totalEntities,
241
+ relationshipsCreated: totalRelationships,
242
+ totalFiles: context.allFiles.length,
243
+ deletedEntities: context.deletedEntityIds.length
244
+ };
245
+ }
246
+
247
+ export { applyChangeAnalysis, buildIndexingResult, cleanStaleEntities, detectChangedFiles, initializeIndexing, resolveSwaggerLinks, separateCodeAndDataFiles, shouldUseIncrementalMode };
248
+ //# sourceMappingURL=indexing-pipeline-WCXIDMAP.js.map
249
+ //# sourceMappingURL=indexing-pipeline-WCXIDMAP.js.map