copilotkit-contribute

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Contributing to CopilotKit

为CopilotKit贡献代码

Important: CopilotKit's internal v2 packages use the
@copilotkit/*
namespace. The public API that users install is
@copilotkit/*
. When contributing, you work with
@copilotkit/*
source but users never see that namespace.
重要提示: CopilotKit内部v2包使用
@copilotkit/*
命名空间。用户安装的公共API同样为
@copilotkit/*
。贡献代码时你操作的是
@copilotkit/*
源码,但用户不会感知到该命名空间的存在。

Live Documentation (MCP)

实时文档(MCP)

This plugin includes an MCP server (
copilotkit-docs
) that provides
search-docs
and
search-code
tools for querying live CopilotKit documentation and source code.
  • Claude Code: Auto-configured by the plugin's
    .mcp.json
    -- no setup needed.
  • Codex: Requires manual configuration. See the copilotkit-debug skill for setup instructions.
本插件包含一个MCP服务器(
copilotkit-docs
),提供
search-docs
search-code
工具,可用于查询CopilotKit实时文档和源代码。
  • Claude Code: 插件的
    .mcp.json
    会自动完成配置,无需额外设置。
  • Codex: 需要手动配置。查看copilotkit-debug skill获取设置说明。

Workflow

工作流程

  1. Fork and clone the CopilotKit/CopilotKit repository.
  2. Install dependencies with
    pnpm install
    (requires pnpm v9.x and Node 20+).
  3. Build once with
    pnpm build
    to bootstrap all packages.
  4. Create a branch using the naming convention:
    feat/<ISSUE>-<name>
    ,
    fix/<ISSUE>-<name>
    , or
    docs/<ISSUE>-<name>
    .
  5. Develop with
    pnpm dev
    (watches all packages) or target a specific package with
    nx run @copilotkit/<pkg>:dev
    .
  6. Write and run tests with
    nx run @copilotkit/<pkg>:test
    . All v2 packages use Vitest.
  7. Lint and format with
    pnpm run lint --fix && pnpm run format
    .
  8. Commit using conventional commit format:
    <type>(<scope>): <subject>
    (enforced by commitlint).
  9. Push and open a PR against the
    main
    branch. CI builds all packages and publishes preview packages via pkg-pr-new.
  1. Fork并克隆 CopilotKit/CopilotKit仓库。
  2. 安装依赖:执行
    pnpm install
    (需要pnpm v9.x和Node 20及以上版本)。
  3. 首次构建:执行
    pnpm build
    来初始化所有包。
  4. 创建分支,分支命名规范为:
    feat/<ISSUE>-<name>
    fix/<ISSUE>-<name>
    docs/<ISSUE>-<name>
  5. 开发:执行
    pnpm dev
    (监听所有包的变化),或者指定单独包运行:
    nx run @copilotkit/<pkg>:dev
  6. 编写并运行测试:执行
    nx run @copilotkit/<pkg>:test
    。所有v2包都使用Vitest。
  7. 代码检查与格式化:执行
    pnpm run lint --fix && pnpm run format
  8. 提交代码:使用约定式提交格式:
    <type>(<scope>): <subject>
    (由commitlint强制校验)。
  9. 推送代码并提交PR:目标分支为
    main
    。CI会构建所有包,并通过pkg-pr-new发布预览版本包。

Before Opening a PR

提交PR前注意事项

  • Reach out to the maintainers first for any significant work (file an issue or ask on Discord).
  • Run
    pnpm run test
    to verify all tests pass.
  • Run
    pnpm run build
    to verify the full build succeeds.
  • Run
    pnpm run check-prettier
    to verify formatting.
  • Ensure commit messages follow the
    <type>(<scope>): <subject>
    format.
  • 如果你要做重大改动,请先联系维护者(提交issue或在Discord上询问)。
  • 运行
    pnpm run test
    确认所有测试通过。
  • 运行
    pnpm run build
    确认完整构建成功。
  • 运行
    pnpm run check-prettier
    确认代码格式符合规范。
  • 确保提交信息遵循
    <type>(<scope>): <subject>
    格式。

Quick Reference

快速参考

TaskCommand
Install dependencies
pnpm install
Build all packages
pnpm build
Dev mode (all)
pnpm dev
Dev mode (v2 only)
pnpm dev:next
Run all tests
pnpm run test
Run v2 tests only
pnpm test:next
Run single package tests
nx run @copilotkit/core:test
Test with coverage
pnpm run test:coverage
Lint
pnpm run lint
Format
pnpm run format
Check formatting
pnpm run check-prettier
Type check
pnpm run check-types
Package quality checks
pnpm run check:packages
Dependency graph
pnpm run graph
任务命令
安装依赖
pnpm install
构建所有包
pnpm build
全量开发模式
pnpm dev
仅v2版本开发模式
pnpm dev:next
运行所有测试
pnpm run test
仅运行v2版本测试
pnpm test:next
运行单个包的测试
nx run @copilotkit/core:test
带覆盖率的测试
pnpm run test:coverage
代码检查
pnpm run lint
代码格式化
pnpm run format
格式检查
pnpm run check-prettier
类型检查
pnpm run check-types
包质量检查
pnpm run check:packages
依赖关系图
pnpm run graph

Key Architecture Points

核心架构要点

  • V2 (
    @copilotkit/*
    ) is the real implementation. V1 (
    @copilotkit/*
    ) wraps V2.
  • New features always go in V2 packages under
    packages/v2/
    .
  • Communication between frontend and runtime uses the AG-UI protocol (SSE-based events).
  • The monorepo uses Nx for task orchestration and pnpm workspaces.
  • V2版本(
    @copilotkit/*
    )是核心实现。V1版本(
    @copilotkit/*
    )是V2的封装。
  • 新功能永远提交到
    packages/v2/
    目录下的V2包中。
  • 前端和运行时之间的通信使用AG-UI协议(基于SSE的事件)。
  • 该monorepo使用Nx进行任务编排,使用pnpm workspace管理依赖。

Reference Documents

参考文档

  • Contribution Guide — full onboarding walkthrough
  • Repo Structure — package layout and architecture
  • Testing Guide — Vitest setup, running tests, coverage
  • PR Guidelines — CI checks, review process, expectations
  • 贡献指南 —— 完整的上手流程
  • 仓库结构 —— 包布局和架构说明
  • 测试指南 —— Vitest配置、测试运行、覆盖率相关说明
  • PR规范 —— CI检查、评审流程、要求说明