feat(skills): support install preflight-only mode
This commit is contained in:
@@ -187,6 +187,17 @@ describe('skills CLI helpers', () => {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('returns null install preflight view when source is invalid', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'flynn-skills-cli-'));
|
||||
const sourceDir = join(root, 'invalid-source-skill');
|
||||
mkdirSync(sourceDir, { recursive: true });
|
||||
|
||||
const view = toSkillInstallPreflightView(sourceDir);
|
||||
|
||||
expect(view).toBeNull();
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('renders install preflight output text', () => {
|
||||
const output = renderSkillInstallPreflight({
|
||||
sourcePath: '/tmp/source-skill',
|
||||
|
||||
+18
-1
@@ -340,8 +340,9 @@ export function registerSkillsCommand(program: Command): void {
|
||||
.command('install <path>')
|
||||
.description('Install a skill from a local directory')
|
||||
.option('--json', 'Output preflight and install result as JSON')
|
||||
.option('--preflight-only', 'Show installer preflight without performing install')
|
||||
.option('-c, --config <path>', 'Config file path')
|
||||
.action((pathArg: string, opts: { json?: boolean; config?: string }) => {
|
||||
.action((pathArg: string, opts: { json?: boolean; preflightOnly?: boolean; config?: string }) => {
|
||||
const loaded = loadConfigSafe(opts.config);
|
||||
if (loaded.error || !loaded.config) {
|
||||
console.error(loaded.error ?? 'Failed to load config');
|
||||
@@ -353,6 +354,22 @@ export function registerSkillsCommand(program: Command): void {
|
||||
const installer = new SkillInstaller(loaded.config.skills.managed_dir ?? defaultManagedDir);
|
||||
const preflight = toSkillInstallPreflightView(pathArg);
|
||||
|
||||
if (opts.preflightOnly) {
|
||||
if (!preflight) {
|
||||
console.error(`Failed to generate install preflight from '${resolve(pathArg)}'.`);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts.json) {
|
||||
console.log(JSON.stringify({ preflight }, null, 2));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(renderSkillInstallPreflight(preflight));
|
||||
return;
|
||||
}
|
||||
|
||||
if (preflight) {
|
||||
if (opts.json) {
|
||||
console.log(JSON.stringify({ preflight }, null, 2));
|
||||
|
||||
Reference in New Issue
Block a user