grok-cli-hurry-mode 1.0.30 → 1.0.31
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/index.js +160 -159
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import * as
|
|
2
|
+
import * as fs from 'fs';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
4
|
import * as path7 from 'path';
|
|
5
5
|
import path7__default from 'path';
|
|
@@ -16,6 +16,7 @@ import axios from 'axios';
|
|
|
16
16
|
import { exec, execSync, spawn } from 'child_process';
|
|
17
17
|
import { promisify } from 'util';
|
|
18
18
|
import { writeFile } from 'fs/promises';
|
|
19
|
+
import * as ops6 from 'fs-extra';
|
|
19
20
|
import { parse } from '@typescript-eslint/typescript-estree';
|
|
20
21
|
import Fuse from 'fuse.js';
|
|
21
22
|
import { glob } from 'glob';
|
|
@@ -90,8 +91,8 @@ var init_settings_manager = __esm({
|
|
|
90
91
|
*/
|
|
91
92
|
ensureDirectoryExists(filePath) {
|
|
92
93
|
const dir = path7.dirname(filePath);
|
|
93
|
-
if (!
|
|
94
|
-
|
|
94
|
+
if (!fs.existsSync(dir)) {
|
|
95
|
+
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
@@ -99,11 +100,11 @@ var init_settings_manager = __esm({
|
|
|
99
100
|
*/
|
|
100
101
|
loadUserSettings() {
|
|
101
102
|
try {
|
|
102
|
-
if (!
|
|
103
|
+
if (!fs.existsSync(this.userSettingsPath)) {
|
|
103
104
|
this.saveUserSettings(DEFAULT_USER_SETTINGS);
|
|
104
105
|
return { ...DEFAULT_USER_SETTINGS };
|
|
105
106
|
}
|
|
106
|
-
const content =
|
|
107
|
+
const content = fs.readFileSync(this.userSettingsPath, "utf-8");
|
|
107
108
|
const settings = JSON.parse(content);
|
|
108
109
|
return { ...DEFAULT_USER_SETTINGS, ...settings };
|
|
109
110
|
} catch (error) {
|
|
@@ -121,9 +122,9 @@ var init_settings_manager = __esm({
|
|
|
121
122
|
try {
|
|
122
123
|
this.ensureDirectoryExists(this.userSettingsPath);
|
|
123
124
|
let existingSettings = { ...DEFAULT_USER_SETTINGS };
|
|
124
|
-
if (
|
|
125
|
+
if (fs.existsSync(this.userSettingsPath)) {
|
|
125
126
|
try {
|
|
126
|
-
const content =
|
|
127
|
+
const content = fs.readFileSync(this.userSettingsPath, "utf-8");
|
|
127
128
|
const parsed = JSON.parse(content);
|
|
128
129
|
existingSettings = { ...DEFAULT_USER_SETTINGS, ...parsed };
|
|
129
130
|
} catch (error) {
|
|
@@ -131,7 +132,7 @@ var init_settings_manager = __esm({
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
const mergedSettings = { ...existingSettings, ...settings };
|
|
134
|
-
|
|
135
|
+
fs.writeFileSync(
|
|
135
136
|
this.userSettingsPath,
|
|
136
137
|
JSON.stringify(mergedSettings, null, 2),
|
|
137
138
|
{ mode: 384 }
|
|
@@ -164,11 +165,11 @@ var init_settings_manager = __esm({
|
|
|
164
165
|
*/
|
|
165
166
|
loadProjectSettings() {
|
|
166
167
|
try {
|
|
167
|
-
if (!
|
|
168
|
+
if (!fs.existsSync(this.projectSettingsPath)) {
|
|
168
169
|
this.saveProjectSettings(DEFAULT_PROJECT_SETTINGS);
|
|
169
170
|
return { ...DEFAULT_PROJECT_SETTINGS };
|
|
170
171
|
}
|
|
171
|
-
const content =
|
|
172
|
+
const content = fs.readFileSync(this.projectSettingsPath, "utf-8");
|
|
172
173
|
const settings = JSON.parse(content);
|
|
173
174
|
return { ...DEFAULT_PROJECT_SETTINGS, ...settings };
|
|
174
175
|
} catch (error) {
|
|
@@ -186,9 +187,9 @@ var init_settings_manager = __esm({
|
|
|
186
187
|
try {
|
|
187
188
|
this.ensureDirectoryExists(this.projectSettingsPath);
|
|
188
189
|
let existingSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
189
|
-
if (
|
|
190
|
+
if (fs.existsSync(this.projectSettingsPath)) {
|
|
190
191
|
try {
|
|
191
|
-
const content =
|
|
192
|
+
const content = fs.readFileSync(this.projectSettingsPath, "utf-8");
|
|
192
193
|
const parsed = JSON.parse(content);
|
|
193
194
|
existingSettings = { ...DEFAULT_PROJECT_SETTINGS, ...parsed };
|
|
194
195
|
} catch (error) {
|
|
@@ -196,7 +197,7 @@ var init_settings_manager = __esm({
|
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
const mergedSettings = { ...existingSettings, ...settings };
|
|
199
|
-
|
|
200
|
+
fs.writeFileSync(
|
|
200
201
|
this.projectSettingsPath,
|
|
201
202
|
JSON.stringify(mergedSettings, null, 2)
|
|
202
203
|
);
|
|
@@ -1469,7 +1470,7 @@ STDERR: ${stderr}` : "");
|
|
|
1469
1470
|
};
|
|
1470
1471
|
var pathExists = async (filePath) => {
|
|
1471
1472
|
try {
|
|
1472
|
-
await
|
|
1473
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
1473
1474
|
return true;
|
|
1474
1475
|
} catch {
|
|
1475
1476
|
return false;
|
|
@@ -1482,16 +1483,16 @@ var TextEditorTool = class {
|
|
|
1482
1483
|
try {
|
|
1483
1484
|
const resolvedPath = path7.resolve(filePath);
|
|
1484
1485
|
if (await pathExists(resolvedPath)) {
|
|
1485
|
-
const stats = await
|
|
1486
|
+
const stats = await fs.promises.stat(resolvedPath);
|
|
1486
1487
|
if (stats.isDirectory()) {
|
|
1487
|
-
const files = await
|
|
1488
|
+
const files = await fs.promises.readdir(resolvedPath);
|
|
1488
1489
|
return {
|
|
1489
1490
|
success: true,
|
|
1490
1491
|
output: `Directory contents of ${filePath}:
|
|
1491
1492
|
${files.join("\n")}`
|
|
1492
1493
|
};
|
|
1493
1494
|
}
|
|
1494
|
-
const content = await
|
|
1495
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
1495
1496
|
const lines = content.split("\n");
|
|
1496
1497
|
if (viewRange) {
|
|
1497
1498
|
const [start, end] = viewRange;
|
|
@@ -1541,7 +1542,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1541
1542
|
error: `File not found: ${filePath}`
|
|
1542
1543
|
};
|
|
1543
1544
|
}
|
|
1544
|
-
const content = await
|
|
1545
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
1545
1546
|
if (!content.includes(oldStr)) {
|
|
1546
1547
|
if (oldStr.includes("\n")) {
|
|
1547
1548
|
const fuzzyResult = this.findFuzzyMatch(content, oldStr);
|
|
@@ -1641,7 +1642,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1641
1642
|
}
|
|
1642
1643
|
}
|
|
1643
1644
|
const dir = path7.dirname(resolvedPath);
|
|
1644
|
-
await
|
|
1645
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
1645
1646
|
await writeFile(resolvedPath, content, "utf-8");
|
|
1646
1647
|
this.editHistory.push({
|
|
1647
1648
|
command: "create",
|
|
@@ -1671,7 +1672,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1671
1672
|
error: `File not found: ${filePath}`
|
|
1672
1673
|
};
|
|
1673
1674
|
}
|
|
1674
|
-
const fileContent = await
|
|
1675
|
+
const fileContent = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
1675
1676
|
const lines = fileContent.split("\n");
|
|
1676
1677
|
if (startLine < 1 || startLine > lines.length) {
|
|
1677
1678
|
return {
|
|
@@ -1739,7 +1740,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1739
1740
|
error: `File not found: ${filePath}`
|
|
1740
1741
|
};
|
|
1741
1742
|
}
|
|
1742
|
-
const fileContent = await
|
|
1743
|
+
const fileContent = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
1743
1744
|
const lines = fileContent.split("\n");
|
|
1744
1745
|
lines.splice(insertLine - 1, 0, content);
|
|
1745
1746
|
const newContent = lines.join("\n");
|
|
@@ -1773,7 +1774,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1773
1774
|
switch (lastEdit.command) {
|
|
1774
1775
|
case "str_replace":
|
|
1775
1776
|
if (lastEdit.path && lastEdit.old_str && lastEdit.new_str) {
|
|
1776
|
-
const content = await
|
|
1777
|
+
const content = await fs.promises.readFile(lastEdit.path, "utf-8");
|
|
1777
1778
|
const revertedContent = content.replace(
|
|
1778
1779
|
lastEdit.new_str,
|
|
1779
1780
|
lastEdit.old_str
|
|
@@ -1783,12 +1784,12 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1783
1784
|
break;
|
|
1784
1785
|
case "create":
|
|
1785
1786
|
if (lastEdit.path) {
|
|
1786
|
-
await
|
|
1787
|
+
await fs.promises.rm(lastEdit.path);
|
|
1787
1788
|
}
|
|
1788
1789
|
break;
|
|
1789
1790
|
case "insert":
|
|
1790
1791
|
if (lastEdit.path && lastEdit.insert_line) {
|
|
1791
|
-
const content = await
|
|
1792
|
+
const content = await fs.promises.readFile(lastEdit.path, "utf-8");
|
|
1792
1793
|
const lines = content.split("\n");
|
|
1793
1794
|
lines.splice(lastEdit.insert_line - 1, 1);
|
|
1794
1795
|
await writeFile(lastEdit.path, lines.join("\n"), "utf-8");
|
|
@@ -1988,7 +1989,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
1988
1989
|
};
|
|
1989
1990
|
var pathExists2 = async (filePath) => {
|
|
1990
1991
|
try {
|
|
1991
|
-
await
|
|
1992
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
1992
1993
|
return true;
|
|
1993
1994
|
} catch {
|
|
1994
1995
|
return false;
|
|
@@ -2042,7 +2043,7 @@ var MorphEditorTool = class {
|
|
|
2042
2043
|
error: "MORPH_API_KEY not configured. Please set your Morph API key."
|
|
2043
2044
|
};
|
|
2044
2045
|
}
|
|
2045
|
-
const initialCode = await
|
|
2046
|
+
const initialCode = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
2046
2047
|
const sessionFlags = this.confirmationService.getSessionFlags();
|
|
2047
2048
|
if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
|
|
2048
2049
|
const confirmationResult = await this.confirmationService.requestConfirmation(
|
|
@@ -2065,7 +2066,7 @@ ${codeEdit}`
|
|
|
2065
2066
|
}
|
|
2066
2067
|
}
|
|
2067
2068
|
const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
|
|
2068
|
-
await
|
|
2069
|
+
await fs.promises.writeFile(resolvedPath, mergedCode, "utf-8");
|
|
2069
2070
|
const oldLines = initialCode.split("\n");
|
|
2070
2071
|
const newLines = mergedCode.split("\n");
|
|
2071
2072
|
const diff = this.generateDiff(oldLines, newLines, targetFile);
|
|
@@ -2239,16 +2240,16 @@ ${codeEdit}`
|
|
|
2239
2240
|
try {
|
|
2240
2241
|
const resolvedPath = path7.resolve(filePath);
|
|
2241
2242
|
if (await pathExists2(resolvedPath)) {
|
|
2242
|
-
const stats = await
|
|
2243
|
+
const stats = await fs.promises.stat(resolvedPath);
|
|
2243
2244
|
if (stats.isDirectory()) {
|
|
2244
|
-
const files = await
|
|
2245
|
+
const files = await fs.promises.readdir(resolvedPath);
|
|
2245
2246
|
return {
|
|
2246
2247
|
success: true,
|
|
2247
2248
|
output: `Directory contents of ${filePath}:
|
|
2248
2249
|
${files.join("\n")}`
|
|
2249
2250
|
};
|
|
2250
2251
|
}
|
|
2251
|
-
const content = await
|
|
2252
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
2252
2253
|
const lines = content.split("\n");
|
|
2253
2254
|
if (viewRange) {
|
|
2254
2255
|
const [start, end] = viewRange;
|
|
@@ -2656,7 +2657,7 @@ var SearchTool = class {
|
|
|
2656
2657
|
const walkDir = async (dir, depth = 0) => {
|
|
2657
2658
|
if (depth > 10 || files.length >= maxResults) return;
|
|
2658
2659
|
try {
|
|
2659
|
-
const entries = await
|
|
2660
|
+
const entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
2660
2661
|
for (const entry of entries) {
|
|
2661
2662
|
if (files.length >= maxResults) break;
|
|
2662
2663
|
const fullPath = path7.join(dir, entry.name);
|
|
@@ -2770,7 +2771,7 @@ var SearchTool = class {
|
|
|
2770
2771
|
};
|
|
2771
2772
|
var pathExists3 = async (filePath) => {
|
|
2772
2773
|
try {
|
|
2773
|
-
await
|
|
2774
|
+
await ops6.promises.access(filePath, ops6.constants.F_OK);
|
|
2774
2775
|
return true;
|
|
2775
2776
|
} catch {
|
|
2776
2777
|
return false;
|
|
@@ -3125,15 +3126,15 @@ ${results.join("\n")}`
|
|
|
3125
3126
|
filePath: operation.filePath
|
|
3126
3127
|
};
|
|
3127
3128
|
case "edit":
|
|
3128
|
-
const originalContent = await
|
|
3129
|
+
const originalContent = await ops6.promises.readFile(resolvedPath, "utf-8");
|
|
3129
3130
|
return {
|
|
3130
3131
|
type: "restore_content",
|
|
3131
3132
|
filePath: operation.filePath,
|
|
3132
3133
|
originalContent
|
|
3133
3134
|
};
|
|
3134
3135
|
case "delete":
|
|
3135
|
-
const contentToRestore = await
|
|
3136
|
-
const stats = await
|
|
3136
|
+
const contentToRestore = await ops6.promises.readFile(resolvedPath, "utf-8");
|
|
3137
|
+
const stats = await ops6.promises.stat(resolvedPath);
|
|
3137
3138
|
return {
|
|
3138
3139
|
type: "restore_deleted",
|
|
3139
3140
|
filePath: operation.filePath,
|
|
@@ -3159,25 +3160,25 @@ ${results.join("\n")}`
|
|
|
3159
3160
|
switch (operation.type) {
|
|
3160
3161
|
case "create":
|
|
3161
3162
|
const dir = path7.dirname(resolvedPath);
|
|
3162
|
-
await
|
|
3163
|
+
await ops6.promises.mkdir(dir, { recursive: true });
|
|
3163
3164
|
await writeFile(resolvedPath, operation.content, "utf-8");
|
|
3164
3165
|
return { success: true, output: `Created ${operation.filePath}` };
|
|
3165
3166
|
case "edit":
|
|
3166
|
-
let content = await
|
|
3167
|
+
let content = await ops6.promises.readFile(resolvedPath, "utf-8");
|
|
3167
3168
|
for (const editOp of operation.operations) {
|
|
3168
3169
|
content = await this.applyEditOperation(content, editOp);
|
|
3169
3170
|
}
|
|
3170
3171
|
await writeFile(resolvedPath, content, "utf-8");
|
|
3171
3172
|
return { success: true, output: `Edited ${operation.filePath}` };
|
|
3172
3173
|
case "delete":
|
|
3173
|
-
await
|
|
3174
|
+
await ops6.promises.rm(resolvedPath);
|
|
3174
3175
|
return { success: true, output: `Deleted ${operation.filePath}` };
|
|
3175
3176
|
case "rename":
|
|
3176
3177
|
case "move":
|
|
3177
3178
|
const newResolvedPath = path7.resolve(operation.newFilePath);
|
|
3178
3179
|
const newDir = path7.dirname(newResolvedPath);
|
|
3179
|
-
await
|
|
3180
|
-
await
|
|
3180
|
+
await ops6.promises.mkdir(newDir, { recursive: true });
|
|
3181
|
+
await ops6.move(resolvedPath, newResolvedPath);
|
|
3181
3182
|
return { success: true, output: `${operation.type === "rename" ? "Renamed" : "Moved"} ${operation.filePath} to ${operation.newFilePath}` };
|
|
3182
3183
|
default:
|
|
3183
3184
|
throw new Error(`Unknown operation type: ${operation.type}`);
|
|
@@ -3221,7 +3222,7 @@ ${results.join("\n")}`
|
|
|
3221
3222
|
case "delete_created":
|
|
3222
3223
|
const createdPath = path7.resolve(rollback.filePath);
|
|
3223
3224
|
if (await pathExists3(createdPath)) {
|
|
3224
|
-
await
|
|
3225
|
+
await ops6.promises.rm(createdPath);
|
|
3225
3226
|
}
|
|
3226
3227
|
break;
|
|
3227
3228
|
case "restore_content":
|
|
@@ -3231,7 +3232,7 @@ ${results.join("\n")}`
|
|
|
3231
3232
|
case "restore_deleted":
|
|
3232
3233
|
const deletedPath = path7.resolve(rollback.filePath);
|
|
3233
3234
|
const deletedDir = path7.dirname(deletedPath);
|
|
3234
|
-
await
|
|
3235
|
+
await ops6.promises.mkdir(deletedDir, { recursive: true });
|
|
3235
3236
|
await writeFile(deletedPath, rollback.content, "utf-8");
|
|
3236
3237
|
break;
|
|
3237
3238
|
case "restore_move":
|
|
@@ -3239,8 +3240,8 @@ ${results.join("\n")}`
|
|
|
3239
3240
|
const movedOldPath = path7.resolve(rollback.oldPath);
|
|
3240
3241
|
if (await pathExists3(movedNewPath)) {
|
|
3241
3242
|
const oldDir = path7.dirname(movedOldPath);
|
|
3242
|
-
await
|
|
3243
|
-
await
|
|
3243
|
+
await ops6.promises.mkdir(oldDir, { recursive: true });
|
|
3244
|
+
await ops6.move(movedNewPath, movedOldPath);
|
|
3244
3245
|
}
|
|
3245
3246
|
break;
|
|
3246
3247
|
}
|
|
@@ -3282,7 +3283,7 @@ ${results.join("\n")}`
|
|
|
3282
3283
|
};
|
|
3283
3284
|
var pathExists4 = async (filePath) => {
|
|
3284
3285
|
try {
|
|
3285
|
-
await
|
|
3286
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
3286
3287
|
return true;
|
|
3287
3288
|
} catch {
|
|
3288
3289
|
return false;
|
|
@@ -3302,7 +3303,7 @@ var AdvancedSearchTool = class {
|
|
|
3302
3303
|
error: `Path not found: ${searchPath}`
|
|
3303
3304
|
};
|
|
3304
3305
|
}
|
|
3305
|
-
const stats = await
|
|
3306
|
+
const stats = await fs.promises.stat(resolvedPath);
|
|
3306
3307
|
const filesToSearch = [];
|
|
3307
3308
|
if (stats.isFile()) {
|
|
3308
3309
|
filesToSearch.push(resolvedPath);
|
|
@@ -3345,7 +3346,7 @@ var AdvancedSearchTool = class {
|
|
|
3345
3346
|
error: `Path not found: ${searchPath}`
|
|
3346
3347
|
};
|
|
3347
3348
|
}
|
|
3348
|
-
const stats = await
|
|
3349
|
+
const stats = await fs.promises.stat(resolvedPath);
|
|
3349
3350
|
const filesToProcess = [];
|
|
3350
3351
|
if (stats.isFile()) {
|
|
3351
3352
|
filesToProcess.push(resolvedPath);
|
|
@@ -3390,7 +3391,7 @@ var AdvancedSearchTool = class {
|
|
|
3390
3391
|
}
|
|
3391
3392
|
for (const result of results) {
|
|
3392
3393
|
if (result.success && result.preview) {
|
|
3393
|
-
await
|
|
3394
|
+
await fs.promises.writeFile(result.filePath, result.preview, "utf-8");
|
|
3394
3395
|
}
|
|
3395
3396
|
}
|
|
3396
3397
|
}
|
|
@@ -3452,7 +3453,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
3452
3453
|
* Search in a single file
|
|
3453
3454
|
*/
|
|
3454
3455
|
async searchInFile(filePath, options) {
|
|
3455
|
-
const content = await
|
|
3456
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
3456
3457
|
const lines = content.split("\n");
|
|
3457
3458
|
const matches = [];
|
|
3458
3459
|
let pattern;
|
|
@@ -3503,7 +3504,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
3503
3504
|
*/
|
|
3504
3505
|
async replaceInFile(filePath, options) {
|
|
3505
3506
|
try {
|
|
3506
|
-
const content = await
|
|
3507
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
3507
3508
|
let pattern;
|
|
3508
3509
|
try {
|
|
3509
3510
|
if (options.isRegex) {
|
|
@@ -3554,7 +3555,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
3554
3555
|
async getFilesRecursively(dirPath, options) {
|
|
3555
3556
|
const files = [];
|
|
3556
3557
|
const walk = async (currentPath) => {
|
|
3557
|
-
const entries = await
|
|
3558
|
+
const entries = await fs.promises.readdir(currentPath, { withFileTypes: true });
|
|
3558
3559
|
for (const entry of entries) {
|
|
3559
3560
|
const fullPath = path7.join(currentPath, entry.name);
|
|
3560
3561
|
if (entry.isDirectory()) {
|
|
@@ -3717,7 +3718,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
3717
3718
|
};
|
|
3718
3719
|
var pathExists5 = async (filePath) => {
|
|
3719
3720
|
try {
|
|
3720
|
-
await
|
|
3721
|
+
await ops6.promises.access(filePath, ops6.constants.F_OK);
|
|
3721
3722
|
return true;
|
|
3722
3723
|
} catch {
|
|
3723
3724
|
return false;
|
|
@@ -3906,11 +3907,11 @@ ${category}/
|
|
|
3906
3907
|
let movedFiles = 0;
|
|
3907
3908
|
for (const [category, fileList] of Object.entries(organization)) {
|
|
3908
3909
|
const categoryDir = path7.join(destBase, category);
|
|
3909
|
-
await
|
|
3910
|
+
await ops6.promises.mkdir(categoryDir, { recursive: true });
|
|
3910
3911
|
for (const filePath of fileList) {
|
|
3911
3912
|
const fileName = path7.basename(filePath);
|
|
3912
3913
|
const destPath = path7.join(categoryDir, fileName);
|
|
3913
|
-
await
|
|
3914
|
+
await ops6.move(filePath, destPath);
|
|
3914
3915
|
movedFiles++;
|
|
3915
3916
|
}
|
|
3916
3917
|
}
|
|
@@ -3966,7 +3967,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
3966
3967
|
}
|
|
3967
3968
|
emptyDirs.sort((a, b) => b.length - a.length);
|
|
3968
3969
|
for (const dir of emptyDirs) {
|
|
3969
|
-
await
|
|
3970
|
+
await ops6.rmdir(dir);
|
|
3970
3971
|
}
|
|
3971
3972
|
return {
|
|
3972
3973
|
success: true,
|
|
@@ -3983,7 +3984,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
3983
3984
|
* Build tree structure recursively
|
|
3984
3985
|
*/
|
|
3985
3986
|
async buildTreeStructure(dirPath, options, currentDepth) {
|
|
3986
|
-
const stats = await
|
|
3987
|
+
const stats = await ops6.promises.stat(dirPath);
|
|
3987
3988
|
const name = path7.basename(dirPath);
|
|
3988
3989
|
const node = {
|
|
3989
3990
|
name: name || path7.basename(dirPath),
|
|
@@ -3995,7 +3996,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
3995
3996
|
if (stats.isDirectory() && (!options.maxDepth || currentDepth < options.maxDepth)) {
|
|
3996
3997
|
node.children = [];
|
|
3997
3998
|
try {
|
|
3998
|
-
const entries = await
|
|
3999
|
+
const entries = await ops6.promises.readdir(dirPath, { withFileTypes: true });
|
|
3999
4000
|
for (const entry of entries) {
|
|
4000
4001
|
if (!options.includeHidden && entry.name.startsWith(".")) {
|
|
4001
4002
|
continue;
|
|
@@ -4145,24 +4146,24 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4145
4146
|
switch (operation.type) {
|
|
4146
4147
|
case "copy":
|
|
4147
4148
|
const copyDest = path7.resolve(operation.destination);
|
|
4148
|
-
await
|
|
4149
|
+
await ops6.copy(sourcePath, copyDest);
|
|
4149
4150
|
return `Copied ${operation.source} to ${operation.destination}`;
|
|
4150
4151
|
case "move":
|
|
4151
4152
|
const moveDest = path7.resolve(operation.destination);
|
|
4152
|
-
await
|
|
4153
|
+
await ops6.move(sourcePath, moveDest);
|
|
4153
4154
|
return `Moved ${operation.source} to ${operation.destination}`;
|
|
4154
4155
|
case "delete":
|
|
4155
|
-
await
|
|
4156
|
+
await ops6.promises.rm(sourcePath);
|
|
4156
4157
|
return `Deleted ${operation.source}`;
|
|
4157
4158
|
case "create_dir":
|
|
4158
|
-
await
|
|
4159
|
+
await ops6.promises.mkdir(sourcePath, { recursive: true });
|
|
4159
4160
|
return `Created directory ${operation.source}`;
|
|
4160
4161
|
case "chmod":
|
|
4161
|
-
await
|
|
4162
|
+
await ops6.promises.chmod(sourcePath, operation.mode);
|
|
4162
4163
|
return `Changed permissions of ${operation.source} to ${operation.mode}`;
|
|
4163
4164
|
case "rename":
|
|
4164
4165
|
const renameDest = path7.resolve(operation.destination);
|
|
4165
|
-
await
|
|
4166
|
+
await ops6.move(sourcePath, renameDest);
|
|
4166
4167
|
return `Renamed ${operation.source} to ${operation.destination}`;
|
|
4167
4168
|
default:
|
|
4168
4169
|
throw new Error(`Unknown operation type: ${operation.type}`);
|
|
@@ -4191,17 +4192,17 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4191
4192
|
* Copy structure recursively
|
|
4192
4193
|
*/
|
|
4193
4194
|
async copyStructureRecursive(source, destination, options) {
|
|
4194
|
-
const stats = await
|
|
4195
|
+
const stats = await ops6.promises.stat(source);
|
|
4195
4196
|
if (stats.isDirectory()) {
|
|
4196
|
-
await
|
|
4197
|
-
const entries = await
|
|
4197
|
+
await ops6.promises.mkdir(destination, { recursive: true });
|
|
4198
|
+
const entries = await ops6.promises.readdir(source);
|
|
4198
4199
|
for (const entry of entries) {
|
|
4199
4200
|
const srcPath = path7.join(source, entry);
|
|
4200
4201
|
const destPath = path7.join(destination, entry);
|
|
4201
4202
|
await this.copyStructureRecursive(srcPath, destPath, options);
|
|
4202
4203
|
}
|
|
4203
4204
|
} else if (options.includeFiles) {
|
|
4204
|
-
await
|
|
4205
|
+
await ops6.copy(source, destination, { overwrite: options.overwrite });
|
|
4205
4206
|
}
|
|
4206
4207
|
}
|
|
4207
4208
|
/**
|
|
@@ -4210,7 +4211,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4210
4211
|
async getFilesRecursively(dirPath) {
|
|
4211
4212
|
const files = [];
|
|
4212
4213
|
const walk = async (currentPath) => {
|
|
4213
|
-
const entries = await
|
|
4214
|
+
const entries = await ops6.promises.readdir(currentPath, { withFileTypes: true });
|
|
4214
4215
|
for (const entry of entries) {
|
|
4215
4216
|
const fullPath = path7.join(currentPath, entry.name);
|
|
4216
4217
|
if (entry.isDirectory()) {
|
|
@@ -4236,14 +4237,14 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4236
4237
|
category = ext || "no-extension";
|
|
4237
4238
|
break;
|
|
4238
4239
|
case "size":
|
|
4239
|
-
const stats = await
|
|
4240
|
+
const stats = await ops6.promises.stat(filePath);
|
|
4240
4241
|
if (stats.size < 1024) category = "small (< 1KB)";
|
|
4241
4242
|
else if (stats.size < 1024 * 1024) category = "medium (< 1MB)";
|
|
4242
4243
|
else if (stats.size < 1024 * 1024 * 10) category = "large (< 10MB)";
|
|
4243
4244
|
else category = "very-large (> 10MB)";
|
|
4244
4245
|
break;
|
|
4245
4246
|
case "date":
|
|
4246
|
-
const fileStats = await
|
|
4247
|
+
const fileStats = await ops6.promises.stat(filePath);
|
|
4247
4248
|
const year = fileStats.mtime.getFullYear();
|
|
4248
4249
|
const month = fileStats.mtime.getMonth() + 1;
|
|
4249
4250
|
category = `${year}-${month.toString().padStart(2, "0")}`;
|
|
@@ -4265,7 +4266,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4265
4266
|
const emptyDirs = [];
|
|
4266
4267
|
const checkDirectory = async (currentPath) => {
|
|
4267
4268
|
try {
|
|
4268
|
-
const entries = await
|
|
4269
|
+
const entries = await ops6.promises.readdir(currentPath);
|
|
4269
4270
|
if (entries.length === 0) {
|
|
4270
4271
|
emptyDirs.push(currentPath);
|
|
4271
4272
|
return true;
|
|
@@ -4273,7 +4274,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4273
4274
|
let hasNonEmptyChildren = false;
|
|
4274
4275
|
for (const entry of entries) {
|
|
4275
4276
|
const fullPath = path7.join(currentPath, entry);
|
|
4276
|
-
const stats = await
|
|
4277
|
+
const stats = await ops6.promises.stat(fullPath);
|
|
4277
4278
|
if (stats.isDirectory()) {
|
|
4278
4279
|
const isEmpty = await checkDirectory(fullPath);
|
|
4279
4280
|
if (!isEmpty) {
|
|
@@ -4298,7 +4299,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
|
|
|
4298
4299
|
};
|
|
4299
4300
|
var pathExists6 = async (filePath) => {
|
|
4300
4301
|
try {
|
|
4301
|
-
await
|
|
4302
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
4302
4303
|
return true;
|
|
4303
4304
|
} catch {
|
|
4304
4305
|
return false;
|
|
@@ -4318,7 +4319,7 @@ var CodeAwareEditorTool = class {
|
|
|
4318
4319
|
error: `File not found: ${filePath}`
|
|
4319
4320
|
};
|
|
4320
4321
|
}
|
|
4321
|
-
const content = await
|
|
4322
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
4322
4323
|
const language = this.detectLanguage(filePath);
|
|
4323
4324
|
const context = await this.parseCodeContext(content, language);
|
|
4324
4325
|
const output = this.formatCodeAnalysis(context, filePath);
|
|
@@ -4345,7 +4346,7 @@ var CodeAwareEditorTool = class {
|
|
|
4345
4346
|
error: `File not found: ${filePath}`
|
|
4346
4347
|
};
|
|
4347
4348
|
}
|
|
4348
|
-
const content = await
|
|
4349
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
4349
4350
|
const language = this.detectLanguage(filePath);
|
|
4350
4351
|
const context = await this.parseCodeContext(content, language);
|
|
4351
4352
|
const result = await this.performRefactoring(content, context, operation, language);
|
|
@@ -4371,7 +4372,7 @@ var CodeAwareEditorTool = class {
|
|
|
4371
4372
|
};
|
|
4372
4373
|
}
|
|
4373
4374
|
}
|
|
4374
|
-
await
|
|
4375
|
+
await fs.promises.writeFile(resolvedPath, result.newContent, "utf-8");
|
|
4375
4376
|
return {
|
|
4376
4377
|
success: true,
|
|
4377
4378
|
output: result.output
|
|
@@ -4395,7 +4396,7 @@ var CodeAwareEditorTool = class {
|
|
|
4395
4396
|
error: `File not found: ${filePath}`
|
|
4396
4397
|
};
|
|
4397
4398
|
}
|
|
4398
|
-
const content = await
|
|
4399
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
4399
4400
|
const language = this.detectLanguage(filePath);
|
|
4400
4401
|
const context = await this.parseCodeContext(content, language);
|
|
4401
4402
|
const insertionPoint = this.findInsertionPoint(content, context, location, target);
|
|
@@ -4425,7 +4426,7 @@ var CodeAwareEditorTool = class {
|
|
|
4425
4426
|
};
|
|
4426
4427
|
}
|
|
4427
4428
|
}
|
|
4428
|
-
await
|
|
4429
|
+
await fs.promises.writeFile(resolvedPath, newContent, "utf-8");
|
|
4429
4430
|
return {
|
|
4430
4431
|
success: true,
|
|
4431
4432
|
output: `Code inserted at line ${insertionPoint.line + 1} in ${filePath}`
|
|
@@ -4449,7 +4450,7 @@ var CodeAwareEditorTool = class {
|
|
|
4449
4450
|
error: `File not found: ${filePath}`
|
|
4450
4451
|
};
|
|
4451
4452
|
}
|
|
4452
|
-
const content = await
|
|
4453
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
4453
4454
|
const language = this.detectLanguage(filePath);
|
|
4454
4455
|
const formattedContent = await this.formatCodeContent(content, language, options);
|
|
4455
4456
|
if (formattedContent === content) {
|
|
@@ -4477,7 +4478,7 @@ var CodeAwareEditorTool = class {
|
|
|
4477
4478
|
};
|
|
4478
4479
|
}
|
|
4479
4480
|
}
|
|
4480
|
-
await
|
|
4481
|
+
await fs.promises.writeFile(resolvedPath, formattedContent, "utf-8");
|
|
4481
4482
|
return {
|
|
4482
4483
|
success: true,
|
|
4483
4484
|
output: `Code formatted in ${filePath}`
|
|
@@ -4501,7 +4502,7 @@ var CodeAwareEditorTool = class {
|
|
|
4501
4502
|
error: `File not found: ${filePath}`
|
|
4502
4503
|
};
|
|
4503
4504
|
}
|
|
4504
|
-
const content = await
|
|
4505
|
+
const content = await fs.promises.readFile(resolvedPath, "utf-8");
|
|
4505
4506
|
const language = this.detectLanguage(filePath);
|
|
4506
4507
|
const context = await this.parseCodeContext(content, language);
|
|
4507
4508
|
const missingImports = symbols.filter(
|
|
@@ -4542,7 +4543,7 @@ ${importsToAdd.join("\n")}`;
|
|
|
4542
4543
|
};
|
|
4543
4544
|
}
|
|
4544
4545
|
}
|
|
4545
|
-
await
|
|
4546
|
+
await fs.promises.writeFile(resolvedPath, newContent, "utf-8");
|
|
4546
4547
|
return {
|
|
4547
4548
|
success: true,
|
|
4548
4549
|
output: `Added ${missingImports.length} missing imports to ${filePath}`
|
|
@@ -5239,7 +5240,7 @@ ${extractedCode}`;
|
|
|
5239
5240
|
};
|
|
5240
5241
|
var pathExists7 = async (filePath) => {
|
|
5241
5242
|
try {
|
|
5242
|
-
await
|
|
5243
|
+
await ops6.promises.access(filePath, ops6.constants.F_OK);
|
|
5243
5244
|
return true;
|
|
5244
5245
|
} catch {
|
|
5245
5246
|
return false;
|
|
@@ -5560,9 +5561,9 @@ This action cannot be undone.`
|
|
|
5560
5561
|
existed: exists
|
|
5561
5562
|
};
|
|
5562
5563
|
if (exists) {
|
|
5563
|
-
const stats = await
|
|
5564
|
+
const stats = await ops6.promises.stat(resolvedPath);
|
|
5564
5565
|
if (stats.isFile() && this.shouldSnapshotFile(resolvedPath)) {
|
|
5565
|
-
snapshot.content = await
|
|
5566
|
+
snapshot.content = await ops6.promises.readFile(resolvedPath, "utf-8");
|
|
5566
5567
|
snapshot.size = stats.size;
|
|
5567
5568
|
snapshot.lastModified = stats.mtime;
|
|
5568
5569
|
snapshot.permissions = stats.mode.toString(8);
|
|
@@ -5583,7 +5584,7 @@ This action cannot be undone.`
|
|
|
5583
5584
|
*/
|
|
5584
5585
|
shouldSnapshotFile(filePath) {
|
|
5585
5586
|
try {
|
|
5586
|
-
const stats =
|
|
5587
|
+
const stats = ops6.statSync(filePath);
|
|
5587
5588
|
if (stats.size > 1024 * 1024) {
|
|
5588
5589
|
return false;
|
|
5589
5590
|
}
|
|
@@ -5676,14 +5677,14 @@ This action cannot be undone.`
|
|
|
5676
5677
|
try {
|
|
5677
5678
|
const currentExists = await pathExists7(snapshot.filePath);
|
|
5678
5679
|
if (snapshot.existed && snapshot.content !== void 0) {
|
|
5679
|
-
await
|
|
5680
|
-
await
|
|
5680
|
+
await ops6.ensureDir(path7.dirname(snapshot.filePath));
|
|
5681
|
+
await ops6.promises.writeFile(snapshot.filePath, snapshot.content, "utf-8");
|
|
5681
5682
|
if (snapshot.permissions) {
|
|
5682
|
-
await
|
|
5683
|
+
await ops6.promises.chmod(snapshot.filePath, parseInt(snapshot.permissions, 8));
|
|
5683
5684
|
}
|
|
5684
5685
|
restored.push(`Restored: ${snapshot.filePath}`);
|
|
5685
5686
|
} else if (!snapshot.existed && currentExists) {
|
|
5686
|
-
await
|
|
5687
|
+
await ops6.promises.rm(snapshot.filePath);
|
|
5687
5688
|
restored.push(`Removed: ${snapshot.filePath}`);
|
|
5688
5689
|
}
|
|
5689
5690
|
} catch (error) {
|
|
@@ -5830,7 +5831,7 @@ ${errors.join("\n")}`;
|
|
|
5830
5831
|
async loadHistory() {
|
|
5831
5832
|
try {
|
|
5832
5833
|
if (await pathExists7(this.historyFile)) {
|
|
5833
|
-
const data = await
|
|
5834
|
+
const data = await ops6.promises.readFile(this.historyFile, "utf-8");
|
|
5834
5835
|
const parsed = JSON.parse(data);
|
|
5835
5836
|
this.history = parsed.entries.map((entry) => ({
|
|
5836
5837
|
...entry,
|
|
@@ -5848,13 +5849,13 @@ ${errors.join("\n")}`;
|
|
|
5848
5849
|
*/
|
|
5849
5850
|
async saveHistory() {
|
|
5850
5851
|
try {
|
|
5851
|
-
await
|
|
5852
|
+
await ops6.ensureDir(path7.dirname(this.historyFile));
|
|
5852
5853
|
const data = {
|
|
5853
5854
|
entries: this.history,
|
|
5854
5855
|
currentPosition: this.currentPosition,
|
|
5855
5856
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
5856
5857
|
};
|
|
5857
|
-
await
|
|
5858
|
+
await ops6.promises.writeFile(this.historyFile, JSON.stringify(data, null, 2), "utf-8");
|
|
5858
5859
|
} catch (error) {
|
|
5859
5860
|
}
|
|
5860
5861
|
}
|
|
@@ -5884,7 +5885,7 @@ try {
|
|
|
5884
5885
|
}
|
|
5885
5886
|
var pathExists8 = async (filePath) => {
|
|
5886
5887
|
try {
|
|
5887
|
-
await
|
|
5888
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
5888
5889
|
return true;
|
|
5889
5890
|
} catch {
|
|
5890
5891
|
return false;
|
|
@@ -5960,7 +5961,7 @@ var ASTParserTool = class {
|
|
|
5960
5961
|
if (!await pathExists8(filePath)) {
|
|
5961
5962
|
throw new Error(`File not found: ${filePath}`);
|
|
5962
5963
|
}
|
|
5963
|
-
const content = await
|
|
5964
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
5964
5965
|
const language = this.detectLanguage(filePath);
|
|
5965
5966
|
let result;
|
|
5966
5967
|
if (language === "typescript" || language === "tsx") {
|
|
@@ -6649,7 +6650,7 @@ var SymbolSearchTool = class {
|
|
|
6649
6650
|
async findSymbolUsages(symbolRef) {
|
|
6650
6651
|
const usages = [];
|
|
6651
6652
|
try {
|
|
6652
|
-
const content = await
|
|
6653
|
+
const content = await fs.promises.readFile(symbolRef.filePath, "utf-8");
|
|
6653
6654
|
const lines = content.split("\n");
|
|
6654
6655
|
for (let i = 0; i < lines.length; i++) {
|
|
6655
6656
|
const line = lines[i];
|
|
@@ -6704,7 +6705,7 @@ var SymbolSearchTool = class {
|
|
|
6704
6705
|
const usageFiles = symbolRef.usages.filter((usage) => usage.type === "reference" || usage.type === "call").map(() => symbolRef.filePath);
|
|
6705
6706
|
const importedBy = symbolRef.usages.filter((usage) => usage.type === "import").map(() => symbolRef.filePath);
|
|
6706
6707
|
const exportedTo = symbolRef.usages.filter((usage) => usage.type === "export").map(() => symbolRef.filePath);
|
|
6707
|
-
|
|
6708
|
+
crossRefs.push({
|
|
6708
6709
|
symbol: symbolName,
|
|
6709
6710
|
definitionFile,
|
|
6710
6711
|
usageFiles: [...new Set(usageFiles)],
|
|
@@ -6823,7 +6824,7 @@ var SymbolSearchTool = class {
|
|
|
6823
6824
|
};
|
|
6824
6825
|
var pathExists9 = async (filePath) => {
|
|
6825
6826
|
try {
|
|
6826
|
-
await
|
|
6827
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
6827
6828
|
return true;
|
|
6828
6829
|
} catch {
|
|
6829
6830
|
return false;
|
|
@@ -7294,7 +7295,7 @@ var DependencyAnalyzerTool = class {
|
|
|
7294
7295
|
};
|
|
7295
7296
|
var pathExists10 = async (filePath) => {
|
|
7296
7297
|
try {
|
|
7297
|
-
await
|
|
7298
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
7298
7299
|
return true;
|
|
7299
7300
|
} catch {
|
|
7300
7301
|
return false;
|
|
@@ -7442,7 +7443,7 @@ var CodeContextTool = class {
|
|
|
7442
7443
|
async analyzeUsagePatterns(symbol, filePath) {
|
|
7443
7444
|
const patterns = [];
|
|
7444
7445
|
try {
|
|
7445
|
-
const content = await
|
|
7446
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
7446
7447
|
const lines = content.split("\n");
|
|
7447
7448
|
let callCount = 0;
|
|
7448
7449
|
let assignmentCount = 0;
|
|
@@ -7595,7 +7596,7 @@ var CodeContextTool = class {
|
|
|
7595
7596
|
}
|
|
7596
7597
|
async analyzeSemanticContext(filePath, symbols, dependencies) {
|
|
7597
7598
|
const fileName = path7__default.basename(filePath);
|
|
7598
|
-
const content = await
|
|
7599
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
7599
7600
|
const purpose = this.inferPurpose(fileName, symbols, content);
|
|
7600
7601
|
const domain = this.extractDomain(filePath, symbols, dependencies);
|
|
7601
7602
|
const patterns = this.detectDesignPatterns(content, symbols);
|
|
@@ -7724,7 +7725,7 @@ var CodeContextTool = class {
|
|
|
7724
7725
|
};
|
|
7725
7726
|
}
|
|
7726
7727
|
async calculateCodeMetrics(filePath, symbols) {
|
|
7727
|
-
const content = await
|
|
7728
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
7728
7729
|
const lines = content.split("\n");
|
|
7729
7730
|
const codeLines = lines.filter((line) => line.trim().length > 0 && !line.trim().startsWith("//"));
|
|
7730
7731
|
const linesOfCode = codeLines.length;
|
|
@@ -7824,7 +7825,7 @@ var CodeContextTool = class {
|
|
|
7824
7825
|
};
|
|
7825
7826
|
var pathExists11 = async (filePath) => {
|
|
7826
7827
|
try {
|
|
7827
|
-
await
|
|
7828
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
7828
7829
|
return true;
|
|
7829
7830
|
} catch {
|
|
7830
7831
|
return false;
|
|
@@ -7908,8 +7909,8 @@ var RefactoringAssistantTool = class {
|
|
|
7908
7909
|
throw new Error("Failed to find symbol occurrences");
|
|
7909
7910
|
}
|
|
7910
7911
|
const symbolRefs = parsed.result.symbols;
|
|
7911
|
-
const relevantRefs = scope === "file" && filePath ?
|
|
7912
|
-
if (
|
|
7912
|
+
const relevantRefs = scope === "file" && filePath ? symbolRefs.filter((ref) => ref.filePath === filePath) : symbolRefs;
|
|
7913
|
+
if (relevantRefs.length === 0) {
|
|
7913
7914
|
throw new Error(`Symbol '${symbolName}' not found in specified scope`);
|
|
7914
7915
|
}
|
|
7915
7916
|
const safety = await this.analyzeSafety(relevantRefs, "rename");
|
|
@@ -7948,7 +7949,7 @@ var RefactoringAssistantTool = class {
|
|
|
7948
7949
|
if (!await pathExists11(filePath)) {
|
|
7949
7950
|
throw new Error(`File not found: ${filePath}`);
|
|
7950
7951
|
}
|
|
7951
|
-
const content = await
|
|
7952
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
7952
7953
|
const lines = content.split("\n");
|
|
7953
7954
|
if (startLine < 0 || endLine >= lines.length || startLine > endLine) {
|
|
7954
7955
|
throw new Error("Invalid line range");
|
|
@@ -8023,7 +8024,7 @@ var RefactoringAssistantTool = class {
|
|
|
8023
8024
|
if (!filePath || !variableName) {
|
|
8024
8025
|
throw new Error("File path and variable name are required");
|
|
8025
8026
|
}
|
|
8026
|
-
const content = await
|
|
8027
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
8027
8028
|
const lines = content.split("\n");
|
|
8028
8029
|
const startLineContent = lines[startLine];
|
|
8029
8030
|
const endLineContent = lines[endLine];
|
|
@@ -8098,7 +8099,7 @@ var RefactoringAssistantTool = class {
|
|
|
8098
8099
|
if (!functionSymbol) {
|
|
8099
8100
|
throw new Error(`Function '${symbolName}' not found`);
|
|
8100
8101
|
}
|
|
8101
|
-
const content = await
|
|
8102
|
+
const content = await fs.promises.readFile(filePath, "utf-8");
|
|
8102
8103
|
const lines = content.split("\n");
|
|
8103
8104
|
const functionLines = lines.slice(functionSymbol.startPosition.row, functionSymbol.endPosition.row + 1);
|
|
8104
8105
|
const functionBody = this.extractFunctionBody(functionLines.join("\n"));
|
|
@@ -8182,8 +8183,8 @@ var RefactoringAssistantTool = class {
|
|
|
8182
8183
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
8183
8184
|
}
|
|
8184
8185
|
async analyzeSafety(refs, operation) {
|
|
8185
|
-
const affectedFiles = new Set(
|
|
8186
|
-
const affectedSymbols =
|
|
8186
|
+
const affectedFiles = new Set(refs.map((ref) => ref.filePath)).size;
|
|
8187
|
+
const affectedSymbols = refs.length;
|
|
8187
8188
|
let riskLevel = "low";
|
|
8188
8189
|
const potentialIssues = [];
|
|
8189
8190
|
if (affectedFiles > 5) {
|
|
@@ -8208,7 +8209,7 @@ var RefactoringAssistantTool = class {
|
|
|
8208
8209
|
}
|
|
8209
8210
|
async generateRenameChanges(ref, oldName, newName, includeComments, includeStrings) {
|
|
8210
8211
|
const changes = [];
|
|
8211
|
-
const content = await
|
|
8212
|
+
const content = await fs.promises.readFile(ref.filePath, "utf-8");
|
|
8212
8213
|
const lines = content.split("\n");
|
|
8213
8214
|
for (let i = 0; i < lines.length; i++) {
|
|
8214
8215
|
const line = lines[i];
|
|
@@ -8499,10 +8500,10 @@ function createTokenCounter(model) {
|
|
|
8499
8500
|
function loadCustomInstructions(workingDirectory = process.cwd()) {
|
|
8500
8501
|
try {
|
|
8501
8502
|
const instructionsPath = path7.join(workingDirectory, ".grok", "GROK.md");
|
|
8502
|
-
if (!
|
|
8503
|
+
if (!fs.existsSync(instructionsPath)) {
|
|
8503
8504
|
return null;
|
|
8504
8505
|
}
|
|
8505
|
-
const customInstructions =
|
|
8506
|
+
const customInstructions = fs.readFileSync(instructionsPath, "utf-8");
|
|
8506
8507
|
return customInstructions.trim();
|
|
8507
8508
|
} catch (error) {
|
|
8508
8509
|
console.warn("Failed to load custom instructions:", error);
|
|
@@ -9241,7 +9242,7 @@ EOF`;
|
|
|
9241
9242
|
|
|
9242
9243
|
// package.json
|
|
9243
9244
|
var package_default = {
|
|
9244
|
-
version: "1.0.
|
|
9245
|
+
version: "1.0.31"};
|
|
9245
9246
|
|
|
9246
9247
|
// src/utils/text-utils.ts
|
|
9247
9248
|
function isWordBoundary(char) {
|
|
@@ -9636,7 +9637,7 @@ var ClaudeMdParserImpl = class {
|
|
|
9636
9637
|
};
|
|
9637
9638
|
}
|
|
9638
9639
|
try {
|
|
9639
|
-
const content = await
|
|
9640
|
+
const content = await ops6.promises.readFile(claudePath, "utf-8");
|
|
9640
9641
|
const hasDocumentationSection = content.includes("Documentation System Workflow") || content.includes(".agent documentation system");
|
|
9641
9642
|
return {
|
|
9642
9643
|
exists: true,
|
|
@@ -9671,7 +9672,7 @@ This document provides context and instructions for Claude Code when working wit
|
|
|
9671
9672
|
|
|
9672
9673
|
${documentationSection}`;
|
|
9673
9674
|
}
|
|
9674
|
-
await
|
|
9675
|
+
await ops6.promises.writeFile(claudePath, newContent);
|
|
9675
9676
|
return {
|
|
9676
9677
|
success: true,
|
|
9677
9678
|
message: exists ? "\u2705 Updated existing CLAUDE.md with documentation system instructions" : "\u2705 Created CLAUDE.md with documentation system instructions"
|
|
@@ -9739,15 +9740,15 @@ var AgentSystemGenerator = class {
|
|
|
9739
9740
|
filesCreated: []
|
|
9740
9741
|
};
|
|
9741
9742
|
}
|
|
9742
|
-
await
|
|
9743
|
-
await
|
|
9744
|
-
await
|
|
9745
|
-
await
|
|
9746
|
-
await
|
|
9747
|
-
await
|
|
9748
|
-
await
|
|
9743
|
+
await ops6.mkdir(agentPath, { recursive: true });
|
|
9744
|
+
await ops6.mkdir(path7__default.join(agentPath, "system"), { recursive: true });
|
|
9745
|
+
await ops6.mkdir(path7__default.join(agentPath, "tasks"), { recursive: true });
|
|
9746
|
+
await ops6.mkdir(path7__default.join(agentPath, "sop"), { recursive: true });
|
|
9747
|
+
await ops6.mkdir(path7__default.join(agentPath, "incidents"), { recursive: true });
|
|
9748
|
+
await ops6.mkdir(path7__default.join(agentPath, "guardrails"), { recursive: true });
|
|
9749
|
+
await ops6.mkdir(path7__default.join(agentPath, "commands"), { recursive: true });
|
|
9749
9750
|
const readmeContent = this.generateReadmeContent();
|
|
9750
|
-
await
|
|
9751
|
+
await ops6.promises.writeFile(path7__default.join(agentPath, "README.md"), readmeContent);
|
|
9751
9752
|
filesCreated.push(".agent/README.md");
|
|
9752
9753
|
const systemFiles = await this.generateSystemDocs(agentPath);
|
|
9753
9754
|
filesCreated.push(...systemFiles);
|
|
@@ -9857,13 +9858,13 @@ Documentation for documentation system commands:
|
|
|
9857
9858
|
const systemPath = path7__default.join(agentPath, "system");
|
|
9858
9859
|
const files = [];
|
|
9859
9860
|
const archContent = this.config.projectType === "grok-cli" ? this.generateGrokArchitecture() : this.generateExternalArchitecture();
|
|
9860
|
-
await
|
|
9861
|
+
await ops6.promises.writeFile(path7__default.join(systemPath, "architecture.md"), archContent);
|
|
9861
9862
|
files.push(".agent/system/architecture.md");
|
|
9862
9863
|
const criticalStateContent = this.generateCriticalState();
|
|
9863
|
-
await
|
|
9864
|
+
await ops6.promises.writeFile(path7__default.join(systemPath, "critical-state.md"), criticalStateContent);
|
|
9864
9865
|
files.push(".agent/system/critical-state.md");
|
|
9865
9866
|
const apiContent = this.generateApiSchema();
|
|
9866
|
-
await
|
|
9867
|
+
await ops6.promises.writeFile(path7__default.join(systemPath, "api-schema.md"), apiContent);
|
|
9867
9868
|
files.push(".agent/system/api-schema.md");
|
|
9868
9869
|
return files;
|
|
9869
9870
|
}
|
|
@@ -10220,7 +10221,7 @@ interface Tool {
|
|
|
10220
10221
|
|
|
10221
10222
|
*Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
|
|
10222
10223
|
`;
|
|
10223
|
-
await
|
|
10224
|
+
await ops6.promises.writeFile(path7__default.join(sopPath, "documentation-workflow.md"), docWorkflowContent);
|
|
10224
10225
|
files.push(".agent/sop/documentation-workflow.md");
|
|
10225
10226
|
if (this.config.projectType === "grok-cli") {
|
|
10226
10227
|
const newCommandContent = `# \u2699\uFE0F Adding New Commands SOP
|
|
@@ -10295,7 +10296,7 @@ Create tool in \`src/tools/\`, then reference in command handler.
|
|
|
10295
10296
|
|
|
10296
10297
|
*Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
|
|
10297
10298
|
`;
|
|
10298
|
-
await
|
|
10299
|
+
await ops6.promises.writeFile(path7__default.join(sopPath, "adding-new-command.md"), newCommandContent);
|
|
10299
10300
|
files.push(".agent/sop/adding-new-command.md");
|
|
10300
10301
|
}
|
|
10301
10302
|
return files;
|
|
@@ -10304,7 +10305,7 @@ Create tool in \`src/tools/\`, then reference in command handler.
|
|
|
10304
10305
|
const tasksPath = path7__default.join(agentPath, "tasks");
|
|
10305
10306
|
const files = [];
|
|
10306
10307
|
const exampleContent = this.config.projectType === "grok-cli" ? this.generateGrokExampleTask() : this.generateExternalExampleTask();
|
|
10307
|
-
await
|
|
10308
|
+
await ops6.promises.writeFile(path7__default.join(tasksPath, "example-prd.md"), exampleContent);
|
|
10308
10309
|
files.push(".agent/tasks/example-prd.md");
|
|
10309
10310
|
return files;
|
|
10310
10311
|
}
|
|
@@ -10496,7 +10497,7 @@ After initialization:
|
|
|
10496
10497
|
|
|
10497
10498
|
*Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
|
|
10498
10499
|
`;
|
|
10499
|
-
await
|
|
10500
|
+
await ops6.promises.writeFile(path7__default.join(commandsPath, "init-agent.md"), initAgentContent);
|
|
10500
10501
|
files.push(".agent/commands/init-agent.md");
|
|
10501
10502
|
return files;
|
|
10502
10503
|
}
|
|
@@ -10504,7 +10505,7 @@ After initialization:
|
|
|
10504
10505
|
const agentPath = path7__default.join(this.config.rootPath, ".agent");
|
|
10505
10506
|
try {
|
|
10506
10507
|
if (existsSync(agentPath)) {
|
|
10507
|
-
await
|
|
10508
|
+
await ops6.rm(agentPath, { recursive: true, force: true });
|
|
10508
10509
|
}
|
|
10509
10510
|
return await this.generateAgentSystem();
|
|
10510
10511
|
} catch (error) {
|
|
@@ -10591,7 +10592,7 @@ var ReadmeGenerator = class {
|
|
|
10591
10592
|
};
|
|
10592
10593
|
}
|
|
10593
10594
|
const content = this.generateReadmeContent(analysis);
|
|
10594
|
-
await
|
|
10595
|
+
await ops6.promises.writeFile(readmePath, content);
|
|
10595
10596
|
return {
|
|
10596
10597
|
success: true,
|
|
10597
10598
|
message: readmeExists ? "\u2705 Updated existing README.md with comprehensive documentation" : "\u2705 Created new README.md with project documentation",
|
|
@@ -10618,7 +10619,7 @@ var ReadmeGenerator = class {
|
|
|
10618
10619
|
try {
|
|
10619
10620
|
const packagePath = path7__default.join(this.config.rootPath, "package.json");
|
|
10620
10621
|
if (existsSync(packagePath)) {
|
|
10621
|
-
const packageContent = await
|
|
10622
|
+
const packageContent = await ops6.promises.readFile(packagePath, "utf-8");
|
|
10622
10623
|
analysis.packageJson = JSON.parse(packageContent);
|
|
10623
10624
|
analysis.dependencies = Object.keys(analysis.packageJson.dependencies || {});
|
|
10624
10625
|
analysis.devDependencies = Object.keys(analysis.packageJson.devDependencies || {});
|
|
@@ -10909,7 +10910,7 @@ var CommentsGenerator = class {
|
|
|
10909
10910
|
message: "File not found"
|
|
10910
10911
|
};
|
|
10911
10912
|
}
|
|
10912
|
-
const content = await
|
|
10913
|
+
const content = await ops6.promises.readFile(this.config.filePath, "utf-8");
|
|
10913
10914
|
const analysis = this.analyzeCode(content);
|
|
10914
10915
|
if (analysis.hasExistingComments) {
|
|
10915
10916
|
return {
|
|
@@ -10919,8 +10920,8 @@ var CommentsGenerator = class {
|
|
|
10919
10920
|
}
|
|
10920
10921
|
const modifiedContent = this.addComments(content, analysis);
|
|
10921
10922
|
const backupPath = this.config.filePath + ".backup";
|
|
10922
|
-
await
|
|
10923
|
-
await
|
|
10923
|
+
await ops6.promises.writeFile(backupPath, content);
|
|
10924
|
+
await ops6.promises.writeFile(this.config.filePath, modifiedContent);
|
|
10924
10925
|
const commentCount = this.countAddedComments(analysis);
|
|
10925
10926
|
return {
|
|
10926
10927
|
success: true,
|
|
@@ -11136,7 +11137,7 @@ var ApiDocsGenerator = class {
|
|
|
11136
11137
|
const content = this.config.outputFormat === "md" ? this.generateMarkdown(documentation) : this.generateHtml(documentation);
|
|
11137
11138
|
const outputFileName = `api-docs.${this.config.outputFormat}`;
|
|
11138
11139
|
const outputPath = path7__default.join(this.config.rootPath, outputFileName);
|
|
11139
|
-
await
|
|
11140
|
+
await ops6.promises.writeFile(outputPath, content);
|
|
11140
11141
|
const stats = this.getDocumentationStats(documentation);
|
|
11141
11142
|
return {
|
|
11142
11143
|
success: true,
|
|
@@ -11172,7 +11173,7 @@ ${stats}`,
|
|
|
11172
11173
|
}
|
|
11173
11174
|
async scanDirectory(dirPath, documentation) {
|
|
11174
11175
|
try {
|
|
11175
|
-
const entries = await
|
|
11176
|
+
const entries = await ops6.promises.readdir(dirPath, { withFileTypes: true });
|
|
11176
11177
|
for (const entry of entries) {
|
|
11177
11178
|
const fullPath = path7__default.join(dirPath, entry.name);
|
|
11178
11179
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
@@ -11191,7 +11192,7 @@ ${stats}`,
|
|
|
11191
11192
|
}
|
|
11192
11193
|
async parseApiFile(filePath, documentation) {
|
|
11193
11194
|
try {
|
|
11194
|
-
const content = await
|
|
11195
|
+
const content = await ops6.promises.readFile(filePath, "utf-8");
|
|
11195
11196
|
const relativePath = path7__default.relative(this.config.rootPath, filePath);
|
|
11196
11197
|
const moduleName = this.getModuleName(relativePath);
|
|
11197
11198
|
const lines = content.split("\n");
|
|
@@ -11518,12 +11519,12 @@ var ChangelogGenerator = class {
|
|
|
11518
11519
|
const changelogPath = path7__default.join(this.config.rootPath, "CHANGELOG.md");
|
|
11519
11520
|
const exists = existsSync(changelogPath);
|
|
11520
11521
|
if (exists) {
|
|
11521
|
-
const existingContent = await
|
|
11522
|
+
const existingContent = await ops6.promises.readFile(changelogPath, "utf-8");
|
|
11522
11523
|
const newContent = content + "\n\n" + existingContent;
|
|
11523
|
-
await
|
|
11524
|
+
await ops6.promises.writeFile(changelogPath, newContent);
|
|
11524
11525
|
} else {
|
|
11525
11526
|
const fullContent = this.generateChangelogHeader() + content;
|
|
11526
|
-
await
|
|
11527
|
+
await ops6.promises.writeFile(changelogPath, fullContent);
|
|
11527
11528
|
}
|
|
11528
11529
|
return {
|
|
11529
11530
|
success: true,
|
|
@@ -11815,13 +11816,13 @@ var UpdateAgentDocs = class {
|
|
|
11815
11816
|
const recentFiles = [];
|
|
11816
11817
|
const scanDir = async (dirPath) => {
|
|
11817
11818
|
try {
|
|
11818
|
-
const entries = await
|
|
11819
|
+
const entries = await ops6.promises.readdir(dirPath, { withFileTypes: true });
|
|
11819
11820
|
for (const entry of entries) {
|
|
11820
11821
|
const fullPath = path7__default.join(dirPath, entry.name);
|
|
11821
11822
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
11822
11823
|
await scanDir(fullPath);
|
|
11823
11824
|
} else if (entry.isFile()) {
|
|
11824
|
-
const stats = await
|
|
11825
|
+
const stats = await ops6.promises.stat(fullPath);
|
|
11825
11826
|
if (stats.mtime.getTime() > oneDayAgo) {
|
|
11826
11827
|
recentFiles.push(path7__default.relative(this.config.rootPath, fullPath));
|
|
11827
11828
|
}
|
|
@@ -11877,9 +11878,9 @@ var UpdateAgentDocs = class {
|
|
|
11877
11878
|
try {
|
|
11878
11879
|
const archPath = path7__default.join(systemPath, "architecture.md");
|
|
11879
11880
|
if (existsSync(archPath)) {
|
|
11880
|
-
const content = await
|
|
11881
|
+
const content = await ops6.promises.readFile(archPath, "utf-8");
|
|
11881
11882
|
const updatedContent = await this.updateArchitectureDoc(content, analysis);
|
|
11882
|
-
await
|
|
11883
|
+
await ops6.promises.writeFile(archPath, updatedContent);
|
|
11883
11884
|
updatedFiles.push(".agent/system/architecture.md");
|
|
11884
11885
|
}
|
|
11885
11886
|
} catch (error) {
|
|
@@ -11893,7 +11894,7 @@ var UpdateAgentDocs = class {
|
|
|
11893
11894
|
if (!existsSync(criticalStatePath)) {
|
|
11894
11895
|
return false;
|
|
11895
11896
|
}
|
|
11896
|
-
const content = await
|
|
11897
|
+
const content = await ops6.promises.readFile(criticalStatePath, "utf-8");
|
|
11897
11898
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
11898
11899
|
const changesSummary = this.generateChangesSummary(analysis);
|
|
11899
11900
|
let updatedContent = content.replace(
|
|
@@ -11918,7 +11919,7 @@ Updated By: /update-agent-docs after detecting changes${recentChangesSection}`
|
|
|
11918
11919
|
);
|
|
11919
11920
|
}
|
|
11920
11921
|
}
|
|
11921
|
-
await
|
|
11922
|
+
await ops6.promises.writeFile(criticalStatePath, updatedContent);
|
|
11922
11923
|
return true;
|
|
11923
11924
|
} catch (error) {
|
|
11924
11925
|
return false;
|
|
@@ -12368,9 +12369,9 @@ var SelfHealingSystem = class {
|
|
|
12368
12369
|
try {
|
|
12369
12370
|
const incident = await this.analyzeAndCreateIncident(error, context);
|
|
12370
12371
|
const incidentPath = path7__default.join(this.agentPath, "incidents", `${incident.id}.md`);
|
|
12371
|
-
await
|
|
12372
|
+
await ops6.mkdir(path7__default.dirname(incidentPath), { recursive: true });
|
|
12372
12373
|
const incidentContent = this.generateIncidentContent(incident);
|
|
12373
|
-
await
|
|
12374
|
+
await ops6.promises.writeFile(incidentPath, incidentContent);
|
|
12374
12375
|
const guardrail = await this.generateGuardrailFromIncident(incident);
|
|
12375
12376
|
if (guardrail) {
|
|
12376
12377
|
await this.saveGuardrail(guardrail);
|
|
@@ -12500,12 +12501,12 @@ ${guardrail ? `\u{1F6E1}\uFE0F Guardrail created: ${guardrail.name}` : ""}
|
|
|
12500
12501
|
if (!existsSync(incidentsPath)) {
|
|
12501
12502
|
return 0;
|
|
12502
12503
|
}
|
|
12503
|
-
const files = await
|
|
12504
|
+
const files = await ops6.promises.readdir(incidentsPath);
|
|
12504
12505
|
let count = 0;
|
|
12505
12506
|
for (const file of files) {
|
|
12506
12507
|
if (file.endsWith(".md")) {
|
|
12507
12508
|
const filePath = path7__default.join(incidentsPath, file);
|
|
12508
|
-
const content = await
|
|
12509
|
+
const content = await ops6.promises.readFile(filePath, "utf-8");
|
|
12509
12510
|
if (content.includes(title)) {
|
|
12510
12511
|
count++;
|
|
12511
12512
|
}
|
|
@@ -12598,10 +12599,10 @@ ${incident.guardrailCreated ? `Guardrail created: ${incident.guardrailCreated}`
|
|
|
12598
12599
|
}
|
|
12599
12600
|
async saveGuardrail(guardrail) {
|
|
12600
12601
|
const guardrailsPath = path7__default.join(this.agentPath, "guardrails");
|
|
12601
|
-
await
|
|
12602
|
+
await ops6.mkdir(guardrailsPath, { recursive: true });
|
|
12602
12603
|
const filePath = path7__default.join(guardrailsPath, `${guardrail.id}.md`);
|
|
12603
12604
|
const content = this.generateGuardrailContent(guardrail);
|
|
12604
|
-
await
|
|
12605
|
+
await ops6.promises.writeFile(filePath, content);
|
|
12605
12606
|
}
|
|
12606
12607
|
generateGuardrailContent(guardrail) {
|
|
12607
12608
|
return `# ${guardrail.name}
|
|
@@ -12660,12 +12661,12 @@ ${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` :
|
|
|
12660
12661
|
if (!existsSync(guardrailsPath)) {
|
|
12661
12662
|
return [];
|
|
12662
12663
|
}
|
|
12663
|
-
const files = await
|
|
12664
|
+
const files = await ops6.promises.readdir(guardrailsPath);
|
|
12664
12665
|
const guardrails = [];
|
|
12665
12666
|
for (const file of files) {
|
|
12666
12667
|
if (file.endsWith(".md")) {
|
|
12667
12668
|
try {
|
|
12668
|
-
const content = await
|
|
12669
|
+
const content = await ops6.promises.readFile(path7__default.join(guardrailsPath, file), "utf-8");
|
|
12669
12670
|
const guardrail = this.parseGuardrailFromContent(content);
|
|
12670
12671
|
if (guardrail) {
|
|
12671
12672
|
guardrails.push(guardrail);
|
|
@@ -12725,12 +12726,12 @@ ${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` :
|
|
|
12725
12726
|
if (!existsSync(incidentsPath)) {
|
|
12726
12727
|
return [];
|
|
12727
12728
|
}
|
|
12728
|
-
const files = await
|
|
12729
|
+
const files = await ops6.promises.readdir(incidentsPath);
|
|
12729
12730
|
const incidents = [];
|
|
12730
12731
|
for (const file of files) {
|
|
12731
12732
|
if (file.endsWith(".md")) {
|
|
12732
12733
|
try {
|
|
12733
|
-
const content = await
|
|
12734
|
+
const content = await ops6.promises.readFile(path7__default.join(incidentsPath, file), "utf-8");
|
|
12734
12735
|
const incident = this.parseIncidentFromContent(content);
|
|
12735
12736
|
if (incident) {
|
|
12736
12737
|
incidents.push(incident);
|