SuperAPI AI 工具集

adding-new-ai-format

测试与质量

查看项目

更新于 10-16 03:46

技能介绍

用途:这是一份面向 PRPM 贡献者的技能文档,说明如何为 PRPM 增加一种新的 AI 编辑器格式支持(如 OpenCode、Cursor、Claude 等),以 OpenCode 集成过程为例,按顺序完成跨包集成。

主要能力与流程:

  1. types 包:在 packages/types/src/package.ts 的 Format 类型与 FORMATS 数组中添加新格式,构建验证命令 npm run build --workspace=@pr-pm/types。
  2. converters 包 schema:在 packages/converters/schemas/ 新建 {format}.schema.json,$id 需采用 https://registry.prpm.dev/api/v1/schemas/{format}.json,子类型用 {format}/{subtype}.json,frontmatter 需加 "additionalProperties": false;含子类型时需分别创建 schema 并更新校验映射。
  3. converters 文档:在 packages/converters/docs/ 新建 {format}.md,需包含文件位置、frontmatter 字段、内容格式、最佳实践、转换说明、限制与示例,并更新 README 中的格式矩阵、可用格式、schema 校验、frontmatter 支持与文件组织表。
  4. 规范类型:在 packages/converters/src/types/canonical.ts 中扩展 format 联合类型、格式专属 metadata、MetadataSection.data、formatScores 与 sourceFormat。
  5. 转换器:新建 from-{format}.ts 解析格式到 canonical,新建 to-{format}.ts 完成反向转换,并在 index.ts 导出。
  6. 校验与分类:在 validation.ts 的 FormatType、schemaMap、subtypeSchemaMap 中登记,在 taxonomy-utils.ts 的 Format 与 normalizeFormat 中登记,构建命令 npm run build --workspace=@pr-pm/converters。
  7. CLI:在 packages/cli/src/core/filesystem.ts 的 getDestinationDir 与 autoDetectFormat 中补充路径与目录,在 commands/search.ts、commands/install.ts 中补充 formatIcons 与 formatLabels。
  8. webapp:在 SearchClient.tsx 的 FORMAT_SUBTYPES 与格式筛选下拉框中登记,并补充测试。

限制:资料未提供各格式的官方规范细节、具体测试用例、价格或平台支持范围;schema 与子类型映射缺失会导致校验回退到基础 schema,造成校验失败或不准确。