Community编程与开发github.com

代码库迁移(Codebase Migrate)

运行大规模代码库迁移和多文件重构。使用 Composio CLI 协调问题跟踪、批量 PR 和 CI 验证,而代理在本地执行涉及数百个文件的转换。

代码库迁移(Codebase Migrate) 是什么?

该技能旨在通过 AI 代理和 CLI 工具的组合,高效协调涉及数百个文件的代码库迁移(如框架升级、API 重命名、配置格式迁移等)。其核心价值在于将大规模变更拆分为可审查的批次,每个批次创建独立的 PR 并等待 CI 验证通过后再合并,从而降低回滚风险和代码审查负担。支持在本地使用 jscodeshift、ts-morph、comby、ast-grep 等工具执行转换,并通过 Composio CLI 与 GitHub、Linear/Jira 等平台集成,用于创建问题、生成 PR 和监控 CI 状态。工作流通常包括:定义精确转换规则、评估影响范围、创建跟踪问题、循环执行“选择文件→转换→测试→PR→等待绿标→合并→下一批次”的流程,并包含 done.list 等安全机制避免重复处理。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComposioHQ/awesome-codex-skills/tree/main/codebase-migrate

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

代码库迁移

协调框架升级、API 重命名、配置重写和结构重构,涉及数百个文件。本地编辑由代理驱动;Composio CLI 负责周边流程:跟踪问题、按批次创建 PR 以及 CI 验证。

何时使用

  • 框架升级(React 17 → 19、Node 18 → 22、Django 4 → 5)。
  • 在单体仓库中执行 API 重命名(例如 getUserById → users.byId)。
  • 配置/格式迁移(webpack → vite、eslint → biome、jest → vitest)。
  • 任何需要“以相同方式更改 200 个文件”并以可审查的切片形式交付的任务。

前提条件

curl -fsSL https://composio.dev/install | bash
composio login
composio link github        # 用于 PR 和 CI 状态
composio link linear        # 或 jira — 用于迁移跟踪

代理将直接使用的本地工具:git、rg、jscodeshift/ts-morph/comby/ast-grep(根据语言选择),以及你的测试运行器。

规划阶段

  1. 精确定义转换规则。 不好的方式:“迁移到 vitest”。好的方式:“将 jest.mock 替换为 vi.mock,将 jest.fn() 替换为 vi.fn(),将 jest.config.js 重命名为 vitest.config.ts 并使用模板 X”。
  2. 评估影响范围:
    rg -l 'jest\.(mock|fn|spyOn)' | wc -l
    rg -l 'from "jest"' | sort
    
  3. 创建跟踪问题:
    composio execute LINEAR_CREATE_ISSUE -d '{
      "teamId":"TEAM_ID",
      "title":"Migrate test runner: jest → vitest",
      "description":"Batches of ~25 files. Checkpoint after each PR lands green."
    }'
    

按可审查批次执行

循环:选择 N 个文件 → 转换 → 测试 → PR → 等待绿标 → 合并 → 下一批次。

# 批次辅助:获取前 25 个匹配模式且尚未处理的文件
BATCH=$(rg -l 'jest\.mock' | grep -v done.list | head -25)
echo "$BATCH" > batch.list

代理在 batch.list 上运行代码转换,然后:

git checkout -b migrate/vitest-batch-03
xargs < batch.list codemod-runner   # 例如 jscodeshift / ts-morph / comby
npm test -- --changed
git add -A && git commit -m "migrate(test): jest → vitest (batch 3)"
git push -u origin migrate/vitest-batch-03

composio execute GITHUB_CREATE_A_PULL_REQUEST -d '{
  "owner":"acme","repo":"app",
  "head":"migrate/vitest-batch-03","base":"main",
  "title":"migrate(test): jest → vitest (batch 3)",
  "body":"Part of LIN-482. 25 files. Codemod: `transforms/jest-to-vitest.ts`."
}'

然后轮询 CI 并在通过后合并:

composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \
  -d '{"owner":"acme","repo":"app","branch":"migrate/vitest-batch-03"}'

工作流脚本

scripts/migrate-batch.ts,通过 composio run --file scripts/migrate-batch.ts -- --batch 3 按批次运行:

const batch = process.argv[process.argv.indexOf("--batch") + 1];

const pr = await execute("GITHUB_CREATE_A_PULL_REQUEST", {
  owner: "acme", repo: "app",
  head: `migrate/vitest-batch-${batch}`, base: "main",
  title: `migrate(test): jest → vitest (batch ${batch})`,
  body: `Part of LIN-482. See transforms/jest-to-vitest.ts.`
});

await execute("LINEAR_CREATE_COMMENT", {
  issueId: "LIN-482",
  body: `Opened PR #${pr.number}: ${pr.html_url}`
});

安全措施

  • 一次 PR 只做一种转换。 切勿将重命名与格式更改混在一起。
  • 维护一个 done.list 记录已迁移的文件,使下一批次跳过它们。
  • 在最后一个批次上运行完整的测试套件,即使每个批次的 PR 只运行了 --changed。
  • 先做代码转换,再进行手动编辑。 如果代码转换遗漏了 3 个文件,手动修复它们并在 PR 正文中注明。
  • 按批次回滚,而不是全局回滚。每个 PR 都应能干净地还原。

验证循环

每次合并后:

rg 'jest\.(mock|fn|spyOn)' | wc -l     # 应趋向于 0
npm test                                # 完整测试套件
composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \
  -d '{"owner":"acme","repo":"app","branch":"main","event":"push"}' \
  | jq '.workflow_runs[0].conclusion'

故障排除

  • 代码转换的正则匹配过多 → 切换到基于 AST 的工具(ast-grep、ts-morph)进行结构匹配。
  • 本地测试通过,CI 失败 → 锁定 Node/Python 版本一致性;检查 .nvmrc / pyproject.toml。
  • PR 篇幅过大,难以审查 → 将批次大小减半;维护人员不会审查超过 800 行的差异。
  • 批次之间发生冲突 → 在合并当前批次之前,rebase 打开中的批次;切勿强制推送已合并的批次。

完整的 CLI 参考:docs.composio.dev/docs/cli

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComposioHQ/-21risk-automation

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/-2chat-automation

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/ably-automation

Automate Ably tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abstract-automation

Automate Abstract tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abuselpdb-automation

Automate Abuselpdb tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abyssale-automation

Automate Abyssale tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accelo-automation

Automate Accelo tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accredible-certificates-automation

Automate Accredible Certificates tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/acculynx-automation

Automate Acculynx tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/active-campaign-automation

Automate ActiveCampaign tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/addresszen-automation

Automate Addresszen tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adobe-automation

Automate Adobe tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adrapid-automation

Automate Adrapid tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adyntel-automation

Automate Adyntel tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aeroleads-automation

Automate Aeroleads tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aero-workflow-automation

Automate Aero Workflow tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinda-automation

Automate Affinda tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinity-automation

Automate Affinity tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agencyzoom-automation

Automate Agencyzoom tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agent-deep-links

Build, validate, and troubleshoot deep links for Codex, Cursor, VS Code, Visual Studio, and similar tools. Use when users ask for clickable links (especially in Slack) that open threads, files, folders, or app settings.

相关技能