Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/cli/src/__tests__/commands/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ vi.mock('../../util/terminal.js', () => ({
}));

import { initCommand } from '../../commands/init.js';
import { BUILTIN_SKILL_NAMES, BUILTIN_SKILL_REGISTRY } from '../../constants.js';

function confirmCallsMatching(pattern: RegExp): any[] {
return mockConfirm.mock.calls.filter(([config]: any[]) =>
Expand Down Expand Up @@ -211,7 +212,7 @@ describe('init command', () => {
expect(mockConfigManager.setEnvironments).not.toHaveBeenCalled();
});

it('silently ignores --built-in when the template declares skills', async () => {
it('installs template skills and all built-in skills when both options are provided', async () => {
mockLoadInitTemplate.mockResolvedValue({
environments: ['codex'],
phases: ['requirements'],
Expand All @@ -220,21 +221,27 @@ describe('init command', () => {

await initCommand({ template: './init.yaml', builtIn: true });

expect(mockSkillManager.addSkill).toHaveBeenCalledTimes(1);
expect(mockSkillManager.addSkill).toHaveBeenCalledWith('codeaholicguy/ai-devkit', 'debug');
expect(mockSkillManager.addSkill).toHaveBeenCalledTimes(BUILTIN_SKILL_NAMES.length + 1);
expect(mockSkillManager.addSkill).toHaveBeenCalledWith(BUILTIN_SKILL_REGISTRY, 'debug');
for (const skill of BUILTIN_SKILL_NAMES) {
expect(mockSkillManager.addSkill).toHaveBeenCalledWith(BUILTIN_SKILL_REGISTRY, skill);
}
const builtinPrompts = confirmCallsMatching(/Install AI DevKit built-in skills/);
expect(builtinPrompts).toHaveLength(0);
});

it('silently ignores --built-in when the template has no skills declared', async () => {
it('installs all built-in skills when the template has no skills declared', async () => {
mockLoadInitTemplate.mockResolvedValue({
environments: ['codex'],
phases: ['requirements']
});

await initCommand({ template: './init.yaml', builtIn: true });

expect(mockSkillManager.addSkill).not.toHaveBeenCalled();
expect(mockSkillManager.addSkill).toHaveBeenCalledTimes(BUILTIN_SKILL_NAMES.length);
for (const skill of BUILTIN_SKILL_NAMES) {
expect(mockSkillManager.addSkill).toHaveBeenCalledWith(BUILTIN_SKILL_REGISTRY, skill);
}
const builtinPrompts = confirmCallsMatching(/Install AI DevKit built-in skills/);
expect(builtinPrompts).toHaveLength(0);
});
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ export async function initCommand(options: InitOptions) {
ui.warning(`${result.registry}/${result.skill}: ${result.reason || 'Unknown error'}`);
});
}
} else if (!hasTemplate) {
}

if (options.builtIn || !hasTemplate) {
const shouldInstall = await shouldInstallBuiltinSkills(options);

if (shouldInstall) {
Expand Down
Loading