grok-cli-hurry-mode 1.0.25 → 1.0.27

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import * as fs from 'fs';
2
+ import * as ops7 from 'fs';
3
3
  import { existsSync } from 'fs';
4
4
  import * as path7 from 'path';
5
5
  import path7__default from 'path';
@@ -15,9 +15,7 @@ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
15
15
  import axios from 'axios';
16
16
  import { exec, execSync, spawn } from 'child_process';
17
17
  import { promisify } from 'util';
18
- import * as fs7 from 'fs-extra';
19
- import fs7__default from 'fs-extra';
20
- import fs17, { writeFile } from 'fs/promises';
18
+ import { writeFile } from 'fs/promises';
21
19
  import { parse } from '@typescript-eslint/typescript-estree';
22
20
  import Fuse from 'fuse.js';
23
21
  import { glob } from 'glob';
@@ -64,6 +62,9 @@ var init_settings_manager = __esm({
64
62
  model: "grok-code-fast-1"
65
63
  };
66
64
  SettingsManager = class _SettingsManager {
65
+ static instance;
66
+ userSettingsPath;
67
+ projectSettingsPath;
67
68
  constructor() {
68
69
  this.userSettingsPath = path7.join(
69
70
  os.homedir(),
@@ -90,8 +91,8 @@ var init_settings_manager = __esm({
90
91
  */
91
92
  ensureDirectoryExists(filePath) {
92
93
  const dir = path7.dirname(filePath);
93
- if (!fs.existsSync(dir)) {
94
- fs.mkdirSync(dir, { recursive: true, mode: 448 });
94
+ if (!ops7.existsSync(dir)) {
95
+ ops7.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 (!fs.existsSync(this.userSettingsPath)) {
103
+ if (!ops7.existsSync(this.userSettingsPath)) {
103
104
  this.saveUserSettings(DEFAULT_USER_SETTINGS);
104
105
  return { ...DEFAULT_USER_SETTINGS };
105
106
  }
106
- const content = fs.readFileSync(this.userSettingsPath, "utf-8");
107
+ const content = ops7.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 (fs.existsSync(this.userSettingsPath)) {
125
+ if (ops7.existsSync(this.userSettingsPath)) {
125
126
  try {
126
- const content = fs.readFileSync(this.userSettingsPath, "utf-8");
127
+ const content = ops7.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
- fs.writeFileSync(
135
+ ops7.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 (!fs.existsSync(this.projectSettingsPath)) {
168
+ if (!ops7.existsSync(this.projectSettingsPath)) {
168
169
  this.saveProjectSettings(DEFAULT_PROJECT_SETTINGS);
169
170
  return { ...DEFAULT_PROJECT_SETTINGS };
170
171
  }
171
- const content = fs.readFileSync(this.projectSettingsPath, "utf-8");
172
+ const content = ops7.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 (fs.existsSync(this.projectSettingsPath)) {
190
+ if (ops7.existsSync(this.projectSettingsPath)) {
190
191
  try {
191
- const content = fs.readFileSync(this.projectSettingsPath, "utf-8");
192
+ const content = ops7.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
- fs.writeFileSync(
200
+ ops7.writeFileSync(
200
201
  this.projectSettingsPath,
201
202
  JSON.stringify(mergedSettings, null, 2)
202
203
  );
@@ -330,8 +331,10 @@ var init_config = __esm({
330
331
  }
331
332
  });
332
333
  var GrokClient = class {
334
+ client;
335
+ currentModel = "grok-code-fast-1";
336
+ defaultMaxTokens;
333
337
  constructor(apiKey, model, baseURL) {
334
- this.currentModel = "grok-code-fast-1";
335
338
  this.client = new OpenAI({
336
339
  apiKey,
337
340
  baseURL: baseURL || process.env.GROK_BASE_URL || "https://api.x.ai/v1",
@@ -410,6 +413,8 @@ var StdioTransport = class {
410
413
  throw new Error("Command is required for stdio transport");
411
414
  }
412
415
  }
416
+ transport;
417
+ process;
413
418
  async connect() {
414
419
  const env = {
415
420
  ...process.env,
@@ -445,11 +450,12 @@ var HttpTransport = class extends EventEmitter {
445
450
  constructor(config2) {
446
451
  super();
447
452
  this.config = config2;
448
- this.connected = false;
449
453
  if (!config2.url) {
450
454
  throw new Error("URL is required for HTTP transport");
451
455
  }
452
456
  }
457
+ client;
458
+ connected = false;
453
459
  async connect() {
454
460
  this.client = axios.create({
455
461
  baseURL: this.config.url,
@@ -478,11 +484,11 @@ var SSETransport = class extends EventEmitter {
478
484
  constructor(config2) {
479
485
  super();
480
486
  this.config = config2;
481
- this.connected = false;
482
487
  if (!config2.url) {
483
488
  throw new Error("URL is required for SSE transport");
484
489
  }
485
490
  }
491
+ connected = false;
486
492
  async connect() {
487
493
  return new Promise((resolve8, reject) => {
488
494
  try {
@@ -542,11 +548,11 @@ var StreamableHttpTransport = class extends EventEmitter {
542
548
  constructor(config2) {
543
549
  super();
544
550
  this.config = config2;
545
- this.connected = false;
546
551
  if (!config2.url) {
547
552
  throw new Error("URL is required for streamable_http transport");
548
553
  }
549
554
  }
555
+ connected = false;
550
556
  async connect() {
551
557
  return new Promise((resolve8, reject) => {
552
558
  try {
@@ -597,12 +603,9 @@ function createTransport(config2) {
597
603
 
598
604
  // src/mcp/client.ts
599
605
  var MCPManager = class extends EventEmitter {
600
- constructor() {
601
- super(...arguments);
602
- this.clients = /* @__PURE__ */ new Map();
603
- this.transports = /* @__PURE__ */ new Map();
604
- this.tools = /* @__PURE__ */ new Map();
605
- }
606
+ clients = /* @__PURE__ */ new Map();
607
+ transports = /* @__PURE__ */ new Map();
608
+ tools = /* @__PURE__ */ new Map();
606
609
  async addServer(config2) {
607
610
  try {
608
611
  let transportConfig = config2.transport;
@@ -1304,24 +1307,25 @@ async function getAllGrokTools() {
1304
1307
  init_config();
1305
1308
  var execAsync = promisify(exec);
1306
1309
  var ConfirmationService = class _ConfirmationService extends EventEmitter {
1307
- constructor() {
1308
- super();
1309
- this.skipConfirmationThisSession = false;
1310
- this.pendingConfirmation = null;
1311
- this.resolveConfirmation = null;
1312
- // Session flags for different operation types
1313
- this.sessionFlags = {
1314
- fileOperations: false,
1315
- bashCommands: false,
1316
- allOperations: false
1317
- };
1318
- }
1310
+ static instance;
1311
+ skipConfirmationThisSession = false;
1312
+ pendingConfirmation = null;
1313
+ resolveConfirmation = null;
1314
+ // Session flags for different operation types
1315
+ sessionFlags = {
1316
+ fileOperations: false,
1317
+ bashCommands: false,
1318
+ allOperations: false
1319
+ };
1319
1320
  static getInstance() {
1320
1321
  if (!_ConfirmationService.instance) {
1321
1322
  _ConfirmationService.instance = new _ConfirmationService();
1322
1323
  }
1323
1324
  return _ConfirmationService.instance;
1324
1325
  }
1326
+ constructor() {
1327
+ super();
1328
+ }
1325
1329
  async requestConfirmation(options, operationType = "file") {
1326
1330
  if (this.sessionFlags.allOperations || operationType === "file" && this.sessionFlags.fileOperations || operationType === "bash" && this.sessionFlags.bashCommands) {
1327
1331
  return { confirmed: true };
@@ -1397,10 +1401,8 @@ var ConfirmationService = class _ConfirmationService extends EventEmitter {
1397
1401
  // src/tools/bash.ts
1398
1402
  var execAsync2 = promisify(exec);
1399
1403
  var BashTool = class {
1400
- constructor() {
1401
- this.currentDirectory = process.cwd();
1402
- this.confirmationService = ConfirmationService.getInstance();
1403
- }
1404
+ currentDirectory = process.cwd();
1405
+ confirmationService = ConfirmationService.getInstance();
1404
1406
  async execute(command, timeout = 6e4) {
1405
1407
  try {
1406
1408
  const sessionFlags = this.confirmationService.getSessionFlags();
@@ -1466,25 +1468,31 @@ STDERR: ${stderr}` : "");
1466
1468
  return this.execute(`grep -r "${pattern}" ${files}`);
1467
1469
  }
1468
1470
  };
1469
- var TextEditorTool = class {
1470
- constructor() {
1471
- this.editHistory = [];
1472
- this.confirmationService = ConfirmationService.getInstance();
1471
+ var pathExists = async (filePath) => {
1472
+ try {
1473
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
1474
+ return true;
1475
+ } catch {
1476
+ return false;
1473
1477
  }
1478
+ };
1479
+ var TextEditorTool = class {
1480
+ editHistory = [];
1481
+ confirmationService = ConfirmationService.getInstance();
1474
1482
  async view(filePath, viewRange) {
1475
1483
  try {
1476
1484
  const resolvedPath = path7.resolve(filePath);
1477
- if (await fs7.pathExists(resolvedPath)) {
1478
- const stats = await fs7.stat(resolvedPath);
1485
+ if (await pathExists(resolvedPath)) {
1486
+ const stats = await ops7.promises.stat(resolvedPath);
1479
1487
  if (stats.isDirectory()) {
1480
- const files = await fs7.readdir(resolvedPath);
1488
+ const files = await ops7.promises.readdir(resolvedPath);
1481
1489
  return {
1482
1490
  success: true,
1483
1491
  output: `Directory contents of ${filePath}:
1484
1492
  ${files.join("\n")}`
1485
1493
  };
1486
1494
  }
1487
- const content = await fs7.readFile(resolvedPath, "utf-8");
1495
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
1488
1496
  const lines = content.split("\n");
1489
1497
  if (viewRange) {
1490
1498
  const [start, end] = viewRange;
@@ -1528,13 +1536,13 @@ ${numberedLines}${additionalLinesMessage}`
1528
1536
  };
1529
1537
  }
1530
1538
  const resolvedPath = path7.resolve(filePath);
1531
- if (!await fs7.pathExists(resolvedPath)) {
1539
+ if (!await pathExists(resolvedPath)) {
1532
1540
  return {
1533
1541
  success: false,
1534
1542
  error: `File not found: ${filePath}`
1535
1543
  };
1536
1544
  }
1537
- const content = await fs7.readFile(resolvedPath, "utf-8");
1545
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
1538
1546
  if (!content.includes(oldStr)) {
1539
1547
  if (oldStr.includes("\n")) {
1540
1548
  const fuzzyResult = this.findFuzzyMatch(content, oldStr);
@@ -1601,7 +1609,7 @@ ${numberedLines}${additionalLinesMessage}`
1601
1609
  async create(filePath, content) {
1602
1610
  try {
1603
1611
  const resolvedPath = path7.resolve(filePath);
1604
- if (await fs7.pathExists(resolvedPath)) {
1612
+ if (await pathExists(resolvedPath)) {
1605
1613
  return {
1606
1614
  success: false,
1607
1615
  error: `File already exists: ${filePath}`
@@ -1634,7 +1642,7 @@ ${numberedLines}${additionalLinesMessage}`
1634
1642
  }
1635
1643
  }
1636
1644
  const dir = path7.dirname(resolvedPath);
1637
- await fs7.ensureDir(dir);
1645
+ await ops7.promises.mkdir(dir, { recursive: true });
1638
1646
  await writeFile(resolvedPath, content, "utf-8");
1639
1647
  this.editHistory.push({
1640
1648
  command: "create",
@@ -1658,13 +1666,13 @@ ${numberedLines}${additionalLinesMessage}`
1658
1666
  async replaceLines(filePath, startLine, endLine, newContent) {
1659
1667
  try {
1660
1668
  const resolvedPath = path7.resolve(filePath);
1661
- if (!await fs7.pathExists(resolvedPath)) {
1669
+ if (!await pathExists(resolvedPath)) {
1662
1670
  return {
1663
1671
  success: false,
1664
1672
  error: `File not found: ${filePath}`
1665
1673
  };
1666
1674
  }
1667
- const fileContent = await fs7.readFile(resolvedPath, "utf-8");
1675
+ const fileContent = await ops7.promises.readFile(resolvedPath, "utf-8");
1668
1676
  const lines = fileContent.split("\n");
1669
1677
  if (startLine < 1 || startLine > lines.length) {
1670
1678
  return {
@@ -1726,13 +1734,13 @@ ${numberedLines}${additionalLinesMessage}`
1726
1734
  async insert(filePath, insertLine, content) {
1727
1735
  try {
1728
1736
  const resolvedPath = path7.resolve(filePath);
1729
- if (!await fs7.pathExists(resolvedPath)) {
1737
+ if (!await pathExists(resolvedPath)) {
1730
1738
  return {
1731
1739
  success: false,
1732
1740
  error: `File not found: ${filePath}`
1733
1741
  };
1734
1742
  }
1735
- const fileContent = await fs7.readFile(resolvedPath, "utf-8");
1743
+ const fileContent = await ops7.promises.readFile(resolvedPath, "utf-8");
1736
1744
  const lines = fileContent.split("\n");
1737
1745
  lines.splice(insertLine - 1, 0, content);
1738
1746
  const newContent = lines.join("\n");
@@ -1766,7 +1774,7 @@ ${numberedLines}${additionalLinesMessage}`
1766
1774
  switch (lastEdit.command) {
1767
1775
  case "str_replace":
1768
1776
  if (lastEdit.path && lastEdit.old_str && lastEdit.new_str) {
1769
- const content = await fs7.readFile(lastEdit.path, "utf-8");
1777
+ const content = await ops7.promises.readFile(lastEdit.path, "utf-8");
1770
1778
  const revertedContent = content.replace(
1771
1779
  lastEdit.new_str,
1772
1780
  lastEdit.old_str
@@ -1776,12 +1784,12 @@ ${numberedLines}${additionalLinesMessage}`
1776
1784
  break;
1777
1785
  case "create":
1778
1786
  if (lastEdit.path) {
1779
- await fs7.remove(lastEdit.path);
1787
+ await ops7.promises.rm(lastEdit.path);
1780
1788
  }
1781
1789
  break;
1782
1790
  case "insert":
1783
1791
  if (lastEdit.path && lastEdit.insert_line) {
1784
- const content = await fs7.readFile(lastEdit.path, "utf-8");
1792
+ const content = await ops7.promises.readFile(lastEdit.path, "utf-8");
1785
1793
  const lines = content.split("\n");
1786
1794
  lines.splice(lastEdit.insert_line - 1, 1);
1787
1795
  await writeFile(lastEdit.path, lines.join("\n"), "utf-8");
@@ -1979,10 +1987,19 @@ ${numberedLines}${additionalLinesMessage}`
1979
1987
  return [...this.editHistory];
1980
1988
  }
1981
1989
  };
1990
+ var pathExists2 = async (filePath) => {
1991
+ try {
1992
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
1993
+ return true;
1994
+ } catch {
1995
+ return false;
1996
+ }
1997
+ };
1982
1998
  var MorphEditorTool = class {
1999
+ confirmationService = ConfirmationService.getInstance();
2000
+ morphApiKey;
2001
+ morphBaseUrl = "https://api.morphllm.com/v1";
1983
2002
  constructor(apiKey) {
1984
- this.confirmationService = ConfirmationService.getInstance();
1985
- this.morphBaseUrl = "https://api.morphllm.com/v1";
1986
2003
  this.morphApiKey = apiKey || process.env.MORPH_API_KEY || "";
1987
2004
  if (!this.morphApiKey) {
1988
2005
  console.warn("MORPH_API_KEY not found. Morph editor functionality will be limited.");
@@ -2014,7 +2031,7 @@ var MorphEditorTool = class {
2014
2031
  async editFile(targetFile, instructions, codeEdit) {
2015
2032
  try {
2016
2033
  const resolvedPath = path7.resolve(targetFile);
2017
- if (!await fs7.pathExists(resolvedPath)) {
2034
+ if (!await pathExists2(resolvedPath)) {
2018
2035
  return {
2019
2036
  success: false,
2020
2037
  error: `File not found: ${targetFile}`
@@ -2026,7 +2043,7 @@ var MorphEditorTool = class {
2026
2043
  error: "MORPH_API_KEY not configured. Please set your Morph API key."
2027
2044
  };
2028
2045
  }
2029
- const initialCode = await fs7.readFile(resolvedPath, "utf-8");
2046
+ const initialCode = await ops7.promises.readFile(resolvedPath, "utf-8");
2030
2047
  const sessionFlags = this.confirmationService.getSessionFlags();
2031
2048
  if (!sessionFlags.fileOperations && !sessionFlags.allOperations) {
2032
2049
  const confirmationResult = await this.confirmationService.requestConfirmation(
@@ -2049,7 +2066,7 @@ ${codeEdit}`
2049
2066
  }
2050
2067
  }
2051
2068
  const mergedCode = await this.callMorphApply(instructions, initialCode, codeEdit);
2052
- await fs7.writeFile(resolvedPath, mergedCode, "utf-8");
2069
+ await ops7.promises.writeFile(resolvedPath, mergedCode, "utf-8");
2053
2070
  const oldLines = initialCode.split("\n");
2054
2071
  const newLines = mergedCode.split("\n");
2055
2072
  const diff = this.generateDiff(oldLines, newLines, targetFile);
@@ -2222,17 +2239,17 @@ ${codeEdit}`
2222
2239
  async view(filePath, viewRange) {
2223
2240
  try {
2224
2241
  const resolvedPath = path7.resolve(filePath);
2225
- if (await fs7.pathExists(resolvedPath)) {
2226
- const stats = await fs7.stat(resolvedPath);
2242
+ if (await pathExists2(resolvedPath)) {
2243
+ const stats = await ops7.promises.stat(resolvedPath);
2227
2244
  if (stats.isDirectory()) {
2228
- const files = await fs7.readdir(resolvedPath);
2245
+ const files = await ops7.promises.readdir(resolvedPath);
2229
2246
  return {
2230
2247
  success: true,
2231
2248
  output: `Directory contents of ${filePath}:
2232
2249
  ${files.join("\n")}`
2233
2250
  };
2234
2251
  }
2235
- const content = await fs7.readFile(resolvedPath, "utf-8");
2252
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
2236
2253
  const lines = content.split("\n");
2237
2254
  if (viewRange) {
2238
2255
  const [start, end] = viewRange;
@@ -2277,9 +2294,7 @@ ${numberedLines}${additionalLinesMessage}`
2277
2294
 
2278
2295
  // src/tools/todo-tool.ts
2279
2296
  var TodoTool = class {
2280
- constructor() {
2281
- this.todos = [];
2282
- }
2297
+ todos = [];
2283
2298
  formatTodoList() {
2284
2299
  if (this.todos.length === 0) {
2285
2300
  return "No todos created yet";
@@ -2407,6 +2422,7 @@ var TodoTool = class {
2407
2422
 
2408
2423
  // src/tools/confirmation-tool.ts
2409
2424
  var ConfirmationTool = class {
2425
+ confirmationService;
2410
2426
  constructor() {
2411
2427
  this.confirmationService = ConfirmationService.getInstance();
2412
2428
  }
@@ -2470,10 +2486,8 @@ var ConfirmationTool = class {
2470
2486
  }
2471
2487
  };
2472
2488
  var SearchTool = class {
2473
- constructor() {
2474
- this.confirmationService = ConfirmationService.getInstance();
2475
- this.currentDirectory = process.cwd();
2476
- }
2489
+ confirmationService = ConfirmationService.getInstance();
2490
+ currentDirectory = process.cwd();
2477
2491
  /**
2478
2492
  * Unified search method that can search for text content or find files
2479
2493
  */
@@ -2643,7 +2657,7 @@ var SearchTool = class {
2643
2657
  const walkDir = async (dir, depth = 0) => {
2644
2658
  if (depth > 10 || files.length >= maxResults) return;
2645
2659
  try {
2646
- const entries = await fs7.readdir(dir, { withFileTypes: true });
2660
+ const entries = await ops7.promises.readdir(dir, { withFileTypes: true });
2647
2661
  for (const entry of entries) {
2648
2662
  if (files.length >= maxResults) break;
2649
2663
  const fullPath = path7.join(dir, entry.name);
@@ -2755,12 +2769,18 @@ var SearchTool = class {
2755
2769
  return this.currentDirectory;
2756
2770
  }
2757
2771
  };
2758
- var MultiFileEditorTool = class {
2759
- constructor() {
2760
- this.confirmationService = ConfirmationService.getInstance();
2761
- this.transactions = /* @__PURE__ */ new Map();
2762
- this.currentTransactionId = null;
2772
+ var pathExists3 = async (filePath) => {
2773
+ try {
2774
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
2775
+ return true;
2776
+ } catch {
2777
+ return false;
2763
2778
  }
2779
+ };
2780
+ var MultiFileEditorTool = class {
2781
+ confirmationService = ConfirmationService.getInstance();
2782
+ transactions = /* @__PURE__ */ new Map();
2783
+ currentTransactionId = null;
2764
2784
  /**
2765
2785
  * Begin a multi-file transaction
2766
2786
  */
@@ -3055,7 +3075,7 @@ ${results.join("\n")}`
3055
3075
  const resolvedPath = path7.resolve(operation.filePath);
3056
3076
  switch (operation.type) {
3057
3077
  case "create":
3058
- if (await fs7.pathExists(resolvedPath)) {
3078
+ if (await pathExists3(resolvedPath)) {
3059
3079
  return { valid: false, error: "File already exists" };
3060
3080
  }
3061
3081
  if (!operation.content) {
@@ -3063,7 +3083,7 @@ ${results.join("\n")}`
3063
3083
  }
3064
3084
  break;
3065
3085
  case "edit":
3066
- if (!await fs7.pathExists(resolvedPath)) {
3086
+ if (!await pathExists3(resolvedPath)) {
3067
3087
  return { valid: false, error: "File does not exist" };
3068
3088
  }
3069
3089
  if (!operation.operations || operation.operations.length === 0) {
@@ -3071,20 +3091,20 @@ ${results.join("\n")}`
3071
3091
  }
3072
3092
  break;
3073
3093
  case "delete":
3074
- if (!await fs7.pathExists(resolvedPath)) {
3094
+ if (!await pathExists3(resolvedPath)) {
3075
3095
  return { valid: false, error: "File does not exist" };
3076
3096
  }
3077
3097
  break;
3078
3098
  case "rename":
3079
3099
  case "move":
3080
- if (!await fs7.pathExists(resolvedPath)) {
3100
+ if (!await pathExists3(resolvedPath)) {
3081
3101
  return { valid: false, error: "Source file does not exist" };
3082
3102
  }
3083
3103
  if (!operation.newFilePath) {
3084
3104
  return { valid: false, error: "Destination path required" };
3085
3105
  }
3086
3106
  const newResolvedPath = path7.resolve(operation.newFilePath);
3087
- if (await fs7.pathExists(newResolvedPath)) {
3107
+ if (await pathExists3(newResolvedPath)) {
3088
3108
  return { valid: false, error: "Destination already exists" };
3089
3109
  }
3090
3110
  break;
@@ -3106,15 +3126,15 @@ ${results.join("\n")}`
3106
3126
  filePath: operation.filePath
3107
3127
  };
3108
3128
  case "edit":
3109
- const originalContent = await fs7.readFile(resolvedPath, "utf-8");
3129
+ const originalContent = await ops7.promises.readFile(resolvedPath, "utf-8");
3110
3130
  return {
3111
3131
  type: "restore_content",
3112
3132
  filePath: operation.filePath,
3113
3133
  originalContent
3114
3134
  };
3115
3135
  case "delete":
3116
- const contentToRestore = await fs7.readFile(resolvedPath, "utf-8");
3117
- const stats = await fs7.stat(resolvedPath);
3136
+ const contentToRestore = await ops7.promises.readFile(resolvedPath, "utf-8");
3137
+ const stats = await ops7.promises.stat(resolvedPath);
3118
3138
  return {
3119
3139
  type: "restore_deleted",
3120
3140
  filePath: operation.filePath,
@@ -3140,25 +3160,25 @@ ${results.join("\n")}`
3140
3160
  switch (operation.type) {
3141
3161
  case "create":
3142
3162
  const dir = path7.dirname(resolvedPath);
3143
- await fs7.ensureDir(dir);
3163
+ await ops7.promises.mkdir(dir, { recursive: true });
3144
3164
  await writeFile(resolvedPath, operation.content, "utf-8");
3145
3165
  return { success: true, output: `Created ${operation.filePath}` };
3146
3166
  case "edit":
3147
- let content = await fs7.readFile(resolvedPath, "utf-8");
3167
+ let content = await ops7.promises.readFile(resolvedPath, "utf-8");
3148
3168
  for (const editOp of operation.operations) {
3149
3169
  content = await this.applyEditOperation(content, editOp);
3150
3170
  }
3151
3171
  await writeFile(resolvedPath, content, "utf-8");
3152
3172
  return { success: true, output: `Edited ${operation.filePath}` };
3153
3173
  case "delete":
3154
- await fs7.remove(resolvedPath);
3174
+ await ops7.promises.rm(resolvedPath);
3155
3175
  return { success: true, output: `Deleted ${operation.filePath}` };
3156
3176
  case "rename":
3157
3177
  case "move":
3158
3178
  const newResolvedPath = path7.resolve(operation.newFilePath);
3159
3179
  const newDir = path7.dirname(newResolvedPath);
3160
- await fs7.ensureDir(newDir);
3161
- await fs7.move(resolvedPath, newResolvedPath);
3180
+ await ops7.promises.mkdir(newDir, { recursive: true });
3181
+ await ops7.move(resolvedPath, newResolvedPath);
3162
3182
  return { success: true, output: `${operation.type === "rename" ? "Renamed" : "Moved"} ${operation.filePath} to ${operation.newFilePath}` };
3163
3183
  default:
3164
3184
  throw new Error(`Unknown operation type: ${operation.type}`);
@@ -3201,8 +3221,8 @@ ${results.join("\n")}`
3201
3221
  switch (rollback.type) {
3202
3222
  case "delete_created":
3203
3223
  const createdPath = path7.resolve(rollback.filePath);
3204
- if (await fs7.pathExists(createdPath)) {
3205
- await fs7.remove(createdPath);
3224
+ if (await pathExists3(createdPath)) {
3225
+ await ops7.promises.rm(createdPath);
3206
3226
  }
3207
3227
  break;
3208
3228
  case "restore_content":
@@ -3212,16 +3232,16 @@ ${results.join("\n")}`
3212
3232
  case "restore_deleted":
3213
3233
  const deletedPath = path7.resolve(rollback.filePath);
3214
3234
  const deletedDir = path7.dirname(deletedPath);
3215
- await fs7.ensureDir(deletedDir);
3235
+ await ops7.promises.mkdir(deletedDir, { recursive: true });
3216
3236
  await writeFile(deletedPath, rollback.content, "utf-8");
3217
3237
  break;
3218
3238
  case "restore_move":
3219
3239
  const movedNewPath = path7.resolve(rollback.newPath);
3220
3240
  const movedOldPath = path7.resolve(rollback.oldPath);
3221
- if (await fs7.pathExists(movedNewPath)) {
3241
+ if (await pathExists3(movedNewPath)) {
3222
3242
  const oldDir = path7.dirname(movedOldPath);
3223
- await fs7.ensureDir(oldDir);
3224
- await fs7.move(movedNewPath, movedOldPath);
3243
+ await ops7.promises.mkdir(oldDir, { recursive: true });
3244
+ await ops7.move(movedNewPath, movedOldPath);
3225
3245
  }
3226
3246
  break;
3227
3247
  }
@@ -3261,23 +3281,29 @@ ${results.join("\n")}`
3261
3281
  return this.currentTransactionId;
3262
3282
  }
3263
3283
  };
3264
- var AdvancedSearchTool = class {
3265
- constructor() {
3266
- this.confirmationService = ConfirmationService.getInstance();
3284
+ var pathExists4 = async (filePath) => {
3285
+ try {
3286
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
3287
+ return true;
3288
+ } catch {
3289
+ return false;
3267
3290
  }
3291
+ };
3292
+ var AdvancedSearchTool = class {
3293
+ confirmationService = ConfirmationService.getInstance();
3268
3294
  /**
3269
3295
  * Search for patterns across files
3270
3296
  */
3271
3297
  async search(searchPath, options) {
3272
3298
  try {
3273
3299
  const resolvedPath = path7.resolve(searchPath);
3274
- if (!await fs7.pathExists(resolvedPath)) {
3300
+ if (!await pathExists4(resolvedPath)) {
3275
3301
  return {
3276
3302
  success: false,
3277
3303
  error: `Path not found: ${searchPath}`
3278
3304
  };
3279
3305
  }
3280
- const stats = await fs7.stat(resolvedPath);
3306
+ const stats = await ops7.promises.stat(resolvedPath);
3281
3307
  const filesToSearch = [];
3282
3308
  if (stats.isFile()) {
3283
3309
  filesToSearch.push(resolvedPath);
@@ -3314,13 +3340,13 @@ var AdvancedSearchTool = class {
3314
3340
  async searchAndReplace(searchPath, options) {
3315
3341
  try {
3316
3342
  const resolvedPath = path7.resolve(searchPath);
3317
- if (!await fs7.pathExists(resolvedPath)) {
3343
+ if (!await pathExists4(resolvedPath)) {
3318
3344
  return {
3319
3345
  success: false,
3320
3346
  error: `Path not found: ${searchPath}`
3321
3347
  };
3322
3348
  }
3323
- const stats = await fs7.stat(resolvedPath);
3349
+ const stats = await ops7.promises.stat(resolvedPath);
3324
3350
  const filesToProcess = [];
3325
3351
  if (stats.isFile()) {
3326
3352
  filesToProcess.push(resolvedPath);
@@ -3365,7 +3391,7 @@ var AdvancedSearchTool = class {
3365
3391
  }
3366
3392
  for (const result of results) {
3367
3393
  if (result.success && result.preview) {
3368
- await fs7.writeFile(result.filePath, result.preview, "utf-8");
3394
+ await ops7.promises.writeFile(result.filePath, result.preview, "utf-8");
3369
3395
  }
3370
3396
  }
3371
3397
  }
@@ -3386,7 +3412,7 @@ var AdvancedSearchTool = class {
3386
3412
  async findFiles(searchPath, pattern, options = {}) {
3387
3413
  try {
3388
3414
  const resolvedPath = path7.resolve(searchPath);
3389
- if (!await fs7.pathExists(resolvedPath)) {
3415
+ if (!await pathExists4(resolvedPath)) {
3390
3416
  return {
3391
3417
  success: false,
3392
3418
  error: `Path not found: ${searchPath}`
@@ -3427,7 +3453,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
3427
3453
  * Search in a single file
3428
3454
  */
3429
3455
  async searchInFile(filePath, options) {
3430
- const content = await fs7.readFile(filePath, "utf-8");
3456
+ const content = await ops7.promises.readFile(filePath, "utf-8");
3431
3457
  const lines = content.split("\n");
3432
3458
  const matches = [];
3433
3459
  let pattern;
@@ -3478,7 +3504,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
3478
3504
  */
3479
3505
  async replaceInFile(filePath, options) {
3480
3506
  try {
3481
- const content = await fs7.readFile(filePath, "utf-8");
3507
+ const content = await ops7.promises.readFile(filePath, "utf-8");
3482
3508
  let pattern;
3483
3509
  try {
3484
3510
  if (options.isRegex) {
@@ -3529,7 +3555,7 @@ ${matchingFiles.join("\n")}` : "No matching files found"
3529
3555
  async getFilesRecursively(dirPath, options) {
3530
3556
  const files = [];
3531
3557
  const walk = async (currentPath) => {
3532
- const entries = await fs7.readdir(currentPath, { withFileTypes: true });
3558
+ const entries = await ops7.promises.readdir(currentPath, { withFileTypes: true });
3533
3559
  for (const entry of entries) {
3534
3560
  const fullPath = path7.join(currentPath, entry.name);
3535
3561
  if (entry.isDirectory()) {
@@ -3690,17 +3716,23 @@ ${matchingFiles.join("\n")}` : "No matching files found"
3690
3716
  return output.trim();
3691
3717
  }
3692
3718
  };
3693
- var FileTreeOperationsTool = class {
3694
- constructor() {
3695
- this.confirmationService = ConfirmationService.getInstance();
3719
+ var pathExists5 = async (filePath) => {
3720
+ try {
3721
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
3722
+ return true;
3723
+ } catch {
3724
+ return false;
3696
3725
  }
3726
+ };
3727
+ var FileTreeOperationsTool = class {
3728
+ confirmationService = ConfirmationService.getInstance();
3697
3729
  /**
3698
3730
  * Generate a visual tree representation of directory structure
3699
3731
  */
3700
3732
  async generateTree(rootPath, options = {}) {
3701
3733
  try {
3702
3734
  const resolvedPath = path7.resolve(rootPath);
3703
- if (!await fs7.pathExists(resolvedPath)) {
3735
+ if (!await pathExists5(resolvedPath)) {
3704
3736
  return {
3705
3737
  success: false,
3706
3738
  error: `Path not found: ${rootPath}`
@@ -3781,13 +3813,13 @@ ${results.join("\n")}`
3781
3813
  try {
3782
3814
  const resolvedSource = path7.resolve(sourcePath);
3783
3815
  const resolvedDest = path7.resolve(destinationPath);
3784
- if (!await fs7.pathExists(resolvedSource)) {
3816
+ if (!await pathExists5(resolvedSource)) {
3785
3817
  return {
3786
3818
  success: false,
3787
3819
  error: `Source path not found: ${sourcePath}`
3788
3820
  };
3789
3821
  }
3790
- if (await fs7.pathExists(resolvedDest) && !options.overwrite) {
3822
+ if (await pathExists5(resolvedDest) && !options.overwrite) {
3791
3823
  return {
3792
3824
  success: false,
3793
3825
  error: `Destination already exists: ${destinationPath}`
@@ -3830,7 +3862,7 @@ Overwrite: ${options.overwrite ? "Yes" : "No"}`
3830
3862
  async organizeFiles(sourcePath, organizationType, destinationBase) {
3831
3863
  try {
3832
3864
  const resolvedSource = path7.resolve(sourcePath);
3833
- if (!await fs7.pathExists(resolvedSource)) {
3865
+ if (!await pathExists5(resolvedSource)) {
3834
3866
  return {
3835
3867
  success: false,
3836
3868
  error: `Source path not found: ${sourcePath}`
@@ -3875,11 +3907,11 @@ ${category}/
3875
3907
  let movedFiles = 0;
3876
3908
  for (const [category, fileList] of Object.entries(organization)) {
3877
3909
  const categoryDir = path7.join(destBase, category);
3878
- await fs7.ensureDir(categoryDir);
3910
+ await ops7.promises.mkdir(categoryDir, { recursive: true });
3879
3911
  for (const filePath of fileList) {
3880
3912
  const fileName = path7.basename(filePath);
3881
3913
  const destPath = path7.join(categoryDir, fileName);
3882
- await fs7.move(filePath, destPath);
3914
+ await ops7.move(filePath, destPath);
3883
3915
  movedFiles++;
3884
3916
  }
3885
3917
  }
@@ -3900,7 +3932,7 @@ ${category}/
3900
3932
  async cleanupEmptyDirectories(rootPath) {
3901
3933
  try {
3902
3934
  const resolvedPath = path7.resolve(rootPath);
3903
- if (!await fs7.pathExists(resolvedPath)) {
3935
+ if (!await pathExists5(resolvedPath)) {
3904
3936
  return {
3905
3937
  success: false,
3906
3938
  error: `Path not found: ${rootPath}`
@@ -3935,7 +3967,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
3935
3967
  }
3936
3968
  emptyDirs.sort((a, b) => b.length - a.length);
3937
3969
  for (const dir of emptyDirs) {
3938
- await fs7.rmdir(dir);
3970
+ await ops7.rmdir(dir);
3939
3971
  }
3940
3972
  return {
3941
3973
  success: true,
@@ -3952,7 +3984,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
3952
3984
  * Build tree structure recursively
3953
3985
  */
3954
3986
  async buildTreeStructure(dirPath, options, currentDepth) {
3955
- const stats = await fs7.stat(dirPath);
3987
+ const stats = await ops7.promises.stat(dirPath);
3956
3988
  const name = path7.basename(dirPath);
3957
3989
  const node = {
3958
3990
  name: name || path7.basename(dirPath),
@@ -3964,7 +3996,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
3964
3996
  if (stats.isDirectory() && (!options.maxDepth || currentDepth < options.maxDepth)) {
3965
3997
  node.children = [];
3966
3998
  try {
3967
- const entries = await fs7.readdir(dirPath, { withFileTypes: true });
3999
+ const entries = await ops7.promises.readdir(dirPath, { withFileTypes: true });
3968
4000
  for (const entry of entries) {
3969
4001
  if (!options.includeHidden && entry.name.startsWith(".")) {
3970
4002
  continue;
@@ -4067,7 +4099,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4067
4099
  switch (operation.type) {
4068
4100
  case "copy":
4069
4101
  case "move":
4070
- if (!await fs7.pathExists(sourcePath)) {
4102
+ if (!await pathExists5(sourcePath)) {
4071
4103
  return { valid: false, error: "Source path does not exist" };
4072
4104
  }
4073
4105
  if (!operation.destination) {
@@ -4075,17 +4107,17 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4075
4107
  }
4076
4108
  break;
4077
4109
  case "delete":
4078
- if (!await fs7.pathExists(sourcePath)) {
4110
+ if (!await pathExists5(sourcePath)) {
4079
4111
  return { valid: false, error: "Path does not exist" };
4080
4112
  }
4081
4113
  break;
4082
4114
  case "create_dir":
4083
- if (await fs7.pathExists(sourcePath)) {
4115
+ if (await pathExists5(sourcePath)) {
4084
4116
  return { valid: false, error: "Directory already exists" };
4085
4117
  }
4086
4118
  break;
4087
4119
  case "chmod":
4088
- if (!await fs7.pathExists(sourcePath)) {
4120
+ if (!await pathExists5(sourcePath)) {
4089
4121
  return { valid: false, error: "Path does not exist" };
4090
4122
  }
4091
4123
  if (!operation.mode) {
@@ -4093,7 +4125,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4093
4125
  }
4094
4126
  break;
4095
4127
  case "rename":
4096
- if (!await fs7.pathExists(sourcePath)) {
4128
+ if (!await pathExists5(sourcePath)) {
4097
4129
  return { valid: false, error: "Source path does not exist" };
4098
4130
  }
4099
4131
  if (!operation.destination) {
@@ -4114,24 +4146,24 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4114
4146
  switch (operation.type) {
4115
4147
  case "copy":
4116
4148
  const copyDest = path7.resolve(operation.destination);
4117
- await fs7.copy(sourcePath, copyDest);
4149
+ await ops7.copy(sourcePath, copyDest);
4118
4150
  return `Copied ${operation.source} to ${operation.destination}`;
4119
4151
  case "move":
4120
4152
  const moveDest = path7.resolve(operation.destination);
4121
- await fs7.move(sourcePath, moveDest);
4153
+ await ops7.move(sourcePath, moveDest);
4122
4154
  return `Moved ${operation.source} to ${operation.destination}`;
4123
4155
  case "delete":
4124
- await fs7.remove(sourcePath);
4156
+ await ops7.promises.rm(sourcePath);
4125
4157
  return `Deleted ${operation.source}`;
4126
4158
  case "create_dir":
4127
- await fs7.ensureDir(sourcePath);
4159
+ await ops7.promises.mkdir(sourcePath, { recursive: true });
4128
4160
  return `Created directory ${operation.source}`;
4129
4161
  case "chmod":
4130
- await fs7.chmod(sourcePath, operation.mode);
4162
+ await ops7.promises.chmod(sourcePath, operation.mode);
4131
4163
  return `Changed permissions of ${operation.source} to ${operation.mode}`;
4132
4164
  case "rename":
4133
4165
  const renameDest = path7.resolve(operation.destination);
4134
- await fs7.move(sourcePath, renameDest);
4166
+ await ops7.move(sourcePath, renameDest);
4135
4167
  return `Renamed ${operation.source} to ${operation.destination}`;
4136
4168
  default:
4137
4169
  throw new Error(`Unknown operation type: ${operation.type}`);
@@ -4160,17 +4192,17 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4160
4192
  * Copy structure recursively
4161
4193
  */
4162
4194
  async copyStructureRecursive(source, destination, options) {
4163
- const stats = await fs7.stat(source);
4195
+ const stats = await ops7.promises.stat(source);
4164
4196
  if (stats.isDirectory()) {
4165
- await fs7.ensureDir(destination);
4166
- const entries = await fs7.readdir(source);
4197
+ await ops7.promises.mkdir(destination, { recursive: true });
4198
+ const entries = await ops7.promises.readdir(source);
4167
4199
  for (const entry of entries) {
4168
4200
  const srcPath = path7.join(source, entry);
4169
4201
  const destPath = path7.join(destination, entry);
4170
4202
  await this.copyStructureRecursive(srcPath, destPath, options);
4171
4203
  }
4172
4204
  } else if (options.includeFiles) {
4173
- await fs7.copy(source, destination, { overwrite: options.overwrite });
4205
+ await ops7.copy(source, destination, { overwrite: options.overwrite });
4174
4206
  }
4175
4207
  }
4176
4208
  /**
@@ -4179,7 +4211,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4179
4211
  async getFilesRecursively(dirPath) {
4180
4212
  const files = [];
4181
4213
  const walk = async (currentPath) => {
4182
- const entries = await fs7.readdir(currentPath, { withFileTypes: true });
4214
+ const entries = await ops7.promises.readdir(currentPath, { withFileTypes: true });
4183
4215
  for (const entry of entries) {
4184
4216
  const fullPath = path7.join(currentPath, entry.name);
4185
4217
  if (entry.isDirectory()) {
@@ -4205,14 +4237,14 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4205
4237
  category = ext || "no-extension";
4206
4238
  break;
4207
4239
  case "size":
4208
- const stats = await fs7.stat(filePath);
4240
+ const stats = await ops7.promises.stat(filePath);
4209
4241
  if (stats.size < 1024) category = "small (< 1KB)";
4210
4242
  else if (stats.size < 1024 * 1024) category = "medium (< 1MB)";
4211
4243
  else if (stats.size < 1024 * 1024 * 10) category = "large (< 10MB)";
4212
4244
  else category = "very-large (> 10MB)";
4213
4245
  break;
4214
4246
  case "date":
4215
- const fileStats = await fs7.stat(filePath);
4247
+ const fileStats = await ops7.promises.stat(filePath);
4216
4248
  const year = fileStats.mtime.getFullYear();
4217
4249
  const month = fileStats.mtime.getMonth() + 1;
4218
4250
  category = `${year}-${month.toString().padStart(2, "0")}`;
@@ -4234,7 +4266,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4234
4266
  const emptyDirs = [];
4235
4267
  const checkDirectory = async (currentPath) => {
4236
4268
  try {
4237
- const entries = await fs7.readdir(currentPath);
4269
+ const entries = await ops7.promises.readdir(currentPath);
4238
4270
  if (entries.length === 0) {
4239
4271
  emptyDirs.push(currentPath);
4240
4272
  return true;
@@ -4242,7 +4274,7 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4242
4274
  let hasNonEmptyChildren = false;
4243
4275
  for (const entry of entries) {
4244
4276
  const fullPath = path7.join(currentPath, entry);
4245
- const stats = await fs7.stat(fullPath);
4277
+ const stats = await ops7.promises.stat(fullPath);
4246
4278
  if (stats.isDirectory()) {
4247
4279
  const isEmpty = await checkDirectory(fullPath);
4248
4280
  if (!isEmpty) {
@@ -4265,23 +4297,29 @@ ${emptyDirs.map((dir) => `- ${path7.relative(rootPath, dir)}`).join("\n")}`;
4265
4297
  return emptyDirs;
4266
4298
  }
4267
4299
  };
4268
- var CodeAwareEditorTool = class {
4269
- constructor() {
4270
- this.confirmationService = ConfirmationService.getInstance();
4300
+ var pathExists6 = async (filePath) => {
4301
+ try {
4302
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
4303
+ return true;
4304
+ } catch {
4305
+ return false;
4271
4306
  }
4307
+ };
4308
+ var CodeAwareEditorTool = class {
4309
+ confirmationService = ConfirmationService.getInstance();
4272
4310
  /**
4273
4311
  * Analyze code structure and context
4274
4312
  */
4275
4313
  async analyzeCode(filePath) {
4276
4314
  try {
4277
4315
  const resolvedPath = path7.resolve(filePath);
4278
- if (!await fs7.pathExists(resolvedPath)) {
4316
+ if (!await pathExists6(resolvedPath)) {
4279
4317
  return {
4280
4318
  success: false,
4281
4319
  error: `File not found: ${filePath}`
4282
4320
  };
4283
4321
  }
4284
- const content = await fs7.readFile(resolvedPath, "utf-8");
4322
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
4285
4323
  const language = this.detectLanguage(filePath);
4286
4324
  const context = await this.parseCodeContext(content, language);
4287
4325
  const output = this.formatCodeAnalysis(context, filePath);
@@ -4302,13 +4340,13 @@ var CodeAwareEditorTool = class {
4302
4340
  async refactor(filePath, operation) {
4303
4341
  try {
4304
4342
  const resolvedPath = path7.resolve(filePath);
4305
- if (!await fs7.pathExists(resolvedPath)) {
4343
+ if (!await pathExists6(resolvedPath)) {
4306
4344
  return {
4307
4345
  success: false,
4308
4346
  error: `File not found: ${filePath}`
4309
4347
  };
4310
4348
  }
4311
- const content = await fs7.readFile(resolvedPath, "utf-8");
4349
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
4312
4350
  const language = this.detectLanguage(filePath);
4313
4351
  const context = await this.parseCodeContext(content, language);
4314
4352
  const result = await this.performRefactoring(content, context, operation, language);
@@ -4334,7 +4372,7 @@ var CodeAwareEditorTool = class {
4334
4372
  };
4335
4373
  }
4336
4374
  }
4337
- await fs7.writeFile(resolvedPath, result.newContent, "utf-8");
4375
+ await ops7.promises.writeFile(resolvedPath, result.newContent, "utf-8");
4338
4376
  return {
4339
4377
  success: true,
4340
4378
  output: result.output
@@ -4352,13 +4390,13 @@ var CodeAwareEditorTool = class {
4352
4390
  async smartInsert(filePath, code, location, target) {
4353
4391
  try {
4354
4392
  const resolvedPath = path7.resolve(filePath);
4355
- if (!await fs7.pathExists(resolvedPath)) {
4393
+ if (!await pathExists6(resolvedPath)) {
4356
4394
  return {
4357
4395
  success: false,
4358
4396
  error: `File not found: ${filePath}`
4359
4397
  };
4360
4398
  }
4361
- const content = await fs7.readFile(resolvedPath, "utf-8");
4399
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
4362
4400
  const language = this.detectLanguage(filePath);
4363
4401
  const context = await this.parseCodeContext(content, language);
4364
4402
  const insertionPoint = this.findInsertionPoint(content, context, location, target);
@@ -4388,7 +4426,7 @@ var CodeAwareEditorTool = class {
4388
4426
  };
4389
4427
  }
4390
4428
  }
4391
- await fs7.writeFile(resolvedPath, newContent, "utf-8");
4429
+ await ops7.promises.writeFile(resolvedPath, newContent, "utf-8");
4392
4430
  return {
4393
4431
  success: true,
4394
4432
  output: `Code inserted at line ${insertionPoint.line + 1} in ${filePath}`
@@ -4406,13 +4444,13 @@ var CodeAwareEditorTool = class {
4406
4444
  async formatCode(filePath, options = {}) {
4407
4445
  try {
4408
4446
  const resolvedPath = path7.resolve(filePath);
4409
- if (!await fs7.pathExists(resolvedPath)) {
4447
+ if (!await pathExists6(resolvedPath)) {
4410
4448
  return {
4411
4449
  success: false,
4412
4450
  error: `File not found: ${filePath}`
4413
4451
  };
4414
4452
  }
4415
- const content = await fs7.readFile(resolvedPath, "utf-8");
4453
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
4416
4454
  const language = this.detectLanguage(filePath);
4417
4455
  const formattedContent = await this.formatCodeContent(content, language, options);
4418
4456
  if (formattedContent === content) {
@@ -4440,7 +4478,7 @@ var CodeAwareEditorTool = class {
4440
4478
  };
4441
4479
  }
4442
4480
  }
4443
- await fs7.writeFile(resolvedPath, formattedContent, "utf-8");
4481
+ await ops7.promises.writeFile(resolvedPath, formattedContent, "utf-8");
4444
4482
  return {
4445
4483
  success: true,
4446
4484
  output: `Code formatted in ${filePath}`
@@ -4458,13 +4496,13 @@ var CodeAwareEditorTool = class {
4458
4496
  async addMissingImports(filePath, symbols) {
4459
4497
  try {
4460
4498
  const resolvedPath = path7.resolve(filePath);
4461
- if (!await fs7.pathExists(resolvedPath)) {
4499
+ if (!await pathExists6(resolvedPath)) {
4462
4500
  return {
4463
4501
  success: false,
4464
4502
  error: `File not found: ${filePath}`
4465
4503
  };
4466
4504
  }
4467
- const content = await fs7.readFile(resolvedPath, "utf-8");
4505
+ const content = await ops7.promises.readFile(resolvedPath, "utf-8");
4468
4506
  const language = this.detectLanguage(filePath);
4469
4507
  const context = await this.parseCodeContext(content, language);
4470
4508
  const missingImports = symbols.filter(
@@ -4505,7 +4543,7 @@ ${importsToAdd.join("\n")}`;
4505
4543
  };
4506
4544
  }
4507
4545
  }
4508
- await fs7.writeFile(resolvedPath, newContent, "utf-8");
4546
+ await ops7.promises.writeFile(resolvedPath, newContent, "utf-8");
4509
4547
  return {
4510
4548
  success: true,
4511
4549
  output: `Added ${missingImports.length} missing imports to ${filePath}`
@@ -5200,11 +5238,22 @@ ${extractedCode}`;
5200
5238
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
5201
5239
  }
5202
5240
  };
5241
+ var pathExists7 = async (filePath) => {
5242
+ try {
5243
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
5244
+ return true;
5245
+ } catch {
5246
+ return false;
5247
+ }
5248
+ };
5203
5249
  var OperationHistoryTool = class {
5250
+ history = [];
5251
+ confirmationService = ConfirmationService.getInstance();
5252
+ currentPosition = -1;
5253
+ // For undo/redo navigation
5254
+ options;
5255
+ historyFile;
5204
5256
  constructor(options = {}) {
5205
- this.history = [];
5206
- this.confirmationService = ConfirmationService.getInstance();
5207
- this.currentPosition = -1;
5208
5257
  this.options = {
5209
5258
  maxEntries: 100,
5210
5259
  maxAge: 7 * 24 * 60 * 60 * 1e3,
@@ -5506,15 +5555,15 @@ This action cannot be undone.`
5506
5555
  for (const filePath of files) {
5507
5556
  try {
5508
5557
  const resolvedPath = path7.resolve(filePath);
5509
- const exists = await fs7.pathExists(resolvedPath);
5558
+ const exists = await pathExists7(resolvedPath);
5510
5559
  const snapshot = {
5511
5560
  filePath: resolvedPath,
5512
5561
  existed: exists
5513
5562
  };
5514
5563
  if (exists) {
5515
- const stats = await fs7.stat(resolvedPath);
5564
+ const stats = await ops7.promises.stat(resolvedPath);
5516
5565
  if (stats.isFile() && this.shouldSnapshotFile(resolvedPath)) {
5517
- snapshot.content = await fs7.readFile(resolvedPath, "utf-8");
5566
+ snapshot.content = await ops7.promises.readFile(resolvedPath, "utf-8");
5518
5567
  snapshot.size = stats.size;
5519
5568
  snapshot.lastModified = stats.mtime;
5520
5569
  snapshot.permissions = stats.mode.toString(8);
@@ -5535,7 +5584,7 @@ This action cannot be undone.`
5535
5584
  */
5536
5585
  shouldSnapshotFile(filePath) {
5537
5586
  try {
5538
- const stats = fs7.statSync(filePath);
5587
+ const stats = ops7.statSync(filePath);
5539
5588
  if (stats.size > 1024 * 1024) {
5540
5589
  return false;
5541
5590
  }
@@ -5626,16 +5675,16 @@ This action cannot be undone.`
5626
5675
  const errors = [];
5627
5676
  for (const snapshot of fileSnapshots) {
5628
5677
  try {
5629
- const currentExists = await fs7.pathExists(snapshot.filePath);
5678
+ const currentExists = await pathExists7(snapshot.filePath);
5630
5679
  if (snapshot.existed && snapshot.content !== void 0) {
5631
- await fs7.ensureDir(path7.dirname(snapshot.filePath));
5632
- await fs7.writeFile(snapshot.filePath, snapshot.content, "utf-8");
5680
+ await ops7.ensureDir(path7.dirname(snapshot.filePath));
5681
+ await ops7.promises.writeFile(snapshot.filePath, snapshot.content, "utf-8");
5633
5682
  if (snapshot.permissions) {
5634
- await fs7.chmod(snapshot.filePath, parseInt(snapshot.permissions, 8));
5683
+ await ops7.promises.chmod(snapshot.filePath, parseInt(snapshot.permissions, 8));
5635
5684
  }
5636
5685
  restored.push(`Restored: ${snapshot.filePath}`);
5637
5686
  } else if (!snapshot.existed && currentExists) {
5638
- await fs7.remove(snapshot.filePath);
5687
+ await ops7.promises.rm(snapshot.filePath);
5639
5688
  restored.push(`Removed: ${snapshot.filePath}`);
5640
5689
  }
5641
5690
  } catch (error) {
@@ -5781,8 +5830,8 @@ ${errors.join("\n")}`;
5781
5830
  */
5782
5831
  async loadHistory() {
5783
5832
  try {
5784
- if (await fs7.pathExists(this.historyFile)) {
5785
- const data = await fs7.readFile(this.historyFile, "utf-8");
5833
+ if (await pathExists7(this.historyFile)) {
5834
+ const data = await ops7.promises.readFile(this.historyFile, "utf-8");
5786
5835
  const parsed = JSON.parse(data);
5787
5836
  this.history = parsed.entries.map((entry) => ({
5788
5837
  ...entry,
@@ -5800,13 +5849,13 @@ ${errors.join("\n")}`;
5800
5849
  */
5801
5850
  async saveHistory() {
5802
5851
  try {
5803
- await fs7.ensureDir(path7.dirname(this.historyFile));
5852
+ await ops7.ensureDir(path7.dirname(this.historyFile));
5804
5853
  const data = {
5805
5854
  entries: this.history,
5806
5855
  currentPosition: this.currentPosition,
5807
5856
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
5808
5857
  };
5809
- await fs7.writeFile(this.historyFile, JSON.stringify(data, null, 2), "utf-8");
5858
+ await ops7.promises.writeFile(this.historyFile, JSON.stringify(data, null, 2), "utf-8");
5810
5859
  } catch (error) {
5811
5860
  }
5812
5861
  }
@@ -5834,11 +5883,19 @@ try {
5834
5883
  } catch (error) {
5835
5884
  console.warn("Tree-sitter modules not available, falling back to TypeScript-only parsing");
5836
5885
  }
5886
+ var pathExists8 = async (filePath) => {
5887
+ try {
5888
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
5889
+ return true;
5890
+ } catch {
5891
+ return false;
5892
+ }
5893
+ };
5837
5894
  var ASTParserTool = class {
5895
+ name = "ast_parser";
5896
+ description = "Parse source code files to extract AST, symbols, imports, exports, and structural information";
5897
+ parsers = /* @__PURE__ */ new Map();
5838
5898
  constructor() {
5839
- this.name = "ast_parser";
5840
- this.description = "Parse source code files to extract AST, symbols, imports, exports, and structural information";
5841
- this.parsers = /* @__PURE__ */ new Map();
5842
5899
  this.initializeParsers();
5843
5900
  }
5844
5901
  initializeParsers() {
@@ -5901,10 +5958,10 @@ var ASTParserTool = class {
5901
5958
  if (!filePath) {
5902
5959
  throw new Error("File path is required");
5903
5960
  }
5904
- if (!await fs7__default.pathExists(filePath)) {
5961
+ if (!await pathExists8(filePath)) {
5905
5962
  throw new Error(`File not found: ${filePath}`);
5906
5963
  }
5907
- const content = await fs7__default.readFile(filePath, "utf-8");
5964
+ const content = await ops7.promises.readFile(filePath, "utf-8");
5908
5965
  const language = this.detectLanguage(filePath);
5909
5966
  let result;
5910
5967
  if (language === "typescript" || language === "tsx") {
@@ -6440,13 +6497,14 @@ var ASTParserTool = class {
6440
6497
  }
6441
6498
  };
6442
6499
  var SymbolSearchTool = class {
6500
+ name = "symbol_search";
6501
+ description = "Search for symbols (functions, classes, variables) across the codebase with fuzzy matching and cross-references";
6502
+ astParser;
6503
+ symbolIndex = /* @__PURE__ */ new Map();
6504
+ lastIndexTime = 0;
6505
+ indexCacheDuration = 5 * 60 * 1e3;
6443
6506
  // 5 minutes
6444
6507
  constructor() {
6445
- this.name = "symbol_search";
6446
- this.description = "Search for symbols (functions, classes, variables) across the codebase with fuzzy matching and cross-references";
6447
- this.symbolIndex = /* @__PURE__ */ new Map();
6448
- this.lastIndexTime = 0;
6449
- this.indexCacheDuration = 5 * 60 * 1e3;
6450
6508
  this.astParser = new ASTParserTool();
6451
6509
  }
6452
6510
  async execute(args) {
@@ -6592,7 +6650,7 @@ var SymbolSearchTool = class {
6592
6650
  async findSymbolUsages(symbolRef) {
6593
6651
  const usages = [];
6594
6652
  try {
6595
- const content = await fs7__default.readFile(symbolRef.filePath, "utf-8");
6653
+ const content = await ops7.promises.readFile(symbolRef.filePath, "utf-8");
6596
6654
  const lines = content.split("\n");
6597
6655
  for (let i = 0; i < lines.length; i++) {
6598
6656
  const line = lines[i];
@@ -6647,7 +6705,7 @@ var SymbolSearchTool = class {
6647
6705
  const usageFiles = symbolRef.usages.filter((usage) => usage.type === "reference" || usage.type === "call").map(() => symbolRef.filePath);
6648
6706
  const importedBy = symbolRef.usages.filter((usage) => usage.type === "import").map(() => symbolRef.filePath);
6649
6707
  const exportedTo = symbolRef.usages.filter((usage) => usage.type === "export").map(() => symbolRef.filePath);
6650
- crossRefs.push({
6708
+ crossReops.push({
6651
6709
  symbol: symbolName,
6652
6710
  definitionFile,
6653
6711
  usageFiles: [...new Set(usageFiles)],
@@ -6764,10 +6822,19 @@ var SymbolSearchTool = class {
6764
6822
  };
6765
6823
  }
6766
6824
  };
6825
+ var pathExists9 = async (filePath) => {
6826
+ try {
6827
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
6828
+ return true;
6829
+ } catch {
6830
+ return false;
6831
+ }
6832
+ };
6767
6833
  var DependencyAnalyzerTool = class {
6834
+ name = "dependency_analyzer";
6835
+ description = "Analyze import/export dependencies, detect circular dependencies, and generate dependency graphs";
6836
+ astParser;
6768
6837
  constructor() {
6769
- this.name = "dependency_analyzer";
6770
- this.description = "Analyze import/export dependencies, detect circular dependencies, and generate dependency graphs";
6771
6838
  this.astParser = new ASTParserTool();
6772
6839
  }
6773
6840
  async execute(args) {
@@ -6783,7 +6850,7 @@ var DependencyAnalyzerTool = class {
6783
6850
  entryPoints = [],
6784
6851
  maxDepth = 50
6785
6852
  } = args;
6786
- if (!await fs7__default.pathExists(rootPath)) {
6853
+ if (!await pathExists9(rootPath)) {
6787
6854
  throw new Error(`Root path does not exist: ${rootPath}`);
6788
6855
  }
6789
6856
  const sourceFiles = await this.findSourceFiles(rootPath, filePatterns, excludePatterns);
@@ -6929,7 +6996,7 @@ var DependencyAnalyzerTool = class {
6929
6996
  } else {
6930
6997
  continue;
6931
6998
  }
6932
- if (resolvedPath && await fs7__default.pathExists(resolvedPath)) {
6999
+ if (resolvedPath && await pathExists9(resolvedPath)) {
6933
7000
  dependencies.push(resolvedPath);
6934
7001
  }
6935
7002
  }
@@ -6940,13 +7007,13 @@ var DependencyAnalyzerTool = class {
6940
7007
  const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
6941
7008
  for (const ext of extensions) {
6942
7009
  const fullPath = basePath + ext;
6943
- if (await fs7__default.pathExists(fullPath)) {
7010
+ if (await pathExists9(fullPath)) {
6944
7011
  return fullPath;
6945
7012
  }
6946
7013
  }
6947
7014
  for (const ext of extensions) {
6948
7015
  const indexPath = path7__default.join(basePath, `index${ext}`);
6949
- if (await fs7__default.pathExists(indexPath)) {
7016
+ if (await pathExists9(indexPath)) {
6950
7017
  return indexPath;
6951
7018
  }
6952
7019
  }
@@ -7226,10 +7293,21 @@ var DependencyAnalyzerTool = class {
7226
7293
  };
7227
7294
  }
7228
7295
  };
7296
+ var pathExists10 = async (filePath) => {
7297
+ try {
7298
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
7299
+ return true;
7300
+ } catch {
7301
+ return false;
7302
+ }
7303
+ };
7229
7304
  var CodeContextTool = class {
7305
+ name = "code_context";
7306
+ description = "Build intelligent code context, analyze relationships, and provide semantic understanding";
7307
+ astParser;
7308
+ symbolSearch;
7309
+ dependencyAnalyzer;
7230
7310
  constructor() {
7231
- this.name = "code_context";
7232
- this.description = "Build intelligent code context, analyze relationships, and provide semantic understanding";
7233
7311
  this.astParser = new ASTParserTool();
7234
7312
  this.symbolSearch = new SymbolSearchTool();
7235
7313
  this.dependencyAnalyzer = new DependencyAnalyzerTool();
@@ -7248,7 +7326,7 @@ var CodeContextTool = class {
7248
7326
  if (!filePath) {
7249
7327
  throw new Error("File path is required");
7250
7328
  }
7251
- if (!await fs7__default.pathExists(filePath)) {
7329
+ if (!await pathExists10(filePath)) {
7252
7330
  throw new Error(`File not found: ${filePath}`);
7253
7331
  }
7254
7332
  const context = await this.buildCodeContext(
@@ -7365,7 +7443,7 @@ var CodeContextTool = class {
7365
7443
  async analyzeUsagePatterns(symbol, filePath) {
7366
7444
  const patterns = [];
7367
7445
  try {
7368
- const content = await fs7__default.readFile(filePath, "utf-8");
7446
+ const content = await ops7.promises.readFile(filePath, "utf-8");
7369
7447
  const lines = content.split("\n");
7370
7448
  let callCount = 0;
7371
7449
  let assignmentCount = 0;
@@ -7518,7 +7596,7 @@ var CodeContextTool = class {
7518
7596
  }
7519
7597
  async analyzeSemanticContext(filePath, symbols, dependencies) {
7520
7598
  const fileName = path7__default.basename(filePath);
7521
- const content = await fs7__default.readFile(filePath, "utf-8");
7599
+ const content = await ops7.promises.readFile(filePath, "utf-8");
7522
7600
  const purpose = this.inferPurpose(fileName, symbols, content);
7523
7601
  const domain = this.extractDomain(filePath, symbols, dependencies);
7524
7602
  const patterns = this.detectDesignPatterns(content, symbols);
@@ -7647,7 +7725,7 @@ var CodeContextTool = class {
7647
7725
  };
7648
7726
  }
7649
7727
  async calculateCodeMetrics(filePath, symbols) {
7650
- const content = await fs7__default.readFile(filePath, "utf-8");
7728
+ const content = await ops7.promises.readFile(filePath, "utf-8");
7651
7729
  const lines = content.split("\n");
7652
7730
  const codeLines = lines.filter((line) => line.trim().length > 0 && !line.trim().startsWith("//"));
7653
7731
  const linesOfCode = codeLines.length;
@@ -7745,10 +7823,22 @@ var CodeContextTool = class {
7745
7823
  };
7746
7824
  }
7747
7825
  };
7826
+ var pathExists11 = async (filePath) => {
7827
+ try {
7828
+ await ops7.promises.access(filePath, ops7.constants.F_OK);
7829
+ return true;
7830
+ } catch {
7831
+ return false;
7832
+ }
7833
+ };
7748
7834
  var RefactoringAssistantTool = class {
7835
+ name = "refactoring_assistant";
7836
+ description = "Perform safe code refactoring operations including rename, extract, inline, and move operations";
7837
+ astParser;
7838
+ symbolSearch;
7839
+ multiFileEditor;
7840
+ operationHistory;
7749
7841
  constructor() {
7750
- this.name = "refactoring_assistant";
7751
- this.description = "Perform safe code refactoring operations including rename, extract, inline, and move operations";
7752
7842
  this.astParser = new ASTParserTool();
7753
7843
  this.symbolSearch = new SymbolSearchTool();
7754
7844
  this.multiFileEditor = new MultiFileEditorTool();
@@ -7819,8 +7909,8 @@ var RefactoringAssistantTool = class {
7819
7909
  throw new Error("Failed to find symbol occurrences");
7820
7910
  }
7821
7911
  const symbolRefs = parsed.result.symbols;
7822
- const relevantRefs = scope === "file" && filePath ? symbolRefs.filter((ref) => ref.filePath === filePath) : symbolRefs;
7823
- if (relevantRefs.length === 0) {
7912
+ const relevantRefs = scope === "file" && filePath ? symbolReops.filter((ref) => ref.filePath === filePath) : symbolRefs;
7913
+ if (relevantReops.length === 0) {
7824
7914
  throw new Error(`Symbol '${symbolName}' not found in specified scope`);
7825
7915
  }
7826
7916
  const safety = await this.analyzeSafety(relevantRefs, "rename");
@@ -7856,10 +7946,10 @@ var RefactoringAssistantTool = class {
7856
7946
  if (!filePath || startLine === void 0 || endLine === void 0 || !functionName) {
7857
7947
  throw new Error("File path, line range, and function name are required");
7858
7948
  }
7859
- if (!await fs7__default.pathExists(filePath)) {
7949
+ if (!await pathExists11(filePath)) {
7860
7950
  throw new Error(`File not found: ${filePath}`);
7861
7951
  }
7862
- const content = await fs7__default.readFile(filePath, "utf-8");
7952
+ const content = await ops7.promises.readFile(filePath, "utf-8");
7863
7953
  const lines = content.split("\n");
7864
7954
  if (startLine < 0 || endLine >= lines.length || startLine > endLine) {
7865
7955
  throw new Error("Invalid line range");
@@ -7934,7 +8024,7 @@ var RefactoringAssistantTool = class {
7934
8024
  if (!filePath || !variableName) {
7935
8025
  throw new Error("File path and variable name are required");
7936
8026
  }
7937
- const content = await fs7__default.readFile(filePath, "utf-8");
8027
+ const content = await ops7.promises.readFile(filePath, "utf-8");
7938
8028
  const lines = content.split("\n");
7939
8029
  const startLineContent = lines[startLine];
7940
8030
  const endLineContent = lines[endLine];
@@ -8009,7 +8099,7 @@ var RefactoringAssistantTool = class {
8009
8099
  if (!functionSymbol) {
8010
8100
  throw new Error(`Function '${symbolName}' not found`);
8011
8101
  }
8012
- const content = await fs7__default.readFile(filePath, "utf-8");
8102
+ const content = await ops7.promises.readFile(filePath, "utf-8");
8013
8103
  const lines = content.split("\n");
8014
8104
  const functionLines = lines.slice(functionSymbol.startPosition.row, functionSymbol.endPosition.row + 1);
8015
8105
  const functionBody = this.extractFunctionBody(functionLines.join("\n"));
@@ -8093,8 +8183,8 @@ var RefactoringAssistantTool = class {
8093
8183
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
8094
8184
  }
8095
8185
  async analyzeSafety(refs, operation) {
8096
- const affectedFiles = new Set(refs.map((ref) => ref.filePath)).size;
8097
- const affectedSymbols = refs.length;
8186
+ const affectedFiles = new Set(reops.map((ref) => ref.filePath)).size;
8187
+ const affectedSymbols = reops.length;
8098
8188
  let riskLevel = "low";
8099
8189
  const potentialIssues = [];
8100
8190
  if (affectedFiles > 5) {
@@ -8119,7 +8209,7 @@ var RefactoringAssistantTool = class {
8119
8209
  }
8120
8210
  async generateRenameChanges(ref, oldName, newName, includeComments, includeStrings) {
8121
8211
  const changes = [];
8122
- const content = await fs7__default.readFile(ref.filePath, "utf-8");
8212
+ const content = await ops7.promises.readFile(ref.filePath, "utf-8");
8123
8213
  const lines = content.split("\n");
8124
8214
  for (let i = 0; i < lines.length; i++) {
8125
8215
  const line = lines[i];
@@ -8344,6 +8434,7 @@ ${body}
8344
8434
  }
8345
8435
  };
8346
8436
  var TokenCounter = class {
8437
+ encoder;
8347
8438
  constructor(model = "gpt-4") {
8348
8439
  try {
8349
8440
  this.encoder = encoding_for_model(model);
@@ -8409,10 +8500,10 @@ function createTokenCounter(model) {
8409
8500
  function loadCustomInstructions(workingDirectory = process.cwd()) {
8410
8501
  try {
8411
8502
  const instructionsPath = path7.join(workingDirectory, ".grok", "GROK.md");
8412
- if (!fs.existsSync(instructionsPath)) {
8503
+ if (!ops7.existsSync(instructionsPath)) {
8413
8504
  return null;
8414
8505
  }
8415
- const customInstructions = fs.readFileSync(instructionsPath, "utf-8");
8506
+ const customInstructions = ops7.readFileSync(instructionsPath, "utf-8");
8416
8507
  return customInstructions.trim();
8417
8508
  } catch (error) {
8418
8509
  console.warn("Failed to load custom instructions:", error);
@@ -8423,12 +8514,33 @@ function loadCustomInstructions(workingDirectory = process.cwd()) {
8423
8514
  // src/agent/grok-agent.ts
8424
8515
  init_settings_manager();
8425
8516
  var GrokAgent = class extends EventEmitter {
8517
+ grokClient;
8518
+ textEditor;
8519
+ morphEditor;
8520
+ bash;
8521
+ todoTool;
8522
+ confirmationTool;
8523
+ search;
8524
+ // Advanced tools
8525
+ multiFileEditor;
8526
+ advancedSearch;
8527
+ fileTreeOps;
8528
+ codeAwareEditor;
8529
+ operationHistory;
8530
+ // Intelligence tools
8531
+ astParser;
8532
+ symbolSearch;
8533
+ dependencyAnalyzer;
8534
+ codeContext;
8535
+ refactoringAssistant;
8536
+ chatHistory = [];
8537
+ messages = [];
8538
+ tokenCounter;
8539
+ abortController = null;
8540
+ mcpInitialized = false;
8541
+ maxToolRounds;
8426
8542
  constructor(apiKey, baseURL, model, maxToolRounds) {
8427
8543
  super();
8428
- this.chatHistory = [];
8429
- this.messages = [];
8430
- this.abortController = null;
8431
- this.mcpInitialized = false;
8432
8544
  const manager = getSettingsManager();
8433
8545
  const savedModel = manager.getCurrentModel();
8434
8546
  const modelToUse = model || savedModel || "grok-code-fast-1";
@@ -9130,7 +9242,7 @@ EOF`;
9130
9242
 
9131
9243
  // package.json
9132
9244
  var package_default = {
9133
- version: "1.0.25"};
9245
+ version: "1.0.27"};
9134
9246
 
9135
9247
  // src/utils/text-utils.ts
9136
9248
  function isWordBoundary(char) {
@@ -9525,7 +9637,7 @@ var ClaudeMdParserImpl = class {
9525
9637
  };
9526
9638
  }
9527
9639
  try {
9528
- const content = await fs17.readFile(claudePath, "utf-8");
9640
+ const content = await ops.promises.readFile(claudePath, "utf-8");
9529
9641
  const hasDocumentationSection = content.includes("Documentation System Workflow") || content.includes(".agent documentation system");
9530
9642
  return {
9531
9643
  exists: true,
@@ -9560,7 +9672,7 @@ This document provides context and instructions for Claude Code when working wit
9560
9672
 
9561
9673
  ${documentationSection}`;
9562
9674
  }
9563
- await fs17.writeFile(claudePath, newContent);
9675
+ await ops.promises.writeFile(claudePath, newContent);
9564
9676
  return {
9565
9677
  success: true,
9566
9678
  message: exists ? "\u2705 Updated existing CLAUDE.md with documentation system instructions" : "\u2705 Created CLAUDE.md with documentation system instructions"
@@ -9613,6 +9725,7 @@ var claudeMdParser = new ClaudeMdParserImpl();
9613
9725
 
9614
9726
  // src/tools/documentation/agent-system-generator.ts
9615
9727
  var AgentSystemGenerator = class {
9728
+ config;
9616
9729
  constructor(config2) {
9617
9730
  this.config = config2;
9618
9731
  }
@@ -9627,15 +9740,15 @@ var AgentSystemGenerator = class {
9627
9740
  filesCreated: []
9628
9741
  };
9629
9742
  }
9630
- await fs17.mkdir(agentPath, { recursive: true });
9631
- await fs17.mkdir(path7__default.join(agentPath, "system"), { recursive: true });
9632
- await fs17.mkdir(path7__default.join(agentPath, "tasks"), { recursive: true });
9633
- await fs17.mkdir(path7__default.join(agentPath, "sop"), { recursive: true });
9634
- await fs17.mkdir(path7__default.join(agentPath, "incidents"), { recursive: true });
9635
- await fs17.mkdir(path7__default.join(agentPath, "guardrails"), { recursive: true });
9636
- await fs17.mkdir(path7__default.join(agentPath, "commands"), { recursive: true });
9743
+ await ops.mkdir(agentPath, { recursive: true });
9744
+ await ops.mkdir(path7__default.join(agentPath, "system"), { recursive: true });
9745
+ await ops.mkdir(path7__default.join(agentPath, "tasks"), { recursive: true });
9746
+ await ops.mkdir(path7__default.join(agentPath, "sop"), { recursive: true });
9747
+ await ops.mkdir(path7__default.join(agentPath, "incidents"), { recursive: true });
9748
+ await ops.mkdir(path7__default.join(agentPath, "guardrails"), { recursive: true });
9749
+ await ops.mkdir(path7__default.join(agentPath, "commands"), { recursive: true });
9637
9750
  const readmeContent = this.generateReadmeContent();
9638
- await fs17.writeFile(path7__default.join(agentPath, "README.md"), readmeContent);
9751
+ await ops.promises.writeFile(path7__default.join(agentPath, "README.md"), readmeContent);
9639
9752
  filesCreated.push(".agent/README.md");
9640
9753
  const systemFiles = await this.generateSystemDocs(agentPath);
9641
9754
  filesCreated.push(...systemFiles);
@@ -9745,13 +9858,13 @@ Documentation for documentation system commands:
9745
9858
  const systemPath = path7__default.join(agentPath, "system");
9746
9859
  const files = [];
9747
9860
  const archContent = this.config.projectType === "grok-cli" ? this.generateGrokArchitecture() : this.generateExternalArchitecture();
9748
- await fs17.writeFile(path7__default.join(systemPath, "architecture.md"), archContent);
9861
+ await ops.promises.writeFile(path7__default.join(systemPath, "architecture.md"), archContent);
9749
9862
  files.push(".agent/system/architecture.md");
9750
9863
  const criticalStateContent = this.generateCriticalState();
9751
- await fs17.writeFile(path7__default.join(systemPath, "critical-state.md"), criticalStateContent);
9864
+ await ops.promises.writeFile(path7__default.join(systemPath, "critical-state.md"), criticalStateContent);
9752
9865
  files.push(".agent/system/critical-state.md");
9753
9866
  const apiContent = this.generateApiSchema();
9754
- await fs17.writeFile(path7__default.join(systemPath, "api-schema.md"), apiContent);
9867
+ await ops.promises.writeFile(path7__default.join(systemPath, "api-schema.md"), apiContent);
9755
9868
  files.push(".agent/system/api-schema.md");
9756
9869
  return files;
9757
9870
  }
@@ -10108,7 +10221,7 @@ interface Tool {
10108
10221
 
10109
10222
  *Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
10110
10223
  `;
10111
- await fs17.writeFile(path7__default.join(sopPath, "documentation-workflow.md"), docWorkflowContent);
10224
+ await ops.promises.writeFile(path7__default.join(sopPath, "documentation-workflow.md"), docWorkflowContent);
10112
10225
  files.push(".agent/sop/documentation-workflow.md");
10113
10226
  if (this.config.projectType === "grok-cli") {
10114
10227
  const newCommandContent = `# \u2699\uFE0F Adding New Commands SOP
@@ -10183,7 +10296,7 @@ Create tool in \`src/tools/\`, then reference in command handler.
10183
10296
 
10184
10297
  *Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
10185
10298
  `;
10186
- await fs17.writeFile(path7__default.join(sopPath, "adding-new-command.md"), newCommandContent);
10299
+ await ops.promises.writeFile(path7__default.join(sopPath, "adding-new-command.md"), newCommandContent);
10187
10300
  files.push(".agent/sop/adding-new-command.md");
10188
10301
  }
10189
10302
  return files;
@@ -10192,7 +10305,7 @@ Create tool in \`src/tools/\`, then reference in command handler.
10192
10305
  const tasksPath = path7__default.join(agentPath, "tasks");
10193
10306
  const files = [];
10194
10307
  const exampleContent = this.config.projectType === "grok-cli" ? this.generateGrokExampleTask() : this.generateExternalExampleTask();
10195
- await fs17.writeFile(path7__default.join(tasksPath, "example-prd.md"), exampleContent);
10308
+ await ops.promises.writeFile(path7__default.join(tasksPath, "example-prd.md"), exampleContent);
10196
10309
  files.push(".agent/tasks/example-prd.md");
10197
10310
  return files;
10198
10311
  }
@@ -10384,7 +10497,7 @@ After initialization:
10384
10497
 
10385
10498
  *Updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}*
10386
10499
  `;
10387
- await fs17.writeFile(path7__default.join(commandsPath, "init-agent.md"), initAgentContent);
10500
+ await ops.promises.writeFile(path7__default.join(commandsPath, "init-agent.md"), initAgentContent);
10388
10501
  files.push(".agent/commands/init-agent.md");
10389
10502
  return files;
10390
10503
  }
@@ -10392,7 +10505,7 @@ After initialization:
10392
10505
  const agentPath = path7__default.join(this.config.rootPath, ".agent");
10393
10506
  try {
10394
10507
  if (existsSync(agentPath)) {
10395
- await fs17.rm(agentPath, { recursive: true, force: true });
10508
+ await ops.rm(agentPath, { recursive: true, force: true });
10396
10509
  }
10397
10510
  return await this.generateAgentSystem();
10398
10511
  } catch (error) {
@@ -10463,6 +10576,7 @@ function findDocsMenuOption(input) {
10463
10576
  return DOCS_MENU_OPTIONS.find((option) => option.key === trimmed) || null;
10464
10577
  }
10465
10578
  var ReadmeGenerator = class {
10579
+ config;
10466
10580
  constructor(config2) {
10467
10581
  this.config = config2;
10468
10582
  }
@@ -10478,7 +10592,7 @@ var ReadmeGenerator = class {
10478
10592
  };
10479
10593
  }
10480
10594
  const content = this.generateReadmeContent(analysis);
10481
- await fs17.writeFile(readmePath, content);
10595
+ await ops.promises.writeFile(readmePath, content);
10482
10596
  return {
10483
10597
  success: true,
10484
10598
  message: readmeExists ? "\u2705 Updated existing README.md with comprehensive documentation" : "\u2705 Created new README.md with project documentation",
@@ -10505,7 +10619,7 @@ var ReadmeGenerator = class {
10505
10619
  try {
10506
10620
  const packagePath = path7__default.join(this.config.rootPath, "package.json");
10507
10621
  if (existsSync(packagePath)) {
10508
- const packageContent = await fs17.readFile(packagePath, "utf-8");
10622
+ const packageContent = await ops.promises.readFile(packagePath, "utf-8");
10509
10623
  analysis.packageJson = JSON.parse(packageContent);
10510
10624
  analysis.dependencies = Object.keys(analysis.packageJson.dependencies || {});
10511
10625
  analysis.devDependencies = Object.keys(analysis.packageJson.devDependencies || {});
@@ -10784,6 +10898,7 @@ TypeScript is configured via \`tsconfig.json\`.
10784
10898
  }
10785
10899
  };
10786
10900
  var CommentsGenerator = class {
10901
+ config;
10787
10902
  constructor(config2) {
10788
10903
  this.config = config2;
10789
10904
  }
@@ -10795,7 +10910,7 @@ var CommentsGenerator = class {
10795
10910
  message: "File not found"
10796
10911
  };
10797
10912
  }
10798
- const content = await fs17.readFile(this.config.filePath, "utf-8");
10913
+ const content = await ops.promises.readFile(this.config.filePath, "utf-8");
10799
10914
  const analysis = this.analyzeCode(content);
10800
10915
  if (analysis.hasExistingComments) {
10801
10916
  return {
@@ -10805,8 +10920,8 @@ var CommentsGenerator = class {
10805
10920
  }
10806
10921
  const modifiedContent = this.addComments(content, analysis);
10807
10922
  const backupPath = this.config.filePath + ".backup";
10808
- await fs17.writeFile(backupPath, content);
10809
- await fs17.writeFile(this.config.filePath, modifiedContent);
10923
+ await ops.promises.writeFile(backupPath, content);
10924
+ await ops.promises.writeFile(this.config.filePath, modifiedContent);
10810
10925
  const commentCount = this.countAddedComments(analysis);
10811
10926
  return {
10812
10927
  success: true,
@@ -11006,6 +11121,7 @@ var CommentsGenerator = class {
11006
11121
  }
11007
11122
  };
11008
11123
  var ApiDocsGenerator = class {
11124
+ config;
11009
11125
  constructor(config2) {
11010
11126
  this.config = config2;
11011
11127
  }
@@ -11021,7 +11137,7 @@ var ApiDocsGenerator = class {
11021
11137
  const content = this.config.outputFormat === "md" ? this.generateMarkdown(documentation) : this.generateHtml(documentation);
11022
11138
  const outputFileName = `api-docs.${this.config.outputFormat}`;
11023
11139
  const outputPath = path7__default.join(this.config.rootPath, outputFileName);
11024
- await fs17.writeFile(outputPath, content);
11140
+ await ops.promises.writeFile(outputPath, content);
11025
11141
  const stats = this.getDocumentationStats(documentation);
11026
11142
  return {
11027
11143
  success: true,
@@ -11057,7 +11173,7 @@ ${stats}`,
11057
11173
  }
11058
11174
  async scanDirectory(dirPath, documentation) {
11059
11175
  try {
11060
- const entries = await fs17.readdir(dirPath, { withFileTypes: true });
11176
+ const entries = await ops.promises.readdir(dirPath, { withFileTypes: true });
11061
11177
  for (const entry of entries) {
11062
11178
  const fullPath = path7__default.join(dirPath, entry.name);
11063
11179
  if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
@@ -11076,7 +11192,7 @@ ${stats}`,
11076
11192
  }
11077
11193
  async parseApiFile(filePath, documentation) {
11078
11194
  try {
11079
- const content = await fs17.readFile(filePath, "utf-8");
11195
+ const content = await ops.promises.readFile(filePath, "utf-8");
11080
11196
  const relativePath = path7__default.relative(this.config.rootPath, filePath);
11081
11197
  const moduleName = this.getModuleName(relativePath);
11082
11198
  const lines = content.split("\n");
@@ -11378,6 +11494,7 @@ type ${type.name} = ${type.definition}
11378
11494
  }
11379
11495
  };
11380
11496
  var ChangelogGenerator = class {
11497
+ config;
11381
11498
  constructor(config2) {
11382
11499
  this.config = config2;
11383
11500
  }
@@ -11402,12 +11519,12 @@ var ChangelogGenerator = class {
11402
11519
  const changelogPath = path7__default.join(this.config.rootPath, "CHANGELOG.md");
11403
11520
  const exists = existsSync(changelogPath);
11404
11521
  if (exists) {
11405
- const existingContent = await fs17.readFile(changelogPath, "utf-8");
11522
+ const existingContent = await ops.promises.readFile(changelogPath, "utf-8");
11406
11523
  const newContent = content + "\n\n" + existingContent;
11407
- await fs17.writeFile(changelogPath, newContent);
11524
+ await ops.promises.writeFile(changelogPath, newContent);
11408
11525
  } else {
11409
11526
  const fullContent = this.generateChangelogHeader() + content;
11410
- await fs17.writeFile(changelogPath, fullContent);
11527
+ await ops.promises.writeFile(changelogPath, fullContent);
11411
11528
  }
11412
11529
  return {
11413
11530
  success: true,
@@ -11606,6 +11723,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11606
11723
  }
11607
11724
  };
11608
11725
  var UpdateAgentDocs = class {
11726
+ config;
11609
11727
  constructor(config2) {
11610
11728
  this.config = config2;
11611
11729
  }
@@ -11698,13 +11816,13 @@ var UpdateAgentDocs = class {
11698
11816
  const recentFiles = [];
11699
11817
  const scanDir = async (dirPath) => {
11700
11818
  try {
11701
- const entries = await fs17.readdir(dirPath, { withFileTypes: true });
11819
+ const entries = await ops.promises.readdir(dirPath, { withFileTypes: true });
11702
11820
  for (const entry of entries) {
11703
11821
  const fullPath = path7__default.join(dirPath, entry.name);
11704
11822
  if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
11705
11823
  await scanDir(fullPath);
11706
11824
  } else if (entry.isFile()) {
11707
- const stats = await fs17.stat(fullPath);
11825
+ const stats = await ops.promises.stat(fullPath);
11708
11826
  if (stats.mtime.getTime() > oneDayAgo) {
11709
11827
  recentFiles.push(path7__default.relative(this.config.rootPath, fullPath));
11710
11828
  }
@@ -11760,9 +11878,9 @@ var UpdateAgentDocs = class {
11760
11878
  try {
11761
11879
  const archPath = path7__default.join(systemPath, "architecture.md");
11762
11880
  if (existsSync(archPath)) {
11763
- const content = await fs17.readFile(archPath, "utf-8");
11881
+ const content = await ops.promises.readFile(archPath, "utf-8");
11764
11882
  const updatedContent = await this.updateArchitectureDoc(content, analysis);
11765
- await fs17.writeFile(archPath, updatedContent);
11883
+ await ops.promises.writeFile(archPath, updatedContent);
11766
11884
  updatedFiles.push(".agent/system/architecture.md");
11767
11885
  }
11768
11886
  } catch (error) {
@@ -11776,7 +11894,7 @@ var UpdateAgentDocs = class {
11776
11894
  if (!existsSync(criticalStatePath)) {
11777
11895
  return false;
11778
11896
  }
11779
- const content = await fs17.readFile(criticalStatePath, "utf-8");
11897
+ const content = await ops.promises.readFile(criticalStatePath, "utf-8");
11780
11898
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
11781
11899
  const changesSummary = this.generateChangesSummary(analysis);
11782
11900
  let updatedContent = content.replace(
@@ -11801,7 +11919,7 @@ Updated By: /update-agent-docs after detecting changes${recentChangesSection}`
11801
11919
  );
11802
11920
  }
11803
11921
  }
11804
- await fs17.writeFile(criticalStatePath, updatedContent);
11922
+ await ops.promises.writeFile(criticalStatePath, updatedContent);
11805
11923
  return true;
11806
11924
  } catch (error) {
11807
11925
  return false;
@@ -11891,10 +12009,10 @@ Updated By: /update-agent-docs after detecting changes${recentChangesSection}`
11891
12009
 
11892
12010
  // src/subagents/subagent-framework.ts
11893
12011
  var SubagentFramework = class {
12012
+ activeTasks = /* @__PURE__ */ new Map();
12013
+ results = /* @__PURE__ */ new Map();
12014
+ configs = /* @__PURE__ */ new Map();
11894
12015
  constructor() {
11895
- this.activeTasks = /* @__PURE__ */ new Map();
11896
- this.results = /* @__PURE__ */ new Map();
11897
- this.configs = /* @__PURE__ */ new Map();
11898
12016
  this.initializeConfigs();
11899
12017
  }
11900
12018
  initializeConfigs() {
@@ -12233,6 +12351,9 @@ This is a generated document for ${projectPath}.
12233
12351
  }
12234
12352
  };
12235
12353
  var SelfHealingSystem = class {
12354
+ rootPath;
12355
+ agentPath;
12356
+ config;
12236
12357
  constructor(rootPath, config2) {
12237
12358
  this.rootPath = rootPath;
12238
12359
  this.agentPath = path7__default.join(rootPath, ".agent");
@@ -12248,9 +12369,9 @@ var SelfHealingSystem = class {
12248
12369
  try {
12249
12370
  const incident = await this.analyzeAndCreateIncident(error, context);
12250
12371
  const incidentPath = path7__default.join(this.agentPath, "incidents", `${incident.id}.md`);
12251
- await fs17.mkdir(path7__default.dirname(incidentPath), { recursive: true });
12372
+ await ops.mkdir(path7__default.dirname(incidentPath), { recursive: true });
12252
12373
  const incidentContent = this.generateIncidentContent(incident);
12253
- await fs17.writeFile(incidentPath, incidentContent);
12374
+ await ops.promises.writeFile(incidentPath, incidentContent);
12254
12375
  const guardrail = await this.generateGuardrailFromIncident(incident);
12255
12376
  if (guardrail) {
12256
12377
  await this.saveGuardrail(guardrail);
@@ -12380,12 +12501,12 @@ ${guardrail ? `\u{1F6E1}\uFE0F Guardrail created: ${guardrail.name}` : ""}
12380
12501
  if (!existsSync(incidentsPath)) {
12381
12502
  return 0;
12382
12503
  }
12383
- const files = await fs17.readdir(incidentsPath);
12504
+ const files = await ops.promises.readdir(incidentsPath);
12384
12505
  let count = 0;
12385
12506
  for (const file of files) {
12386
12507
  if (file.endsWith(".md")) {
12387
12508
  const filePath = path7__default.join(incidentsPath, file);
12388
- const content = await fs17.readFile(filePath, "utf-8");
12509
+ const content = await ops.promises.readFile(filePath, "utf-8");
12389
12510
  if (content.includes(title)) {
12390
12511
  count++;
12391
12512
  }
@@ -12478,10 +12599,10 @@ ${incident.guardrailCreated ? `Guardrail created: ${incident.guardrailCreated}`
12478
12599
  }
12479
12600
  async saveGuardrail(guardrail) {
12480
12601
  const guardrailsPath = path7__default.join(this.agentPath, "guardrails");
12481
- await fs17.mkdir(guardrailsPath, { recursive: true });
12602
+ await ops.mkdir(guardrailsPath, { recursive: true });
12482
12603
  const filePath = path7__default.join(guardrailsPath, `${guardrail.id}.md`);
12483
12604
  const content = this.generateGuardrailContent(guardrail);
12484
- await fs17.writeFile(filePath, content);
12605
+ await ops.promises.writeFile(filePath, content);
12485
12606
  }
12486
12607
  generateGuardrailContent(guardrail) {
12487
12608
  return `# ${guardrail.name}
@@ -12540,12 +12661,12 @@ ${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` :
12540
12661
  if (!existsSync(guardrailsPath)) {
12541
12662
  return [];
12542
12663
  }
12543
- const files = await fs17.readdir(guardrailsPath);
12664
+ const files = await ops.promises.readdir(guardrailsPath);
12544
12665
  const guardrails = [];
12545
12666
  for (const file of files) {
12546
12667
  if (file.endsWith(".md")) {
12547
12668
  try {
12548
- const content = await fs17.readFile(path7__default.join(guardrailsPath, file), "utf-8");
12669
+ const content = await ops.promises.readFile(path7__default.join(guardrailsPath, file), "utf-8");
12549
12670
  const guardrail = this.parseGuardrailFromContent(content);
12550
12671
  if (guardrail) {
12551
12672
  guardrails.push(guardrail);
@@ -12605,12 +12726,12 @@ ${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` :
12605
12726
  if (!existsSync(incidentsPath)) {
12606
12727
  return [];
12607
12728
  }
12608
- const files = await fs17.readdir(incidentsPath);
12729
+ const files = await ops.promises.readdir(incidentsPath);
12609
12730
  const incidents = [];
12610
12731
  for (const file of files) {
12611
12732
  if (file.endsWith(".md")) {
12612
12733
  try {
12613
- const content = await fs17.readFile(path7__default.join(incidentsPath, file), "utf-8");
12734
+ const content = await ops.promises.readFile(path7__default.join(incidentsPath, file), "utf-8");
12614
12735
  const incident = this.parseIncidentFromContent(content);
12615
12736
  if (incident) {
12616
12737
  incidents.push(incident);
@@ -14964,6 +15085,10 @@ function createMCPCommand() {
14964
15085
  return mcpCommand;
14965
15086
  }
14966
15087
 
15088
+ // package.json with { type: 'json' }
15089
+ var package_default2 = {
15090
+ version: "1.0.27"};
15091
+
14967
15092
  // src/index.ts
14968
15093
  dotenv.config();
14969
15094
  process.on("SIGTERM", () => {
@@ -15163,7 +15288,7 @@ async function processPromptHeadless(prompt, apiKey, baseURL, model, maxToolRoun
15163
15288
  }
15164
15289
  program.name("grok").description(
15165
15290
  "A conversational AI CLI tool powered by Grok with text editor capabilities"
15166
- ).version(package_default.version).argument("[message...]", "Initial message to send to Grok").option("-d, --directory <dir>", "set working directory", process.cwd()).option("-k, --api-key <key>", "Grok API key (or set GROK_API_KEY env var)").option(
15291
+ ).version(package_default2.version).argument("[message...]", "Initial message to send to Grok").option("-d, --directory <dir>", "set working directory", process.cwd()).option("-k, --api-key <key>", "Grok API key (or set GROK_API_KEY env var)").option(
15167
15292
  "-u, --base-url <url>",
15168
15293
  "Grok API base URL (or set GROK_BASE_URL env var)"
15169
15294
  ).option(