动态技能经理(DSM)
动态技能经理 是一个CLI工具,用于将来自多个来源(MCP、Vercel skills和Native)的技能集成到Claude Code生态系统中。DSM提供了一个统一的界面,用于在不同的技能生态系统中发现、安装和管理人工智能辅助开发工具。
概述
DSM弥合了不同技能生态系统之间的差距,实现了以下方面的无缝集成:
- MCP(模型上下文协议) 技能—来自MCP服务器的工具、资源和提示
- Vercel技能 -Vercel生态系统的AI助手功能
- 本地(OMC)技能 -哦,我的克劳德本地技能集成
主要特点
- 统一技能界面:单身
UnifiedSkill类型抽象了技能来源之间的差异 - 适配器模式:用于添加新技能源的可扩展架构
- 执行上下文检测:自动检测全局、本地、npx和Node.js API模式
- 技能评分与分析:基于意图的任务分析和关键字评分
- 基于范围的安装:在全球范围内、每个项目或每个会话中安装技能
- 全面的错误处理:20多种错误类型,包括类别和严重程度
安装
全球安装
在全球范围内安装DSM以实现系统范围内的可用性:```bash
npm install -g dsm
### 本地安装
在项目中安装DSM:```bash
npm install dsm
NPX使用
使用npx在不安装的情况下运行DSM:```bash
npx dsm
### 需求
- Node.js>=18.0.0
- npm>=10.0.0
## 用法
### 命令参考
#### 状态
显示DSM状态、执行上下文和已安装的技能计数:```bash
dsm status
# or
dsm st
输出:```
DSM Status
Execution Context: local
Storage Path: /project/.dsm
Ephemeral Mode: No
Installed Skills: 3/3
- mcp: 2
- vercel: 1
#### 列表
列出已安装的技能(可选筛选):```bash
# List all installed skills
dsm list
# or
dsm ls
# Filter by source
dsm list --source mcp
dsm list --source vercel
# Filter by status
dsm list --status installed
dsm list --status enabled
# JSON output
dsm list --json
添加/安装
安装具有可选范围的技能:```bash
Install with default (session) scope
dsm add mcp/github
Install with specific scope
dsm add vercel/retry --scope project
dsm add mcp/postgres --scope global
Force reinstall
dsm add mcp/github --force
Alternate command
dsm install mcp/github
**范围:**
- `global` -适用于所有项目(存储在 `~/.dsm/`)
- `project` -在当前项目中可用(存储在 `./.dsm/`)
- `session` -仅适用于当前会话
#### 删除/卸载
删除已安装的技能:```bash
dsm remove mcp/github
# or
dsm rm mcp/github
# or
dsm uninstall mcp/github
搜索
搜索可用技能:```bash
General search
dsm search react
dsm search database
Filter by source
dsm search api --source mcp
JSON output
dsm search testing --json
#### MCP服务器管理
管理MCP服务器连接:```bash
# List configured MCP servers
dsm mcp list
# Connect to an MCP server
dsm mcp connect my-server http://localhost:3000
# Disconnect from an MCP server
dsm mcp disconnect my-server
分析
分析任务并建议相关技能:```bash
dsm analyze "build a REST API for user management"
dsm analyse "create a React component for data visualization"
#### 捆绑
管理技能包:```bash
# List saved bundles
dsm bundle list
# Show bundle details
dsm bundle show fullstack
# Remove a bundle
dsm bundle remove fullstack
初始化
初始化DSM配置:```bash
dsm init
这将创建:
- 配置文件: `dsm.config.json`
- 存储目录: `.dsm/`
#### 版本
显示DSM版本:```bash
dsm version
# or
dsm v
全局选项
| 选项 | 描述 |
|---|---|
--json |
输出为JSON |
--compact |
紧凑型输出(无ANSI颜色) |
--verbose |
详细输出 |
建筑
项目结构```
src/
├── core/
│ ├── types.ts # Type definitions (UnifiedSkill, Task, etc.)
│ ├── errors.ts # DSMError class with 20+ error subclasses
│ └── execution-context.ts # Execution context detection
├── adapters/
│ ├── base-adapter.ts # BaseAdapter abstract class
│ ├── mcp-adapter.ts # MCP server adapter (JSON-RPC over HTTP/stdio)
│ ├── vercel-adapter.ts # Vercel Skills adapter (SKILL.md parsing)
│ └── omc-adapter.ts # OMC native skills adapter (.claude/skills parsing)
├── registry/
│ ├── skill-registry.ts # Skill registry with adapter management
│ └── bundle-storage.ts # Skill bundle persistence (bundles.json)
├── analyzer/
│ └── task-analyzer.ts # Task analysis and skill scoring
├── cli/
│ └── index.ts # Commander.js CLI with all commands
└── index.ts # Main entry point
### 适配器模式
所有技能来源均采用 `SkillAdapter` 接口:```typescript
interface SkillAdapter {
readonly source: SkillSource;
discover(): Promise;
install(skillId: string, options?: InstallOptions): Promise;
uninstall(skillId: string): Promise;
isAvailable(skillId: string): Promise;
}
支持的适配器:
| 适配器 | 来源 | 用途 |
|---|---|---|
MCPAdapter |
mcp |
通过JSON-RPC连接到MCP服务器 |
VercelAdapter |
vercel |
从Vercel技能库解析SKILL.md |
BaseAdapter |
omc |
自定义技能实现的基类 |
统一技能模型
这 UnifiedSkill 界面标准化了所有来源的技能:```typescript
interface UnifiedSkill {
id: string; // "source/id" format
name: string; // Human-readable name
description: string; // Skill description
source: SkillSource; // 'mcp' | 'vercel' | 'omc'
version: string; // Semantic version
capabilities: Capability[];
triggers: Trigger[];
adapter: string;
config: Record;
status: SkillStatus;
scope: SkillScope;
metadata: SkillMetadata;
}
### 能力类型
|类型|描述|
|------|-------------|
| `tool` |可执行工具/功能|
| `resource` |可访问的数据资源|
| `prompt` |提示模板|
| `native` |本地OMC功能|
### 意图分类
这 `TaskAnalyzer` 将任务分为9种意图类型:
|意图|描述|
|--------|-------------|
| `code-generation` |创建新代码/组件/API|
| `refactoring` |重组或优化代码|
| `testing` |编写或运行测试|
| `debugging` |解决问题或调查问题|
| `documentation` |编写文档或解释代码|
| `analysis` |性能分析、代码审查|
| `deployment` |发布或部署到生产环境|
| `research` |查找信息或最佳实践|
| `unknown` |无法分类|
## 配置
### 配置文件
DSM使用 `dsm.config.json` 配置:```json
{
"outputFormat": "table",
"defaultScope": "session",
"autoEnable": true,
"telemetryEnabled": false,
"mcpServers": {
"my-server": {
"endpoint": "http://localhost:3000",
"enabled": true
}
}
}
配置选项
| 选项 | 类型 | 默认值 | 描述 |
|---|---|---|---|
outputFormat |
字符串 | table |
table, json,或 compact |
defaultScope |
字符串 | session |
global, project,或 session |
autoEnable |
布尔值 | true |
安装后自动启用技能 |
telemetryEnabled |
布尔值 | false |
启用遥测 |
mcpServers |
对象 | {} |
MCP服务器配置 |
DSM_HOME
您可以设置自定义DSM主目录:```bash
export DSM_HOME=/custom/path/to/dsm
### 执行上下文
DSM自动检测执行上下文:
|上下文|指标|存储位置|短暂|
|---------|-----------|------------------|-----------|
| `npx` |通过npx运行|项目本地 `.dsm/` |是的|
| `global` | `DSM_HOME` 在npm/全局路径中| `~/.dsm/` |没有|
| `local` |默认|项目本地 `.dsm/` |没有|
| `node-api` | `DSM_API_MODE=true` |项目本地 `.dsm/` |没有|
## 程序化使用
您可以将DSM用作Node.js库:```typescript
import { SkillRegistry, MCPAdapter, VercelAdapter } from 'dynamic-skills';
// Create registry
const registry = new SkillRegistry();
// Register adapters
registry.registerAdapter('mcp', new MCPAdapter());
registry.registerAdapter('vercel', new VercelAdapter());
// Initialize
await registry.initialize();
// Search skills
const results = await registry.search({
query: 'api',
filters: { sources: ['mcp'] }
});
// Install a skill
const result = await registry.install('mcp/github', {
scope: 'project'
});
// List installed skills
const skills = registry.getAll();
任务分析```typescript
import { TaskAnalyzer } from 'dynamic-skills';
const analyzer = new TaskAnalyzer(registry);
const task = {
id: 'task-1',
input: 'Build a REST API for user management',
context: { projectType: 'nodejs' }
};
const analysis = await analyzer.analyze(task);
console.log('Intent:', analysis.intent.intentType);
console.log('Confidence:', analysis.confidence);
console.log('Suggested skills:', analysis.suggestedSkills);
## 错误处理
DSM提供20多种错误类型的全面错误处理:
|类别|错误|
|----------|--------|
|验证| `ValidationError`, `InvalidSkillIdError`, `InvalidSchemaError` |
|安装| `InstallationError`, `SkillNotFoundError`, `DuplicateSkillError` |
|执行| `ExecutionError`, `SkillExecutionTimeoutError`, `SkillInvocationError` |
|存储| `StorageError`, `StorageReadError`, `StorageWriteError` |
|网络| `NetworkError`, `RegistryConnectionError`, `RegistryTimeoutError` |
|协议| `MCPProtocolError`, `MCPConnectionError`, `VercelSkillsError` |
|配置| `ConfigurationError`, `MissingConfigError`, `InvalidConfigError` |
|安全| `SecurityError`, `SkillValidationError`, `DangerousCapabilityError` |
|兼容性| `CompatibilityError`, `VersionMismatchError`, `UnsupportedPlatformError` |
### 错误格式```typescript
{
code: string; // Error code (e.g., 'SKILL_NOT_FOUND')
message: string; // Human-readable message
severity: ErrorSeverity; // 'critical' | 'high' | 'medium' | 'low'
category: ErrorCategory; // Error category
timestamp: Date; // When the error occurred
context?: ErrorContext; // Additional context
cause?: string; // Root cause message
}
发展
构建命令```bash
Compile TypeScript
npm run build
Watch mode
npm run build:watch
Run CLI directly with ts-node
npm run dev
Lint code
npm run lint
Format code
npm run format
Run tests
npm run test
Run tests in watch mode
npm run test:watch
Generate coverage report
npm run test:coverage
Clean build artifacts
npm run clean
### 依赖项
**对等依赖关系:**
- `@anthropic-ai/sdk >= 0.26.0`
**生产依赖性:**
- `chalk` -终端造型
- `cli-table3` -表格格式
- `commander` -CLI框架
- `conf` -配置管理
- `figlet` -ASCII艺术标题
- `inquirer` -交互式提示
- `js-yaml` -YAML解析
- `ora` -加载旋转器
- `zod` -运行时验证
## 贡献
欢迎投稿!请遵循以下指南:
1. 克隆该仓库
1. 创建要素分支(`git checkout -b feature/amazing-feature`)
1. 通过适当的测试进行更改
1. 跑 `npm run lint` 和 `npm run test` 验证
1. 提交您的更改(`git commit -m 'Add amazing feature'`)
1. 推到分支(`git push origin feature/amazing-feature`)
1. 打开拉取请求
### 添加新适配器
要添加对新技能源的支持,请执行以下操作:
1. 创建新的适配器扩展 `BaseAdapter`
1. 实施 `SkillAdapter` 接口
1. 在CLI中注册适配器
1. 为新适配器添加测试```typescript
// src/adapters/my-adapter.ts
import { BaseAdapter } from './base-adapter.js';
export class MyAdapter extends BaseAdapter implements SkillAdapter {
readonly type = 'my-source' as const;
readonly name = 'My Adapter';
readonly source = 'omc' as const;
async discover(): Promise {
// Discovery logic
}
async install(skillId: string, options?: InstallOptions): Promise {
// Installation logic
}
async uninstall(skillId: string): Promise {
// Uninstallation logic
}
async isAvailable(skillId: string): Promise {
// Availability check
}
}
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
链接
- 仓库: https://github.com/example/dynamic-skills
- 问题: https://github.com/example/dynamic-skills/issues
- MCP规范: https://github.com/modelcontextprotocol
- Vercel技能: https://vercel.com/docs/skills
