Complete uctoo backend API integration skill. Converts natural-language requests into uctoo-backend API calls, supporting user management, product management, order management, login and authentication features. When a user mentions keywords such as "uctoo", "backend API", "user management", "product", "order", "login", or "authentication", you should directly use the http_request tool to initiate actual API requests.
这是 uctoo-api-skill 的 V2 版本,采用完全重构的架构,真正发挥大模型的语义理解和推理能力。
V1 (旧架构):
V2 (新架构):
┌─────────────────────────────────────────────────────────┐
│ 用户输入 │
│ "请使用 demo 账号 123456 登录" │
└──────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 大模型(知识层 + 推理) │
│ ┌───────────────────────────────────────────────────┐ │
│ │ 1. 理解用户意图:需要登录 │ │
│ │ 2. 识别参数:username=demo, password=123456 │ │
│ │ 3. 选择 API:POST /api/uctoo/auth/login │ │
│ │ 4. 组装请求体:{"username":"demo","password":"123456"}│ │
│ │ 5. 调用 HTTP 工具执行请求 │ │
│ │ 6. 解析响应并生成友好回复 │ │
│ └───────────────────────────────────────────────────┘ │
└──────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ HTTP 工具(连接层) │
│ 执行实际的 API 请求 │
└──────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ UCTOO 后端 API │
└─────────────────────────────────────────────────────────┘
uctoo-api-skill/
├── SKILL.md # 主技能文件(知识层)
├── README.md # 本文件
├── Main.cj # 入口点(用于测试)
├── references/ # 参考文档
│ ├── api_spec.md # 完整的 API 规范
│ ├── examples.md # 使用示例
│ └── uctoo_api_design.md # API 设计文档
├── scripts/ # 脚本工具
│ ├── api_client.py # HTTP 客户端(主要使用)
│ ├── api_client.js # JavaScript 版本(备用)
│ └── test_api.py # API 测试脚本
├── src/ # 源代码
│ └── uctoo_api_skill.cj # 极简技能实现
└── backup-v1/ # V1 版本备份
└── ...
python scripts/test_api.py
python scripts/api_client.py POST "/api/uctoo/auth/login" '{"username":"demo","password":"123456"}'
技能会通过 Agentskills 运行时自动加载,大模型会根据 SKILL.md 中的说明来使用它。
SKILL.md 采用渐进式披露(Progressive Disclosure)原则:
充分利用大模型能力
极高的灵活性
易于维护
易于扩展
符合最佳实践
从 V7.0 版本开始,系统实现了会话级自动 Token 管理机制,彻底解决了大模型在多轮对话中无法正确传递认证 Token 的问题。
┌─────────────────────────────────────────────────────────────┐
│ WebSocket Session │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ SessionContext │ │
│ │ - setCurrentSession(sessionId) │ │
│ │ - getAccessToken() → TokenManager.getAccessToken() │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ TokenManager │ │
│ │ - setToken(sessionId, tokenInfo) │ │
│ │ - getAccessToken(sessionId) │ │
│ │ - parseLoginResponse(response) │ │
│ │ - isLoginEndpoint(url) │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ HttpTool │ │
│ │ 1. 检测登录请求 → 自动保存 token │ │
│ │ 2. 检测非登录请求 → 自动注入 Authorization header │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
| 组件 | 文件 | 功能 |
|------|------|------|
| TokenInfo | src/tool/token_manager.cj | Token 信息封装,包含过期时间检查 |
| TokenManager | src/tool/token_manager.cj | Token 存储和管理,支持多会话 |
| SessionContext | src/tool/token_manager.cj | 当前会话上下文,线程安全 |
| HttpTool | src/tool/http_tool.cj | 自动 token 保存和注入 |
// HttpTool 检测到登录请求
if (tokenManager.isLoginEndpoint(url)) {
// 解析响应并保存 token
let tokenInfoOpt = tokenManager.parseLoginResponse(responseJson)
match (tokenInfoOpt) {
case Some(tokenInfo) =>
tokenManager.setToken(sessionId, tokenInfo)
LogUtils.info("[HttpTool] Auto-saved token for session")
case None => ()
}
}
// HttpTool 检测到非登录请求
if (!hasAuthorization && !tokenManager.isLoginEndpoint(url)) {
let tokenOpt = sessionContext.getAccessToken()
match (tokenOpt) {
case Some(token) =>
headers.add("Authorization", "Bearer ${token}")
LogUtils.info("[HttpTool] Auto-injected Authorization header")
case None => ()
}
}
// WebSocket 会话关闭时
tokenManager.removeToken(sessionId)
sessionContext.clearCurrentSession()
用户只需正常对话,系统自动处理认证:
用户: 请使用 demo 账号 123456 登录
助手: 登录成功!用户信息:...
用户: 编辑 id 为 fd0a410a-xxx 的实体,将 link 改为 uctoo.com
助手: 编辑成功! # 系统自动注入了 Authorization header
/auth/login 或 /auth/signin 判断access_token、refresh_token、user.id、user.usernameAuthorization: Bearer {token}当用户提及 "uctoo"、"登录"、"用户管理" 等关键词时,技能会被激活。
大模型读取 SKILL.md 中的说明,理解:
大模型根据用户需求:
| 特性 | V1 | V2 | |------|-----|-----| | 代码量 | 大量(10+ 文件) | 极少(2 个文件) | | 语义理解 | 硬编码关键词 | 大模型自然语言理解 | | API 选择 | 固定逻辑 | 大模型动态决策 | | 参数提取 | 正则表达式 | 大模型智能提取 | | 可维护性 | 低(需改代码) | 高(只需改文档) | | 可扩展性 | 低 | 高 | | 灵活性 | 低 | 极高 |
Token 管理
API 格式
/api/uctoo/ 前缀错误处理
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer