Files
skillkit/packages/cli/src/commands/enable.ts
T
Rohit Ghumare 160d2b1534 feat: add TUI enhancements and monorepo structure (#2)
* feat: add TUI enhancements and monorepo structure

- Add Translate screen for cross-agent skill translation
- Add Context screen for project context management
- Add Recommend screen with smart skill recommendations
- Fix TUI screen duplication by using fixed height container
- Clean up unnecessary comments following code-simplifier principles
- Refactor to monorepo structure with @skillkit/core, @skillkit/cli,
  @skillkit/tui, and @skillkit/agents packages
- Add comprehensive tests for translator, context, and recommend features
- Update license to Apache-2.0
- Add CONTRIBUTING.md with contribution guidelines

* ci: switch from npm to pnpm for monorepo support

* ci: use pnpm version from package.json

* fix: remove unused import in TUI helpers
2026-01-23 09:41:15 +00:00

107 lines
2.6 KiB
TypeScript

import chalk from 'chalk';
import { Command, Option } from 'clipanion';
import { setSkillEnabled, findSkill } from '@skillkit/core';
import { getSearchDirs } from '../helpers.js';
export class EnableCommand extends Command {
static override paths = [['enable']];
static override usage = Command.Usage({
description: 'Enable one or more skills',
examples: [
['Enable a skill', '$0 enable pdf'],
['Enable multiple skills', '$0 enable pdf xlsx docx'],
],
});
skills = Option.Rest({ required: 1 });
async execute(): Promise<number> {
const searchDirs = getSearchDirs();
let success = 0;
let failed = 0;
for (const skillName of this.skills) {
const skill = findSkill(skillName, searchDirs);
if (!skill) {
console.log(chalk.red(`Skill not found: ${skillName}`));
failed++;
continue;
}
if (skill.enabled) {
console.log(chalk.dim(`Already enabled: ${skillName}`));
continue;
}
const result = setSkillEnabled(skill.path, true);
if (result) {
console.log(chalk.green(`Enabled: ${skillName}`));
success++;
} else {
console.log(chalk.red(`Failed to enable: ${skillName}`));
failed++;
}
}
if (success > 0) {
console.log(chalk.dim('\nRun `skillkit sync` to update your agent config'));
}
return failed > 0 ? 1 : 0;
}
}
export class DisableCommand extends Command {
static override paths = [['disable']];
static override usage = Command.Usage({
description: 'Disable one or more skills',
examples: [
['Disable a skill', '$0 disable pdf'],
['Disable multiple skills', '$0 disable pdf xlsx docx'],
],
});
skills = Option.Rest({ required: 1 });
async execute(): Promise<number> {
const searchDirs = getSearchDirs();
let success = 0;
let failed = 0;
for (const skillName of this.skills) {
const skill = findSkill(skillName, searchDirs);
if (!skill) {
console.log(chalk.red(`Skill not found: ${skillName}`));
failed++;
continue;
}
if (!skill.enabled) {
console.log(chalk.dim(`Already disabled: ${skillName}`));
continue;
}
const result = setSkillEnabled(skill.path, false);
if (result) {
console.log(chalk.yellow(`Disabled: ${skillName}`));
success++;
} else {
console.log(chalk.red(`Failed to disable: ${skillName}`));
failed++;
}
}
if (success > 0) {
console.log(chalk.dim('\nRun `skillkit sync` to update your agent config'));
}
return failed > 0 ? 1 : 0;
}
}