2026-02-28 17:57:28 +08:00

89 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Skills Market Server
Skills Market API 服务,使用 Express + MongoDB。
## 安装 MongoDB
### Windows
1. 下载 MongoDB Community Edition: https://www.mongodb.com/try/download/community
2. 安装后MongoDB 会作为 Windows 服务自动启动
3. 默认端口: 27017
### 或使用 Docker
```bash
docker run -d -p 27017:27017 --name mongodb mongo:latest
```
## 启动服务
```bash
# 安装依赖
npm install
# 启动服务
npm start
# 开发模式(自动重启)
npm run dev
```
## API 接口
| 接口 | 方法 | 说明 |
|------|------|------|
| `/api/skills` | GET | 获取 skills 列表 |
| `/api/skills/:name` | GET | 获取 skill 详情 |
| `/api/skills/:name/download` | GET | 下载 skill增加下载计数 |
| `/api/skills/:name/publish` | POST | 发布/更新 skill |
| `/api/skills/:name/versions` | GET | 获取版本历史 |
| `/api/skills/:name/versions/:version` | GET | 获取特定版本 |
| `/api/skills/:name` | DELETE | 删除 skill |
| `/api/health` | GET | 健康检查 |
| `/api/stats` | GET | 统计信息 |
## 环境变量
创建 `.env` 文件:
```
PORT=3001
MONGO_URL=mongodb://localhost:27017
DB_NAME=skills_market
```
## MongoDB 数据结构
```javascript
// skills 集合
{
"_id": ObjectId("..."),
"name": "agent-browser",
"description": "Browser automation...",
"owner": "user123",
"downloads": 150,
"is_public": true,
"tags": ["browser", "automation"],
// 文件数组
"files": [
{ "path": "SKILL.md", "content": "---\nname: ..." },
{ "path": "references/commands.md", "content": "# Commands..." },
{ "path": "templates/auth.sh", "content": "#!/bin/bash..." }
],
// 版本历史
"versions": [
{
"version": 1,
"description": "Initial version",
"files": [ /* 快照 */ ],
"created_at": ISODate("..."),
"created_by": "user123"
}
],
"created_at": ISODate("..."),
"updated_at": ISODate("...")
}
```