From 8ec5b9d8f28237611f34bd501390cb49fb74d819 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Sat, 11 Apr 2026 20:24:20 +0100 Subject: [PATCH 1/4] Add progressive disclosure tools (skillkit_catalog, skillkit_load, skillkit_resource) to MCP server Three new tools for token-efficient local skill access: - skillkit_catalog (L1): lightweight catalog of installed skills (~50 tokens/skill) - skillkit_load (L2): full SKILL.md content for a single skill - skillkit_resource (L3): specific reference file with path traversal protection Bumps server version to 1.21.0. Adds 14 new tests (18 total). --- packages/mcp/src/__tests__/tools.test.ts | 156 ++++++++++++++++++++++- packages/mcp/src/index.ts | 44 ++++++- packages/mcp/src/tools.ts | 132 ++++++++++++++++++- packages/mcp/src/types.ts | 16 +++ 4 files changed, 345 insertions(+), 3 deletions(-) diff --git a/packages/mcp/src/__tests__/tools.test.ts b/packages/mcp/src/__tests__/tools.test.ts index 57f781b3..165ed4ea 100644 --- a/packages/mcp/src/__tests__/tools.test.ts +++ b/packages/mcp/src/__tests__/tools.test.ts @@ -1,9 +1,13 @@ -import { describe, it, expect } from 'vitest'; +import { describe, it, expect, vi, beforeEach } from 'vitest'; import { handleSearchSkills, handleGetSkill, handleRecommendSkills, handleListCategories, + handleSkillkitCatalog, + handleSkillkitLoad, + handleSkillkitResource, + getLocalSkillDirs, } from '../tools.js'; import type { SkillEntry } from '../tools.js'; @@ -82,3 +86,153 @@ describe('handleListCategories', () => { expect(react?.count).toBe(1); }); }); + +vi.mock('@skillkit/core', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + findAllSkills: vi.fn(), + findSkill: vi.fn(), + readSkillContent: vi.fn(), + }; +}); + +vi.mock('node:fs', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + existsSync: vi.fn(actual.existsSync), + readFileSync: vi.fn(actual.readFileSync), + }; +}); + +import { findAllSkills, findSkill, readSkillContent } from '@skillkit/core'; +import { existsSync, readFileSync } from 'node:fs'; + +const mockFindAllSkills = vi.mocked(findAllSkills); +const mockFindSkill = vi.mocked(findSkill); +const mockReadSkillContent = vi.mocked(readSkillContent); +const mockExistsSync = vi.mocked(existsSync); +const mockReadFileSync = vi.mocked(readFileSync); + +describe('handleSkillkitCatalog', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('returns minimal catalog entries', () => { + mockFindAllSkills.mockReturnValue([ + { name: 'my-skill', description: 'A test skill', path: '/home/user/.claude/skills/my-skill', location: 'global', enabled: true }, + { name: 'other-skill', description: 'Another skill', path: '/project/skills/other-skill', location: 'project', enabled: true }, + ]); + const result = handleSkillkitCatalog({}); + const data = JSON.parse(result.content[0].text); + expect(data.total).toBe(2); + expect(data.skills[0]).toEqual({ name: 'my-skill', description: 'A test skill', source: 'global' }); + expect(data.skills[1]).toEqual({ name: 'other-skill', description: 'Another skill', source: 'project' }); + }); + + it('returns empty array when no skills found', () => { + mockFindAllSkills.mockReturnValue([]); + const result = handleSkillkitCatalog({}); + const data = JSON.parse(result.content[0].text); + expect(data.total).toBe(0); + expect(data.skills).toEqual([]); + }); +}); + +describe('handleSkillkitLoad', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('returns full skill content', () => { + mockFindSkill.mockReturnValue({ + name: 'my-skill', + description: 'A test skill', + path: '/home/user/.claude/skills/my-skill', + location: 'global', + enabled: true, + }); + mockReadSkillContent.mockReturnValue('# My Skill\n\nFull content here'); + const result = handleSkillkitLoad({ name: 'my-skill' }); + expect(result.content[0].text).toBe('# My Skill\n\nFull content here'); + expect((result as Record).isError).toBeUndefined(); + }); + + it('returns error for missing skill', () => { + mockFindSkill.mockReturnValue(null); + const result = handleSkillkitLoad({ name: 'nonexistent' }); + expect((result as Record).isError).toBe(true); + expect(result.content[0].text).toContain('Skill not found'); + }); + + it('returns error when content unreadable', () => { + mockFindSkill.mockReturnValue({ + name: 'broken-skill', + description: 'Broken', + path: '/home/user/.claude/skills/broken-skill', + location: 'global', + enabled: true, + }); + mockReadSkillContent.mockReturnValue(null); + const result = handleSkillkitLoad({ name: 'broken-skill' }); + expect((result as Record).isError).toBe(true); + expect(result.content[0].text).toContain('Could not read'); + }); +}); + +describe('handleSkillkitResource', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('returns file content', () => { + mockFindSkill.mockReturnValue({ + name: 'my-skill', + description: 'A test skill', + path: '/home/user/.claude/skills/my-skill', + location: 'global', + enabled: true, + }); + mockExistsSync.mockReturnValue(true); + mockReadFileSync.mockReturnValue('reference content' as never); + const result = handleSkillkitResource({ name: 'my-skill', file: 'references/api.md' }); + expect(result.content[0].text).toBe('reference content'); + expect((result as Record).isError).toBeUndefined(); + }); + + it('returns error for missing skill', () => { + mockFindSkill.mockReturnValue(null); + const result = handleSkillkitResource({ name: 'nonexistent', file: 'references/api.md' }); + expect((result as Record).isError).toBe(true); + expect(result.content[0].text).toContain('Skill not found'); + }); + + it('blocks path traversal', () => { + mockFindSkill.mockReturnValue({ + name: 'my-skill', + description: 'A test skill', + path: '/home/user/.claude/skills/my-skill', + location: 'global', + enabled: true, + }); + const result = handleSkillkitResource({ name: 'my-skill', file: '../../etc/passwd' }); + expect((result as Record).isError).toBe(true); + expect(result.content[0].text).toContain('Path traversal denied'); + }); + + it('returns error for missing file', () => { + mockFindSkill.mockReturnValue({ + name: 'my-skill', + description: 'A test skill', + path: '/home/user/.claude/skills/my-skill', + location: 'global', + enabled: true, + }); + mockExistsSync.mockReturnValue(false); + const result = handleSkillkitResource({ name: 'my-skill', file: 'references/missing.md' }); + expect((result as Record).isError).toBe(true); + expect(result.content[0].text).toContain('File not found'); + }); +}); diff --git a/packages/mcp/src/index.ts b/packages/mcp/src/index.ts index bcf2a549..f774f19a 100644 --- a/packages/mcp/src/index.ts +++ b/packages/mcp/src/index.ts @@ -13,6 +13,9 @@ import { handleGetSkill, handleRecommendSkills, handleListCategories, + handleSkillkitCatalog, + handleSkillkitLoad, + handleSkillkitResource, } from './tools.js'; import type { SkillEntry } from './tools.js'; import { getTrendingResource, getCategoriesResource } from './resources.js'; @@ -55,7 +58,7 @@ async function loadSkills(): Promise { const server = new Server( { name: 'skillkit-discovery', - version: '1.17.0', + version: '1.21.0', }, { capabilities: { @@ -125,6 +128,39 @@ server.setRequestHandler(ListToolsRequestSchema, async () => { properties: {}, }, }, + { + name: 'skillkit_catalog', + description: 'List all installed skills with name and description. Use this first to see what skills are available. Each entry costs ~50 tokens.', + inputSchema: { + type: 'object', + properties: { + agent: { type: 'string', description: 'Filter by agent type (e.g. claude-code, cursor)' }, + }, + }, + }, + { + name: 'skillkit_load', + description: 'Load the full content of a specific installed skill. Call this only when you need the detailed instructions for a skill found via skillkit_catalog.', + inputSchema: { + type: 'object', + properties: { + name: { type: 'string', description: 'Skill name from the catalog' }, + }, + required: ['name'], + }, + }, + { + name: 'skillkit_resource', + description: 'Load a specific reference file from within a skill directory. Use when a skill references external files.', + inputSchema: { + type: 'object', + properties: { + name: { type: 'string', description: 'Skill name' }, + file: { type: 'string', description: 'Relative file path within the skill (e.g. references/api.md)' }, + }, + required: ['name', 'file'], + }, + }, ], }; }); @@ -142,6 +178,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { return handleRecommendSkills(skills, args); case 'list_categories': return handleListCategories(skills); + case 'skillkit_catalog': + return handleSkillkitCatalog(args); + case 'skillkit_load': + return handleSkillkitLoad(args); + case 'skillkit_resource': + return handleSkillkitResource(args); default: return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], diff --git a/packages/mcp/src/tools.ts b/packages/mcp/src/tools.ts index 42071523..f3ea08a1 100644 --- a/packages/mcp/src/tools.ts +++ b/packages/mcp/src/tools.ts @@ -1,8 +1,21 @@ -import { RelevanceRanker } from '@skillkit/core'; +import { + RelevanceRanker, + findAllSkills, + findSkill, + readSkillContent, + isPathInside, + SKILL_DISCOVERY_PATHS, +} from '@skillkit/core'; +import { homedir } from 'node:os'; +import { join, resolve } from 'node:path'; +import { existsSync, readFileSync } from 'node:fs'; import { SearchSkillsInputSchema, GetSkillInputSchema, RecommendSkillsInputSchema, + SkillkitCatalogInputSchema, + SkillkitLoadInputSchema, + SkillkitResourceInputSchema, } from './types.js'; export interface SkillEntry { @@ -167,3 +180,120 @@ export function handleListCategories(skills: SkillEntry[]) { ], }; } + +export function getLocalSkillDirs(agentFilter?: string): string[] { + const dirs: string[] = []; + const home = homedir(); + const roots = [home, process.cwd()]; + + for (const root of roots) { + for (const rel of SKILL_DISCOVERY_PATHS) { + if (agentFilter) { + const dirAgent = rel.replace(/^\./, '').split('/')[0]; + if (dirAgent !== agentFilter && dirAgent !== 'agents' && dirAgent !== 'skills') continue; + } + const full = join(root, rel); + if (existsSync(full) && !dirs.includes(full)) { + dirs.push(full); + } + } + } + + return dirs; +} + +export function handleSkillkitCatalog(args: unknown) { + const input = SkillkitCatalogInputSchema.parse(args); + const dirs = getLocalSkillDirs(input.agent); + const skills = findAllSkills(dirs); + + const catalog = skills.map((s) => ({ + name: s.name, + description: s.description, + source: s.location, + })); + + return { + content: [ + { + type: 'text' as const, + text: JSON.stringify({ skills: catalog, total: catalog.length }, null, 2), + }, + ], + }; +} + +export function handleSkillkitLoad(args: unknown) { + const input = SkillkitLoadInputSchema.parse(args); + const dirs = getLocalSkillDirs(); + const skill = findSkill(input.name, dirs); + + if (!skill) { + return { + content: [{ type: 'text' as const, text: `Skill not found: ${input.name}` }], + isError: true, + }; + } + + const content = readSkillContent(skill.path); + if (!content) { + return { + content: [{ type: 'text' as const, text: `Could not read skill content: ${input.name}` }], + isError: true, + }; + } + + return { + content: [ + { + type: 'text' as const, + text: content, + }, + ], + }; +} + +export function handleSkillkitResource(args: unknown) { + const input = SkillkitResourceInputSchema.parse(args); + const dirs = getLocalSkillDirs(); + const skill = findSkill(input.name, dirs); + + if (!skill) { + return { + content: [{ type: 'text' as const, text: `Skill not found: ${input.name}` }], + isError: true, + }; + } + + const filePath = resolve(join(skill.path, input.file)); + if (!isPathInside(filePath, skill.path)) { + return { + content: [{ type: 'text' as const, text: `Path traversal denied: ${input.file}` }], + isError: true, + }; + } + + if (!existsSync(filePath)) { + return { + content: [{ type: 'text' as const, text: `File not found: ${input.file}` }], + isError: true, + }; + } + + try { + const content = readFileSync(filePath, 'utf-8'); + return { + content: [ + { + type: 'text' as const, + text: content, + }, + ], + }; + } catch { + return { + content: [{ type: 'text' as const, text: `Could not read file: ${input.file}` }], + isError: true, + }; + } +} diff --git a/packages/mcp/src/types.ts b/packages/mcp/src/types.ts index 893e513f..23408125 100644 --- a/packages/mcp/src/types.ts +++ b/packages/mcp/src/types.ts @@ -31,6 +31,22 @@ export const RecommendSkillsInputSchema = z.object({ export const ListCategoriesInputSchema = z.object({}); +export const SkillkitCatalogInputSchema = z.object({ + agent: z.string().optional().describe('Filter by agent type (e.g. claude-code, cursor)'), +}); + +export const SkillkitLoadInputSchema = z.object({ + name: z.string().describe('Skill name from the catalog'), +}); + +export const SkillkitResourceInputSchema = z.object({ + name: z.string().describe('Skill name'), + file: z.string().describe('Relative file path within the skill (e.g. references/api.md)'), +}); + export type SearchSkillsInput = z.infer; export type GetSkillInput = z.infer; export type RecommendSkillsInput = z.infer; +export type SkillkitCatalogInput = z.infer; +export type SkillkitLoadInput = z.infer; +export type SkillkitResourceInput = z.infer; From ebd26b7c84376162dbb49965d39765bf13c74696 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Sat, 11 Apr 2026 20:25:13 +0100 Subject: [PATCH 2/4] =?UTF-8?q?docs:=20fix=20agent=20count=2032=E2=86=9245?= =?UTF-8?q?=20in=20package=20READMEs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/skillkit/README.md | 8 ++++---- apps/skillkit/package.json | 4 ++-- packages/agents/README.md | 17 +++++++++++++++-- packages/agents/package.json | 4 ++-- packages/cli/README.md | 4 ++-- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/apps/skillkit/README.md b/apps/skillkit/README.md index 61b3c448..54eab357 100644 --- a/apps/skillkit/README.md +++ b/apps/skillkit/README.md @@ -1,6 +1,6 @@ # SkillKit -Universal skills manager for AI coding agents. Install, manage, and sync skills across 32 AI agents including Claude Code, Cursor, Codex, Gemini CLI, and more. +Universal skills manager for AI coding agents. Install, manage, and sync skills across 45 AI agents including Claude Code, Cursor, Codex, Gemini CLI, and more. ## Installation @@ -150,11 +150,11 @@ skillkit memory compress skillkit memory export auth-insight --output auth-skill.md ``` -## Supported Agents (32) +## Supported Agents (45) -**Primary (17):** Claude Code, Cursor, Codex, Gemini CLI, Windsurf, GitHub Copilot, OpenCode, Antigravity, Amp, Clawdbot, Droid, Goose, Kilo, Kiro, Roo, Trae, Universal +**Primary (18):** Claude Code, Cursor, Codex, Gemini CLI, Windsurf, GitHub Copilot, OpenCode, Antigravity, Amp, Clawdbot, OpenClaw, Droid, Goose, Kilo, Kiro, Roo, Trae, Universal -**Extended (15):** Cline, CodeBuddy, CommandCode, Continue, Crush, Factory, MCPJam, Mux, Neovate, OpenHands, Pi, Qoder, Qwen, Vercel, Zencoder +**Extended (27):** Aider, Amazon Q, Augment Code, Bolt, Cline, CodeBuddy, CodeGPT, CommandCode, Continue, Crush, Devin, Factory, Lovable, MCPJam, Mux, Neovate, OpenHands, Pi, PlayCode Agent, Qoder, Qwen, Replit Agent, Sourcegraph Cody, Tabby, Tabnine, Vercel, Zencoder ## Usage Examples diff --git a/apps/skillkit/package.json b/apps/skillkit/package.json index 35e45274..16266e76 100644 --- a/apps/skillkit/package.json +++ b/apps/skillkit/package.json @@ -1,7 +1,7 @@ { "name": "skillkit", - "version": "1.20.0", - "description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 13 more", + "version": "1.21.0", + "description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 41 more", "type": "module", "bin": { "skillkit": "./dist/cli.js", diff --git a/packages/agents/README.md b/packages/agents/README.md index 002fb364..b74d1378 100644 --- a/packages/agents/README.md +++ b/packages/agents/README.md @@ -3,7 +3,7 @@ [![npm version](https://img.shields.io/npm/v/@skillkit/agents.svg)](https://www.npmjs.com/package/@skillkit/agents) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -**Agent adapters for SkillKit** - configuration and detection for 32 AI coding agents. +**Agent adapters for SkillKit** - configuration and detection for 45 AI coding agents. ## Installation @@ -11,7 +11,7 @@ npm install @skillkit/agents ``` -## Supported Agents (32) +## Supported Agents (45) | Agent | Config Format | Project Skills | Global Skills | |-------|--------------|----------------|---------------| @@ -23,11 +23,14 @@ npm install @skillkit/agents | Antigravity | SKILL.md | `.antigravity/skills/` | - | | Amp | SKILL.md | `.amp/skills/` | - | | Clawdbot | SKILL.md | `.clawdbot/skills/` | - | +| OpenClaw | SKILL.md | `skills/` | - | | Cline | SKILL.md | `.cline/skills/` | - | | CodeBuddy | SKILL.md | `.codebuddy/skills/` | - | +| CodeGPT | SKILL.md | `.codegpt/skills/` | - | | CommandCode | SKILL.md | `.commandcode/skills/` | - | | Continue | SKILL.md | `.continue/skills/` | `~/.continue/skills/` | | Crush | SKILL.md | `.crush/skills/` | - | +| Devin | SKILL.md | `.devin/skills/` | - | | Droid (Factory) | SKILL.md | `.factory/skills/` | - | | Factory | SKILL.md | `.factory/skills/` | - | | GitHub Copilot | Markdown | `.github/skills/` | - | @@ -39,6 +42,7 @@ npm install @skillkit/agents | Neovate | SKILL.md | `.neovate/skills/` | - | | OpenHands | SKILL.md | `.openhands/skills/` | - | | Pi | SKILL.md | `.pi/skills/` | - | +| PlayCode Agent | SKILL.md | `.playcode/skills/` | - | | Qoder | SKILL.md | `.qoder/skills/` | - | | Qwen | SKILL.md | `.qwen/skills/` | - | | Roo Code | SKILL.md | `.roo/skills/` | `~/.roo/skills/` | @@ -46,6 +50,15 @@ npm install @skillkit/agents | Vercel | SKILL.md | `.vercel/skills/` | - | | Windsurf | Markdown | `.windsurf/skills/` | `~/.codeium/windsurf/skills/` | | Zencoder | SKILL.md | `.zencoder/skills/` | - | +| Aider | SKILL.md | `.aider/skills/` | - | +| Amazon Q | SKILL.md | `.amazonq/skills/` | - | +| Augment Code | SKILL.md | `.augment/skills/` | - | +| Bolt | SKILL.md | `.bolt/skills/` | - | +| Lovable | SKILL.md | `.lovable/skills/` | - | +| Replit Agent | SKILL.md | `.replit/skills/` | - | +| Sourcegraph Cody | SKILL.md | `.cody/skills/` | - | +| Tabby | SKILL.md | `.tabby/skills/` | - | +| Tabnine | SKILL.md | `.tabnine/skills/` | - | | Universal | SKILL.md | `skills/` | - | ## Usage diff --git a/packages/agents/package.json b/packages/agents/package.json index 0031f795..544d4b80 100644 --- a/packages/agents/package.json +++ b/packages/agents/package.json @@ -1,7 +1,7 @@ { "name": "@skillkit/agents", - "version": "1.20.0", - "description": "Agent adapters for SkillKit - supports 32 AI coding agents", + "version": "1.21.0", + "description": "Agent adapters for SkillKit - supports 45 AI coding agents", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/cli/README.md b/packages/cli/README.md index 7bf605bd..3e2a772d 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -3,7 +3,7 @@ [![npm version](https://img.shields.io/npm/v/@skillkit/cli.svg)](https://www.npmjs.com/package/@skillkit/cli) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -**Command-line interface for SkillKit** - install, manage, translate, and sync skills across 32 AI coding agents. +**Command-line interface for SkillKit** - install, manage, translate, and sync skills across 45 AI coding agents. ## Installation @@ -264,7 +264,7 @@ const recs = await recommendCommand({ | Gemini CLI | SKILL.md | | Windsurf | Markdown | | GitHub Copilot | Markdown | -| + 26 more | SKILL.md | +| + 39 more | SKILL.md | ## Documentation From 559b7602021744fc0ec298b81a801f7752ecaa3e Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Sat, 11 Apr 2026 20:32:28 +0100 Subject: [PATCH 3/4] fix: add 13 missing agent dirs to SKILL_DISCOVERY_PATHS, fix agent filter - Add .aider, .amazonq, .augment, .bolt, .codegpt, .cody, .devin, .lovable, .playcode, .replit, .tabby, .tabnine to discovery paths - Fix agent filter in getLocalSkillDirs: use AGENT_DIR_MAP lookup instead of reverse-engineering from directory prefix (claude != claude-code) - Update Agent Types code block in agents README to list all 45 agents --- packages/agents/README.md | 13 +++++++++++++ packages/core/src/skills.ts | 12 ++++++++++++ packages/mcp/src/tools.ts | 30 ++++++++++++++++++++++++++---- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/packages/agents/README.md b/packages/agents/README.md index b74d1378..e6adf75c 100644 --- a/packages/agents/README.md +++ b/packages/agents/README.md @@ -183,11 +183,14 @@ type AgentType = | 'antigravity' | 'amp' | 'clawdbot' + | 'openclaw' | 'cline' | 'codebuddy' + | 'codegpt' | 'commandcode' | 'continue' | 'crush' + | 'devin' | 'droid' | 'factory' | 'github-copilot' @@ -199,6 +202,7 @@ type AgentType = | 'neovate' | 'openhands' | 'pi' + | 'playcode-agent' | 'qoder' | 'qwen' | 'roo' @@ -206,6 +210,15 @@ type AgentType = | 'vercel' | 'windsurf' | 'zencoder' + | 'aider' + | 'amazon-q' + | 'augment-code' + | 'bolt' + | 'lovable' + | 'replit-agent' + | 'sourcegraph-cody' + | 'tabby' + | 'tabnine' | 'universal'; ``` diff --git a/packages/core/src/skills.ts b/packages/core/src/skills.ts index 5724c7ec..f1dd64ba 100644 --- a/packages/core/src/skills.ts +++ b/packages/core/src/skills.ts @@ -11,33 +11,45 @@ export const SKILL_DISCOVERY_PATHS = [ 'agents', '.agents/skills', '.agent/skills', + '.aider/skills', + '.amazonq/skills', '.amp/skills', '.antigravity/skills', + '.augment/skills', + '.bolt/skills', '.claude/skills', '.cline/skills', '.clawdbot/skills', '.codebuddy/skills', + '.codegpt/skills', '.codex/skills', + '.cody/skills', '.commandcode/skills', '.continue/skills', '.copilot/skills', '.crush/skills', '.cursor/skills', + '.devin/skills', '.factory/skills', '.gemini/skills', '.github/skills', '.goose/skills', '.kilocode/skills', '.kiro/skills', + '.lovable/skills', '.mcpjam/skills', '.mux/skills', '.neovate/skills', '.opencode/skills', '.openhands/skills', '.pi/skills', + '.playcode/skills', '.qoder/skills', '.qwen/skills', + '.replit/skills', '.roo/skills', + '.tabby/skills', + '.tabnine/skills', '.trae/skills', '.vercel/skills', '.windsurf/skills', diff --git a/packages/mcp/src/tools.ts b/packages/mcp/src/tools.ts index f3ea08a1..131865eb 100644 --- a/packages/mcp/src/tools.ts +++ b/packages/mcp/src/tools.ts @@ -181,17 +181,39 @@ export function handleListCategories(skills: SkillEntry[]) { }; } +const AGENT_DIR_MAP: Record = { + 'claude-code': '.claude/skills', 'cursor': '.cursor/skills', 'codex': '.codex/skills', + 'gemini-cli': '.gemini/skills', 'opencode': '.opencode/skills', 'antigravity': '.antigravity/skills', + 'amp': '.amp/skills', 'clawdbot': '.clawdbot/skills', 'openclaw': 'skills', + 'github-copilot': '.github/skills', 'goose': '.goose/skills', 'kilo': '.kilocode/skills', + 'kiro-cli': '.kiro/skills', 'roo': '.roo/skills', 'trae': '.trae/skills', + 'windsurf': '.windsurf/skills', 'universal': 'skills', 'droid': '.factory/skills', + 'factory': '.factory/skills', 'cline': '.cline/skills', 'codebuddy': '.codebuddy/skills', + 'codegpt': '.codegpt/skills', 'commandcode': '.commandcode/skills', 'continue': '.continue/skills', + 'crush': '.crush/skills', 'devin': '.devin/skills', 'mcpjam': '.mcpjam/skills', + 'mux': '.mux/skills', 'neovate': '.neovate/skills', 'openhands': '.openhands/skills', + 'pi': '.pi/skills', 'playcode-agent': '.playcode/skills', 'qoder': '.qoder/skills', + 'qwen': '.qwen/skills', 'vercel': '.vercel/skills', 'zencoder': '.zencoder/skills', + 'aider': '.aider/skills', 'amazon-q': '.amazonq/skills', 'augment-code': '.augment/skills', + 'bolt': '.bolt/skills', 'lovable': '.lovable/skills', 'replit-agent': '.replit/skills', + 'sourcegraph-cody': '.cody/skills', 'tabby': '.tabby/skills', 'tabnine': '.tabnine/skills', +}; + export function getLocalSkillDirs(agentFilter?: string): string[] { const dirs: string[] = []; const home = homedir(); const roots = [home, process.cwd()]; + let allowedPaths: Set | null = null; + if (agentFilter) { + const agentDir = AGENT_DIR_MAP[agentFilter]; + allowedPaths = new Set(['skills', 'agents', '.agents/skills', '.agent/skills']); + if (agentDir) allowedPaths.add(agentDir); + } + for (const root of roots) { for (const rel of SKILL_DISCOVERY_PATHS) { - if (agentFilter) { - const dirAgent = rel.replace(/^\./, '').split('/')[0]; - if (dirAgent !== agentFilter && dirAgent !== 'agents' && dirAgent !== 'skills') continue; - } + if (allowedPaths && !allowedPaths.has(rel)) continue; const full = join(root, rel); if (existsSync(full) && !dirs.includes(full)) { dirs.push(full); From eda488c96016b7918894cc0a11979243af41e3e5 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Sat, 11 Apr 2026 21:11:24 +0100 Subject: [PATCH 4/4] fix: symlink escape in resource sandbox, search order, global paths - Resolve symlinks with realpathSync before path containment check to prevent symlink-based directory escape in skillkit_resource - Search project-local skills before home-level (cwd first in roots) - AGENT_DIR_MAP now maps to arrays, includes non-standard global paths (opencode: .config/opencode/skills, windsurf: .codeium/...) - Extra global dirs scanned when agent filter matches --- packages/mcp/src/tools.ts | 72 +++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/packages/mcp/src/tools.ts b/packages/mcp/src/tools.ts index 131865eb..d67c447d 100644 --- a/packages/mcp/src/tools.ts +++ b/packages/mcp/src/tools.ts @@ -8,7 +8,7 @@ import { } from '@skillkit/core'; import { homedir } from 'node:os'; import { join, resolve } from 'node:path'; -import { existsSync, readFileSync } from 'node:fs'; +import { existsSync, readFileSync, realpathSync } from 'node:fs'; import { SearchSkillsInputSchema, GetSkillInputSchema, @@ -181,34 +181,34 @@ export function handleListCategories(skills: SkillEntry[]) { }; } -const AGENT_DIR_MAP: Record = { - 'claude-code': '.claude/skills', 'cursor': '.cursor/skills', 'codex': '.codex/skills', - 'gemini-cli': '.gemini/skills', 'opencode': '.opencode/skills', 'antigravity': '.antigravity/skills', - 'amp': '.amp/skills', 'clawdbot': '.clawdbot/skills', 'openclaw': 'skills', - 'github-copilot': '.github/skills', 'goose': '.goose/skills', 'kilo': '.kilocode/skills', - 'kiro-cli': '.kiro/skills', 'roo': '.roo/skills', 'trae': '.trae/skills', - 'windsurf': '.windsurf/skills', 'universal': 'skills', 'droid': '.factory/skills', - 'factory': '.factory/skills', 'cline': '.cline/skills', 'codebuddy': '.codebuddy/skills', - 'codegpt': '.codegpt/skills', 'commandcode': '.commandcode/skills', 'continue': '.continue/skills', - 'crush': '.crush/skills', 'devin': '.devin/skills', 'mcpjam': '.mcpjam/skills', - 'mux': '.mux/skills', 'neovate': '.neovate/skills', 'openhands': '.openhands/skills', - 'pi': '.pi/skills', 'playcode-agent': '.playcode/skills', 'qoder': '.qoder/skills', - 'qwen': '.qwen/skills', 'vercel': '.vercel/skills', 'zencoder': '.zencoder/skills', - 'aider': '.aider/skills', 'amazon-q': '.amazonq/skills', 'augment-code': '.augment/skills', - 'bolt': '.bolt/skills', 'lovable': '.lovable/skills', 'replit-agent': '.replit/skills', - 'sourcegraph-cody': '.cody/skills', 'tabby': '.tabby/skills', 'tabnine': '.tabnine/skills', +const AGENT_DIR_MAP: Record = { + 'claude-code': ['.claude/skills'], 'cursor': ['.cursor/skills'], 'codex': ['.codex/skills'], + 'gemini-cli': ['.gemini/skills'], 'opencode': ['.opencode/skills', '.config/opencode/skills'], + 'antigravity': ['.antigravity/skills'], 'amp': ['.amp/skills'], 'clawdbot': ['.clawdbot/skills'], + 'openclaw': ['skills'], 'github-copilot': ['.github/skills'], 'goose': ['.goose/skills'], + 'kilo': ['.kilocode/skills'], 'kiro-cli': ['.kiro/skills'], 'roo': ['.roo/skills'], + 'trae': ['.trae/skills'], 'windsurf': ['.windsurf/skills', '.codeium/windsurf/skills'], + 'universal': ['skills'], 'droid': ['.factory/skills'], 'factory': ['.factory/skills'], + 'cline': ['.cline/skills'], 'codebuddy': ['.codebuddy/skills'], 'codegpt': ['.codegpt/skills'], + 'commandcode': ['.commandcode/skills'], 'continue': ['.continue/skills'], + 'crush': ['.crush/skills'], 'devin': ['.devin/skills'], 'mcpjam': ['.mcpjam/skills'], + 'mux': ['.mux/skills'], 'neovate': ['.neovate/skills'], 'openhands': ['.openhands/skills'], + 'pi': ['.pi/skills'], 'playcode-agent': ['.playcode/skills'], 'qoder': ['.qoder/skills'], + 'qwen': ['.qwen/skills'], 'vercel': ['.vercel/skills'], 'zencoder': ['.zencoder/skills'], + 'aider': ['.aider/skills'], 'amazon-q': ['.amazonq/skills'], 'augment-code': ['.augment/skills'], + 'bolt': ['.bolt/skills'], 'lovable': ['.lovable/skills'], 'replit-agent': ['.replit/skills'], + 'sourcegraph-cody': ['.cody/skills'], 'tabby': ['.tabby/skills'], 'tabnine': ['.tabnine/skills'], }; export function getLocalSkillDirs(agentFilter?: string): string[] { const dirs: string[] = []; const home = homedir(); - const roots = [home, process.cwd()]; + const roots = [process.cwd(), home]; let allowedPaths: Set | null = null; if (agentFilter) { - const agentDir = AGENT_DIR_MAP[agentFilter]; - allowedPaths = new Set(['skills', 'agents', '.agents/skills', '.agent/skills']); - if (agentDir) allowedPaths.add(agentDir); + const agentDirs = AGENT_DIR_MAP[agentFilter] ?? []; + allowedPaths = new Set(['skills', 'agents', '.agents/skills', '.agent/skills', ...agentDirs]); } for (const root of roots) { @@ -221,6 +221,18 @@ export function getLocalSkillDirs(agentFilter?: string): string[] { } } + if (agentFilter) { + const agentDirs = AGENT_DIR_MAP[agentFilter] ?? []; + for (const rel of agentDirs) { + if (!SKILL_DISCOVERY_PATHS.includes(rel)) { + const full = join(home, rel); + if (existsSync(full) && !dirs.includes(full)) { + dirs.push(full); + } + } + } + } + return dirs; } @@ -302,8 +314,24 @@ export function handleSkillkitResource(args: unknown) { }; } + let realPath: string; + let realSkillDir: string; try { - const content = readFileSync(filePath, 'utf-8'); + realPath = realpathSync(filePath); + realSkillDir = realpathSync(skill.path); + } catch { + realPath = filePath; + realSkillDir = resolve(skill.path); + } + if (!isPathInside(realPath, realSkillDir)) { + return { + content: [{ type: 'text' as const, text: `Path traversal denied: ${input.file}` }], + isError: true, + }; + } + + try { + const content = readFileSync(realPath, 'utf-8'); return { content: [ {