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.
Files changed (151) hide show
  1. package/dist/chunks/analysis-tool-handlers-GH5FDEWW.js +817 -0
  2. package/dist/chunks/analysis-tool-handlers-IXP4MWZX.js +817 -0
  3. package/dist/chunks/analysis-tool-handlers-LC2BTQYK.js +13 -0
  4. package/dist/chunks/analysis-tool-handlers-QYFKQPFL.js +817 -0
  5. package/dist/chunks/autodoc-tool-handlers-2HF6ERYN.js +1112 -0
  6. package/dist/chunks/autodoc-tool-handlers-4OGQJ7C3.js +1112 -0
  7. package/dist/chunks/autodoc-tool-handlers-N736CB56.js +138 -0
  8. package/dist/chunks/autodoc-tool-handlers-NQYBY6U4.js +1112 -0
  9. package/dist/chunks/branch-tool-handlers-KW3H4FJK.js +276 -0
  10. package/dist/chunks/branch-tool-handlers-QOUDZKJ2.js +276 -0
  11. package/dist/chunks/branch-tool-handlers-RB2U36KI.js +2 -0
  12. package/dist/chunks/branch-tool-handlers-ZHJM6PDK.js +276 -0
  13. package/dist/chunks/chunk-2Z6OQPYC.js +656 -0
  14. package/dist/chunks/chunk-3MQ7LRPN.js +322 -0
  15. package/dist/chunks/chunk-4W6QYGXZ.js +10 -0
  16. package/dist/chunks/chunk-533NFGUG.js +1 -0
  17. package/dist/chunks/chunk-5NUPOPWM.js +1 -0
  18. package/dist/chunks/chunk-AK4HIPA2.js +322 -0
  19. package/dist/chunks/chunk-B3H5NS3I.js +656 -0
  20. package/dist/chunks/chunk-DPTZHDST.js +4 -0
  21. package/dist/chunks/chunk-E5HQWLU5.js +322 -0
  22. package/dist/chunks/chunk-EOH25B5P.js +572 -0
  23. package/dist/chunks/chunk-ESV6F6E3.js +3179 -0
  24. package/dist/chunks/chunk-FPELPFER.js +924 -0
  25. package/dist/chunks/chunk-G6J42I55.js +161 -0
  26. package/dist/chunks/chunk-GCQE7ZYW.js +1 -0
  27. package/dist/chunks/chunk-GTIF6MOX.js +1 -0
  28. package/dist/chunks/chunk-I6STSSAK.js +2 -0
  29. package/dist/chunks/chunk-J2WBGTK2.js +4697 -0
  30. package/dist/chunks/chunk-KAYOX5EB.js +4697 -0
  31. package/dist/chunks/chunk-KPMTACOT.js +656 -0
  32. package/dist/chunks/chunk-L376GZ44.js +3179 -0
  33. package/dist/chunks/chunk-LCTOTHDA.js +15 -0
  34. package/dist/chunks/chunk-LEDJ7GVQ.js +316 -0
  35. package/dist/chunks/chunk-LH4OUKNZ.js +277 -0
  36. package/dist/chunks/chunk-O6IE2MEZ.js +161 -0
  37. package/dist/chunks/chunk-OEXPCY3F.js +316 -0
  38. package/dist/chunks/chunk-OMXOLFDN.js +924 -0
  39. package/dist/chunks/chunk-PLPBXWOU.js +3179 -0
  40. package/dist/chunks/chunk-PWLE5DN2.js +572 -0
  41. package/dist/chunks/chunk-PY43JPWL.js +447 -0
  42. package/dist/chunks/chunk-Q3B4EB7A.js +15 -0
  43. package/dist/chunks/chunk-Q5LPVLXA.js +337 -0
  44. package/dist/chunks/chunk-QIRZHZK2.js +5 -0
  45. package/dist/chunks/chunk-ROQ27LSL.js +924 -0
  46. package/dist/chunks/chunk-S5Q7BD6J.js +572 -0
  47. package/dist/chunks/chunk-SAMX3HJQ.js +337 -0
  48. package/dist/chunks/chunk-SV3WKUNV.js +1 -0
  49. package/dist/chunks/chunk-TCHCDCDO.js +167 -0
  50. package/dist/chunks/chunk-TR3HS7U6.js +316 -0
  51. package/dist/chunks/chunk-TUWE6FCW.js +167 -0
  52. package/dist/chunks/chunk-TVOTA7EE.js +277 -0
  53. package/dist/chunks/chunk-VS44D772.js +337 -0
  54. package/dist/chunks/chunk-WIE3G5ES.js +167 -0
  55. package/dist/chunks/chunk-XG3ACLWR.js +5 -0
  56. package/dist/chunks/chunk-XJ2Z5QQO.js +1 -0
  57. package/dist/chunks/chunk-XK2NY7RB.js +277 -0
  58. package/dist/chunks/chunk-Y4F7NZFZ.js +4700 -0
  59. package/dist/chunks/chunk-YS75L3ZS.js +161 -0
  60. package/dist/chunks/chunk-ZVG5HHI3.js +15 -0
  61. package/dist/chunks/dev-agent-DDDIVWOF.js +1 -0
  62. package/dist/chunks/dev-agent-E2VCFKXN.js +1624 -0
  63. package/dist/chunks/dev-agent-KJNSU5KQ.js +1624 -0
  64. package/dist/chunks/dev-agent-NDERYIPV.js +1624 -0
  65. package/dist/chunks/faiss-provider-7R4BQDIV.js +12 -0
  66. package/dist/chunks/faiss-provider-7ZFRSDN5.js +12 -0
  67. package/dist/chunks/faiss-provider-SXB7FTLB.js +1 -0
  68. package/dist/chunks/faiss-provider-TKLBEUSH.js +12 -0
  69. package/dist/chunks/file-tool-handlers-5DODQXGF.js +1027 -0
  70. package/dist/chunks/file-tool-handlers-KGHLE4KR.js +1027 -0
  71. package/dist/chunks/file-tool-handlers-KTOQ4NFS.js +12 -0
  72. package/dist/chunks/file-tool-handlers-V4SFUDQB.js +1027 -0
  73. package/dist/chunks/graph-metrics-tool-handlers-3AV4X4ZY.js +65 -0
  74. package/dist/chunks/graph-metrics-tool-handlers-3VMDQHJ6.js +65 -0
  75. package/dist/chunks/graph-metrics-tool-handlers-BZ6E6YHF.js +1 -0
  76. package/dist/chunks/graph-metrics-tool-handlers-IYBGSXL7.js +65 -0
  77. package/dist/chunks/graph-storage-factory-2CQ2RPDV.js +13 -0
  78. package/dist/chunks/graph-storage-factory-C5SMMYL6.js +13 -0
  79. package/dist/chunks/graph-storage-factory-EEO2V3GJ.js +1 -0
  80. package/dist/chunks/graph-storage-factory-WBCTXP34.js +13 -0
  81. package/dist/chunks/history-tool-handlers-AS7OQFZI.js +1 -0
  82. package/dist/chunks/history-tool-handlers-FSNJYXV2.js +208 -0
  83. package/dist/chunks/history-tool-handlers-JZAH4EIQ.js +208 -0
  84. package/dist/chunks/history-tool-handlers-KCSCXZ7T.js +208 -0
  85. package/dist/chunks/incremental-updater-A2EL4QXU.js +14 -0
  86. package/dist/chunks/incremental-updater-EQIKBVY2.js +14 -0
  87. package/dist/chunks/incremental-updater-JFGRPH3B.js +14 -0
  88. package/dist/chunks/incremental-updater-S5BAAGHP.js +1 -0
  89. package/dist/chunks/indexer-agent-ASKY7JPG.js +1 -0
  90. package/dist/chunks/indexer-agent-NKAOF323.js +21 -0
  91. package/dist/chunks/indexer-agent-PJN5IOKQ.js +21 -0
  92. package/dist/chunks/indexer-agent-WRJFWKZX.js +21 -0
  93. package/dist/chunks/indexing-pipeline-D4P2O72Z.js +249 -0
  94. package/dist/chunks/indexing-pipeline-L7C543N4.js +1 -0
  95. package/dist/chunks/indexing-pipeline-NHPRN3AB.js +249 -0
  96. package/dist/chunks/indexing-pipeline-ZAXCZU22.js +249 -0
  97. package/dist/chunks/layered-faiss-provider-62CNW54X.js +1 -0
  98. package/dist/chunks/layered-faiss-provider-O7L77GFX.js +12 -0
  99. package/dist/chunks/layered-faiss-provider-RVHLHLPK.js +12 -0
  100. package/dist/chunks/layered-faiss-provider-YT7EDIJI.js +12 -0
  101. package/dist/chunks/merge-agent-3RF7VFF5.js +2481 -0
  102. package/dist/chunks/merge-agent-JCKTCBCE.js +2481 -0
  103. package/dist/chunks/merge-agent-VCL7OXPN.js +2481 -0
  104. package/dist/chunks/merge-agent-ZGK24WVF.js +11 -0
  105. package/dist/chunks/merge-tool-handlers-GV2LOIKU.js +277 -0
  106. package/dist/chunks/merge-tool-handlers-TYDWU5X2.js +277 -0
  107. package/dist/chunks/merge-tool-handlers-U7X2ZO2M.js +1 -0
  108. package/dist/chunks/merge-tool-handlers-YH62ZLPJ.js +277 -0
  109. package/dist/chunks/pattern-tool-handlers-76NF5JDS.js +13 -0
  110. package/dist/chunks/pattern-tool-handlers-IJAGEIVD.js +1549 -0
  111. package/dist/chunks/pattern-tool-handlers-VA5WYA62.js +1549 -0
  112. package/dist/chunks/pattern-tool-handlers-WQ6UBMJS.js +1549 -0
  113. package/dist/chunks/query-agent-36ADGCFZ.js +1 -0
  114. package/dist/chunks/query-agent-H22CR5N5.js +191 -0
  115. package/dist/chunks/query-agent-K2UGZS4M.js +191 -0
  116. package/dist/chunks/query-agent-YJCEHOXD.js +191 -0
  117. package/dist/chunks/semantic-agent-AC7CBEDE.js +6381 -0
  118. package/dist/chunks/semantic-agent-HK5X6CKU.js +6381 -0
  119. package/dist/chunks/semantic-agent-KONIKEGW.js +6381 -0
  120. package/dist/chunks/semantic-agent-LH6IZ2L7.js +137 -0
  121. package/dist/chunks/semantic-tool-handlers-5LMSH2U7.js +3 -0
  122. package/dist/chunks/semantic-tool-handlers-735UMO7Y.js +817 -0
  123. package/dist/chunks/semantic-tool-handlers-BNUYPP7X.js +817 -0
  124. package/dist/chunks/semantic-tool-handlers-MYZPEUD2.js +817 -0
  125. package/dist/chunks/snapshot-tool-handlers-6SIHZT2F.js +201 -0
  126. package/dist/chunks/snapshot-tool-handlers-DS4P3KOT.js +201 -0
  127. package/dist/chunks/snapshot-tool-handlers-JYHRFPC7.js +201 -0
  128. package/dist/chunks/snapshot-tool-handlers-YEHMAT3L.js +1 -0
  129. package/dist/chunks/storage-paths-A3C7WHHG.js +8 -0
  130. package/dist/chunks/storage-paths-HDYH7WPM.js +1 -0
  131. package/dist/chunks/storage-paths-IMFRHBWF.js +8 -0
  132. package/dist/chunks/storage-paths-P3PUSMUD.js +8 -0
  133. package/dist/chunks/taint-tool-handlers-CWESOOMQ.js +68 -0
  134. package/dist/chunks/taint-tool-handlers-OG3NVVP3.js +1 -0
  135. package/dist/chunks/taint-tool-handlers-ON3G3FA7.js +68 -0
  136. package/dist/chunks/taint-tool-handlers-P4P5J6DB.js +68 -0
  137. package/dist/chunks/tracing-tool-handlers-4BDCXTZZ.js +3935 -0
  138. package/dist/chunks/tracing-tool-handlers-6FPNM7HX.js +3935 -0
  139. package/dist/chunks/tracing-tool-handlers-LQTQ5SKK.js +89 -0
  140. package/dist/chunks/tracing-tool-handlers-XRQX2DTS.js +3935 -0
  141. package/dist/chunks/validation-tool-handlers-DZUG7KYY.js +2 -0
  142. package/dist/chunks/validation-tool-handlers-O6TGFSH5.js +555 -0
  143. package/dist/chunks/validation-tool-handlers-RREUYKIR.js +555 -0
  144. package/dist/chunks/validation-tool-handlers-XPWSMS37.js +555 -0
  145. package/dist/index.js +13 -13
  146. package/dist/roslyn-addon/.build-hash +1 -1
  147. package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
  148. package/dist/roslyn-addon/ILGPU.dll +0 -0
  149. package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
  150. package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
  151. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ import { init_storage_paths, getProjectPaths, getProjectDir, ensureProjectDir } from './chunk-XK2NY7RB.js';
2
+ import { init_logging, log } from './chunk-VCCBEJQ5.js';
3
+ import { __require } from './chunk-NAQKA54E.js';
4
+ import { existsSync } from 'fs';
5
+ import { resolve } from 'path';
6
+
7
+ // src/shared/project-context.ts
8
+ init_logging();
9
+ init_storage_paths();
10
+ var ProjectContextManager = class {
11
+ state;
12
+ constructor() {
13
+ const cwd = process.cwd();
14
+ log.i("PROJCTX", `[ProjectContextManager] Initializing with cwd: ${cwd}`);
15
+ this.state = {
16
+ currentProject: cwd,
17
+ previousProject: null
18
+ };
19
+ }
20
+ indexingInProgress = /* @__PURE__ */ new Set();
21
+ onProjectChangeCallbacks = [];
22
+ /**
23
+ * Get current project path
24
+ */
25
+ getCurrentProject() {
26
+ return this.state.currentProject;
27
+ }
28
+ /**
29
+ * Resolve and normalize project path
30
+ * - If absolute path provided, use it
31
+ * - If relative path, resolve from CWD
32
+ * - If undefined/null, use current project
33
+ */
34
+ resolveProjectPath(projectPath) {
35
+ if (!projectPath) {
36
+ return this.state.currentProject;
37
+ }
38
+ const resolved = resolve(projectPath);
39
+ return resolved;
40
+ }
41
+ /**
42
+ * Get project info including indexing status
43
+ */
44
+ getProjectInfo(projectPath) {
45
+ const path = this.resolveProjectPath(projectPath);
46
+ const paths = getProjectPaths(path);
47
+ const projectDir = getProjectDir(path);
48
+ const hash = projectDir.split(/[/\\]/).pop() || "";
49
+ const hasGraphDb = existsSync(paths.graphDbPath);
50
+ const hasVectorsDb = existsSync(paths.vectorsDbPath);
51
+ const isIndexed = hasGraphDb;
52
+ let lastIndexedAt;
53
+ if (existsSync(paths.metaPath)) {
54
+ try {
55
+ const meta = JSON.parse(__require("fs").readFileSync(paths.metaPath, "utf-8"));
56
+ lastIndexedAt = meta.lastIndexedAt;
57
+ } catch {
58
+ }
59
+ }
60
+ return {
61
+ path,
62
+ hash,
63
+ isIndexed,
64
+ hasGraphDb,
65
+ hasVectorsDb,
66
+ lastIndexedAt
67
+ };
68
+ }
69
+ /**
70
+ * Check if project is indexed
71
+ */
72
+ isProjectIndexed(projectPath) {
73
+ const info = this.getProjectInfo(projectPath);
74
+ return info.isIndexed;
75
+ }
76
+ /**
77
+ * Switch to a different project context
78
+ * Returns true if switch was successful
79
+ */
80
+ async switchProject(projectPath) {
81
+ const resolved = this.resolveProjectPath(projectPath);
82
+ if (resolved === this.state.currentProject) {
83
+ return true;
84
+ }
85
+ ensureProjectDir(resolved);
86
+ this.state.previousProject = this.state.currentProject;
87
+ this.state.currentProject = resolved;
88
+ log.i("PROJCTX", `[ProjectContext] Switched project: ${this.state.previousProject} -> ${resolved}`);
89
+ for (const callback of this.onProjectChangeCallbacks) {
90
+ try {
91
+ callback(resolved, this.state.previousProject);
92
+ } catch (error) {
93
+ log.e("PROJCTX", "callback_error", { err: String(error) });
94
+ }
95
+ }
96
+ return true;
97
+ }
98
+ /**
99
+ * Get storage paths for current or specified project
100
+ */
101
+ getStoragePaths(projectPath) {
102
+ const resolved = this.resolveProjectPath(projectPath);
103
+ return getProjectPaths(resolved);
104
+ }
105
+ /**
106
+ * Check if indexing is in progress for a project
107
+ */
108
+ isIndexingInProgress(projectPath) {
109
+ const resolved = this.resolveProjectPath(projectPath);
110
+ return this.indexingInProgress.has(resolved);
111
+ }
112
+ /**
113
+ * Mark indexing as started for a project
114
+ */
115
+ startIndexing(projectPath) {
116
+ const resolved = this.resolveProjectPath(projectPath);
117
+ this.indexingInProgress.add(resolved);
118
+ log.i("PROJCTX", `[ProjectContext] Indexing started for: ${resolved}`);
119
+ }
120
+ /**
121
+ * Mark indexing as completed for a project
122
+ */
123
+ finishIndexing(projectPath) {
124
+ const resolved = this.resolveProjectPath(projectPath);
125
+ this.indexingInProgress.delete(resolved);
126
+ log.i("PROJCTX", `[ProjectContext] Indexing completed for: ${resolved}`);
127
+ }
128
+ /**
129
+ * Register callback for project changes
130
+ */
131
+ onProjectChange(callback) {
132
+ this.onProjectChangeCallbacks.push(callback);
133
+ }
134
+ /**
135
+ * Get status summary for debugging
136
+ */
137
+ getStatus() {
138
+ return {
139
+ currentProject: this.state.currentProject,
140
+ previousProject: this.state.previousProject,
141
+ isIndexed: this.isProjectIndexed(),
142
+ indexingInProgress: Array.from(this.indexingInProgress)
143
+ };
144
+ }
145
+ /**
146
+ * Reset to default state (mainly for testing)
147
+ */
148
+ reset() {
149
+ this.state = {
150
+ currentProject: process.cwd(),
151
+ previousProject: null
152
+ };
153
+ this.indexingInProgress.clear();
154
+ this.onProjectChangeCallbacks = [];
155
+ }
156
+ };
157
+ var instance = null;
158
+ function getProjectContext() {
159
+ if (!instance) {
160
+ instance = new ProjectContextManager();
161
+ }
162
+ return instance;
163
+ }
164
+
165
+ export { getProjectContext };
166
+ //# sourceMappingURL=chunk-WIE3G5ES.js.map
167
+ //# sourceMappingURL=chunk-WIE3G5ES.js.map
@@ -0,0 +1,5 @@
1
+ import {a}from'./chunk-XJ2Z5QQO.js';import {R,I}from'./chunk-4BI7EBPQ.js';var y={entities:100,relationships:100,clones:30,searchResults:20,hotspots:20,graphNodes:200,taintVulnerabilities:20};function P(o,n=0,e=50){let t=Math.min(e,200),r=Math.max(0,n),i=o.length,s=o.slice(r,r+t),a=r+t<i;return {data:s,pagination:{offset:r,limit:t,total:i,hasMore:a,...a&&{nextOffset:r+t}}}}function l(o,n=5e4){let e=JSON.stringify(o,null,2),t=Buffer.byteLength(e,"utf8");if(t<=n)return {text:e,wasTruncated:false,originalSize:t,truncatedSize:t};let r=f(o,n),i=JSON.stringify(r,null,2);return {text:i,wasTruncated:true,originalSize:t,truncatedSize:Buffer.byteLength(i,"utf8")}}function f(o,n,e=0){return e>5?"[nested data omitted]":o==null||typeof o!="object"?o:Array.isArray(o)?d(o,n):S(o,n,e)}function d(o,n){let e=o,t=JSON.stringify(e).length;for(;t>n*.8&&e.length>1;){let i=Math.max(1,Math.floor(e.length/2));e=o.slice(0,i),t=JSON.stringify(e).length;}return e.length<o.length?{_truncated:true,_message:`Response truncated. Showing ${e.length} of ${o.length} items. Use 'offset' parameter to paginate.`,_total:o.length,_showing:e.length,items:e}:e}function S(o,n,e=0){let t={},r=["id","name","type","count","total","pagination","error","success"],i=[];for(let s of Object.keys(o))r.includes(s)?t[s]=o[s]:Array.isArray(o[s])&&i.push(s);for(let s of Object.keys(o))if(!r.includes(s)&&!Array.isArray(o[s])){let a=o[s];if(typeof a=="string"&&a.length>n*.2)t[s]=a.slice(0,Math.floor(n*.2))+"... [truncated]";else if(typeof a=="object"&&a!==null){let c=n-JSON.stringify(t).length;c>100?t[s]=f(a,c*.8,e+1):t[s]="[object omitted \u2014 response too large]";}else t[s]=a;}for(let s of i){let a=o[s],c=n-JSON.stringify(t).length;t[s]=d(a,c*.8);}return t}R();var m=class{constructor(n){this.context=n;}maxResponseSize=5e4;getProjectContext(){return a()}resolveProjectPath(n){if(n.projectPath)return this.context.session?.resolvePath(n.projectPath)??n.projectPath;if(n.directory)return this.context.session?.resolvePath(n.directory)??n.directory;if(this.context.session)return this.context.session.projectPath;if(this.context.projectPath)return this.context.projectPath;let e=a().getCurrentProject();return e||process.cwd()}getProjectStoragePaths(n){let e=this.resolveProjectPath({projectPath:n});return a().getStoragePaths(e)}isProjectIndexed(n){let e=this.resolveProjectPath({projectPath:n});return a().isProjectIndexed(e)}async ensureGraphStorageForProject(n){let e=this.resolveProjectPath({projectPath:n});I.d("BASETOOL","ensure_storage",{resolved:e,hasSession:!!this.context.session});let t=await this.context.getGraphStorage();return t.setProject(e),I.d("BASETOOL","storage_set",{resolved:e}),t}async ensureSemanticAgentForProject(n){let e=this.resolveProjectPath({projectPath:n}),t=await this.context.getSemanticAgent(),i=t?.getVectorStore?.()?.getProjectContext?.();if(I.d("BASETOOL","semantic_ctx",{resolved:e,hasSession:!!this.context.session,ctx:JSON.stringify(i)}),t&&typeof t.reinitializeForProject=="function"){I.d("BASETOOL","reinit_proj",{resolved:e}),await t.reinitializeForProject(e);let s=t.getVectorStore?.()?.getProjectContext?.();I.d("BASETOOL","ctx_switched",{ctx:JSON.stringify(s)});}return t}applyResponseLimits(n){return !n.content||n.content.length===0?n:{content:n.content.map(t=>{if(t.type!=="text")return t;let r=Buffer.byteLength(t.text,"utf8");if(r<=this.maxResponseSize)return t;let i;try{let a=JSON.parse(t.text),c=l(a,this.maxResponseSize);if(c.wasTruncated){let p=JSON.parse(c.text);p._responseMeta={truncated:!0,originalSizeBytes:c.originalSize,truncatedSizeBytes:c.truncatedSize,hint:"Response was truncated. Use 'offset' and 'limit' parameters for pagination."},i={type:"text",text:JSON.stringify(p,null,2)};}else i={type:"text",text:c.text};}catch{i={type:"text",text:t.text.slice(0,this.maxResponseSize)+`
2
+
3
+ [RESPONSE TRUNCATED - original size: `+r+" bytes]"};}let s=Buffer.byteLength(i.text,"utf8");return s>this.maxResponseSize?{type:"text",text:i.text.slice(0,this.maxResponseSize-200)+`
4
+
5
+ [RESPONSE TRUNCATED \u2014 hard cap at `+this.maxResponseSize+" bytes. Original: "+s+" bytes. Use 'offset'/'limit' for pagination.]"}:i})}}summarizeArgs(n){if(!n||typeof n!="object")return {};let e={};for(let[t,r]of Object.entries(n))r!=null&&(typeof r=="string"?e[t]=r.length>80?r.slice(0,80)+"...":r:Array.isArray(r)?e[t]=`[${r.length}]`:e[t]=r);return e}responseSize(n){let e=0;for(let t of n.content)e+=t.text.length;return e}async handle(n){let e=Date.now(),t=this.constructor.name.replace("ToolHandler","").toLowerCase();try{let r=this.parseArgs(n),i=await this.execute(r),s=this.applyResponseLimits(i),a=Date.now()-e,c=this.responseSize(s);return I.i("BASETOOL","mcp_response",{tool:t,durationMs:a,respBytes:c,args:this.summarizeArgs(n),reqId:this.context.requestId}),s}catch(r){let i=Date.now()-e;return I.e("BASETOOL","exec_failed",{tool:t,durationMs:i,err:r.message,args:this.summarizeArgs(n),reqId:this.context.requestId}),{content:[{type:"text",text:JSON.stringify({success:false,error:r.message})}]}}}};export{y as a,P as b,l as c,m as d};
@@ -0,0 +1 @@
1
+ import {I,o,n,x}from'./chunk-SV3WKUNV.js';import {R,I as I$1}from'./chunk-4BI7EBPQ.js';import {a}from'./chunk-DXB73IDG.js';import {existsSync}from'fs';import {resolve}from'path';R();I();var c=class{state;constructor(){let t=process.cwd();I$1.i("PROJCTX",`[ProjectContextManager] Initializing with cwd: ${t}`),this.state={currentProject:t,previousProject:null};}indexingInProgress=new Set;onProjectChangeCallbacks=[];getCurrentProject(){return this.state.currentProject}resolveProjectPath(t){return t?resolve(t):this.state.currentProject}getProjectInfo(t){let e=this.resolveProjectPath(t),r=o(e),l=n(e).split(/[/\\]/).pop()||"",P=existsSync(r.graphDbPath),u=existsSync(r.vectorsDbPath),j=P,g;if(existsSync(r.metaPath))try{g=JSON.parse(a("fs").readFileSync(r.metaPath,"utf-8")).lastIndexedAt;}catch{}return {path:e,hash:l,isIndexed:j,hasGraphDb:P,hasVectorsDb:u,lastIndexedAt:g}}isProjectIndexed(t){return this.getProjectInfo(t).isIndexed}async switchProject(t){let e=this.resolveProjectPath(t);if(e===this.state.currentProject)return true;x(e),this.state.previousProject=this.state.currentProject,this.state.currentProject=e,I$1.i("PROJCTX",`[ProjectContext] Switched project: ${this.state.previousProject} -> ${e}`);for(let r of this.onProjectChangeCallbacks)try{r(e,this.state.previousProject);}catch(a){I$1.e("PROJCTX","callback_error",{err:String(a)});}return true}getStoragePaths(t){let e=this.resolveProjectPath(t);return o(e)}isIndexingInProgress(t){let e=this.resolveProjectPath(t);return this.indexingInProgress.has(e)}startIndexing(t){let e=this.resolveProjectPath(t);this.indexingInProgress.add(e),I$1.i("PROJCTX",`[ProjectContext] Indexing started for: ${e}`);}finishIndexing(t){let e=this.resolveProjectPath(t);this.indexingInProgress.delete(e),I$1.i("PROJCTX",`[ProjectContext] Indexing completed for: ${e}`);}onProjectChange(t){this.onProjectChangeCallbacks.push(t);}getStatus(){return {currentProject:this.state.currentProject,previousProject:this.state.previousProject,isIndexed:this.isProjectIndexed(),indexingInProgress:Array.from(this.indexingInProgress)}}reset(){this.state={currentProject:process.cwd(),previousProject:null},this.indexingInProgress.clear(),this.onProjectChangeCallbacks=[];}},i=null;function S(){return i||(i=new c),i}export{S as a};
@@ -0,0 +1,277 @@
1
+ import { hashText, init_fast_hash } from './chunk-HEMJHRHZ.js';
2
+ import { __export, __esm } from './chunk-NAQKA54E.js';
3
+ import { execSync } from 'child_process';
4
+ import { existsSync, mkdirSync } from 'fs';
5
+ import { homedir } from 'os';
6
+ import { join } from 'path';
7
+
8
+ // src/shared/storage-paths.ts
9
+ var storage_paths_exports = {};
10
+ __export(storage_paths_exports, {
11
+ DEFAULT_BRANCH: () => DEFAULT_BRANCH,
12
+ ensureDataDir: () => ensureDataDir,
13
+ ensureGlobalDbDir: () => ensureGlobalDbDir,
14
+ ensureProjectDir: () => ensureProjectDir,
15
+ getASTCacheDir: () => getASTCacheDir,
16
+ getBranchPaths: () => getBranchPaths,
17
+ getCacheDir: () => getCacheDir,
18
+ getConfigDir: () => getConfigDir,
19
+ getConfigPath: () => getConfigPath,
20
+ getCoreLockPath: () => getCoreLockPath,
21
+ getCorePidPath: () => getCorePidPath,
22
+ getCurrentGitBranch: () => getCurrentGitBranch,
23
+ getCurrentGitBranchOrDefault: () => getCurrentGitBranchOrDefault,
24
+ getDataDir: () => getDataDir,
25
+ getFaissHotBufferPath: () => getFaissHotBufferPath,
26
+ getFaissIdMapPath: () => getFaissIdMapPath,
27
+ getFaissIndexPath: () => getFaissIndexPath,
28
+ getFaissIndexPathByHash: () => getFaissIndexPathByHash,
29
+ getGlobalDbPaths: () => getGlobalDbPaths,
30
+ getIPCSocketPath: () => getIPCSocketPath,
31
+ getLogsDir: () => getLogsDir,
32
+ getModelsDir: () => getModelsDir,
33
+ getMultiDbPaths: () => getMultiDbPaths,
34
+ getProjectDir: () => getProjectDir,
35
+ getProjectHash: () => getProjectHash,
36
+ getProjectPaths: () => getProjectPaths,
37
+ getProjectsDir: () => getProjectsDir,
38
+ getSemanticConfigPath: () => getSemanticConfigPath,
39
+ getTreeSitterCacheDir: () => getTreeSitterCacheDir,
40
+ hashProjectPath: () => hashProjectPath,
41
+ initializeStorageDirs: () => initializeStorageDirs,
42
+ isBaseBranch: () => isBaseBranch,
43
+ normalizeBranchName: () => normalizeBranchName
44
+ });
45
+ function getDataDir() {
46
+ let baseDir;
47
+ switch (process.platform) {
48
+ case "win32":
49
+ baseDir = process.env["LOCALAPPDATA"] || join(homedir(), "AppData", "Local");
50
+ break;
51
+ case "darwin":
52
+ baseDir = join(homedir(), "Library", "Application Support");
53
+ break;
54
+ default:
55
+ baseDir = process.env["XDG_DATA_HOME"] || join(homedir(), ".local", "share");
56
+ }
57
+ return join(baseDir, "UltraCode");
58
+ }
59
+ function ensureDataDir() {
60
+ const dir = getDataDir();
61
+ if (!existsSync(dir)) {
62
+ mkdirSync(dir, { recursive: true });
63
+ }
64
+ return dir;
65
+ }
66
+ function getIPCSocketPath() {
67
+ if (process.platform === "win32") {
68
+ return "\\\\.\\pipe\\ultracode-core";
69
+ }
70
+ return "/tmp/ultracode-core.sock";
71
+ }
72
+ function getLogsDir() {
73
+ return join(getDataDir(), "logs");
74
+ }
75
+ function getCacheDir() {
76
+ return join(getDataDir(), "cache");
77
+ }
78
+ function getProjectsDir() {
79
+ return join(getDataDir(), "projects");
80
+ }
81
+ function getModelsDir() {
82
+ return join(getDataDir(), "models");
83
+ }
84
+ function getConfigDir() {
85
+ return join(getDataDir(), "config");
86
+ }
87
+ function getConfigPath() {
88
+ return join(getDataDir(), "config.yaml");
89
+ }
90
+ function getSemanticConfigPath() {
91
+ return join(getConfigDir(), "semantic-config.json");
92
+ }
93
+ function getCorePidPath() {
94
+ return join(getDataDir(), "core.pid");
95
+ }
96
+ function getCoreLockPath() {
97
+ return join(getDataDir(), "core.lock");
98
+ }
99
+ function hashProjectPath(projectPath) {
100
+ if (!projectPath) {
101
+ throw new Error(
102
+ `hashProjectPath: projectPath must not be empty (got ${JSON.stringify(projectPath)}). Ensure projectPath is provided in tool args or resolved from session/context.`
103
+ );
104
+ }
105
+ const normalized = projectPath.toLowerCase().replace(/\\/g, "/").replace(/\/$/, "");
106
+ return hashText(normalized);
107
+ }
108
+ function getProjectDir(projectPath) {
109
+ const hash = hashProjectPath(projectPath);
110
+ return join(getProjectsDir(), hash);
111
+ }
112
+ function getProjectPaths(projectPath) {
113
+ const projectDir = getProjectDir(projectPath);
114
+ return {
115
+ dir: projectDir,
116
+ metaPath: join(projectDir, "meta.json"),
117
+ graphDbPath: join(projectDir, "graph.db"),
118
+ vectorsDbPath: join(projectDir, "vectors.db"),
119
+ branchesDir: join(projectDir, "branches"),
120
+ // Cache persistence paths
121
+ parserCachePath: join(projectDir, "parser-cache.json"),
122
+ semanticCachePath: join(projectDir, "semantic-cache.json")
123
+ };
124
+ }
125
+ function getGlobalDbPaths() {
126
+ const dataDir = getDataDir();
127
+ return {
128
+ dir: dataDir,
129
+ /** @deprecated Use multi-db paths instead */
130
+ graphDbPath: join(dataDir, "graph.db"),
131
+ /** @deprecated FAISS is used for vectors, not SQLite */
132
+ vectorsDbPath: join(dataDir, "graph.db"),
133
+ /** @deprecated Use getMultiDbPaths() instead */
134
+ unifiedDbPath: join(dataDir, "graph.db"),
135
+ metaPath: join(dataDir, "global-meta.json"),
136
+ cacheDir: getCacheDir(),
137
+ projectsDir: getProjectsDir()
138
+ };
139
+ }
140
+ function getMultiDbPaths(basePath) {
141
+ const dir = basePath ?? getDataDir();
142
+ return {
143
+ graph: join(dir, "graph.db"),
144
+ semantic: join(dir, "semantic.db"),
145
+ versioning: join(dir, "versioning.db"),
146
+ cache: join(dir, "cache.db")
147
+ };
148
+ }
149
+ function getProjectHash(projectPath) {
150
+ return hashProjectPath(projectPath);
151
+ }
152
+ function normalizeBranchName(branchName) {
153
+ return branchName.toLowerCase().replace(/[<>:"/\\|?*]/g, "_");
154
+ }
155
+ function isBaseBranch(branchName) {
156
+ if (!branchName) return false;
157
+ const normalized = branchName.toLowerCase();
158
+ return BASE_BRANCH_CANDIDATES.includes(normalized);
159
+ }
160
+ function getCurrentGitBranch(projectPath) {
161
+ if (!projectPath) {
162
+ return null;
163
+ }
164
+ try {
165
+ const gitDir = join(projectPath, ".git");
166
+ if (!existsSync(gitDir)) {
167
+ return null;
168
+ }
169
+ const branch = execSync("git symbolic-ref --short HEAD", {
170
+ cwd: projectPath,
171
+ encoding: "utf-8",
172
+ stdio: ["pipe", "pipe", "ignore"],
173
+ windowsHide: true
174
+ }).trim();
175
+ return branch || null;
176
+ } catch {
177
+ try {
178
+ const ref = execSync("git rev-parse --abbrev-ref HEAD", {
179
+ cwd: projectPath,
180
+ encoding: "utf-8",
181
+ stdio: ["pipe", "pipe", "ignore"],
182
+ windowsHide: true
183
+ }).trim();
184
+ if (ref === "HEAD") {
185
+ const hash = execSync("git rev-parse --short HEAD", {
186
+ cwd: projectPath,
187
+ encoding: "utf-8",
188
+ stdio: ["pipe", "pipe", "ignore"],
189
+ windowsHide: true
190
+ }).trim();
191
+ return hash ? `detached-${hash}` : null;
192
+ }
193
+ return ref || null;
194
+ } catch {
195
+ return null;
196
+ }
197
+ }
198
+ }
199
+ function getCurrentGitBranchOrDefault(projectPath) {
200
+ return getCurrentGitBranch(projectPath) || DEFAULT_BRANCH;
201
+ }
202
+ function ensureProjectDir(projectPath) {
203
+ const paths = getProjectPaths(projectPath);
204
+ if (!existsSync(paths.dir)) {
205
+ mkdirSync(paths.dir, { recursive: true });
206
+ }
207
+ return paths.dir;
208
+ }
209
+ function ensureGlobalDbDir() {
210
+ const paths = getGlobalDbPaths();
211
+ if (!existsSync(paths.dir)) {
212
+ mkdirSync(paths.dir, { recursive: true });
213
+ }
214
+ return paths.dir;
215
+ }
216
+ function getBranchPaths(projectPath, branchName) {
217
+ const { branchesDir } = getProjectPaths(projectPath);
218
+ const safeBranchName = branchName.replace(/[<>:"/\\|?*]/g, "_");
219
+ const branchDir = join(branchesDir, safeBranchName);
220
+ return {
221
+ dir: branchDir,
222
+ graphDbPath: join(branchDir, "graph.db"),
223
+ vectorsDbPath: join(branchDir, "vectors.db")
224
+ };
225
+ }
226
+ function getFaissIndexPath(projectPath, branchName) {
227
+ const projectDir = getProjectDir(projectPath);
228
+ const safeBranch = normalizeBranchName(branchName);
229
+ if (!existsSync(projectDir)) {
230
+ mkdirSync(projectDir, { recursive: true });
231
+ }
232
+ return join(projectDir, `faiss-${safeBranch}.bin`);
233
+ }
234
+ function getFaissIndexPathByHash(projectHash, branchName) {
235
+ const projectDir = join(getProjectsDir(), projectHash);
236
+ const safeBranch = normalizeBranchName(branchName);
237
+ if (!existsSync(projectDir)) {
238
+ mkdirSync(projectDir, { recursive: true });
239
+ }
240
+ return join(projectDir, `faiss-${safeBranch}.bin`);
241
+ }
242
+ function getFaissIdMapPath(projectPath, branchName) {
243
+ const projectDir = getProjectDir(projectPath);
244
+ const safeBranch = normalizeBranchName(branchName);
245
+ return join(projectDir, `faiss-${safeBranch}.idmap.json`);
246
+ }
247
+ function getFaissHotBufferPath(projectPath, branchName) {
248
+ const projectDir = getProjectDir(projectPath);
249
+ const safeBranch = normalizeBranchName(branchName);
250
+ return join(projectDir, `faiss-${safeBranch}-hot.bin`);
251
+ }
252
+ function getTreeSitterCacheDir() {
253
+ return join(getCacheDir(), "tree-sitter");
254
+ }
255
+ function getASTCacheDir() {
256
+ return join(getCacheDir(), "ast");
257
+ }
258
+ function initializeStorageDirs() {
259
+ const dirs = [getDataDir(), getLogsDir(), getProjectsDir(), getModelsDir(), getConfigDir()];
260
+ for (const dir of dirs) {
261
+ if (!existsSync(dir)) {
262
+ mkdirSync(dir, { recursive: true });
263
+ }
264
+ }
265
+ }
266
+ var DEFAULT_BRANCH, BASE_BRANCH_CANDIDATES;
267
+ var init_storage_paths = __esm({
268
+ "src/shared/storage-paths.ts"() {
269
+ init_fast_hash();
270
+ DEFAULT_BRANCH = "main";
271
+ BASE_BRANCH_CANDIDATES = ["main", "master", "dev", "develop", "trunk"];
272
+ }
273
+ });
274
+
275
+ export { DEFAULT_BRANCH, ensureDataDir, ensureGlobalDbDir, ensureProjectDir, getASTCacheDir, getBranchPaths, getCacheDir, getConfigDir, getConfigPath, getCoreLockPath, getCorePidPath, getCurrentGitBranch, getCurrentGitBranchOrDefault, getDataDir, getFaissHotBufferPath, getFaissIdMapPath, getFaissIndexPath, getFaissIndexPathByHash, getGlobalDbPaths, getIPCSocketPath, getLogsDir, getModelsDir, getMultiDbPaths, getProjectDir, getProjectHash, getProjectPaths, getProjectsDir, getSemanticConfigPath, getTreeSitterCacheDir, hashProjectPath, init_storage_paths, initializeStorageDirs, isBaseBranch, normalizeBranchName, storage_paths_exports };
276
+ //# sourceMappingURL=chunk-XK2NY7RB.js.map
277
+ //# sourceMappingURL=chunk-XK2NY7RB.js.map