Migrate console to coreEvents.emitFeedback or debugLogger (#15219)

This commit is contained in:
Adib234
2025-12-29 15:46:10 -05:00
committed by GitHub
parent dcd2449b1a
commit 10ae84869a
66 changed files with 564 additions and 425 deletions
+11 -6
View File
@@ -10,7 +10,7 @@ import toml from '@iarna/toml';
import { glob } from 'glob';
import { z } from 'zod';
import type { Config } from '@google/gemini-cli-core';
import { Storage } from '@google/gemini-cli-core';
import { Storage, coreEvents } from '@google/gemini-cli-core';
import type { ICommandLoader } from './types.js';
import type {
CommandContext,
@@ -126,7 +126,8 @@ export class FileCommandLoader implements ICommandLoader {
!signal.aborted &&
(error as { code?: string })?.code !== 'ENOENT'
) {
console.error(
coreEvents.emitFeedback(
'error',
`[FileCommandLoader] Error loading commands from ${dirInfo.path}:`,
error,
);
@@ -189,7 +190,8 @@ export class FileCommandLoader implements ICommandLoader {
try {
fileContent = await fs.readFile(filePath, 'utf-8');
} catch (error: unknown) {
console.error(
coreEvents.emitFeedback(
'error',
`[FileCommandLoader] Failed to read file ${filePath}:`,
error instanceof Error ? error.message : String(error),
);
@@ -200,7 +202,8 @@ export class FileCommandLoader implements ICommandLoader {
try {
parsed = toml.parse(fileContent);
} catch (error: unknown) {
console.error(
coreEvents.emitFeedback(
'error',
`[FileCommandLoader] Failed to parse TOML file ${filePath}:`,
error instanceof Error ? error.message : String(error),
);
@@ -210,7 +213,8 @@ export class FileCommandLoader implements ICommandLoader {
const validationResult = TomlCommandDefSchema.safeParse(parsed);
if (!validationResult.success) {
console.error(
coreEvents.emitFeedback(
'error',
`[FileCommandLoader] Skipping invalid command file: ${filePath}. Validation errors:`,
validationResult.error.flatten(),
);
@@ -278,7 +282,8 @@ export class FileCommandLoader implements ICommandLoader {
_args: string,
): Promise<SlashCommandActionReturn> => {
if (!context.invocation) {
console.error(
coreEvents.emitFeedback(
'error',
`[FileCommandLoader] Critical error: Command '${baseCommandName}' was executed without invocation context.`,
);
return {