mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Polish: Move 'Failed to load skills' warning to debug logs (#16142)
This commit is contained in:
@@ -12,7 +12,7 @@ import { ExtensionManager } from './extension-manager.js';
|
|||||||
import { loadSettings } from './settings.js';
|
import { loadSettings } from './settings.js';
|
||||||
import { createExtension } from '../test-utils/createExtension.js';
|
import { createExtension } from '../test-utils/createExtension.js';
|
||||||
import { EXTENSIONS_DIRECTORY_NAME } from './extensions/variables.js';
|
import { EXTENSIONS_DIRECTORY_NAME } from './extensions/variables.js';
|
||||||
import { coreEvents } from '@google/gemini-cli-core';
|
import { coreEvents, debugLogger } from '@google/gemini-cli-core';
|
||||||
|
|
||||||
const mockHomedir = vi.hoisted(() => vi.fn());
|
const mockHomedir = vi.hoisted(() => vi.fn());
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ describe('ExtensionManager skills validation', () => {
|
|||||||
settings: loadSettings(tempWorkspaceDir).merged,
|
settings: loadSettings(tempWorkspaceDir).merged,
|
||||||
});
|
});
|
||||||
vi.spyOn(coreEvents, 'emitFeedback');
|
vi.spyOn(coreEvents, 'emitFeedback');
|
||||||
|
vi.spyOn(debugLogger, 'debug').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -83,8 +84,7 @@ describe('ExtensionManager skills validation', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(extension.name).toBe('skills-ext');
|
expect(extension.name).toBe('skills-ext');
|
||||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
expect(debugLogger.debug).toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining('Failed to load skills from'),
|
expect.stringContaining('Failed to load skills from'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -102,12 +102,10 @@ describe('ExtensionManager skills validation', () => {
|
|||||||
|
|
||||||
await extensionManager.loadExtensions();
|
await extensionManager.loadExtensions();
|
||||||
|
|
||||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
expect(debugLogger.debug).toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining('Failed to load skills from'),
|
expect.stringContaining('Failed to load skills from'),
|
||||||
);
|
);
|
||||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
expect(debugLogger.debug).toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining(
|
expect.stringContaining(
|
||||||
'The directory is not empty but no valid skills were discovered',
|
'The directory is not empty but no valid skills were discovered',
|
||||||
),
|
),
|
||||||
@@ -139,8 +137,7 @@ describe('ExtensionManager skills validation', () => {
|
|||||||
expect(extension.skills![0].name).toBe('test-skill');
|
expect(extension.skills![0].name).toBe('test-skill');
|
||||||
// It might be called for other reasons during startup, but shouldn't be called for our skills loading success
|
// It might be called for other reasons during startup, but shouldn't be called for our skills loading success
|
||||||
// Actually, it shouldn't be called with our warning message
|
// Actually, it shouldn't be called with our warning message
|
||||||
expect(coreEvents.emitFeedback).not.toHaveBeenCalledWith(
|
expect(debugLogger.debug).not.toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining('Failed to load skills from'),
|
expect.stringContaining('Failed to load skills from'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import * as os from 'node:os';
|
|||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { loadSkillsFromDir } from './skillLoader.js';
|
import { loadSkillsFromDir } from './skillLoader.js';
|
||||||
import { coreEvents } from '../utils/events.js';
|
import { coreEvents } from '../utils/events.js';
|
||||||
|
import { debugLogger } from '../utils/debugLogger.js';
|
||||||
|
|
||||||
describe('skillLoader', () => {
|
describe('skillLoader', () => {
|
||||||
let testRootDir: string;
|
let testRootDir: string;
|
||||||
@@ -19,6 +20,7 @@ describe('skillLoader', () => {
|
|||||||
path.join(os.tmpdir(), 'skill-loader-test-'),
|
path.join(os.tmpdir(), 'skill-loader-test-'),
|
||||||
);
|
);
|
||||||
vi.spyOn(coreEvents, 'emitFeedback');
|
vi.spyOn(coreEvents, 'emitFeedback');
|
||||||
|
vi.spyOn(debugLogger, 'debug').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -53,8 +55,7 @@ describe('skillLoader', () => {
|
|||||||
const skills = await loadSkillsFromDir(testRootDir);
|
const skills = await loadSkillsFromDir(testRootDir);
|
||||||
|
|
||||||
expect(skills).toHaveLength(0);
|
expect(skills).toHaveLength(0);
|
||||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
expect(debugLogger.debug).toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining('Failed to load skills from'),
|
expect.stringContaining('Failed to load skills from'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -89,8 +90,7 @@ describe('skillLoader', () => {
|
|||||||
const skills = await loadSkillsFromDir(testRootDir);
|
const skills = await loadSkillsFromDir(testRootDir);
|
||||||
|
|
||||||
expect(skills).toHaveLength(0);
|
expect(skills).toHaveLength(0);
|
||||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
expect(debugLogger.debug).toHaveBeenCalledWith(
|
||||||
'warning',
|
|
||||||
expect.stringContaining('Failed to load skills from'),
|
expect.stringContaining('Failed to load skills from'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ export async function loadSkillsFromDir(
|
|||||||
if (discoveredSkills.length === 0) {
|
if (discoveredSkills.length === 0) {
|
||||||
const files = await fs.readdir(absoluteSearchPath);
|
const files = await fs.readdir(absoluteSearchPath);
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
coreEvents.emitFeedback(
|
debugLogger.debug(
|
||||||
'warning',
|
|
||||||
`Failed to load skills from ${absoluteSearchPath}. The directory is not empty but no valid skills were discovered. Please ensure SKILL.md files are present in subdirectories and have valid frontmatter.`,
|
`Failed to load skills from ${absoluteSearchPath}. The directory is not empty but no valid skills were discovered. Please ensure SKILL.md files are present in subdirectories and have valid frontmatter.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user