Ejecuta cualquier Skill en Manus
con un clic
con un clic
Ejecuta cualquier Skill en Manus con un clic
Comenzar$pwd:
$ git log --oneline --stat
stars:307
forks:89
updated:19 de abril de 2026, 13:39
SKILL.md
自动发现项目中的代码问题并提交 GitHub Issue
安全审计技能,用于检查和修复依赖安全问题
CI检查验证和质量保障
生成代码评审友好的 commit 信息
开发流程检查技能,确保代码修改后执行必要的质量检查
文档创建技能,用于创建标准化的项目文档
| name | api-docs |
| description | 文档自动生成 |
我是 API 文档自动生成技能,专门从 xiaozhi-client 项目的源代码中提取 API 信息,生成符合 Nextra (Next.js) 标准的 MDX 文档,同时遵循务实开发理念。
深度解析 TypeScript/JavaScript 源代码,提取 API 相关信息:
@Tool 装饰器的方法@Param 装饰器的参数定义// 示例源代码
@Tool("控制灯光设备 - 支持通过名称控制灯光设备的开关、亮度和色温")
public async LightControl(
@Param(z.string().describe("灯光设备名称"))
name: string,
@Param(z.enum(["turn_on", "turn_off"]).describe("控制动作"))
action: "turn_on" | "turn_off",
@Param(z.number().min(1).max(100).optional().describe("亮度百分比"))
brightnessPct?: number
) {
// 实现逻辑...
}
// 提取的信息
{
name: "LightControl",
description: "控制灯光设备 - 支持通过名称控制灯光设备的开关、亮度和色温",
parameters: [
{
name: "name",
type: "string",
description: "灯光设备名称",
required: true
},
{
name: "action",
type: "turn_on | turn_off",
description: "控制动作",
required: true
},
{
name: "brightnessPct",
type: "number",
description: "亮度百分比",
required: false,
constraints: { min: 1, max: 100 }
}
]
}
基于提取的信息生成符合 xiaozhi-client 项目标准的 Nextra MDX 文档。
# {ToolName}
## 工具介绍
{工具描述}
## 参数定义
| 参数 | 类型 | 范围 | 说明 |
|------|------|------|------|
{参数表格}
## 使用示例
### 基础用法
{基础示例代码}
### 高级功能
{高级示例代码}
## 错误信息
| 错误类型 | 错误信息 | 处理建议 |
|----------|----------|----------|
{错误表格}
## 返回值格式
### 成功响应
{成功响应示例}
### 错误响应
{错误响应示例}
从类型定义文件中提取相关类型信息,增强文档的完整性。
// 源类型定义
export interface LightControlParams {
entity_id: string;
action: LightActionType;
brightness?: number;
transition?: number;
}
export type LightActionType = "turn_on" | "turn_off" | "toggle";
// 生成的类型文档
### LightControlParams
灯光控制参数接口
| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
| entity_id | string | 是 | 灯光设备实体ID |
| action | LightActionType | 是 | 控制动作类型 |
| brightness | number | 否 | 亮度百分比 (1-100) |
| transition | number | 否 | 渐变时间(秒) |
### LightActionType
灯光控制动作类型
**可选值:**
- `"turn_on"` - 开灯
- `"turn_off"` - 关灯
- `"toggle"` - 切换开关状态
基于 API 定义生成实际可运行的示例代码。
// 基础示例
// 开启客厅主灯
LightControl("客厅主灯", "turn_on");
// 高级示例
// 开启灯光并设置亮度和渐变效果
LightControl("客厅主灯", "turn_on", 80, undefined, 2);
// 错误处理示例
try {
const result = await LightControl("不存在的设备", "turn_on");
console.log("操作成功:", result);
} catch (error) {
console.error("操作失败:", error.message);
}
// @Tool 装饰器解析
@Tool(description: string)
// 提取:工具描述信息
// @Param 装饰器解析
@Param(zSchema, description: string)
// 提取:参数类型、验证规则、描述信息
/**
* 通过名称控制灯光设备
* @param name 灯光设备名称
* @param action 控制动作 枚举值:turn_on | turn_off
* @param brightnessPct 亮度百分比 (1-100),可选参数
* @returns Promise<LightControlResult> 控制结果
* @example
* ```typescript
* LightControl("书房小灯", "turn_on", 80);
* ```
*/
// 提取:功能描述、参数说明、返回值、使用示例
// 支持 xiaozhi-client 项目的复杂路径别名系统
import { UnifiedMCPServer } from "@core/unified-server";
import { StartCommand } from "@cli/commands/start";
import { WebSocketAdapter } from "@transports/websocket";
import type { XiaozhiConfig } from "@/types";
// 提取:模块路径信息,用于生成导航和链接
// 支持:@cli/*, @core/*, @transports/*, @managers/*, @services/*, @types/*, @utils/*
// 接口定义
export interface LightControlResult {
success: boolean;
entity_id: string;
action: string;
changed_states?: HassState[];
errors?: string[];
}
// 枚举定义
export enum LightActionType {
TURN_ON = "turn_on",
TURN_OFF = "turn_off"
}
// 类型别名
export type DeviceState = "on" | "off" | "unavailable";
// 提取:完整的类型信息和文档
interface ScanOptions {
include: string[]; // 包含的文件模式
exclude: string[]; // 排除的文件模式
tools: boolean; // 是否扫描工具方法
types: boolean; // 是否扫描类型定义
examples: boolean; // 是否生成示例
}
const scanResult = scanSourceCode(options);
interface ExtractedInfo {
tools: ToolInfo[];
types: TypeInfo[];
examples: ExampleInfo[];
relationships: RelationshipInfo[];
}
const extractedInfo = extractApiInfo(scanResult);
interface GenerationOptions {
template: string; // 文档模板路径
output: string; // 输出目录
format: 'mdx' | 'md'; // 输出格式
navigation: boolean; // 是否更新导航
}
const generatedDocs = generateDocumentation(extractedInfo, options);
// 自动更新 meta.json 文件(Nextra 导航配置)
function updateNavigation(docs: GeneratedDoc[]): void {
const metaJsonPath = 'docs/meta.json';
const currentConfig = readFileSync(metaJsonPath, 'utf8');
const updatedConfig = insertIntoNavigation(currentConfig, docs);
writeFileSync(metaJsonPath, updatedConfig);
}
function insertIntoNavigation(config: string, docs: GeneratedDoc[]): string {
const parsed = JSON.parse(config);
// 根据文档类型插入到合适的导航位置
// MCP 工具文档 -> 使用指南,API 参考 -> 开发指南
return JSON.stringify(parsed, null, 2);
}
# {{toolName}}
## 工具介绍
{{description}}
## 参数定义
| 参数 | 类型 | 范围 | 说明 |
|------|------|------|------|
{{#each parameters}}
| {{name}} | {{type}} | {{constraints}} | {{description}} |
{{/each}}
## 使用示例
{{#each examples}}
### {{title}}
```typescript
{{code}}
{{/each}}
{{#if errors}}
| 错误类型 | 错误信息 | 处理建议 |
|---|---|---|
| {{#each errors}} | ||
| {{type}} | {{message}} | {{suggestion}} |
| {{/each}} | ||
| {{/if}} |
### 2. 类型文档模板
```handlebars
## {{typeName}}
{{description}}
{{#if properties}}
### 属性
| 属性 | 类型 | 必需 | 说明 |
|------|------|------|------|
{{#each properties}}
| {{name}} | {{type}} | {{required}} | {{description}} |
{{/each}}
{{/if}}
{{#if values}}
### 可选值
{{#each values}}
- `{{value}}` - {{description}}
{{/each}}
{{/if}}
// 基础用法示例
function generateBasicExample(tool: ToolInfo): string {
const requiredParams = tool.parameters.filter(p => p.required);
const paramValues = requiredParams.map(p => getExampleValue(p));
return `${tool.name}(${paramValues.join(', ')});`;
}
// 完整功能示例
function generateAdvancedExample(tool: ToolInfo): string {
const allParams = tool.parameters;
const paramValues = allParams.map(p => getExampleValue(p));
return `const result = await ${tool.name}(${paramValues.join(', ')});\n` +
`console.log('操作结果:', result);`;
}
interface ApiDocConfig {
input: {
sourceDir: string; // 源码目录
patterns: string[]; // 文件匹配模式
};
output: {
docsDir: string; // 文档输出目录
format: 'mdx' | 'md'; // 输出格式
templateDir?: string; // 自定义模板目录
};
generation: {
includeExamples: boolean; // 是否生成示例
includeTypes: boolean; // 是否包含类型文档
updateNavigation: boolean; // 是否更新导航
};
formatting: {
codeTheme: string; // 代码主题
tableStyle: 'github' | 'gitlab'; // 表格样式
useEmojis: boolean; // 是否使用表情符号
};
}
interface ToolConfig {
name: string;
category: string;
tags: string[];
examples: ExampleConfig[];
relatedTools: string[];
deprecated?: boolean;
experimental?: boolean;
}
interface ValidationResult {
valid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
score: number; // 0-100 文档质量评分
}
function validateDocumentation(docs: GeneratedDoc[]): ValidationResult {
// 检查文档完整性
// 验证链接有效性
// 检查代码示例正确性
// 评估文档质量
}
// 测试生成的示例代码
async function testExamples(examples: CodeExample[]): Promise<TestResult[]> {
const results = [];
for (const example of examples) {
try {
const result = await executeExample(example);
results.push({ example, success: true, result });
} catch (error) {
results.push({ example, success: false, error });
}
}
return results;
}
// 监听源码变化,自动更新文档
function setupDocumentationSync(): void {
watch(sourceFiles, (filePath) => {
const changes = detectChanges(filePath);
if (changes.affectsApi) {
regenerateDocumentation(changes);
}
});
}
# 生成所有API文档
api-docs generate
# 生成特定工具的文档
api-docs generate --tool LightControl
# 监听模式,自动更新
api-docs generate --watch
# 验证文档质量
api-docs validate
# 生成覆盖率报告
api-docs coverage
{
"scripts": {
"docs:generate": "api-docs generate",
"docs:validate": "api-docs validate",
"docs:watch": "api-docs generate --watch"
}
}
# GitHub Actions 示例
- name: Generate API Documentation
run: |
api-docs generate
api-docs validate
- name: Deploy Documentation
run: |
# 部署生成的文档到文档站点
通过这个技能,可以确保 xiaozhi-client 项目的 API 文档始终保持最新、准确和高质量,提升开发者体验和项目可维护性。特别适配 Nextra (Next.js) 文档系统和项目的复杂路径别名结构。
docs/meta.json 管理文档导航结构docs/content/guides/mcp-tools/*.mdxdocs/content/api/reference/*.mdxdocs/content/development/*.mdx---
title: 工具名称
description: 工具描述
---