ultracode 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/analysis-tool-handlers-GH5FDEWW.js +817 -0
- package/dist/chunks/analysis-tool-handlers-IXP4MWZX.js +817 -0
- package/dist/chunks/analysis-tool-handlers-LC2BTQYK.js +13 -0
- package/dist/chunks/analysis-tool-handlers-QYFKQPFL.js +817 -0
- package/dist/chunks/autodoc-tool-handlers-2HF6ERYN.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-4OGQJ7C3.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-N736CB56.js +138 -0
- package/dist/chunks/autodoc-tool-handlers-NQYBY6U4.js +1112 -0
- package/dist/chunks/branch-tool-handlers-KW3H4FJK.js +276 -0
- package/dist/chunks/branch-tool-handlers-QOUDZKJ2.js +276 -0
- package/dist/chunks/branch-tool-handlers-RB2U36KI.js +2 -0
- package/dist/chunks/branch-tool-handlers-ZHJM6PDK.js +276 -0
- package/dist/chunks/chunk-2Z6OQPYC.js +656 -0
- package/dist/chunks/chunk-3MQ7LRPN.js +322 -0
- package/dist/chunks/chunk-4W6QYGXZ.js +10 -0
- package/dist/chunks/chunk-533NFGUG.js +1 -0
- package/dist/chunks/chunk-5NUPOPWM.js +1 -0
- package/dist/chunks/chunk-AK4HIPA2.js +322 -0
- package/dist/chunks/chunk-B3H5NS3I.js +656 -0
- package/dist/chunks/chunk-DPTZHDST.js +4 -0
- package/dist/chunks/chunk-E5HQWLU5.js +322 -0
- package/dist/chunks/chunk-EOH25B5P.js +572 -0
- package/dist/chunks/chunk-ESV6F6E3.js +3179 -0
- package/dist/chunks/chunk-FPELPFER.js +924 -0
- package/dist/chunks/chunk-G6J42I55.js +161 -0
- package/dist/chunks/chunk-GCQE7ZYW.js +1 -0
- package/dist/chunks/chunk-GTIF6MOX.js +1 -0
- package/dist/chunks/chunk-I6STSSAK.js +2 -0
- package/dist/chunks/chunk-J2WBGTK2.js +4697 -0
- package/dist/chunks/chunk-KAYOX5EB.js +4697 -0
- package/dist/chunks/chunk-KPMTACOT.js +656 -0
- package/dist/chunks/chunk-L376GZ44.js +3179 -0
- package/dist/chunks/chunk-LCTOTHDA.js +15 -0
- package/dist/chunks/chunk-LEDJ7GVQ.js +316 -0
- package/dist/chunks/chunk-LH4OUKNZ.js +277 -0
- package/dist/chunks/chunk-O6IE2MEZ.js +161 -0
- package/dist/chunks/chunk-OEXPCY3F.js +316 -0
- package/dist/chunks/chunk-OMXOLFDN.js +924 -0
- package/dist/chunks/chunk-PLPBXWOU.js +3179 -0
- package/dist/chunks/chunk-PWLE5DN2.js +572 -0
- package/dist/chunks/chunk-PY43JPWL.js +447 -0
- package/dist/chunks/chunk-Q3B4EB7A.js +15 -0
- package/dist/chunks/chunk-Q5LPVLXA.js +337 -0
- package/dist/chunks/chunk-QIRZHZK2.js +5 -0
- package/dist/chunks/chunk-ROQ27LSL.js +924 -0
- package/dist/chunks/chunk-S5Q7BD6J.js +572 -0
- package/dist/chunks/chunk-SAMX3HJQ.js +337 -0
- package/dist/chunks/chunk-SV3WKUNV.js +1 -0
- package/dist/chunks/chunk-TCHCDCDO.js +167 -0
- package/dist/chunks/chunk-TR3HS7U6.js +316 -0
- package/dist/chunks/chunk-TUWE6FCW.js +167 -0
- package/dist/chunks/chunk-TVOTA7EE.js +277 -0
- package/dist/chunks/chunk-VS44D772.js +337 -0
- package/dist/chunks/chunk-WIE3G5ES.js +167 -0
- package/dist/chunks/chunk-XG3ACLWR.js +5 -0
- package/dist/chunks/chunk-XJ2Z5QQO.js +1 -0
- package/dist/chunks/chunk-XK2NY7RB.js +277 -0
- package/dist/chunks/chunk-Y4F7NZFZ.js +4700 -0
- package/dist/chunks/chunk-YS75L3ZS.js +161 -0
- package/dist/chunks/chunk-ZVG5HHI3.js +15 -0
- package/dist/chunks/dev-agent-DDDIVWOF.js +1 -0
- package/dist/chunks/dev-agent-E2VCFKXN.js +1624 -0
- package/dist/chunks/dev-agent-KJNSU5KQ.js +1624 -0
- package/dist/chunks/dev-agent-NDERYIPV.js +1624 -0
- package/dist/chunks/faiss-provider-7R4BQDIV.js +12 -0
- package/dist/chunks/faiss-provider-7ZFRSDN5.js +12 -0
- package/dist/chunks/faiss-provider-SXB7FTLB.js +1 -0
- package/dist/chunks/faiss-provider-TKLBEUSH.js +12 -0
- package/dist/chunks/file-tool-handlers-5DODQXGF.js +1027 -0
- package/dist/chunks/file-tool-handlers-KGHLE4KR.js +1027 -0
- package/dist/chunks/file-tool-handlers-KTOQ4NFS.js +12 -0
- package/dist/chunks/file-tool-handlers-V4SFUDQB.js +1027 -0
- package/dist/chunks/graph-metrics-tool-handlers-3AV4X4ZY.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-3VMDQHJ6.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-BZ6E6YHF.js +1 -0
- package/dist/chunks/graph-metrics-tool-handlers-IYBGSXL7.js +65 -0
- package/dist/chunks/graph-storage-factory-2CQ2RPDV.js +13 -0
- package/dist/chunks/graph-storage-factory-C5SMMYL6.js +13 -0
- package/dist/chunks/graph-storage-factory-EEO2V3GJ.js +1 -0
- package/dist/chunks/graph-storage-factory-WBCTXP34.js +13 -0
- package/dist/chunks/history-tool-handlers-AS7OQFZI.js +1 -0
- package/dist/chunks/history-tool-handlers-FSNJYXV2.js +208 -0
- package/dist/chunks/history-tool-handlers-JZAH4EIQ.js +208 -0
- package/dist/chunks/history-tool-handlers-KCSCXZ7T.js +208 -0
- package/dist/chunks/incremental-updater-A2EL4QXU.js +14 -0
- package/dist/chunks/incremental-updater-EQIKBVY2.js +14 -0
- package/dist/chunks/incremental-updater-JFGRPH3B.js +14 -0
- package/dist/chunks/incremental-updater-S5BAAGHP.js +1 -0
- package/dist/chunks/indexer-agent-ASKY7JPG.js +1 -0
- package/dist/chunks/indexer-agent-NKAOF323.js +21 -0
- package/dist/chunks/indexer-agent-PJN5IOKQ.js +21 -0
- package/dist/chunks/indexer-agent-WRJFWKZX.js +21 -0
- package/dist/chunks/indexing-pipeline-D4P2O72Z.js +249 -0
- package/dist/chunks/indexing-pipeline-L7C543N4.js +1 -0
- package/dist/chunks/indexing-pipeline-NHPRN3AB.js +249 -0
- package/dist/chunks/indexing-pipeline-ZAXCZU22.js +249 -0
- package/dist/chunks/layered-faiss-provider-62CNW54X.js +1 -0
- package/dist/chunks/layered-faiss-provider-O7L77GFX.js +12 -0
- package/dist/chunks/layered-faiss-provider-RVHLHLPK.js +12 -0
- package/dist/chunks/layered-faiss-provider-YT7EDIJI.js +12 -0
- package/dist/chunks/merge-agent-3RF7VFF5.js +2481 -0
- package/dist/chunks/merge-agent-JCKTCBCE.js +2481 -0
- package/dist/chunks/merge-agent-VCL7OXPN.js +2481 -0
- package/dist/chunks/merge-agent-ZGK24WVF.js +11 -0
- package/dist/chunks/merge-tool-handlers-GV2LOIKU.js +277 -0
- package/dist/chunks/merge-tool-handlers-TYDWU5X2.js +277 -0
- package/dist/chunks/merge-tool-handlers-U7X2ZO2M.js +1 -0
- package/dist/chunks/merge-tool-handlers-YH62ZLPJ.js +277 -0
- package/dist/chunks/pattern-tool-handlers-76NF5JDS.js +13 -0
- package/dist/chunks/pattern-tool-handlers-IJAGEIVD.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-VA5WYA62.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-WQ6UBMJS.js +1549 -0
- package/dist/chunks/query-agent-36ADGCFZ.js +1 -0
- package/dist/chunks/query-agent-H22CR5N5.js +191 -0
- package/dist/chunks/query-agent-K2UGZS4M.js +191 -0
- package/dist/chunks/query-agent-YJCEHOXD.js +191 -0
- package/dist/chunks/semantic-agent-AC7CBEDE.js +6381 -0
- package/dist/chunks/semantic-agent-HK5X6CKU.js +6381 -0
- package/dist/chunks/semantic-agent-KONIKEGW.js +6381 -0
- package/dist/chunks/semantic-agent-LH6IZ2L7.js +137 -0
- package/dist/chunks/semantic-tool-handlers-5LMSH2U7.js +3 -0
- package/dist/chunks/semantic-tool-handlers-735UMO7Y.js +817 -0
- package/dist/chunks/semantic-tool-handlers-BNUYPP7X.js +817 -0
- package/dist/chunks/semantic-tool-handlers-MYZPEUD2.js +817 -0
- package/dist/chunks/snapshot-tool-handlers-6SIHZT2F.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-DS4P3KOT.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-JYHRFPC7.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-YEHMAT3L.js +1 -0
- package/dist/chunks/storage-paths-A3C7WHHG.js +8 -0
- package/dist/chunks/storage-paths-HDYH7WPM.js +1 -0
- package/dist/chunks/storage-paths-IMFRHBWF.js +8 -0
- package/dist/chunks/storage-paths-P3PUSMUD.js +8 -0
- package/dist/chunks/taint-tool-handlers-CWESOOMQ.js +68 -0
- package/dist/chunks/taint-tool-handlers-OG3NVVP3.js +1 -0
- package/dist/chunks/taint-tool-handlers-ON3G3FA7.js +68 -0
- package/dist/chunks/taint-tool-handlers-P4P5J6DB.js +68 -0
- package/dist/chunks/tracing-tool-handlers-4BDCXTZZ.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-6FPNM7HX.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-LQTQ5SKK.js +89 -0
- package/dist/chunks/tracing-tool-handlers-XRQX2DTS.js +3935 -0
- package/dist/chunks/validation-tool-handlers-DZUG7KYY.js +2 -0
- package/dist/chunks/validation-tool-handlers-O6TGFSH5.js +555 -0
- package/dist/chunks/validation-tool-handlers-RREUYKIR.js +555 -0
- package/dist/chunks/validation-tool-handlers-XPWSMS37.js +555 -0
- package/dist/index.js +13 -13
- package/dist/roslyn-addon/.build-hash +1 -1
- package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
- package/dist/roslyn-addon/ILGPU.dll +0 -0
- package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
- package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getProjectContext } from './chunk-TCHCDCDO.js';
|
|
2
|
+
|
|
3
|
+
// src/shared/indexing-context.ts
|
|
4
|
+
function getCurrentIndexingDirectory() {
|
|
5
|
+
return getProjectContext().getCurrentProject();
|
|
6
|
+
}
|
|
7
|
+
function setCurrentIndexingDirectory(directory) {
|
|
8
|
+
if (directory) {
|
|
9
|
+
getProjectContext().switchProject(directory);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { getCurrentIndexingDirectory, setCurrentIndexingDirectory };
|
|
14
|
+
//# sourceMappingURL=chunk-LCTOTHDA.js.map
|
|
15
|
+
//# sourceMappingURL=chunk-LCTOTHDA.js.map
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { getGraphStorage } from './chunk-J2WBGTK2.js';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
function extractReferences(content) {
|
|
6
|
+
const refs = [];
|
|
7
|
+
const fileLinePattern = /(?:`([^`]+\.(?:ts|js|tsx|jsx|py|go|rs|java|kt|swift|cpp|c|h)):(\d+)`|([a-zA-Z0-9_\-/.]+\.(?:ts|js|tsx|jsx|py|go|rs|java|kt|swift|cpp|c|h)):(\d+))/g;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = fileLinePattern.exec(content)) !== null) {
|
|
10
|
+
const filePath = match[1] || match[3];
|
|
11
|
+
const lineNum = match[2] || match[4];
|
|
12
|
+
if (filePath && lineNum) {
|
|
13
|
+
refs.push({
|
|
14
|
+
original: match[0],
|
|
15
|
+
filePath,
|
|
16
|
+
lineNumber: parseInt(lineNum, 10),
|
|
17
|
+
startIndex: match.index,
|
|
18
|
+
endIndex: match.index + match[0].length
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const mdLinkPattern = /\[([^\]]+)\]\(([^)]+\.(?:ts|js|tsx|jsx|py|go|rs|java|kt|swift|cpp|c|h))(?:#L(\d+))?\)/g;
|
|
23
|
+
while ((match = mdLinkPattern.exec(content)) !== null) {
|
|
24
|
+
const mdFilePath = match[2];
|
|
25
|
+
if (mdFilePath) {
|
|
26
|
+
refs.push({
|
|
27
|
+
original: match[0],
|
|
28
|
+
filePath: mdFilePath,
|
|
29
|
+
lineNumber: match[3] ? parseInt(match[3], 10) : void 0,
|
|
30
|
+
startIndex: match.index,
|
|
31
|
+
endIndex: match.index + match[0].length
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return refs;
|
|
36
|
+
}
|
|
37
|
+
function extractSections(content) {
|
|
38
|
+
const lines = content.split("\n");
|
|
39
|
+
const sections = [];
|
|
40
|
+
let currentSection = null;
|
|
41
|
+
let contentLines = [];
|
|
42
|
+
for (let i = 0; i < lines.length; i++) {
|
|
43
|
+
const line = lines[i] ?? "";
|
|
44
|
+
const headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
45
|
+
if (headerMatch?.[2]) {
|
|
46
|
+
if (currentSection) {
|
|
47
|
+
currentSection.content = contentLines.join("\n");
|
|
48
|
+
currentSection.endLine = i - 1;
|
|
49
|
+
sections.push(currentSection);
|
|
50
|
+
}
|
|
51
|
+
currentSection = {
|
|
52
|
+
title: headerMatch[2],
|
|
53
|
+
content: "",
|
|
54
|
+
startLine: i,
|
|
55
|
+
endLine: i,
|
|
56
|
+
relatedEntities: []
|
|
57
|
+
};
|
|
58
|
+
contentLines = [];
|
|
59
|
+
} else if (currentSection) {
|
|
60
|
+
contentLines.push(line);
|
|
61
|
+
const entityRefs = line.match(/`([A-Z][a-zA-Z0-9_]+)`/g);
|
|
62
|
+
if (entityRefs) {
|
|
63
|
+
for (const ref of entityRefs) {
|
|
64
|
+
const name = ref.slice(1, -1);
|
|
65
|
+
if (!currentSection.relatedEntities.includes(name)) {
|
|
66
|
+
currentSection.relatedEntities.push(name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (currentSection) {
|
|
73
|
+
currentSection.content = contentLines.join("\n");
|
|
74
|
+
currentSection.endLine = lines.length - 1;
|
|
75
|
+
sections.push(currentSection);
|
|
76
|
+
}
|
|
77
|
+
return sections;
|
|
78
|
+
}
|
|
79
|
+
async function detectChanges(modulePath, existingDoc, currentEntities) {
|
|
80
|
+
const changes = [];
|
|
81
|
+
const refs = extractReferences(existingDoc);
|
|
82
|
+
const sections = extractSections(existingDoc);
|
|
83
|
+
const documentedEntities = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const section of sections) {
|
|
85
|
+
for (const entity of section.relatedEntities) {
|
|
86
|
+
documentedEntities.add(entity);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const entityPattern = /`([A-Z][a-zA-Z0-9_]+)`/g;
|
|
90
|
+
let match;
|
|
91
|
+
while ((match = entityPattern.exec(existingDoc)) !== null) {
|
|
92
|
+
if (match[1]) {
|
|
93
|
+
documentedEntities.add(match[1]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (const entity of currentEntities) {
|
|
97
|
+
if (!documentedEntities.has(entity.name)) {
|
|
98
|
+
changes.push({
|
|
99
|
+
type: "added",
|
|
100
|
+
entityId: entity.id,
|
|
101
|
+
entityName: entity.name,
|
|
102
|
+
entityType: entity.type,
|
|
103
|
+
filePath: entity.filePath,
|
|
104
|
+
newLineNumber: entity.location?.start?.line,
|
|
105
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const currentEntityNames = new Set(currentEntities.map((e) => e.name));
|
|
110
|
+
for (const docEntity of documentedEntities) {
|
|
111
|
+
if (!currentEntityNames.has(docEntity)) {
|
|
112
|
+
changes.push({
|
|
113
|
+
type: "deleted",
|
|
114
|
+
entityName: docEntity,
|
|
115
|
+
entityType: "unknown",
|
|
116
|
+
filePath: modulePath,
|
|
117
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (const ref of refs) {
|
|
122
|
+
if (ref.lineNumber && ref.entityName) {
|
|
123
|
+
const entity = currentEntities.find((e) => e.name === ref.entityName);
|
|
124
|
+
if (entity && entity.location?.start?.line !== ref.lineNumber) {
|
|
125
|
+
changes.push({
|
|
126
|
+
type: "moved",
|
|
127
|
+
entityId: entity.id,
|
|
128
|
+
entityName: entity.name,
|
|
129
|
+
entityType: entity.type,
|
|
130
|
+
filePath: entity.filePath,
|
|
131
|
+
oldLineNumber: ref.lineNumber,
|
|
132
|
+
newLineNumber: entity.location?.start?.line,
|
|
133
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return changes;
|
|
139
|
+
}
|
|
140
|
+
function updateReferences(content, changes) {
|
|
141
|
+
let updated = content;
|
|
142
|
+
const lineUpdates = /* @__PURE__ */ new Map();
|
|
143
|
+
for (const change of changes) {
|
|
144
|
+
if (change.type === "moved" && change.oldLineNumber && change.newLineNumber) {
|
|
145
|
+
const key = `${change.filePath}:${change.oldLineNumber}`;
|
|
146
|
+
lineUpdates.set(key, { old: change.oldLineNumber, new: change.newLineNumber });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const fileLinePattern = /(`[^`]+\.(?:ts|js|tsx|jsx)):(\d+)`/g;
|
|
150
|
+
updated = updated.replace(fileLinePattern, (match, filePart, lineNum) => {
|
|
151
|
+
const line = parseInt(lineNum, 10);
|
|
152
|
+
for (const [key, update] of lineUpdates) {
|
|
153
|
+
if (key.endsWith(`:${line}`)) {
|
|
154
|
+
return `${filePart}:${update.new}\``;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return match;
|
|
158
|
+
});
|
|
159
|
+
const mdLinkPattern = /(\[[^\]]+\]\([^)]+\.(?:ts|js|tsx|jsx))#L(\d+)\)/g;
|
|
160
|
+
updated = updated.replace(mdLinkPattern, (match, linkPart, lineNum) => {
|
|
161
|
+
const line = parseInt(lineNum, 10);
|
|
162
|
+
for (const [key, update] of lineUpdates) {
|
|
163
|
+
if (key.endsWith(`:${line}`)) {
|
|
164
|
+
return `${linkPart}#L${update.new})`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return match;
|
|
168
|
+
});
|
|
169
|
+
return updated;
|
|
170
|
+
}
|
|
171
|
+
function mergeWithExisting(existingContent, newContent, changes) {
|
|
172
|
+
const existingSections = extractSections(existingContent);
|
|
173
|
+
const newSections = extractSections(newContent);
|
|
174
|
+
const result = [];
|
|
175
|
+
const processedNewSections = /* @__PURE__ */ new Set();
|
|
176
|
+
for (const existingSection of existingSections) {
|
|
177
|
+
const newSection = newSections.find((s) => s.title === existingSection.title);
|
|
178
|
+
if (newSection) {
|
|
179
|
+
processedNewSections.add(newSection.title);
|
|
180
|
+
const addedEntities = changes.filter((c) => c.type === "added").map((c) => c.entityName);
|
|
181
|
+
if (addedEntities.length > 0 && existingSection.title.toLowerCase().includes("export")) {
|
|
182
|
+
result.push(`## ${existingSection.title}`);
|
|
183
|
+
result.push(existingSection.content);
|
|
184
|
+
result.push("");
|
|
185
|
+
result.push("### Added");
|
|
186
|
+
result.push("");
|
|
187
|
+
for (const entity of addedEntities) {
|
|
188
|
+
result.push(`- \`${entity}\` *(added ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]})*`);
|
|
189
|
+
}
|
|
190
|
+
result.push("");
|
|
191
|
+
} else {
|
|
192
|
+
result.push(`## ${existingSection.title}`);
|
|
193
|
+
result.push(existingSection.content);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
result.push(`## ${existingSection.title}`);
|
|
197
|
+
result.push(existingSection.content);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
for (const newSection of newSections) {
|
|
201
|
+
if (!processedNewSections.has(newSection.title)) {
|
|
202
|
+
const existsInOriginal = existingSections.some((s) => s.title === newSection.title);
|
|
203
|
+
if (!existsInOriginal) {
|
|
204
|
+
result.push("");
|
|
205
|
+
result.push(`## ${newSection.title}`);
|
|
206
|
+
result.push(newSection.content);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return result.join("\n");
|
|
211
|
+
}
|
|
212
|
+
function markDeleted(content, deletedEntities) {
|
|
213
|
+
if (deletedEntities.length === 0) return content;
|
|
214
|
+
let updated = content;
|
|
215
|
+
if (!updated.includes("## Deprecated") && !updated.includes("## Deleted")) {
|
|
216
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
217
|
+
const deletedSection = ["", "## Deleted", "", "*The following items were removed from the codebase:*", ""];
|
|
218
|
+
for (const deleted of deletedEntities) {
|
|
219
|
+
deletedSection.push(`- ~~\`${deleted.entityName}\`~~ *(removed ${timestamp})*`);
|
|
220
|
+
}
|
|
221
|
+
deletedSection.push("");
|
|
222
|
+
updated += deletedSection.join("\n");
|
|
223
|
+
} else {
|
|
224
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
225
|
+
const insertPoint = updated.indexOf("## Deleted");
|
|
226
|
+
if (insertPoint !== -1) {
|
|
227
|
+
const afterHeader = updated.indexOf("\n\n", insertPoint) + 2;
|
|
228
|
+
const newItems = deletedEntities.map((d) => `- ~~\`${d.entityName}\`~~ *(removed ${timestamp})*`).join("\n");
|
|
229
|
+
updated = updated.slice(0, afterHeader) + newItems + "\n" + updated.slice(afterHeader);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (const deleted of deletedEntities) {
|
|
233
|
+
const pattern = new RegExp(`\`${deleted.entityName}\`(?![^~]*~~)`, "g");
|
|
234
|
+
updated = updated.replace(pattern, `~~\`${deleted.entityName}\`~~`);
|
|
235
|
+
}
|
|
236
|
+
return updated;
|
|
237
|
+
}
|
|
238
|
+
async function updateModuleDoc(modulePath, docPath, newContent, options = {}) {
|
|
239
|
+
const result = {
|
|
240
|
+
docPath,
|
|
241
|
+
updated: false,
|
|
242
|
+
changes: []
|
|
243
|
+
};
|
|
244
|
+
const docExists = existsSync(docPath);
|
|
245
|
+
if (!docExists) {
|
|
246
|
+
result.updated = true;
|
|
247
|
+
result.newContent = newContent;
|
|
248
|
+
result.changes.push({
|
|
249
|
+
type: "created_new",
|
|
250
|
+
description: "Created new documentation file"
|
|
251
|
+
});
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
const existingContent = readFileSync(docPath, "utf-8");
|
|
255
|
+
const storage = await getGraphStorage();
|
|
256
|
+
const currentEntities = await storage.searchEntitiesInDirectory(modulePath);
|
|
257
|
+
const changes = await detectChanges(modulePath, existingContent, currentEntities);
|
|
258
|
+
if (changes.length === 0) {
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
let updatedContent = existingContent;
|
|
262
|
+
const movedChanges = changes.filter((c) => c.type === "moved");
|
|
263
|
+
if (movedChanges.length > 0) {
|
|
264
|
+
updatedContent = updateReferences(updatedContent, movedChanges);
|
|
265
|
+
result.changes.push({
|
|
266
|
+
type: "reference_updated",
|
|
267
|
+
description: `Updated ${movedChanges.length} line/file references`
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const addedChanges = changes.filter((c) => c.type === "added");
|
|
271
|
+
if (addedChanges.length > 0) {
|
|
272
|
+
updatedContent = mergeWithExisting(updatedContent, newContent, addedChanges);
|
|
273
|
+
result.changes.push({
|
|
274
|
+
type: "content_added",
|
|
275
|
+
description: `Added documentation for ${addedChanges.length} new entities: ${addedChanges.map((c) => c.entityName).join(", ")}`
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const deletedChanges = changes.filter((c) => c.type === "deleted");
|
|
279
|
+
if (deletedChanges.length > 0) {
|
|
280
|
+
updatedContent = markDeleted(updatedContent, deletedChanges);
|
|
281
|
+
result.changes.push({
|
|
282
|
+
type: "content_marked_deleted",
|
|
283
|
+
description: `Marked ${deletedChanges.length} deleted entities: ${deletedChanges.map((c) => c.entityName).join(", ")}`
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (options.useLlm && options.llmEnhancer && addedChanges.length > 0) {
|
|
287
|
+
updatedContent = await options.llmEnhancer(updatedContent, addedChanges);
|
|
288
|
+
}
|
|
289
|
+
if (updatedContent !== existingContent) {
|
|
290
|
+
result.updated = true;
|
|
291
|
+
result.newContent = updatedContent;
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
async function updateAllModuleDocs(rootDir, options = {}) {
|
|
296
|
+
const results = [];
|
|
297
|
+
const { scanModules, generateModuleReadme } = await import('./doc-generator-RMUSNK3G.js');
|
|
298
|
+
const modules = await scanModules(rootDir);
|
|
299
|
+
for (const mod of modules) {
|
|
300
|
+
const docPath = path.join(mod.path, "AUTODOC.md");
|
|
301
|
+
const newContent = generateModuleReadme(mod);
|
|
302
|
+
const result = await updateModuleDoc(mod.path, docPath, newContent, {
|
|
303
|
+
useLlm: options.useLlm,
|
|
304
|
+
llmEnhancer: options.llmEnhancer
|
|
305
|
+
});
|
|
306
|
+
if (result.updated && !options.preview && result.newContent) {
|
|
307
|
+
writeFileSync(docPath, result.newContent, "utf-8");
|
|
308
|
+
}
|
|
309
|
+
results.push(result);
|
|
310
|
+
}
|
|
311
|
+
return results;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export { detectChanges, extractReferences, extractSections, markDeleted, mergeWithExisting, updateAllModuleDocs, updateModuleDoc, updateReferences };
|
|
315
|
+
//# sourceMappingURL=chunk-LEDJ7GVQ.js.map
|
|
316
|
+
//# sourceMappingURL=chunk-LEDJ7GVQ.js.map
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { hashText, init_fast_hash } from './chunk-HEMJHRHZ.js';
|
|
2
|
+
import { __export, __esm } from './chunk-NAQKA54E.js';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
5
|
+
import { homedir } from 'os';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
// src/shared/storage-paths.ts
|
|
9
|
+
var storage_paths_exports = {};
|
|
10
|
+
__export(storage_paths_exports, {
|
|
11
|
+
DEFAULT_BRANCH: () => DEFAULT_BRANCH,
|
|
12
|
+
ensureDataDir: () => ensureDataDir,
|
|
13
|
+
ensureGlobalDbDir: () => ensureGlobalDbDir,
|
|
14
|
+
ensureProjectDir: () => ensureProjectDir,
|
|
15
|
+
getASTCacheDir: () => getASTCacheDir,
|
|
16
|
+
getBranchPaths: () => getBranchPaths,
|
|
17
|
+
getCacheDir: () => getCacheDir,
|
|
18
|
+
getConfigDir: () => getConfigDir,
|
|
19
|
+
getConfigPath: () => getConfigPath,
|
|
20
|
+
getCoreLockPath: () => getCoreLockPath,
|
|
21
|
+
getCorePidPath: () => getCorePidPath,
|
|
22
|
+
getCurrentGitBranch: () => getCurrentGitBranch,
|
|
23
|
+
getCurrentGitBranchOrDefault: () => getCurrentGitBranchOrDefault,
|
|
24
|
+
getDataDir: () => getDataDir,
|
|
25
|
+
getFaissHotBufferPath: () => getFaissHotBufferPath,
|
|
26
|
+
getFaissIdMapPath: () => getFaissIdMapPath,
|
|
27
|
+
getFaissIndexPath: () => getFaissIndexPath,
|
|
28
|
+
getFaissIndexPathByHash: () => getFaissIndexPathByHash,
|
|
29
|
+
getGlobalDbPaths: () => getGlobalDbPaths,
|
|
30
|
+
getIPCSocketPath: () => getIPCSocketPath,
|
|
31
|
+
getLogsDir: () => getLogsDir,
|
|
32
|
+
getModelsDir: () => getModelsDir,
|
|
33
|
+
getMultiDbPaths: () => getMultiDbPaths,
|
|
34
|
+
getProjectDir: () => getProjectDir,
|
|
35
|
+
getProjectHash: () => getProjectHash,
|
|
36
|
+
getProjectPaths: () => getProjectPaths,
|
|
37
|
+
getProjectsDir: () => getProjectsDir,
|
|
38
|
+
getSemanticConfigPath: () => getSemanticConfigPath,
|
|
39
|
+
getTreeSitterCacheDir: () => getTreeSitterCacheDir,
|
|
40
|
+
hashProjectPath: () => hashProjectPath,
|
|
41
|
+
initializeStorageDirs: () => initializeStorageDirs,
|
|
42
|
+
isBaseBranch: () => isBaseBranch,
|
|
43
|
+
normalizeBranchName: () => normalizeBranchName
|
|
44
|
+
});
|
|
45
|
+
function getDataDir() {
|
|
46
|
+
let baseDir;
|
|
47
|
+
switch (process.platform) {
|
|
48
|
+
case "win32":
|
|
49
|
+
baseDir = process.env["LOCALAPPDATA"] || join(homedir(), "AppData", "Local");
|
|
50
|
+
break;
|
|
51
|
+
case "darwin":
|
|
52
|
+
baseDir = join(homedir(), "Library", "Application Support");
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
baseDir = process.env["XDG_DATA_HOME"] || join(homedir(), ".local", "share");
|
|
56
|
+
}
|
|
57
|
+
return join(baseDir, "UltraCode");
|
|
58
|
+
}
|
|
59
|
+
function ensureDataDir() {
|
|
60
|
+
const dir = getDataDir();
|
|
61
|
+
if (!existsSync(dir)) {
|
|
62
|
+
mkdirSync(dir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
return dir;
|
|
65
|
+
}
|
|
66
|
+
function getIPCSocketPath() {
|
|
67
|
+
if (process.platform === "win32") {
|
|
68
|
+
return "\\\\.\\pipe\\ultracode-core";
|
|
69
|
+
}
|
|
70
|
+
return "/tmp/ultracode-core.sock";
|
|
71
|
+
}
|
|
72
|
+
function getLogsDir() {
|
|
73
|
+
return join(getDataDir(), "logs");
|
|
74
|
+
}
|
|
75
|
+
function getCacheDir() {
|
|
76
|
+
return join(getDataDir(), "cache");
|
|
77
|
+
}
|
|
78
|
+
function getProjectsDir() {
|
|
79
|
+
return join(getDataDir(), "projects");
|
|
80
|
+
}
|
|
81
|
+
function getModelsDir() {
|
|
82
|
+
return join(getDataDir(), "models");
|
|
83
|
+
}
|
|
84
|
+
function getConfigDir() {
|
|
85
|
+
return join(getDataDir(), "config");
|
|
86
|
+
}
|
|
87
|
+
function getConfigPath() {
|
|
88
|
+
return join(getDataDir(), "config.yaml");
|
|
89
|
+
}
|
|
90
|
+
function getSemanticConfigPath() {
|
|
91
|
+
return join(getConfigDir(), "semantic-config.json");
|
|
92
|
+
}
|
|
93
|
+
function getCorePidPath() {
|
|
94
|
+
return join(getDataDir(), "core.pid");
|
|
95
|
+
}
|
|
96
|
+
function getCoreLockPath() {
|
|
97
|
+
return join(getDataDir(), "core.lock");
|
|
98
|
+
}
|
|
99
|
+
function hashProjectPath(projectPath) {
|
|
100
|
+
if (!projectPath) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`hashProjectPath: projectPath must not be empty (got ${JSON.stringify(projectPath)}). Ensure projectPath is provided in tool args or resolved from session/context.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const normalized = projectPath.toLowerCase().replace(/\\/g, "/").replace(/\/$/, "");
|
|
106
|
+
return hashText(normalized);
|
|
107
|
+
}
|
|
108
|
+
function getProjectDir(projectPath) {
|
|
109
|
+
const hash = hashProjectPath(projectPath);
|
|
110
|
+
return join(getProjectsDir(), hash);
|
|
111
|
+
}
|
|
112
|
+
function getProjectPaths(projectPath) {
|
|
113
|
+
const projectDir = getProjectDir(projectPath);
|
|
114
|
+
return {
|
|
115
|
+
dir: projectDir,
|
|
116
|
+
metaPath: join(projectDir, "meta.json"),
|
|
117
|
+
graphDbPath: join(projectDir, "graph.db"),
|
|
118
|
+
vectorsDbPath: join(projectDir, "vectors.db"),
|
|
119
|
+
branchesDir: join(projectDir, "branches"),
|
|
120
|
+
// Cache persistence paths
|
|
121
|
+
parserCachePath: join(projectDir, "parser-cache.json"),
|
|
122
|
+
semanticCachePath: join(projectDir, "semantic-cache.json")
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function getGlobalDbPaths() {
|
|
126
|
+
const dataDir = getDataDir();
|
|
127
|
+
return {
|
|
128
|
+
dir: dataDir,
|
|
129
|
+
/** @deprecated Use multi-db paths instead */
|
|
130
|
+
graphDbPath: join(dataDir, "graph.db"),
|
|
131
|
+
/** @deprecated FAISS is used for vectors, not SQLite */
|
|
132
|
+
vectorsDbPath: join(dataDir, "graph.db"),
|
|
133
|
+
/** @deprecated Use getMultiDbPaths() instead */
|
|
134
|
+
unifiedDbPath: join(dataDir, "graph.db"),
|
|
135
|
+
metaPath: join(dataDir, "global-meta.json"),
|
|
136
|
+
cacheDir: getCacheDir(),
|
|
137
|
+
projectsDir: getProjectsDir()
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function getMultiDbPaths(basePath) {
|
|
141
|
+
const dir = basePath ?? getDataDir();
|
|
142
|
+
return {
|
|
143
|
+
graph: join(dir, "graph.db"),
|
|
144
|
+
semantic: join(dir, "semantic.db"),
|
|
145
|
+
versioning: join(dir, "versioning.db"),
|
|
146
|
+
cache: join(dir, "cache.db")
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function getProjectHash(projectPath) {
|
|
150
|
+
return hashProjectPath(projectPath);
|
|
151
|
+
}
|
|
152
|
+
function normalizeBranchName(branchName) {
|
|
153
|
+
return branchName.toLowerCase().replace(/[<>:"/\\|?*]/g, "_");
|
|
154
|
+
}
|
|
155
|
+
function isBaseBranch(branchName) {
|
|
156
|
+
if (!branchName) return false;
|
|
157
|
+
const normalized = branchName.toLowerCase();
|
|
158
|
+
return BASE_BRANCH_CANDIDATES.includes(normalized);
|
|
159
|
+
}
|
|
160
|
+
function getCurrentGitBranch(projectPath) {
|
|
161
|
+
if (!projectPath) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const gitDir = join(projectPath, ".git");
|
|
166
|
+
if (!existsSync(gitDir)) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
const branch = execSync("git symbolic-ref --short HEAD", {
|
|
170
|
+
cwd: projectPath,
|
|
171
|
+
encoding: "utf-8",
|
|
172
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
173
|
+
windowsHide: true
|
|
174
|
+
}).trim();
|
|
175
|
+
return branch || null;
|
|
176
|
+
} catch {
|
|
177
|
+
try {
|
|
178
|
+
const ref = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
179
|
+
cwd: projectPath,
|
|
180
|
+
encoding: "utf-8",
|
|
181
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
182
|
+
windowsHide: true
|
|
183
|
+
}).trim();
|
|
184
|
+
if (ref === "HEAD") {
|
|
185
|
+
const hash = execSync("git rev-parse --short HEAD", {
|
|
186
|
+
cwd: projectPath,
|
|
187
|
+
encoding: "utf-8",
|
|
188
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
189
|
+
windowsHide: true
|
|
190
|
+
}).trim();
|
|
191
|
+
return hash ? `detached-${hash}` : null;
|
|
192
|
+
}
|
|
193
|
+
return ref || null;
|
|
194
|
+
} catch {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function getCurrentGitBranchOrDefault(projectPath) {
|
|
200
|
+
return getCurrentGitBranch(projectPath) || DEFAULT_BRANCH;
|
|
201
|
+
}
|
|
202
|
+
function ensureProjectDir(projectPath) {
|
|
203
|
+
const paths = getProjectPaths(projectPath);
|
|
204
|
+
if (!existsSync(paths.dir)) {
|
|
205
|
+
mkdirSync(paths.dir, { recursive: true });
|
|
206
|
+
}
|
|
207
|
+
return paths.dir;
|
|
208
|
+
}
|
|
209
|
+
function ensureGlobalDbDir() {
|
|
210
|
+
const paths = getGlobalDbPaths();
|
|
211
|
+
if (!existsSync(paths.dir)) {
|
|
212
|
+
mkdirSync(paths.dir, { recursive: true });
|
|
213
|
+
}
|
|
214
|
+
return paths.dir;
|
|
215
|
+
}
|
|
216
|
+
function getBranchPaths(projectPath, branchName) {
|
|
217
|
+
const { branchesDir } = getProjectPaths(projectPath);
|
|
218
|
+
const safeBranchName = branchName.replace(/[<>:"/\\|?*]/g, "_");
|
|
219
|
+
const branchDir = join(branchesDir, safeBranchName);
|
|
220
|
+
return {
|
|
221
|
+
dir: branchDir,
|
|
222
|
+
graphDbPath: join(branchDir, "graph.db"),
|
|
223
|
+
vectorsDbPath: join(branchDir, "vectors.db")
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function getFaissIndexPath(projectPath, branchName) {
|
|
227
|
+
const projectDir = getProjectDir(projectPath);
|
|
228
|
+
const safeBranch = normalizeBranchName(branchName);
|
|
229
|
+
if (!existsSync(projectDir)) {
|
|
230
|
+
mkdirSync(projectDir, { recursive: true });
|
|
231
|
+
}
|
|
232
|
+
return join(projectDir, `faiss-${safeBranch}.bin`);
|
|
233
|
+
}
|
|
234
|
+
function getFaissIndexPathByHash(projectHash, branchName) {
|
|
235
|
+
const projectDir = join(getProjectsDir(), projectHash);
|
|
236
|
+
const safeBranch = normalizeBranchName(branchName);
|
|
237
|
+
if (!existsSync(projectDir)) {
|
|
238
|
+
mkdirSync(projectDir, { recursive: true });
|
|
239
|
+
}
|
|
240
|
+
return join(projectDir, `faiss-${safeBranch}.bin`);
|
|
241
|
+
}
|
|
242
|
+
function getFaissIdMapPath(projectPath, branchName) {
|
|
243
|
+
const projectDir = getProjectDir(projectPath);
|
|
244
|
+
const safeBranch = normalizeBranchName(branchName);
|
|
245
|
+
return join(projectDir, `faiss-${safeBranch}.idmap.json`);
|
|
246
|
+
}
|
|
247
|
+
function getFaissHotBufferPath(projectPath, branchName) {
|
|
248
|
+
const projectDir = getProjectDir(projectPath);
|
|
249
|
+
const safeBranch = normalizeBranchName(branchName);
|
|
250
|
+
return join(projectDir, `faiss-${safeBranch}-hot.bin`);
|
|
251
|
+
}
|
|
252
|
+
function getTreeSitterCacheDir() {
|
|
253
|
+
return join(getCacheDir(), "tree-sitter");
|
|
254
|
+
}
|
|
255
|
+
function getASTCacheDir() {
|
|
256
|
+
return join(getCacheDir(), "ast");
|
|
257
|
+
}
|
|
258
|
+
function initializeStorageDirs() {
|
|
259
|
+
const dirs = [getDataDir(), getLogsDir(), getProjectsDir(), getModelsDir(), getConfigDir()];
|
|
260
|
+
for (const dir of dirs) {
|
|
261
|
+
if (!existsSync(dir)) {
|
|
262
|
+
mkdirSync(dir, { recursive: true });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var DEFAULT_BRANCH, BASE_BRANCH_CANDIDATES;
|
|
267
|
+
var init_storage_paths = __esm({
|
|
268
|
+
"src/shared/storage-paths.ts"() {
|
|
269
|
+
init_fast_hash();
|
|
270
|
+
DEFAULT_BRANCH = "main";
|
|
271
|
+
BASE_BRANCH_CANDIDATES = ["main", "master", "dev", "develop", "trunk"];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
export { DEFAULT_BRANCH, ensureDataDir, ensureGlobalDbDir, ensureProjectDir, getASTCacheDir, getBranchPaths, getCacheDir, getConfigDir, getConfigPath, getCoreLockPath, getCorePidPath, getCurrentGitBranch, getCurrentGitBranchOrDefault, getDataDir, getFaissHotBufferPath, getFaissIdMapPath, getFaissIndexPath, getFaissIndexPathByHash, getGlobalDbPaths, getIPCSocketPath, getLogsDir, getModelsDir, getMultiDbPaths, getProjectDir, getProjectHash, getProjectPaths, getProjectsDir, getSemanticConfigPath, getTreeSitterCacheDir, hashProjectPath, init_storage_paths, initializeStorageDirs, isBaseBranch, normalizeBranchName, storage_paths_exports };
|
|
276
|
+
//# sourceMappingURL=chunk-LH4OUKNZ.js.map
|
|
277
|
+
//# sourceMappingURL=chunk-LH4OUKNZ.js.map
|