mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-19 02:13:58 +00:00
feat(cli): add beautiful onboarding UI with @clack/prompts (#17)
* feat(cli): add beautiful onboarding UI with @clack/prompts - Add new onboarding module with theme, logo, prompts, summary, and preferences - Implement adaptive ASCII logos (full/compact/minimal based on terminal width) - Add agent icons (⟁ ◫ ◎ ✦ ⬡) and circle-based step indicators (● ○) - Create agentMultiselect and skillMultiselect with visual formatting - Add progress bars and score formatting utilities - Store user preferences in ~/.skillkit/preferences.json - Update all interactive commands with new UI (init, install, sync, marketplace, recommend) - Add unit tests (18 tests) and e2e tests (16 tests) - Replace nested ternaries with if/else for clarity * fix(cli): address review feedback from CodeRabbit and Devin - Fix symlink install method: actually create symlinks for subsequent agents - Fix validate type signature to match @clack/prompts API (string | Error | undefined) - Handle zero detected agents to avoid empty multiselect blocking - Clamp divider width to avoid negative repeat counts - Guard progressBar against invalid totals/values - Isolate preference tests from real ~/.skillkit state * fix(cli): TypeScript type compatibility with @clack/prompts - Cast select options to match Option<T> type signature - Cast groupMultiselect options for proper Record type - Fix tasks function return type to Promise<string | void> * fix(cli): use 'as any' for @clack/prompts type compatibility The Option<T> type from @clack/prompts has a complex structure that doesn't match our inline types. Using 'as any' assertion to bypass strict type checking while maintaining runtime correctness.
This commit is contained in:
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* E2E Tests: Onboarding UI
|
||||
*
|
||||
* Tests for the new @clack/prompts based CLI onboarding experience
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Onboarding UI', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit init --list', () => {
|
||||
it('should display agents with icons', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show agent icons
|
||||
expect(output).toContain('Claude Code');
|
||||
expect(output).toContain('Cursor');
|
||||
expect(output).toContain('Codex');
|
||||
|
||||
// Should show Skills dir info
|
||||
expect(output).toContain('Skills dir');
|
||||
expect(output).toContain('Config');
|
||||
|
||||
// Should complete successfully
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should display all 17 agents', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
const agents = [
|
||||
'Claude Code',
|
||||
'Cursor',
|
||||
'Codex',
|
||||
'Gemini',
|
||||
'OpenCode',
|
||||
'Copilot',
|
||||
'Windsurf',
|
||||
'Droid',
|
||||
'Goose',
|
||||
'Amp',
|
||||
'Kilo',
|
||||
'Kiro',
|
||||
'Roo',
|
||||
'Trae',
|
||||
'Antigravity',
|
||||
'Clawdbot',
|
||||
'Universal',
|
||||
];
|
||||
|
||||
for (const agent of agents) {
|
||||
expect(output.toLowerCase()).toContain(agent.toLowerCase());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit install --list', () => {
|
||||
it('should list skills with visual formatting', async () => {
|
||||
// Create a test repo-like structure
|
||||
const skillsDir = join(testDir, 'test-skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'skill-one');
|
||||
createTestSkill(skillsDir, 'skill-two');
|
||||
|
||||
const result = await runCli(['install', testDir, '--list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show skills found
|
||||
expect(output.toLowerCase()).toMatch(/skill|found|available/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit marketplace', () => {
|
||||
it('should display marketplace header', async () => {
|
||||
const result = await runCli(['marketplace', '--json']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// JSON output should contain marketplace data
|
||||
if (result.success) {
|
||||
try {
|
||||
const data = JSON.parse(result.stdout.trim().split('\n').pop() || '{}');
|
||||
expect(data).toHaveProperty('totalSkills');
|
||||
expect(data).toHaveProperty('sources');
|
||||
} catch {
|
||||
// Non-JSON output is also acceptable
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should show popular tags with progress bars', async () => {
|
||||
const result = await runCli(['marketplace', 'tags', '--json']);
|
||||
|
||||
if (result.success && result.stdout.trim().startsWith('[')) {
|
||||
const tags = JSON.parse(result.stdout);
|
||||
expect(Array.isArray(tags)).toBe(true);
|
||||
if (tags.length > 0) {
|
||||
expect(tags[0]).toHaveProperty('tag');
|
||||
expect(tags[0]).toHaveProperty('count');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit sync', () => {
|
||||
it('should sync with formatted output', async () => {
|
||||
// Create skills to sync
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'sync-skill-1');
|
||||
createTestSkill(skillsDir, 'sync-skill-2');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show sync operation
|
||||
expect(output.toLowerCase()).toMatch(/sync|skill|claude/);
|
||||
});
|
||||
|
||||
it('should show skill status indicators', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'enabled-skill');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should complete without error
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit recommend', () => {
|
||||
it('should show project analysis with spinner', async () => {
|
||||
// Create a node project
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'test-project', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
|
||||
const result = await runCli(['recommend', '--quiet'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show some output about recommendations or project
|
||||
expect(
|
||||
output.toLowerCase().includes('project') ||
|
||||
output.toLowerCase().includes('skill') ||
|
||||
output.toLowerCase().includes('recommend') ||
|
||||
output.toLowerCase().includes('index') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should format scores with progress bars', async () => {
|
||||
// Create a TypeScript project
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({
|
||||
name: 'test-project',
|
||||
dependencies: { typescript: '^5.0.0' },
|
||||
}, null, 2)
|
||||
);
|
||||
writeFileSync(join(testDir, 'tsconfig.json'), '{}');
|
||||
|
||||
const result = await runCli(['recommend', '--json'], { cwd: testDir });
|
||||
|
||||
if (result.success && result.stdout.includes('"recommendations"')) {
|
||||
const data = JSON.parse(result.stdout);
|
||||
expect(data).toHaveProperty('recommendations');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Non-interactive mode', () => {
|
||||
it('should work with --yes flag', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'test-skill');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
// Should complete without prompting
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should work with --quiet flag', async () => {
|
||||
const result = await runCli(['init', '--list', '-q']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should still show content but without extra formatting
|
||||
expect(output).toContain('Claude Code');
|
||||
});
|
||||
|
||||
it('should work with --json flag', async () => {
|
||||
const result = await runCli(['marketplace', '--json']);
|
||||
|
||||
// Should output valid JSON
|
||||
if (result.success) {
|
||||
const jsonLine = result.stdout.trim().split('\n').pop() || '';
|
||||
if (jsonLine.startsWith('{') || jsonLine.startsWith('[')) {
|
||||
expect(() => JSON.parse(jsonLine)).not.toThrow();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Error handling', () => {
|
||||
it('should show formatted errors', async () => {
|
||||
const result = await runCli(['install', 'nonexistent-source-12345']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show some error message
|
||||
expect(
|
||||
output.toLowerCase().includes('error') ||
|
||||
output.toLowerCase().includes('fail') ||
|
||||
output.toLowerCase().includes('not found') ||
|
||||
!result.success
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle missing skills gracefully', async () => {
|
||||
const result = await runCli(['read', 'nonexistent-skill'], { cwd: testDir });
|
||||
// Should not crash
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Visual elements', () => {
|
||||
it('should use Unicode symbols in output', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should contain Unicode agent icons (any of the defined icons)
|
||||
const unicodePatterns = [
|
||||
/[\u2500-\u257F]/, // Box drawing
|
||||
/[\u25A0-\u25FF]/, // Geometric shapes
|
||||
/[\u2700-\u27BF]/, // Dingbats
|
||||
];
|
||||
|
||||
const hasUnicode = unicodePatterns.some(pattern => pattern.test(output));
|
||||
// Unicode support depends on terminal, so just check it doesn't crash
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle narrow terminal gracefully', async () => {
|
||||
// Even with narrow output, should not crash
|
||||
const result = await runCli(['init', '--list'], {
|
||||
env: { COLUMNS: '40' },
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -21,6 +21,7 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.11.0",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/tui": "workspace:*",
|
||||
@@ -29,6 +30,7 @@
|
||||
"got": "^14.4.1",
|
||||
"isomorphic-git": "^1.27.1",
|
||||
"ora": "^8.1.0",
|
||||
"picocolors": "^1.1.1",
|
||||
"yaml": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
/**
|
||||
* Unit Tests: Onboarding Module
|
||||
*
|
||||
* Tests for the CLI onboarding experience components
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { existsSync, mkdirSync, rmSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { mkdtempSync } from 'node:fs';
|
||||
|
||||
describe('Onboarding Module', () => {
|
||||
describe('theme', () => {
|
||||
it('should export agent icons', async () => {
|
||||
const { AGENT_ICONS, AGENT_NAMES } = await import('../onboarding/theme.js');
|
||||
|
||||
expect(AGENT_ICONS).toBeDefined();
|
||||
expect(AGENT_ICONS['claude-code']).toBe('\u27c1'); // ⟁
|
||||
expect(AGENT_ICONS['cursor']).toBe('\u25eb'); // ◫
|
||||
expect(AGENT_ICONS['codex']).toBe('\u25ce'); // ◎
|
||||
|
||||
expect(AGENT_NAMES).toBeDefined();
|
||||
expect(AGENT_NAMES['claude-code']).toBe('Claude Code');
|
||||
expect(AGENT_NAMES['cursor']).toBe('Cursor');
|
||||
});
|
||||
|
||||
it('should export symbols', async () => {
|
||||
const { symbols } = await import('../onboarding/theme.js');
|
||||
|
||||
expect(symbols).toBeDefined();
|
||||
expect(symbols.stepPending).toBe('\u25cb'); // ○
|
||||
expect(symbols.stepActive).toBe('\u25cf'); // ●
|
||||
expect(symbols.success).toBe('\u2713'); // ✓
|
||||
expect(symbols.error).toBe('\u2717'); // ✗
|
||||
});
|
||||
|
||||
it('should export color utilities', async () => {
|
||||
const { colors } = await import('../onboarding/theme.js');
|
||||
|
||||
expect(colors).toBeDefined();
|
||||
expect(typeof colors.accent).toBe('function');
|
||||
expect(typeof colors.primary).toBe('function');
|
||||
expect(typeof colors.success).toBe('function');
|
||||
expect(typeof colors.error).toBe('function');
|
||||
});
|
||||
|
||||
it('should format agent with icon', async () => {
|
||||
const { formatAgent, getAgentIcon } = await import('../onboarding/theme.js');
|
||||
|
||||
const formatted = formatAgent('claude-code');
|
||||
expect(formatted).toContain('\u27c1'); // ⟁
|
||||
expect(formatted).toContain('Claude Code');
|
||||
|
||||
const icon = getAgentIcon('cursor');
|
||||
expect(icon).toBe('\u25eb'); // ◫
|
||||
});
|
||||
|
||||
it('should generate progress bars', async () => {
|
||||
const { progressBar } = await import('../onboarding/theme.js');
|
||||
|
||||
const bar50 = progressBar(50, 100, 10);
|
||||
expect(bar50).toContain('\u2588'); // █ (filled)
|
||||
expect(bar50).toContain('\u2591'); // ░ (empty)
|
||||
expect(bar50.length).toBe(10);
|
||||
|
||||
const bar100 = progressBar(100, 100, 6);
|
||||
expect(bar100).toBe('\u2588'.repeat(6));
|
||||
|
||||
const bar0 = progressBar(0, 100, 6);
|
||||
expect(bar0).toBe('\u2591'.repeat(6));
|
||||
});
|
||||
|
||||
it('should format score with visual bar', async () => {
|
||||
const { formatScore } = await import('../onboarding/theme.js');
|
||||
|
||||
const score = formatScore(75);
|
||||
expect(score).toContain('75%');
|
||||
expect(score).toContain('\u2588'); // progress bar
|
||||
});
|
||||
});
|
||||
|
||||
describe('logo', () => {
|
||||
it('should export logo functions', async () => {
|
||||
const { getLogo, getFullLogo, getCompactLogo, getMinimalLogo, getHeader, getDivider } =
|
||||
await import('../onboarding/logo.js');
|
||||
|
||||
expect(typeof getLogo).toBe('function');
|
||||
expect(typeof getFullLogo).toBe('function');
|
||||
expect(typeof getCompactLogo).toBe('function');
|
||||
expect(typeof getMinimalLogo).toBe('function');
|
||||
expect(typeof getHeader).toBe('function');
|
||||
expect(typeof getDivider).toBe('function');
|
||||
});
|
||||
|
||||
it('should generate full logo with version', async () => {
|
||||
const { getFullLogo } = await import('../onboarding/logo.js');
|
||||
|
||||
const logo = getFullLogo('1.7.2', 17);
|
||||
// Full logo uses block characters (███), not literal text
|
||||
expect(logo).toContain('\u2588'); // █ block character
|
||||
expect(logo).toContain('v1.7.2');
|
||||
expect(logo).toContain('17 agents');
|
||||
});
|
||||
|
||||
it('should generate compact logo', async () => {
|
||||
const { getCompactLogo } = await import('../onboarding/logo.js');
|
||||
|
||||
const logo = getCompactLogo('1.7.2');
|
||||
// Compact logo has spaced letters: S K I L L K I T
|
||||
expect(logo).toContain('S K I L L K I T');
|
||||
expect(logo).toContain('v1.7.2');
|
||||
});
|
||||
|
||||
it('should generate minimal logo', async () => {
|
||||
const { getMinimalLogo } = await import('../onboarding/logo.js');
|
||||
|
||||
const logo = getMinimalLogo('1.7.2');
|
||||
expect(logo).toContain('SKILLKIT');
|
||||
expect(logo).toContain('\u25c7'); // ◇ diamond
|
||||
});
|
||||
|
||||
it('should generate header', async () => {
|
||||
const { getHeader } = await import('../onboarding/logo.js');
|
||||
|
||||
const header = getHeader('Test Title');
|
||||
expect(header).toContain('SkillKit');
|
||||
expect(header).toContain('Test Title');
|
||||
});
|
||||
|
||||
it('should generate divider', async () => {
|
||||
const { getDivider } = await import('../onboarding/logo.js');
|
||||
|
||||
const divider = getDivider(20);
|
||||
expect(divider).toContain('\u2500'); // ─
|
||||
});
|
||||
});
|
||||
|
||||
describe('preferences', () => {
|
||||
let testDir: string;
|
||||
let originalHome: string | undefined;
|
||||
let originalUserProfile: string | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
testDir = mkdtempSync(join(tmpdir(), 'skillkit-prefs-test-'));
|
||||
originalHome = process.env.HOME;
|
||||
originalUserProfile = process.env.USERPROFILE;
|
||||
process.env.HOME = testDir;
|
||||
process.env.USERPROFILE = testDir;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (existsSync(testDir)) {
|
||||
rmSync(testDir, { recursive: true, force: true });
|
||||
}
|
||||
if (originalHome === undefined) {
|
||||
delete process.env.HOME;
|
||||
} else {
|
||||
process.env.HOME = originalHome;
|
||||
}
|
||||
if (originalUserProfile === undefined) {
|
||||
delete process.env.USERPROFILE;
|
||||
} else {
|
||||
process.env.USERPROFILE = originalUserProfile;
|
||||
}
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it('should export preference functions', async () => {
|
||||
const {
|
||||
loadPreferences,
|
||||
savePreferences,
|
||||
isOnboardingComplete,
|
||||
completeOnboarding,
|
||||
saveLastAgents,
|
||||
getLastAgents,
|
||||
saveInstallMethod,
|
||||
getInstallMethod,
|
||||
} = await import('../onboarding/preferences.js');
|
||||
|
||||
expect(typeof loadPreferences).toBe('function');
|
||||
expect(typeof savePreferences).toBe('function');
|
||||
expect(typeof isOnboardingComplete).toBe('function');
|
||||
expect(typeof completeOnboarding).toBe('function');
|
||||
expect(typeof saveLastAgents).toBe('function');
|
||||
expect(typeof getLastAgents).toBe('function');
|
||||
expect(typeof saveInstallMethod).toBe('function');
|
||||
expect(typeof getInstallMethod).toBe('function');
|
||||
});
|
||||
|
||||
it('should return default preferences when file does not exist', async () => {
|
||||
const { loadPreferences } = await import('../onboarding/preferences.js');
|
||||
|
||||
const prefs = loadPreferences();
|
||||
expect(prefs).toBeDefined();
|
||||
expect(prefs.onboardingComplete).toBe(false);
|
||||
expect(prefs.lastSelectedAgents).toEqual([]);
|
||||
expect(prefs.defaultInstallMethod).toBe('symlink');
|
||||
});
|
||||
});
|
||||
|
||||
describe('summary', () => {
|
||||
it('should export summary functions', async () => {
|
||||
const {
|
||||
showInstallSummary,
|
||||
showNextSteps,
|
||||
showAgentSummary,
|
||||
showProjectSummary,
|
||||
showSyncSummary,
|
||||
showSkillList,
|
||||
showMarketplaceInfo,
|
||||
} = await import('../onboarding/summary.js');
|
||||
|
||||
expect(typeof showInstallSummary).toBe('function');
|
||||
expect(typeof showNextSteps).toBe('function');
|
||||
expect(typeof showAgentSummary).toBe('function');
|
||||
expect(typeof showProjectSummary).toBe('function');
|
||||
expect(typeof showSyncSummary).toBe('function');
|
||||
expect(typeof showSkillList).toBe('function');
|
||||
expect(typeof showMarketplaceInfo).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('prompts', () => {
|
||||
it('should export prompt functions', async () => {
|
||||
const {
|
||||
isCancel,
|
||||
intro,
|
||||
outro,
|
||||
cancel,
|
||||
note,
|
||||
log,
|
||||
step,
|
||||
success,
|
||||
warn,
|
||||
error,
|
||||
spinner,
|
||||
text,
|
||||
password,
|
||||
confirm,
|
||||
select,
|
||||
agentMultiselect,
|
||||
skillMultiselect,
|
||||
stepTrail,
|
||||
selectInstallMethod,
|
||||
} = await import('../onboarding/prompts.js');
|
||||
|
||||
expect(typeof isCancel).toBe('function');
|
||||
expect(typeof intro).toBe('function');
|
||||
expect(typeof outro).toBe('function');
|
||||
expect(typeof cancel).toBe('function');
|
||||
expect(typeof note).toBe('function');
|
||||
expect(typeof log).toBe('function');
|
||||
expect(typeof step).toBe('function');
|
||||
expect(typeof success).toBe('function');
|
||||
expect(typeof warn).toBe('function');
|
||||
expect(typeof error).toBe('function');
|
||||
expect(typeof spinner).toBe('function');
|
||||
expect(typeof text).toBe('function');
|
||||
expect(typeof password).toBe('function');
|
||||
expect(typeof confirm).toBe('function');
|
||||
expect(typeof select).toBe('function');
|
||||
expect(typeof agentMultiselect).toBe('function');
|
||||
expect(typeof skillMultiselect).toBe('function');
|
||||
expect(typeof stepTrail).toBe('function');
|
||||
expect(typeof selectInstallMethod).toBe('function');
|
||||
});
|
||||
|
||||
it('should generate step trail', async () => {
|
||||
const { stepTrail } = await import('../onboarding/prompts.js');
|
||||
|
||||
const trail = stepTrail([
|
||||
{ label: 'Step 1', status: 'complete' },
|
||||
{ label: 'Step 2', status: 'active' },
|
||||
{ label: 'Step 3', status: 'pending' },
|
||||
]);
|
||||
|
||||
expect(trail).toContain('Step 1');
|
||||
expect(trail).toContain('Step 2');
|
||||
expect(trail).toContain('Step 3');
|
||||
expect(trail).toContain('\u25cf'); // ● (filled circle)
|
||||
expect(trail).toContain('\u25cb'); // ○ (empty circle)
|
||||
});
|
||||
});
|
||||
|
||||
describe('index exports', () => {
|
||||
it('should re-export all modules', async () => {
|
||||
const onboarding = await import('../onboarding/index.js');
|
||||
|
||||
// Theme exports
|
||||
expect(onboarding.AGENT_ICONS).toBeDefined();
|
||||
expect(onboarding.AGENT_NAMES).toBeDefined();
|
||||
expect(onboarding.symbols).toBeDefined();
|
||||
expect(onboarding.colors).toBeDefined();
|
||||
expect(onboarding.formatAgent).toBeDefined();
|
||||
expect(onboarding.getAgentIcon).toBeDefined();
|
||||
expect(onboarding.progressBar).toBeDefined();
|
||||
expect(onboarding.formatScore).toBeDefined();
|
||||
|
||||
// Logo exports
|
||||
expect(onboarding.getLogo).toBeDefined();
|
||||
expect(onboarding.getHeader).toBeDefined();
|
||||
expect(onboarding.getDivider).toBeDefined();
|
||||
|
||||
// Prompts exports
|
||||
expect(onboarding.isCancel).toBeDefined();
|
||||
expect(onboarding.spinner).toBeDefined();
|
||||
expect(onboarding.agentMultiselect).toBeDefined();
|
||||
expect(onboarding.skillMultiselect).toBeDefined();
|
||||
|
||||
// Summary exports
|
||||
expect(onboarding.showInstallSummary).toBeDefined();
|
||||
expect(onboarding.showNextSteps).toBeDefined();
|
||||
|
||||
// Preferences exports
|
||||
expect(onboarding.loadPreferences).toBeDefined();
|
||||
expect(onboarding.savePreferences).toBeDefined();
|
||||
|
||||
// Main functions
|
||||
expect(onboarding.welcome).toBeDefined();
|
||||
expect(onboarding.header).toBeDefined();
|
||||
expect(onboarding.showCompletion).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,27 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { createInterface } from 'node:readline';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
import { detectAgent, getAdapter, getAllAdapters } from '@skillkit/agents';
|
||||
import { initProject } from '../helpers.js';
|
||||
import {
|
||||
welcome,
|
||||
header,
|
||||
colors,
|
||||
symbols,
|
||||
formatAgent,
|
||||
isCancel,
|
||||
spinner,
|
||||
select,
|
||||
confirm,
|
||||
outro,
|
||||
cancel,
|
||||
step,
|
||||
note,
|
||||
showNextSteps,
|
||||
isOnboardingComplete,
|
||||
completeOnboarding,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
export class InitCommand extends Command {
|
||||
static override paths = [['init']];
|
||||
@@ -27,64 +43,120 @@ export class InitCommand extends Command {
|
||||
description: 'List supported agents',
|
||||
});
|
||||
|
||||
quiet = Option.Boolean('--quiet,-q', false, {
|
||||
description: 'Minimal output (no logo)',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const isInteractive = process.stdin.isTTY;
|
||||
|
||||
// List mode
|
||||
if (this.list) {
|
||||
console.log(chalk.cyan('Supported agents:\n'));
|
||||
if (!this.quiet) {
|
||||
header('Supported Agents');
|
||||
}
|
||||
|
||||
const adapters = getAllAdapters();
|
||||
console.log('');
|
||||
|
||||
for (const adapter of adapters) {
|
||||
console.log(` ${chalk.green(adapter.type)}`);
|
||||
console.log(` Name: ${adapter.name}`);
|
||||
console.log(` Skills dir: ${adapter.skillsDir}`);
|
||||
console.log(` Config file: ${adapter.configFile}`);
|
||||
console.log();
|
||||
console.log(` ${formatAgent(adapter.type)}`);
|
||||
console.log(` ${colors.muted('Skills dir:')} ${adapter.skillsDir}`);
|
||||
console.log(` ${colors.muted('Config:')} ${adapter.configFile}`);
|
||||
console.log('');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// Show welcome for first-time users
|
||||
const isFirstRun = !isOnboardingComplete();
|
||||
if (isInteractive && isFirstRun && !this.quiet) {
|
||||
welcome();
|
||||
} else if (!this.quiet) {
|
||||
header('Initialize');
|
||||
}
|
||||
|
||||
let agentType: AgentType;
|
||||
const s = spinner();
|
||||
|
||||
if (this.agent) {
|
||||
// Use specified agent
|
||||
agentType = this.agent as AgentType;
|
||||
} else if (isInteractive) {
|
||||
// Auto-detect and let user confirm/change
|
||||
s.start('Detecting agent...');
|
||||
const detected = await detectAgent();
|
||||
s.stop(`Detected: ${formatAgent(detected)}`);
|
||||
|
||||
const allAgents = getAllAdapters().map(a => a.type);
|
||||
|
||||
// Let user confirm or select different agent
|
||||
const agentResult = await select({
|
||||
message: 'Initialize for which agent?',
|
||||
options: allAgents.map(a => ({
|
||||
value: a,
|
||||
label: formatAgent(a),
|
||||
hint: a === detected ? '(detected)' : undefined,
|
||||
})),
|
||||
initialValue: detected,
|
||||
});
|
||||
|
||||
if (isCancel(agentResult)) {
|
||||
cancel('Initialization cancelled');
|
||||
return 0;
|
||||
}
|
||||
|
||||
agentType = agentResult as AgentType;
|
||||
} else {
|
||||
console.log(chalk.dim('Auto-detecting agent...'));
|
||||
// Non-interactive: auto-detect
|
||||
s.start('Detecting agent...');
|
||||
agentType = await detectAgent();
|
||||
s.stop(`Detected: ${formatAgent(agentType)}`);
|
||||
}
|
||||
|
||||
const adapter = getAdapter(agentType);
|
||||
|
||||
console.log(chalk.cyan(`Initializing for ${adapter.name}...`));
|
||||
|
||||
// Initialize project
|
||||
s.start(`Initializing for ${adapter.name}...`);
|
||||
await initProject(agentType);
|
||||
s.stop(`Initialized for ${adapter.name}`);
|
||||
|
||||
console.log();
|
||||
console.log(chalk.green('Initialized successfully!'));
|
||||
console.log();
|
||||
console.log(chalk.dim('Created:'));
|
||||
console.log(chalk.dim(` - ${adapter.skillsDir}/ (skills directory)`));
|
||||
console.log(chalk.dim(` - skillkit.yaml (config file)`));
|
||||
console.log(chalk.dim(` - ${adapter.configFile} (agent config)`));
|
||||
console.log();
|
||||
console.log(chalk.cyan('Next steps:'));
|
||||
console.log(chalk.dim(' 1. Install skills: skillkit install owner/repo'));
|
||||
console.log(chalk.dim(' 2. Sync config: skillkit sync'));
|
||||
console.log(chalk.dim(' 3. Use skills: skillkit read <skill-name>'));
|
||||
// Show what was created
|
||||
note(
|
||||
[
|
||||
`${symbols.success} ${adapter.skillsDir}/ ${colors.muted('(skills directory)')}`,
|
||||
`${symbols.success} skillkit.yaml ${colors.muted('(config file)')}`,
|
||||
`${symbols.success} ${adapter.configFile} ${colors.muted('(agent config)')}`,
|
||||
].join('\n'),
|
||||
'Created'
|
||||
);
|
||||
|
||||
// Check if SKILL.md exists and offer to publish
|
||||
// Mark onboarding complete
|
||||
if (isFirstRun) {
|
||||
completeOnboarding();
|
||||
}
|
||||
|
||||
// Check for SKILL.md to offer publishing
|
||||
await this.checkAndPromptPublish();
|
||||
|
||||
outro('Initialization complete!');
|
||||
|
||||
showNextSteps({
|
||||
skillNames: [],
|
||||
agentTypes: [agentType],
|
||||
});
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Initialization failed'));
|
||||
console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
console.log(colors.error('Initialization failed'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async checkAndPromptPublish(): Promise<void> {
|
||||
// Skip in non-interactive environments (CI, piped input, etc.)
|
||||
if (!process.stdin.isTTY) return;
|
||||
|
||||
const skillMdLocations = [
|
||||
@@ -97,32 +169,21 @@ export class InitCommand extends Command {
|
||||
const foundSkillMd = skillMdLocations.find(loc => existsSync(loc));
|
||||
if (!foundSkillMd) return;
|
||||
|
||||
console.log();
|
||||
console.log(chalk.yellow('Found SKILL.md in your project!'));
|
||||
console.log(chalk.dim('Would you like to publish it to the SkillKit marketplace?'));
|
||||
console.log();
|
||||
console.log('');
|
||||
step(`Found SKILL.md in your project`);
|
||||
|
||||
const answer = await this.prompt('Publish skill? [y/N]: ');
|
||||
const publishResult = await confirm({
|
||||
message: 'Would you like to publish it to the SkillKit marketplace?',
|
||||
initialValue: false,
|
||||
});
|
||||
|
||||
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
||||
console.log();
|
||||
console.log(chalk.cyan('To publish your skill, run:'));
|
||||
console.log(chalk.white(` skillkit publish ${foundSkillMd}`));
|
||||
console.log();
|
||||
if (isCancel(publishResult) || !publishResult) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private prompt(question: string): Promise<string> {
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
rl.question(question, answer => {
|
||||
rl.close();
|
||||
resolve(answer.trim());
|
||||
});
|
||||
});
|
||||
console.log('');
|
||||
console.log(colors.cyan('To publish your skill, run:'));
|
||||
console.log(` ${colors.bold(`skillkit publish ${foundSkillMd}`)}`);
|
||||
console.log('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
import { existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
|
||||
import { existsSync, mkdirSync, cpSync, rmSync, symlinkSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import chalk from 'chalk';
|
||||
import ora from 'ora';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { detectProvider, isLocalPath, getProvider } from '@skillkit/core';
|
||||
import type { SkillMetadata, GitProvider, AgentType } from '@skillkit/core';
|
||||
import { isPathInside } from '@skillkit/core';
|
||||
import { getAdapter, detectAgent } from '@skillkit/agents';
|
||||
import { getAdapter, detectAgent, getAllAdapters } from '@skillkit/agents';
|
||||
import { getInstallDir, saveSkillMetadata } from '../helpers.js';
|
||||
import {
|
||||
welcome,
|
||||
colors,
|
||||
symbols,
|
||||
formatAgent,
|
||||
getAgentIcon,
|
||||
isCancel,
|
||||
spinner,
|
||||
agentMultiselect,
|
||||
skillMultiselect,
|
||||
selectInstallMethod,
|
||||
confirm,
|
||||
outro,
|
||||
cancel,
|
||||
step,
|
||||
success,
|
||||
error,
|
||||
warn,
|
||||
showInstallSummary,
|
||||
showNextSteps,
|
||||
saveLastAgents,
|
||||
getLastAgents,
|
||||
type InstallResult,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
export class InstallCommand extends Command {
|
||||
static override paths = [['install'], ['i']];
|
||||
@@ -61,10 +83,20 @@ export class InstallCommand extends Command {
|
||||
description: 'Target specific agents (can specify multiple)',
|
||||
});
|
||||
|
||||
quiet = Option.Boolean('--quiet,-q', false, {
|
||||
description: 'Minimal output (no logo)',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const spinner = ora();
|
||||
const isInteractive = process.stdin.isTTY && !this.skills && !this.all && !this.yes;
|
||||
const s = spinner();
|
||||
|
||||
try {
|
||||
// Show welcome logo for interactive mode
|
||||
if (isInteractive && !this.quiet) {
|
||||
welcome();
|
||||
}
|
||||
|
||||
let providerAdapter = detectProvider(this.source);
|
||||
|
||||
if (this.provider) {
|
||||
@@ -72,40 +104,42 @@ export class InstallCommand extends Command {
|
||||
}
|
||||
|
||||
if (!providerAdapter) {
|
||||
console.error(chalk.red(`Could not detect provider for: ${this.source}`));
|
||||
console.error(chalk.dim('Use --provider flag or specify source as:'));
|
||||
console.error(chalk.dim(' GitHub: owner/repo or https://github.com/owner/repo'));
|
||||
console.error(chalk.dim(' GitLab: gitlab:owner/repo or https://gitlab.com/owner/repo'));
|
||||
console.error(chalk.dim(' Bitbucket: bitbucket:owner/repo'));
|
||||
console.error(chalk.dim(' Local: ./path or ~/path'));
|
||||
error(`Could not detect provider for: ${this.source}`);
|
||||
console.log(colors.muted('Use --provider flag or specify source as:'));
|
||||
console.log(colors.muted(' GitHub: owner/repo or https://github.com/owner/repo'));
|
||||
console.log(colors.muted(' GitLab: gitlab:owner/repo or https://gitlab.com/owner/repo'));
|
||||
console.log(colors.muted(' Bitbucket: bitbucket:owner/repo'));
|
||||
console.log(colors.muted(' Local: ./path or ~/path'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
spinner.start(`Fetching from ${providerAdapter.name}...`);
|
||||
s.start(`Fetching from ${providerAdapter.name}...`);
|
||||
|
||||
const result = await providerAdapter.clone(this.source, '', { depth: 1 });
|
||||
|
||||
if (!result.success || !result.path) {
|
||||
spinner.fail(chalk.red(result.error || 'Failed to fetch source'));
|
||||
s.stop(colors.error(result.error || 'Failed to fetch source'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
spinner.succeed(`Found ${result.skills?.length || 0} skill(s)`);
|
||||
s.stop(`Found ${result.skills?.length || 0} skill(s)`);
|
||||
|
||||
const discoveredSkills = result.discoveredSkills || [];
|
||||
|
||||
// List mode - just show skills and exit
|
||||
if (this.list) {
|
||||
if (discoveredSkills.length === 0) {
|
||||
console.log(chalk.yellow('\nNo skills found in this repository'));
|
||||
warn('No skills found in this repository');
|
||||
} else {
|
||||
console.log(chalk.cyan('\nAvailable skills:\n'));
|
||||
console.log('');
|
||||
console.log(colors.bold('Available skills:'));
|
||||
console.log('');
|
||||
for (const skill of discoveredSkills) {
|
||||
console.log(` ${chalk.green(skill.name)}`);
|
||||
console.log(` ${colors.success(symbols.stepActive)} ${colors.primary(skill.name)}`);
|
||||
}
|
||||
console.log();
|
||||
console.log(chalk.dim(`Total: ${discoveredSkills.length} skill(s)`));
|
||||
console.log(chalk.dim('\nTo install specific skills: skillkit install <source> --skills=skill1,skill2'));
|
||||
console.log(chalk.dim('To install all skills: skillkit install <source> --all'));
|
||||
console.log('');
|
||||
console.log(colors.muted(`Total: ${discoveredSkills.length} skill(s)`));
|
||||
console.log(colors.muted('To install: skillkit install <source> --skills=skill1,skill2'));
|
||||
}
|
||||
|
||||
const cleanupPath = result.tempRoot || result.path;
|
||||
@@ -118,83 +152,165 @@ export class InstallCommand extends Command {
|
||||
|
||||
let skillsToInstall = discoveredSkills;
|
||||
|
||||
// Non-interactive: use --skills filter
|
||||
if (this.skills) {
|
||||
const requestedSkills = this.skills.split(',').map(s => s.trim());
|
||||
const available = discoveredSkills.map(s => s.name);
|
||||
const notFound = requestedSkills.filter(s => !available.includes(s));
|
||||
|
||||
if (notFound.length > 0) {
|
||||
console.error(chalk.red(`Skills not found: ${notFound.join(', ')}`));
|
||||
console.error(chalk.dim(`Available: ${available.join(', ')}`));
|
||||
error(`Skills not found: ${notFound.join(', ')}`);
|
||||
console.log(colors.muted(`Available: ${available.join(', ')}`));
|
||||
return 1;
|
||||
}
|
||||
|
||||
skillsToInstall = discoveredSkills.filter(s => requestedSkills.includes(s.name));
|
||||
} else if (this.all || this.yes) {
|
||||
skillsToInstall = discoveredSkills;
|
||||
} else {
|
||||
skillsToInstall = discoveredSkills;
|
||||
} else if (isInteractive && discoveredSkills.length > 1) {
|
||||
// Interactive skill selection
|
||||
step(`Source: ${colors.cyan(this.source)}`);
|
||||
|
||||
if (skillsToInstall.length > 0) {
|
||||
console.log(chalk.cyan('\nSkills to install:'));
|
||||
skillsToInstall.forEach(s => console.log(chalk.dim(` - ${s.name}`)));
|
||||
console.log();
|
||||
const skillResult = await skillMultiselect({
|
||||
message: 'Select skills to install',
|
||||
skills: discoveredSkills.map(s => ({ name: s.name })),
|
||||
initialValues: discoveredSkills.map(s => s.name),
|
||||
});
|
||||
|
||||
if (isCancel(skillResult)) {
|
||||
cancel('Installation cancelled');
|
||||
return 0;
|
||||
}
|
||||
|
||||
skillsToInstall = discoveredSkills.filter(s => (skillResult as string[]).includes(s.name));
|
||||
}
|
||||
|
||||
if (skillsToInstall.length === 0) {
|
||||
console.log(chalk.yellow('No skills to install'));
|
||||
warn('No skills to install');
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Determine target agents
|
||||
let targetAgents: AgentType[];
|
||||
|
||||
if (this.agent && this.agent.length > 0) {
|
||||
// Explicitly specified agents
|
||||
targetAgents = this.agent as AgentType[];
|
||||
} else if (isInteractive) {
|
||||
// Interactive agent selection
|
||||
const allAgentTypes = getAllAdapters().map(a => a.type);
|
||||
const detectedAgent = await detectAgent();
|
||||
|
||||
// Get last selected agents or use detected
|
||||
const lastAgents = getLastAgents();
|
||||
const initialAgents = lastAgents.length > 0
|
||||
? lastAgents.filter(a => allAgentTypes.includes(a as AgentType))
|
||||
: [detectedAgent];
|
||||
|
||||
const agentResult = await agentMultiselect({
|
||||
message: 'Install to which agents?',
|
||||
agents: allAgentTypes,
|
||||
initialValues: initialAgents,
|
||||
});
|
||||
|
||||
if (isCancel(agentResult)) {
|
||||
cancel('Installation cancelled');
|
||||
return 0;
|
||||
}
|
||||
|
||||
targetAgents = agentResult as AgentType[];
|
||||
|
||||
// Save selection for next time
|
||||
saveLastAgents(targetAgents);
|
||||
} else {
|
||||
// Non-interactive: use detected agent
|
||||
const detectedAgent = await detectAgent();
|
||||
targetAgents = [detectedAgent];
|
||||
}
|
||||
|
||||
// Interactive: select installation method
|
||||
let installMethod: 'symlink' | 'copy' = 'copy';
|
||||
|
||||
if (isInteractive && targetAgents.length > 1) {
|
||||
const methodResult = await selectInstallMethod({});
|
||||
|
||||
if (isCancel(methodResult)) {
|
||||
cancel('Installation cancelled');
|
||||
return 0;
|
||||
}
|
||||
|
||||
installMethod = methodResult as 'symlink' | 'copy';
|
||||
}
|
||||
|
||||
// Confirm installation
|
||||
if (isInteractive && !this.yes) {
|
||||
console.log('');
|
||||
const agentDisplay = targetAgents.length <= 3
|
||||
? targetAgents.map(formatAgent).join(', ')
|
||||
: `${targetAgents.slice(0, 2).map(formatAgent).join(', ')} +${targetAgents.length - 2} more`;
|
||||
|
||||
const confirmResult = await confirm({
|
||||
message: `Install ${skillsToInstall.length} skill(s) to ${agentDisplay}?`,
|
||||
initialValue: true,
|
||||
});
|
||||
|
||||
if (isCancel(confirmResult) || !confirmResult) {
|
||||
cancel('Installation cancelled');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform installation
|
||||
let totalInstalled = 0;
|
||||
const installResults: { agent: string; dir: string; count: number }[] = [];
|
||||
const installResults: InstallResult[] = [];
|
||||
|
||||
for (const agentType of targetAgents) {
|
||||
const adapter = getAdapter(agentType);
|
||||
const installDir = getInstallDir(this.global, agentType);
|
||||
for (const skill of skillsToInstall) {
|
||||
const skillName = skill.name;
|
||||
const sourcePath = skill.path;
|
||||
const installedAgents: string[] = [];
|
||||
let primaryPath: string | null = null;
|
||||
|
||||
if (!existsSync(installDir)) {
|
||||
mkdirSync(installDir, { recursive: true });
|
||||
}
|
||||
for (const agentType of targetAgents) {
|
||||
const adapter = getAdapter(agentType);
|
||||
const installDir = getInstallDir(this.global, agentType);
|
||||
|
||||
if (targetAgents.length > 1) {
|
||||
console.log(chalk.cyan(`\nInstalling to ${adapter.name}...`));
|
||||
}
|
||||
if (!existsSync(installDir)) {
|
||||
mkdirSync(installDir, { recursive: true });
|
||||
}
|
||||
|
||||
let installed = 0;
|
||||
for (const skill of skillsToInstall) {
|
||||
const skillName = skill.name;
|
||||
const sourcePath = skill.path;
|
||||
const targetPath = join(installDir, skillName);
|
||||
|
||||
if (existsSync(targetPath) && !this.force) {
|
||||
console.log(chalk.yellow(` Skipping ${skillName} (already exists, use --force to overwrite)`));
|
||||
if (!this.quiet) {
|
||||
warn(`Skipping ${skillName} for ${adapter.name} (already exists, use --force)`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const securityRoot = result.tempRoot || result.path;
|
||||
if (!isPathInside(sourcePath, securityRoot)) {
|
||||
console.log(chalk.red(` Skipping ${skillName} (path traversal detected)`));
|
||||
error(`Skipping ${skillName} (path traversal detected)`);
|
||||
continue;
|
||||
}
|
||||
|
||||
spinner.start(`Installing ${skillName}...`);
|
||||
const isSymlinkMode = installMethod === 'symlink' && targetAgents.length > 1;
|
||||
const useSymlink = isSymlinkMode && primaryPath !== null;
|
||||
|
||||
s.start(`Installing ${skillName} to ${adapter.name}${useSymlink ? ' (symlink)' : ''}...`);
|
||||
|
||||
try {
|
||||
if (existsSync(targetPath)) {
|
||||
rmSync(targetPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
|
||||
if (useSymlink && primaryPath) {
|
||||
symlinkSync(primaryPath, targetPath, 'dir');
|
||||
} else {
|
||||
cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
|
||||
if (isSymlinkMode && primaryPath === null) {
|
||||
primaryPath = targetPath;
|
||||
}
|
||||
}
|
||||
|
||||
const metadata: SkillMetadata = {
|
||||
name: skillName,
|
||||
@@ -207,41 +323,66 @@ export class InstallCommand extends Command {
|
||||
};
|
||||
saveSkillMetadata(targetPath, metadata);
|
||||
|
||||
spinner.succeed(chalk.green(`Installed ${skillName}`));
|
||||
installed++;
|
||||
} catch (error) {
|
||||
spinner.fail(chalk.red(`Failed to install ${skillName}`));
|
||||
console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
|
||||
installedAgents.push(agentType);
|
||||
s.stop(`Installed ${skillName} to ${adapter.name}${useSymlink ? ' (symlink)' : ''}`);
|
||||
} catch (err) {
|
||||
s.stop(colors.error(`Failed to install ${skillName} to ${adapter.name}`));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
}
|
||||
}
|
||||
|
||||
totalInstalled += installed;
|
||||
installResults.push({ agent: adapter.name, dir: installDir, count: installed });
|
||||
if (installedAgents.length > 0) {
|
||||
totalInstalled++;
|
||||
installResults.push({
|
||||
skillName,
|
||||
method: installMethod,
|
||||
agents: installedAgents,
|
||||
path: join(getInstallDir(this.global, installedAgents[0] as AgentType), skillName),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup temp directory
|
||||
const cleanupPath = result.tempRoot || result.path;
|
||||
if (!isLocalPath(this.source) && cleanupPath && existsSync(cleanupPath)) {
|
||||
rmSync(cleanupPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
console.log();
|
||||
if (targetAgents.length > 1) {
|
||||
console.log(chalk.green(`Installed ${totalInstalled} skill(s) across ${targetAgents.length} agents:`));
|
||||
for (const r of installResults) {
|
||||
console.log(chalk.dim(` - ${r.agent}: ${r.count} skill(s) to ${r.dir}`));
|
||||
// Show summary
|
||||
if (totalInstalled > 0) {
|
||||
if (isInteractive) {
|
||||
showInstallSummary({
|
||||
totalSkills: totalInstalled,
|
||||
totalAgents: targetAgents.length,
|
||||
results: installResults,
|
||||
source: this.source,
|
||||
});
|
||||
|
||||
outro('Installation complete!');
|
||||
|
||||
if (!this.yes) {
|
||||
showNextSteps({
|
||||
skillNames: installResults.map(r => r.skillName),
|
||||
agentTypes: targetAgents,
|
||||
syncNeeded: true,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
success(`Installed ${totalInstalled} skill(s) to ${targetAgents.length} agent(s)`);
|
||||
for (const r of installResults) {
|
||||
console.log(colors.muted(` ${symbols.success} ${r.skillName} ${symbols.arrowRight} ${r.agents.map(getAgentIcon).join(' ')}`));
|
||||
}
|
||||
console.log('');
|
||||
console.log(colors.muted('Run `skillkit sync` to update agent configs'));
|
||||
}
|
||||
} else {
|
||||
console.log(chalk.green(`Installed ${totalInstalled} skill(s) to ${installResults[0]?.dir}`));
|
||||
}
|
||||
|
||||
if (!this.yes) {
|
||||
console.log(chalk.dim('\nRun `skillkit sync` to update your agent config'));
|
||||
warn('No skills were installed');
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail(chalk.red('Installation failed'));
|
||||
console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Installation failed'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
import chalk from 'chalk';
|
||||
import ora from 'ora';
|
||||
import {
|
||||
createMarketplaceAggregator,
|
||||
type MarketplaceSearchOptions,
|
||||
} from '@skillkit/core';
|
||||
import {
|
||||
header,
|
||||
colors,
|
||||
spinner,
|
||||
warn,
|
||||
showMarketplaceInfo,
|
||||
showSkillList,
|
||||
progressBar,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
/**
|
||||
* Marketplace command - browse and install skills from the marketplace
|
||||
*/
|
||||
export class MarketplaceCommand extends Command {
|
||||
static override paths = [['marketplace'], ['market'], ['mp']];
|
||||
|
||||
@@ -51,6 +55,10 @@ export class MarketplaceCommand extends Command {
|
||||
description: 'Output as JSON',
|
||||
});
|
||||
|
||||
quiet = Option.Boolean('--quiet,-q', false, {
|
||||
description: 'Minimal output',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const marketplace = createMarketplaceAggregator();
|
||||
|
||||
@@ -73,11 +81,16 @@ export class MarketplaceCommand extends Command {
|
||||
}
|
||||
|
||||
private async browseMarketplace(marketplace: ReturnType<typeof createMarketplaceAggregator>): Promise<number> {
|
||||
const spinner = ora('Loading marketplace...').start();
|
||||
if (!this.quiet && !this.json) {
|
||||
header('Skill Marketplace');
|
||||
}
|
||||
|
||||
const s = spinner();
|
||||
s.start('Loading marketplace...');
|
||||
|
||||
try {
|
||||
const index = await marketplace.getIndex();
|
||||
spinner.stop();
|
||||
s.stop('Marketplace loaded');
|
||||
|
||||
if (this.json) {
|
||||
console.log(JSON.stringify({
|
||||
@@ -88,31 +101,31 @@ export class MarketplaceCommand extends Command {
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.bold('Skill Marketplace\n'));
|
||||
console.log(`Total skills: ${chalk.cyan(index.totalCount)}`);
|
||||
console.log(`Sources: ${chalk.cyan(index.sources.length)}`);
|
||||
console.log(`Last updated: ${chalk.dim(new Date(index.updatedAt).toLocaleString())}\n`);
|
||||
// Show marketplace info
|
||||
showMarketplaceInfo({
|
||||
totalSkills: index.totalCount,
|
||||
sourceCount: index.sources.length,
|
||||
lastUpdated: index.updatedAt,
|
||||
});
|
||||
|
||||
// Show featured skills
|
||||
console.log(colors.bold('Featured Skills:'));
|
||||
console.log('');
|
||||
|
||||
// Show sample skills
|
||||
console.log(chalk.bold('Featured Skills:\n'));
|
||||
const featured = index.skills.slice(0, 10);
|
||||
showSkillList(featured.map(skill => ({
|
||||
name: skill.name,
|
||||
description: skill.description,
|
||||
source: skill.source.name,
|
||||
})));
|
||||
|
||||
for (const skill of featured) {
|
||||
console.log(` ${chalk.cyan(skill.name)}`);
|
||||
if (skill.description) {
|
||||
console.log(` ${chalk.dim(skill.description.slice(0, 60))}${skill.description.length > 60 ? '...' : ''}`);
|
||||
}
|
||||
console.log(` ${chalk.dim(`Source: ${skill.source.name}`)}`);
|
||||
console.log();
|
||||
}
|
||||
|
||||
console.log(chalk.dim('Use "skillkit marketplace search <query>" to search for skills.'));
|
||||
console.log(chalk.dim('Use "skillkit marketplace tags" to see popular tags.'));
|
||||
console.log(colors.muted('Use "skillkit marketplace search <query>" to search for skills.'));
|
||||
console.log(colors.muted('Use "skillkit marketplace tags" to see popular tags.'));
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail('Failed to load marketplace');
|
||||
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Failed to load marketplace'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -120,12 +133,16 @@ export class MarketplaceCommand extends Command {
|
||||
private async searchSkills(marketplace: ReturnType<typeof createMarketplaceAggregator>): Promise<number> {
|
||||
const query = this.query || this.action;
|
||||
|
||||
if (!this.quiet && !this.json) {
|
||||
header('Search Skills');
|
||||
}
|
||||
|
||||
// Validate and parse limit
|
||||
let limit = 20;
|
||||
if (this.limit) {
|
||||
const parsed = parseInt(this.limit, 10);
|
||||
if (isNaN(parsed) || parsed <= 0) {
|
||||
console.error(chalk.red('Invalid --limit value. Must be a positive number.'));
|
||||
console.log(colors.error('Invalid --limit value. Must be a positive number.'));
|
||||
return 1;
|
||||
}
|
||||
limit = parsed;
|
||||
@@ -137,7 +154,8 @@ export class MarketplaceCommand extends Command {
|
||||
.map((t) => t.trim())
|
||||
.filter((t) => t.length > 0);
|
||||
|
||||
const spinner = ora(`Searching for "${query}"...`).start();
|
||||
const s = spinner();
|
||||
s.start(`Searching for "${query}"...`);
|
||||
|
||||
try {
|
||||
const options: MarketplaceSearchOptions = {
|
||||
@@ -148,7 +166,7 @@ export class MarketplaceCommand extends Command {
|
||||
};
|
||||
|
||||
const result = await marketplace.search(options);
|
||||
spinner.stop();
|
||||
s.stop(`Found ${result.total} skill(s)`);
|
||||
|
||||
if (this.json) {
|
||||
console.log(JSON.stringify(result));
|
||||
@@ -156,77 +174,94 @@ export class MarketplaceCommand extends Command {
|
||||
}
|
||||
|
||||
if (result.skills.length === 0) {
|
||||
console.log(chalk.yellow(`No skills found${query ? ` matching "${query}"` : ''}.`));
|
||||
warn(`No skills found${query ? ` matching "${query}"` : ''}.`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.bold(`Found ${result.total} skill(s):\n`));
|
||||
console.log('');
|
||||
console.log(colors.bold(`Found ${result.total} skill(s):`));
|
||||
console.log('');
|
||||
|
||||
for (const skill of result.skills) {
|
||||
console.log(`${chalk.cyan(skill.name)} ${chalk.dim(`(${skill.source.name})`)}`);
|
||||
if (skill.description) {
|
||||
console.log(` ${skill.description}`);
|
||||
}
|
||||
if (skill.tags.length > 0) {
|
||||
console.log(` Tags: ${chalk.dim(skill.tags.join(', '))}`);
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
showSkillList(result.skills.map(skill => ({
|
||||
name: skill.name,
|
||||
description: skill.description,
|
||||
source: skill.source.name,
|
||||
})));
|
||||
|
||||
if (result.total > result.skills.length) {
|
||||
console.log(chalk.dim(`Showing ${result.skills.length} of ${result.total} results. Use --limit to see more.`));
|
||||
console.log(colors.muted(`Showing ${result.skills.length} of ${result.total} results. Use --limit to see more.`));
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail('Search failed');
|
||||
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Search failed'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async refreshIndex(marketplace: ReturnType<typeof createMarketplaceAggregator>): Promise<number> {
|
||||
const spinner = ora('Refreshing marketplace index...').start();
|
||||
if (!this.quiet) {
|
||||
header('Refresh Marketplace');
|
||||
}
|
||||
|
||||
const s = spinner();
|
||||
s.start('Refreshing marketplace index...');
|
||||
|
||||
try {
|
||||
const index = await marketplace.refresh();
|
||||
spinner.succeed(`Marketplace refreshed: ${index.totalCount} skills from ${index.sources.length} sources`);
|
||||
s.stop(`Refreshed: ${index.totalCount} skills from ${index.sources.length} sources`);
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail('Refresh failed');
|
||||
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Refresh failed'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async showTags(marketplace: ReturnType<typeof createMarketplaceAggregator>): Promise<number> {
|
||||
const spinner = ora('Loading tags...').start();
|
||||
if (!this.quiet && !this.json) {
|
||||
header('Popular Tags');
|
||||
}
|
||||
|
||||
const s = spinner();
|
||||
s.start('Loading tags...');
|
||||
|
||||
try {
|
||||
const tags = await marketplace.getPopularTags(30);
|
||||
spinner.stop();
|
||||
s.stop('Tags loaded');
|
||||
|
||||
if (this.json) {
|
||||
console.log(JSON.stringify(tags));
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.bold('Popular Tags:\n'));
|
||||
console.log('');
|
||||
console.log(colors.bold('Popular Tags:'));
|
||||
console.log('');
|
||||
|
||||
const maxCount = Math.max(...tags.map(t => t.count));
|
||||
|
||||
for (const { tag, count } of tags) {
|
||||
const bar = '█'.repeat(Math.min(count, 20));
|
||||
console.log(` ${tag.padEnd(15)} ${chalk.cyan(bar)} ${count}`);
|
||||
const bar = progressBar(count, maxCount, 20);
|
||||
console.log(` ${tag.padEnd(15)} ${colors.dim(bar)} ${colors.muted(String(count))}`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail('Failed to load tags');
|
||||
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Failed to load tags'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async showSources(marketplace: ReturnType<typeof createMarketplaceAggregator>): Promise<number> {
|
||||
if (!this.quiet && !this.json) {
|
||||
header('Skill Sources');
|
||||
}
|
||||
|
||||
const sources = marketplace.getSources();
|
||||
|
||||
if (this.json) {
|
||||
@@ -234,15 +269,18 @@ export class MarketplaceCommand extends Command {
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.bold('Skill Sources:\n'));
|
||||
console.log('');
|
||||
console.log(colors.bold('Skill Sources:'));
|
||||
console.log('');
|
||||
|
||||
for (const source of sources) {
|
||||
console.log(`${chalk.cyan(source.name)} ${source.official ? chalk.green('(official)') : ''}`);
|
||||
console.log(` ${chalk.dim(`${source.owner}/${source.repo}`)}`);
|
||||
const officialBadge = source.official ? colors.success(' (official)') : '';
|
||||
console.log(`${colors.cyan(source.name)}${officialBadge}`);
|
||||
console.log(` ${colors.muted(`${source.owner}/${source.repo}`)}`);
|
||||
if (source.description) {
|
||||
console.log(` ${source.description}`);
|
||||
}
|
||||
console.log();
|
||||
console.log('');
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { resolve } from 'node:path';
|
||||
import chalk from 'chalk';
|
||||
import ora from 'ora';
|
||||
import {
|
||||
type ProjectProfile,
|
||||
type ScoredSkill,
|
||||
@@ -14,10 +12,16 @@ import {
|
||||
INDEX_PATH,
|
||||
KNOWN_SKILL_REPOS,
|
||||
} from '@skillkit/core';
|
||||
import {
|
||||
header,
|
||||
colors,
|
||||
symbols,
|
||||
spinner,
|
||||
warn,
|
||||
showProjectSummary,
|
||||
progressBar,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
/**
|
||||
* Recommend command - get smart skill recommendations based on project analysis
|
||||
*/
|
||||
export class RecommendCommand extends Command {
|
||||
static override paths = [['recommend'], ['rec']];
|
||||
|
||||
@@ -97,6 +101,11 @@ export class RecommendCommand extends Command {
|
||||
description: 'Project path (default: current directory)',
|
||||
});
|
||||
|
||||
// Quiet mode
|
||||
quiet = Option.Boolean('--quiet,-q', false, {
|
||||
description: 'Minimal output',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const targetPath = resolve(this.projectPath || process.cwd());
|
||||
|
||||
@@ -105,19 +114,23 @@ export class RecommendCommand extends Command {
|
||||
return await this.updateIndex();
|
||||
}
|
||||
|
||||
if (!this.quiet && !this.json) {
|
||||
header('Skill Recommendations');
|
||||
}
|
||||
|
||||
// Load or create project profile
|
||||
const profile = await this.getProjectProfile(targetPath);
|
||||
if (!profile) {
|
||||
console.error(chalk.red('Failed to analyze project'));
|
||||
console.log(colors.error('Failed to analyze project'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load skill index
|
||||
const index = this.loadIndex();
|
||||
if (!index || index.skills.length === 0) {
|
||||
console.log(chalk.yellow('No skill index found.'));
|
||||
console.log(chalk.dim('Run "skillkit recommend --update" to fetch skills from known sources.'));
|
||||
console.log(chalk.dim('Or install skills manually with "skillkit install <source>"\n'));
|
||||
warn('No skill index found.');
|
||||
console.log(colors.muted('Run "skillkit recommend --update" to fetch skills from known sources.'));
|
||||
console.log(colors.muted('Or install skills manually with "skillkit install <source>"\n'));
|
||||
|
||||
// Still show project profile
|
||||
this.showProjectProfile(profile);
|
||||
@@ -153,19 +166,20 @@ export class RecommendCommand extends Command {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project profile from context or by analyzing project
|
||||
*/
|
||||
private async getProjectProfile(projectPath: string): Promise<ProjectProfile | null> {
|
||||
const manager = new ContextManager(projectPath);
|
||||
let context = manager.get();
|
||||
|
||||
if (!context) {
|
||||
// Auto-analyze project
|
||||
if (!this.json) {
|
||||
console.log(chalk.dim('Analyzing project...\n'));
|
||||
if (!this.json && !this.quiet) {
|
||||
const s = spinner();
|
||||
s.start('Analyzing project...');
|
||||
context = manager.init();
|
||||
s.stop('Project analyzed');
|
||||
} else {
|
||||
context = manager.init();
|
||||
}
|
||||
context = manager.init();
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
@@ -183,33 +197,18 @@ export class RecommendCommand extends Command {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Show project profile summary
|
||||
*/
|
||||
private showProjectProfile(profile: ProjectProfile): void {
|
||||
console.log(chalk.cyan('Project Profile:'));
|
||||
console.log(` Name: ${chalk.bold(profile.name)}`);
|
||||
if (profile.type) {
|
||||
console.log(` Type: ${profile.type}`);
|
||||
}
|
||||
const languages = profile.stack.languages.map(l => `${l.name}${l.version ? ` ${l.version}` : ''}`);
|
||||
const frameworks = profile.stack.frameworks.map(f => `${f.name}${f.version ? ` ${f.version}` : ''}`);
|
||||
|
||||
const stackItems: string[] = [];
|
||||
for (const lang of profile.stack.languages) {
|
||||
stackItems.push(`${lang.name}${lang.version ? ` ${lang.version}` : ''}`);
|
||||
}
|
||||
for (const fw of profile.stack.frameworks) {
|
||||
stackItems.push(`${fw.name}${fw.version ? ` ${fw.version}` : ''}`);
|
||||
}
|
||||
|
||||
if (stackItems.length > 0) {
|
||||
console.log(` Stack: ${chalk.dim(stackItems.join(', '))}`);
|
||||
}
|
||||
console.log();
|
||||
showProjectSummary({
|
||||
name: profile.name,
|
||||
type: profile.type,
|
||||
languages,
|
||||
frameworks,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display recommendations
|
||||
*/
|
||||
private displayRecommendations(
|
||||
recommendations: ScoredSkill[],
|
||||
profile: ProjectProfile,
|
||||
@@ -219,59 +218,59 @@ export class RecommendCommand extends Command {
|
||||
this.showProjectProfile(profile);
|
||||
|
||||
if (recommendations.length === 0) {
|
||||
console.log(chalk.yellow('No matching skills found.'));
|
||||
console.log(chalk.dim('Try lowering the minimum score with --min-score'));
|
||||
warn('No matching skills found.');
|
||||
console.log(colors.muted('Try lowering the minimum score with --min-score'));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Recommended Skills (${recommendations.length} of ${totalScanned} scanned):\n`));
|
||||
console.log(colors.bold(`Recommended Skills (${recommendations.length} of ${totalScanned} scanned):`));
|
||||
console.log('');
|
||||
|
||||
for (const rec of recommendations) {
|
||||
const scoreColor = rec.score >= 70 ? chalk.green : rec.score >= 50 ? chalk.yellow : chalk.dim;
|
||||
const scoreBar = this.getScoreBar(rec.score);
|
||||
let scoreColor: (text: string) => string;
|
||||
if (rec.score >= 70) {
|
||||
scoreColor = colors.success;
|
||||
} else if (rec.score >= 50) {
|
||||
scoreColor = colors.warning;
|
||||
} else {
|
||||
scoreColor = colors.muted;
|
||||
}
|
||||
const scoreBar = progressBar(rec.score, 100, 10);
|
||||
|
||||
console.log(` ${scoreColor(`${rec.score}%`)} ${scoreBar} ${chalk.bold(rec.skill.name)}`);
|
||||
console.log(` ${scoreColor(`${rec.score}%`)} ${colors.dim(scoreBar)} ${colors.bold(rec.skill.name)}`);
|
||||
|
||||
if (rec.skill.description) {
|
||||
console.log(` ${chalk.dim(truncate(rec.skill.description, 70))}`);
|
||||
console.log(` ${colors.muted(truncate(rec.skill.description, 70))}`);
|
||||
}
|
||||
|
||||
if (rec.skill.source) {
|
||||
console.log(` ${chalk.dim('Source:')} ${rec.skill.source}`);
|
||||
console.log(` ${colors.dim('Source:')} ${rec.skill.source}`);
|
||||
}
|
||||
|
||||
if (this.verbose && rec.reasons.length > 0) {
|
||||
console.log(chalk.dim(' Reasons:'));
|
||||
console.log(colors.dim(' Reasons:'));
|
||||
for (const reason of rec.reasons.filter(r => r.weight > 0)) {
|
||||
console.log(` ${chalk.dim('•')} ${reason.description} (+${reason.weight})`);
|
||||
console.log(` ${colors.muted(symbols.stepActive)} ${reason.description} (+${reason.weight})`);
|
||||
}
|
||||
}
|
||||
|
||||
if (rec.warnings.length > 0) {
|
||||
for (const warning of rec.warnings) {
|
||||
console.log(` ${chalk.yellow('⚠')} ${warning}`);
|
||||
console.log(` ${colors.warning(symbols.warning)} ${warning}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log('');
|
||||
}
|
||||
|
||||
console.log(chalk.dim('Install with: skillkit install <source>'));
|
||||
console.log(colors.muted('Install with: skillkit install <source>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a visual score bar
|
||||
*/
|
||||
private getScoreBar(score: number): string {
|
||||
const filled = Math.round(score / 10);
|
||||
const empty = 10 - filled;
|
||||
return chalk.green('█'.repeat(filled)) + chalk.dim('░'.repeat(empty));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle search mode
|
||||
*/
|
||||
private handleSearch(engine: RecommendationEngine, query: string): number {
|
||||
if (!this.quiet && !this.json) {
|
||||
header(`Search: "${query}"`);
|
||||
}
|
||||
|
||||
const results = engine.search({
|
||||
query,
|
||||
limit: this.limit ? parseInt(this.limit, 10) : 10,
|
||||
@@ -287,35 +286,41 @@ export class RecommendCommand extends Command {
|
||||
}
|
||||
|
||||
if (results.length === 0) {
|
||||
console.log(chalk.yellow(`No skills found matching "${query}"`));
|
||||
warn(`No skills found matching "${query}"`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Search results for "${query}" (${results.length} found):\n`));
|
||||
console.log('');
|
||||
console.log(colors.bold(`Search results for "${query}" (${results.length} found):`));
|
||||
console.log('');
|
||||
|
||||
for (const result of results) {
|
||||
const relevanceColor =
|
||||
result.relevance >= 70 ? chalk.green : result.relevance >= 50 ? chalk.yellow : chalk.dim;
|
||||
let relevanceColor: (text: string) => string;
|
||||
if (result.relevance >= 70) {
|
||||
relevanceColor = colors.success;
|
||||
} else if (result.relevance >= 50) {
|
||||
relevanceColor = colors.warning;
|
||||
} else {
|
||||
relevanceColor = colors.muted;
|
||||
}
|
||||
const relevanceBar = progressBar(result.relevance, 100, 10);
|
||||
|
||||
console.log(` ${relevanceColor(`${result.relevance}%`)} ${chalk.bold(result.skill.name)}`);
|
||||
console.log(` ${relevanceColor(`${result.relevance}%`)} ${colors.dim(relevanceBar)} ${colors.bold(result.skill.name)}`);
|
||||
|
||||
if (result.snippet) {
|
||||
console.log(` ${chalk.dim(result.snippet)}`);
|
||||
console.log(` ${colors.muted(result.snippet)}`);
|
||||
}
|
||||
|
||||
if (result.matchedTerms.length > 0) {
|
||||
console.log(` ${chalk.dim('Matched:')} ${result.matchedTerms.join(', ')}`);
|
||||
console.log(` ${colors.dim('Matched:')} ${result.matchedTerms.join(', ')}`);
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log('');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load skill index from cache
|
||||
*/
|
||||
private loadIndex() {
|
||||
const index = loadIndexFromCache();
|
||||
|
||||
@@ -324,63 +329,62 @@ export class RecommendCommand extends Command {
|
||||
}
|
||||
|
||||
// Check if index is stale
|
||||
if (isIndexStale(index) && !this.json) {
|
||||
if (isIndexStale(index) && !this.json && !this.quiet) {
|
||||
const lastUpdated = new Date(index.lastUpdated);
|
||||
const hoursSinceUpdate = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
||||
console.log(
|
||||
chalk.dim(`Index is ${Math.round(hoursSinceUpdate)} hours old. Run --update to refresh.\n`)
|
||||
colors.muted(`Index is ${Math.round(hoursSinceUpdate)} hours old. Run --update to refresh.\n`)
|
||||
);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update skill index from sources
|
||||
*/
|
||||
private async updateIndex(): Promise<number> {
|
||||
console.log(chalk.cyan('Updating skill index from GitHub repositories...\n'));
|
||||
console.log(chalk.dim(`Sources: ${KNOWN_SKILL_REPOS.map(r => `${r.owner}/${r.repo}`).join(', ')}\n`));
|
||||
if (!this.quiet) {
|
||||
header('Update Skill Index');
|
||||
}
|
||||
|
||||
const spinner = ora('Fetching skills...').start();
|
||||
console.log(colors.muted(`Sources: ${KNOWN_SKILL_REPOS.map(r => `${r.owner}/${r.repo}`).join(', ')}\n`));
|
||||
|
||||
const s = spinner();
|
||||
s.start('Fetching skills...');
|
||||
|
||||
try {
|
||||
const { index, errors } = await buildSkillIndex(KNOWN_SKILL_REPOS, (message) => {
|
||||
spinner.text = message;
|
||||
s.message(message);
|
||||
});
|
||||
|
||||
spinner.stop();
|
||||
s.stop(`Fetched ${index.skills.length} skills`);
|
||||
|
||||
// Report any errors
|
||||
if (errors.length > 0) {
|
||||
console.log(chalk.yellow('\nWarnings:'));
|
||||
console.log('');
|
||||
console.log(colors.warning('Warnings:'));
|
||||
for (const error of errors) {
|
||||
console.log(chalk.dim(` • ${error}`));
|
||||
console.log(colors.muted(` ${symbols.stepActive} ${error}`));
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
|
||||
// Save the index
|
||||
saveIndex(index);
|
||||
|
||||
console.log(chalk.green(`✓ Updated index with ${index.skills.length} skills`));
|
||||
console.log('');
|
||||
console.log(colors.success(`${symbols.success} Updated index with ${index.skills.length} skills`));
|
||||
if (index.sources.length > 0) {
|
||||
console.log(chalk.dim(` Sources: ${index.sources.map((s) => s.name).join(', ')}`));
|
||||
console.log(colors.muted(` Sources: ${index.sources.map((s) => s.name).join(', ')}`));
|
||||
}
|
||||
console.log(chalk.dim(` Saved to: ${INDEX_PATH}\n`));
|
||||
console.log(colors.muted(` Saved to: ${INDEX_PATH}\n`));
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
spinner.fail('Failed to update index');
|
||||
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
s.stop(colors.error('Failed to update index'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate string to max length
|
||||
*/
|
||||
function truncate(str: string, maxLen: number): string {
|
||||
if (str.length <= maxLen) return str;
|
||||
return str.slice(0, maxLen - 3) + '...';
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { dirname } from 'node:path';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { loadConfig, findAllSkills } from '@skillkit/core';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
import { getAdapter, detectAgent } from '@skillkit/agents';
|
||||
import { getAdapter, detectAgent, getAllAdapters } from '@skillkit/agents';
|
||||
import { getSearchDirs, getAgentConfigPath } from '../helpers.js';
|
||||
import {
|
||||
header,
|
||||
colors,
|
||||
symbols,
|
||||
formatAgent,
|
||||
isCancel,
|
||||
spinner,
|
||||
select,
|
||||
confirm,
|
||||
outro,
|
||||
cancel,
|
||||
warn,
|
||||
showSyncSummary,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
export class SyncCommand extends Command {
|
||||
static override paths = [['sync'], ['s']];
|
||||
@@ -36,19 +49,54 @@ export class SyncCommand extends Command {
|
||||
description: 'Skip confirmation prompts',
|
||||
});
|
||||
|
||||
quiet = Option.Boolean('--quiet,-q', false, {
|
||||
description: 'Minimal output',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const isInteractive = process.stdin.isTTY && !this.yes;
|
||||
|
||||
if (!this.quiet) {
|
||||
header('Sync Skills');
|
||||
}
|
||||
|
||||
try {
|
||||
let agentType: AgentType;
|
||||
const s = spinner();
|
||||
|
||||
if (this.agent) {
|
||||
agentType = this.agent as AgentType;
|
||||
} else if (isInteractive) {
|
||||
// Let user select agent
|
||||
s.start('Detecting agent...');
|
||||
const config = loadConfig();
|
||||
const detected = config.agent || (await detectAgent());
|
||||
s.stop(`Detected: ${formatAgent(detected)}`);
|
||||
|
||||
const allAgents = getAllAdapters().map(a => a.type);
|
||||
|
||||
const agentResult = await select({
|
||||
message: 'Sync to which agent?',
|
||||
options: allAgents.map(a => ({
|
||||
value: a,
|
||||
label: formatAgent(a),
|
||||
hint: a === detected ? '(current)' : undefined,
|
||||
})),
|
||||
initialValue: detected,
|
||||
});
|
||||
|
||||
if (isCancel(agentResult)) {
|
||||
cancel('Sync cancelled');
|
||||
return 0;
|
||||
}
|
||||
|
||||
agentType = agentResult as AgentType;
|
||||
} else {
|
||||
const config = loadConfig();
|
||||
agentType = config.agent || (await detectAgent());
|
||||
}
|
||||
|
||||
const adapter = getAdapter(agentType);
|
||||
|
||||
const outputPath = this.output || getAgentConfigPath(agentType);
|
||||
|
||||
const searchDirs = getSearchDirs(agentType);
|
||||
@@ -59,23 +107,47 @@ export class SyncCommand extends Command {
|
||||
}
|
||||
|
||||
if (skills.length === 0) {
|
||||
console.log(chalk.yellow('No skills found to sync'));
|
||||
console.log(chalk.dim('Install skills with: skillkit install <source>'));
|
||||
warn('No skills found to sync');
|
||||
console.log(colors.muted('Install skills with: skillkit install <source>'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Syncing ${skills.length} skill(s) for ${adapter.name}:`));
|
||||
skills.forEach(s => {
|
||||
const status = s.enabled ? chalk.green('✓') : chalk.dim('○');
|
||||
const location = s.location === 'project' ? chalk.blue('[project]') : chalk.dim('[global]');
|
||||
console.log(` ${status} ${s.name} ${location}`);
|
||||
});
|
||||
console.log();
|
||||
// Show skills to sync
|
||||
if (!this.quiet) {
|
||||
console.log('');
|
||||
console.log(colors.bold(`Syncing ${skills.length} skill(s) for ${adapter.name}:`));
|
||||
console.log('');
|
||||
|
||||
for (const skill of skills) {
|
||||
const status = skill.enabled ? colors.success(symbols.success) : colors.muted(symbols.stepPending);
|
||||
const location = skill.location === 'project'
|
||||
? colors.cyan('[project]')
|
||||
: colors.muted('[global]');
|
||||
console.log(` ${status} ${skill.name} ${location}`);
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
// Confirm sync
|
||||
if (isInteractive && !this.yes) {
|
||||
const confirmResult = await confirm({
|
||||
message: `Sync ${skills.length} skill(s) to ${outputPath}?`,
|
||||
initialValue: true,
|
||||
});
|
||||
|
||||
if (isCancel(confirmResult) || !confirmResult) {
|
||||
cancel('Sync cancelled');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate and write config
|
||||
s.start('Generating config...');
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
if (!config) {
|
||||
console.log(chalk.yellow('No configuration generated'));
|
||||
s.stop('No configuration generated');
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -93,13 +165,23 @@ export class SyncCommand extends Command {
|
||||
|
||||
writeFileSync(outputPath, newContent, 'utf-8');
|
||||
|
||||
console.log(chalk.green(`Synced to ${outputPath}`));
|
||||
console.log(chalk.dim(`Agent: ${adapter.name}`));
|
||||
s.stop('Config generated');
|
||||
|
||||
// Show summary
|
||||
showSyncSummary({
|
||||
skillCount: skills.length,
|
||||
agentType,
|
||||
configPath: outputPath,
|
||||
});
|
||||
|
||||
if (!this.quiet) {
|
||||
outro('Sync complete!');
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Sync failed'));
|
||||
console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
|
||||
} catch (err) {
|
||||
console.log(colors.error('Sync failed'));
|
||||
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
export {
|
||||
AGENT_ICONS,
|
||||
AGENT_NAMES,
|
||||
symbols,
|
||||
SPINNER_FRAMES,
|
||||
colors,
|
||||
formatAgent,
|
||||
getAgentIcon,
|
||||
formatAgentIconsInline,
|
||||
progressBar,
|
||||
formatScore,
|
||||
} from './theme.js';
|
||||
|
||||
export {
|
||||
getLogo,
|
||||
getFullLogo,
|
||||
getCompactLogo,
|
||||
getMinimalLogo,
|
||||
getHeader,
|
||||
getDivider,
|
||||
} from './logo.js';
|
||||
|
||||
export * as prompts from './prompts.js';
|
||||
export {
|
||||
isCancel,
|
||||
intro,
|
||||
outro,
|
||||
cancel,
|
||||
note,
|
||||
log,
|
||||
step,
|
||||
success,
|
||||
warn,
|
||||
error,
|
||||
spinner,
|
||||
text,
|
||||
password,
|
||||
confirm,
|
||||
select,
|
||||
agentMultiselect,
|
||||
skillMultiselect,
|
||||
groupMultiselect,
|
||||
stepTrail,
|
||||
selectInstallMethod,
|
||||
tasks,
|
||||
summaryBox,
|
||||
type SkillOption,
|
||||
} from './prompts.js';
|
||||
|
||||
export {
|
||||
showInstallSummary,
|
||||
showNextSteps,
|
||||
showAgentSummary,
|
||||
showProjectSummary,
|
||||
showSyncSummary,
|
||||
showSkillList,
|
||||
showMarketplaceInfo,
|
||||
type InstallResult,
|
||||
type InstallSummary,
|
||||
} from './summary.js';
|
||||
|
||||
export {
|
||||
loadPreferences,
|
||||
savePreferences,
|
||||
isOnboardingComplete,
|
||||
completeOnboarding,
|
||||
saveLastAgents,
|
||||
getLastAgents,
|
||||
saveInstallMethod,
|
||||
getInstallMethod,
|
||||
getPreferencesDir,
|
||||
getPreferencesPath,
|
||||
type UserPreferences,
|
||||
} from './preferences.js';
|
||||
|
||||
import { getLogo, getHeader } from './logo.js';
|
||||
import * as prompts from './prompts.js';
|
||||
import { colors, formatAgent } from './theme.js';
|
||||
import { showNextSteps } from './summary.js';
|
||||
import {
|
||||
completeOnboarding,
|
||||
saveLastAgents,
|
||||
getLastAgents,
|
||||
} from './preferences.js';
|
||||
|
||||
let VERSION = '1.7.2';
|
||||
let AGENT_COUNT = 17;
|
||||
|
||||
export function setVersion(version: string): void {
|
||||
VERSION = version;
|
||||
}
|
||||
|
||||
export function setAgentCount(count: number): void {
|
||||
AGENT_COUNT = count;
|
||||
}
|
||||
|
||||
export function welcome(): void {
|
||||
console.log(getLogo(VERSION, AGENT_COUNT));
|
||||
}
|
||||
|
||||
export function header(title: string): void {
|
||||
console.log(getHeader(title));
|
||||
}
|
||||
|
||||
export async function runOnboarding(detectedAgents: string[]): Promise<{
|
||||
selectedAgents: string[];
|
||||
cancelled: boolean;
|
||||
}> {
|
||||
welcome();
|
||||
|
||||
if (detectedAgents.length === 0) {
|
||||
prompts.warn('No agents detected');
|
||||
completeOnboarding();
|
||||
return { selectedAgents: [], cancelled: false };
|
||||
}
|
||||
|
||||
prompts.log(`Detected ${detectedAgents.length} agent${detectedAgents.length !== 1 ? 's' : ''}: ${detectedAgents.map(formatAgent).join(', ')}`);
|
||||
|
||||
const agentResult = await prompts.agentMultiselect({
|
||||
message: 'Select agents to configure',
|
||||
agents: detectedAgents,
|
||||
initialValues: detectedAgents,
|
||||
});
|
||||
|
||||
if (prompts.isCancel(agentResult)) {
|
||||
prompts.cancel('Setup cancelled');
|
||||
return { selectedAgents: [], cancelled: true };
|
||||
}
|
||||
|
||||
saveLastAgents(agentResult as string[]);
|
||||
completeOnboarding();
|
||||
|
||||
prompts.success(`Configured ${agentResult.length} agent${agentResult.length !== 1 ? 's' : ''}`);
|
||||
|
||||
return { selectedAgents: agentResult as string[], cancelled: false };
|
||||
}
|
||||
|
||||
export interface InstallFlowOptions {
|
||||
source: string;
|
||||
discoveredSkills: Array<{ name: string; path: string }>;
|
||||
detectedAgents: string[];
|
||||
showLogo?: boolean;
|
||||
}
|
||||
|
||||
export interface InstallFlowResult {
|
||||
selectedSkills: string[];
|
||||
selectedAgents: string[];
|
||||
installMethod: 'symlink' | 'copy';
|
||||
cancelled: boolean;
|
||||
}
|
||||
|
||||
export async function runInstallFlow(options: InstallFlowOptions): Promise<InstallFlowResult> {
|
||||
const { source, discoveredSkills, detectedAgents, showLogo = true } = options;
|
||||
|
||||
if (showLogo) {
|
||||
welcome();
|
||||
}
|
||||
|
||||
prompts.step(`Source: ${colors.cyan(source)}`);
|
||||
prompts.step(`Found ${discoveredSkills.length} skill${discoveredSkills.length !== 1 ? 's' : ''}`);
|
||||
|
||||
const skillNames = discoveredSkills.map(s => s.name);
|
||||
const skillResult = await prompts.skillMultiselect({
|
||||
message: 'Select skills to install',
|
||||
skills: discoveredSkills.map(s => ({ name: s.name })),
|
||||
initialValues: skillNames,
|
||||
});
|
||||
|
||||
if (prompts.isCancel(skillResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return { selectedSkills: [], selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
}
|
||||
|
||||
if (detectedAgents.length > 1) {
|
||||
prompts.step(`Detected ${detectedAgents.length} agents`);
|
||||
}
|
||||
|
||||
const lastAgents = getLastAgents();
|
||||
const initialAgents = lastAgents.length > 0 ? lastAgents : detectedAgents;
|
||||
|
||||
const agentResult = await prompts.agentMultiselect({
|
||||
message: 'Install to which agents?',
|
||||
agents: detectedAgents,
|
||||
initialValues: initialAgents.filter(a => detectedAgents.includes(a)),
|
||||
});
|
||||
|
||||
if (prompts.isCancel(agentResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return { selectedSkills: skillResult as string[], selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
}
|
||||
|
||||
saveLastAgents(agentResult as string[]);
|
||||
|
||||
const methodResult = await prompts.selectInstallMethod({
|
||||
message: 'Installation method',
|
||||
});
|
||||
|
||||
if (prompts.isCancel(methodResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return {
|
||||
selectedSkills: skillResult as string[],
|
||||
selectedAgents: agentResult as string[],
|
||||
installMethod: 'symlink',
|
||||
cancelled: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
selectedSkills: skillResult as string[],
|
||||
selectedAgents: agentResult as string[],
|
||||
installMethod: methodResult as 'symlink' | 'copy',
|
||||
cancelled: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function showCompletion(options: {
|
||||
skillNames: string[];
|
||||
agentTypes: string[];
|
||||
action?: 'install' | 'sync' | 'init';
|
||||
}): void {
|
||||
const action = options.action || 'install';
|
||||
const messages: Record<string, string> = {
|
||||
install: 'Installation complete!',
|
||||
sync: 'Sync complete!',
|
||||
init: 'Initialization complete!',
|
||||
};
|
||||
|
||||
prompts.outro(messages[action] || 'Done!');
|
||||
showNextSteps(options);
|
||||
}
|
||||
|
||||
export function handleCancel(message?: string): void {
|
||||
prompts.cancel(message || 'Operation cancelled');
|
||||
process.exit(0);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import pc from 'picocolors';
|
||||
import { symbols } from './theme.js';
|
||||
|
||||
function getTerminalWidth(): number {
|
||||
return process.stdout.columns || 80;
|
||||
}
|
||||
|
||||
export function getFullLogo(version?: string, agentCount?: number): string {
|
||||
const lines = [
|
||||
'',
|
||||
pc.dim(' ') + pc.white('███████╗') + pc.gray('██╗ ██╗') + pc.dim('██╗') + pc.gray('██╗ ') + pc.dim('██╗ ') + pc.white('██╗ ██╗') + pc.gray('██╗') + pc.dim('████████╗'),
|
||||
pc.dim(' ') + pc.white('██╔════╝') + pc.gray('██║ ██╔╝') + pc.dim('██║') + pc.gray('██║ ') + pc.dim('██║ ') + pc.white('██║ ██╔╝') + pc.gray('██║') + pc.dim('╚══██╔══╝'),
|
||||
pc.dim(' ') + pc.white('███████╗') + pc.gray('█████╔╝ ') + pc.dim('██║') + pc.gray('██║ ') + pc.dim('██║ ') + pc.white('█████╔╝ ') + pc.gray('██║') + pc.dim(' ██║ '),
|
||||
pc.dim(' ') + pc.white('╚════██║') + pc.gray('██╔═██╗ ') + pc.dim('██║') + pc.gray('██║ ') + pc.dim('██║ ') + pc.white('██╔═██╗ ') + pc.gray('██║') + pc.dim(' ██║ '),
|
||||
pc.dim(' ') + pc.white('███████║') + pc.gray('██║ ██╗') + pc.dim('██║') + pc.gray('███████╗') + pc.dim('███████╗') + pc.white('██║ ██╗') + pc.gray('██║') + pc.dim(' ██║ '),
|
||||
pc.dim(' ') + pc.white('╚══════╝') + pc.gray('╚═╝ ╚═╝') + pc.dim('╚═╝') + pc.gray('╚══════╝') + pc.dim('╚══════╝') + pc.white('╚═╝ ╚═╝') + pc.gray('╚═╝') + pc.dim(' ╚═╝ '),
|
||||
'',
|
||||
];
|
||||
|
||||
if (version || agentCount) {
|
||||
const info: string[] = [];
|
||||
if (version) info.push(`v${version}`);
|
||||
if (agentCount) info.push(`${agentCount} agents`);
|
||||
lines.push(pc.dim(' ') + pc.dim(info.join(' │ ')));
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function getCompactLogo(version?: string, agentCount?: number): string {
|
||||
const frame = `${symbols.frameCorner}${symbols.frameLine.repeat(18)}${symbols.frameCorner}`;
|
||||
|
||||
const lines = [
|
||||
'',
|
||||
pc.dim(` ${frame}`),
|
||||
pc.dim(' ') + pc.white(' S K I L L K I T '),
|
||||
pc.dim(` ${frame}`),
|
||||
];
|
||||
|
||||
if (version || agentCount) {
|
||||
const info: string[] = [];
|
||||
if (version) info.push(`v${version}`);
|
||||
if (agentCount) info.push(`${agentCount} agents`);
|
||||
lines.push(pc.dim(' ') + pc.dim(info.join(' │ ')));
|
||||
}
|
||||
|
||||
lines.push('');
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function getMinimalLogo(version?: string): string {
|
||||
const lines = [
|
||||
'',
|
||||
pc.dim(`${symbols.diamondOpen}───`) + pc.white('SKILLKIT') + pc.dim(`───${symbols.diamondOpen}`),
|
||||
];
|
||||
|
||||
if (version) {
|
||||
lines.push(pc.dim(` v${version}`));
|
||||
}
|
||||
|
||||
lines.push('');
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function getLogo(version?: string, agentCount?: number): string {
|
||||
const width = getTerminalWidth();
|
||||
|
||||
if (width >= 70) {
|
||||
return getFullLogo(version, agentCount);
|
||||
}
|
||||
if (width >= 50) {
|
||||
return getCompactLogo(version, agentCount);
|
||||
}
|
||||
return getMinimalLogo(version);
|
||||
}
|
||||
|
||||
export function getHeader(title: string): string {
|
||||
return `\n${pc.dim(symbols.diamondOpen)} ${pc.white(pc.bold('SkillKit'))} ${pc.dim('│')} ${pc.cyan(title)}\n`;
|
||||
}
|
||||
|
||||
export function getDivider(width?: number): string {
|
||||
const fallback = Math.min(getTerminalWidth() - 4, 60);
|
||||
const w = Math.max(1, width ?? fallback);
|
||||
return pc.dim(symbols.horizontalLine.repeat(w));
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
|
||||
const SKILLKIT_DIR = join(homedir(), '.skillkit');
|
||||
const PREFERENCES_FILE = join(SKILLKIT_DIR, 'preferences.json');
|
||||
|
||||
export interface UserPreferences {
|
||||
onboardingComplete: boolean;
|
||||
lastSelectedAgents: string[];
|
||||
defaultInstallMethod: 'symlink' | 'copy';
|
||||
outputFormat: 'pretty' | 'json';
|
||||
lastAccessed: string;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_PREFERENCES: UserPreferences = {
|
||||
onboardingComplete: false,
|
||||
lastSelectedAgents: [],
|
||||
defaultInstallMethod: 'symlink',
|
||||
outputFormat: 'pretty',
|
||||
lastAccessed: new Date().toISOString(),
|
||||
};
|
||||
|
||||
function ensureDir(): void {
|
||||
if (!existsSync(SKILLKIT_DIR)) {
|
||||
mkdirSync(SKILLKIT_DIR, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
export function loadPreferences(): UserPreferences {
|
||||
try {
|
||||
if (!existsSync(PREFERENCES_FILE)) {
|
||||
return { ...DEFAULT_PREFERENCES };
|
||||
}
|
||||
|
||||
const content = readFileSync(PREFERENCES_FILE, 'utf-8');
|
||||
const data = JSON.parse(content);
|
||||
|
||||
return {
|
||||
...DEFAULT_PREFERENCES,
|
||||
...data,
|
||||
lastAccessed: new Date().toISOString(),
|
||||
};
|
||||
} catch {
|
||||
return { ...DEFAULT_PREFERENCES };
|
||||
}
|
||||
}
|
||||
|
||||
export function savePreferences(prefs: Partial<UserPreferences>): void {
|
||||
try {
|
||||
ensureDir();
|
||||
|
||||
const current = loadPreferences();
|
||||
const updated: UserPreferences = {
|
||||
...current,
|
||||
...prefs,
|
||||
lastAccessed: new Date().toISOString(),
|
||||
};
|
||||
|
||||
writeFileSync(PREFERENCES_FILE, JSON.stringify(updated, null, 2), 'utf-8');
|
||||
} catch {
|
||||
// Silently fail - preferences are not critical
|
||||
}
|
||||
}
|
||||
|
||||
export function isOnboardingComplete(): boolean {
|
||||
return loadPreferences().onboardingComplete;
|
||||
}
|
||||
|
||||
export function completeOnboarding(): void {
|
||||
savePreferences({ onboardingComplete: true });
|
||||
}
|
||||
|
||||
export function saveLastAgents(agents: string[]): void {
|
||||
savePreferences({ lastSelectedAgents: agents });
|
||||
}
|
||||
|
||||
export function getLastAgents(): string[] {
|
||||
return loadPreferences().lastSelectedAgents;
|
||||
}
|
||||
|
||||
export function saveInstallMethod(method: 'symlink' | 'copy'): void {
|
||||
savePreferences({ defaultInstallMethod: method });
|
||||
}
|
||||
|
||||
export function getInstallMethod(): 'symlink' | 'copy' {
|
||||
return loadPreferences().defaultInstallMethod;
|
||||
}
|
||||
|
||||
export function getPreferencesDir(): string {
|
||||
return SKILLKIT_DIR;
|
||||
}
|
||||
|
||||
export function getPreferencesPath(): string {
|
||||
return PREFERENCES_FILE;
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
import * as clack from '@clack/prompts';
|
||||
import pc from 'picocolors';
|
||||
import { symbols, colors, formatAgent, formatScore } from './theme.js';
|
||||
|
||||
export function isCancel(value: unknown): value is symbol {
|
||||
return clack.isCancel(value);
|
||||
}
|
||||
|
||||
export function intro(message?: string): void {
|
||||
clack.intro(message ? pc.bold(message) : undefined);
|
||||
}
|
||||
|
||||
export function outro(message: string): void {
|
||||
clack.outro(pc.green(message));
|
||||
}
|
||||
|
||||
export function cancel(message: string = 'Operation cancelled'): void {
|
||||
clack.cancel(pc.yellow(message));
|
||||
}
|
||||
|
||||
export function note(message: string, title?: string): void {
|
||||
clack.note(message, title);
|
||||
}
|
||||
|
||||
export function log(message: string): void {
|
||||
clack.log.info(message);
|
||||
}
|
||||
|
||||
export function step(message: string): void {
|
||||
clack.log.step(message);
|
||||
}
|
||||
|
||||
export function success(message: string): void {
|
||||
clack.log.success(pc.green(message));
|
||||
}
|
||||
|
||||
export function warn(message: string): void {
|
||||
clack.log.warn(pc.yellow(message));
|
||||
}
|
||||
|
||||
export function error(message: string): void {
|
||||
clack.log.error(pc.red(message));
|
||||
}
|
||||
|
||||
export function spinner(): ReturnType<typeof clack.spinner> {
|
||||
return clack.spinner();
|
||||
}
|
||||
|
||||
export async function text(options: {
|
||||
message: string;
|
||||
placeholder?: string;
|
||||
defaultValue?: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}): Promise<string | symbol> {
|
||||
return clack.text({
|
||||
message: options.message,
|
||||
placeholder: options.placeholder,
|
||||
defaultValue: options.defaultValue,
|
||||
validate: options.validate,
|
||||
});
|
||||
}
|
||||
|
||||
export async function password(options: {
|
||||
message: string;
|
||||
validate?: (value: string) => string | Error | undefined;
|
||||
}): Promise<string | symbol> {
|
||||
return clack.password({
|
||||
message: options.message,
|
||||
validate: options.validate,
|
||||
});
|
||||
}
|
||||
|
||||
export async function confirm(options: {
|
||||
message: string;
|
||||
initialValue?: boolean;
|
||||
}): Promise<boolean | symbol> {
|
||||
return clack.confirm({
|
||||
message: options.message,
|
||||
initialValue: options.initialValue,
|
||||
});
|
||||
}
|
||||
|
||||
export async function select<T extends string>(options: {
|
||||
message: string;
|
||||
options: Array<{ value: T; label: string; hint?: string }>;
|
||||
initialValue?: T;
|
||||
}): Promise<T | symbol> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return clack.select({
|
||||
message: options.message,
|
||||
options: options.options as any,
|
||||
initialValue: options.initialValue,
|
||||
});
|
||||
}
|
||||
|
||||
export async function agentMultiselect(options: {
|
||||
message: string;
|
||||
agents: string[];
|
||||
initialValues?: string[];
|
||||
required?: boolean;
|
||||
}): Promise<string[] | symbol> {
|
||||
const agentOptions = options.agents.map((agent) => ({
|
||||
value: agent,
|
||||
label: formatAgent(agent),
|
||||
hint: undefined as string | undefined,
|
||||
}));
|
||||
|
||||
return clack.multiselect({
|
||||
message: options.message,
|
||||
options: agentOptions,
|
||||
initialValues: options.initialValues,
|
||||
required: options.required ?? true,
|
||||
});
|
||||
}
|
||||
|
||||
export interface SkillOption {
|
||||
name: string;
|
||||
description?: string;
|
||||
score?: number;
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export async function skillMultiselect(options: {
|
||||
message: string;
|
||||
skills: SkillOption[];
|
||||
initialValues?: string[];
|
||||
required?: boolean;
|
||||
}): Promise<string[] | symbol> {
|
||||
const skillOptions = options.skills.map((skill) => {
|
||||
const label = skill.name;
|
||||
let hint: string | undefined;
|
||||
|
||||
if (skill.score !== undefined) {
|
||||
hint = formatScore(skill.score);
|
||||
} else if (skill.source) {
|
||||
hint = pc.dim(skill.source);
|
||||
}
|
||||
|
||||
return { value: skill.name, label, hint };
|
||||
});
|
||||
|
||||
return clack.multiselect({
|
||||
message: options.message,
|
||||
options: skillOptions,
|
||||
initialValues: options.initialValues,
|
||||
required: options.required ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
export async function groupMultiselect<T extends string>(options: {
|
||||
message: string;
|
||||
options: Record<string, Array<{ value: T; label: string; hint?: string }>>;
|
||||
required?: boolean;
|
||||
}): Promise<T[] | symbol> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return clack.groupMultiselect({
|
||||
message: options.message,
|
||||
options: options.options as any,
|
||||
required: options.required,
|
||||
});
|
||||
}
|
||||
|
||||
export function stepTrail(steps: Array<{ label: string; status: 'pending' | 'active' | 'complete' }>): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
for (let i = 0; i < steps.length; i++) {
|
||||
const currentStep = steps[i];
|
||||
const isLast = i === steps.length - 1;
|
||||
|
||||
let icon: string;
|
||||
let labelColor: (text: string) => string;
|
||||
|
||||
switch (currentStep.status) {
|
||||
case 'complete':
|
||||
icon = colors.success(symbols.stepComplete);
|
||||
labelColor = colors.muted;
|
||||
break;
|
||||
case 'active':
|
||||
icon = colors.accent(symbols.stepActive);
|
||||
labelColor = colors.primary;
|
||||
break;
|
||||
case 'pending':
|
||||
default:
|
||||
icon = colors.muted(symbols.stepPending);
|
||||
labelColor = colors.muted;
|
||||
break;
|
||||
}
|
||||
|
||||
lines.push(`${icon} ${labelColor(currentStep.label)}`);
|
||||
|
||||
if (!isLast) {
|
||||
lines.push(`${colors.muted(symbols.stepLine)}`);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export async function selectInstallMethod(options: {
|
||||
message?: string;
|
||||
}): Promise<'symlink' | 'copy' | symbol> {
|
||||
return clack.select({
|
||||
message: options.message || 'Installation method',
|
||||
options: [
|
||||
{
|
||||
value: 'symlink' as const,
|
||||
label: 'Symlink (Recommended)',
|
||||
hint: 'Single source, auto-updates',
|
||||
},
|
||||
{
|
||||
value: 'copy' as const,
|
||||
label: 'Copy to all agents',
|
||||
hint: 'Independent copies',
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
export async function tasks(
|
||||
taskList: Array<{
|
||||
title: string;
|
||||
task: (message: (msg: string) => void) => Promise<string | void>;
|
||||
enabled?: boolean;
|
||||
}>
|
||||
): Promise<void> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return clack.tasks(taskList.filter((t) => t.enabled !== false) as any);
|
||||
}
|
||||
|
||||
export function summaryBox(options: {
|
||||
title: string;
|
||||
items: Array<{ label: string; value: string; icon?: string }>;
|
||||
}): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const item of options.items) {
|
||||
const icon = item.icon ? `${item.icon} ` : '';
|
||||
lines.push(` ${icon}${colors.primary(item.label)}`);
|
||||
lines.push(` ${colors.muted(item.value)}`);
|
||||
}
|
||||
|
||||
clack.note(lines.join('\n'), options.title);
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import * as prompts from './prompts.js';
|
||||
import { symbols, colors, formatAgent, getAgentIcon, formatAgentIconsInline } from './theme.js';
|
||||
|
||||
export interface InstallResult {
|
||||
skillName: string;
|
||||
method: 'symlink' | 'copy';
|
||||
agents: string[];
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface InstallSummary {
|
||||
totalSkills: number;
|
||||
totalAgents: number;
|
||||
results: InstallResult[];
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export function showInstallSummary(summary: InstallSummary): void {
|
||||
const title = `Installed ${summary.totalSkills} skill${summary.totalSkills !== 1 ? 's' : ''} to ${summary.totalAgents} agent${summary.totalAgents !== 1 ? 's' : ''}`;
|
||||
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const result of summary.results) {
|
||||
lines.push(`${colors.success(symbols.success)} ${colors.primary(result.skillName)}`);
|
||||
|
||||
const agentDisplay = result.agents.length <= 3
|
||||
? result.agents.map(formatAgent).join(', ')
|
||||
: `${formatAgentIconsInline(result.agents.slice(0, 3))} +${result.agents.length - 3} more`;
|
||||
|
||||
lines.push(` ${result.method} ${symbols.arrowRight} ${agentDisplay}`);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
prompts.note(lines.join('\n').trim(), title);
|
||||
}
|
||||
|
||||
export function showNextSteps(options: {
|
||||
skillNames: string[];
|
||||
agentTypes: string[];
|
||||
syncNeeded?: boolean;
|
||||
}): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`${colors.muted('1.')} Run ${colors.cyan('skillkit sync')} to update agent configs`);
|
||||
lines.push(`${colors.muted('2.')} Use ${colors.cyan(`skillkit read ${options.skillNames[0] || '<skill>'}`)} to view skill docs`);
|
||||
|
||||
if (options.agentTypes.includes('claude-code')) {
|
||||
lines.push(`${colors.muted('3.')} Skills are available via ${colors.cyan('/@')} in Claude Code`);
|
||||
} else if (options.agentTypes.includes('cursor')) {
|
||||
lines.push(`${colors.muted('3.')} Skills are available in Cursor rules`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(colors.dim('Next steps:'));
|
||||
console.log(lines.map(l => ` ${l}`).join('\n'));
|
||||
console.log('');
|
||||
}
|
||||
|
||||
export function showAgentSummary(agents: string[]): void {
|
||||
console.log('');
|
||||
console.log(colors.dim('Detected agents:'));
|
||||
|
||||
const iconLine = agents.map(a => `${getAgentIcon(a)} ${colors.muted(a)}`).join(' ');
|
||||
console.log(` ${iconLine}`);
|
||||
console.log('');
|
||||
}
|
||||
|
||||
export function showProjectSummary(profile: {
|
||||
name: string;
|
||||
type?: string;
|
||||
languages: string[];
|
||||
frameworks: string[];
|
||||
}): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`${colors.primary('Project:')} ${profile.name}`);
|
||||
|
||||
if (profile.type) {
|
||||
lines.push(`${colors.primary('Type:')} ${profile.type}`);
|
||||
}
|
||||
|
||||
if (profile.languages.length > 0) {
|
||||
lines.push(`${colors.primary('Languages:')} ${profile.languages.join(', ')}`);
|
||||
}
|
||||
|
||||
if (profile.frameworks.length > 0) {
|
||||
lines.push(`${colors.primary('Frameworks:')} ${profile.frameworks.join(', ')}`);
|
||||
}
|
||||
|
||||
prompts.note(lines.join('\n'), 'Project Analysis');
|
||||
}
|
||||
|
||||
export function showSyncSummary(options: {
|
||||
skillCount: number;
|
||||
agentType: string;
|
||||
configPath: string;
|
||||
}): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`${colors.success(symbols.success)} Synced ${options.skillCount} skill${options.skillCount !== 1 ? 's' : ''}`);
|
||||
lines.push(` Agent: ${formatAgent(options.agentType)}`);
|
||||
lines.push(` Config: ${colors.muted(options.configPath)}`);
|
||||
|
||||
console.log('');
|
||||
console.log(lines.join('\n'));
|
||||
console.log('');
|
||||
}
|
||||
|
||||
export function showSkillList(skills: Array<{
|
||||
name: string;
|
||||
description?: string;
|
||||
score?: number;
|
||||
source?: string;
|
||||
installed?: boolean;
|
||||
}>): void {
|
||||
console.log('');
|
||||
|
||||
for (const skill of skills) {
|
||||
let line = '';
|
||||
|
||||
if (skill.installed) {
|
||||
line += colors.success(symbols.success) + ' ';
|
||||
} else {
|
||||
line += colors.muted(symbols.stepPending) + ' ';
|
||||
}
|
||||
|
||||
line += colors.primary(skill.name);
|
||||
|
||||
if (skill.score !== undefined) {
|
||||
let scoreColor: (text: string) => string;
|
||||
if (skill.score >= 70) {
|
||||
scoreColor = colors.success;
|
||||
} else if (skill.score >= 50) {
|
||||
scoreColor = colors.warning;
|
||||
} else {
|
||||
scoreColor = colors.muted;
|
||||
}
|
||||
line += ` ${scoreColor(`${skill.score}%`)}`;
|
||||
}
|
||||
|
||||
console.log(line);
|
||||
|
||||
if (skill.description) {
|
||||
console.log(` ${colors.muted(truncate(skill.description, 60))}`);
|
||||
}
|
||||
|
||||
if (skill.source) {
|
||||
console.log(` ${colors.dim(`Source: ${skill.source}`)}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
}
|
||||
|
||||
export function showMarketplaceInfo(options: {
|
||||
totalSkills: number;
|
||||
sourceCount: number;
|
||||
lastUpdated?: string;
|
||||
}): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`Total skills: ${colors.cyan(String(options.totalSkills))}`);
|
||||
lines.push(`Sources: ${colors.cyan(String(options.sourceCount))}`);
|
||||
|
||||
if (options.lastUpdated) {
|
||||
const date = new Date(options.lastUpdated).toLocaleDateString();
|
||||
lines.push(`Updated: ${colors.muted(date)}`);
|
||||
}
|
||||
|
||||
prompts.note(lines.join('\n'), 'Skill Marketplace');
|
||||
}
|
||||
|
||||
function truncate(str: string, maxLen: number): string {
|
||||
if (str.length <= maxLen) return str;
|
||||
return str.slice(0, maxLen - 3) + '...';
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import pc from 'picocolors';
|
||||
|
||||
export const AGENT_ICONS: Record<string, string> = {
|
||||
'claude-code': '\u27c1',
|
||||
'cursor': '\u25eb',
|
||||
'codex': '\u25ce',
|
||||
'gemini-cli': '\u2726',
|
||||
'opencode': '\u2b21',
|
||||
'github-copilot': '\u25c8',
|
||||
'windsurf': '\u224b',
|
||||
'droid': '\u25a3',
|
||||
'goose': '\u25c7',
|
||||
'amp': '\u25b3',
|
||||
'kilo': '\u25c9',
|
||||
'kiro-cli': '\u2b22',
|
||||
'roo': '\u2299',
|
||||
'trae': '\u25c6',
|
||||
'antigravity': '\u229b',
|
||||
'clawdbot': '\u27d0',
|
||||
'universal': '\u25cf',
|
||||
};
|
||||
|
||||
export const AGENT_NAMES: Record<string, string> = {
|
||||
'claude-code': 'Claude Code',
|
||||
'cursor': 'Cursor',
|
||||
'codex': 'Codex CLI',
|
||||
'gemini-cli': 'Gemini CLI',
|
||||
'opencode': 'OpenCode',
|
||||
'github-copilot': 'Copilot',
|
||||
'windsurf': 'Windsurf',
|
||||
'droid': 'Droid',
|
||||
'goose': 'Goose',
|
||||
'amp': 'Amp',
|
||||
'kilo': 'Kilo Code',
|
||||
'kiro-cli': 'Kiro',
|
||||
'roo': 'Roo Code',
|
||||
'trae': 'Trae',
|
||||
'antigravity': 'Antigravity',
|
||||
'clawdbot': 'Clawdbot',
|
||||
'universal': 'Universal',
|
||||
};
|
||||
|
||||
export const symbols = {
|
||||
stepPending: '\u25cb',
|
||||
stepActive: '\u25cf',
|
||||
stepComplete: '\u25cf',
|
||||
stepLine: '\u2502',
|
||||
selected: '\u25cf',
|
||||
unselected: '\u25cb',
|
||||
pointer: '\u25b8',
|
||||
progressFull: '\u2588',
|
||||
progressEmpty: '\u2591',
|
||||
success: '\u2713',
|
||||
error: '\u2717',
|
||||
warning: '\u26a0',
|
||||
info: '\u2139',
|
||||
arrowRight: '\u2192',
|
||||
arrowLeft: '\u2190',
|
||||
diamondOpen: '\u25c7',
|
||||
diamondFilled: '\u25c6',
|
||||
horizontalLine: '\u2500',
|
||||
verticalLine: '\u2502',
|
||||
frameCorner: '\u25c7',
|
||||
frameLine: '\u2500',
|
||||
};
|
||||
|
||||
export const SPINNER_FRAMES = [
|
||||
'\u280b',
|
||||
'\u2819',
|
||||
'\u2839',
|
||||
'\u2838',
|
||||
'\u283c',
|
||||
'\u2834',
|
||||
'\u2826',
|
||||
'\u2827',
|
||||
'\u2807',
|
||||
'\u280f',
|
||||
];
|
||||
|
||||
export const colors = {
|
||||
accent: (text: string) => pc.green(text),
|
||||
accentBright: (text: string) => pc.bold(pc.green(text)),
|
||||
primary: (text: string) => pc.white(text),
|
||||
secondary: (text: string) => pc.gray(text),
|
||||
muted: (text: string) => pc.dim(text),
|
||||
success: (text: string) => pc.green(text),
|
||||
error: (text: string) => pc.red(text),
|
||||
warning: (text: string) => pc.yellow(text),
|
||||
info: (text: string) => pc.blue(text),
|
||||
bold: (text: string) => pc.bold(text),
|
||||
dim: (text: string) => pc.dim(text),
|
||||
underline: (text: string) => pc.underline(text),
|
||||
cyan: (text: string) => pc.cyan(text),
|
||||
magenta: (text: string) => pc.magenta(text),
|
||||
};
|
||||
|
||||
export function formatAgent(agentType: string): string {
|
||||
const icon = AGENT_ICONS[agentType] || symbols.stepActive;
|
||||
const name = AGENT_NAMES[agentType] || agentType;
|
||||
return `${icon} ${name}`;
|
||||
}
|
||||
|
||||
export function getAgentIcon(agentType: string): string {
|
||||
return AGENT_ICONS[agentType] || symbols.stepActive;
|
||||
}
|
||||
|
||||
export function formatAgentIconsInline(agents: string[]): string {
|
||||
return agents.map(a => getAgentIcon(a)).join(' ');
|
||||
}
|
||||
|
||||
export function progressBar(value: number, total: number, width: number = 6): string {
|
||||
if (width <= 0 || total <= 0) return '';
|
||||
const clampedValue = Math.min(Math.max(value, 0), total);
|
||||
const filled = Math.round((clampedValue / total) * width);
|
||||
const safeFilled = Math.min(Math.max(filled, 0), width);
|
||||
const empty = width - safeFilled;
|
||||
return symbols.progressFull.repeat(safeFilled) + symbols.progressEmpty.repeat(empty);
|
||||
}
|
||||
|
||||
export function formatScore(score: number): string {
|
||||
const bar = progressBar(score, 100, 6);
|
||||
let scoreColor: (text: string) => string;
|
||||
if (score >= 70) {
|
||||
scoreColor = colors.success;
|
||||
} else if (score >= 50) {
|
||||
scoreColor = colors.warning;
|
||||
} else {
|
||||
scoreColor = colors.muted;
|
||||
}
|
||||
return `${scoreColor(`${score}%`)} ${colors.dim(bar)}`;
|
||||
}
|
||||
Generated
+28
@@ -82,6 +82,9 @@ importers:
|
||||
|
||||
packages/cli:
|
||||
dependencies:
|
||||
'@clack/prompts':
|
||||
specifier: ^0.11.0
|
||||
version: 0.11.0
|
||||
'@skillkit/agents':
|
||||
specifier: workspace:*
|
||||
version: link:../agents
|
||||
@@ -106,6 +109,9 @@ importers:
|
||||
ora:
|
||||
specifier: ^8.1.0
|
||||
version: 8.2.0
|
||||
picocolors:
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
yaml:
|
||||
specifier: ^2.7.0
|
||||
version: 2.8.2
|
||||
@@ -187,6 +193,12 @@ importers:
|
||||
|
||||
packages:
|
||||
|
||||
'@clack/core@0.5.0':
|
||||
resolution: {integrity: sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow==}
|
||||
|
||||
'@clack/prompts@0.11.0':
|
||||
resolution: {integrity: sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw==}
|
||||
|
||||
'@dimforge/rapier2d-simd-compat@0.17.3':
|
||||
resolution: {integrity: sha512-bijvwWz6NHsNj5e5i1vtd3dU2pDhthSaTUZSh14DUGGKJfw8eMnlWZsxwHBxB/a3AXVNDjL9abuHw1k9FGR+jg==}
|
||||
|
||||
@@ -1524,6 +1536,9 @@ packages:
|
||||
resolution: {integrity: sha512-kWJDCr9EWtZ+/EYYM5MareWj2cRnZGF93YDNpH4jQiHB+hBIZnfPFSQiVMzZOdk+zXWqTZ/9fTeQNu2DqeiudA==}
|
||||
engines: {node: '>=20.12.2'}
|
||||
|
||||
sisteransi@1.0.5:
|
||||
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -1823,6 +1838,17 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@clack/core@0.5.0':
|
||||
dependencies:
|
||||
picocolors: 1.1.1
|
||||
sisteransi: 1.0.5
|
||||
|
||||
'@clack/prompts@0.11.0':
|
||||
dependencies:
|
||||
'@clack/core': 0.5.0
|
||||
picocolors: 1.1.1
|
||||
sisteransi: 1.0.5
|
||||
|
||||
'@dimforge/rapier2d-simd-compat@0.17.3':
|
||||
optional: true
|
||||
|
||||
@@ -3072,6 +3098,8 @@ snapshots:
|
||||
|
||||
simple-xml-to-json@1.2.3: {}
|
||||
|
||||
sisteransi@1.0.5: {}
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
|
||||
source-map@0.7.6: {}
|
||||
|
||||
Reference in New Issue
Block a user