add-adapter
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAdd a catalog adapter (vendor-official or community)
添加入目录的适配器(厂商官方或社区版)
Use this to list a third-party adapter in the Chat SDK catalog and docs. It is not for building a first-party package.
packages/adapter-*本指南用于在Chat SDK目录和文档中列出第三方适配器,不适用于构建第一方包。
packages/adapter-*Gather the source — never invent details
收集源信息——切勿编造细节
Ask the user for:
- Their adapter's GitHub repository URL.
- Their docs or README.
Read both. Everything you write into the catalog and docs must come directly from those sources or from the user. Do not assume or guess any information:
- — read it from the repo's
packageName, verbatim.package.json - Factory export (e.g. ) — read it from the package's exports/source. Do not guess it from the display name.
createFooAdapter - (
typeorplatform), env vars, and the feature matrix — base these on what the code and README actually document.state - Install and usage snippets — take them from the README; do not write example code the adapter may not support.
If the repo or README does not make something clear, stop and ask the user rather than filling it in. When in doubt, ask.
Choose the (kebab-case) and confirm it is not already taken: .
slugls apps/docs/content/adapters/*/向用户索要:
- 其适配器的GitHub仓库URL。
- 其文档或README。
阅读上述两者。你写入目录和文档的所有内容必须直接来自这些来源或用户提供的信息。不得假设或猜测任何信息:
- — 从仓库的
packageName中读取,完全照搬。package.json - 工厂导出(例如)——从包的导出/源码中读取。不要根据显示名称猜测。
createFooAdapter - (
type或platform)、环境变量和功能矩阵——基于代码和README实际记录的内容来确定。state - 安装和使用代码片段——从README中提取;不要编写适配器可能不支持的示例代码。
如果仓库或README中有不明确的地方,停止操作并询问用户,而不是自行填充内容。如有疑问,务必询问。
选择(短横线命名法,kebab-case)并确认尚未被占用:。
slugls apps/docs/content/adapters/*/Pick the tier
选择层级
- community — listed in the docs only. No catalog entry, no changeset.
chat/adapters - vendor-official — a maintained/blessed adapter. Everything community has, plus a catalog entry, a matching
chat/adaptersscaffold-spec entry, and a changeset. Frontmatter addscreate-chat-sdkandvendorOfficial: true.author
- community(社区版) — 仅在文档中列出。无需添加目录条目和变更记录。
chat/adapters - vendor-official(厂商官方版) — 经过维护/认证的适配器。包含社区版的所有内容,另外还需添加目录条目、匹配的
chat/adapters脚手架规范条目以及变更记录。页面前置元数据需添加create-chat-sdk和vendorOfficial: true字段。author
Files to change
需要修改的文件
<tier>vendor-officialcommunity- — the docs page. Start from assets/adapter.mdx. The filename basename must equal the
apps/docs/content/adapters/<tier>/<slug>.mdxfrontmatter field, and the page must renderslug.<FeatureSupport /> - — add
apps/docs/content/adapters/<tier>/meta.jsonto the"<slug>"array.pages - — add a registry entry:
apps/docs/adapters.json,name,slug,type,community: true,description,packageName,author(the GitHub URL). Addreadmefor vendor-official.vendorOfficial: true - — add
packages/integration-tests/src/docs-adapters.test.tsto the hardcoded expected list for its tier."<slug>" - — add the
packages/integration-tests/src/documentation-test-utils.tstopackageName, plus every import specifier used in the MDX code blocks (subpaths count separately).VALID_DOC_PACKAGES
Vendor-official also:
- — add an
packages/chat/src/adapters/index.tsentry withADAPTERS. Reuse thegroup: "vendor-official"/env/secretEnvhelpers; useurlEnvwhen there are no env vars. Seeenv: { notes: "…" }.packages/chat/src/adapters/AGENTS.md - — add a matching
packages/create-chat-sdk/src/catalog/scaffold-spec.tsentry, modeled on a similar adapter. This is a required registration step, not a behavior change: the object is"<slug>": { invocation: … }, so every catalog slug must have one orsatisfies Record<AdapterSlug, …>fails to type-check.create-chat-sdk - —
.changeset/<slug>-adapter.md+"chat": patch, one line describing the addition."create-chat-sdk": patch
<tier>vendor-officialcommunity- — 文档页面。从assets/adapter.mdx开始创建。文件名的基础名必须与前置元数据中的
apps/docs/content/adapters/<tier>/<slug>.mdx字段一致,且页面必须渲染slug组件。<FeatureSupport /> - — 在
apps/docs/content/adapters/<tier>/meta.json数组中添加pages。"<slug>" - — 添加一条注册表条目:包含
apps/docs/adapters.json、name、slug、type、community: true、description、packageName、author(GitHub URL)。厂商官方版需添加readme。vendorOfficial: true - — 在对应层级的硬编码预期列表中添加
packages/integration-tests/src/docs-adapters.test.ts。"<slug>" - — 将
packages/integration-tests/src/documentation-test-utils.ts添加到packageName中,同时添加MDX代码块中使用的所有导入标识符(子路径需单独计数)。VALID_DOC_PACKAGES
厂商官方版额外步骤:
- — 添加一条
packages/chat/src/adapters/index.ts条目,设置ADAPTERS。复用group: "vendor-official"/env/secretEnv工具函数;当没有环境变量时,使用urlEnv。参考env: { notes: "…" }。packages/chat/src/adapters/AGENTS.md - — 添加匹配的
packages/create-chat-sdk/src/catalog/scaffold-spec.ts条目,参考同类适配器的写法。这是必填的注册步骤,不属于行为变更:该对象需满足"<slug>": { invocation: … }类型约束,因此每个目录中的slug都必须对应一条条目,否则Record<AdapterSlug, …>会类型检查失败。create-chat-sdk - — 写入
.changeset/<slug>-adapter.md+"chat": patch,用一行文字描述本次添加操作。"create-chat-sdk": patch
Invariants the tests enforce
测试强制执行的约束
- Registry ↔ catalog parity. must equal the adapters.json slugs where
Object.keys(ADAPTERS). So vendor-official must be in!community || vendorOfficial; community-only must not be. This is why community adapters skip steps 6–8.chat/adapters - peerDeps ↔ PackageInstall. The catalog entry's (sorted) must exactly equal the extra packages in the MDX
peerDeps, after removing the adapter's own<PackageInstall package="…" />,packageName, and anychat. Easiest:@chat-adapter/state-*, install onlypeerDeps: [](plus a state adapter) in<packageName> chat, and keep any other imports in fenced code blocks.PackageInstall - Fields match. ,
packageName,type, andcommunitymust match between the MDX frontmatter and the adapters.json entry.vendorOfficial - Required frontmatter: ,
title,description,packageName,slug,tagline(type|platform),state,mdxBody: true(pluscommunity: trueandvendorOfficial: truefor vendor-official).author - Imports. Every import in an MDX code block must be listed in .
VALID_DOC_PACKAGES
- 注册表与目录一致性。必须等于adapters.json中
Object.keys(ADAPTERS)的slug集合。因此厂商官方版必须加入!community || vendorOfficial;仅社区版不得加入。这也是社区版适配器跳过步骤6-8的原因。chat/adapters - peerDeps与PackageInstall一致性。目录条目中的(已排序)必须与MDX中
peerDeps里除适配器自身<PackageInstall package="…" />、packageName以及任何chat之外的额外包完全一致。最简单的做法是:@chat-adapter/state-*,在peerDeps: []中仅安装PackageInstall(加上状态适配器),将其他导入放在代码块中。<packageName> chat - 字段匹配。、
packageName、type和community必须在MDX前置元数据和adapters.json条目之间保持一致。vendorOfficial - 必填前置元数据:、
title、description、packageName、slug、tagline(type|platform)、state、mdxBody: true(厂商官方版需额外添加community: true和vendorOfficial: true)。author - 导入约束。MDX代码块中的每个导入都必须在中列出。
VALID_DOC_PACKAGES
Validate
验证
bash
pnpm --filter chat build # regenerate the catalog the tests import
pnpm --filter @chat-adapter/integration-tests test
pnpm --filter chat typecheck
pnpm --filter create-chat-sdk typecheck # vendor-official only
pnpm check && pnpm konsistentbash
pnpm --filter chat build # 重新生成测试导入的目录
pnpm --filter @chat-adapter/integration-tests test
pnpm --filter chat typecheck
pnpm --filter create-chat-sdk typecheck # 仅厂商官方版需要
pnpm check && pnpm konsistentResources
参考资源
- Human guide (vendor-official):
apps/docs/content/docs/contributing/vendor-official.mdx - Human guide (community listing):
apps/docs/content/docs/contributing/publishing.mdx - MDX template: assets/adapter.mdx
- Catalog conventions:
packages/chat/src/adapters/AGENTS.md - Examples to copy: and
apps/docs/content/adapters/vendor-official/apps/docs/content/adapters/community/
- 人工指南(厂商官方版):
apps/docs/content/docs/contributing/vendor-official.mdx - 人工指南(社区版列表):
apps/docs/content/docs/contributing/publishing.mdx - MDX模板:assets/adapter.mdx
- 目录规范:
packages/chat/src/adapters/AGENTS.md - 参考示例:和
apps/docs/content/adapters/vendor-official/",apps/docs/content/adapters/community/