feat(skills): preview installer plan during install

This commit is contained in:
William Valentin
2026-02-12 18:15:42 -08:00
parent d3ba1328f2
commit 601844c50e
3 changed files with 132 additions and 4 deletions
+41
View File
@@ -13,6 +13,8 @@ import {
uninstallSkillByName,
toSkillInstallerPlanView,
renderSkillInstallerPlan,
toSkillInstallPreflightView,
renderSkillInstallPreflight,
} from './skills.js';
import type { Skill } from '../skills/index.js';
@@ -160,6 +162,45 @@ describe('skills CLI helpers', () => {
expect(output).toContain('[brew] brew not available in PATH');
});
it('builds install preflight view from a source skill directory', () => {
const root = mkdtempSync(join(tmpdir(), 'flynn-skills-cli-'));
const sourceDir = join(root, 'source-skill');
mkdirSync(sourceDir, { recursive: true });
writeFileSync(join(sourceDir, 'SKILL.md'), '# Preflight Skill\nInstructions');
writeFileSync(
join(sourceDir, 'manifest.json'),
JSON.stringify({
name: 'preflight-skill',
description: 'Preflight test',
version: '1.0.0',
installers: [{ type: 'download', url: 'https://example.com/tool.tgz' }],
}),
'utf-8',
);
const view = toSkillInstallPreflightView(sourceDir);
expect(view).not.toBeNull();
expect(view?.skill.name).toBe('preflight-skill');
expect(view?.steps[0]?.installerType).toBe('download');
rmSync(root, { recursive: true, force: true });
});
it('renders install preflight output text', () => {
const output = renderSkillInstallPreflight({
sourcePath: '/tmp/source-skill',
skill: { name: 'preflight-skill', tier: 'managed', version: '1.0.0' },
mode: 'dry-run',
steps: [{ installerType: 'download', command: 'download https://example.com/tool.tgz -> <default destination>' }],
skipped: [],
});
expect(output).toContain("Install preflight for 'preflight-skill' from /tmp/source-skill");
expect(output).toContain('Planned installer steps:');
expect(output).toContain('[download] download https://example.com/tool.tgz -> <default destination>');
});
it('summarizes refresh counts across status and tiers', () => {
const summary = summarizeSkillsRefresh([
buildSkill({ manifest: { name: 'a', description: 'a', version: '1.0.0', tier: 'bundled' } }),