SuperAPI AI 工具集

fetch-library-docs

编程与开发

查看项目

更新于 10-16 07:50

技能介绍

用途

fetch-library-docs 是一个用于获取外部库和框架官方文档的技能,覆盖 React、Next.js、Prisma、FastAPI、Express、Tailwind、MongoDB 等。其目标是在需要库 API 信息时提供官方文档内容,并宣称可节省 60-90% 的 token。

主要能力

该技能支持自动检测调用时机。当出现以下情况时会自动调用:

  • 实现:即将使用库 API 编写代码,内容类型为 examples、api-ref。
  • 调试:错误信息包含库名(如 PrismaClientError),内容类型为 troubleshooting。
  • 安装:添加新包、npm install、setup 任务,内容类型为 setup。
  • 集成:连接库(“use X with Y”),内容类型为 examples、setup。
  • 升级:版本迁移、破坏性变更,内容类型为 migration。
  • 不确定:首次使用库功能、不确定模式,内容类型为 examples。

以下情况不应调用:

  • 已从训练中获得足够知识。
  • 用户已粘贴文档或已打开文档。
  • 任务涉及本地/私有代码(应使用代码库搜索)。
  • 比较库(应使用网络搜索)。

使用方式

决策逻辑分为三步:

  1. 识别库。优先级:用户提及 → 错误信息 → 文件导入 → package.json → 询问用户。示例:PrismaClientKnownRequestError → library = "prisma";import { useState } from 'react' → library = "react";from fastapi import FastAPI → library = "fastapi"。
  2. 识别主题。优先级:用户指定 → 错误信息 → 正在实现的功能 → "getting started"。
  3. 选择内容类型。实现代码用 examples、api-ref;调试错误用 troubleshooting、examples;安装/设置用 setup;集成库用 examples、setup;升级版本用 migration;理解原理用 concepts;最佳实践用 patterns。

执行命令:

# With known library ID (faster - saves 1 API call)
bash scripts/fetch-docs.sh --library-id <id> --topic "<topic>" --content-type <types>

# With library name (auto-resolves)
bash scripts/fetch-docs.sh --library <name> --topic "<topic>" --content-type <types>

常用库 ID:

  • React:/reactjs/react.dev
  • Next.js:/vercel/next.js
  • Prisma:/prisma/docs
  • Tailwind:/tailwindlabs/tailwindcss.com
  • FastAPI:/tiangolo/fastapi

完整列表见 references/library-ids.md。

错误处理

  • [LIBRARY_NOT_FOUND]:尝试拼写变体。
  • [LIBRARY_MISMATCH]:直接使用 --library-id。
  • [EMPTY_RESULTS]:扩大主题或使用 --content-type all。
  • [RATE_LIMIT_ERROR]:检查 API key 设置。

调用预算:Context7 允许每个问题 3 次调用。使用 --library-id 可节省 1 次调用。完整错误处理见 references/context7-tools.md。

参考文件

  • Library IDs:完整库 ID 列表。
  • Usage Patterns:真实示例。
  • Context7 Tools:API 细节、错误码、设置。

适用场景

适用于在编码、调试、安装、集成、升级等任务中需要外部库官方文档的场景,尤其是希望减少 token 消耗时。

限制

资料未提供该技能的具体实现细节、支持的库完整列表、API key 获取方式、收费或价格信息、平台限制以及实际效果验证数据。