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,1112 @@
|
|
|
1
|
+
import './chunk-FTBE7VMY.js';
|
|
2
|
+
import { AutoDocInitSchema, AutoDocSaveSchema, AutoDocGetSchema, AutoDocSearchSchema, AutoDocValidateSchema, AutoDocStatusSchema, AutoDocSyncSchema, AutoDocGenerateSchema, AutoDocChangelogSchema, AutoDocInstallHooksSchema, AutoDocDetectLanguageSchema } from './chunk-JP4AKI4T.js';
|
|
3
|
+
import { BaseToolHandler } from './chunk-WLKASYMP.js';
|
|
4
|
+
import './chunk-KMXE2SJJ.js';
|
|
5
|
+
import './chunk-V2SCB5H5.js';
|
|
6
|
+
import './chunk-HNDYLCWI.js';
|
|
7
|
+
import './chunk-CTXFPNDA.js';
|
|
8
|
+
import './chunk-TJSOOFXA.js';
|
|
9
|
+
import './chunk-AIZUHUK6.js';
|
|
10
|
+
import './chunk-L2X4HRXI.js';
|
|
11
|
+
import './chunk-ZD54CMKT.js';
|
|
12
|
+
import './chunk-HEMJHRHZ.js';
|
|
13
|
+
import { writeDocumentToDisk } from './chunk-5RGY76OC.js';
|
|
14
|
+
import { generateDocs } from './chunk-EOTZN6YO.js';
|
|
15
|
+
import { toError } from './chunk-5WKPA33T.js';
|
|
16
|
+
import './chunk-F7CKCMXI.js';
|
|
17
|
+
import './chunk-BMHPPH2B.js';
|
|
18
|
+
import { init_logging, log } from './chunk-VCCBEJQ5.js';
|
|
19
|
+
import './chunk-UN27MREV.js';
|
|
20
|
+
import './chunk-EZDL43GB.js';
|
|
21
|
+
import './chunk-NAQKA54E.js';
|
|
22
|
+
import path, { join } from 'path';
|
|
23
|
+
import { execSync } from 'child_process';
|
|
24
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
25
|
+
|
|
26
|
+
// src/autodoc/generator/generate-handler-utils.ts
|
|
27
|
+
init_logging();
|
|
28
|
+
var GENERAL_DOC_FILES = [
|
|
29
|
+
"architecture.md",
|
|
30
|
+
"dependencies.md",
|
|
31
|
+
"deployment.md",
|
|
32
|
+
"flow.md",
|
|
33
|
+
"glossary.md",
|
|
34
|
+
"processes.md"
|
|
35
|
+
];
|
|
36
|
+
var TEMPLATES = {
|
|
37
|
+
"architecture.md": `# Architecture
|
|
38
|
+
|
|
39
|
+
## Overview
|
|
40
|
+
|
|
41
|
+
*Describe the high-level architecture of your project here.*
|
|
42
|
+
|
|
43
|
+
## Core Components
|
|
44
|
+
|
|
45
|
+
| Component | Location | Description |
|
|
46
|
+
|-----------|----------|-------------|
|
|
47
|
+
| Example | [\`src/example.ts\`](../src/example.ts) | Description |
|
|
48
|
+
|
|
49
|
+
## Data Flow
|
|
50
|
+
|
|
51
|
+
\`\`\`
|
|
52
|
+
[Request] \u2192 [Handler] \u2192 [Service] \u2192 [Storage]
|
|
53
|
+
\`\`\`
|
|
54
|
+
|
|
55
|
+
## Key Decisions
|
|
56
|
+
|
|
57
|
+
| Decision | Rationale |
|
|
58
|
+
|----------|-----------|
|
|
59
|
+
| Example | Reason |
|
|
60
|
+
|
|
61
|
+
## Related Documents
|
|
62
|
+
|
|
63
|
+
- [\u2192 dependencies.md](./dependencies.md)
|
|
64
|
+
- [\u2192 deployment.md](./deployment.md)
|
|
65
|
+
- [\u2192 processes.md](./processes.md)
|
|
66
|
+
`,
|
|
67
|
+
"dependencies.md": `# Dependencies
|
|
68
|
+
|
|
69
|
+
## Runtime Dependencies
|
|
70
|
+
|
|
71
|
+
| Package | Version | Purpose |
|
|
72
|
+
|---------|---------|---------|
|
|
73
|
+
| example | ^1.0.0 | Description |
|
|
74
|
+
|
|
75
|
+
## Dev Dependencies
|
|
76
|
+
|
|
77
|
+
| Package | Version | Purpose |
|
|
78
|
+
|---------|---------|---------|
|
|
79
|
+
| typescript | ^5.0.0 | Type checking |
|
|
80
|
+
|
|
81
|
+
## System Requirements
|
|
82
|
+
|
|
83
|
+
- Node.js 18+
|
|
84
|
+
- *Add other requirements*
|
|
85
|
+
|
|
86
|
+
## Optional Dependencies
|
|
87
|
+
|
|
88
|
+
*List optional dependencies and when they are needed.*
|
|
89
|
+
`,
|
|
90
|
+
"deployment.md": `# Deployment
|
|
91
|
+
|
|
92
|
+
## Build
|
|
93
|
+
|
|
94
|
+
\`\`\`bash
|
|
95
|
+
npm run build
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
| Variable | Default | Description |
|
|
101
|
+
|----------|---------|-------------|
|
|
102
|
+
| NODE_ENV | development | Environment |
|
|
103
|
+
|
|
104
|
+
## Installation
|
|
105
|
+
|
|
106
|
+
\`\`\`bash
|
|
107
|
+
npm install
|
|
108
|
+
\`\`\`
|
|
109
|
+
|
|
110
|
+
## Production Setup
|
|
111
|
+
|
|
112
|
+
*Describe production deployment steps.*
|
|
113
|
+
`,
|
|
114
|
+
"flow.md": `# Data Flow
|
|
115
|
+
|
|
116
|
+
## Request Flow
|
|
117
|
+
|
|
118
|
+
\`\`\`
|
|
119
|
+
\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
|
|
120
|
+
\u2502 Client \u2502 \u2500\u2500\u25BA \u2502 Handler \u2502 \u2500\u2500\u25BA \u2502 Service \u2502
|
|
121
|
+
\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
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
## Key Processes
|
|
125
|
+
|
|
126
|
+
### Process 1
|
|
127
|
+
|
|
128
|
+
1. Step one
|
|
129
|
+
2. Step two
|
|
130
|
+
3. Step three
|
|
131
|
+
|
|
132
|
+
## State Management
|
|
133
|
+
|
|
134
|
+
*Describe how state is managed.*
|
|
135
|
+
`,
|
|
136
|
+
"glossary.md": `# Glossary
|
|
137
|
+
|
|
138
|
+
## Terms
|
|
139
|
+
|
|
140
|
+
| Term | Definition |
|
|
141
|
+
|------|------------|
|
|
142
|
+
| **Entity** | A code element (function, class, variable) tracked in the graph |
|
|
143
|
+
| **Relationship** | A connection between entities (imports, calls, extends) |
|
|
144
|
+
|
|
145
|
+
## Abbreviations
|
|
146
|
+
|
|
147
|
+
| Abbr | Full Form |
|
|
148
|
+
|------|-----------|
|
|
149
|
+
| AST | Abstract Syntax Tree |
|
|
150
|
+
| MCP | Model Context Protocol |
|
|
151
|
+
`,
|
|
152
|
+
"processes.md": `# Processes
|
|
153
|
+
|
|
154
|
+
## Development Workflow
|
|
155
|
+
|
|
156
|
+
1. Create feature branch
|
|
157
|
+
2. Implement changes
|
|
158
|
+
3. Run tests
|
|
159
|
+
4. Create PR
|
|
160
|
+
|
|
161
|
+
## Testing
|
|
162
|
+
|
|
163
|
+
\`\`\`bash
|
|
164
|
+
npm test
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
## Code Style
|
|
168
|
+
|
|
169
|
+
*Describe code style guidelines.*
|
|
170
|
+
|
|
171
|
+
## Release Process
|
|
172
|
+
|
|
173
|
+
1. Update version
|
|
174
|
+
2. Update changelog
|
|
175
|
+
3. Create release tag
|
|
176
|
+
`
|
|
177
|
+
};
|
|
178
|
+
function ensureGeneralDocs(autodocDir) {
|
|
179
|
+
if (!existsSync(autodocDir)) {
|
|
180
|
+
mkdirSync(autodocDir, { recursive: true });
|
|
181
|
+
}
|
|
182
|
+
for (const filename of GENERAL_DOC_FILES) {
|
|
183
|
+
const filePath = path.join(autodocDir, filename);
|
|
184
|
+
if (!existsSync(filePath)) {
|
|
185
|
+
writeFileSync(filePath, TEMPLATES[filename], "utf-8");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/autodoc/generator/generate-handler-utils.ts
|
|
191
|
+
function findRepoRoot(targetDir) {
|
|
192
|
+
try {
|
|
193
|
+
return execSync("git rev-parse --show-toplevel", {
|
|
194
|
+
cwd: targetDir,
|
|
195
|
+
encoding: "utf-8",
|
|
196
|
+
windowsHide: true,
|
|
197
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
198
|
+
}).trim();
|
|
199
|
+
} catch {
|
|
200
|
+
return targetDir;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function detectDocLanguage(requestedLang, getAutoDocManager, autodocDir) {
|
|
204
|
+
if (requestedLang !== "auto") {
|
|
205
|
+
return requestedLang;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
const adm = await getAutoDocManager();
|
|
209
|
+
const configLang = adm?.getConfig()?.language;
|
|
210
|
+
if (configLang && configLang !== "auto" && configLang !== "en") {
|
|
211
|
+
return configLang;
|
|
212
|
+
}
|
|
213
|
+
const { readdir, readFile } = await import('fs/promises');
|
|
214
|
+
const { detectLanguageFromText, aggregateLanguageDetection } = await import('./language-detector-2YC3ZIGH.js');
|
|
215
|
+
const targetDir = autodocDir || join(process.cwd(), ".autodoc");
|
|
216
|
+
try {
|
|
217
|
+
const files = await readdir(targetDir);
|
|
218
|
+
const mdFiles = files.filter((f) => f.endsWith(".md")).slice(0, 5);
|
|
219
|
+
const results = [];
|
|
220
|
+
for (const file of mdFiles) {
|
|
221
|
+
try {
|
|
222
|
+
const content = await readFile(join(targetDir, file), "utf-8");
|
|
223
|
+
const result = detectLanguageFromText(content);
|
|
224
|
+
if (result.confidence > 0) {
|
|
225
|
+
results.push(result);
|
|
226
|
+
}
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (results.length > 0) {
|
|
231
|
+
const aggregated = aggregateLanguageDetection(results);
|
|
232
|
+
if (aggregated.confidence > 0.3) {
|
|
233
|
+
log.d("AUTODOCGEN", "language_detected", { lang: aggregated.language, conf: aggregated.confidence });
|
|
234
|
+
return aggregated.language;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
} catch {
|
|
238
|
+
}
|
|
239
|
+
return "en";
|
|
240
|
+
} catch {
|
|
241
|
+
return "en";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async function enhanceWithLLM(modules, files, docLanguage, _context) {
|
|
245
|
+
const { detectLLMProviders, batchGenerateDocs } = await import('./llm-YL3RLYED.js');
|
|
246
|
+
const { recommended } = await detectLLMProviders();
|
|
247
|
+
if (!recommended) {
|
|
248
|
+
log.w("AUTODOCGEN", "no_llm_provider", { hint: "Install Ollama or configure TGI/OpenAI" });
|
|
249
|
+
return { llmStatus: "no_provider_available" };
|
|
250
|
+
}
|
|
251
|
+
const modelName = recommended.selectedModel || recommended.name;
|
|
252
|
+
log.i("AUTODOCGEN", "using_llm", {
|
|
253
|
+
provider: recommended.name,
|
|
254
|
+
model: modelName,
|
|
255
|
+
modules: modules.length,
|
|
256
|
+
lang: docLanguage
|
|
257
|
+
});
|
|
258
|
+
try {
|
|
259
|
+
const enhancedDocs = await batchGenerateDocs(recommended, modules, {
|
|
260
|
+
concurrency: 1,
|
|
261
|
+
language: docLanguage,
|
|
262
|
+
onProgress: (completed, total) => {
|
|
263
|
+
log.d("AUTODOCGEN", "llm_progress", { completed, total });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
for (const file of files) {
|
|
267
|
+
const enhanced = enhancedDocs.get(file.path.replace(/AUTODOC\.md$/, "").replace(/[\\/]$/, ""));
|
|
268
|
+
if (enhanced) {
|
|
269
|
+
file.content = enhanced;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return { llmStatus: `using_${recommended.name}:${modelName}` };
|
|
273
|
+
} catch (error) {
|
|
274
|
+
log.w("AUTODOCGEN", "llm_gen_failed", { error: error.message });
|
|
275
|
+
return { llmStatus: `error_${recommended.name}` };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async function writeFilesIncremental(files, adm, useLlm, _context) {
|
|
279
|
+
const { updateModuleDoc } = await import('./incremental-updater-KDIQGAUU.js');
|
|
280
|
+
let filesWritten = 0;
|
|
281
|
+
const incrementalChanges = [];
|
|
282
|
+
for (const file of files) {
|
|
283
|
+
try {
|
|
284
|
+
const modulePath = file.path.replace(/[\\/]AUTODOC\.md$/, "");
|
|
285
|
+
const updateResult = await updateModuleDoc(modulePath, file.path, file.content, { useLlm });
|
|
286
|
+
if (updateResult.updated && updateResult.newContent) {
|
|
287
|
+
if (adm) {
|
|
288
|
+
await adm.saveDocument(file.path, updateResult.newContent, { autoGenerated: true });
|
|
289
|
+
}
|
|
290
|
+
await writeDocumentToDisk(file.path, updateResult.newContent);
|
|
291
|
+
filesWritten++;
|
|
292
|
+
incrementalChanges.push({
|
|
293
|
+
path: file.path,
|
|
294
|
+
changes: updateResult.changes.map((c) => c.description)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
} catch (error) {
|
|
298
|
+
log.w("AUTODOCGEN", "incr_update_failed", { path: file.path, error: error.message });
|
|
299
|
+
try {
|
|
300
|
+
if (adm) {
|
|
301
|
+
await adm.saveDocument(file.path, file.content, { autoGenerated: true });
|
|
302
|
+
}
|
|
303
|
+
await writeDocumentToDisk(file.path, file.content);
|
|
304
|
+
filesWritten++;
|
|
305
|
+
} catch (innerError) {
|
|
306
|
+
log.w("AUTODOCGEN", "write_failed", { path: file.path, error: innerError.message });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return { filesWritten, incrementalChanges };
|
|
311
|
+
}
|
|
312
|
+
async function writeFilesOverwrite(files, adm, _context) {
|
|
313
|
+
let filesWritten = 0;
|
|
314
|
+
for (const file of files) {
|
|
315
|
+
try {
|
|
316
|
+
if (adm) {
|
|
317
|
+
await adm.saveDocument(file.path, file.content, { autoGenerated: true });
|
|
318
|
+
}
|
|
319
|
+
await writeDocumentToDisk(file.path, file.content);
|
|
320
|
+
filesWritten++;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
log.w("AUTODOCGEN", "write_failed", { path: file.path, error: error.message });
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return filesWritten;
|
|
326
|
+
}
|
|
327
|
+
async function executeGenerateDocs(options, context) {
|
|
328
|
+
const targetDir = context.normalizeInputPath(options.rootDir || "") || process.cwd();
|
|
329
|
+
const repoRoot = findRepoRoot(targetDir);
|
|
330
|
+
const targetAutodocDir = options.autodocDir ? context.normalizeInputPath(options.autodocDir) || options.autodocDir : join(repoRoot, ".autodoc");
|
|
331
|
+
const docLanguage = await detectDocLanguage(options.language || "auto", context.getAutoDocManager, targetAutodocDir);
|
|
332
|
+
ensureGeneralDocs(targetAutodocDir);
|
|
333
|
+
const result = await generateDocs({
|
|
334
|
+
rootDir: targetDir,
|
|
335
|
+
exclude: options.exclude,
|
|
336
|
+
maxDepth: options.maxDepth
|
|
337
|
+
});
|
|
338
|
+
if (options.module) {
|
|
339
|
+
const filterLower = options.module.toLowerCase();
|
|
340
|
+
result.modules = result.modules.filter(
|
|
341
|
+
(m) => m.name.toLowerCase() === filterLower || m.name.toLowerCase().includes(filterLower)
|
|
342
|
+
);
|
|
343
|
+
result.files = result.files.filter((f) => result.modules.some((m) => f.path.includes(m.path)));
|
|
344
|
+
}
|
|
345
|
+
let llmStatus = "not_requested";
|
|
346
|
+
if (options.useLlm && result.modules.length > 0) {
|
|
347
|
+
const llmResult = await enhanceWithLLM(result.modules, result.files, docLanguage);
|
|
348
|
+
llmStatus = llmResult.llmStatus;
|
|
349
|
+
}
|
|
350
|
+
let filesWritten = 0;
|
|
351
|
+
let incrementalChanges = [];
|
|
352
|
+
if (!options.preview) {
|
|
353
|
+
const adm = await context.getAutoDocManager();
|
|
354
|
+
if (options.incremental) {
|
|
355
|
+
const writeResult = await writeFilesIncremental(result.files, adm, options.useLlm || false);
|
|
356
|
+
filesWritten = writeResult.filesWritten;
|
|
357
|
+
incrementalChanges = writeResult.incrementalChanges;
|
|
358
|
+
} else {
|
|
359
|
+
filesWritten = await writeFilesOverwrite(result.files, adm);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
success: true,
|
|
364
|
+
preview: options.preview || false,
|
|
365
|
+
useLlm: options.useLlm || false,
|
|
366
|
+
llmStatus,
|
|
367
|
+
incremental: options.incremental || false,
|
|
368
|
+
language: docLanguage,
|
|
369
|
+
modulesFound: result.modules.length,
|
|
370
|
+
filesToGenerate: result.files.length,
|
|
371
|
+
filesWritten,
|
|
372
|
+
incrementalChanges: options.incremental ? incrementalChanges : void 0,
|
|
373
|
+
modules: result.modules.map((m) => ({
|
|
374
|
+
name: m.name,
|
|
375
|
+
path: m.path,
|
|
376
|
+
files: m.files.length,
|
|
377
|
+
exports: m.exports.slice(0, 5)
|
|
378
|
+
})),
|
|
379
|
+
files: result.files.map((f) => ({
|
|
380
|
+
path: f.path,
|
|
381
|
+
type: f.type,
|
|
382
|
+
preview: options.preview ? f.content.slice(0, 200) + "..." : void 0
|
|
383
|
+
}))
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/tools/handlers/autodoc-tool-handlers.ts
|
|
388
|
+
init_logging();
|
|
389
|
+
async function getAutoDocManagerFromContext(context) {
|
|
390
|
+
const container = context.getServiceContainer?.();
|
|
391
|
+
if (!container) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
const adm = await container.getAutoDocManager();
|
|
395
|
+
if (adm && !adm.isInitialized()) {
|
|
396
|
+
const graphStorage = await container.getGraphStorage?.();
|
|
397
|
+
await adm.initialize(graphStorage);
|
|
398
|
+
}
|
|
399
|
+
return adm;
|
|
400
|
+
}
|
|
401
|
+
function autodocNotEnabledResult() {
|
|
402
|
+
return {
|
|
403
|
+
content: [
|
|
404
|
+
{
|
|
405
|
+
type: "text",
|
|
406
|
+
text: JSON.stringify({
|
|
407
|
+
success: false,
|
|
408
|
+
error: "AutoDoc not enabled. Create .autodoc folder in project root to enable."
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
var AutoDocInitToolHandler = class extends BaseToolHandler {
|
|
415
|
+
parseArgs(args) {
|
|
416
|
+
return AutoDocInitSchema.parse(args);
|
|
417
|
+
}
|
|
418
|
+
async execute(args) {
|
|
419
|
+
const container = this.context.getServiceContainer?.();
|
|
420
|
+
if (!container) {
|
|
421
|
+
return autodocNotEnabledResult();
|
|
422
|
+
}
|
|
423
|
+
const adm = await container.getAutoDocManager();
|
|
424
|
+
if (!adm) {
|
|
425
|
+
return autodocNotEnabledResult();
|
|
426
|
+
}
|
|
427
|
+
adm.setConfig({
|
|
428
|
+
enabled: args.enabled,
|
|
429
|
+
language: args.language,
|
|
430
|
+
docsDir: args.docsDir || join(container.directory, ".memory_bank")
|
|
431
|
+
});
|
|
432
|
+
return {
|
|
433
|
+
content: [
|
|
434
|
+
{
|
|
435
|
+
type: "text",
|
|
436
|
+
text: JSON.stringify(
|
|
437
|
+
{
|
|
438
|
+
success: true,
|
|
439
|
+
message: "AutoDoc initialized",
|
|
440
|
+
config: adm.getConfig()
|
|
441
|
+
},
|
|
442
|
+
null,
|
|
443
|
+
2
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
]
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
var AutoDocSaveToolHandler = class extends BaseToolHandler {
|
|
451
|
+
parseArgs(args) {
|
|
452
|
+
return AutoDocSaveSchema.parse(args);
|
|
453
|
+
}
|
|
454
|
+
async execute(args) {
|
|
455
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
456
|
+
if (!adm) {
|
|
457
|
+
return autodocNotEnabledResult();
|
|
458
|
+
}
|
|
459
|
+
const normalizedPath = this.context.normalizeInputPath(args.filePath) || args.filePath;
|
|
460
|
+
const saveOptions = {
|
|
461
|
+
type: args.type,
|
|
462
|
+
autoGenerated: args.autoGenerated
|
|
463
|
+
};
|
|
464
|
+
const savedDocs = await adm.saveDocument(normalizedPath, args.content, saveOptions);
|
|
465
|
+
let fileWritten = false;
|
|
466
|
+
try {
|
|
467
|
+
const { writeDocumentToDisk: writeDocumentToDisk2 } = await import('./file-sync-F6G6OINI.js');
|
|
468
|
+
await writeDocumentToDisk2(normalizedPath, args.content);
|
|
469
|
+
fileWritten = true;
|
|
470
|
+
} catch (error) {
|
|
471
|
+
const err = toError(error);
|
|
472
|
+
log.w("AUTODOCTOOL", "file_write_failed", { error: err.message, path: normalizedPath, stack: err.stack });
|
|
473
|
+
}
|
|
474
|
+
let embeddingsGenerated = 0;
|
|
475
|
+
const debugInfo = { savedDocsCount: savedDocs.length };
|
|
476
|
+
if (savedDocs.length > 0) {
|
|
477
|
+
try {
|
|
478
|
+
log.i("AUTODOCTOOL", "embeddings_start", { docsCount: savedDocs.length });
|
|
479
|
+
debugInfo.step = "getSemanticAgent";
|
|
480
|
+
const semanticAgent = await this.context.getSemanticAgent();
|
|
481
|
+
debugInfo.hasAgent = !!semanticAgent;
|
|
482
|
+
debugInfo.agentType = typeof semanticAgent;
|
|
483
|
+
log.i("AUTODOCTOOL", "embeddings_agent", { hasAgent: !!semanticAgent, agentType: typeof semanticAgent });
|
|
484
|
+
debugInfo.step = "getVectorStore";
|
|
485
|
+
const vectorStore = semanticAgent?.getVectorStore?.();
|
|
486
|
+
debugInfo.hasStore = !!vectorStore;
|
|
487
|
+
debugInfo.hasGetVectorStoreFn = typeof semanticAgent?.getVectorStore;
|
|
488
|
+
log.i("AUTODOCTOOL", "embeddings_store", {
|
|
489
|
+
hasStore: !!vectorStore,
|
|
490
|
+
storeType: typeof vectorStore,
|
|
491
|
+
hasGetVectorStore: typeof semanticAgent?.getVectorStore
|
|
492
|
+
});
|
|
493
|
+
if (semanticAgent && vectorStore) {
|
|
494
|
+
debugInfo.step = "processing";
|
|
495
|
+
debugInfo.agentAndStoreOk = true;
|
|
496
|
+
log.i("AUTODOCTOOL", "embeddings_processing", { count: savedDocs.length });
|
|
497
|
+
const docIds = savedDocs.map((d) => d.id);
|
|
498
|
+
const existingIds = await vectorStore.getExistingIds(docIds);
|
|
499
|
+
log.i("AUTODOCTOOL", "embeddings_existing_check", { total: docIds.length, existing: existingIds.size });
|
|
500
|
+
for (const doc of savedDocs) {
|
|
501
|
+
const textToEmbed = `${doc.title}
|
|
502
|
+
|
|
503
|
+
${doc.content}`;
|
|
504
|
+
const embedding = await semanticAgent.generateEmbedding(textToEmbed);
|
|
505
|
+
if (embedding) {
|
|
506
|
+
const exists = existingIds.has(doc.id);
|
|
507
|
+
log.i("AUTODOCTOOL", exists ? "updating_embedding" : "inserting_embedding", {
|
|
508
|
+
id: doc.id,
|
|
509
|
+
vectorDim: embedding.length,
|
|
510
|
+
contentLen: textToEmbed.length
|
|
511
|
+
});
|
|
512
|
+
const metadata = {
|
|
513
|
+
type: "autodoc",
|
|
514
|
+
docType: doc.type,
|
|
515
|
+
filePath: doc.filePath,
|
|
516
|
+
section: doc.section,
|
|
517
|
+
title: doc.title
|
|
518
|
+
};
|
|
519
|
+
if (exists) {
|
|
520
|
+
await vectorStore.update(doc.id, embedding, metadata);
|
|
521
|
+
} else {
|
|
522
|
+
await vectorStore.insert({
|
|
523
|
+
id: doc.id,
|
|
524
|
+
content: textToEmbed.slice(0, 1e3),
|
|
525
|
+
vector: embedding,
|
|
526
|
+
metadata,
|
|
527
|
+
createdAt: Date.now()
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
embeddingsGenerated++;
|
|
531
|
+
log.d("AUTODOCTOOL", "embedding_saved", { id: doc.id, operation: exists ? "update" : "insert" });
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
log.i("AUTODOCTOOL", "embeddings_done", { generated: embeddingsGenerated });
|
|
535
|
+
if (embeddingsGenerated > 0) {
|
|
536
|
+
log.i("AUTODOCTOOL", "flushing_embeddings");
|
|
537
|
+
await vectorStore.flushAndSave();
|
|
538
|
+
log.i("AUTODOCTOOL", "embeddings_flushed");
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
debugInfo.skipped = true;
|
|
542
|
+
debugInfo.reason = `agent=${!!semanticAgent}, store=${!!vectorStore}`;
|
|
543
|
+
log.w("AUTODOCTOOL", "embeddings_skipped", { hasAgent: !!semanticAgent, hasStore: !!vectorStore });
|
|
544
|
+
}
|
|
545
|
+
} catch (error) {
|
|
546
|
+
const err = toError(error);
|
|
547
|
+
debugInfo.error = err.message;
|
|
548
|
+
debugInfo.stack = err.stack;
|
|
549
|
+
log.e("AUTODOCTOOL", "embedding_failed", { error: err.message, stack: err.stack });
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
content: [
|
|
554
|
+
{
|
|
555
|
+
type: "text",
|
|
556
|
+
text: JSON.stringify(
|
|
557
|
+
{
|
|
558
|
+
success: true,
|
|
559
|
+
message: `Saved ${savedDocs.length} sections`,
|
|
560
|
+
fileWritten,
|
|
561
|
+
embeddingsGenerated,
|
|
562
|
+
debug: debugInfo,
|
|
563
|
+
docs: savedDocs.map((d) => ({
|
|
564
|
+
id: d.id,
|
|
565
|
+
title: d.title,
|
|
566
|
+
section: d.section
|
|
567
|
+
}))
|
|
568
|
+
},
|
|
569
|
+
null,
|
|
570
|
+
2
|
|
571
|
+
)
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
var AutoDocGetToolHandler = class extends BaseToolHandler {
|
|
578
|
+
parseArgs(args) {
|
|
579
|
+
return AutoDocGetSchema.parse(args);
|
|
580
|
+
}
|
|
581
|
+
async execute(args) {
|
|
582
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
583
|
+
if (!adm) {
|
|
584
|
+
return autodocNotEnabledResult();
|
|
585
|
+
}
|
|
586
|
+
if (args.docId) {
|
|
587
|
+
const doc = await adm.getDocument(args.docId);
|
|
588
|
+
return {
|
|
589
|
+
content: [
|
|
590
|
+
{
|
|
591
|
+
type: "text",
|
|
592
|
+
text: JSON.stringify(
|
|
593
|
+
{
|
|
594
|
+
success: !!doc,
|
|
595
|
+
doc: doc || null
|
|
596
|
+
},
|
|
597
|
+
null,
|
|
598
|
+
2
|
|
599
|
+
)
|
|
600
|
+
}
|
|
601
|
+
]
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
if (args.filePath) {
|
|
605
|
+
const normalizedPath = this.context.normalizeInputPath(args.filePath) || args.filePath;
|
|
606
|
+
const docs = await adm.getDocumentsByFile(normalizedPath);
|
|
607
|
+
return {
|
|
608
|
+
content: [
|
|
609
|
+
{
|
|
610
|
+
type: "text",
|
|
611
|
+
text: JSON.stringify(
|
|
612
|
+
{
|
|
613
|
+
success: true,
|
|
614
|
+
count: docs.length,
|
|
615
|
+
docs
|
|
616
|
+
},
|
|
617
|
+
null,
|
|
618
|
+
2
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
]
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
content: [
|
|
626
|
+
{
|
|
627
|
+
type: "text",
|
|
628
|
+
text: JSON.stringify({ success: false, error: "Provide docId or filePath" }, null, 2)
|
|
629
|
+
}
|
|
630
|
+
]
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var AutoDocSearchToolHandler = class extends BaseToolHandler {
|
|
635
|
+
parseArgs(args) {
|
|
636
|
+
return AutoDocSearchSchema.parse(args);
|
|
637
|
+
}
|
|
638
|
+
async execute(args) {
|
|
639
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
640
|
+
if (!adm) {
|
|
641
|
+
return autodocNotEnabledResult();
|
|
642
|
+
}
|
|
643
|
+
const searchResults = [];
|
|
644
|
+
if (args.mode === "text" || args.mode === "hybrid") {
|
|
645
|
+
const textResults = await adm.searchDocsByText(args.query, args.limit);
|
|
646
|
+
for (const d of textResults) {
|
|
647
|
+
searchResults.push({
|
|
648
|
+
id: d.id,
|
|
649
|
+
title: d.title,
|
|
650
|
+
filePath: d.filePath,
|
|
651
|
+
section: d.section,
|
|
652
|
+
snippet: d.content.slice(0, 200),
|
|
653
|
+
source: "text"
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (args.mode === "semantic" || args.mode === "hybrid") {
|
|
658
|
+
try {
|
|
659
|
+
const semanticAgent = await this.context.getSemanticAgent();
|
|
660
|
+
const vectorStore = semanticAgent?.getVectorStore?.();
|
|
661
|
+
if (semanticAgent && vectorStore) {
|
|
662
|
+
const queryEmbedding = await semanticAgent.generateEmbedding(args.query);
|
|
663
|
+
log.i("AUTODOCTOOL", "search_embedding_generated", {
|
|
664
|
+
hasEmbedding: !!queryEmbedding,
|
|
665
|
+
dim: queryEmbedding?.length
|
|
666
|
+
});
|
|
667
|
+
if (queryEmbedding) {
|
|
668
|
+
const semanticResults = await vectorStore.searchWithFilters(queryEmbedding, {
|
|
669
|
+
limit: args.limit,
|
|
670
|
+
metadataFilter: { type: "autodoc" }
|
|
671
|
+
});
|
|
672
|
+
log.i("AUTODOCTOOL", "search_results", {
|
|
673
|
+
count: semanticResults.length,
|
|
674
|
+
ids: semanticResults.map((r) => r.id).slice(0, 5)
|
|
675
|
+
});
|
|
676
|
+
for (const result of semanticResults) {
|
|
677
|
+
log.d("AUTODOCTOOL", "search_result_check", {
|
|
678
|
+
id: result.id,
|
|
679
|
+
startsWithDoc: result.id.startsWith("doc::")
|
|
680
|
+
});
|
|
681
|
+
if (result.id.startsWith("doc::")) {
|
|
682
|
+
const doc = await adm.getDocument(result.id);
|
|
683
|
+
if (doc && !searchResults.some((r) => r.id === doc.id)) {
|
|
684
|
+
searchResults.push({
|
|
685
|
+
id: doc.id,
|
|
686
|
+
title: doc.title,
|
|
687
|
+
filePath: doc.filePath,
|
|
688
|
+
section: doc.section,
|
|
689
|
+
snippet: doc.content.slice(0, 200),
|
|
690
|
+
score: result.similarity,
|
|
691
|
+
source: "semantic"
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
} catch (error) {
|
|
699
|
+
const err = toError(error);
|
|
700
|
+
log.w("AUTODOCTOOL", "semantic_search_err", { error: err.message, stack: err.stack });
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
searchResults.sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
704
|
+
return {
|
|
705
|
+
content: [
|
|
706
|
+
{
|
|
707
|
+
type: "text",
|
|
708
|
+
text: JSON.stringify(
|
|
709
|
+
{
|
|
710
|
+
success: true,
|
|
711
|
+
query: args.query,
|
|
712
|
+
mode: args.mode || "text",
|
|
713
|
+
resultsCount: searchResults.length,
|
|
714
|
+
results: searchResults.slice(0, args.limit)
|
|
715
|
+
},
|
|
716
|
+
null,
|
|
717
|
+
2
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
]
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
var AutoDocValidateToolHandler = class extends BaseToolHandler {
|
|
725
|
+
parseArgs(args) {
|
|
726
|
+
return AutoDocValidateSchema.parse(args);
|
|
727
|
+
}
|
|
728
|
+
async execute(args) {
|
|
729
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
730
|
+
if (!adm) {
|
|
731
|
+
return autodocNotEnabledResult();
|
|
732
|
+
}
|
|
733
|
+
const validation = await adm.validateReferences();
|
|
734
|
+
const result = {
|
|
735
|
+
success: true,
|
|
736
|
+
total: validation.total,
|
|
737
|
+
valid: validation.valid,
|
|
738
|
+
broken: validation.broken.length
|
|
739
|
+
};
|
|
740
|
+
if (args.filePath) {
|
|
741
|
+
const normalizedPath = this.context.normalizeInputPath(args.filePath) || args.filePath;
|
|
742
|
+
result.brokenInFile = validation.broken.filter(
|
|
743
|
+
(b) => b.ref.sourceLocation.filePath === normalizedPath
|
|
744
|
+
);
|
|
745
|
+
} else {
|
|
746
|
+
result.brokenRefs = validation.broken.slice(0, 20);
|
|
747
|
+
}
|
|
748
|
+
return {
|
|
749
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
var AutoDocStatusToolHandler = class extends BaseToolHandler {
|
|
754
|
+
parseArgs(args) {
|
|
755
|
+
return AutoDocStatusSchema.parse(args);
|
|
756
|
+
}
|
|
757
|
+
async execute(_args) {
|
|
758
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
759
|
+
if (!adm) {
|
|
760
|
+
return autodocNotEnabledResult();
|
|
761
|
+
}
|
|
762
|
+
const status = await adm.getStatus();
|
|
763
|
+
return {
|
|
764
|
+
content: [
|
|
765
|
+
{
|
|
766
|
+
type: "text",
|
|
767
|
+
text: JSON.stringify(
|
|
768
|
+
{
|
|
769
|
+
success: true,
|
|
770
|
+
status
|
|
771
|
+
},
|
|
772
|
+
null,
|
|
773
|
+
2
|
|
774
|
+
)
|
|
775
|
+
}
|
|
776
|
+
]
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
var AutoDocSyncToolHandler = class extends BaseToolHandler {
|
|
781
|
+
parseArgs(args) {
|
|
782
|
+
return AutoDocSyncSchema.parse(args);
|
|
783
|
+
}
|
|
784
|
+
async execute(args) {
|
|
785
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
786
|
+
if (!adm) {
|
|
787
|
+
return autodocNotEnabledResult();
|
|
788
|
+
}
|
|
789
|
+
const { syncBidirectional, syncDbToDisk, syncDiskToDb } = await import('./file-sync-F6G6OINI.js');
|
|
790
|
+
const syncResult = {
|
|
791
|
+
validated: 0,
|
|
792
|
+
brokenRefs: 0,
|
|
793
|
+
outdatedDocs: 0,
|
|
794
|
+
markedOutdated: []
|
|
795
|
+
};
|
|
796
|
+
if (args.docsDir) {
|
|
797
|
+
const normalizedDocsDir = this.context.normalizeInputPath(args.docsDir) || args.docsDir;
|
|
798
|
+
const getDocsAsEntities = async (fp) => {
|
|
799
|
+
return adm.getDocumentsByFile(fp);
|
|
800
|
+
};
|
|
801
|
+
const getAllDocsAsEntities = async () => {
|
|
802
|
+
return adm.getAllDocuments();
|
|
803
|
+
};
|
|
804
|
+
if (args.direction === "disk-to-db") {
|
|
805
|
+
const diskToDb = await syncDiskToDb(
|
|
806
|
+
normalizedDocsDir,
|
|
807
|
+
getDocsAsEntities,
|
|
808
|
+
async (fp, content) => {
|
|
809
|
+
await adm.saveDocument(fp, content);
|
|
810
|
+
return [];
|
|
811
|
+
},
|
|
812
|
+
8
|
|
813
|
+
);
|
|
814
|
+
syncResult.fileSync = {
|
|
815
|
+
diskToDb: {
|
|
816
|
+
added: diskToDb.added,
|
|
817
|
+
updated: diskToDb.updated,
|
|
818
|
+
errors: diskToDb.errors.map((e) => ({ path: e.file, error: e.error }))
|
|
819
|
+
},
|
|
820
|
+
dbToDisk: { written: [], errors: [] }
|
|
821
|
+
};
|
|
822
|
+
} else if (args.direction === "db-to-disk") {
|
|
823
|
+
const dbToDisk = await syncDbToDisk(getAllDocsAsEntities, 8);
|
|
824
|
+
syncResult.fileSync = {
|
|
825
|
+
diskToDb: { added: [], updated: [], errors: [] },
|
|
826
|
+
dbToDisk: {
|
|
827
|
+
written: dbToDisk.written,
|
|
828
|
+
errors: dbToDisk.errors.map((e) => ({ path: e.file, error: e.error }))
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
} else {
|
|
832
|
+
const bidirectional = await syncBidirectional(
|
|
833
|
+
normalizedDocsDir,
|
|
834
|
+
getDocsAsEntities,
|
|
835
|
+
getAllDocsAsEntities,
|
|
836
|
+
async (fp, content) => {
|
|
837
|
+
await adm.saveDocument(fp, content);
|
|
838
|
+
return [];
|
|
839
|
+
},
|
|
840
|
+
8
|
|
841
|
+
);
|
|
842
|
+
syncResult.fileSync = {
|
|
843
|
+
diskToDb: {
|
|
844
|
+
added: bidirectional.diskToDb.added,
|
|
845
|
+
updated: bidirectional.diskToDb.updated,
|
|
846
|
+
errors: bidirectional.diskToDb.errors.map((e) => ({ path: e.file, error: e.error }))
|
|
847
|
+
},
|
|
848
|
+
dbToDisk: {
|
|
849
|
+
written: bidirectional.dbToDisk.written,
|
|
850
|
+
errors: bidirectional.dbToDisk.errors.map((e) => ({ path: e.file, error: e.error }))
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
const validation = await adm.validateReferences();
|
|
856
|
+
syncResult.validated = validation.total;
|
|
857
|
+
syncResult.brokenRefs = validation.broken.length;
|
|
858
|
+
const outdated = await adm.getOutdatedDocs();
|
|
859
|
+
syncResult.outdatedDocs = outdated.length;
|
|
860
|
+
if (args.scope === "file" && args.filePath) {
|
|
861
|
+
const normalizedPath = this.context.normalizeInputPath(args.filePath) || args.filePath;
|
|
862
|
+
const fileDocs = await adm.getDocumentsByFile(normalizedPath);
|
|
863
|
+
for (const doc of fileDocs) {
|
|
864
|
+
if (doc.confidence && doc.confidence < 0.7) {
|
|
865
|
+
syncResult.markedOutdated.push(doc.id);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
} else {
|
|
869
|
+
syncResult.markedOutdated = outdated.map((o) => o.docId);
|
|
870
|
+
}
|
|
871
|
+
const fileSyncMsg = syncResult.fileSync ? ` Files: ${syncResult.fileSync.diskToDb.added.length} added, ${syncResult.fileSync.diskToDb.updated.length} updated, ${syncResult.fileSync.dbToDisk.written.length} written.` : "";
|
|
872
|
+
return {
|
|
873
|
+
content: [
|
|
874
|
+
{
|
|
875
|
+
type: "text",
|
|
876
|
+
text: JSON.stringify(
|
|
877
|
+
{
|
|
878
|
+
success: true,
|
|
879
|
+
message: `Sync completed. ${syncResult.brokenRefs} broken refs, ${syncResult.outdatedDocs} outdated docs.${fileSyncMsg}`,
|
|
880
|
+
...syncResult
|
|
881
|
+
},
|
|
882
|
+
null,
|
|
883
|
+
2
|
|
884
|
+
)
|
|
885
|
+
}
|
|
886
|
+
]
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
var AutoDocGenerateToolHandler = class extends BaseToolHandler {
|
|
891
|
+
parseArgs(args) {
|
|
892
|
+
return AutoDocGenerateSchema.parse(args);
|
|
893
|
+
}
|
|
894
|
+
async execute(args) {
|
|
895
|
+
const container = this.context.getServiceContainer?.();
|
|
896
|
+
if (!container) {
|
|
897
|
+
return autodocNotEnabledResult();
|
|
898
|
+
}
|
|
899
|
+
let useLlm = args.useLlm;
|
|
900
|
+
if (useLlm === void 0) {
|
|
901
|
+
try {
|
|
902
|
+
const { detectLLMProviders } = await import('./llm-provider-J6V62H56.js');
|
|
903
|
+
const { recommended } = await detectLLMProviders();
|
|
904
|
+
useLlm = !!recommended;
|
|
905
|
+
} catch {
|
|
906
|
+
useLlm = false;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
const result = await executeGenerateDocs(
|
|
910
|
+
{
|
|
911
|
+
rootDir: args.rootDir,
|
|
912
|
+
autodocDir: args.autodocDir,
|
|
913
|
+
exclude: args.exclude,
|
|
914
|
+
maxDepth: args.maxDepth,
|
|
915
|
+
module: args.module,
|
|
916
|
+
useLlm,
|
|
917
|
+
preview: args.preview,
|
|
918
|
+
incremental: args.incremental,
|
|
919
|
+
language: args.language
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
normalizeInputPath: this.context.normalizeInputPath,
|
|
923
|
+
requestId: this.context.requestId,
|
|
924
|
+
getAutoDocManager: container.getAutoDocManager.bind(container)
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
return {
|
|
928
|
+
content: [
|
|
929
|
+
{
|
|
930
|
+
type: "text",
|
|
931
|
+
text: JSON.stringify(result, null, 2)
|
|
932
|
+
}
|
|
933
|
+
]
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
var AutoDocChangelogToolHandler = class extends BaseToolHandler {
|
|
938
|
+
parseArgs(args) {
|
|
939
|
+
return AutoDocChangelogSchema.parse(args);
|
|
940
|
+
}
|
|
941
|
+
async execute(args) {
|
|
942
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
943
|
+
if (!adm) {
|
|
944
|
+
return autodocNotEnabledResult();
|
|
945
|
+
}
|
|
946
|
+
const changelog = await adm.getChangelog({
|
|
947
|
+
since: args.since,
|
|
948
|
+
limit: args.limit,
|
|
949
|
+
branch: args.branch
|
|
950
|
+
});
|
|
951
|
+
return {
|
|
952
|
+
content: [
|
|
953
|
+
{
|
|
954
|
+
type: "text",
|
|
955
|
+
text: JSON.stringify(
|
|
956
|
+
{
|
|
957
|
+
success: true,
|
|
958
|
+
entriesCount: changelog.length,
|
|
959
|
+
entries: changelog.map((entry) => ({
|
|
960
|
+
id: entry.id,
|
|
961
|
+
timestamp: entry.timestamp,
|
|
962
|
+
date: new Date(entry.timestamp).toISOString(),
|
|
963
|
+
branch: entry.branch,
|
|
964
|
+
summary: entry.summary,
|
|
965
|
+
changesCount: entry.changes?.length || 0,
|
|
966
|
+
impactedDocsCount: entry.impactedDocs?.length || 0
|
|
967
|
+
}))
|
|
968
|
+
},
|
|
969
|
+
null,
|
|
970
|
+
2
|
|
971
|
+
)
|
|
972
|
+
}
|
|
973
|
+
]
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
var AutoDocInstallHooksToolHandler = class extends BaseToolHandler {
|
|
978
|
+
parseArgs(args) {
|
|
979
|
+
return AutoDocInstallHooksSchema.parse(args);
|
|
980
|
+
}
|
|
981
|
+
async execute(args) {
|
|
982
|
+
const container = this.context.getServiceContainer?.();
|
|
983
|
+
if (!container) {
|
|
984
|
+
return {
|
|
985
|
+
content: [{ type: "text", text: JSON.stringify({ error: "ServiceContainer not available" }) }]
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
const { installPreCommitHook, uninstallHooks, getHookStatus } = await import('./hook-installer-UDHK3ZRM.js');
|
|
989
|
+
const projectPath = container.directory;
|
|
990
|
+
if (args.action === "status") {
|
|
991
|
+
const status = await getHookStatus(projectPath);
|
|
992
|
+
return {
|
|
993
|
+
content: [
|
|
994
|
+
{
|
|
995
|
+
type: "text",
|
|
996
|
+
text: JSON.stringify(
|
|
997
|
+
{
|
|
998
|
+
success: true,
|
|
999
|
+
gitRepo: status.gitRepo,
|
|
1000
|
+
hooksDir: status.hooksDir,
|
|
1001
|
+
preCommitInstalled: status.preCommit
|
|
1002
|
+
},
|
|
1003
|
+
null,
|
|
1004
|
+
2
|
|
1005
|
+
)
|
|
1006
|
+
}
|
|
1007
|
+
]
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
if (args.action === "uninstall") {
|
|
1011
|
+
const result2 = await uninstallHooks(projectPath);
|
|
1012
|
+
return {
|
|
1013
|
+
content: [
|
|
1014
|
+
{
|
|
1015
|
+
type: "text",
|
|
1016
|
+
text: JSON.stringify(
|
|
1017
|
+
{
|
|
1018
|
+
success: result2.success,
|
|
1019
|
+
removed: result2.installed,
|
|
1020
|
+
skipped: result2.skipped,
|
|
1021
|
+
errors: result2.errors
|
|
1022
|
+
},
|
|
1023
|
+
null,
|
|
1024
|
+
2
|
|
1025
|
+
)
|
|
1026
|
+
}
|
|
1027
|
+
]
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
const result = await installPreCommitHook(projectPath);
|
|
1031
|
+
return {
|
|
1032
|
+
content: [
|
|
1033
|
+
{
|
|
1034
|
+
type: "text",
|
|
1035
|
+
text: JSON.stringify(
|
|
1036
|
+
{
|
|
1037
|
+
success: result.success,
|
|
1038
|
+
installed: result.installed,
|
|
1039
|
+
skipped: result.skipped,
|
|
1040
|
+
errors: result.errors
|
|
1041
|
+
},
|
|
1042
|
+
null,
|
|
1043
|
+
2
|
|
1044
|
+
)
|
|
1045
|
+
}
|
|
1046
|
+
]
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
var AutoDocDetectLanguageToolHandler = class extends BaseToolHandler {
|
|
1051
|
+
parseArgs(args) {
|
|
1052
|
+
return AutoDocDetectLanguageSchema.parse(args);
|
|
1053
|
+
}
|
|
1054
|
+
async execute(args) {
|
|
1055
|
+
const { detectLanguageFromText, aggregateLanguageDetection } = await import('./language-detector-2YC3ZIGH.js');
|
|
1056
|
+
const results = [];
|
|
1057
|
+
if (args.scope === "comments" || args.scope === "all") {
|
|
1058
|
+
const graphStorage = await this.context.getGraphStorage();
|
|
1059
|
+
const allEntities = await graphStorage.getAllEntities();
|
|
1060
|
+
const entities = allEntities.slice(0, args.sampleSize * 2);
|
|
1061
|
+
let analyzed = 0;
|
|
1062
|
+
for (const entity of entities) {
|
|
1063
|
+
if (analyzed >= args.sampleSize) break;
|
|
1064
|
+
const commentsSource = entity.metadata?.["comments"] || entity.documentation;
|
|
1065
|
+
if (commentsSource) {
|
|
1066
|
+
const commentsText = Array.isArray(commentsSource) ? commentsSource.join("\n") : String(commentsSource);
|
|
1067
|
+
const result = detectLanguageFromText(commentsText);
|
|
1068
|
+
if (result.confidence > 0) {
|
|
1069
|
+
results.push(result);
|
|
1070
|
+
analyzed++;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (args.scope === "docs" || args.scope === "all") {
|
|
1076
|
+
const adm = await getAutoDocManagerFromContext(this.context);
|
|
1077
|
+
if (adm) {
|
|
1078
|
+
const allDocs = await adm.searchDocsByText("", args.sampleSize);
|
|
1079
|
+
for (const doc of allDocs) {
|
|
1080
|
+
const result = detectLanguageFromText(doc.content);
|
|
1081
|
+
if (result.confidence > 0) {
|
|
1082
|
+
results.push(result);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
const aggregated = aggregateLanguageDetection(results);
|
|
1088
|
+
return {
|
|
1089
|
+
content: [
|
|
1090
|
+
{
|
|
1091
|
+
type: "text",
|
|
1092
|
+
text: JSON.stringify(
|
|
1093
|
+
{
|
|
1094
|
+
success: true,
|
|
1095
|
+
detectedLanguage: aggregated.language,
|
|
1096
|
+
confidence: Math.round(aggregated.confidence * 100) / 100,
|
|
1097
|
+
samplesAnalyzed: results.length,
|
|
1098
|
+
charCounts: aggregated.charCounts,
|
|
1099
|
+
recommendation: aggregated.confidence > 0.5 ? `Use language: ${aggregated.language}` : "Low confidence - defaulting to 'en'"
|
|
1100
|
+
},
|
|
1101
|
+
null,
|
|
1102
|
+
2
|
|
1103
|
+
)
|
|
1104
|
+
}
|
|
1105
|
+
]
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
export { AutoDocChangelogToolHandler, AutoDocDetectLanguageToolHandler, AutoDocGenerateToolHandler, AutoDocGetToolHandler, AutoDocInitToolHandler, AutoDocInstallHooksToolHandler, AutoDocSaveToolHandler, AutoDocSearchToolHandler, AutoDocStatusToolHandler, AutoDocSyncToolHandler, AutoDocValidateToolHandler };
|
|
1111
|
+
//# sourceMappingURL=autodoc-tool-handlers-EHTNCH6I.js.map
|
|
1112
|
+
//# sourceMappingURL=autodoc-tool-handlers-EHTNCH6I.js.map
|