refactor(skills): centralize install action modes
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
renderSkillInstallPreflight,
|
||||
toSkillInstallerExecutionStubView,
|
||||
renderSkillInstallerExecutionStub,
|
||||
toSkillInstallerExecutionStubFromPreflight,
|
||||
runSkillInstallAction,
|
||||
} from './skills.js';
|
||||
import type { Skill } from '../skills/index.js';
|
||||
|
||||
@@ -247,6 +249,21 @@ describe('skills CLI helpers', () => {
|
||||
expect(output).toContain('Skipped:');
|
||||
});
|
||||
|
||||
it('derives execution stub view from preflight data', () => {
|
||||
const preflight = {
|
||||
sourcePath: '/tmp/source-skill',
|
||||
skill: { name: 'exec-stub', tier: 'managed' as const, version: '1.0.0' },
|
||||
mode: 'dry-run' as const,
|
||||
steps: [{ installerType: 'download', command: 'download https://example.com/a.tgz -> /tmp/a.tgz' }],
|
||||
skipped: [],
|
||||
};
|
||||
|
||||
const view = toSkillInstallerExecutionStubFromPreflight(preflight);
|
||||
|
||||
expect(view.execution).toBe('stub');
|
||||
expect(view.wouldRun).toEqual(['download https://example.com/a.tgz -> /tmp/a.tgz']);
|
||||
});
|
||||
|
||||
it('summarizes refresh counts across status and tiers', () => {
|
||||
const summary = summarizeSkillsRefresh([
|
||||
buildSkill({ manifest: { name: 'a', description: 'a', version: '1.0.0', tier: 'bundled' } }),
|
||||
@@ -306,6 +323,27 @@ describe('skills CLI helpers', () => {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('supports plan-only install action mode without installing', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'flynn-skills-cli-'));
|
||||
const sourceDir = join(root, 'source-skill');
|
||||
const managedDir = join(root, 'managed');
|
||||
mkdirSync(sourceDir, { recursive: true });
|
||||
writeFileSync(join(sourceDir, 'SKILL.md'), '# Plan Skill\nInstructions');
|
||||
writeFileSync(
|
||||
join(sourceDir, 'manifest.json'),
|
||||
JSON.stringify({ name: 'plan-skill', description: 'Plan only', version: '1.0.0' }),
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const installer = new SkillInstaller(managedDir);
|
||||
const result = runSkillInstallAction(installer, sourceDir, { mode: 'plan-only', asJson: false });
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(existsSync(join(managedDir, 'plan-skill', 'SKILL.md'))).toBe(false);
|
||||
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('requires --yes confirmation for uninstall helper', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'flynn-skills-cli-'));
|
||||
const installer = new SkillInstaller(join(root, 'managed'));
|
||||
|
||||
Reference in New Issue
Block a user