@@ -10,7 +10,7 @@ import toml from '@iarna/toml';
1010import { glob } from 'glob' ;
1111import { z } from 'zod' ;
1212import type { Config } from '@google/gemini-cli-core' ;
13- import { Storage } from '@google/gemini-cli-core' ;
13+ import { Storage , coreEvents } from '@google/gemini-cli-core' ;
1414import type { ICommandLoader } from './types.js' ;
1515import type {
1616 CommandContext ,
@@ -126,7 +126,8 @@ export class FileCommandLoader implements ICommandLoader {
126126 ! signal . aborted &&
127127 ( error as { code ?: string } ) ?. code !== 'ENOENT'
128128 ) {
129- console . error (
129+ coreEvents . emitFeedback (
130+ 'error' ,
130131 `[FileCommandLoader] Error loading commands from ${ dirInfo . path } :` ,
131132 error ,
132133 ) ;
@@ -189,7 +190,8 @@ export class FileCommandLoader implements ICommandLoader {
189190 try {
190191 fileContent = await fs . readFile ( filePath , 'utf-8' ) ;
191192 } catch ( error : unknown ) {
192- console . error (
193+ coreEvents . emitFeedback (
194+ 'error' ,
193195 `[FileCommandLoader] Failed to read file ${ filePath } :` ,
194196 error instanceof Error ? error . message : String ( error ) ,
195197 ) ;
@@ -200,7 +202,8 @@ export class FileCommandLoader implements ICommandLoader {
200202 try {
201203 parsed = toml . parse ( fileContent ) ;
202204 } catch ( error : unknown ) {
203- console . error (
205+ coreEvents . emitFeedback (
206+ 'error' ,
204207 `[FileCommandLoader] Failed to parse TOML file ${ filePath } :` ,
205208 error instanceof Error ? error . message : String ( error ) ,
206209 ) ;
@@ -210,7 +213,8 @@ export class FileCommandLoader implements ICommandLoader {
210213 const validationResult = TomlCommandDefSchema . safeParse ( parsed ) ;
211214
212215 if ( ! validationResult . success ) {
213- console . error (
216+ coreEvents . emitFeedback (
217+ 'error' ,
214218 `[FileCommandLoader] Skipping invalid command file: ${ filePath } . Validation errors:` ,
215219 validationResult . error . flatten ( ) ,
216220 ) ;
@@ -278,7 +282,8 @@ export class FileCommandLoader implements ICommandLoader {
278282 _args : string ,
279283 ) : Promise < SlashCommandActionReturn > => {
280284 if ( ! context . invocation ) {
281- console . error (
285+ coreEvents . emitFeedback (
286+ 'error' ,
282287 `[FileCommandLoader] Critical error: Command '${ baseCommandName } ' was executed without invocation context.` ,
283288 ) ;
284289 return {
0 commit comments