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.
- package/dist/chunks/analysis-tool-handlers-H2RXLDPX.js +817 -0
- package/dist/chunks/analysis-tool-handlers-RJZAR6VT.js +817 -0
- package/dist/chunks/analysis-tool-handlers-Z2RF24T7.js +13 -0
- package/dist/chunks/autodoc-tool-handlers-CV5JEQUA.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-EHTNCH6I.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-MECXQJ2K.js +138 -0
- package/dist/chunks/chaos-CO7TOBOJ.js +18 -0
- package/dist/chunks/chaos-VM2PXERO.js +1573 -0
- package/dist/chunks/chaos-W3XRVJ7K.js +1564 -0
- package/dist/chunks/chunk-6K37BWK5.js +439 -0
- package/dist/chunks/chunk-EALTCYHZ.js +10 -0
- package/dist/chunks/chunk-FTBE7VMY.js +316 -0
- package/dist/chunks/chunk-KBW6LRQP.js +322 -0
- package/dist/chunks/chunk-NKUHX4CU.js +5 -0
- package/dist/chunks/chunk-NZFF4DQ4.js +3179 -0
- package/dist/chunks/chunk-RGP5UVQ7.js +3179 -0
- package/dist/chunks/chunk-RMZXFGQZ.js +322 -0
- package/dist/chunks/chunk-UG44F23Y.js +316 -0
- package/dist/chunks/chunk-V2SCB5H5.js +4403 -0
- package/dist/chunks/chunk-V6JAQNM3.js +1 -0
- package/dist/chunks/chunk-XFGXM4CR.js +4403 -0
- package/dist/chunks/dev-agent-JVIGBMHQ.js +1 -0
- package/dist/chunks/dev-agent-TRVP5U6N.js +1624 -0
- package/dist/chunks/dev-agent-Y5G5WKQ4.js +1624 -0
- package/dist/chunks/graph-storage-factory-AYZ57YSL.js +13 -0
- package/dist/chunks/graph-storage-factory-GTAIJEI5.js +1 -0
- package/dist/chunks/graph-storage-factory-T2WO5QVG.js +13 -0
- package/dist/chunks/incremental-updater-KDIQGAUU.js +14 -0
- package/dist/chunks/incremental-updater-OJRSTO3Q.js +1 -0
- package/dist/chunks/incremental-updater-SBEBH7KF.js +14 -0
- package/dist/chunks/indexer-agent-H3QIEL3Z.js +21 -0
- package/dist/chunks/indexer-agent-KHF5JMV7.js +21 -0
- package/dist/chunks/indexer-agent-SHJD6Z77.js +1 -0
- package/dist/chunks/indexing-pipeline-J6Z4BHKF.js +1 -0
- package/dist/chunks/indexing-pipeline-OY3337QN.js +249 -0
- package/dist/chunks/indexing-pipeline-WCXIDMAP.js +249 -0
- package/dist/chunks/merge-agent-LSUBDJB2.js +2481 -0
- package/dist/chunks/merge-agent-MJEW3HWU.js +2481 -0
- package/dist/chunks/merge-agent-O45OXF33.js +11 -0
- package/dist/chunks/merge-tool-handlers-BDSVNQVZ.js +277 -0
- package/dist/chunks/merge-tool-handlers-HP7DRBXJ.js +1 -0
- package/dist/chunks/merge-tool-handlers-RUJAKE3D.js +277 -0
- package/dist/chunks/pattern-tool-handlers-L62W3CXR.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-SAHX2CVW.js +13 -0
- package/dist/chunks/query-agent-3TWDFIMT.js +191 -0
- package/dist/chunks/query-agent-HXQ3BMMF.js +191 -0
- package/dist/chunks/query-agent-USMC2GNG.js +1 -0
- package/dist/chunks/semantic-agent-MQCAWIAB.js +6381 -0
- package/dist/chunks/semantic-agent-NDGR3NAK.js +6381 -0
- package/dist/chunks/semantic-agent-S4ZL6GZC.js +137 -0
- package/dist/index.js +17 -17
- 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,138 @@
|
|
|
1
|
+
import'./chunk-EALTCYHZ.js';import {a,b,c,d as d$1,e,f,g,h,i,j as j$1,k}from'./chunk-VDY3Y3CS.js';import {d}from'./chunk-RPKK6MZA.js';import'./chunk-QBFXI33X.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 {e as e$2}from'./chunk-R7SWWANK.js';import {e as e$1}from'./chunk-SOG7QA72.js';import {a as a$1}from'./chunk-F3VMUQ7O.js';import'./chunk-2KIPXYOB.js';import'./chunk-OG62YNVF.js';import {R,I}from'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import'./chunk-POFMGITV.js';import'./chunk-DXB73IDG.js';import ee,{join}from'path';import {execSync}from'child_process';import {existsSync,mkdirSync,writeFileSync}from'fs';R();var te=["architecture.md","dependencies.md","deployment.md","flow.md","glossary.md","processes.md"],ne={"architecture.md":`# Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
*Describe the high-level architecture of your project here.*
|
|
6
|
+
|
|
7
|
+
## Core Components
|
|
8
|
+
|
|
9
|
+
| Component | Location | Description |
|
|
10
|
+
|-----------|----------|-------------|
|
|
11
|
+
| Example | [\`src/example.ts\`](../src/example.ts) | Description |
|
|
12
|
+
|
|
13
|
+
## Data Flow
|
|
14
|
+
|
|
15
|
+
\`\`\`
|
|
16
|
+
[Request] \u2192 [Handler] \u2192 [Service] \u2192 [Storage]
|
|
17
|
+
\`\`\`
|
|
18
|
+
|
|
19
|
+
## Key Decisions
|
|
20
|
+
|
|
21
|
+
| Decision | Rationale |
|
|
22
|
+
|----------|-----------|
|
|
23
|
+
| Example | Reason |
|
|
24
|
+
|
|
25
|
+
## Related Documents
|
|
26
|
+
|
|
27
|
+
- [\u2192 dependencies.md](./dependencies.md)
|
|
28
|
+
- [\u2192 deployment.md](./deployment.md)
|
|
29
|
+
- [\u2192 processes.md](./processes.md)
|
|
30
|
+
`,"dependencies.md":`# Dependencies
|
|
31
|
+
|
|
32
|
+
## Runtime Dependencies
|
|
33
|
+
|
|
34
|
+
| Package | Version | Purpose |
|
|
35
|
+
|---------|---------|---------|
|
|
36
|
+
| example | ^1.0.0 | Description |
|
|
37
|
+
|
|
38
|
+
## Dev Dependencies
|
|
39
|
+
|
|
40
|
+
| Package | Version | Purpose |
|
|
41
|
+
|---------|---------|---------|
|
|
42
|
+
| typescript | ^5.0.0 | Type checking |
|
|
43
|
+
|
|
44
|
+
## System Requirements
|
|
45
|
+
|
|
46
|
+
- Node.js 18+
|
|
47
|
+
- *Add other requirements*
|
|
48
|
+
|
|
49
|
+
## Optional Dependencies
|
|
50
|
+
|
|
51
|
+
*List optional dependencies and when they are needed.*
|
|
52
|
+
`,"deployment.md":`# Deployment
|
|
53
|
+
|
|
54
|
+
## Build
|
|
55
|
+
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
npm run build
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
| Variable | Default | Description |
|
|
63
|
+
|----------|---------|-------------|
|
|
64
|
+
| NODE_ENV | development | Environment |
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
\`\`\`bash
|
|
69
|
+
npm install
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
## Production Setup
|
|
73
|
+
|
|
74
|
+
*Describe production deployment steps.*
|
|
75
|
+
`,"flow.md":`# Data Flow
|
|
76
|
+
|
|
77
|
+
## Request Flow
|
|
78
|
+
|
|
79
|
+
\`\`\`
|
|
80
|
+
\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
|
|
81
|
+
\u2502 Client \u2502 \u2500\u2500\u25BA \u2502 Handler \u2502 \u2500\u2500\u25BA \u2502 Service \u2502
|
|
82
|
+
\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
|
|
83
|
+
\`\`\`
|
|
84
|
+
|
|
85
|
+
## Key Processes
|
|
86
|
+
|
|
87
|
+
### Process 1
|
|
88
|
+
|
|
89
|
+
1. Step one
|
|
90
|
+
2. Step two
|
|
91
|
+
3. Step three
|
|
92
|
+
|
|
93
|
+
## State Management
|
|
94
|
+
|
|
95
|
+
*Describe how state is managed.*
|
|
96
|
+
`,"glossary.md":`# Glossary
|
|
97
|
+
|
|
98
|
+
## Terms
|
|
99
|
+
|
|
100
|
+
| Term | Definition |
|
|
101
|
+
|------|------------|
|
|
102
|
+
| **Entity** | A code element (function, class, variable) tracked in the graph |
|
|
103
|
+
| **Relationship** | A connection between entities (imports, calls, extends) |
|
|
104
|
+
|
|
105
|
+
## Abbreviations
|
|
106
|
+
|
|
107
|
+
| Abbr | Full Form |
|
|
108
|
+
|------|-----------|
|
|
109
|
+
| AST | Abstract Syntax Tree |
|
|
110
|
+
| MCP | Model Context Protocol |
|
|
111
|
+
`,"processes.md":`# Processes
|
|
112
|
+
|
|
113
|
+
## Development Workflow
|
|
114
|
+
|
|
115
|
+
1. Create feature branch
|
|
116
|
+
2. Implement changes
|
|
117
|
+
3. Run tests
|
|
118
|
+
4. Create PR
|
|
119
|
+
|
|
120
|
+
## Testing
|
|
121
|
+
|
|
122
|
+
\`\`\`bash
|
|
123
|
+
npm test
|
|
124
|
+
\`\`\`
|
|
125
|
+
|
|
126
|
+
## Code Style
|
|
127
|
+
|
|
128
|
+
*Describe code style guidelines.*
|
|
129
|
+
|
|
130
|
+
## Release Process
|
|
131
|
+
|
|
132
|
+
1. Update version
|
|
133
|
+
2. Update changelog
|
|
134
|
+
3. Create release tag
|
|
135
|
+
`};function N(l){existsSync(l)||mkdirSync(l,{recursive:true});for(let e of te){let n=ee.join(l,e);existsSync(n)||writeFileSync(n,ne[e],"utf-8");}}function re(l){try{return execSync("git rev-parse --show-toplevel",{cwd:l,encoding:"utf-8",windowsHide:!0,stdio:["pipe","pipe","pipe"]}).trim()}catch{return l}}async function se(l,e,n){if(l!=="auto")return l;try{let r=(await e())?.getConfig()?.language;if(r&&r!=="auto"&&r!=="en")return r;let{readdir:c,readFile:t}=await import('fs/promises'),{detectLanguageFromText:d,aggregateLanguageDetection:a}=await import('./language-detector-4D6IZXBP.js'),o=n||join(process.cwd(),".autodoc");try{let p=(await c(o)).filter(u=>u.endsWith(".md")).slice(0,5),f=[];for(let u of p)try{let g=await t(join(o,u),"utf-8"),y=d(g);y.confidence>0&&f.push(y);}catch{}if(f.length>0){let u=a(f);if(u.confidence>.3)return I.d("AUTODOCGEN","language_detected",{lang:u.language,conf:u.confidence}),u.language}}catch{}return "en"}catch{return "en"}}async function ie(l,e,n,i){let{detectLLMProviders:r,batchGenerateDocs:c}=await import('./llm-O2QLMW4C.js'),{recommended:t}=await r();if(!t)return I.w("AUTODOCGEN","no_llm_provider",{hint:"Install Ollama or configure TGI/OpenAI"}),{llmStatus:"no_provider_available"};let d=t.selectedModel||t.name;I.i("AUTODOCGEN","using_llm",{provider:t.name,model:d,modules:l.length,lang:n});try{let a=await c(t,l,{concurrency:1,language:n,onProgress:(o,s)=>{I.d("AUTODOCGEN","llm_progress",{completed:o,total:s});}});for(let o of e){let s=a.get(o.path.replace(/AUTODOC\.md$/,"").replace(/[\\/]$/,""));s&&(o.content=s);}return {llmStatus:`using_${t.name}:${d}`}}catch(a){return I.w("AUTODOCGEN","llm_gen_failed",{error:a.message}),{llmStatus:`error_${t.name}`}}}async function ae(l,e,n,i){let{updateModuleDoc:r}=await import('./incremental-updater-OJRSTO3Q.js'),c=0,t=[];for(let d of l)try{let a=d.path.replace(/[\\/]AUTODOC\.md$/,""),o=await r(a,d.path,d.content,{useLlm:n});o.updated&&o.newContent&&(e&&await e.saveDocument(d.path,o.newContent,{autoGenerated:!0}),await e$2(d.path,o.newContent),c++,t.push({path:d.path,changes:o.changes.map(s=>s.description)}));}catch(a){I.w("AUTODOCGEN","incr_update_failed",{path:d.path,error:a.message});try{e&&await e.saveDocument(d.path,d.content,{autoGenerated:!0}),await e$2(d.path,d.content),c++;}catch(o){I.w("AUTODOCGEN","write_failed",{path:d.path,error:o.message});}}return {filesWritten:c,incrementalChanges:t}}async function ce(l,e,n){let i=0;for(let r of l)try{e&&await e.saveDocument(r.path,r.content,{autoGenerated:!0}),await e$2(r.path,r.content),i++;}catch(c){I.w("AUTODOCGEN","write_failed",{path:r.path,error:c.message});}return i}async function U(l,e){let n=e.normalizeInputPath(l.rootDir||"")||process.cwd(),i=re(n),r=l.autodocDir?e.normalizeInputPath(l.autodocDir)||l.autodocDir:join(i,".autodoc"),c=await se(l.language||"auto",e.getAutoDocManager,r);N(r);let t=await e$1({rootDir:n,exclude:l.exclude,maxDepth:l.maxDepth});if(l.module){let s=l.module.toLowerCase();t.modules=t.modules.filter(p=>p.name.toLowerCase()===s||p.name.toLowerCase().includes(s)),t.files=t.files.filter(p=>t.modules.some(f=>p.path.includes(f.path)));}let d="not_requested";l.useLlm&&t.modules.length>0&&(d=(await ie(t.modules,t.files,c)).llmStatus);let a=0,o=[];if(!l.preview){let s=await e.getAutoDocManager();if(l.incremental){let p=await ae(t.files,s,l.useLlm||false);a=p.filesWritten,o=p.incrementalChanges;}else a=await ce(t.files,s);}return {success:true,preview:l.preview||false,useLlm:l.useLlm||false,llmStatus:d,incremental:l.incremental||false,language:c,modulesFound:t.modules.length,filesToGenerate:t.files.length,filesWritten:a,incrementalChanges:l.incremental?o:void 0,modules:t.modules.map(s=>({name:s.name,path:s.path,files:s.files.length,exports:s.exports.slice(0,5)})),files:t.files.map(s=>({path:s.path,type:s.type,preview:l.preview?s.content.slice(0,200)+"...":void 0}))}}R();async function x(l){let e=l.getServiceContainer?.();if(!e)return null;let n=await e.getAutoDocManager();if(n&&!n.isInitialized()){let i=await e.getGraphStorage?.();await n.initialize(i);}return n}function D(){return {content:[{type:"text",text:JSON.stringify({success:false,error:"AutoDoc not enabled. Create .autodoc folder in project root to enable."})}]}}var $=class extends d{parseArgs(e){return a.parse(e)}async execute(e){let n=this.context.getServiceContainer?.();if(!n)return D();let i=await n.getAutoDocManager();return i?(i.setConfig({enabled:e.enabled,language:e.language,docsDir:e.docsDir||join(n.directory,".memory_bank")}),{content:[{type:"text",text:JSON.stringify({success:true,message:"AutoDoc initialized",config:i.getConfig()},null,2)}]}):D()}},V=class extends d{parseArgs(e){return b.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();let i=this.context.normalizeInputPath(e.filePath)||e.filePath,r={type:e.type,autoGenerated:e.autoGenerated},c=await n.saveDocument(i,e.content,r),t=false;try{let{writeDocumentToDisk:o}=await import('./file-sync-X6FXAJ5R.js');await o(i,e.content),t=!0;}catch(o){let s=a$1(o);I.w("AUTODOCTOOL","file_write_failed",{error:s.message,path:i,stack:s.stack});}let d=0,a={savedDocsCount:c.length};if(c.length>0)try{I.i("AUTODOCTOOL","embeddings_start",{docsCount:c.length}),a.step="getSemanticAgent";let o=await this.context.getSemanticAgent();a.hasAgent=!!o,a.agentType=typeof o,I.i("AUTODOCTOOL","embeddings_agent",{hasAgent:!!o,agentType:typeof o}),a.step="getVectorStore";let s=o?.getVectorStore?.();if(a.hasStore=!!s,a.hasGetVectorStoreFn=typeof o?.getVectorStore,I.i("AUTODOCTOOL","embeddings_store",{hasStore:!!s,storeType:typeof s,hasGetVectorStore:typeof o?.getVectorStore}),o&&s){a.step="processing",a.agentAndStoreOk=!0,I.i("AUTODOCTOOL","embeddings_processing",{count:c.length});let p=c.map(u=>u.id),f=await s.getExistingIds(p);I.i("AUTODOCTOOL","embeddings_existing_check",{total:p.length,existing:f.size});for(let u of c){let g=`${u.title}
|
|
136
|
+
|
|
137
|
+
${u.content}`,y=await o.generateEmbedding(g);if(y){let b=f.has(u.id);I.i("AUTODOCTOOL",b?"updating_embedding":"inserting_embedding",{id:u.id,vectorDim:y.length,contentLen:g.length});let O={type:"autodoc",docType:u.type,filePath:u.filePath,section:u.section,title:u.title};b?await s.update(u.id,y,O):await s.insert({id:u.id,content:g.slice(0,1e3),vector:y,metadata:O,createdAt:Date.now()}),d++,I.d("AUTODOCTOOL","embedding_saved",{id:u.id,operation:b?"update":"insert"});}}I.i("AUTODOCTOOL","embeddings_done",{generated:d}),d>0&&(I.i("AUTODOCTOOL","flushing_embeddings"),await s.flushAndSave(),I.i("AUTODOCTOOL","embeddings_flushed"));}else a.skipped=!0,a.reason=`agent=${!!o}, store=${!!s}`,I.w("AUTODOCTOOL","embeddings_skipped",{hasAgent:!!o,hasStore:!!s});}catch(o){let s=a$1(o);a.error=s.message,a.stack=s.stack,I.e("AUTODOCTOOL","embedding_failed",{error:s.message,stack:s.stack});}return {content:[{type:"text",text:JSON.stringify({success:true,message:`Saved ${c.length} sections`,fileWritten:t,embeddingsGenerated:d,debug:a,docs:c.map(o=>({id:o.id,title:o.title,section:o.section}))},null,2)}]}}},J=class extends d{parseArgs(e){return c.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();if(e.docId){let i=await n.getDocument(e.docId);return {content:[{type:"text",text:JSON.stringify({success:!!i,doc:i||null},null,2)}]}}if(e.filePath){let i=this.context.normalizeInputPath(e.filePath)||e.filePath,r=await n.getDocumentsByFile(i);return {content:[{type:"text",text:JSON.stringify({success:true,count:r.length,docs:r},null,2)}]}}return {content:[{type:"text",text:JSON.stringify({success:false,error:"Provide docId or filePath"},null,2)}]}}},W=class extends d{parseArgs(e){return d$1.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();let i=[];if(e.mode==="text"||e.mode==="hybrid"){let r=await n.searchDocsByText(e.query,e.limit);for(let c of r)i.push({id:c.id,title:c.title,filePath:c.filePath,section:c.section,snippet:c.content.slice(0,200),source:"text"});}if(e.mode==="semantic"||e.mode==="hybrid")try{let r=await this.context.getSemanticAgent(),c=r?.getVectorStore?.();if(r&&c){let t=await r.generateEmbedding(e.query);if(I.i("AUTODOCTOOL","search_embedding_generated",{hasEmbedding:!!t,dim:t?.length}),t){let d=await c.searchWithFilters(t,{limit:e.limit,metadataFilter:{type:"autodoc"}});I.i("AUTODOCTOOL","search_results",{count:d.length,ids:d.map(a=>a.id).slice(0,5)});for(let a of d)if(I.d("AUTODOCTOOL","search_result_check",{id:a.id,startsWithDoc:a.id.startsWith("doc::")}),a.id.startsWith("doc::")){let o=await n.getDocument(a.id);o&&!i.some(s=>s.id===o.id)&&i.push({id:o.id,title:o.title,filePath:o.filePath,section:o.section,snippet:o.content.slice(0,200),score:a.similarity,source:"semantic"});}}}}catch(r){let c=a$1(r);I.w("AUTODOCTOOL","semantic_search_err",{error:c.message,stack:c.stack});}return i.sort((r,c)=>(c.score??0)-(r.score??0)),{content:[{type:"text",text:JSON.stringify({success:true,query:e.query,mode:e.mode||"text",resultsCount:i.length,results:i.slice(0,e.limit)},null,2)}]}}},j=class extends d{parseArgs(e$1){return e.parse(e$1)}async execute(e){let n=await x(this.context);if(!n)return D();let i=await n.validateReferences(),r={success:true,total:i.total,valid:i.valid,broken:i.broken.length};if(e.filePath){let c=this.context.normalizeInputPath(e.filePath)||e.filePath;r.brokenInFile=i.broken.filter(t=>t.ref.sourceLocation.filePath===c);}else r.brokenRefs=i.broken.slice(0,20);return {content:[{type:"text",text:JSON.stringify(r,null,2)}]}}},q=class extends d{parseArgs(e){return f.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();let i=await n.getStatus();return {content:[{type:"text",text:JSON.stringify({success:true,status:i},null,2)}]}}},B=class extends d{parseArgs(e){return g.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();let{syncBidirectional:i,syncDbToDisk:r,syncDiskToDb:c}=await import('./file-sync-X6FXAJ5R.js'),t={validated:0,brokenRefs:0,outdatedDocs:0,markedOutdated:[]};if(e.docsDir){let s=this.context.normalizeInputPath(e.docsDir)||e.docsDir,p=async u=>n.getDocumentsByFile(u),f=async()=>n.getAllDocuments();if(e.direction==="disk-to-db"){let u=await c(s,p,async(g,y)=>(await n.saveDocument(g,y),[]),8);t.fileSync={diskToDb:{added:u.added,updated:u.updated,errors:u.errors.map(g=>({path:g.file,error:g.error}))},dbToDisk:{written:[],errors:[]}};}else if(e.direction==="db-to-disk"){let u=await r(f,8);t.fileSync={diskToDb:{added:[],updated:[],errors:[]},dbToDisk:{written:u.written,errors:u.errors.map(g=>({path:g.file,error:g.error}))}};}else {let u=await i(s,p,f,async(g,y)=>(await n.saveDocument(g,y),[]),8);t.fileSync={diskToDb:{added:u.diskToDb.added,updated:u.diskToDb.updated,errors:u.diskToDb.errors.map(g=>({path:g.file,error:g.error}))},dbToDisk:{written:u.dbToDisk.written,errors:u.dbToDisk.errors.map(g=>({path:g.file,error:g.error}))}};}}let d=await n.validateReferences();t.validated=d.total,t.brokenRefs=d.broken.length;let a=await n.getOutdatedDocs();if(t.outdatedDocs=a.length,e.scope==="file"&&e.filePath){let s=this.context.normalizeInputPath(e.filePath)||e.filePath,p=await n.getDocumentsByFile(s);for(let f of p)f.confidence&&f.confidence<.7&&t.markedOutdated.push(f.id);}else t.markedOutdated=a.map(s=>s.docId);let o=t.fileSync?` Files: ${t.fileSync.diskToDb.added.length} added, ${t.fileSync.diskToDb.updated.length} updated, ${t.fileSync.dbToDisk.written.length} written.`:"";return {content:[{type:"text",text:JSON.stringify({success:true,message:`Sync completed. ${t.brokenRefs} broken refs, ${t.outdatedDocs} outdated docs.${o}`,...t},null,2)}]}}},H=class extends d{parseArgs(e){return h.parse(e)}async execute(e){let n=this.context.getServiceContainer?.();if(!n)return D();let i=e.useLlm;if(i===void 0)try{let{detectLLMProviders:c}=await import('./llm-provider-ZCW4DWD3.js'),{recommended:t}=await c();i=!!t;}catch{i=false;}let r=await U({rootDir:e.rootDir,autodocDir:e.autodocDir,exclude:e.exclude,maxDepth:e.maxDepth,module:e.module,useLlm:i,preview:e.preview,incremental:e.incremental,language:e.language},{normalizeInputPath:this.context.normalizeInputPath,requestId:this.context.requestId,getAutoDocManager:n.getAutoDocManager.bind(n)});return {content:[{type:"text",text:JSON.stringify(r,null,2)}]}}},K=class extends d{parseArgs(e){return i.parse(e)}async execute(e){let n=await x(this.context);if(!n)return D();let i=await n.getChangelog({since:e.since,limit:e.limit,branch:e.branch});return {content:[{type:"text",text:JSON.stringify({success:true,entriesCount:i.length,entries:i.map(r=>({id:r.id,timestamp:r.timestamp,date:new Date(r.timestamp).toISOString(),branch:r.branch,summary:r.summary,changesCount:r.changes?.length||0,impactedDocsCount:r.impactedDocs?.length||0}))},null,2)}]}}},Q=class extends d{parseArgs(e){return j$1.parse(e)}async execute(e){let n=this.context.getServiceContainer?.();if(!n)return {content:[{type:"text",text:JSON.stringify({error:"ServiceContainer not available"})}]};let{installPreCommitHook:i,uninstallHooks:r,getHookStatus:c}=await import('./hook-installer-RK74YA5D.js'),t=n.directory;if(e.action==="status"){let a=await c(t);return {content:[{type:"text",text:JSON.stringify({success:true,gitRepo:a.gitRepo,hooksDir:a.hooksDir,preCommitInstalled:a.preCommit},null,2)}]}}if(e.action==="uninstall"){let a=await r(t);return {content:[{type:"text",text:JSON.stringify({success:a.success,removed:a.installed,skipped:a.skipped,errors:a.errors},null,2)}]}}let d=await i(t);return {content:[{type:"text",text:JSON.stringify({success:d.success,installed:d.installed,skipped:d.skipped,errors:d.errors},null,2)}]}}},X=class extends d{parseArgs(e){return k.parse(e)}async execute(e){let{detectLanguageFromText:n,aggregateLanguageDetection:i}=await import('./language-detector-4D6IZXBP.js'),r=[];if(e.scope==="comments"||e.scope==="all"){let a=(await(await this.context.getGraphStorage()).getAllEntities()).slice(0,e.sampleSize*2),o=0;for(let s of a){if(o>=e.sampleSize)break;let p=s.metadata?.comments||s.documentation;if(p){let f=Array.isArray(p)?p.join(`
|
|
138
|
+
`):String(p),u=n(f);u.confidence>0&&(r.push(u),o++);}}}if(e.scope==="docs"||e.scope==="all"){let t=await x(this.context);if(t){let d=await t.searchDocsByText("",e.sampleSize);for(let a of d){let o=n(a.content);o.confidence>0&&r.push(o);}}}let c=i(r);return {content:[{type:"text",text:JSON.stringify({success:true,detectedLanguage:c.language,confidence:Math.round(c.confidence*100)/100,samplesAnalyzed:r.length,charCounts:c.charCounts,recommendation:c.confidence>.5?`Use language: ${c.language}`:"Low confidence - defaulting to 'en'"},null,2)}]}}};export{K as AutoDocChangelogToolHandler,X as AutoDocDetectLanguageToolHandler,H as AutoDocGenerateToolHandler,J as AutoDocGetToolHandler,$ as AutoDocInitToolHandler,Q as AutoDocInstallHooksToolHandler,V as AutoDocSaveToolHandler,W as AutoDocSearchToolHandler,q as AutoDocStatusToolHandler,B as AutoDocSyncToolHandler,j as AutoDocValidateToolHandler};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import {R,I as I$1}from'./chunk-4BI7EBPQ.js';import'./chunk-DXB73IDG.js';function E(d){let e=d.toLowerCase();return ["state","config","context","data","token","user","auth","session","settings","cache","store","value","status","flag","id"].some(n=>e.includes(n))?true:[/^_[a-z]+$/,/^is[A-Z]/,/^has[A-Z]/,/[Ss]tate$/,/[Cc]onfig$/,/Subject$/].some(n=>n.test(d))}R();var z=["Task.Run","Task.Factory.StartNew","Task.WhenAll","Task.WhenAny","Task.Delay","Parallel.ForEach","Parallel.For","Parallel.ForEachAsync","ThreadPool.QueueUserWorkItem","Channel<","Channel.CreateBounded","Channel.CreateUnbounded","Timer","PeriodicTimer","BackgroundService","IHostedService"],j=[/\block\s*\(/,/SemaphoreSlim/,/Monitor\.(Enter|Exit|TryEnter)/,/Interlocked\./,/ReaderWriterLockSlim/,/SpinLock/,/Volatile\.(Read|Write)/,/Mutex/,/ConcurrentDictionary/,/ConcurrentBag/,/ConcurrentQueue/,/ConcurrentStack/,/ImmutableArray/,/ImmutableList/,/ImmutableDictionary/];function A(d){let e=d.name.toLowerCase(),i=d.metadata?.modifiers||[];if(i.includes("readonly")||[/^_log(ger)?$/i,/^_(http)?client$/i,/^_mediator$/i,/^_mapper$/i,/^_sender$/i,/^_(message|event)?bus$/i,/^_publisher$/i,/^_inner$/i,/^_next$/i,/^_handler$/i,/^_service$/i,/^_provider$/i,/^_factory$/i,/^_repository$/i,/^_config(uration)?$/i,/^_options$/i,/^_settings$/i,/^_env(ironment)?$/i].some(a=>a.test(d.name)))return false;if(i.includes("static")&&!i.includes("const")||["state","cache","connection","session","current","singleton","shared","global"].some(a=>e.includes(a))||["config","configuration","settings","options","context","token","instance"].some(a=>e.includes(a))&&!/^_[a-z]/.test(d.name))return true;let o=d.type;return !!(/^_[a-z]/.test(d.name)&&(d.type==="variable"||d.type==="constant"||o==="field"||o==="property")||/^(Is|Has|Can|Should|Current|Last|Previous)/.test(d.name))}function x(d){let e=[],i=new Map;for(let t of d){if(t.language!=="csharp"&&t.metadata?.language!=="csharp")continue;let n=t.metadata?.modifiers||[],s=t.metadata?.returnType||"",o=t.metadata?.parameters||[],a=t.location?.start?.line||0,c=t.type,u=t.type==="variable"||t.type==="constant"||c==="field"||c==="property",r=t.type==="method"||t.type==="function"||c==="constructor";if(u&&n.includes("static")&&!n.includes("readonly")&&!n.includes("const")&&e.push({pattern:"mutable-static",severity:"critical",entityId:t.id,entityName:t.name,filePath:t.filePath,line:a,description:`Mutable static field '${t.name}' \u2014 shared across all threads without protection`,suggestion:"Use ConcurrentDictionary, add readonly, or move state to DI-managed service"}),r&&n.includes("async")&&(s==="void"||s==="Void")&&e.push({pattern:"async-void",severity:"high",entityId:t.id,entityName:t.name,filePath:t.filePath,line:a,description:`async void method '${t.name}' \u2014 exceptions will crash the process`,suggestion:"Replace 'async void' with 'async Task'. Only use async void for event handlers"}),t.type==="class"){let h=i.get(t.filePath)||[];h.push(t),i.set(t.filePath,h);}r&&(t.name===".ctor"||c==="constructor")&&o.length>=10&&e.push({pattern:"god-service",severity:"medium",entityId:t.id,entityName:t.name,filePath:t.filePath,line:a,description:`Constructor with ${o.length} parameters \u2014 likely a God Service violating SRP`,suggestion:"Split into smaller focused services. Group related dependencies into aggregate services"}),r&&n.includes("async")&&s!=="void"&&s!=="Void"&&(s.includes("Task")||s.includes("ValueTask"))&&!o.some(h=>h.type?.includes("CancellationToken"))&&e.push({pattern:"missing-cancellation",severity:"medium",entityId:t.id,entityName:t.name,filePath:t.filePath,line:a,description:`Async method '${t.name}' without CancellationToken \u2014 cannot be cancelled gracefully`,suggestion:"Add CancellationToken parameter and pass it to downstream async calls"}),u&&n.includes("static")&&!n.includes("readonly")&&!n.includes("const")&&((t.metadata?.decorators||[]).some(p=>p.name==="Singleton"||p.name==="SingleInstance"||p.name==="ServiceLifetime.Singleton")||t.name.toLowerCase().includes("singleton"))&&e.push({pattern:"singleton-mutable-state",severity:"high",entityId:t.id,entityName:t.name,filePath:t.filePath,line:a,description:`Singleton class has mutable field '${t.name}' \u2014 concurrent access will cause data races`,suggestion:"Use ConcurrentDictionary/ImmutableCollections, change to Scoped lifetime, or add lock synchronization"});}return e}R();R();var T=["localStorage","sessionStorage","indexedDB","caches","requestAnimationFrame","requestIdleCallback","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","fetch","XMLHttpRequest","WebSocket","EventSource","BroadcastChannel","SharedWorker","ServiceWorker","setTimeout","setInterval","queueMicrotask","history.pushState","history.replaceState","navigator.clipboard","navigator.geolocation","MediaRecorder","RTCPeerConnection","FileReader","FileWriter","Task.Run","Task.Factory.StartNew","Task.WhenAll","Task.WhenAny","Task.Delay","Parallel.ForEach","Parallel.For","Parallel.ForEachAsync","ThreadPool.QueueUserWorkItem","Channel.","Timer","PeriodicTimer"],b=[/\.addEventListener\s*\(/,/\.on[A-Z]\w+\s*=/,/new\s+Promise\s*\(/,/\.then\s*\(/,/\.catch\s*\(/,/\.finally\s*\(/,/callback/i,/handler/i,/listener/i,/\.subscribe\s*\(/,/\.pipe\s*\(/,/rxjs/i,/observable/i,/subject/i,/\$\./,/emit/i,/dispatch/i,/broadcast/i,/async\s+Task/,/async\s+ValueTask/,/\.ConfigureAwait\(/,/CancellationToken/,/IAsyncEnumerable/],k=class{constructor(e){this.storage=e;}_entityCache=null;_relLookup=null;_relCache=new Map;setEntityCache(e){this._entityCache=new Map(e.map(i=>[i.id,i]));}setRelationshipCache(e){this._relLookup=e;}clearEntityCache(){this._entityCache=null,this._relLookup=null,this._relCache.clear();}async getEntityCached(e){return this._entityCache?this._entityCache.get(e)||null:this.storage.getEntity(e)}async analyzeRaces(e,i){let t=i.filter(h=>h.operationType==="read"||h.operationType==="check"),n=i.filter(h=>h.operationType==="write"||h.operationType==="initialize"||h.operationType==="emit"),s=performance.now(),o=await this.analyzeMutations(n),a=performance.now()-s;a>200&&I$1.w("CHAOS_RACE","slow_mutations",{id:e,writers:n.length,ms:+a.toFixed(0),cached:!!this._entityCache});let c=this.calculateRiskFactors(o),u=this.detectConflicts(e,o,t),r=this.calculateRaceRisk(c,u);return {stateIdentifier:e,readers:t.length,writers:n.length,asyncWriters:o.filter(h=>h.isAsync).length,unprotectedWriters:o.filter(h=>!h.hasLock).length,raceRisk:r,raceReason:this.generateRaceReason(c,u),conflicts:u,mutations:o}}async analyzeMutations(e){let i=await Promise.all(e.map(t=>this.isAsyncContext(t)));return e.map((t,n)=>({file:t.file,line:t.line,entityId:t.entityId,entityName:t.entityName,mutationType:this.classifyMutation(t),condition:this.extractCondition(t.context),isAsync:i[n],hasLock:this.detectLockPattern(t.code,t.context),code:t.code}))}async isAsyncContext(e){let i=`${e.code}
|
|
2
|
+
${e.context||""}`;if(/async\s|await\s|\.then\(|Promise|setTimeout|setInterval|\.subscribe\(/.test(i))return true;for(let t of T)if(i.includes(t))return true;for(let t of b)if(t.test(i))return true;if(!e.entityId)return false;try{let t=await this.getEntityCached(e.entityId);if(!t)return !1;if((t.language==="csharp"||t.metadata?.language==="csharp")&&(t.metadata?.modifiers?.includes("async")||/Task|ValueTask/.test(t.metadata?.returnType||"")))return !0;let n=t.code||"";if(/^async\s/.test(n)||/async\s+function/.test(n))return !0;for(let a of T)if(n.includes(a))return !0;for(let a of b)if(a.test(n))return !0;if(this._relCache.has(e.entityId))return this._relCache.get(e.entityId);let s=this._relLookup?.get(e.entityId)||await this.storage.getRelationshipsForEntity(e.entityId),o=!1;for(let a of s)if(a.type==="contains"){let c=await this.getEntityCached(a.fromId);if(c?.name&&/handler|listener|callback|on[A-Z]/i.test(c.name)){o=!0;break}}if(this._relCache.set(e.entityId,o),o)return !0}catch{}return false}detectLockPattern(e,i){let t=[/mutex/i,/lock\(/i,/semaphore/i,/synchronized/i,/atomic/i,/\.lock\(\)/,/await\s+.*lock/i,/critical\s*section/i,/with\s*lock/i,/\block\s*\(/,/SemaphoreSlim/,/Monitor\.(Enter|Exit|TryEnter)/,/Interlocked\./,/ReaderWriterLockSlim/,/SpinLock/,/Volatile\.(Read|Write)/],n=`${e}
|
|
3
|
+
${i}`;return t.some(s=>s.test(n))}extractCondition(e){let i=e.match(/if\s*\(([^)]+)\)/);if(i?.[1])return i[1].trim();let t=e.match(/([^?]+)\s*\?/);if(t?.[1]&&t[1].length<50)return t[1].trim();let n=e.match(/case\s+([^:]+):/);if(n?.[1])return `case ${n[1].trim()}`}classifyMutation(e){let i=e.code.toLowerCase();return /=\s*(null|undefined|false|0|''|""|``)\s*[;,)]/.test(i)||/\.(clear|reset)\(\)/.test(i)?"reset":/\+\+|--|\+=\s*1|-=\s*1/.test(i)?"increment":/=\s*!/.test(i)?"toggle":e.context&&/if\s*\(/.test(e.context)?"conditional-write":"write"}calculateRiskFactors(e){let i=e.filter(a=>a.condition).map(a=>a.condition),t=new Set(i),n=0;for(let a of t){let c=a.startsWith("!")?a.slice(1):`!${a}`;t.has(c)&&n++;}let s=new Map;for(let a of i)s.set(a,(s.get(a)||0)+1);let o=Array.from(s.values()).filter(a=>a>1).length;return {writerCount:e.length,asyncBoundaries:e.filter(a=>a.isAsync).length,sharedConditions:o,oppositeConditions:n/2,hasLocks:e.some(a=>a.hasLock),resetPoints:e.filter(a=>a.mutationType==="reset").length}}detectConflicts(e,i,t){let n=[],s=i.filter(r=>r.mutationType==="reset");s.length>=2&&n.push({pattern:"competing-resets",severity:this.assessConflictSeverity(s),stateIdentifier:e,description:`${s.length} places reset ${e}`,locations:s,explanation:`Multiple functions reset ${e} to initial value. If called concurrently, state may be reset while another function expects it to be set.`,suggestion:"Centralize reset logic in a single function or use state machine pattern"});let o=i.filter(r=>r.mutationType==="conditional-write"&&!r.hasLock);if(o.length>=2){let r=new Map;for(let h of o)if(h.condition){let l=h.condition.replace(/\s+/g,""),p=r.get(l);p||(p=[],r.set(l,p)),p.push(h);}for(let[h,l]of r)l.length>=2&&n.push({pattern:"check-then-act",severity:"high",stateIdentifier:e,description:`${l.length} places check "${h}" then modify ${e}`,locations:l,sharedCondition:h,explanation:"Multiple functions check the same condition before modifying state. Between check and act, another function may change the state.",suggestion:"Use atomic compare-and-swap, mutex, or combine into single handler"});}let a=i.filter(r=>r.isAsync&&!r.hasLock);a.length>=2&&n.push({pattern:"async-boundary",severity:"high",stateIdentifier:e,description:`${a.length} async operations modify ${e} without synchronization`,locations:a,explanation:"Async operations can interleave unpredictably. One operation may overwrite changes from another.",suggestion:"Add mutex/lock or use queue-based state updates"});let c=this.findOppositeConditionGroups(i);for(let r of c)n.push({pattern:"competing-mutations",severity:"critical",stateIdentifier:e,description:`Functions with opposite conditions both modify ${e}`,locations:r,explanation:'Functions checking opposite conditions (e.g., "if (x)" vs "if (!x)") both modify the state. This is a classic race condition pattern where both may execute simultaneously.',suggestion:"Merge into single handler with exclusive logic, or add explicit synchronization"});let u=i.filter(r=>/handler|listener|on[A-Z]|callback/i.test(r.entityName));return u.length>=2&&n.push({pattern:"event-handler-race",severity:"medium",stateIdentifier:e,description:`${u.length} event handlers modify ${e}`,locations:u,explanation:"Multiple event handlers modify shared state. Event ordering may vary, causing unpredictable state.",suggestion:"Consolidate handlers or use event queue with single consumer"}),n}findOppositeConditionGroups(e){let i=[],t=new Set;for(let n=0;n<e.length;n++){let s=e[n];if(t.has(n)||!s||!s.condition)continue;let o=s.condition,a=o.replace(/\s+/g,""),c=o.startsWith("!")?o.slice(1).replace(/\s+/g,""):`!${a}`,u=[s];t.add(n);for(let r=n+1;r<e.length;r++){let h=e[r];if(t.has(r)||!h||!h.condition)continue;let l=h.condition.replace(/\s+/g,"");(l===c||`!${l}`===a)&&(u.push(h),t.add(r));}u.length>=2&&i.push(u);}return i}assessConflictSeverity(e){let i=e.some(s=>s.isAsync),t=e.every(s=>!s.hasLock),n=e.length;return i&&t&&n>=3?"critical":i&&t||n>=3&&t?"high":n>=2&&t?"medium":"low"}calculateRaceRisk(e,i){let t="none";if(e.writerCount===1)return "none";e.writerCount>=2&&(t="low"),e.asyncBoundaries>=2&&!e.hasLocks&&(t="high"),e.oppositeConditions>=1&&(t="high"),e.resetPoints>=2&&e.asyncBoundaries>=1&&(t="critical");for(let n of i)this.riskLevel(n.severity)>this.riskLevel(t)&&(t=n.severity);return t}riskLevel(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}generateRaceReason(e,i){if(e.writerCount<=1)return;let t=[];if(t.push(`${e.writerCount} writers`),e.asyncBoundaries>0&&t.push(`${e.asyncBoundaries} async`),!e.hasLocks&&e.writerCount>=2&&t.push("no sync"),i.length>0){let n=[...new Set(i.map(s=>s.pattern))];t.push(`patterns: ${n.join(", ")}`);}return t.join(", ")}};function I(d){let e=new Map;for(let i of d){let t=e.get(i.fromId);if(t||(t=[],e.set(i.fromId,t)),t.push(i),i.toId!==i.fromId){let n=e.get(i.toId);n||(n=[],e.set(i.toId,n)),n.push(i);}}return e}var v=class{constructor(e){this.storage=e;this.raceDetector=new k(e);}raceDetector;_cachedEntities=null;_cachedFunctions=null;_relLookup=null;async detectPatterns(e,i,t){let n=performance.now();this._cachedEntities=i||await this.storage.getAllEntities(),this._relLookup=t||null;let s=[];this.raceDetector.setEntityCache(this._cachedEntities),this._relLookup&&this.raceDetector.setRelationshipCache(this._relLookup);let o=performance.now();if(this._cachedFunctions=await this.storage.searchEntities({types:["function","method","constructor"]}),I$1.i("CHAOS_DET","preload_functions",{count:this._cachedFunctions.length,ms:+(performance.now()-o).toFixed(0)}),e.stateIdentifiers&&e.stateIdentifiers.length>0){for(let a of e.stateIdentifiers){let c=await this.analyzeIdentifier(a);c&&s.push(c);}I$1.i("CHAOS_DET","manual_identifiers",{count:e.stateIdentifiers.length,matched:s.length,ms:+(performance.now()-n).toFixed(0)});}else if(e.autoDetect){let a=performance.now(),c=this.autoDetectStateIdentifiers(this._cachedEntities);I$1.i("CHAOS_DET","autoDetect",{candidates:c.length,fromEntities:this._cachedEntities.length,ms:+(performance.now()-a).toFixed(0)});for(let u=0;u<c.length;u++){let r=performance.now(),h=await this.analyzeIdentifier(c[u]);h&&s.push(h);let l=performance.now()-r;l>1e3&&I$1.w("CHAOS_DET","slow_identifier",{identifier:c[u],index:u,ms:+l.toFixed(0),ops:h?.operations.length||0,writers:h?.raceAnalysis.writers||0});}I$1.i("CHAOS_DET","all_identifiers",{total:c.length,matched:s.length,ms:+(performance.now()-n).toFixed(0)});}return this._cachedEntities=null,this._cachedFunctions=null,this._relLookup=null,this.raceDetector.clearEntityCache(),s.sort((a,c)=>{let u={critical:0,high:1,medium:2,low:3,none:4};return u[a.raceAnalysis.raceRisk]-u[c.raceAnalysis.raceRisk]})}autoDetectStateIdentifiers(e){let i=new Map;for(let t of e){let s=(t.language||t.metadata?.language)==="csharp",o=t.type;if(!(t.type==="variable"||t.type==="constant"||o==="field"||o==="property"))continue;(s?A(t):E(t.name))&&i.set(t.name,(i.get(t.name)||0)+1);}return Array.from(i.entries()).sort((t,n)=>n[1]-t[1]).slice(0,20).map(([t])=>t)}async analyzeIdentifier(e){let i=performance.now(),t=await this.findStateOperations(e),n=performance.now();if(t.length===0)return null;let s=this.findRelatedIdentifiers(e),o=performance.now(),a=await this.raceDetector.analyzeRaces(e,t),c=performance.now();return I$1.d("CHAOS_DET","analyzeIdentifier",{id:e,ops:t.length,opsMs:+(n-i).toFixed(0),raceMs:+(c-o).toFixed(0),writers:a.writers,risk:a.raceRisk}),{identifier:e,type:this.inferStateType(e,t),scope:this.inferScope(t),operations:t,relatedIdentifiers:s,raceAnalysis:a}}async findStateOperations(e){let i=performance.now(),t=[],n=await this.storage.searchEntities({namePattern:e,types:["variable","constant","field","property"]});for(let r of n)t.push({file:r.filePath,line:r.location?.start?.line||0,column:r.location?.start?.column||0,entityId:r.id,entityName:r.name,operationType:"initialize",code:r.code?.slice(0,200)||"",context:"",isDefensive:false,depth:0});let s=new Map;if(this._cachedEntities)for(let r of this._cachedEntities)s.set(r.id,r);for(let r of n){let h=this._relLookup?.get(r.id)||await this.storage.getRelationshipsForEntity(r.id),l=[];for(let p of h)if(p.type==="references"){let g=p.fromId===r.id?p.toId:p.fromId;g!==r.id&&!s.has(g)&&l.push(g);}if(l.length>0){let p=await this.storage.getEntitiesBatch(l);for(let[g,m]of p)s.set(g,m);}for(let p of h)if(p.type==="references"){let g=p.fromId===r.id?p.toId:p.fromId,m=s.get(g)||null;if(m&&m.id!==r.id){let S=await this.classifyOperation(m,e);t.push({file:m.filePath,line:m.location?.start?.line||0,column:m.location?.start?.column||0,entityId:m.id,entityName:m.name,operationType:S,code:m.code?.slice(0,200)||"",context:await this.getContext(m),isDefensive:this.isDefensiveCode(m.code||""),depth:1});}}}let o=this._cachedFunctions||await this.storage.searchEntities({types:["function","method","constructor"]}),a=new Set(t.map(r=>r.entityId)),c=new RegExp(`\\b${e}\\b`);for(let r of o){if(!r.code||a.has(r.id)||!c.test(r.code))continue;let h=this.classifyOperationFromCode(r.code,e);a.add(r.id),t.push({file:r.filePath,line:r.location?.start?.line||0,column:r.location?.start?.column||0,entityId:r.id,entityName:r.name,operationType:h,code:this.extractRelevantCode(r.code,e),context:"",isDefensive:this.isDefensiveCode(r.code),depth:1});}let u=performance.now()-i;return u>500&&I$1.w("CHAOS_DET","slow_findOps",{identifier:e,vars:n.length,fns:o.length,ops:t.length,ms:+u.toFixed(0)}),t}async classifyOperation(e,i){let t=e.code||"";return this.classifyOperationFromCode(t,i)}classifyOperationFromCode(e,i){return new RegExp(`${i}\\s*=(?!=)`,"g").test(e)?(new RegExp(`${i}\\s*=\\s*(null|undefined|false|0|''|""|\\[\\]|\\{\\})`,"g").test(e),"write"):/\.next\(|\.emit\(/.test(e)?"emit":/\.subscribe\(|\.pipe\(/.test(e)?"subscribe":/\block\s*\(/.test(e)||/Interlocked\./.test(e)?"write":/\bawait\b/.test(e)?"read":new RegExp(`if\\s*\\([^)]*${i}`,"g").test(e)?"check":new RegExp(`\\(\\s*[^)]*${i}[^)]*\\)`,"g").test(e)?"pass":"read"}extractRelevantCode(e,i){let t=e.split(`
|
|
4
|
+
`);for(let n=0;n<t.length;n++)if(t[n]?.includes(i)){let o=Math.max(0,n-1),a=Math.min(t.length,n+2);return t.slice(o,a).join(`
|
|
5
|
+
`).slice(0,200)}return e.slice(0,200)}async getContext(e){return ""}isDefensiveCode(e){return /!==?\s*(null|undefined)|typeof\s+\w+|&&\s*\w+\.|try\s*{|\?\?|\?\./i.test(e)}findRelatedIdentifiers(e){let i=[],t=this._cachedEntities||[],n=[`_${e}`,`${e}_`,`${e}Value`,`${e}State`,`current${e.charAt(0).toUpperCase()}${e.slice(1)}`,`saved${e.charAt(0).toUpperCase()}${e.slice(1)}`,`old${e.charAt(0).toUpperCase()}${e.slice(1)}`,`new${e.charAt(0).toUpperCase()}${e.slice(1)}`];for(let s of t)(n.includes(s.name)||s.name.toLowerCase().includes(e.toLowerCase()))&&s.name!==e&&!i.includes(s.name)&&i.push(s.name);return i.slice(0,5)}inferStateType(e,i){for(let t of i)if(t.operationType==="initialize"&&t.code){let n=t.code.match(new RegExp(`${e}\\s*:\\s*([\\w<>\\[\\]|&]+)`));if(n?.[1])return n[1];if(/=\s*(true|false)/.test(t.code))return "boolean";if(/=\s*\d+/.test(t.code))return "number";if(/=\s*['"`]/.test(t.code))return "string";if(/=\s*\[/.test(t.code))return "array";if(/=\s*\{/.test(t.code))return "object";if(/=\s*new\s+(\w+)/.test(t.code)){let s=t.code.match(/=\s*new\s+(\w+)/);return s?.[1]?s[1]:"unknown"}}return "unknown"}inferScope(e){let i=new Set(e.map(t=>t.file));return i.size===1?"local":i.size<=3?"module":"global"}};var P=class{detector;storage;_csharpPatterns=[];constructor(e){this.storage=e,this.detector=new v(e);}get csharpPatterns(){return this._csharpPatterns}async analyze(e){let i=performance.now(),t=await this.storage.getAllEntities(),n=performance.now();I$1.i("CHAOS","1_getAllEntities",{count:t.length,ms:+(n-i).toFixed(0)});let s=await this.storage.getAllRelationships(),o=I(s),a=performance.now();I$1.i("CHAOS","1b_getAllRelationships",{count:s.length,indexKeys:o.size,ms:+(a-n).toFixed(0)});let c=await this.detector.detectPatterns(e,t,o),u=performance.now();I$1.i("CHAOS","2_detectPatterns",{patterns:c.length,ms:+(u-n).toFixed(0)});let r=[];try{this._csharpPatterns=x(t);}catch{this._csharpPatterns=[];}let h=performance.now();I$1.i("CHAOS","3_csharpPatterns",{count:this._csharpPatterns.length,ms:+(h-u).toFixed(0)});for(let l of c){let{raceAnalysis:p}=l,g=new Set(l.operations.map(f=>f.file)),m=this.calculateChaosScore(l,p),S=this.assessDivergenceRisk(l,p),_=this.generateHotspots(l,p),M=this.generateQuickFixes(l,p),R=this.chooseStrategy(l,p),O={overview:{stateIdentifier:l.identifier,totalFiles:g.size,totalOperations:l.operations.length,chaosScore:m,divergenceRisk:S,raceRisk:p.raceRisk,writers:p.writers,conflicts:p.conflicts.length},hotspots:_,raceConflicts:p.conflicts.map(f=>({pattern:f.pattern,severity:f.severity,locations:f.locations.map($=>`${$.file}:${$.line}`),suggestion:f.suggestion})),quickFixes:M,refactoringStrategy:R,estimatedEffort:this.estimateEffort(l,p)},F=l.operations.filter(f=>f.operationType==="write"||f.operationType==="initialize"||f.operationType==="emit"),C=new Set(F.map(f=>f.file));r.push({statePattern:l,flowMap:{stateIdentifier:l.identifier,origin:{file:l.operations[0]?.file||"",line:l.operations[0]?.line||0,entityName:l.identifier,type:"initialization",code:l.operations[0]?.code||""},nodes:[],edges:[],totalOperations:l.operations.length,mutationPoints:p.writers,maxDepth:Math.max(...l.operations.map(f=>f.depth),0)},metrics:{stateIdentifier:l.identifier,coupling:{score:Math.min(100,g.size*15),affectedComponents:l.operations.length,sharedStateCount:l.relatedIdentifiers.length,bidirectionalBindings:0},defensive:{nullChecks:l.operations.filter(f=>f.isDefensive).length,typeGuards:0,defaultValues:0,tryCatch:0,localCopies:0},mutationSpread:{totalMutations:p.writers,filesWithMutations:C.size,componentsWithMutations:p.mutations.length,averageMutationsPerComponent:C.size>0?p.writers/C.size:0},divergenceRisk:S,complexity:{cyclomaticComplexity:0,cognitiveComplexity:0},score:m},raceAnalysis:p,refactoringPlan:{stateIdentifier:l.identifier,currentMetrics:{stateIdentifier:l.identifier,coupling:{score:Math.min(100,g.size*15),affectedComponents:l.operations.length,sharedStateCount:l.relatedIdentifiers.length,bidirectionalBindings:0},defensive:{nullChecks:l.operations.filter(f=>f.isDefensive).length,typeGuards:0,defaultValues:0,tryCatch:0,localCopies:0},mutationSpread:{totalMutations:p.writers,filesWithMutations:C.size,componentsWithMutations:p.mutations.length,averageMutationsPerComponent:C.size>0?p.writers/C.size:0},divergenceRisk:S,complexity:{cyclomaticComplexity:0,cognitiveComplexity:0},score:m},strategy:R,reasoning:this.generateReasoning(R,p),steps:[],newComponents:[],benefits:{reducedCoupling:R==="Service"?40:R==="ImmutableState"?50:60,reducedMutations:Math.floor(p.writers/2),reducedComplexity:p.conflicts.length>0?50:30,improvedTestability:true,improvedMaintainability:true,estimatedLOCChange:0},risks:p.conflicts.length>0?["\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044F \u0442\u0449\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u0438"]:[],prerequisites:[]},summary:O,timestamp:new Date().toISOString()});}return I$1.i("CHAOS","4_total",{entities:t.length,statePatterns:c.length,csharpPatterns:this._csharpPatterns.length,results:r.length,totalMs:+(performance.now()-i).toFixed(0)}),r}formatForAI(e){if(e.length===0&&this._csharpPatterns.length===0)return "No state patterns detected.";let i=[`# State Chaos Analysis
|
|
6
|
+
`];for(let t of e){let{summary:n,raceAnalysis:s}=t,{overview:o}=n,a=this.getRiskEmoji(o.raceRisk);if(i.push(`## ${a} ${o.stateIdentifier}`),i.push(`Chaos: ${o.chaosScore}/100 | Files: ${o.totalFiles} | Writers: ${o.writers} | Race: ${o.raceRisk}`),s.conflicts.length>0){i.push(`
|
|
7
|
+
**\u26A0\uFE0F Race Conditions:**`);for(let c of s.conflicts)i.push(`- **${c.pattern}** (${c.severity})`),i.push(` ${c.explanation}`),i.push(` \u{1F4CD} ${c.locations.map(u=>`${u.entityName}:${u.line}`).join(", ")}`),i.push(` \u{1F4A1} ${c.suggestion}`);}if(n.quickFixes.length>0){i.push(`
|
|
8
|
+
**Quick Fixes:**`);for(let c of n.quickFixes)i.push(`- ${c}`);}i.push(`
|
|
9
|
+
**Strategy:** ${n.refactoringStrategy}`),i.push(`**Effort:** ${n.estimatedEffort}
|
|
10
|
+
`),i.push(`---
|
|
11
|
+
`);}return this._csharpPatterns.length>0&&i.push(this.formatCSharpPatternsForAI()),i.join(`
|
|
12
|
+
`)}formatCSharpPatternsForAI(){let e=[`
|
|
13
|
+
# C# Anti-Patterns
|
|
14
|
+
`],i=new Map;for(let n of this._csharpPatterns){let s=i.get(n.pattern)||[];s.push(n),i.set(n.pattern,s);}let t={critical:"\u{1F534}",high:"\u{1F7E0}",medium:"\u{1F7E1}"};for(let[n,s]of i){let o=s[0].severity;e.push(`## ${t[o]||"\u26AA"} ${n} (${s.length} found)`);for(let a of s.slice(0,10))e.push(`- **${a.entityName}** ${a.filePath}:${a.line}`),e.push(` ${a.description}`),e.push(` \u{1F4A1} ${a.suggestion}`);s.length>10&&e.push(` ... and ${s.length-10} more`),e.push("");}return e.join(`
|
|
15
|
+
`)}formatDetailed(e){let{statePattern:i,raceAnalysis:t,metrics:n,summary:s}=e,o=[];if(o.push(`# \u0410\u043D\u0430\u043B\u0438\u0437 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u044F: ${i.identifier}`),o.push(`**\u0422\u0438\u043F:** ${i.type||"unknown"}`),o.push(`**Scope:** ${i.scope}`),o.push(""),o.push("## \u041C\u0435\u0442\u0440\u0438\u043A\u0438"),o.push(`- **Chaos Score:** ${n.score}/100`),o.push(`- **Divergence Risk:** ${n.divergenceRisk}`),o.push(`- **Race Risk:** ${t.raceRisk}`),o.push(`- **\u041E\u043F\u0435\u0440\u0430\u0446\u0438\u0439:** ${i.operations.length}`),o.push(`- **\u0424\u0430\u0439\u043B\u043E\u0432:** ${new Set(i.operations.map(a=>a.file)).size}`),o.push(`- **\u041F\u0438\u0441\u0430\u0442\u0435\u043B\u0435\u0439:** ${t.writers} (async: ${t.asyncWriters})`),o.push(""),t.conflicts.length>0){o.push("## \u26A0\uFE0F \u041E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0435 \u0433\u043E\u043D\u043A\u0438");for(let a of t.conflicts){o.push(`### ${a.pattern} (${a.severity})`),o.push(`**\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435:** ${a.description}`),o.push(`**\u041E\u0431\u044A\u044F\u0441\u043D\u0435\u043D\u0438\u0435:** ${a.explanation}`),o.push("**\u041B\u043E\u043A\u0430\u0446\u0438\u0438:**");for(let c of a.locations)o.push(`- \`${c.entityName}\` \u0432 ${c.file}:${c.line}`),c.condition&&o.push(` \u0423\u0441\u043B\u043E\u0432\u0438\u0435: \`${c.condition}\``);o.push(`**\u0420\u0435\u043A\u043E\u043C\u0435\u043D\u0434\u0430\u0446\u0438\u044F:** ${a.suggestion}`),o.push("");}}if(t.mutations.length>0){o.push("## \u0422\u043E\u0447\u043A\u0438 \u043C\u0443\u0442\u0430\u0446\u0438\u0438");for(let a of t.mutations){let c=[];a.isAsync&&c.push("async"),a.hasLock||c.push("no-lock");let u=c.length>0?` [${c.join(", ")}]`:"";o.push(`- **${a.entityName}** (${a.mutationType})${u}`),o.push(` ${a.file}:${a.line}`),a.condition&&o.push(` \u0423\u0441\u043B\u043E\u0432\u0438\u0435: \`${a.condition}\``);}o.push("");}return i.relatedIdentifiers.length>0&&(o.push("## \u0421\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u044B"),o.push(i.relatedIdentifiers.map(a=>`\`${a}\``).join(", ")),o.push("")),o.push("## \u0420\u0435\u043A\u043E\u043C\u0435\u043D\u0434\u0430\u0446\u0438\u0438"),o.push(`**\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044F:** ${s.refactoringStrategy}`),o.push(`**\u041E\u0431\u043E\u0441\u043D\u043E\u0432\u0430\u043D\u0438\u0435:** ${e.refactoringPlan.reasoning}`),o.push(`**Effort:** ${s.estimatedEffort}`),o.join(`
|
|
16
|
+
`)}calculateChaosScore(e,i){let t=Math.min(50,e.operations.length*3),n=Math.min(20,new Set(e.operations.map(o=>o.file)).size*5),s=this.raceRiskToScore(i.raceRisk);return Math.min(100,t+n+s)}raceRiskToScore(e){return {none:0,low:5,medium:15,high:25,critical:30}[e]}assessDivergenceRisk(e,i){let t=e.operations.length,n=new Set(e.operations.map(o=>o.file)).size,s=i.raceRisk;return s==="critical"||s==="high"&&t>=10?"critical":s==="high"||n>=5&&t>=15?"high":s==="medium"||n>=3&&t>=8?"medium":"low"}generateHotspots(e,i){let t=[];for(let n of i.conflicts)for(let s of n.locations)t.push({file:s.file,entity:s.entityName,issues:[n.pattern,n.description],priority:n.severity==="critical"||n.severity==="high"?"high":"medium"});for(let n of i.mutations)if(n.isAsync&&!n.hasLock){let s=t.find(o=>o.file===n.file&&o.entity===n.entityName);s?s.issues.push("unprotected async write"):t.push({file:n.file,entity:n.entityName,issues:["unprotected async write"],priority:"medium"});}return t.sort((n,s)=>n.priority==="high"?-1:s.priority==="high"?1:0).slice(0,5)}generateQuickFixes(e,i){let t=[];i.conflicts.some(s=>s.pattern==="competing-resets")&&t.push("\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u0435 \u0444\u0443\u043D\u043A\u0446\u0438\u0438 \u0441\u0431\u0440\u043E\u0441\u0430 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u044F \u0432 \u0435\u0434\u0438\u043D\u044B\u0439 \u043C\u0435\u0442\u043E\u0434 reset()"),i.asyncWriters>0&&i.unprotectedWriters>0&&t.push("\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043C\u044C\u044E\u0442\u0435\u043A\u0441 \u0438\u043B\u0438 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 queue \u0434\u043B\u044F \u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u044B\u0445 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0439"),i.conflicts.some(s=>s.pattern==="check-then-act")&&t.push("\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0430\u0442\u043E\u043C\u0430\u0440\u043D\u044B\u0435 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043B\u0438 compare-and-swap \u043F\u0430\u0442\u0442\u0435\u0440\u043D"),e.relatedIdentifiers.length>2&&t.push(`\u041A\u043E\u043D\u0441\u043E\u043B\u0438\u0434\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0432\u044F\u0437\u0430\u043D\u043D\u044B\u0435 \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435: ${e.relatedIdentifiers.slice(0,3).join(", ")}`),new Set(e.operations.map(s=>s.file)).size>3&&t.push("\u0421\u043E\u0437\u0434\u0430\u0439\u0442\u0435 \u0446\u0435\u043D\u0442\u0440\u0430\u043B\u0438\u0437\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043B\u044F \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u044F \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435\u043C");let n=e.operations.map(s=>s.code).join(`
|
|
17
|
+
`);return /async\s+void\b/.test(n)&&t.push("\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u0435 'async void' \u043D\u0430 'async Task' \u2014 async void \u043D\u0435 \u043E\u0431\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 \u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F"),/static\b/.test(n)&&!/readonly|const|ConcurrentDictionary/.test(n)&&t.push("\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 ConcurrentDictionary \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u043C\u0435\u0441\u0442\u0438\u0442\u0435 state \u0432 DI-managed service"),/\.ctor|constructor/i.test(e.identifier)&&e.operations.length>10&&t.push("\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u0435 god-service \u043D\u0430 \u043C\u0435\u043D\u044C\u0448\u0438\u0435 \u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044B"),/async\s+Task/.test(n)&&!/CancellationToken/.test(n)&&t.push("\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 CancellationToken \u0432 async \u043C\u0435\u0442\u043E\u0434\u044B"),t}chooseStrategy(e,i){if(i.raceRisk==="critical"||i.conflicts.length>=3)return "StateMachine";let t=e.operations.map(o=>o.code).join(`
|
|
18
|
+
`);if(/\bTask\b|\basync\s+Task\b|\bawait\b.*\.\w+Async\b/.test(t)||e.operations.some(o=>o.file.endsWith(".cs"))){if(/static\b/.test(t)&&/Singleton|AddSingleton/.test(t))return "DI_Lifetime";if(i.raceRisk==="high"&&i.asyncWriters>2)return "Channel";if(i.writers>5&&i.unprotectedWriters>3)return "ImmutableState"}return i.raceRisk==="high"&&i.asyncWriters>2?"EventBus":new Set(e.operations.map(o=>o.file)).size>5?"Store":(e.operations.some(o=>o.angularPattern==="behavior_subject"),"Service")}generateReasoning(e,i){return {StateMachine:`\u041E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u044B \u043A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0435 \u0433\u043E\u043D\u043A\u0438 (${i.conflicts.length} \u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442\u043E\u0432). State machine \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0438\u0442 \u044F\u0432\u043D\u044B\u0435 \u043F\u0435\u0440\u0435\u0445\u043E\u0434\u044B \u0438 \u043F\u0440\u0435\u0434\u043E\u0442\u0432\u0440\u0430\u0442\u0438\u0442 invalid states.`,EventBus:`${i.asyncWriters} \u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u044B\u0445 \u043F\u0438\u0441\u0430\u0442\u0435\u043B\u0435\u0439 \u0441\u043E\u0437\u0434\u0430\u044E\u0442 \u043D\u0435\u043F\u0440\u0435\u0434\u0441\u043A\u0430\u0437\u0443\u0435\u043C\u043E\u0435 \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435. Event-driven \u0430\u0440\u0445\u0438\u0442\u0435\u043A\u0442\u0443\u0440\u0430 \u0443\u043F\u043E\u0440\u044F\u0434\u043E\u0447\u0438\u0442 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F.`,Store:"\u0421\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435 \u0440\u0430\u0437\u0431\u0440\u043E\u0441\u0430\u043D\u043E \u043F\u043E \u043C\u043D\u043E\u0433\u0438\u043C \u0444\u0430\u0439\u043B\u0430\u043C. \u0426\u0435\u043D\u0442\u0440\u0430\u043B\u0438\u0437\u043E\u0432\u0430\u043D\u043D\u044B\u0439 store \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0438\u0442 single source of truth.",Service:"\u0426\u0435\u043D\u0442\u0440\u0430\u043B\u0438\u0437\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u043F\u0440\u043E\u0441\u0442\u0438\u0442 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435\u043C \u0438 \u0434\u043E\u0431\u0430\u0432\u0438\u0442 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C \u0434\u043E\u0441\u0442\u0443\u043F\u0430.",Context:"Context API \u043F\u043E\u0434\u043E\u0439\u0434\u0451\u0442 \u0434\u043B\u044F \u043F\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u044F \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0440\u0435\u0432\u043E \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432.",Signal:"Angular Signals \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0430\u0442 \u0440\u0435\u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0441\u0442\u044C \u0441 \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u043C \u043E\u0442\u0441\u043B\u0435\u0436\u0438\u0432\u0430\u043D\u0438\u0435\u043C \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0435\u0439.",StateManager:"\u041A\u0430\u0441\u0442\u043E\u043C\u043D\u044B\u0439 StateManager \u043F\u043E\u0437\u0432\u043E\u043B\u0438\u0442 \u0440\u0435\u0430\u043B\u0438\u0437\u043E\u0432\u0430\u0442\u044C \u0441\u043F\u0435\u0446\u0438\u0444\u0438\u0447\u043D\u0443\u044E \u043B\u043E\u0433\u0438\u043A\u0443 \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u0438.",DI_Lifetime:"Mutable state \u0432 Singleton-\u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0432\u044B\u0437\u044B\u0432\u0430\u0435\u0442 \u0433\u043E\u043D\u043A\u0438. \u0418\u0437\u043C\u0435\u043D\u0438\u0442\u0435 lifetime \u043D\u0430 Scoped \u0438\u043B\u0438 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 ImmutableDictionary.",Channel:`${i.asyncWriters} async producer/consumer \u043D\u0443\u0436\u0434\u0430\u044E\u0442\u0441\u044F \u0432 \u0443\u043F\u043E\u0440\u044F\u0434\u043E\u0447\u0435\u043D\u043D\u043E\u0439 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0435. System.Threading.Channels \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0438\u0442 \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u0443\u044E \u043E\u0447\u0435\u0440\u0435\u0434\u044C.`,ImmutableState:"\u041C\u043D\u043E\u0436\u0435\u0441\u0442\u0432\u043E \u043D\u0435\u043A\u043E\u043D\u0442\u0440\u043E\u043B\u0438\u0440\u0443\u0435\u043C\u044B\u0445 \u043C\u0443\u0442\u0430\u0446\u0438\u0439. \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 record types \u0438 ImmutableCollections \u0434\u043B\u044F \u043F\u0440\u0435\u0434\u043E\u0442\u0432\u0440\u0430\u0449\u0435\u043D\u0438\u044F \u0433\u043E\u043D\u043E\u043A."}[e]}estimateEffort(e,i){let t=new Set(e.operations.map(s=>s.file)).size,n=i.conflicts.length;return n>=3||t>10?"\u0412\u044B\u0441\u043E\u043A\u0430\u044F (1-2 \u043D\u0435\u0434\u0435\u043B\u0438)":n>=1||t>5?"\u0421\u0440\u0435\u0434\u043D\u044F\u044F (2-5 \u0434\u043D\u0435\u0439)":"\u041D\u0438\u0437\u043A\u0430\u044F (1-2 \u0434\u043D\u044F)"}getRiskEmoji(e){return {none:"\u2705",low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F7E0}",critical:"\u{1F534}"}[e]}};export{z as CSHARP_ASYNC_APIS,j as CSHARP_LOCK_PATTERNS,P as ChaosAnalyzer,k as RaceDetector,v as StateDetector,x as detectCSharpChaosPatterns,A as isCSharpStateIdentifier,E as isStateIdentifier};
|