51 lines
2.2 KiB
JavaScript
Executable File
51 lines
2.2 KiB
JavaScript
Executable File
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const SKILL_PLATFORMS = Object.freeze([
|
|
{ id: 'codex', name: 'Codex', directory: '.agents/skills', legacyDirectory: '.codex/skills' },
|
|
{ id: 'claude_code', name: 'Claude Code', directory: '.claude/skills' },
|
|
{ id: 'cursor', name: 'Cursor', directory: '.cursor/skills' },
|
|
{ id: 'vscode', name: 'VS Code / Copilot', directory: '.github/skills' },
|
|
{ id: 'trae', name: 'Trae', directory: '.trae/skills' },
|
|
{ id: 'antigravity', name: 'Antigravity', directory: '.agents/skills', legacyDirectory: '.agent/skills' },
|
|
{ id: 'pi', name: 'Pi', directory: '.agents/skills' },
|
|
{ id: 'kiro', name: 'Kiro', directory: '.kiro/skills' },
|
|
{ id: 'qoder', name: 'Qoder', directory: '.qoder/skills' },
|
|
{ id: 'kimi', name: 'Kimi Code', directory: '.kimi-code/skills', gitRoot: true },
|
|
{ id: 'opencode', name: 'OpenCode', directory: '.opencode/skills' },
|
|
{ id: 'codebuddy', name: 'CodeBuddy', directory: '.codebuddy/skills' },
|
|
{ id: 'deepseek_harness', name: 'DeepSeek Harness (DSH)', directory: '.dsh/skills', gitRoot: true },
|
|
]);
|
|
|
|
function findGitRootOrSelf(projectPath) {
|
|
const original = path.resolve(projectPath);
|
|
for (let current = original; ; current = path.dirname(current)) {
|
|
if (fs.existsSync(path.join(current, '.git'))) return current;
|
|
if (path.dirname(current) === current) return original;
|
|
}
|
|
}
|
|
|
|
function getSkillPlatform(options = {}) {
|
|
const id = options.clientId || 'codex';
|
|
return SKILL_PLATFORMS.find((platform) => platform.id === id) || null;
|
|
}
|
|
|
|
function requireSkillPlatform(options = {}) {
|
|
const platform = getSkillPlatform(options);
|
|
if (!platform) throw new Error(`Project Skills installation is not supported for client: ${options.clientId}`);
|
|
return platform;
|
|
}
|
|
|
|
function getSkillsDirectory(options = {}) {
|
|
const platform = requireSkillPlatform(options);
|
|
return options.legacy && platform.legacyDirectory ? platform.legacyDirectory : platform.directory;
|
|
}
|
|
|
|
function getSkillProjectPath(projectPath, options = {}) {
|
|
return requireSkillPlatform(options).gitRoot ? findGitRootOrSelf(projectPath) : path.resolve(projectPath);
|
|
}
|
|
|
|
module.exports = { SKILL_PLATFORMS, findGitRootOrSelf, getSkillPlatform, getSkillsDirectory, getSkillProjectPath };
|