@xagent/x-cli 1.2.13 → 1.2.14
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/README.md +19 -1
- package/dist/index.js +165 -160
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import OpenAI from 'openai';
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
3
|
+
import * as fs10 from 'fs';
|
|
4
|
+
import fs10__default, { existsSync, promises } from 'fs';
|
|
5
5
|
import * as path8 from 'path';
|
|
6
6
|
import path8__default from 'path';
|
|
7
7
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
@@ -13,8 +13,8 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
13
13
|
import { exec, execSync, spawn } from 'child_process';
|
|
14
14
|
import { promisify } from 'util';
|
|
15
15
|
import { createTwoFilesPatch } from 'diff';
|
|
16
|
-
import * as
|
|
17
|
-
import
|
|
16
|
+
import * as fs7 from 'fs/promises';
|
|
17
|
+
import fs7__default, { writeFile } from 'fs/promises';
|
|
18
18
|
import * as ops6 from 'fs-extra';
|
|
19
19
|
import { parse } from '@typescript-eslint/typescript-estree';
|
|
20
20
|
import Fuse from 'fuse.js';
|
|
@@ -170,11 +170,11 @@ var init_client = __esm({
|
|
|
170
170
|
};
|
|
171
171
|
const logPath = process.env.XCLI_TOKEN_LOG || `${process.env.HOME}/.grok/token-usage.jsonl`;
|
|
172
172
|
const dir = path8__default.dirname(logPath);
|
|
173
|
-
if (!
|
|
174
|
-
|
|
173
|
+
if (!fs10__default.existsSync(dir)) {
|
|
174
|
+
fs10__default.mkdirSync(dir, { recursive: true });
|
|
175
175
|
}
|
|
176
176
|
const logLine = JSON.stringify(tokenData) + "\n";
|
|
177
|
-
|
|
177
|
+
fs10__default.appendFileSync(logPath, logLine);
|
|
178
178
|
} catch (error) {
|
|
179
179
|
console.warn("Failed to log token usage:", error);
|
|
180
180
|
}
|
|
@@ -435,8 +435,8 @@ var init_settings_manager = __esm({
|
|
|
435
435
|
*/
|
|
436
436
|
ensureDirectoryExists(filePath) {
|
|
437
437
|
const dir = path8.dirname(filePath);
|
|
438
|
-
if (!
|
|
439
|
-
|
|
438
|
+
if (!fs10.existsSync(dir)) {
|
|
439
|
+
fs10.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
@@ -444,11 +444,11 @@ var init_settings_manager = __esm({
|
|
|
444
444
|
*/
|
|
445
445
|
loadUserSettings() {
|
|
446
446
|
try {
|
|
447
|
-
if (!
|
|
447
|
+
if (!fs10.existsSync(this.userSettingsPath)) {
|
|
448
448
|
this.saveUserSettings(DEFAULT_USER_SETTINGS);
|
|
449
449
|
return { ...DEFAULT_USER_SETTINGS };
|
|
450
450
|
}
|
|
451
|
-
const content =
|
|
451
|
+
const content = fs10.readFileSync(this.userSettingsPath, "utf-8");
|
|
452
452
|
const settings = JSON.parse(content);
|
|
453
453
|
return { ...DEFAULT_USER_SETTINGS, ...settings };
|
|
454
454
|
} catch (error) {
|
|
@@ -466,9 +466,9 @@ var init_settings_manager = __esm({
|
|
|
466
466
|
try {
|
|
467
467
|
this.ensureDirectoryExists(this.userSettingsPath);
|
|
468
468
|
let existingSettings = { ...DEFAULT_USER_SETTINGS };
|
|
469
|
-
if (
|
|
469
|
+
if (fs10.existsSync(this.userSettingsPath)) {
|
|
470
470
|
try {
|
|
471
|
-
const content =
|
|
471
|
+
const content = fs10.readFileSync(this.userSettingsPath, "utf-8");
|
|
472
472
|
const parsed = JSON.parse(content);
|
|
473
473
|
existingSettings = { ...DEFAULT_USER_SETTINGS, ...parsed };
|
|
474
474
|
} catch (_error) {
|
|
@@ -476,7 +476,7 @@ var init_settings_manager = __esm({
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
const mergedSettings = { ...existingSettings, ...settings };
|
|
479
|
-
|
|
479
|
+
fs10.writeFileSync(
|
|
480
480
|
this.userSettingsPath,
|
|
481
481
|
JSON.stringify(mergedSettings, null, 2),
|
|
482
482
|
{ mode: 384 }
|
|
@@ -509,11 +509,11 @@ var init_settings_manager = __esm({
|
|
|
509
509
|
*/
|
|
510
510
|
loadProjectSettings() {
|
|
511
511
|
try {
|
|
512
|
-
if (!
|
|
512
|
+
if (!fs10.existsSync(this.projectSettingsPath)) {
|
|
513
513
|
this.saveProjectSettings(DEFAULT_PROJECT_SETTINGS);
|
|
514
514
|
return { ...DEFAULT_PROJECT_SETTINGS };
|
|
515
515
|
}
|
|
516
|
-
const content =
|
|
516
|
+
const content = fs10.readFileSync(this.projectSettingsPath, "utf-8");
|
|
517
517
|
const settings = JSON.parse(content);
|
|
518
518
|
return { ...DEFAULT_PROJECT_SETTINGS, ...settings };
|
|
519
519
|
} catch (error) {
|
|
@@ -531,9 +531,9 @@ var init_settings_manager = __esm({
|
|
|
531
531
|
try {
|
|
532
532
|
this.ensureDirectoryExists(this.projectSettingsPath);
|
|
533
533
|
let existingSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
534
|
-
if (
|
|
534
|
+
if (fs10.existsSync(this.projectSettingsPath)) {
|
|
535
535
|
try {
|
|
536
|
-
const content =
|
|
536
|
+
const content = fs10.readFileSync(this.projectSettingsPath, "utf-8");
|
|
537
537
|
const parsed = JSON.parse(content);
|
|
538
538
|
existingSettings = { ...DEFAULT_PROJECT_SETTINGS, ...parsed };
|
|
539
539
|
} catch (_error) {
|
|
@@ -541,7 +541,7 @@ var init_settings_manager = __esm({
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
const mergedSettings = { ...existingSettings, ...settings };
|
|
544
|
-
|
|
544
|
+
fs10.writeFileSync(
|
|
545
545
|
this.projectSettingsPath,
|
|
546
546
|
JSON.stringify(mergedSettings, null, 2)
|
|
547
547
|
);
|
|
@@ -1926,12 +1926,12 @@ ${data ? JSON.stringify(data, null, 2) : "No additional data"}
|
|
|
1926
1926
|
`;
|
|
1927
1927
|
const workingDir = process.cwd();
|
|
1928
1928
|
const logsDir = path8.join(workingDir, "logs");
|
|
1929
|
-
const
|
|
1930
|
-
if (
|
|
1931
|
-
const sessionFiles =
|
|
1929
|
+
const fs22 = fs10;
|
|
1930
|
+
if (fs22.existsSync(logsDir)) {
|
|
1931
|
+
const sessionFiles = fs22.readdirSync(logsDir).filter((f) => f.startsWith("session-") && f.endsWith(".log"));
|
|
1932
1932
|
if (sessionFiles.length > 0) {
|
|
1933
1933
|
const sessionFile = path8.join(logsDir, sessionFiles[sessionFiles.length - 1]);
|
|
1934
|
-
|
|
1934
|
+
fs22.appendFileSync(sessionFile, logEntry);
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
1937
|
} catch (error) {
|
|
@@ -1944,7 +1944,7 @@ var init_text_editor = __esm({
|
|
|
1944
1944
|
init_confirmation_service();
|
|
1945
1945
|
pathExists = async (filePath) => {
|
|
1946
1946
|
try {
|
|
1947
|
-
await
|
|
1947
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
1948
1948
|
return true;
|
|
1949
1949
|
} catch {
|
|
1950
1950
|
return false;
|
|
@@ -1959,16 +1959,16 @@ var init_text_editor = __esm({
|
|
|
1959
1959
|
try {
|
|
1960
1960
|
const resolvedPath = path8.resolve(filePath);
|
|
1961
1961
|
if (await pathExists(resolvedPath)) {
|
|
1962
|
-
const stats = await
|
|
1962
|
+
const stats = await fs10.promises.stat(resolvedPath);
|
|
1963
1963
|
if (stats.isDirectory()) {
|
|
1964
|
-
const files = await
|
|
1964
|
+
const files = await fs10.promises.readdir(resolvedPath);
|
|
1965
1965
|
return {
|
|
1966
1966
|
success: true,
|
|
1967
1967
|
output: `Directory contents of ${filePath}:
|
|
1968
1968
|
${files.join("\n")}`
|
|
1969
1969
|
};
|
|
1970
1970
|
}
|
|
1971
|
-
const content = await
|
|
1971
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
1972
1972
|
const lines = content.split("\n");
|
|
1973
1973
|
if (viewRange) {
|
|
1974
1974
|
const [start, end] = viewRange;
|
|
@@ -2018,7 +2018,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2018
2018
|
error: `File not found: ${filePath}`
|
|
2019
2019
|
};
|
|
2020
2020
|
}
|
|
2021
|
-
const content = await
|
|
2021
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
2022
2022
|
if (!content.includes(oldStr)) {
|
|
2023
2023
|
if (oldStr.includes("\n")) {
|
|
2024
2024
|
const fuzzyResult = this.findFuzzyMatch(content, oldStr);
|
|
@@ -2118,7 +2118,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
2120
2120
|
const dir = path8.dirname(resolvedPath);
|
|
2121
|
-
await
|
|
2121
|
+
await fs10.promises.mkdir(dir, { recursive: true });
|
|
2122
2122
|
await writeFile(resolvedPath, content, "utf-8");
|
|
2123
2123
|
this.editHistory.push({
|
|
2124
2124
|
command: "create",
|
|
@@ -2148,7 +2148,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2148
2148
|
error: `File not found: ${filePath}`
|
|
2149
2149
|
};
|
|
2150
2150
|
}
|
|
2151
|
-
const fileContent = await
|
|
2151
|
+
const fileContent = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
2152
2152
|
const lines = fileContent.split("\n");
|
|
2153
2153
|
if (startLine < 1 || startLine > lines.length) {
|
|
2154
2154
|
return {
|
|
@@ -2216,7 +2216,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2216
2216
|
error: `File not found: ${filePath}`
|
|
2217
2217
|
};
|
|
2218
2218
|
}
|
|
2219
|
-
const fileContent = await
|
|
2219
|
+
const fileContent = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
2220
2220
|
const lines = fileContent.split("\n");
|
|
2221
2221
|
lines.splice(insertLine - 1, 0, content);
|
|
2222
2222
|
const newContent = lines.join("\n");
|
|
@@ -2250,7 +2250,7 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2250
2250
|
switch (lastEdit.command) {
|
|
2251
2251
|
case "str_replace":
|
|
2252
2252
|
if (lastEdit.path && lastEdit.old_str && lastEdit.new_str) {
|
|
2253
|
-
const content = await
|
|
2253
|
+
const content = await fs10.promises.readFile(lastEdit.path, "utf-8");
|
|
2254
2254
|
const revertedContent = content.replace(
|
|
2255
2255
|
lastEdit.new_str,
|
|
2256
2256
|
lastEdit.old_str
|
|
@@ -2260,12 +2260,12 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2260
2260
|
break;
|
|
2261
2261
|
case "create":
|
|
2262
2262
|
if (lastEdit.path) {
|
|
2263
|
-
await
|
|
2263
|
+
await fs10.promises.rm(lastEdit.path);
|
|
2264
2264
|
}
|
|
2265
2265
|
break;
|
|
2266
2266
|
case "insert":
|
|
2267
2267
|
if (lastEdit.path && lastEdit.insert_line) {
|
|
2268
|
-
const content = await
|
|
2268
|
+
const content = await fs10.promises.readFile(lastEdit.path, "utf-8");
|
|
2269
2269
|
const lines = content.split("\n");
|
|
2270
2270
|
lines.splice(lastEdit.insert_line - 1, 1);
|
|
2271
2271
|
await writeFile(lastEdit.path, lines.join("\n"), "utf-8");
|
|
@@ -2593,13 +2593,17 @@ ${numberedLines}${additionalLinesMessage}`
|
|
|
2593
2593
|
};
|
|
2594
2594
|
}
|
|
2595
2595
|
});
|
|
2596
|
+
var init_smart_edit = __esm({
|
|
2597
|
+
"src/tools/smart-edit.ts"() {
|
|
2598
|
+
}
|
|
2599
|
+
});
|
|
2596
2600
|
var pathExists2, MorphEditorTool;
|
|
2597
2601
|
var init_morph_editor = __esm({
|
|
2598
2602
|
"src/tools/morph-editor.ts"() {
|
|
2599
2603
|
init_confirmation_service();
|
|
2600
2604
|
pathExists2 = async (filePath) => {
|
|
2601
2605
|
try {
|
|
2602
|
-
await
|
|
2606
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
2603
2607
|
return true;
|
|
2604
2608
|
} catch {
|
|
2605
2609
|
return false;
|
|
@@ -2652,7 +2656,7 @@ var init_morph_editor = __esm({
|
|
|
2652
2656
|
error: "MORPH_API_KEY not configured. Please set your Morph API key."
|
|
2653
2657
|
};
|
|
2654
2658
|
}
|
|
2655
|
-
const initialCode = await
|
|
2659
|
+
const initialCode = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
2656
2660
|
const sessionFlags = this.confirmationService.getSessionFlags();
|
|
2657
2661
|
if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
|
|
2658
2662
|
const confirmationResult = await this.confirmationService.requestConfirmation(
|
|
@@ -2675,7 +2679,7 @@ ${codeEdit}`
|
|
|
2675
2679
|
}
|
|
2676
2680
|
}
|
|
2677
2681
|
const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
|
|
2678
|
-
await
|
|
2682
|
+
await fs10.promises.writeFile(resolvedPath, mergedCode, "utf-8");
|
|
2679
2683
|
const oldLines = initialCode.split("\n");
|
|
2680
2684
|
const newLines = mergedCode.split("\n");
|
|
2681
2685
|
const diff = this.generateDiff(oldLines, newLines, targetFile);
|
|
@@ -2849,16 +2853,16 @@ ${codeEdit}`
|
|
|
2849
2853
|
try {
|
|
2850
2854
|
const resolvedPath = path8.resolve(filePath);
|
|
2851
2855
|
if (await pathExists2(resolvedPath)) {
|
|
2852
|
-
const stats = await
|
|
2856
|
+
const stats = await fs10.promises.stat(resolvedPath);
|
|
2853
2857
|
if (stats.isDirectory()) {
|
|
2854
|
-
const files = await
|
|
2858
|
+
const files = await fs10.promises.readdir(resolvedPath);
|
|
2855
2859
|
return {
|
|
2856
2860
|
success: true,
|
|
2857
2861
|
output: `Directory contents of ${filePath}:
|
|
2858
2862
|
${files.join("\n")}`
|
|
2859
2863
|
};
|
|
2860
2864
|
}
|
|
2861
|
-
const content = await
|
|
2865
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
2862
2866
|
const lines = content.split("\n");
|
|
2863
2867
|
if (viewRange) {
|
|
2864
2868
|
const [start, end] = viewRange;
|
|
@@ -3286,7 +3290,7 @@ var init_search = __esm({
|
|
|
3286
3290
|
const walkDir = async (dir, depth = 0) => {
|
|
3287
3291
|
if (depth > 10 || files.length >= maxResults) return;
|
|
3288
3292
|
try {
|
|
3289
|
-
const entries = await
|
|
3293
|
+
const entries = await fs10.promises.readdir(dir, { withFileTypes: true });
|
|
3290
3294
|
for (const entry of entries) {
|
|
3291
3295
|
if (files.length >= maxResults) break;
|
|
3292
3296
|
const fullPath = path8.join(dir, entry.name);
|
|
@@ -3926,7 +3930,7 @@ var init_advanced_search = __esm({
|
|
|
3926
3930
|
init_confirmation_service();
|
|
3927
3931
|
pathExists4 = async (filePath) => {
|
|
3928
3932
|
try {
|
|
3929
|
-
await
|
|
3933
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
3930
3934
|
return true;
|
|
3931
3935
|
} catch {
|
|
3932
3936
|
return false;
|
|
@@ -3948,7 +3952,7 @@ var init_advanced_search = __esm({
|
|
|
3948
3952
|
error: `Path not found: ${searchPath}`
|
|
3949
3953
|
};
|
|
3950
3954
|
}
|
|
3951
|
-
const stats = await
|
|
3955
|
+
const stats = await fs10.promises.stat(resolvedPath);
|
|
3952
3956
|
const filesToSearch = [];
|
|
3953
3957
|
if (stats.isFile()) {
|
|
3954
3958
|
filesToSearch.push(resolvedPath);
|
|
@@ -3991,7 +3995,7 @@ var init_advanced_search = __esm({
|
|
|
3991
3995
|
error: `Path not found: ${searchPath}`
|
|
3992
3996
|
};
|
|
3993
3997
|
}
|
|
3994
|
-
const stats = await
|
|
3998
|
+
const stats = await fs10.promises.stat(resolvedPath);
|
|
3995
3999
|
const filesToProcess = [];
|
|
3996
4000
|
if (stats.isFile()) {
|
|
3997
4001
|
filesToProcess.push(resolvedPath);
|
|
@@ -4036,7 +4040,7 @@ var init_advanced_search = __esm({
|
|
|
4036
4040
|
}
|
|
4037
4041
|
for (const result of results) {
|
|
4038
4042
|
if (result.success && result.preview) {
|
|
4039
|
-
await
|
|
4043
|
+
await fs10.promises.writeFile(result.filePath, result.preview, "utf-8");
|
|
4040
4044
|
}
|
|
4041
4045
|
}
|
|
4042
4046
|
}
|
|
@@ -4098,7 +4102,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
4098
4102
|
* Search in a single file
|
|
4099
4103
|
*/
|
|
4100
4104
|
async searchInFile(filePath, options) {
|
|
4101
|
-
const content = await
|
|
4105
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
4102
4106
|
const lines = content.split("\n");
|
|
4103
4107
|
const matches = [];
|
|
4104
4108
|
let pattern;
|
|
@@ -4149,7 +4153,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
4149
4153
|
*/
|
|
4150
4154
|
async replaceInFile(filePath, options) {
|
|
4151
4155
|
try {
|
|
4152
|
-
const content = await
|
|
4156
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
4153
4157
|
let pattern;
|
|
4154
4158
|
try {
|
|
4155
4159
|
if (options.isRegex) {
|
|
@@ -4200,7 +4204,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
|
|
|
4200
4204
|
async getFilesRecursively(dirPath, options) {
|
|
4201
4205
|
const files = [];
|
|
4202
4206
|
const walk = async (currentPath) => {
|
|
4203
|
-
const entries = await
|
|
4207
|
+
const entries = await fs10.promises.readdir(currentPath, { withFileTypes: true });
|
|
4204
4208
|
for (const entry of entries) {
|
|
4205
4209
|
const fullPath = path8.join(currentPath, entry.name);
|
|
4206
4210
|
if (entry.isDirectory()) {
|
|
@@ -4958,7 +4962,7 @@ var init_code_aware_editor = __esm({
|
|
|
4958
4962
|
init_confirmation_service();
|
|
4959
4963
|
pathExists6 = async (filePath) => {
|
|
4960
4964
|
try {
|
|
4961
|
-
await
|
|
4965
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
4962
4966
|
return true;
|
|
4963
4967
|
} catch {
|
|
4964
4968
|
return false;
|
|
@@ -4980,7 +4984,7 @@ var init_code_aware_editor = __esm({
|
|
|
4980
4984
|
error: `File not found: ${filePath}`
|
|
4981
4985
|
};
|
|
4982
4986
|
}
|
|
4983
|
-
const content = await
|
|
4987
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
4984
4988
|
const language = this.detectLanguage(filePath);
|
|
4985
4989
|
const context = await this.parseCodeContext(content, language);
|
|
4986
4990
|
const output = this.formatCodeAnalysis(context, filePath);
|
|
@@ -5007,7 +5011,7 @@ var init_code_aware_editor = __esm({
|
|
|
5007
5011
|
error: `File not found: ${filePath}`
|
|
5008
5012
|
};
|
|
5009
5013
|
}
|
|
5010
|
-
const content = await
|
|
5014
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
5011
5015
|
const language = this.detectLanguage(filePath);
|
|
5012
5016
|
const context = await this.parseCodeContext(content, language);
|
|
5013
5017
|
const result = await this.performRefactoring(content, context, operation, language);
|
|
@@ -5033,7 +5037,7 @@ var init_code_aware_editor = __esm({
|
|
|
5033
5037
|
};
|
|
5034
5038
|
}
|
|
5035
5039
|
}
|
|
5036
|
-
await
|
|
5040
|
+
await fs10.promises.writeFile(resolvedPath, result.newContent, "utf-8");
|
|
5037
5041
|
return {
|
|
5038
5042
|
success: true,
|
|
5039
5043
|
output: result.output
|
|
@@ -5057,7 +5061,7 @@ var init_code_aware_editor = __esm({
|
|
|
5057
5061
|
error: `File not found: ${filePath}`
|
|
5058
5062
|
};
|
|
5059
5063
|
}
|
|
5060
|
-
const content = await
|
|
5064
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
5061
5065
|
const language = this.detectLanguage(filePath);
|
|
5062
5066
|
const context = await this.parseCodeContext(content, language);
|
|
5063
5067
|
const insertionPoint = this.findInsertionPoint(content, context, location, target);
|
|
@@ -5087,7 +5091,7 @@ var init_code_aware_editor = __esm({
|
|
|
5087
5091
|
};
|
|
5088
5092
|
}
|
|
5089
5093
|
}
|
|
5090
|
-
await
|
|
5094
|
+
await fs10.promises.writeFile(resolvedPath, newContent, "utf-8");
|
|
5091
5095
|
return {
|
|
5092
5096
|
success: true,
|
|
5093
5097
|
output: `Code inserted at line ${insertionPoint.line + 1} in ${filePath}`
|
|
@@ -5111,7 +5115,7 @@ var init_code_aware_editor = __esm({
|
|
|
5111
5115
|
error: `File not found: ${filePath}`
|
|
5112
5116
|
};
|
|
5113
5117
|
}
|
|
5114
|
-
const content = await
|
|
5118
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
5115
5119
|
const language = this.detectLanguage(filePath);
|
|
5116
5120
|
const formattedContent = await this.formatCodeContent(content, language, options);
|
|
5117
5121
|
if (formattedContent === content) {
|
|
@@ -5139,7 +5143,7 @@ var init_code_aware_editor = __esm({
|
|
|
5139
5143
|
};
|
|
5140
5144
|
}
|
|
5141
5145
|
}
|
|
5142
|
-
await
|
|
5146
|
+
await fs10.promises.writeFile(resolvedPath, formattedContent, "utf-8");
|
|
5143
5147
|
return {
|
|
5144
5148
|
success: true,
|
|
5145
5149
|
output: `Code formatted in ${filePath}`
|
|
@@ -5163,7 +5167,7 @@ var init_code_aware_editor = __esm({
|
|
|
5163
5167
|
error: `File not found: ${filePath}`
|
|
5164
5168
|
};
|
|
5165
5169
|
}
|
|
5166
|
-
const content = await
|
|
5170
|
+
const content = await fs10.promises.readFile(resolvedPath, "utf-8");
|
|
5167
5171
|
const language = this.detectLanguage(filePath);
|
|
5168
5172
|
const context = await this.parseCodeContext(content, language);
|
|
5169
5173
|
const missingImports = symbols.filter(
|
|
@@ -5204,7 +5208,7 @@ ${importsToAdd.join("\n")}`;
|
|
|
5204
5208
|
};
|
|
5205
5209
|
}
|
|
5206
5210
|
}
|
|
5207
|
-
await
|
|
5211
|
+
await fs10.promises.writeFile(resolvedPath, newContent, "utf-8");
|
|
5208
5212
|
return {
|
|
5209
5213
|
success: true,
|
|
5210
5214
|
output: `Added ${missingImports.length} missing imports to ${filePath}`
|
|
@@ -6563,7 +6567,7 @@ var init_ast_parser = __esm({
|
|
|
6563
6567
|
}
|
|
6564
6568
|
pathExists8 = async (filePath) => {
|
|
6565
6569
|
try {
|
|
6566
|
-
await
|
|
6570
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
6567
6571
|
return true;
|
|
6568
6572
|
} catch {
|
|
6569
6573
|
return false;
|
|
@@ -6639,7 +6643,7 @@ var init_ast_parser = __esm({
|
|
|
6639
6643
|
if (!await pathExists8(filePath)) {
|
|
6640
6644
|
throw new Error(`File not found: ${filePath}`);
|
|
6641
6645
|
}
|
|
6642
|
-
const content = await
|
|
6646
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
6643
6647
|
const language = this.detectLanguage(filePath);
|
|
6644
6648
|
let result;
|
|
6645
6649
|
if (language === "typescript" || language === "tsx") {
|
|
@@ -7333,7 +7337,7 @@ var init_symbol_search = __esm({
|
|
|
7333
7337
|
async findSymbolUsages(symbolRef) {
|
|
7334
7338
|
const usages = [];
|
|
7335
7339
|
try {
|
|
7336
|
-
const content = await
|
|
7340
|
+
const content = await fs10.promises.readFile(symbolRef.filePath, "utf-8");
|
|
7337
7341
|
const lines = content.split("\n");
|
|
7338
7342
|
for (let i = 0; i < lines.length; i++) {
|
|
7339
7343
|
const line = lines[i];
|
|
@@ -7513,7 +7517,7 @@ var init_dependency_analyzer = __esm({
|
|
|
7513
7517
|
init_ast_parser();
|
|
7514
7518
|
pathExists9 = async (filePath) => {
|
|
7515
7519
|
try {
|
|
7516
|
-
await
|
|
7520
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
7517
7521
|
return true;
|
|
7518
7522
|
} catch {
|
|
7519
7523
|
return false;
|
|
@@ -7991,7 +7995,7 @@ var init_code_context = __esm({
|
|
|
7991
7995
|
init_dependency_analyzer();
|
|
7992
7996
|
pathExists10 = async (filePath) => {
|
|
7993
7997
|
try {
|
|
7994
|
-
await
|
|
7998
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
7995
7999
|
return true;
|
|
7996
8000
|
} catch {
|
|
7997
8001
|
return false;
|
|
@@ -8136,7 +8140,7 @@ var init_code_context = __esm({
|
|
|
8136
8140
|
async analyzeUsagePatterns(symbol, filePath) {
|
|
8137
8141
|
const patterns = [];
|
|
8138
8142
|
try {
|
|
8139
|
-
const content = await
|
|
8143
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8140
8144
|
const lines = content.split("\n");
|
|
8141
8145
|
let callCount = 0;
|
|
8142
8146
|
let assignmentCount = 0;
|
|
@@ -8289,7 +8293,7 @@ var init_code_context = __esm({
|
|
|
8289
8293
|
}
|
|
8290
8294
|
async analyzeSemanticContext(filePath, symbols, dependencies) {
|
|
8291
8295
|
const fileName = path8__default.basename(filePath);
|
|
8292
|
-
const content = await
|
|
8296
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8293
8297
|
const purpose = this.inferPurpose(fileName, symbols, content);
|
|
8294
8298
|
const domain = this.extractDomain(filePath, symbols, dependencies);
|
|
8295
8299
|
const patterns = this.detectDesignPatterns(content, symbols);
|
|
@@ -8418,7 +8422,7 @@ var init_code_context = __esm({
|
|
|
8418
8422
|
};
|
|
8419
8423
|
}
|
|
8420
8424
|
async calculateCodeMetrics(filePath, symbols) {
|
|
8421
|
-
const content = await
|
|
8425
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8422
8426
|
const lines = content.split("\n");
|
|
8423
8427
|
const codeLines = lines.filter((line) => line.trim().length > 0 && !line.trim().startsWith("//"));
|
|
8424
8428
|
const linesOfCode = codeLines.length;
|
|
@@ -8527,7 +8531,7 @@ var init_refactoring_assistant = __esm({
|
|
|
8527
8531
|
init_operation_history();
|
|
8528
8532
|
pathExists11 = async (filePath) => {
|
|
8529
8533
|
try {
|
|
8530
|
-
await
|
|
8534
|
+
await fs10.promises.access(filePath, fs10.constants.F_OK);
|
|
8531
8535
|
return true;
|
|
8532
8536
|
} catch {
|
|
8533
8537
|
return false;
|
|
@@ -8647,7 +8651,7 @@ var init_refactoring_assistant = __esm({
|
|
|
8647
8651
|
if (!await pathExists11(filePath)) {
|
|
8648
8652
|
throw new Error(`File not found: ${filePath}`);
|
|
8649
8653
|
}
|
|
8650
|
-
const content = await
|
|
8654
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8651
8655
|
const lines = content.split("\n");
|
|
8652
8656
|
if (startLine < 0 || endLine >= lines.length || startLine > endLine) {
|
|
8653
8657
|
throw new Error("Invalid line range");
|
|
@@ -8722,7 +8726,7 @@ var init_refactoring_assistant = __esm({
|
|
|
8722
8726
|
if (!filePath || !variableName) {
|
|
8723
8727
|
throw new Error("File path and variable name are required");
|
|
8724
8728
|
}
|
|
8725
|
-
const content = await
|
|
8729
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8726
8730
|
const lines = content.split("\n");
|
|
8727
8731
|
const startLineContent = lines[startLine];
|
|
8728
8732
|
const endLineContent = lines[endLine];
|
|
@@ -8797,7 +8801,7 @@ var init_refactoring_assistant = __esm({
|
|
|
8797
8801
|
if (!functionSymbol) {
|
|
8798
8802
|
throw new Error(`Function '${symbolName}' not found`);
|
|
8799
8803
|
}
|
|
8800
|
-
const content = await
|
|
8804
|
+
const content = await fs10.promises.readFile(filePath, "utf-8");
|
|
8801
8805
|
const lines = content.split("\n");
|
|
8802
8806
|
const functionLines = lines.slice(functionSymbol.startPosition.row, functionSymbol.endPosition.row + 1);
|
|
8803
8807
|
const functionBody = this.extractFunctionBody(functionLines.join("\n"));
|
|
@@ -8907,7 +8911,7 @@ var init_refactoring_assistant = __esm({
|
|
|
8907
8911
|
}
|
|
8908
8912
|
async generateRenameChanges(ref, oldName, newName, includeComments, includeStrings) {
|
|
8909
8913
|
const changes = [];
|
|
8910
|
-
const content = await
|
|
8914
|
+
const content = await fs10.promises.readFile(ref.filePath, "utf-8");
|
|
8911
8915
|
const lines = content.split("\n");
|
|
8912
8916
|
for (let i = 0; i < lines.length; i++) {
|
|
8913
8917
|
const line = lines[i];
|
|
@@ -9282,7 +9286,7 @@ var init_codebase_explorer = __esm({
|
|
|
9282
9286
|
return files;
|
|
9283
9287
|
}
|
|
9284
9288
|
try {
|
|
9285
|
-
const entries = await
|
|
9289
|
+
const entries = await fs7__default.readdir(dirPath, { withFileTypes: true });
|
|
9286
9290
|
for (const entry of entries) {
|
|
9287
9291
|
const fullPath = path8__default.join(dirPath, entry.name);
|
|
9288
9292
|
const relativePath = path8__default.relative(options.rootPath, fullPath);
|
|
@@ -9305,7 +9309,7 @@ var init_codebase_explorer = __esm({
|
|
|
9305
9309
|
files.push(...subFiles);
|
|
9306
9310
|
} else {
|
|
9307
9311
|
try {
|
|
9308
|
-
const stats = await
|
|
9312
|
+
const stats = await fs7__default.stat(fullPath);
|
|
9309
9313
|
fileInfo.size = stats.size;
|
|
9310
9314
|
fileInfo.lastModified = stats.mtimeMs;
|
|
9311
9315
|
if (fileInfo.size > this.settings.maxFileSize) {
|
|
@@ -9578,7 +9582,7 @@ var init_codebase_explorer = __esm({
|
|
|
9578
9582
|
async detectProjectType(rootPath, files) {
|
|
9579
9583
|
const packageJsonPath = path8__default.join(rootPath, "package.json");
|
|
9580
9584
|
try {
|
|
9581
|
-
const packageJson = await
|
|
9585
|
+
const packageJson = await fs7__default.readFile(packageJsonPath, "utf-8");
|
|
9582
9586
|
const pkg = JSON.parse(packageJson);
|
|
9583
9587
|
if (pkg.dependencies?.react || pkg.devDependencies?.react) return "react";
|
|
9584
9588
|
if (pkg.dependencies?.vue || pkg.devDependencies?.vue) return "vue";
|
|
@@ -9774,7 +9778,7 @@ var init_codebase_explorer = __esm({
|
|
|
9774
9778
|
*/
|
|
9775
9779
|
async calculateFileChecksum(filePath) {
|
|
9776
9780
|
try {
|
|
9777
|
-
const content = await
|
|
9781
|
+
const content = await fs7__default.readFile(filePath);
|
|
9778
9782
|
return crypto2.createHash("sha256").update(content).digest("hex");
|
|
9779
9783
|
} catch {
|
|
9780
9784
|
return "";
|
|
@@ -9958,7 +9962,7 @@ var init_incremental_indexer = __esm({
|
|
|
9958
9962
|
async scanDirectory(dirPath, options, files, depth = 0) {
|
|
9959
9963
|
if (depth > 10) return;
|
|
9960
9964
|
try {
|
|
9961
|
-
const entries = await
|
|
9965
|
+
const entries = await fs7__default.readdir(dirPath, { withFileTypes: true });
|
|
9962
9966
|
for (const entry of entries) {
|
|
9963
9967
|
const fullPath = path8__default.join(dirPath, entry.name);
|
|
9964
9968
|
if (!this.shouldTrackFile(fullPath, options)) {
|
|
@@ -9968,7 +9972,7 @@ var init_incremental_indexer = __esm({
|
|
|
9968
9972
|
await this.scanDirectory(fullPath, options, files, depth + 1);
|
|
9969
9973
|
} else {
|
|
9970
9974
|
try {
|
|
9971
|
-
const stats = await
|
|
9975
|
+
const stats = await fs7__default.stat(fullPath);
|
|
9972
9976
|
if (options.maxFileSize && stats.size > options.maxFileSize) {
|
|
9973
9977
|
continue;
|
|
9974
9978
|
}
|
|
@@ -10008,7 +10012,7 @@ var init_incremental_indexer = __esm({
|
|
|
10008
10012
|
}
|
|
10009
10013
|
async calculateChecksum(filePath) {
|
|
10010
10014
|
try {
|
|
10011
|
-
const content = await
|
|
10015
|
+
const content = await fs7__default.readFile(filePath);
|
|
10012
10016
|
return crypto2.createHash("sha256").update(content).digest("hex");
|
|
10013
10017
|
} catch {
|
|
10014
10018
|
return "";
|
|
@@ -11663,7 +11667,7 @@ var init_autonomous_executor = __esm({
|
|
|
11663
11667
|
let originalContent = "";
|
|
11664
11668
|
try {
|
|
11665
11669
|
if (operation !== "create") {
|
|
11666
|
-
originalContent = await
|
|
11670
|
+
originalContent = await fs7.readFile(filePath, "utf-8");
|
|
11667
11671
|
}
|
|
11668
11672
|
} catch (error) {
|
|
11669
11673
|
if (operation === "update") {
|
|
@@ -11719,11 +11723,11 @@ var init_autonomous_executor = __esm({
|
|
|
11719
11723
|
*/
|
|
11720
11724
|
async applyFileTransaction(step) {
|
|
11721
11725
|
const dir = path8.dirname(step.filePath);
|
|
11722
|
-
await
|
|
11726
|
+
await fs7.mkdir(dir, { recursive: true });
|
|
11723
11727
|
if (step.operation === "delete") {
|
|
11724
|
-
await
|
|
11728
|
+
await fs7.unlink(step.filePath);
|
|
11725
11729
|
} else {
|
|
11726
|
-
await
|
|
11730
|
+
await fs7.writeFile(step.filePath, step.newContent, "utf-8");
|
|
11727
11731
|
}
|
|
11728
11732
|
}
|
|
11729
11733
|
/**
|
|
@@ -11732,15 +11736,15 @@ var init_autonomous_executor = __esm({
|
|
|
11732
11736
|
async rollbackFileTransaction(step) {
|
|
11733
11737
|
if (step.operation === "create") {
|
|
11734
11738
|
try {
|
|
11735
|
-
await
|
|
11739
|
+
await fs7.unlink(step.filePath);
|
|
11736
11740
|
} catch {
|
|
11737
11741
|
}
|
|
11738
11742
|
} else if (step.operation === "update") {
|
|
11739
|
-
await
|
|
11743
|
+
await fs7.writeFile(step.filePath, step.originalContent, "utf-8");
|
|
11740
11744
|
} else if (step.operation === "delete") {
|
|
11741
11745
|
const dir = path8.dirname(step.filePath);
|
|
11742
|
-
await
|
|
11743
|
-
await
|
|
11746
|
+
await fs7.mkdir(dir, { recursive: true });
|
|
11747
|
+
await fs7.writeFile(step.filePath, step.originalContent, "utf-8");
|
|
11744
11748
|
}
|
|
11745
11749
|
}
|
|
11746
11750
|
/**
|
|
@@ -12249,7 +12253,7 @@ var init_autonomous_executor = __esm({
|
|
|
12249
12253
|
await this.transactionManager.commitTransaction(transactionId);
|
|
12250
12254
|
for (const file of filesModified) {
|
|
12251
12255
|
try {
|
|
12252
|
-
const content = await
|
|
12256
|
+
const content = await fs7.readFile(file, "utf-8");
|
|
12253
12257
|
context.fileSnapshots.set(file, content);
|
|
12254
12258
|
} catch {
|
|
12255
12259
|
}
|
|
@@ -12358,13 +12362,13 @@ var init_autonomous_executor = __esm({
|
|
|
12358
12362
|
async saveTaskState(task) {
|
|
12359
12363
|
try {
|
|
12360
12364
|
const stateFile = path8.join(this.config.rootPath, ".autonomous", `task_${task.id}.json`);
|
|
12361
|
-
await
|
|
12365
|
+
await fs7.mkdir(path8.dirname(stateFile), { recursive: true });
|
|
12362
12366
|
const state = {
|
|
12363
12367
|
task,
|
|
12364
12368
|
timestamp: Date.now(),
|
|
12365
12369
|
version: "1.0"
|
|
12366
12370
|
};
|
|
12367
|
-
await
|
|
12371
|
+
await fs7.writeFile(stateFile, JSON.stringify(state, null, 2), "utf-8");
|
|
12368
12372
|
} catch (error) {
|
|
12369
12373
|
console.warn("Failed to save task state:", error);
|
|
12370
12374
|
}
|
|
@@ -12375,7 +12379,7 @@ var init_autonomous_executor = __esm({
|
|
|
12375
12379
|
async loadTaskState(taskId) {
|
|
12376
12380
|
try {
|
|
12377
12381
|
const stateFile = path8.join(this.config.rootPath, ".autonomous", `task_${taskId}.json`);
|
|
12378
|
-
const content = await
|
|
12382
|
+
const content = await fs7.readFile(stateFile, "utf-8");
|
|
12379
12383
|
const state = JSON.parse(content);
|
|
12380
12384
|
return state.task;
|
|
12381
12385
|
} catch {
|
|
@@ -12409,7 +12413,7 @@ var init_autonomous_executor = __esm({
|
|
|
12409
12413
|
console.log(`\u{1F916} Generating changes for: "${goal}" in ${filePath}`);
|
|
12410
12414
|
let currentContent = "";
|
|
12411
12415
|
try {
|
|
12412
|
-
currentContent = await
|
|
12416
|
+
currentContent = await fs7.readFile(filePath, "utf-8");
|
|
12413
12417
|
} catch {
|
|
12414
12418
|
currentContent = "";
|
|
12415
12419
|
}
|
|
@@ -12907,12 +12911,12 @@ var init_agent_framework = __esm({
|
|
|
12907
12911
|
*/
|
|
12908
12912
|
async loadPersistedMemory() {
|
|
12909
12913
|
try {
|
|
12910
|
-
await
|
|
12911
|
-
const files = await
|
|
12914
|
+
await fs7.mkdir(this.memoryPath, { recursive: true });
|
|
12915
|
+
const files = await fs7.readdir(this.memoryPath);
|
|
12912
12916
|
for (const file of files) {
|
|
12913
12917
|
if (file.endsWith(".json")) {
|
|
12914
12918
|
try {
|
|
12915
|
-
const content = await
|
|
12919
|
+
const content = await fs7.readFile(path8.join(this.memoryPath, file), "utf-8");
|
|
12916
12920
|
const sessionData = JSON.parse(content);
|
|
12917
12921
|
const session = {
|
|
12918
12922
|
...sessionData,
|
|
@@ -12953,7 +12957,7 @@ var init_agent_framework = __esm({
|
|
|
12953
12957
|
},
|
|
12954
12958
|
learnedPatterns: Array.from(session.learnedPatterns.entries())
|
|
12955
12959
|
};
|
|
12956
|
-
await
|
|
12960
|
+
await fs7.writeFile(filePath, JSON.stringify(serializable, null, 2), "utf-8");
|
|
12957
12961
|
} catch (error) {
|
|
12958
12962
|
console.warn(`Failed to persist session ${session.id}:`, error);
|
|
12959
12963
|
}
|
|
@@ -12968,7 +12972,7 @@ var init_agent_framework = __esm({
|
|
|
12968
12972
|
*/
|
|
12969
12973
|
async loadPlugins() {
|
|
12970
12974
|
try {
|
|
12971
|
-
await
|
|
12975
|
+
await fs7.mkdir(this.pluginPath, { recursive: true });
|
|
12972
12976
|
} catch (error) {
|
|
12973
12977
|
console.warn("Failed to load plugins:", error);
|
|
12974
12978
|
}
|
|
@@ -13393,6 +13397,7 @@ var init_tools2 = __esm({
|
|
|
13393
13397
|
"src/tools/index.ts"() {
|
|
13394
13398
|
init_bash();
|
|
13395
13399
|
init_text_editor();
|
|
13400
|
+
init_smart_edit();
|
|
13396
13401
|
init_morph_editor();
|
|
13397
13402
|
init_todo_tool();
|
|
13398
13403
|
init_confirmation_tool();
|
|
@@ -13472,10 +13477,10 @@ var init_token_counter = __esm({
|
|
|
13472
13477
|
function loadCustomInstructions(workingDirectory = process.cwd()) {
|
|
13473
13478
|
try {
|
|
13474
13479
|
const instructionsPath = path8.join(workingDirectory, ".grok", "GROK.md");
|
|
13475
|
-
if (!
|
|
13480
|
+
if (!fs10.existsSync(instructionsPath)) {
|
|
13476
13481
|
return null;
|
|
13477
13482
|
}
|
|
13478
|
-
const customInstructions =
|
|
13483
|
+
const customInstructions = fs10.readFileSync(instructionsPath, "utf-8");
|
|
13479
13484
|
return customInstructions.trim();
|
|
13480
13485
|
} catch (error) {
|
|
13481
13486
|
console.warn("Failed to load custom instructions:", error);
|
|
@@ -13591,10 +13596,10 @@ var init_execution_orchestrator = __esm({
|
|
|
13591
13596
|
const state = /* @__PURE__ */ new Map();
|
|
13592
13597
|
try {
|
|
13593
13598
|
const walkDir = (dir) => {
|
|
13594
|
-
const files =
|
|
13599
|
+
const files = fs10.readdirSync(dir);
|
|
13595
13600
|
for (const file of files) {
|
|
13596
13601
|
const filePath = path8.join(dir, file);
|
|
13597
|
-
const stat =
|
|
13602
|
+
const stat = fs10.statSync(filePath);
|
|
13598
13603
|
if (stat.isDirectory() && !file.startsWith(".") && file !== "node_modules") {
|
|
13599
13604
|
walkDir(filePath);
|
|
13600
13605
|
} else if (stat.isFile()) {
|
|
@@ -13642,7 +13647,7 @@ var init_execution_orchestrator = __esm({
|
|
|
13642
13647
|
console.log(`[grok-one-shot] #${step.id} Changes detected:`);
|
|
13643
13648
|
for (const change of step.changes) {
|
|
13644
13649
|
console.log(` ${change.changeType.toUpperCase()}: ${change.filePath}`);
|
|
13645
|
-
if (change.changeType === "modified" &&
|
|
13650
|
+
if (change.changeType === "modified" && fs10.existsSync(change.filePath)) {
|
|
13646
13651
|
try {
|
|
13647
13652
|
if (this.isGitRepository()) {
|
|
13648
13653
|
const diff = execSync(`git diff --no-index /dev/null ${change.filePath} 2>/dev/null || git diff ${change.filePath}`, {
|
|
@@ -13668,8 +13673,8 @@ var init_execution_orchestrator = __esm({
|
|
|
13668
13673
|
}
|
|
13669
13674
|
try {
|
|
13670
13675
|
const patchesDir = path8.join(__require("os").homedir(), ".grok", "patches");
|
|
13671
|
-
if (!
|
|
13672
|
-
|
|
13676
|
+
if (!fs10.existsSync(patchesDir)) {
|
|
13677
|
+
fs10.mkdirSync(patchesDir, { recursive: true });
|
|
13673
13678
|
}
|
|
13674
13679
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
13675
13680
|
const patchFile = path8.join(patchesDir, `step-${step.id}-${timestamp}.patch`);
|
|
@@ -13679,7 +13684,7 @@ var init_execution_orchestrator = __esm({
|
|
|
13679
13684
|
|
|
13680
13685
|
`;
|
|
13681
13686
|
for (const change of step.changes) {
|
|
13682
|
-
if (change.changeType === "modified" &&
|
|
13687
|
+
if (change.changeType === "modified" && fs10.existsSync(change.filePath)) {
|
|
13683
13688
|
try {
|
|
13684
13689
|
const diff = execSync(`git diff ${change.filePath}`, {
|
|
13685
13690
|
encoding: "utf-8",
|
|
@@ -13693,7 +13698,7 @@ ${diff}
|
|
|
13693
13698
|
}
|
|
13694
13699
|
}
|
|
13695
13700
|
}
|
|
13696
|
-
|
|
13701
|
+
fs10.writeFileSync(patchFile, patchContent);
|
|
13697
13702
|
console.log(`[grok-one-shot] #${step.id} Patch saved: ${patchFile}`);
|
|
13698
13703
|
return patchFile;
|
|
13699
13704
|
} catch (error) {
|
|
@@ -13709,10 +13714,10 @@ ${diff}
|
|
|
13709
13714
|
return;
|
|
13710
13715
|
}
|
|
13711
13716
|
for (const change of step.changes) {
|
|
13712
|
-
if ((change.changeType === "modified" || change.changeType === "created") &&
|
|
13717
|
+
if ((change.changeType === "modified" || change.changeType === "created") && fs10.existsSync(change.filePath)) {
|
|
13713
13718
|
try {
|
|
13714
13719
|
const backupPath = `${change.filePath}.bak`;
|
|
13715
|
-
|
|
13720
|
+
fs10.copyFileSync(change.filePath, backupPath);
|
|
13716
13721
|
change.backupPath = backupPath;
|
|
13717
13722
|
console.log(`[grok-one-shot] #${step.id} Backup created: ${backupPath}`);
|
|
13718
13723
|
} catch (_error) {
|
|
@@ -13804,10 +13809,10 @@ Auto-generated by grok-one-shot execution orchestrator`;
|
|
|
13804
13809
|
try {
|
|
13805
13810
|
const testFiles = [];
|
|
13806
13811
|
const walkDir = (dir) => {
|
|
13807
|
-
const files =
|
|
13812
|
+
const files = fs10.readdirSync(dir);
|
|
13808
13813
|
for (const file of files) {
|
|
13809
13814
|
const filePath = path8.join(dir, file);
|
|
13810
|
-
const stat =
|
|
13815
|
+
const stat = fs10.statSync(filePath);
|
|
13811
13816
|
if (stat.isDirectory() && !file.startsWith(".") && file !== "node_modules") {
|
|
13812
13817
|
walkDir(filePath);
|
|
13813
13818
|
} else if (stat.isFile() && (file.includes("test") || file.includes("spec"))) {
|
|
@@ -13826,7 +13831,7 @@ Auto-generated by grok-one-shot execution orchestrator`;
|
|
|
13826
13831
|
*/
|
|
13827
13832
|
findBuildFiles() {
|
|
13828
13833
|
const buildFiles = ["package.json", "tsconfig.json", "webpack.config.js", "babel.config.js"];
|
|
13829
|
-
return buildFiles.filter((file) =>
|
|
13834
|
+
return buildFiles.filter((file) => fs10.existsSync(file));
|
|
13830
13835
|
}
|
|
13831
13836
|
/**
|
|
13832
13837
|
* Find source files
|
|
@@ -13835,10 +13840,10 @@ Auto-generated by grok-one-shot execution orchestrator`;
|
|
|
13835
13840
|
try {
|
|
13836
13841
|
const sourceFiles = [];
|
|
13837
13842
|
const walkDir = (dir) => {
|
|
13838
|
-
const files =
|
|
13843
|
+
const files = fs10.readdirSync(dir);
|
|
13839
13844
|
for (const file of files) {
|
|
13840
13845
|
const filePath = path8.join(dir, file);
|
|
13841
|
-
const stat =
|
|
13846
|
+
const stat = fs10.statSync(filePath);
|
|
13842
13847
|
if (stat.isDirectory() && !file.startsWith(".") && file !== "node_modules") {
|
|
13843
13848
|
walkDir(filePath);
|
|
13844
13849
|
} else if (stat.isFile() && (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".tsx") || file.endsWith(".jsx"))) {
|
|
@@ -18863,8 +18868,8 @@ var init_codebase_indexer = __esm({
|
|
|
18863
18868
|
};
|
|
18864
18869
|
}
|
|
18865
18870
|
async indexFile(filePath) {
|
|
18866
|
-
const stats = await
|
|
18867
|
-
const content = await
|
|
18871
|
+
const stats = await fs10__default.promises.stat(filePath);
|
|
18872
|
+
const content = await fs10__default.promises.readFile(filePath, "utf8");
|
|
18868
18873
|
const extension = path8__default.extname(filePath);
|
|
18869
18874
|
const language = this.detectLanguage(extension);
|
|
18870
18875
|
return {
|
|
@@ -18879,7 +18884,7 @@ var init_codebase_indexer = __esm({
|
|
|
18879
18884
|
};
|
|
18880
18885
|
}
|
|
18881
18886
|
async extractSymbols(filePath) {
|
|
18882
|
-
const content = await
|
|
18887
|
+
const content = await fs10__default.promises.readFile(filePath, "utf8");
|
|
18883
18888
|
const extension = path8__default.extname(filePath);
|
|
18884
18889
|
const symbols = [];
|
|
18885
18890
|
if (extension === ".ts" || extension === ".js" || extension === ".tsx" || extension === ".jsx") {
|
|
@@ -19029,7 +19034,7 @@ var init_codebase_indexer = __esm({
|
|
|
19029
19034
|
const dirInfo = dirMap.get(dir);
|
|
19030
19035
|
dirInfo.fileCount++;
|
|
19031
19036
|
try {
|
|
19032
|
-
const stats = await
|
|
19037
|
+
const stats = await fs10__default.promises.stat(file);
|
|
19033
19038
|
dirInfo.totalSize += stats.size;
|
|
19034
19039
|
} catch (error) {
|
|
19035
19040
|
}
|
|
@@ -19056,7 +19061,7 @@ var init_codebase_indexer = __esm({
|
|
|
19056
19061
|
const packageJson = configFiles.find((f) => path8__default.basename(f) === "package.json");
|
|
19057
19062
|
if (packageJson) {
|
|
19058
19063
|
try {
|
|
19059
|
-
const pkg = JSON.parse(
|
|
19064
|
+
const pkg = JSON.parse(fs10__default.readFileSync(packageJson, "utf8"));
|
|
19060
19065
|
if (pkg.main) entryPoints.push(path8__default.resolve(path8__default.dirname(packageJson), pkg.main));
|
|
19061
19066
|
if (pkg.types) entryPoints.push(path8__default.resolve(path8__default.dirname(packageJson), pkg.types));
|
|
19062
19067
|
} catch (error) {
|
|
@@ -19838,7 +19843,7 @@ var init_semantic_code_search = __esm({
|
|
|
19838
19843
|
}
|
|
19839
19844
|
async extractContext(symbol) {
|
|
19840
19845
|
try {
|
|
19841
|
-
const content = await
|
|
19846
|
+
const content = await fs7__default.readFile(symbol.filePath, "utf8");
|
|
19842
19847
|
const lines = content.split("\n");
|
|
19843
19848
|
const startLine = Math.max(0, symbol.line - 3);
|
|
19844
19849
|
const endLine = Math.min(lines.length, symbol.line + 3);
|
|
@@ -19879,7 +19884,7 @@ var init_semantic_code_search = __esm({
|
|
|
19879
19884
|
for (const [filePath, fileInfo] of index.files) {
|
|
19880
19885
|
if (fileInfo.language === "unknown" || fileInfo.size > 1e5) continue;
|
|
19881
19886
|
try {
|
|
19882
|
-
const content = await
|
|
19887
|
+
const content = await fs7__default.readFile(filePath, "utf8");
|
|
19883
19888
|
const lines = content.split("\n");
|
|
19884
19889
|
for (let i = 0; i < lines.length; i++) {
|
|
19885
19890
|
const line = lines[i].toLowerCase();
|
|
@@ -21622,12 +21627,12 @@ EOF`;
|
|
|
21622
21627
|
saveSessionLog() {
|
|
21623
21628
|
try {
|
|
21624
21629
|
const sessionDir = path8__default.join(__require("os").homedir(), ".grok");
|
|
21625
|
-
if (!
|
|
21626
|
-
|
|
21630
|
+
if (!fs10__default.existsSync(sessionDir)) {
|
|
21631
|
+
fs10__default.mkdirSync(sessionDir, { recursive: true });
|
|
21627
21632
|
}
|
|
21628
21633
|
const sessionFile = path8__default.join(sessionDir, "session.log");
|
|
21629
21634
|
const logLines = this.chatHistory.map((entry) => JSON.stringify(entry)).join("\n") + "\n";
|
|
21630
|
-
|
|
21635
|
+
fs10__default.writeFileSync(sessionFile, logLines);
|
|
21631
21636
|
} catch (error) {
|
|
21632
21637
|
console.warn("Failed to save session log:", error);
|
|
21633
21638
|
}
|
|
@@ -21876,8 +21881,8 @@ EOF`;
|
|
|
21876
21881
|
logEntry(entry) {
|
|
21877
21882
|
try {
|
|
21878
21883
|
const dir = path8__default.dirname(this.sessionLogPath);
|
|
21879
|
-
if (!
|
|
21880
|
-
|
|
21884
|
+
if (!fs10__default.existsSync(dir)) {
|
|
21885
|
+
fs10__default.mkdirSync(dir, { recursive: true });
|
|
21881
21886
|
}
|
|
21882
21887
|
const logLine = JSON.stringify({
|
|
21883
21888
|
type: entry.type,
|
|
@@ -21886,7 +21891,7 @@ EOF`;
|
|
|
21886
21891
|
toolCallId: entry.toolCall?.id,
|
|
21887
21892
|
toolCallsCount: entry.toolCalls?.length
|
|
21888
21893
|
}) + "\n";
|
|
21889
|
-
|
|
21894
|
+
fs10__default.appendFileSync(this.sessionLogPath, logLine);
|
|
21890
21895
|
} catch (error) {
|
|
21891
21896
|
console.warn("Failed to log session entry:", error);
|
|
21892
21897
|
}
|
|
@@ -24076,7 +24081,7 @@ var init_readonly_filesystem_overlay = __esm({
|
|
|
24076
24081
|
};
|
|
24077
24082
|
}
|
|
24078
24083
|
try {
|
|
24079
|
-
const actualContent = await
|
|
24084
|
+
const actualContent = await fs10__default.promises.readFile(resolvedPath, "utf-8");
|
|
24080
24085
|
return {
|
|
24081
24086
|
success: true,
|
|
24082
24087
|
output: this.formatFileContent(actualContent, args),
|
|
@@ -24133,7 +24138,7 @@ var init_readonly_filesystem_overlay = __esm({
|
|
|
24133
24138
|
const filePath = args.path || args.file_path || args.filename;
|
|
24134
24139
|
const content = args.content || "";
|
|
24135
24140
|
const resolvedPath = path8__default.resolve(this.config.baseDirectory, filePath);
|
|
24136
|
-
const fileExists =
|
|
24141
|
+
const fileExists = fs10__default.existsSync(resolvedPath);
|
|
24137
24142
|
const sizeImpact = content.length;
|
|
24138
24143
|
return {
|
|
24139
24144
|
type: "file_creation",
|
|
@@ -24162,7 +24167,7 @@ var init_readonly_filesystem_overlay = __esm({
|
|
|
24162
24167
|
const filePath = args.path || args.file_path || args.filename;
|
|
24163
24168
|
const resolvedPath = path8__default.resolve(this.config.baseDirectory, filePath);
|
|
24164
24169
|
try {
|
|
24165
|
-
const originalContent =
|
|
24170
|
+
const originalContent = fs10__default.existsSync(resolvedPath) ? await fs10__default.promises.readFile(resolvedPath, "utf-8") : "";
|
|
24166
24171
|
let newContent = originalContent;
|
|
24167
24172
|
if (args.old_string && args.new_string !== void 0) {
|
|
24168
24173
|
newContent = args.replace_all ? originalContent.split(args.old_string).join(args.new_string) : originalContent.replace(args.old_string, args.new_string);
|
|
@@ -24205,11 +24210,11 @@ var init_readonly_filesystem_overlay = __esm({
|
|
|
24205
24210
|
async simulateFileDeletion(args) {
|
|
24206
24211
|
const filePath = args.path || args.file_path || args.filename;
|
|
24207
24212
|
const resolvedPath = path8__default.resolve(this.config.baseDirectory, filePath);
|
|
24208
|
-
const fileExists =
|
|
24213
|
+
const fileExists = fs10__default.existsSync(resolvedPath);
|
|
24209
24214
|
let originalSize = 0;
|
|
24210
24215
|
if (fileExists) {
|
|
24211
24216
|
try {
|
|
24212
|
-
const stats = await
|
|
24217
|
+
const stats = await fs10__default.promises.stat(resolvedPath);
|
|
24213
24218
|
originalSize = stats.size;
|
|
24214
24219
|
} catch {
|
|
24215
24220
|
}
|
|
@@ -29275,7 +29280,7 @@ var init_package = __esm({
|
|
|
29275
29280
|
package_default = {
|
|
29276
29281
|
type: "module",
|
|
29277
29282
|
name: "@xagent/one-shot",
|
|
29278
|
-
version: "1.2.
|
|
29283
|
+
version: "1.2.14",
|
|
29279
29284
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
29280
29285
|
main: "dist/index.js",
|
|
29281
29286
|
module: "dist/index.js",
|
|
@@ -31851,14 +31856,14 @@ function useContextInfo(agent) {
|
|
|
31851
31856
|
async function getWorkspaceFileCount() {
|
|
31852
31857
|
try {
|
|
31853
31858
|
const cwd = process.cwd();
|
|
31854
|
-
const entries = await
|
|
31859
|
+
const entries = await fs10__default.promises.readdir(cwd, { withFileTypes: true });
|
|
31855
31860
|
let count = 0;
|
|
31856
31861
|
for (const entry of entries) {
|
|
31857
31862
|
if (entry.isFile() && !shouldIgnoreFile(entry.name)) {
|
|
31858
31863
|
count++;
|
|
31859
31864
|
} else if (entry.isDirectory() && !shouldIgnoreDirectory(entry.name)) {
|
|
31860
31865
|
try {
|
|
31861
|
-
const subEntries = await
|
|
31866
|
+
const subEntries = await fs10__default.promises.readdir(path8__default.join(cwd, entry.name), { withFileTypes: true });
|
|
31862
31867
|
count += subEntries.filter((sub) => sub.isFile() && !shouldIgnoreFile(sub.name)).length;
|
|
31863
31868
|
} catch {
|
|
31864
31869
|
}
|
|
@@ -31879,8 +31884,8 @@ function shouldIgnoreDirectory(dirname6) {
|
|
|
31879
31884
|
async function getIndexSize() {
|
|
31880
31885
|
try {
|
|
31881
31886
|
const indexPath = path8__default.join(process.cwd(), ".grok", "index.json");
|
|
31882
|
-
if (
|
|
31883
|
-
const stats = await
|
|
31887
|
+
if (fs10__default.existsSync(indexPath)) {
|
|
31888
|
+
const stats = await fs10__default.promises.stat(indexPath);
|
|
31884
31889
|
const mb = stats.size / (1024 * 1024);
|
|
31885
31890
|
return mb > 1 ? `${mb.toFixed(1)} MB` : `${(stats.size / 1024).toFixed(1)} KB`;
|
|
31886
31891
|
}
|
|
@@ -31891,8 +31896,8 @@ async function getIndexSize() {
|
|
|
31891
31896
|
async function getSessionFileCount() {
|
|
31892
31897
|
try {
|
|
31893
31898
|
const sessionPath = path8__default.join(os__default.homedir(), ".grok", "session.log");
|
|
31894
|
-
if (
|
|
31895
|
-
const content = await
|
|
31899
|
+
if (fs10__default.existsSync(sessionPath)) {
|
|
31900
|
+
const content = await fs10__default.promises.readFile(sessionPath, "utf8");
|
|
31896
31901
|
return content.split("\n").filter((line) => line.trim()).length;
|
|
31897
31902
|
}
|
|
31898
31903
|
} catch {
|
|
@@ -31902,8 +31907,8 @@ async function getSessionFileCount() {
|
|
|
31902
31907
|
async function getGitBranch() {
|
|
31903
31908
|
try {
|
|
31904
31909
|
const gitPath = path8__default.join(process.cwd(), ".git", "HEAD");
|
|
31905
|
-
if (
|
|
31906
|
-
const content = await
|
|
31910
|
+
if (fs10__default.existsSync(gitPath)) {
|
|
31911
|
+
const content = await fs10__default.promises.readFile(gitPath, "utf8");
|
|
31907
31912
|
const match = content.match(/ref: refs\/heads\/(.+)/);
|
|
31908
31913
|
return match ? match[1].trim() : "detached";
|
|
31909
31914
|
}
|
|
@@ -31914,8 +31919,8 @@ async function getGitBranch() {
|
|
|
31914
31919
|
async function getProjectName() {
|
|
31915
31920
|
try {
|
|
31916
31921
|
const packagePath = path8__default.join(process.cwd(), "package.json");
|
|
31917
|
-
if (
|
|
31918
|
-
const content = await
|
|
31922
|
+
if (fs10__default.existsSync(packagePath)) {
|
|
31923
|
+
const content = await fs10__default.promises.readFile(packagePath, "utf8");
|
|
31919
31924
|
const pkg = JSON.parse(content);
|
|
31920
31925
|
return pkg.name;
|
|
31921
31926
|
}
|
|
@@ -31958,20 +31963,20 @@ function useCLAUDEmd(setChatHistory) {
|
|
|
31958
31963
|
useEffect(() => {
|
|
31959
31964
|
const filesToLoad = [
|
|
31960
31965
|
{ path: "GROK.md", label: "GROK.md", fallback: "CLAUDE.md" },
|
|
31961
|
-
{ path: "docs-
|
|
31966
|
+
{ path: ".agent/docs-summary.md", label: "Compressed Documentation Summary" }
|
|
31962
31967
|
];
|
|
31963
31968
|
const loadedDocs = [];
|
|
31964
31969
|
let totalChars = 0;
|
|
31965
31970
|
for (const file of filesToLoad) {
|
|
31966
31971
|
let filePath = file.path;
|
|
31967
|
-
let exists =
|
|
31972
|
+
let exists = fs10__default.existsSync(filePath);
|
|
31968
31973
|
if (!exists && file.fallback) {
|
|
31969
31974
|
filePath = file.fallback;
|
|
31970
|
-
exists =
|
|
31975
|
+
exists = fs10__default.existsSync(filePath);
|
|
31971
31976
|
}
|
|
31972
31977
|
if (exists) {
|
|
31973
31978
|
try {
|
|
31974
|
-
const content =
|
|
31979
|
+
const content = fs10__default.readFileSync(filePath, "utf8");
|
|
31975
31980
|
const charCount = content.length;
|
|
31976
31981
|
totalChars += charCount;
|
|
31977
31982
|
loadedDocs.push(file.label);
|
|
@@ -32345,11 +32350,11 @@ function useSessionLogging(chatHistory) {
|
|
|
32345
32350
|
const sessionFile = path8__default.join(os__default.homedir(), ".grok", "session.log");
|
|
32346
32351
|
try {
|
|
32347
32352
|
const dir = path8__default.dirname(sessionFile);
|
|
32348
|
-
if (!
|
|
32349
|
-
|
|
32353
|
+
if (!fs10__default.existsSync(dir)) {
|
|
32354
|
+
fs10__default.mkdirSync(dir, { recursive: true });
|
|
32350
32355
|
}
|
|
32351
32356
|
const lines = newEntries.map((entry) => JSON.stringify(entry)).join("\n") + "\n";
|
|
32352
|
-
|
|
32357
|
+
fs10__default.appendFileSync(sessionFile, lines);
|
|
32353
32358
|
} catch {
|
|
32354
32359
|
}
|
|
32355
32360
|
}
|
|
@@ -32750,10 +32755,10 @@ ${data ? JSON.stringify(data, null, 2) : "No additional data"}
|
|
|
32750
32755
|
`;
|
|
32751
32756
|
const workingDir = process.cwd();
|
|
32752
32757
|
const logsDir = path8__default.join(workingDir, "logs");
|
|
32753
|
-
const sessionFiles =
|
|
32758
|
+
const sessionFiles = fs10__default.readdirSync(logsDir).filter((f) => f.startsWith("session-") && f.endsWith(".log"));
|
|
32754
32759
|
if (sessionFiles.length > 0) {
|
|
32755
32760
|
const sessionFile = path8__default.join(logsDir, sessionFiles[sessionFiles.length - 1]);
|
|
32756
|
-
|
|
32761
|
+
fs10__default.appendFileSync(sessionFile, logEntry);
|
|
32757
32762
|
} else {
|
|
32758
32763
|
console.log(`[ColoredDiffRenderer] ${message}`, data);
|
|
32759
32764
|
}
|
|
@@ -32827,10 +32832,10 @@ ${data ? JSON.stringify(data, null, 2) : "No additional data"}
|
|
|
32827
32832
|
`;
|
|
32828
32833
|
const workingDir = process.cwd();
|
|
32829
32834
|
const logsDir = path8__default.join(workingDir, "logs");
|
|
32830
|
-
const sessionFiles =
|
|
32835
|
+
const sessionFiles = fs10__default.readdirSync(logsDir).filter((f) => f.startsWith("session-") && f.endsWith(".log"));
|
|
32831
32836
|
if (sessionFiles.length > 0) {
|
|
32832
32837
|
const sessionFile = path8__default.join(logsDir, sessionFiles[sessionFiles.length - 1]);
|
|
32833
|
-
|
|
32838
|
+
fs10__default.appendFileSync(sessionFile, logEntry);
|
|
32834
32839
|
} else {
|
|
32835
32840
|
console.log(`[MarkdownRenderer] ${message}`, data);
|
|
32836
32841
|
}
|
|
@@ -34779,7 +34784,7 @@ var init_session_logger = __esm({
|
|
|
34779
34784
|
this.init();
|
|
34780
34785
|
}
|
|
34781
34786
|
init() {
|
|
34782
|
-
|
|
34787
|
+
fs10__default.mkdirSync(path8__default.dirname(this.logPath), { recursive: true });
|
|
34783
34788
|
const header = `
|
|
34784
34789
|
=================================================================
|
|
34785
34790
|
\u{1F9EA} GROK ONE-SHOT TESTING SESSION
|
|
@@ -34788,7 +34793,7 @@ Started: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
|
34788
34793
|
=================================================================
|
|
34789
34794
|
|
|
34790
34795
|
`;
|
|
34791
|
-
|
|
34796
|
+
fs10__default.writeFileSync(this.logPath, header);
|
|
34792
34797
|
}
|
|
34793
34798
|
logTerminalState(state) {
|
|
34794
34799
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -34804,7 +34809,7 @@ LAST ENTRY: ${state.chatHistory.length > 0 ? JSON.stringify(state.chatHistory[st
|
|
|
34804
34809
|
=====================================
|
|
34805
34810
|
|
|
34806
34811
|
`;
|
|
34807
|
-
|
|
34812
|
+
fs10__default.appendFileSync(this.logPath, entry);
|
|
34808
34813
|
}
|
|
34809
34814
|
logUserAction(action, details = {}) {
|
|
34810
34815
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -34812,7 +34817,7 @@ LAST ENTRY: ${state.chatHistory.length > 0 ? JSON.stringify(state.chatHistory[st
|
|
|
34812
34817
|
Details: ${JSON.stringify(details, null, 2)}
|
|
34813
34818
|
|
|
34814
34819
|
`;
|
|
34815
|
-
|
|
34820
|
+
fs10__default.appendFileSync(this.logPath, entry);
|
|
34816
34821
|
}
|
|
34817
34822
|
logPasteEvent(event) {
|
|
34818
34823
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -34820,7 +34825,7 @@ Details: ${JSON.stringify(details, null, 2)}
|
|
|
34820
34825
|
Data: ${JSON.stringify(event.data, null, 2)}
|
|
34821
34826
|
|
|
34822
34827
|
`;
|
|
34823
|
-
|
|
34828
|
+
fs10__default.appendFileSync(this.logPath, entry);
|
|
34824
34829
|
}
|
|
34825
34830
|
logTestResult(testName, result, details) {
|
|
34826
34831
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -34831,7 +34836,7 @@ Details: ${details}
|
|
|
34831
34836
|
=================================================================
|
|
34832
34837
|
|
|
34833
34838
|
`;
|
|
34834
|
-
|
|
34839
|
+
fs10__default.appendFileSync(this.logPath, entry);
|
|
34835
34840
|
}
|
|
34836
34841
|
getLogPath() {
|
|
34837
34842
|
return this.logPath;
|
|
@@ -35288,7 +35293,7 @@ var require_package = __commonJS({
|
|
|
35288
35293
|
module.exports = {
|
|
35289
35294
|
type: "module",
|
|
35290
35295
|
name: "@xagent/one-shot",
|
|
35291
|
-
version: "1.2.
|
|
35296
|
+
version: "1.2.14",
|
|
35292
35297
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
35293
35298
|
main: "dist/index.js",
|
|
35294
35299
|
module: "dist/index.js",
|
|
@@ -35442,7 +35447,7 @@ var require_package = __commonJS({
|
|
|
35442
35447
|
}
|
|
35443
35448
|
});
|
|
35444
35449
|
dotenv.config();
|
|
35445
|
-
var logStream =
|
|
35450
|
+
var logStream = fs10__default.createWriteStream(path8__default.join(process.cwd(), "xcli-startup.log"), { flags: "a" });
|
|
35446
35451
|
var isQuietCommand = process.argv.includes("--version") || process.argv.includes("-V") || process.argv.includes("--help") || process.argv.includes("-h");
|
|
35447
35452
|
if (isQuietCommand) {
|
|
35448
35453
|
process.env.GROK_QUIET_MODE = "true";
|