mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
feat: add user-level custom taps for skill sources
Introduce tap add/remove/list commands to manage custom skill sources stored in ~/.skillkit/taps.json. Taps are included in find/search results, allowing users to add private or community repositories.
This commit is contained in:
@@ -124,6 +124,9 @@ import {
|
||||
TimelineCommand,
|
||||
SessionHandoffCommand,
|
||||
LineageCommand,
|
||||
TapAddCommand,
|
||||
TapRemoveCommand,
|
||||
TapListCommand,
|
||||
} from '@skillkit/cli';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -277,4 +280,8 @@ cli.register(TimelineCommand);
|
||||
cli.register(SessionHandoffCommand);
|
||||
cli.register(LineageCommand);
|
||||
|
||||
cli.register(TapAddCommand);
|
||||
cli.register(TapRemoveCommand);
|
||||
cli.register(TapListCommand);
|
||||
|
||||
cli.runExit(process.argv.slice(2));
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
GitHubSkillRegistry,
|
||||
SkillsShRegistry,
|
||||
} from "@skillkit/core";
|
||||
import { formatCount } from "../helpers.js";
|
||||
import { formatCount, loadTaps } from "../helpers.js";
|
||||
|
||||
interface SkillResult {
|
||||
name: string;
|
||||
@@ -87,6 +87,20 @@ export class FindCommand extends Command {
|
||||
}),
|
||||
);
|
||||
|
||||
const taps = loadTaps();
|
||||
for (const tap of taps.taps) {
|
||||
const tapLabel = tap.name || tap.source;
|
||||
const exists = allSkills.some((s) => s.source === tap.source);
|
||||
if (!exists) {
|
||||
allSkills.push({
|
||||
name: tapLabel,
|
||||
description: `Custom tap: ${tap.source}`,
|
||||
source: tap.source,
|
||||
repoName: tap.source.split("/").pop() || "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let results: SkillResult[];
|
||||
let searchTerm: string | undefined;
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ export { TimelineCommand } from './timeline.js';
|
||||
export { SessionHandoffCommand } from './handoff.js';
|
||||
export { LineageCommand } from './lineage.js';
|
||||
export { SaveCommand } from './save.js';
|
||||
export { TapAddCommand, TapRemoveCommand, TapListCommand } from './tap.js';
|
||||
export {
|
||||
AgentsMdCommand,
|
||||
AgentsMdInitCommand,
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { colors, symbols, step, success, warn } from '../onboarding/index.js';
|
||||
import { loadTaps, saveTaps } from '../helpers.js';
|
||||
|
||||
export class TapAddCommand extends Command {
|
||||
static override paths = [['tap', 'add']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Add a custom skill source (tap)',
|
||||
examples: [
|
||||
['Add a GitHub source', '$0 tap add myorg/skills'],
|
||||
['Add with a display name', '$0 tap add myorg/skills --name "My Org Skills"'],
|
||||
],
|
||||
});
|
||||
|
||||
source = Option.String({ required: true });
|
||||
|
||||
name = Option.String('--name,-n', {
|
||||
description: 'Display name for the tap',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const taps = loadTaps();
|
||||
|
||||
const exists = taps.taps.some((t) => t.source === this.source);
|
||||
if (exists) {
|
||||
warn(`Tap already exists: ${this.source}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
taps.taps.push({
|
||||
source: this.source,
|
||||
name: this.name,
|
||||
addedAt: new Date().toISOString(),
|
||||
});
|
||||
saveTaps(taps);
|
||||
|
||||
success(`Added tap: ${this.source}${this.name ? ` (${this.name})` : ''}`);
|
||||
console.log(colors.muted('Skills from this source will appear in search results'));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class TapRemoveCommand extends Command {
|
||||
static override paths = [['tap', 'remove'], ['tap', 'rm']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Remove a custom skill source (tap)',
|
||||
examples: [
|
||||
['Remove a tap', '$0 tap remove myorg/skills'],
|
||||
],
|
||||
});
|
||||
|
||||
source = Option.String({ required: true });
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const taps = loadTaps();
|
||||
|
||||
const idx = taps.taps.findIndex((t) => t.source === this.source);
|
||||
if (idx === -1) {
|
||||
warn(`Tap not found: ${this.source}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
taps.taps.splice(idx, 1);
|
||||
saveTaps(taps);
|
||||
|
||||
success(`Removed tap: ${this.source}`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class TapListCommand extends Command {
|
||||
static override paths = [['tap', 'list'], ['tap', 'ls'], ['tap']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'List all custom skill sources (taps)',
|
||||
examples: [
|
||||
['List taps', '$0 tap list'],
|
||||
],
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const taps = loadTaps();
|
||||
|
||||
if (taps.taps.length === 0) {
|
||||
step('No custom taps configured');
|
||||
console.log(colors.muted('Add one with: skillkit tap add owner/repo'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
step(`${taps.taps.length} tap(s) configured`);
|
||||
console.log('');
|
||||
|
||||
for (const tap of taps.taps) {
|
||||
const label = tap.name ? `${tap.name} (${tap.source})` : tap.source;
|
||||
console.log(` ${colors.success(symbols.bullet)} ${colors.primary(label)}`);
|
||||
if (tap.addedAt) {
|
||||
console.log(` ${colors.muted(`Added: ${tap.addedAt}`)}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import {
|
||||
loadConfig,
|
||||
getSearchDirs as coreGetSearchDirs,
|
||||
@@ -61,6 +64,38 @@ export function timeAgo(dateStr: string): string {
|
||||
return `${Math.floor(days / 365)}y ago`;
|
||||
}
|
||||
|
||||
export interface TapEntry {
|
||||
source: string;
|
||||
name?: string;
|
||||
addedAt: string;
|
||||
}
|
||||
|
||||
export interface TapsFile {
|
||||
version: 1;
|
||||
taps: TapEntry[];
|
||||
}
|
||||
|
||||
const TAPS_FILE = join(homedir(), '.skillkit', 'taps.json');
|
||||
|
||||
export function loadTaps(): TapsFile {
|
||||
if (!existsSync(TAPS_FILE)) return { version: 1, taps: [] };
|
||||
try {
|
||||
const data = JSON.parse(readFileSync(TAPS_FILE, 'utf-8'));
|
||||
if (data && data.version === 1 && Array.isArray(data.taps)) {
|
||||
return data as TapsFile;
|
||||
}
|
||||
return { version: 1, taps: [] };
|
||||
} catch {
|
||||
return { version: 1, taps: [] };
|
||||
}
|
||||
}
|
||||
|
||||
export function saveTaps(taps: TapsFile): void {
|
||||
const dir = dirname(TAPS_FILE);
|
||||
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
||||
writeFileSync(TAPS_FILE, JSON.stringify(taps, null, 2), 'utf-8');
|
||||
}
|
||||
|
||||
export async function fetchGitHubActivity(
|
||||
owner: string,
|
||||
repo: string,
|
||||
|
||||
Reference in New Issue
Block a user