@forge/cli
14.2.015.0.0-next.23
out/service/skills-agents.js+
out/service/skills-agents.jsNew file+99
Index: package/out/service/skills-agents.js
===================================================================
--- package/out/service/skills-agents.js
+++ package/out/service/skills-agents.js
@@ -0,0 +1,99 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.agentName = exports.SKILLS_AGENT_REGISTRY = exports.SKILLS_SCOPES = exports.SKILLS_AGENTS = exports.SkillsAgent = void 0;
+exports.resolveAgentPath = resolveAgentPath;
+exports.parseSkillsAgent = parseSkillsAgent;
+exports.parseSkillsScope = parseSkillsScope;
+exports.detectAgents = detectAgents;
+const fs_1 = require("fs");
+const os_1 = require("os");
+const path_1 = require("path");
+const cli_shared_1 = require("@forge/cli-shared");
+var SkillsAgent;
+(function (SkillsAgent) {
+ SkillsAgent["CLAUDE_CODE"] = "claude-code";
+ SkillsAgent["CURSOR"] = "cursor";
+ SkillsAgent["CODEX"] = "codex";
+ SkillsAgent["GEMINI"] = "gemini";
+ SkillsAgent["COPILOT"] = "copilot";
+ SkillsAgent["VSCODE"] = "vscode";
+})(SkillsAgent || (exports.SkillsAgent = SkillsAgent = {}));
+exports.SKILLS_AGENTS = Object.values(SkillsAgent);
+exports.SKILLS_SCOPES = ['user', 'project'];
+const json = (path) => ({ path, format: 'json', serverKey: 'mcpServers' });
+const toml = (path) => ({ path, format: 'toml', serverKey: 'mcp_servers' });
+const MOVABLE_FOLDERS = {
+ $CODEX_HOME: { variable: 'CODEX_HOME', fallback: '~/.codex' },
+ $COPILOT_HOME: { variable: 'COPILOT_HOME', fallback: '~/.copilot' }
+};
+exports.SKILLS_AGENT_REGISTRY = {
+ [SkillsAgent.CLAUDE_CODE]: {
+ displayName: 'Claude Code',
+ configDirectories: ['~/.claude'],
+ user: { skills: '~/.claude/skills', mcp: [json('~/.claude.json')] },
+ project: { skills: '.claude/skills', mcp: [json('.mcp.json')] }
+ },
+ [SkillsAgent.CURSOR]: {
+ displayName: 'Cursor',
+ configDirectories: ['~/.cursor'],
+ user: { skills: '~/.cursor/skills', mcp: [json('~/.cursor/mcp.json')] },
+ project: { skills: '.cursor/skills', mcp: [json('.cursor/mcp.json')] }
+ },
+ [SkillsAgent.CODEX]: {
+ displayName: 'Codex',
+ configDirectories: ['$CODEX_HOME'],
+ user: { skills: '~/.agents/skills', mcp: [toml('$CODEX_HOME/config.toml')] },
+ project: { skills: '.agents/skills', mcp: [toml('.codex/config.toml')] }
+ },
+ [SkillsAgent.GEMINI]: {
+ displayName: 'Gemini CLI',
+ configDirectories: ['~/.gemini'],
+ user: { skills: '~/.gemini/skills', mcp: [json('~/.gemini/settings.json')] },
+ project: { skills: '.gemini/skills', mcp: [json('.gemini/settings.json')] }
+ },
+ [SkillsAgent.COPILOT]: {
+ displayName: 'GitHub Copilot CLI',
+ configDirectories: ['$COPILOT_HOME'],
+ user: { skills: '$COPILOT_HOME/skills', mcp: [json('$COPILOT_HOME/mcp-config.json')] },
+ project: { skills: '.github/skills', mcp: [json('.mcp.json'), json('.github/mcp.json')] }
+ },
+ [SkillsAgent.VSCODE]: {
+ displayName: 'Visual Studio Code',
+ configDirectories: [
+ '~/Library/Application Support/Code/User',
+ '~/.config/Code/User',
+ '~/AppData/Roaming/Code/User'
+ ],
+ user: { skills: '~/.copilot/skills', mcp: [] },
+ project: { skills: '.github/skills', mcp: [{ path: '.vscode/mcp.json', format: 'jsonc', serverKey: 'servers' }] }
+ }
+};
+const agentName = (agent) => exports.SKILLS_AGENT_REGISTRY[agent].displayName;
+exports.agentName = agentName;
+function resolveAgentPath(path, options = {}) {
+ const [first, ...rest] = path.split('/');
+ const movable = MOVABLE_FOLDERS[first];
+ if (movable) {
+ const moved = process.env[movable.variable];
+ return moved ? (0, path_1.resolve)(moved, ...rest) : resolveAgentPath([movable.fallback, ...rest].join('/'), options);
+ }
+ return path.startsWith('~/')
+ ? (0, path_1.resolve)(options.homeDirectory ?? (0, os_1.homedir)(), path.slice(2))
+ : (0, path_1.resolve)(options.projectDirectory ?? process.cwd(), path);
+}
+function parseSkillsAgent(name) {
+ const normalized = name.trim().toLowerCase();
+ const agent = (normalized === 'claude' ? SkillsAgent.CLAUDE_CODE : normalized);
+ if (!exports.SKILLS_AGENTS.includes(agent))
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.skills.errors.unknownAgent(name));
+ return agent;
+}
+function parseSkillsScope(scope) {
+ if (scope !== 'user' && scope !== 'project')
+ throw new cli_shared_1.ValidationError(cli_shared_1.Text.skills.errors.invalidScope);
+ return scope;
+}
+function detectAgents(options = {}) {
+ return exports.SKILLS_AGENTS.filter((agent) => exports.SKILLS_AGENT_REGISTRY[agent].configDirectories.some((directory) => (0, fs_1.existsSync)(resolveAgentPath(directory, options))));
+}
+//# sourceMappingURL=skills-agents.js.map
\ No newline at end of file