feat(cli): add security consent prompts for skill installation (#16549)

This commit is contained in:
N. Taylor Mullen
2026-01-14 17:47:02 -08:00
committed by GitHub
parent 5bdfe1a1fa
commit a81500a929
7 changed files with 296 additions and 101 deletions

View File

@@ -78,4 +78,33 @@ describe('skillUtils', () => {
const installedExists = await fs.stat(installedPath).catch(() => null);
expect(installedExists?.isDirectory()).toBe(true);
});
it('should abort installation if consent is rejected', async () => {
const mockSkillDir = path.join(tempDir, 'mock-skill-source');
const skillSubDir = path.join(mockSkillDir, 'test-skill');
await fs.mkdir(skillSubDir, { recursive: true });
await fs.writeFile(
path.join(skillSubDir, 'SKILL.md'),
'---\nname: test-skill\ndescription: test\n---\nbody',
);
const requestConsent = vi.fn().mockResolvedValue(false);
await expect(
installSkill(
mockSkillDir,
'workspace',
undefined,
() => {},
requestConsent,
),
).rejects.toThrow('Skill installation cancelled by user.');
expect(requestConsent).toHaveBeenCalled();
// Verify it was NOT copied
const installedPath = path.join(tempDir, '.gemini/skills', 'test-skill');
const installedExists = await fs.stat(installedPath).catch(() => null);
expect(installedExists).toBeNull();
});
});