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,12 @@
|
|
|
1
|
+
import {a}from'./chunk-W5ZEGGQZ.js';import {d}from'./chunk-XG3ACLWR.js';import'./chunk-XJ2Z5QQO.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-SV3WKUNV.js';import'./chunk-PZF7YC35.js';import {a as a$1}from'./chunk-F3VMUQ7O.js';import'./chunk-NWQZW3Y6.js';import'./chunk-4BI7EBPQ.js';import'./chunk-DXB73IDG.js';import {z}from'zod';var x=class{storage;semanticSearch;constructor(t,i){this.storage=t,this.semanticSearch=i;}async analyzeModificationImpact(t,i={}){let{maxCallerDepth:a=2,analyzeStates:e=true,minConfidence:r=.5}=i,n=await this.storage.getEntity(t);if(!n)return this.emptyResult("Entity not found");let s=await this.findDirectCallers(t,a),c=e?await this.analyzeStateImpact(n):[],l=await this.detectBreakingChanges(n,s),o=this.generateReviewSuggestions(n,s,c),p=this.calculateConfidence(s.length,c.length);if(p<r)return this.emptyResult("Insufficient data for reliable analysis");let f=this.generateSummary(n,s,c,l);return {analyzed:true,directCallers:s,stateImpact:c,breakingChanges:l,reviewSuggestions:o,summary:f,confidence:p}}async analyzeNewFileImpact(t,i){let a=[];if(this.semanticSearch)for(let r of i.slice(0,3))try{let n=await this.semanticSearch.search(r,{limit:3,minSimilarity:.7});for(let s of n){let c=await this.storage.getEntity(s.entityId);c&&c.filePath!==t&&a.push({name:c.name,file:c.filePath,similarity:s.similarity});}}catch{}let e=[];if(a.length>0){e.push(`Found ${a.length} similar entities - consider reusing existing code`);for(let r of a.slice(0,3))e.push(` \u2022 ${r.name} in ${r.file} (${Math.round(r.similarity*100)}% similar)`);}return {analyzed:a.length>0,directCallers:[],stateImpact:[],breakingChanges:[],reviewSuggestions:e,summary:a.length>0?`\u26A0\uFE0F Similar code exists: ${a.map(r=>r.name).join(", ")}`:"",confidence:a.length>0?.7:0}}async analyzeRenameImpact(t,i,a){if(!await this.storage.getEntity(t))return this.emptyResult("Entity not found");let r=await this.findAllReferences(t),n=new Set(r.map(o=>o.file)),s=[],c=await this.storage.searchEntities({namePattern:a});c.length>0&&s.push({description:`Name "${a}" already exists in ${c.length} place(s)`,location:c[0].filePath,severity:"warning"});let l=[`Rename will affect ${r.length} reference(s) in ${n.size} file(s)`];return r.length>10&&l.push("\u26A0\uFE0F Large refactoring - consider reviewing changes before applying"),{analyzed:true,directCallers:r,stateImpact:[],breakingChanges:s,reviewSuggestions:l,summary:`Renaming ${i} \u2192 ${a} affects ${r.length} references`,confidence:.9}}async detectSwaggerContractBreaks(t){let i={affectsContract:false,contractBreaks:[],isGeneratedCode:false,generatedFromSwagger:null};if(!await this.storage.getEntity(t))return i;let e=await this.storage.getRelationshipsForEntity(t);for(let r of e){if(r.type==="produces_api"&&r.fromId===t){i.affectsContract=true;let n=await this.storage.getEntity(r.toId);if(n){let s=`${n.metadata?.httpMethod||""} ${n.metadata?.path||""}`.trim();i.contractBreaks.push({rule:"controller-modified",change:"unknown",endpoint:s||n.name,message:`API contract may be affected: controller produces ${s||n.name}`});}}if(r.type==="generated_from"&&r.fromId===t){i.isGeneratedCode=true;let n=await this.storage.getEntity(r.toId);i.generatedFromSwagger=n?.filePath||null;}if(r.type==="consumes_api"&&r.fromId===t){i.isGeneratedCode=true;let n=await this.storage.getEntity(r.toId);i.generatedFromSwagger=n?.filePath||null;}}return i}async findDirectCallers(t,i){let a=[],e=new Set,r=async(n,s)=>{if(s>i||e.has(n))return;e.add(n);let c=await this.storage.getRelationshipsForEntity(n,"calls");for(let l of c)if(l.toId===n&&!e.has(l.fromId)){let o=await this.storage.getEntity(l.fromId);o&&(a.push({name:o.name,file:o.filePath,line:o.location.start.line}),s<i&&await r(l.fromId,s+1));}};return await r(t,0),a}async findAllReferences(t){let i=[],a=await this.storage.getRelationshipsForEntity(t);for(let e of a){let r=e.fromId===t?e.toId:e.fromId,n=await this.storage.getEntity(r);n&&i.push({name:n.name,file:n.filePath,line:n.location.start.line});}return i}async analyzeStateImpact(t){let i=[],a=t.metadata,e=Array.isArray(a.stateModifications)?a.stateModifications:[];for(let r of e){let n=await this.storage.getAllEntities(),s=[];for(let c of n){if(c.id===t.id)continue;let l=c.metadata;if((Array.isArray(l.stateReads)?l.stateReads:[]).includes(r)&&s.push(c.name),l.controlFlow?.branches&&Array.isArray(l.controlFlow.branches))for(let p of l.controlFlow.branches)p.condition?.includes(r)&&(s.includes(c.name)||s.push(c.name));}s.length>0&&i.push({state:r,affectedEntities:s.slice(0,10),risk:s.length>5?"high":s.length>2?"medium":"low"});}return i}async detectBreakingChanges(t,i){let a=[],e=t.metadata;(e.exported===true||t.name.startsWith("export"))&&i.length>3&&a.push({description:`Exported entity with ${i.length} callers - signature changes may break consumers`,location:`${t.filePath}:${t.location.start.line}`,severity:"warning"});let n=Array.isArray(e.parameters)?e.parameters:[];return n.length>0&&i.length>0&&a.push({description:`Function has ${n.length} parameters - changes may require updating ${i.length} call sites`,location:`${t.filePath}:${t.location.start.line}`,severity:"warning"}),a}generateReviewSuggestions(t,i,a){let e=[];if(i.length>0){let r=new Set(i.map(n=>n.file));e.push(`\u{1F4CD} Review ${i.length} caller(s) in ${r.size} file(s)`);for(let n of i.slice(0,3))e.push(` \u2022 ${n.name} (${n.file}:${n.line})`);i.length>3&&e.push(` ... and ${i.length-3} more`);}if(a.length>0){let r=a.filter(n=>n.risk==="high");r.length>0&&e.push(`\u26A0\uFE0F High-risk state changes: ${r.map(n=>n.state).join(", ")}`);for(let n of a.slice(0,2))e.push(` State "${n.state}" affects: ${n.affectedEntities.slice(0,3).join(", ")}${n.affectedEntities.length>3?"...":""}`);}return e}generateSummary(t,i,a,e){let r=[];if(i.length===0&&a.length===0)return `\u2705 No significant impact detected for ${t.name}`;if(i.length>0&&r.push(`${i.length} caller(s)`),a.length>0){let s=a.reduce((c,l)=>c+l.affectedEntities.length,0);r.push(`${s} state-dependent entities`);}return e.length>0&&r.push(`${e.length} potential breaking change(s)`),`${e.length>0?"\u26A0\uFE0F":"\u2139\uFE0F"} Modification of ${t.name} may affect: ${r.join(", ")}`}calculateConfidence(t,i){let a=.6;return t>0&&(a+=.1),t>5&&(a+=.1),i>0&&(a+=.1),Math.min(a,1)}emptyResult(t){return {analyzed:false,directCallers:[],stateImpact:[],breakingChanges:[],reviewSuggestions:[],summary:t,confidence:0}}};function I(u){if(!u.analyzed||u.confidence<.5)return null;let t=[];if(t.push(""),t.push("\u2500\u2500\u2500 Impact Analysis \u2500\u2500\u2500"),t.push(u.summary),u.reviewSuggestions.length>0){t.push("");for(let i of u.reviewSuggestions)t.push(i);}if(u.breakingChanges.length>0){t.push(""),t.push("\u26A0\uFE0F Potential Issues:");for(let i of u.breakingChanges)t.push(` ${i.severity==="error"?"\u274C":"\u26A0\uFE0F"} ${i.description}`);}return t.join(`
|
|
2
|
+
`)}async function C(u){try{let i=(await u.getSemanticAgent()).getVectorStore?.();return i?{search:async(a,e)=>(await i.search(a,e.limit)).filter(n=>n.similarity>=e.minSimilarity).map(n=>({entityId:n.entityId,similarity:n.similarity}))}:void 0}catch{return}}async function S(u,t,i,a=5){let r=u.getConductor().getAgentByType?.("dev");if(!r)throw new Error("DevAgent not available for reindexing");await r.process({id:`${i}-${Date.now()}`,type:"index",priority:a,payload:{files:t},createdAt:Date.now()});}function E(u,t){let i={...u};return {content:[{type:"text",text:JSON.stringify(i,null,2)}]}}function b(u,t){let i=typeof u=="string"?u:u.message;return {content:[{type:"text",text:JSON.stringify({error:i,...t})}]}}async function A(u){let{dirname:t}=await import('path'),{mkdir:i}=await import('fs/promises');await i(t(u),{recursive:true});}var D=z.object({entityId:z.string().optional(),filePath:z.string().optional(),entityName:z.string().optional(),projectPath:a,newCode:z.string(),preview:z.boolean().optional().default(false)}),k=class extends d{parseArgs(t){return D.parse(t)}async execute(t){let{CodeModifier:i}=await import('./code-modifier-6CY6TPXI.js'),a=await this.ensureGraphStorageForProject(t.projectPath),e=await C(this.context),r=null;try{r=(await this.context.getSemanticAgent()).getVectorStore?.();}catch{}let n=this.resolveProjectPath({}),s=new i(a,r,n),c=new x(a,e),l=t.entityId;if(!l&&t.filePath){let o=this.context.normalizeInputPath(t.filePath),p=await a.findEntities({filters:{filePath:o},limit:100});if(t.entityName){let f=p.find(h=>h.name===t.entityName);f&&(l=f.id);}else p.length===1&&p[0]&&(l=p[0].id);}if(!l)return {content:[{type:"text",text:JSON.stringify({error:"Entity not found"})}]};try{let[o,p]=await Promise.all([s.modifyEntity({entityId:l,newCode:t.newCode,preview:t.preview}),t.preview?Promise.resolve(null):c.analyzeModificationImpact(l).catch(()=>null)]),f={success:o.success,preview:t.preview,entityId:l,filesModified:o.filesModified,snapshotId:o.snapshotId};if(o.validationReport){let{before:h,after:y}=o.validationReport;f.validation={before:h,after:y,improved:(y?.summary?.errors??0)<(h?.summary?.errors??0)};}if(p){let h=I(p);h&&(f.impactAnalysis=h);}if(o.swaggerWarning)try{let h=await c.detectSwaggerContractBreaks(l);f.swaggerImpact={affectsContract:h.affectsContract,contractBreaks:h.contractBreaks,isGeneratedCode:h.isGeneratedCode,generatedFromSwagger:h.generatedFromSwagger,warning:o.swaggerWarning};}catch{f.swaggerImpact={affectsContract:!0,warning:o.swaggerWarning};}return {content:[{type:"text",text:JSON.stringify(f,null,2)}]}}catch(o){let p=a$1(o);return {content:[{type:"text",text:JSON.stringify({error:p.message})}]}}}},G=z.object({sourcePath:z.string(),destinationPath:z.string(),projectPath:a,updateImports:z.boolean().optional().default(true)}),F=class extends d{parseArgs(t){return G.parse(t)}async execute(t){let{copyFile:i}=await import('fs/promises'),a=this.context.normalizeInputPath(t.sourcePath)||t.sourcePath,e=this.context.normalizeInputPath(t.destinationPath)||t.destinationPath;try{return await A(e),await i(a,e),await S(this.context,[e],"copy-index"),E({success:!0,source:a,destination:e,indexed:!0})}catch(r){let n=a$1(r);return b(n)}}},B=z.object({sourcePath:z.string(),destinationPath:z.string(),projectPath:a,updateImports:z.boolean().optional().default(true)}),$=class extends d{parseArgs(t){return B.parse(t)}async execute(t){let{rename:i}=await import('fs/promises'),a=this.context.normalizeInputPath(t.sourcePath)||t.sourcePath,e=this.context.normalizeInputPath(t.destinationPath)||t.destinationPath;try{await A(e),await i(a,e);let r=await this.ensureGraphStorageForProject(t.projectPath),n=await r.findEntities({filters:{filePath:a},limit:1e3});for(let s of n)await r.deleteEntity(s.id);return await S(this.context,[e],"rename-index"),E({success:!0,source:a,destination:e,entitiesMoved:n.length,importsUpdated:t.updateImports})}catch(r){let n=a$1(r);return b(n)}}},L=z.object({filePath:z.string(),outputDirectory:z.string().optional(),projectPath:a,splitBy:z.enum(["class","function","module"]).optional().default("class"),preview:z.boolean().optional().default(true)}),N=class extends d{parseArgs(t){return L.parse(t)}async execute(t){let{mkdir:i}=await import('fs/promises'),{dirname:a,join:e,extname:r}=await import('path'),n=this.context.normalizeInputPath(t.filePath)||t.filePath,s=t.outputDirectory?this.context.normalizeInputPath(t.outputDirectory)||t.outputDirectory:a(n);try{let l=await(await this.ensureGraphStorageForProject(t.projectPath)).findEntities({filters:{filePath:n},limit:1e3}),o=t.splitBy==="class"?["class","interface","enum"]:t.splitBy==="function"?["function","method"]:["module"],p=l.filter(y=>o.some(P=>y.type.toLowerCase().includes(P)));if(p.length<=1)return {content:[{type:"text",text:JSON.stringify({success:!1,message:`Only ${p.length} entity found, nothing to split`,entities:p.map(y=>y.name)})}]};let f=r(n),h=p.map(y=>({name:y.name,type:y.type,outputPath:e(s,`${y.name}${f}`)}));return t.preview?{content:[{type:"text",text:JSON.stringify({preview:!0,sourceFile:n,entitiesToSplit:p.length,plannedFiles:h},null,2)}]}:(await i(s,{recursive:!0}),{content:[{type:"text",text:JSON.stringify({success:!0,sourceFile:n,filesCreated:h.length,files:h},null,2)}]})}catch(c){let l=a$1(c);return {content:[{type:"text",text:JSON.stringify({error:l.message})}]}}}},U=z.object({filePaths:z.array(z.string()),outputPath:z.string(),projectPath:a,preview:z.boolean().optional().default(true)}),j=class extends d{parseArgs(t){return U.parse(t)}async execute(t){let{readText:i,writeFile:a}=await import('./file-ops-HXOTPMZ7.js'),e=t.filePaths.map(n=>this.context.normalizeInputPath(n)||n),r=this.context.normalizeInputPath(t.outputPath)||t.outputPath;try{let s=(await Promise.all(e.map(async c=>({path:c,content:await i(c)})))).map(c=>`// ============= From: ${c.path} =============
|
|
3
|
+
${c.content}`).join(`
|
|
4
|
+
|
|
5
|
+
`);return t.preview?{content:[{type:"text",text:JSON.stringify({preview:!0,inputFiles:e.length,outputPath:r,combinedSize:s.length,previewLines:s.split(`
|
|
6
|
+
`).slice(0,20).join(`
|
|
7
|
+
`)+`
|
|
8
|
+
...`},null,2)}]}:(await A(r),await a(r,s),await S(this.context,[r],"synthesize-index"),E({success:!0,inputFiles:e.length,outputPath:r,indexed:!0}))}catch(n){let s=a$1(n);return b(s)}}},V=z.object({filePath:z.string(),content:z.string(),projectPath:a,overwrite:z.boolean().optional().default(false)}),O=class extends d{parseArgs(t){return V.parse(t)}async execute(t){let{writeFile:i,existsSync:a}=await import('./file-ops-HXOTPMZ7.js'),e=this.context.normalizeInputPath(t.filePath)||t.filePath,r=await C(this.context);try{if(!t.overwrite&&a(e))return b("File already exists",{path:e,hint:"Use overwrite: true to replace"});await A(e),await i(e,t.content),await S(this.context,[e],"create-index");let n={success:!0,path:e,size:t.content.length,indexed:!0};if(r){let s=await this.ensureGraphStorageForProject(t.projectPath),c=new x(s,r);try{let o=(await s.findEntities({filters:{filePath:e},limit:10})).map(p=>p.name);if(o.length>0){let p=await c.analyzeNewFileImpact(e,o),f=I(p);f&&(n.impactAnalysis=f);}}catch{}}return {content:[{type:"text",text:JSON.stringify(n,null,2)}]}}catch(n){let s=a$1(n);return {content:[{type:"text",text:JSON.stringify({error:s.message})}]}}}},q=z.object({entityId:z.string().optional(),entityName:z.string().optional(),projectPath:a,newName:z.string(),preview:z.boolean().optional().default(true)}),J=class extends d{parseArgs(t){return q.parse(t)}async execute(t){let i=await this.ensureGraphStorageForProject(t.projectPath),a=new x(i),e=null;if(t.entityId)e=await i.getEntity(t.entityId);else if(t.entityName){let o=await i.findEntities({filters:{name:t.entityName},limit:1});o.length>0&&o[0]&&(e=o[0]);}if(!e)return {content:[{type:"text",text:JSON.stringify({error:"Entity not found"})}]};let[r,n]=await Promise.all([i.getRelationshipsForEntity(e.id),a.analyzeRenameImpact(e.id,e.name,t.newName).catch(()=>null)]),s=r.filter(o=>o.type==="references"||o.type==="calls"),c=new Set;c.add(e.filePath);for(let o of s){let p=await i.getEntity(o.fromId===e.id?o.toId:o.fromId);p?.filePath&&c.add(p.filePath);}let l=n?I(n):null;if(t.preview){let o={preview:true,entity:{id:e.id,name:e.name,type:e.type,filePath:e.filePath},newName:t.newName,referencesFound:s.length,filesToUpdate:Array.from(c)};return l&&(o.impactAnalysis=l),{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}try{let{readText:o,writeFile:p}=await import('./file-ops-HXOTPMZ7.js');for(let h of c){let y=await o(h),P=new RegExp(`\\b${e.name}\\b`,"g");y=y.replace(P,t.newName),await p(h,y);}await i.updateEntity(e.id,{name:t.newName}),await S(this.context,Array.from(c),"rename-reindex");let f={success:!0,oldName:e.name,newName:t.newName,filesUpdated:c.size,referencesUpdated:s.length};return l&&(f.impactAnalysis=l),{content:[{type:"text",text:JSON.stringify(f,null,2)}]}}catch(o){let p=a$1(o);return {content:[{type:"text",text:JSON.stringify({error:p.message})}]}}}},W=z.object({targetEntityId:z.string().optional(),targetEntityName:z.string().optional(),projectPath:a,memberCode:z.string(),position:z.enum(["start","end","after"]).optional().default("end"),afterMember:z.string().optional(),preview:z.boolean().optional().default(true)}),M=class extends d{parseArgs(t){return W.parse(t)}async execute(t){let i=await this.ensureGraphStorageForProject(t.projectPath),a=new x(i),e=null;if(t.targetEntityId)e=await i.getEntity(t.targetEntityId);else if(t.targetEntityName){let n=await i.findEntities({filters:{name:t.targetEntityName},limit:1});n.length>0&&n[0]&&(e=n[0]);}if(!e)return {content:[{type:"text",text:JSON.stringify({error:"Target entity not found"})}]};if(!["class","interface","struct","enum","module","object"].some(n=>e.type.toLowerCase().includes(n)))return {content:[{type:"text",text:JSON.stringify({error:"Invalid target type",entityType:e.type,hint:"Target must be a class, interface, struct, enum, or module"})}]};if(t.preview)return {content:[{type:"text",text:JSON.stringify({preview:true,target:{id:e.id,name:e.name,type:e.type,filePath:e.filePath},memberCode:t.memberCode,position:t.position},null,2)}]};try{let{readText:n,writeFile:s}=await import('./file-ops-HXOTPMZ7.js'),c=await n(e.filePath),l=e.location;if(!l?.end?.line)return {content:[{type:"text",text:JSON.stringify({error:"Entity location not available"})}]};let o=c.split(`
|
|
9
|
+
`),p=l.end.line-1,f=l.start?.line?l.start.line-1:0,y=(o[f]?.match(/^(\s*)/)?.[1]||"")+" ",P=t.memberCode.split(`
|
|
10
|
+
`).map(R=>y+R).join(`
|
|
11
|
+
`);o.splice(p,0,"",P),c=o.join(`
|
|
12
|
+
`),await s(e.filePath,c),await S(this.context,[e.filePath],"add-member-index");let v={success:!0,target:e.name,memberAdded:!0,filePath:e.filePath,indexed:!0};try{let R=await a.analyzeModificationImpact(e.id),z=I(R);z&&(v.impactAnalysis=z);}catch{}return {content:[{type:"text",text:JSON.stringify(v,null,2)}]}}catch(n){let s=a$1(n);return {content:[{type:"text",text:JSON.stringify({error:s.message})}]}}}};export{M as AddMemberToolHandler,F as CopyFileToolHandler,O as CreateFileToolHandler,k as ModifyEntityCodeToolHandler,$ as RenameFileToolHandler,J as RenameSymbolToolHandler,N as SplitFileToolHandler,j as SynthesizeFilesToolHandler};
|