- Introduced skills catalog management with functionalities to list, get details, preview, and apply skill changes. - Implemented IPC handlers for skills-related actions, enhancing communication between renderer and main processes. - Updated the UI to include a dedicated Skills panel within the extension store, improving user access to skills management. - Added new constants and types for skills API integration, ensuring a structured approach to skills handling. - Enhanced state management to support skills loading, error handling, and detail fetching.
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import * as path from 'node:path';
|
|
|
|
import { getHomeDir } from '@main/utils/pathDecoder';
|
|
import type { SkillRootKind, SkillScope } from '@shared/types/extensions';
|
|
|
|
export interface ResolvedSkillRoot {
|
|
scope: SkillScope;
|
|
rootKind: SkillRootKind;
|
|
projectRoot: string | null;
|
|
rootPath: string;
|
|
}
|
|
|
|
const USER_ROOTS: Array<{ rootKind: SkillRootKind; segments: string[] }> = [
|
|
{ rootKind: 'claude', segments: ['.claude', 'skills'] },
|
|
{ rootKind: 'cursor', segments: ['.cursor', 'skills'] },
|
|
{ rootKind: 'agents', segments: ['.agents', 'skills'] },
|
|
];
|
|
|
|
export class SkillRootsResolver {
|
|
resolve(projectPath?: string): ResolvedSkillRoot[] {
|
|
const roots: ResolvedSkillRoot[] = [];
|
|
const homeDir = getHomeDir();
|
|
|
|
for (const def of USER_ROOTS) {
|
|
roots.push({
|
|
scope: 'user',
|
|
rootKind: def.rootKind,
|
|
projectRoot: null,
|
|
rootPath: path.join(homeDir, ...def.segments),
|
|
});
|
|
}
|
|
|
|
if (projectPath) {
|
|
for (const def of USER_ROOTS) {
|
|
roots.push({
|
|
scope: 'project',
|
|
rootKind: def.rootKind,
|
|
projectRoot: projectPath,
|
|
rootPath: path.join(projectPath, ...def.segments),
|
|
});
|
|
}
|
|
}
|
|
|
|
return roots;
|
|
}
|
|
}
|