@@ -8,7 +8,6 @@ import fs from 'node:fs';
88import path from 'node:path' ;
99import { EOL } from 'node:os' ;
1010import { spawn } from 'node:child_process' ;
11- import { rgPath } from '@lvce-editor/ripgrep' ;
1211import type { ToolInvocation , ToolResult } from './tools.js' ;
1312import { BaseDeclarativeTool , BaseToolInvocation , Kind } from './tools.js' ;
1413import { SchemaValidator } from '../utils/schemaValidator.js' ;
@@ -18,6 +17,14 @@ import type { Config } from '../config/config.js';
1817
1918const DEFAULT_TOTAL_MAX_MATCHES = 20000 ;
2019
20+ /**
21+ * Lazy loads the ripgrep binary path to avoid loading the library until needed
22+ */
23+ async function getRipgrepPath ( ) : Promise < string > {
24+ const { rgPath } = await import ( '@lvce-editor/ripgrep' ) ;
25+ return rgPath ;
26+ }
27+
2128/**
2229 * Parameters for the GrepTool
2330 */
@@ -292,8 +299,9 @@ class GrepToolInvocation extends BaseToolInvocation<
292299 rgArgs . push ( absolutePath ) ;
293300
294301 try {
302+ const ripgrepPath = await getRipgrepPath ( ) ;
295303 const output = await new Promise < string > ( ( resolve , reject ) => {
296- const child = spawn ( rgPath , rgArgs , {
304+ const child = spawn ( ripgrepPath , rgArgs , {
297305 windowsHide : true ,
298306 } ) ;
299307
0 commit comments