mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
fix: version display, install UX — audit findings (#95)
* fix: version display, install UX — audit findings - Fix version showing hardcoded 1.7.6 instead of actual 1.19.2 - Export setVersion/setAgentCount from @skillkit/cli - Call setVersion(version) and setAgentCount(getAllAdapters().length) in cli.ts - Change fallback from '1.7.6' to 'dev' so stale values are obvious - Fix install pre-selecting all skills by default (bad UX) - Add "Install all / Select specific" prompt before multiselect - When selecting manually, start with nothing pre-selected - Apply same fix to both InstallCommand and runInstallFlow() - Matches existing quickAgentSelect pattern Fixes found during comprehensive codebase audit. Related issues: #87, #88, #89, #90, #91, #92, #93, #94 * refactor: extract quickSkillSelect, use getAdapterCount - Extract duplicated "Install all / Select specific" pattern into quickSkillSelect() in prompts.ts (mirrors existing quickAgentSelect) - Both install.ts and runInstallFlow() now use the shared helper - Add getAdapterCount() to @skillkit/agents to avoid allocating 44 spread-copied objects just to call .length - Use getAdapterCount() in cli.ts instead of getAllAdapters().length
This commit is contained in:
@@ -3,6 +3,8 @@ import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { Cli, Builtins } from 'clipanion';
|
||||
import { setVersion, setAgentCount } from '@skillkit/cli';
|
||||
import { getAdapterCount } from '@skillkit/agents';
|
||||
import {
|
||||
InstallCommand,
|
||||
SyncCommand,
|
||||
@@ -130,6 +132,9 @@ const packageJsonPath = join(__dirname, '../package.json');
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
||||
const version = packageJson.version || '1.2.0';
|
||||
|
||||
setVersion(version);
|
||||
setAgentCount(getAdapterCount());
|
||||
|
||||
const cli = new Cli({
|
||||
binaryLabel: 'skillkit',
|
||||
binaryName: 'skillkit',
|
||||
|
||||
@@ -107,6 +107,10 @@ export function getAllAdapters(): AgentAdapterWithType[] {
|
||||
}));
|
||||
}
|
||||
|
||||
export function getAdapterCount(): number {
|
||||
return Object.keys(adapters).length;
|
||||
}
|
||||
|
||||
export async function detectAgent(): Promise<AgentType> {
|
||||
const checkOrder: AgentType[] = [
|
||||
'claude-code',
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
isCancel,
|
||||
spinner,
|
||||
quickAgentSelect,
|
||||
skillMultiselect,
|
||||
quickSkillSelect,
|
||||
selectInstallMethod,
|
||||
confirm,
|
||||
outro,
|
||||
@@ -273,13 +273,10 @@ export class InstallCommand extends Command {
|
||||
} else if (this.all || this.yes) {
|
||||
skillsToInstall = discoveredSkills;
|
||||
} else if (isInteractive && discoveredSkills.length > 1) {
|
||||
// Interactive skill selection
|
||||
step(`Source: ${colors.cyan(this.source)}`);
|
||||
|
||||
const skillResult = await skillMultiselect({
|
||||
message: "Select skills to install",
|
||||
const skillResult = await quickSkillSelect({
|
||||
skills: discoveredSkills.map((s) => ({ name: s.name })),
|
||||
initialValues: discoveredSkills.map((s) => s.name),
|
||||
});
|
||||
|
||||
if (isCancel(skillResult)) {
|
||||
@@ -287,8 +284,9 @@ export class InstallCommand extends Command {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const selected = (skillResult as { skills: string[] }).skills;
|
||||
skillsToInstall = discoveredSkills.filter((s) =>
|
||||
(skillResult as string[]).includes(s.name),
|
||||
selected.includes(s.name),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,8 @@ export * from './commands/index.js';
|
||||
// Export helper functions
|
||||
export * from './helpers.js';
|
||||
|
||||
// Export onboarding utilities
|
||||
export { setVersion, setAgentCount } from './onboarding/index.js';
|
||||
|
||||
// Re-export commonly used types from core
|
||||
export type { AgentType, Skill, SkillMetadata, SkillkitConfig } from '@skillkit/core';
|
||||
|
||||
@@ -42,6 +42,7 @@ export {
|
||||
select,
|
||||
agentMultiselect,
|
||||
quickAgentSelect,
|
||||
quickSkillSelect,
|
||||
skillMultiselect,
|
||||
groupMultiselect,
|
||||
stepTrail,
|
||||
@@ -87,8 +88,8 @@ import {
|
||||
getLastAgents,
|
||||
} from './preferences.js';
|
||||
|
||||
let VERSION = '1.7.6';
|
||||
let AGENT_COUNT = 44;
|
||||
let VERSION = 'dev';
|
||||
let AGENT_COUNT = 0;
|
||||
|
||||
export function setVersion(version: string): void {
|
||||
VERSION = version;
|
||||
@@ -161,18 +162,22 @@ export async function runInstallFlow(options: InstallFlowOptions): Promise<Insta
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
let selectedSkills: string[];
|
||||
|
||||
if (prompts.isCancel(skillResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return { selectedSkills: [], selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
if (discoveredSkills.length > 1) {
|
||||
const skillResult = await prompts.quickSkillSelect({
|
||||
skills: discoveredSkills.map(s => ({ name: s.name })),
|
||||
});
|
||||
|
||||
if (prompts.isCancel(skillResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return { selectedSkills: [], selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
}
|
||||
|
||||
selectedSkills = (skillResult as { skills: string[] }).skills;
|
||||
} else {
|
||||
selectedSkills = discoveredSkills.map(s => s.name);
|
||||
}
|
||||
|
||||
if (detectedAgents.length > 1) {
|
||||
@@ -190,7 +195,7 @@ export async function runInstallFlow(options: InstallFlowOptions): Promise<Insta
|
||||
|
||||
if (prompts.isCancel(agentResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return { selectedSkills: skillResult as string[], selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
return { selectedSkills, selectedAgents: [], installMethod: 'symlink', cancelled: true };
|
||||
}
|
||||
|
||||
saveLastAgents(agentResult as string[]);
|
||||
@@ -202,7 +207,7 @@ export async function runInstallFlow(options: InstallFlowOptions): Promise<Insta
|
||||
if (prompts.isCancel(methodResult)) {
|
||||
prompts.cancel('Installation cancelled');
|
||||
return {
|
||||
selectedSkills: skillResult as string[],
|
||||
selectedSkills,
|
||||
selectedAgents: agentResult as string[],
|
||||
installMethod: 'symlink',
|
||||
cancelled: true,
|
||||
@@ -210,7 +215,7 @@ export async function runInstallFlow(options: InstallFlowOptions): Promise<Insta
|
||||
}
|
||||
|
||||
return {
|
||||
selectedSkills: skillResult as string[],
|
||||
selectedSkills,
|
||||
selectedAgents: agentResult as string[],
|
||||
installMethod: methodResult as 'symlink' | 'copy',
|
||||
cancelled: false,
|
||||
|
||||
@@ -213,6 +213,43 @@ export async function skillMultiselect(options: {
|
||||
});
|
||||
}
|
||||
|
||||
export async function quickSkillSelect(options: {
|
||||
message?: string;
|
||||
skills: SkillOption[];
|
||||
}): Promise<{ skills: string[]; method: 'all' | 'select' } | symbol> {
|
||||
const { skills } = options;
|
||||
|
||||
const result = await clack.select({
|
||||
message: options.message || `Found ${skills.length} skills — how would you like to install?`,
|
||||
options: [
|
||||
{ value: 'all' as const, label: 'Install all skills', hint: `${skills.length} skills` },
|
||||
{ value: 'select' as const, label: 'Select specific skills', hint: 'Choose manually' },
|
||||
],
|
||||
});
|
||||
|
||||
if (clack.isCancel(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const method = result as 'all' | 'select';
|
||||
|
||||
if (method === 'all') {
|
||||
return { skills: skills.map(s => s.name), method };
|
||||
}
|
||||
|
||||
const selected = await skillMultiselect({
|
||||
message: 'Select skills to install',
|
||||
skills,
|
||||
initialValues: [],
|
||||
});
|
||||
|
||||
if (clack.isCancel(selected)) {
|
||||
return selected;
|
||||
}
|
||||
|
||||
return { skills: selected as string[], method };
|
||||
}
|
||||
|
||||
export async function groupMultiselect<T extends string>(options: {
|
||||
message: string;
|
||||
options: Record<string, Array<{ value: T; label: string; hint?: string }>>;
|
||||
|
||||
Reference in New Issue
Block a user