mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
Migrate console to coreEvents.emitFeedback or debugLogger (#15219)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user