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,13 @@
|
|
|
1
|
+
import {a}from'./chunk-W5ZEGGQZ.js';import {a as a$1,d,b}from'./chunk-XG3ACLWR.js';import'./chunk-XJ2Z5QQO.js';import'./chunk-RK5TLU72.js';import {d as d$1}from'./chunk-3IFLFBQ4.js';import'./chunk-SV3WKUNV.js';import'./chunk-PZF7YC35.js';import {a as a$2}from'./chunk-F3VMUQ7O.js';import {R,I}from'./chunk-4BI7EBPQ.js';import'./chunk-DXB73IDG.js';import {execSync}from'child_process';import {z}from'zod';R();var H=z.object({entityId:z.string().optional(),filePath:z.string().optional(),projectPath:a,type:z.enum(["extract_method","rename","move","simplify","all"]).optional().default("all"),offset:z.number().optional().default(0),limit:z.number().optional().default(a$1.searchResults)}),T=class extends d{parseArgs(t){return H.parse(t)}async execute(t){let c=await this.ensureGraphStorageForProject(t.projectPath),m=await this.context.getSemanticAgent(),o=Math.min(t.limit,200),n,r=t.entityId,h=t.filePath?this.context.normalizeInputPath(t.filePath):void 0;if(t.entityId){let d=await c.getEntity(t.entityId);d?.filePath&&(h=d.filePath);}if(!n&&h)try{let{readFile:d}=await import('fs/promises');n=await d(h,"utf-8");}catch{return {content:[{type:"text",text:JSON.stringify({error:`Cannot read file: ${h}`})}]}}if(!n)return {content:[{type:"text",text:JSON.stringify({error:"No code found. Provide entityId or filePath."})}]};let l=await m.suggestRefactoring(n),g=b(l,t.offset,o);return {content:[{type:"text",text:JSON.stringify({entityId:r,filePath:h,suggestionsFound:g.data.length,pagination:g.pagination,suggestions:g.data.map(d=>({type:d.type,impact:d.impact,confidence:d.confidence,description:d.description,entityId:r,filePath:h,suggestedCode:d.code}))},null,2)}]}}},G=z.object({projectPath:a,metric:z.enum(["complexity","changes","coupling","all"]).optional().default("complexity"),offset:z.number().optional().default(0),limit:z.number().optional().default(a$1.hotspots),includeHistoricalMetrics:z.boolean().optional().default(true).describe("Use Prolly Tree history for changeFrequency calculation"),lookbackDays:z.number().optional().default(30).describe("Number of days to look back for change frequency")}),M=class extends d{changeFrequencyCache=new Map;parseArgs(t){return G.parse(t)}async execute(t){this.changeFrequencyCache.clear();let c=await this.ensureGraphStorageForProject(t.projectPath),m=Math.min(t.limit,200),o=await c.findEntities({filters:{},limit:5e3});t.includeHistoricalMetrics&&(t.metric==="changes"||t.metric==="all")&&await this.preloadChangeFrequencies(o,c,t.lookbackDays);let r=[];for(let l of o){let{score:g,changeMetrics:d}=this.calculateHotspotScore(l,t.metric,t.includeHistoricalMetrics);if(g>0){let i=l.metadata?.metrics??{},a=i.linesOfCode,p=a??(l.location?.end?.line&&l.location?.start?.line?l.location.end.line-l.location.start.line+1:void 0);r.push({id:l.id,name:l.name,type:l.type,filePath:l.filePath,score:Math.round(g*100)/100,metrics:{...i,...p!==void 0&&a===void 0?{linesOfCode:p}:{},...d}});}}r.sort((l,g)=>g.score-l.score);let h=b(r,t.offset,m);return {content:[{type:"text",text:JSON.stringify({metric:t.metric,includeHistoricalMetrics:t.includeHistoricalMetrics,lookbackDays:t.lookbackDays,hotspotsFound:h.data.length,pagination:h.pagination,hotspots:h.data,nextSteps:["graph_metrics({metric:'pagerank'}) \u2014 rank hotspots by architectural importance","taint_analysis() \u2014 check if hotspots contain security vulnerabilities"]},null,2)}]}}async preloadChangeFrequencies(t,c,m){let o=c.getLibSQLAdapter?.(),n=o?.getCommitManager?.(),r=o?.getProllyNodeStore?.(),h=new Map,l=false;for(let i of t)h.set(i.id,{count:0,source:"none"});if(n&&r){let i=Date.now()-m*24*60*60*1e3,a=await n.getCommitsSince(i);if(a.length>=2){l=true;let p=new d$1(r,n);for(let u=0;u<a.length-1;u++){let S=a[u],e=a[u+1];if(!(!S||!e))try{let s=await p.diffCommits(e.commitHash,S.commitHash);if(!s)continue;for(let y of [...s.treeDiff.added,...s.treeDiff.modified,...s.treeDiff.deleted]){let P=h.get(y.key);P&&h.set(y.key,{count:P.count+1,source:"prolly"});}}catch(s){I.w("HOTSPOTS","diff_failed",{error:s.message});}}I.d("HOTSPOTS","prolly_preload_complete",{commits:a.length,withChanges:[...h.values()].filter(u=>u.count>0).length});}else I.d("HOTSPOTS","insufficient_commits",{count:a.length});}else I.d("HOTSPOTS","prolly_not_available",{reason:"missing components"});let g=new Map,d=0;for(let i of t){let a=h.get(i.id);if(!a||a.count>0||!i.filePath)continue;let p=g.get(i.filePath);p===void 0&&(p=this.getChangeFrequencyFromGit(i.filePath,m),g.set(i.filePath,p)),p>0&&(h.set(i.id,{count:p,source:"git"}),d++);}d>0&&I.d("HOTSPOTS","git_fallback_complete",{filesChecked:g.size,entitiesUpdated:d});for(let[i,a]of h)this.changeFrequencyCache.set(i,{changeCount:a.count,source:a.source});I.d("HOTSPOTS","preloaded_change_frequencies",{entities:t.length,prollyAvailable:l,withChanges:[...h.values()].filter(i=>i.count>0).length});}getChangeFrequencyFromGit(t,c){try{let m=new Date(Date.now()-c*24*60*60*1e3).toISOString().split("T")[0];return execSync(`git log --oneline --since="${m}" -- "${t}"`,{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim().split(`
|
|
2
|
+
`).filter(Boolean).length}catch{return 0}}calculateHotspotScore(t,c,m){let o=t.metadata?.metrics||{},n=0,r,h=o.linesOfCode||(t.location?.end?.line&&t.location?.start?.line?t.location.end.line-t.location.start.line+1:0);if(c==="complexity"||c==="all"){n+=(o.cyclomaticComplexity||0)*2,n+=(o.cognitiveComplexity||0)*1.5,n+=(o.nestingDepth||0)*3,n+=h/50;let l=o.parameterCount||0;n+=l>4?(l-4)*2:0;}if(c==="changes"||c==="all")if(m){let l=this.changeFrequencyCache.get(t.id);if(l&&l.changeCount>0){let g=Math.log(l.changeCount+1)*10;n+=g,r={changeFrequency:l.changeCount,changeFrequencyScore:Math.round(g*100)/100,changeSource:l.source};}else r={changeFrequency:0,changeFrequencyScore:0,changeSource:"none"};}else n+=(o.changeFrequency||0)*10;return (c==="coupling"||c==="all")&&(n+=o.couplingScore||0,n+=(o.dependencyCount||0)/5),{score:n,changeMetrics:r}}},$=z.object({entityId:z.string().describe("Entity ID to find related concepts for"),projectPath:a,offset:z.number().optional().default(0),limit:z.number().optional().default(a$1.searchResults)}),O=class extends d{parseArgs(t){return $.parse(t)}async execute(t){let c=await this.ensureGraphStorageForProject(t.projectPath),m=await this.context.getSemanticAgent(),o=Math.min(t.limit,200),n=await c.getEntity(t.entityId);if(!n)return {content:[{type:"text",text:JSON.stringify({error:`Entity not found: ${t.entityId}`})}]};let r=n.name,l=(await m.semanticSearch(r,500)).results||[],g=b(l,t.offset,o),d=await Promise.all(g.data.map(async i=>{try{let a=null,u=i.metadata?.entityId;if(u&&/^[0-9a-f]{12}$/.test(u)&&(a=await c.getEntity(u)),!a&&typeof i.id=="string"&&i.id.startsWith("ent:")){let y=i.id.slice(4);/^[0-9a-f]{12}$/.test(y)&&(a=await c.getEntity(y));}if(!a){let y=u??(typeof i.id=="string"&&i.id.startsWith("ent:")?i.id.slice(4):void 0);if(y&&y.includes(":")){let P=y.lastIndexOf(":"),I=y.slice(P+1);if(I){let k=await c.searchEntities({namePattern:I});a=k.find(j=>j.metadata?.communityId!=null||j.metadata?.pageRank!=null)??k[0]??null;}}}if(!a)return i;let S=a.metadata??{},e=S.communityId,s=S.pageRank;if(e!=null||s!=null)return {...i,...e!=null?{communityId:e}:{},...typeof s=="number"?{pageRank:Math.round(s*1e4)/1e4}:{}}}catch{}return i}));return {content:[{type:"text",text:JSON.stringify({entityId:t.entityId,concept:r,relatedCount:d.length,pagination:g.pagination,related:d},null,2)}]}}},J=z.object({projectPath:a,scope:z.enum(["file","module","project"]).optional().default("project"),stateIdentifiers:z.array(z.string()).optional(),autoDetect:z.boolean().optional().default(true),maxDepth:z.number().optional(),excludePatterns:z.array(z.string()).optional(),format:z.enum(["summary","detailed","json"]).optional().default("summary")}),N=class extends d{parseArgs(t){return J.parse(t)}async execute(t){let c=await this.ensureGraphStorageForProject(t.projectPath),{ChaosAnalyzer:m}=await import('./chaos-CO7TOBOJ.js'),o=new m(c),n=await o.analyze({scope:t.scope||"project",stateIdentifiers:t.stateIdentifiers,autoDetect:t.autoDetect??true,maxDepth:t.maxDepth,excludePatterns:t.excludePatterns}),r=[];for(let d of n){let i=d.statePattern.identifier;if(i)try{let a=await c.searchEntities({namePattern:i}),p=null,u=null;for(let S of a){let e=S.metadata??{};if(e.communityId!=null||e.pageRank!=null){p=e.pageRank,u=e.communityId;break}}a.length>0&&r.push({stateIdentifier:i,pageRank:typeof p=="number"?p:null,communityId:typeof u=="number"?u:null,communityRisk:typeof p=="number"&&p>.7?"high":typeof p=="number"&&p>.4?"medium":"low"});}catch{}}let h=["graph_metrics({metric:'louvain'}) \u2014 cluster chaotic modules by community","graph_metrics({metric:'pagerank'}) \u2014 assess architectural importance of chaotic entities"];if(t.format==="json")return {content:[{type:"text",text:JSON.stringify({statePatterns:n,csharpPatterns:o.csharpPatterns,graphContext:r,nextSteps:h},null,2)}]};if(t.format==="detailed"&&(n.length>0||o.csharpPatterns.length>0)){let d=[];return n.length>0&&d.push(n.map(i=>o.formatDetailed(i)).join(`
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`)),o.csharpPatterns.length>0&&n.length===0&&d.push(o.formatForAI(n)),{content:[{type:"text",text:d.join(`
|
|
7
|
+
|
|
8
|
+
`)}]}}let l=o.formatForAI(n),g=`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
Next steps:
|
|
12
|
+
${h.map(d=>`- ${d}`).join(`
|
|
13
|
+
`)}`;return {content:[{type:"text",text:l+g}]}}},Q=z.object({entityId:z.string().optional(),filePath:z.string().optional(),projectPath:a,depth:z.number().optional().default(3),highlightRecentChanges:z.boolean().optional().default(false).describe("Annotate impacted entities with recently-changed status (Prolly Tree)"),recentCommitsCount:z.number().optional().default(10).describe("Number of recent commits to consider for highlighting")}),D=class extends d{parseArgs(t){return Q.parse(t)}async execute(t){let c=await this.ensureGraphStorageForProject(t.projectPath),m=t.entityId;if(m&&!await c.getEntity(m)){let a=await c.searchEntities({namePattern:m});if(a.length>0)if(t.filePath){let u=(this.context.normalizeInputPath(t.filePath)||"").replace(/\\/g,"/").toLowerCase(),S=a.find(e=>{let s=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return s.includes(u)||s.endsWith(u)});S?m=S.id:m=a[0].id;}else m=a[0].id;else m=void 0;}if(!m&&t.filePath){let i=this.context.normalizeInputPath(t.filePath),a=await c.findEntities({filters:{filePath:i},limit:1});a.length>0&&a[0]&&(m=a[0].id);}if(!m)return {content:[{type:"text",text:JSON.stringify({error:"Entity not found"})}]};let o=await c.getEntity(m),n=await c.getRelationshipsForEntity(m),r=new Set,h=[m],l=0;for(;h.length>0&&l<t.depth;){let i=[];for(let a of h){let p=await c.getRelationshipsForEntity(a);for(let u of p){let S=u.fromId===a?u.toId:u.fromId;!r.has(S)&&S!==m&&(r.add(S),i.push(S));}}h=i,l++;}let g;{let i=Array.from(r),a=await c.getEntitiesBatch(i),p=[],u=[],S=[];for(let[,e]of a)if(e.metadata?.isApiContract){let s=e.metadata.swaggerType;if(s==="endpoint"){let y=`${e.metadata.httpMethod||""} ${e.metadata.path||""}`.trim();p.push(y||e.name);}else s==="schema"&&u.push(e.name);}if(o?.metadata?.isApiContract){let e=o.metadata.swaggerType;if(e==="endpoint"){let s=`${o.metadata.httpMethod||""} ${o.metadata.path||""}`.trim();p.push(s||o.name);}else e==="schema"&&u.push(o.name);}for(let e of n)if(e.type==="consumes_api"||e.metadata?.context?.includes("consumes")){let s=e.fromId===m?e.toId:e.fromId,y=a.get(s);y&&S.push(y.name);}if(p.length>0||u.length>0){let e=p.length>3||u.length>5?"high":p.length>0?"medium":"low";g={affectsApiContract:true,affectedEndpoints:[...new Set(p)],affectedSchemas:[...new Set(u)],breakingChangeRisk:e,consumers:[...new Set(S)],warning:"Changes affect external API contract \u2014 consumers may break"};}}let d;if(t.highlightRecentChanges){let{getRecentlyChangedEntities:i}=await import('./recently-changed-277BN4MZ.js'),a=c.getLibSQLAdapter?.();if(a){let p=await i(a,{lastCommits:t.recentCommitsCount});if(p){let u=0,S=0;for(let s of r)p.addedIds.has(s)?u++:p.modifiedIds.has(s)&&S++;let e=u+S;d={recentlyAddedCount:u,recentlyModifiedCount:S,volatileRatio:r.size>0?Math.round(e/r.size*100)/100:0,commitsAnalyzed:p.commitsAnalyzed};}}}return {content:[{type:"text",text:JSON.stringify({entity:o?{id:o.id,name:o.name,type:o.type}:null,directRelationships:n.length,totalImpactedEntities:r.size,impactDepth:t.depth,riskLevel:r.size>50?"high":r.size>20?"medium":"low",...g?{contractImpact:g}:{},...d?{recentlyChangedImpact:d}:{},nextSteps:["graph_metrics({metric:'pagerank'}) \u2014 assess importance of impacted entities","taint_analysis() \u2014 check if impacted code has security vulnerabilities"]},null,2)}]}}},B=z.object({projectPath:a,swaggerFile:z.string().optional().describe("Path to swagger file (auto-detected if omitted)"),schemaName:z.string().optional().describe("Specific schema name to analyze"),endpointPath:z.string().optional().describe("Specific endpoint like 'GET /api/users'")}),v=class extends d{parseArgs(t){return B.parse(t)}async execute(t){let c=await this.ensureGraphStorageForProject(t.projectPath),m=await c.getAllEntities(),o=await c.getAllRelationships(),n=m.filter(e=>e.metadata?.isApiContract);if(n.length===0)return {content:[{type:"text",text:JSON.stringify({error:"No swagger/OpenAPI specifications found in the project graph. Index a project with swagger files first."})}]};if(t.swaggerFile){let e=this.context.normalizeInputPath(t.swaggerFile);n=n.filter(s=>s.filePath.replace(/\\/g,"/").toLowerCase().includes((e||"").replace(/\\/g,"/").toLowerCase()));}if(t.schemaName&&(n=n.filter(e=>e.metadata?.swaggerType==="schema"&&e.name===t.schemaName)),t.endpointPath){let[e,...s]=t.endpointPath.split(" "),y=s.join(" ");n=n.filter(P=>{if(P.metadata?.swaggerType!=="endpoint")return false;let I=(P.metadata.httpMethod||"").toUpperCase(),k=P.metadata.path||"";return (!e||I===e.toUpperCase())&&(!y||k===y)});}let r=[],h=[],l=[],g=new Set(n.map(e=>e.id)),d=new Map(m.map(e=>[e.id,e]));for(let e of o)if(e.type==="produces_api"){let s=d.get(e.fromId),y=d.get(e.toId);s&&y&&(g.has(e.toId)||g.has(e.fromId))&&r.push({name:s.name,file:s.filePath,type:s.type});}else if(e.type==="consumes_api"){let s=d.get(e.fromId),y=d.get(e.toId);s&&y&&(g.has(e.toId)||g.has(e.fromId))&&h.push({name:s.name,file:s.filePath,type:s.type});}else if(e.type==="generated_from"){let s=d.get(e.fromId),y=d.get(e.toId);s&&y&&(g.has(e.toId)||g.has(e.fromId))&&l.push({name:s.name,file:s.filePath,schemaName:y.name});}let i=r.length+h.length+l.length,a=i>10?"high":i>3?"medium":"low",p=[];h.length>0&&p.push(`${h.length} generated client(s) may need regeneration after swagger changes`),l.length>0&&p.push(`${l.length} generated type(s) are linked to swagger schemas \u2014 regenerate after schema changes`),r.length>0&&p.push(`${r.length} controller(s) produce this API \u2014 update swagger spec after changing these`);let u=n.filter(e=>e.metadata?.swaggerType==="endpoint").map(e=>({name:e.name,method:e.metadata?.httpMethod,path:e.metadata?.path})),S=n.filter(e=>e.metadata?.swaggerType==="schema").map(e=>e.name);return {content:[{type:"text",text:JSON.stringify({swaggerFiles:[...new Set(n.map(e=>e.filePath))],endpoints:u,schemas:S,producers:r,consumers:h,generatedTypes:l,breakingChangeRisk:a,totalAffectedEntities:i,recommendations:p},null,2)}]}}},U=z.object({directory:z.string().optional(),projectPath:a}),_=class extends d{parseArgs(t){return U.parse(t)}async execute(t){let c=t.directory?this.context.normalizeInputPath(t.directory)??this.resolveProjectPath({}):this.resolveProjectPath({projectPath:t.projectPath});try{let{TechnologyDetector:m}=await import('./technology-detector-MM7TXWRB.js'),o=await this.context.getGraphStorage();o.setProject(c);let r=await new m(o,c).detectStack();return {content:[{type:"text",text:JSON.stringify({directory:c,languages:r.languages,frameworks:r.frameworks,buildTools:r.buildTools,dependencies:r.dependencies,confidence:r.confidence},null,2)}]}}catch(m){let o=a$2(m);return {content:[{type:"text",text:JSON.stringify({error:o.message})}]}}}};export{D as AnalyzeCodeImpactToolHandler,M as AnalyzeHotspotsToolHandler,N as AnalyzeStateChaosToolHandler,v as AnalyzeSwaggerImpactToolHandler,_ as DetectTechnologyStackToolHandler,O as FindRelatedConceptsToolHandler,T as SuggestRefactoringToolHandler};
|