fix: hide skills with cron allowedTools when cron is disabled

When cron functionality is disabled, skills that require cron tools
(like the 'loop' skill) should be hidden from the available commands
to avoid confusing users with non-functional commands.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-04-02 10:24:49 +08:00
parent a5f17ee39c
commit a827e8bfa6
2 changed files with 39 additions and 1 deletions

View file

@ -33,6 +33,7 @@ describe('BundledSkillLoader', () => {
};
mockConfig = {
getSkillManager: vi.fn().mockReturnValue(mockSkillManager),
isCronEnabled: vi.fn().mockReturnValue(false),
} as unknown as Config;
});
@ -125,4 +126,25 @@ describe('BundledSkillLoader', () => {
expect(commands).toHaveLength(2);
expect(commands.map((c) => c.name)).toEqual(['review', 'deploy']);
});
it('should hide skills with cron allowedTools when cron is disabled', async () => {
const skills = [
makeSkill({ name: 'review', description: 'Review code' }),
makeSkill({
name: 'loop',
description: 'Loop command',
allowedTools: ['cron_create', 'cron_list', 'cron_delete'],
}),
];
mockSkillManager.listSkills.mockResolvedValue(skills);
(mockConfig.isCronEnabled as ReturnType<typeof vi.fn>).mockReturnValue(
false,
);
const loader = new BundledSkillLoader(mockConfig);
const commands = await loader.loadCommands(signal);
expect(commands).toHaveLength(1);
expect(commands[0].name).toBe('review');
});
});