write-api
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "write-api" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ce86c7f8b2d500b1ad0f54779389476d589c8ea93c34902b665ba6f73104e8ea. Verify the upstream source and version against https://skillhub.cn/skills/user_3782c7dd/write-api before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Search YAPI for endpoints and automatically generate front-end API code. Used when requests mention terms like “write interface”, “add interface”, “API”, “yapi”, or “interface method”; supports keyword search, automatic file locating, and style adaptation.
Introduction source: third_party · user_3782c7dd · 1.0.2 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: write-api
description: 搜索YAPI接口并自动生成前端API代码。当用户提到"写接口"、"加接口"、"API"、"yapi"、"接口方法"时使用。支持关键词搜索、自动定位文件、风格适配。
version: 0.0.1write-api
根据用户需求搜索 YAPI 接口,自动定位目标文件,生成风格一致的前端 API 方法。
执行流程
所有 YAPI 接口请求 Header 中 ShortName 的值为当前操作系统用户名。
第一步:解析用户意图
判断用户输入类型:
- 包含 YAPI ID(纯数字或明确提及 ID)→ 跳到第二步"获取详情"
- 自然语言描述(如"截图队列接口"、"用户列表API")→ 提取关键词,进入搜索流程
第二步:调用 YAPI 接口
2a. 搜索接口(关键词模式)
关键词若含中文,需先 URL 编码(如 截图 → %E6%88%AA%E5%9B%BE):
curl -s -H "ShortName: {动态用户名}" "https://hicode.hikvision.com/gateway/front-platform-system/yapi/projectInfo?keyword={URL编码后的关键词}"
从响应 data.interface[] 中提取匹配项:
- 仅一条结果 → 直接使用,无需用户选择。
- 多条结果 → 展示编号列表,等用户选择(可多选,逗号分隔):
找到以下匹配接口,请选择(输入序号,多个用逗号分隔): 1. 屏幕截图队列(发送) - ID: 1590163 2. 屏幕截图队列(接收) - ID: 1590173 - 无结果 → 提示用户换关键词重试。
2b. 获取接口详情
curl -s -H "ShortName: {动态用户名}" "https://hicode.hikvision.com/gateway/front-platform-system/yapi/info?id={_id}"
响应结构和类型定义详见 reference.md。
第三步:定位目标文件
按优先级逐级判断,命中即停:
- 用户已指定文件路径 → 直接使用
- 当前打开的文件是 API 文件 → 直接使用
判断条件:文件内容含
import引入request/axios,或含export的请求方法调用 - 自动扫描项目:
- 搜索
src/api/**/*.{ts,js}和src/services/**/*.{ts,js} - 搜索含
import.*request或import.*axios的文件 - 列出候选文件让用户确认
- 搜索
- 以上均无结果 → 请用户指定文件路径或打开目标文件
第四步:生成代码并插入
-
读取目标文件,分析现有代码风格:
- 缩进风格(空格数 / 制表符)
- 引号类型(单引号 / 双引号)
- 分号使用习惯
- 命名风格(驼峰 / 其他)
- 导入语句格式
- 不分析注释格式(注释固定使用 JSDoc,见下方规范)
-
根据接口详情生成 API 方法,规则:
- 方法名:根据接口路径 + 请求方法生成驼峰命名(如
GET /user/list→getUserList) - 注释:固定 JSDoc 格式,见下方"注释规范"
- GET 参数:逐一列为函数参数,通过
{ params: { ... } }传递 - POST/PUT 参数:从
req_body_other(JSON Schema)解析字段,生成内联类型(非Record<string, any>) - 路径参数:使用模板字符串
`/api/user/${id}`
- 方法名:根据接口路径 + 请求方法生成驼峰命名(如
-
插入到文件末尾,代码风格与现有代码一致。
注释规范(固定 JSDoc,不随目标文件风格变化)
/**
* {接口标题}
* @param {参数名} {参数描述}(必填/可选)
* @see http://yapi.hikvision.com/project/{project_id}/interface/api/{_id}
*/
规则:
- 第一行固定为接口标题,取
title字段 - 每个参数单独一行
@param,描述取字段的desc,末尾标注(必填)或(可选) - 参数来源:
req_query/req_params/req_body_form/req_body_other中的字段 - POST/PUT 的
data参数:用缩进子行列出每个字段及其描述和必填标识 - 若接口无参数,省略
@param行 - 最后一行固定为
@see链接,project_id和_id均从接口详情中取
使用示例
以下方式均可触发:
"帮我加一个截图队列的接口""写一个用户列表的API方法""yapi 1590163 这个接口帮我生成一下""把订单查询接口加到当前文件""write-api ids=123,456"(兼容旧模式,多个ID逗号分隔)
补充说明
- 支持一次处理多个接口(多个ID或搜索后选择多个)
- 生成代码前检查目标文件中是否已存在同路径的接口方法,避免重复
- 代码生成模板、类型定义和 YAPI 响应结构详见 reference.md
Current listing version
1.0.2
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决前端开发中高频刚需场景,显著提升对接 YAPI 的效率
- 支持多种输入模式,覆盖关键词搜索、ID 直连等典型使用路径
Highlights
- 触发词覆盖全面且边界清晰,支持自然语言与精确 ID 两种模式
Areas to improve
-
Description in the wrong location Reported severity: Minor
顶层 frontmatter 中 description 为空,实际描述内容在 skill_body 内部
Recommendation: 将 description 内容移至顶层 frontmatter
-
缺少When to Use章节 Reported severity: Minor
文档中缺少明确的 When to Use 使用场景说明章节
Recommendation: 在文档中添加 When to Use 章节,明确适用场景
-
Document is too long Reported severity: Minor
主文档约180行,超出建议的500行以内但接近上限
Recommendation: 考虑将部分技术细节移至 reference.md 等辅助文档
Highlights
- 执行流程分步清晰,有明确的出口条件和端到端示例
- frontmatter 结构完整,版本号明确
Highlights
- YAPI 接口调用参数正确,Header 处理规范
- 覆盖主要异常场景(无结果、多条结果、文件定位失败)
- 代码插入前有重复检查机制,避免冗余
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- hicode.hikvision.com
- yapi.hikvision.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.