[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"pack-detail-framework-language-migration-zh":3,"seo:pack:framework-language-migration:zh":97},{"code":4,"message":5,"data":6},200,"操作成功",{"pack":7},{"slug":8,"icon":9,"tone":10,"status":11,"status_label":12,"title":13,"description":14,"items":15,"install_cmd":96},"framework-language-migration","🔄","#0891B2","new","本周新建","框架 + 语言迁移工具集","给正在做真实迁移的工程师的十个选择：JS→TS、CommonJS→ESM、React class→hooks、Express→Hono、Python 2→3、Vue 2→3。Codemod CLI + ast-grep 结构化重写 + TypeScript \u002F TypeScript-Go 加速类型检查 + tsx 免构建跑 TS + Mypy \u002F Ty 给 Python 加类型 + Ruff 跑 pyupgrade 规则 + Hono 作为 Express 迁移目标 + Legacy Modernizer agent。按顺序装，按片切。",[16,28,38,45,52,59,66,74,81,88],{"id":17,"uuid":18,"slug":19,"title":20,"description":21,"author_name":22,"view_count":23,"vote_count":24,"lang_type":25,"type":26,"type_label":27},853,"a414acda-33ca-11f1-9bc6-00163e2b0d79","codemod-ai-powered-code-migration-cli-a414acda","Codemod — AI-Powered Code Migration CLI","Scaffold, share, and run large-scale code migrations with AI. First-class ast-grep support, multi-step YAML workflows, community codemod registry. Apache-2.0, 970+ stars.","Script Depot",103,0,"en","script","Script",{"id":29,"uuid":30,"slug":31,"title":32,"description":33,"author_name":34,"view_count":35,"vote_count":24,"lang_type":25,"type":36,"type_label":37},2640,"0a991711-47d7-11f1-9bc6-00163e2b0d79","ast-grep-structural-code-search-rewrite-tool-0a991711","ast-grep — Structural Code Search and Rewrite Tool","A fast CLI tool for searching and transforming code using abstract syntax tree patterns instead of regex, supporting JavaScript, TypeScript, Python, Rust, Go, and more.","AI Open Source",99,"skill","Skill",{"id":39,"uuid":40,"slug":41,"title":42,"description":43,"author_name":22,"view_count":44,"vote_count":24,"lang_type":25,"type":36,"type_label":37},1068,"1b748b68-35fe-11f1-9bc6-00163e2b0d79","typescript-javascript-syntax-types-1b748b68","TypeScript — JavaScript with Syntax for Types","TypeScript is a superset of JavaScript that adds static types, interfaces, generics, and modern ES features, compiled down to plain JavaScript. Created by Anders Hejlsberg at Microsoft. Used by Airbnb, Slack, Asana, and a huge share of modern web projects.",166,{"id":46,"uuid":47,"slug":48,"title":49,"description":50,"author_name":22,"view_count":51,"vote_count":24,"lang_type":25,"type":36,"type_label":37},3014,"ec44e9ae-4d11-11f1-9bc6-00163e2b0d79","typescript-go-native-typescript-compiler-port-go-ec44e9ae","TypeScript Go — Native TypeScript Compiler Port in Go","A native port of the TypeScript compiler to Go by Microsoft, delivering up to 10x faster type-checking and build times.",66,{"id":53,"uuid":54,"slug":55,"title":56,"description":57,"author_name":34,"view_count":58,"vote_count":24,"lang_type":25,"type":36,"type_label":37},4188,"e388a8b5-52b5-11f1-9bc6-00163e2b0d79","tsx-fastest-way-run-typescript-node-js-e388a8b5","tsx — The Fastest Way to Run TypeScript in Node.js","tsx (TypeScript Execute) is a lightweight CLI that runs TypeScript and ESM files in Node.js with near-instant startup. It uses esbuild under the hood for fast transpilation without requiring tsconfig or a build step.",44,{"id":60,"uuid":61,"slug":62,"title":63,"description":64,"author_name":34,"view_count":65,"vote_count":24,"lang_type":25,"type":36,"type_label":37},2113,"79146220-40a1-11f1-9bc6-00163e2b0d79","mypy-optional-static-type-checker-python-79146220","Mypy — Optional Static Type Checker for Python","Mypy checks Python type annotations at development time, catching type errors before code runs. It is the reference implementation of PEP 484 gradual typing for Python.",108,{"id":67,"uuid":68,"slug":69,"title":70,"description":71,"author_name":72,"view_count":73,"vote_count":24,"lang_type":25,"type":26,"type_label":27},3025,"7f3e3d30-2021-41c2-994f-82f7b451275f","ruff-python-linter-and-formatter-in-one-fast-cli","Ruff — Python Linter and Formatter in One Fast CLI","Ruff combines linting, import sorting, and formatting in a Rust CLI. Replace several Python style tools with `ruff check` and `ruff format` in seconds.","Astral",69,{"id":75,"uuid":76,"slug":77,"title":78,"description":79,"author_name":72,"view_count":80,"vote_count":24,"lang_type":25,"type":26,"type_label":27},3026,"d4b6fc04-0b89-4fea-9456-49d7361b6a32","ty-astral-s-fast-python-type-checker","Ty — Astral's Fast Python Type Checker","Ty is Astral's Rust-based Python type checker and language server. Use it to trial fast type feedback next to Ruff and uv before standardizing on CI.",75,{"id":82,"uuid":83,"slug":84,"title":85,"description":86,"author_name":22,"view_count":87,"vote_count":24,"lang_type":25,"type":26,"type_label":27},450,"ff72c952-86a4-402d-b288-7468b3a3f4c5","hono-ultrafast-web-framework-edge-ff72c952","Hono — Ultrafast Web Framework for the Edge","Tiny, fast web framework for Cloudflare Workers, Deno, Bun, and Node.js. Perfect API layer for AI services. 29K+ GitHub stars.",87,{"id":89,"uuid":90,"slug":91,"title":92,"description":93,"author_name":94,"view_count":95,"vote_count":24,"lang_type":25,"type":36,"type_label":37},4505,"dccb0175-e306-4c4b-ba7c-039b28f8847b","claude-code-agent-legacy-modernizer-dccb0175","Claude Code Agent: Legacy Modernizer","Use this agent when modernizing legacy systems that need incremental migration strategies, technical debt reduction, and risk mitigation while maintaining business continuity. Specifically:\\\\n\\\\n\u003Cexample>\\\\nContext: A development team has a 15-year-old mono...","TokRepo精选",23,"tokrepo install pack\u002Fframework-language-migration",{"pageType":98,"pageKey":8,"locale":99,"title":100,"metaDescription":101,"h1":102,"tldr":103,"bodyMarkdown":104,"faq":105,"schema":121,"internalLinks":127,"citations":140,"wordCount":153,"generatedAt":154},"pack","zh","框架 + 语言迁移工具集 — 10 个 AI 时代真做迁移的工具","Codemod CLI、ast-grep、TypeScript、TypeScript-Go、tsx、Mypy、Ruff、Ty、Hono、Legacy Modernizer agent — 真做 JS→TS \u002F CommonJS→ESM \u002F React class→hooks \u002F Express→Hono \u002F Python 2→3 \u002F Vue 2→3 的工具集。按顺序装，按片切。","框架 + 语言迁移工具集 — 按顺序装，按片切","十个工具把一个看起来吓人的多月迁移，拆成一连串小的可回滚 PR。Codemod 干掉机械的 80%，类型检查环抓它漏的，agent 处理那些需要判断的遗留考古。基线 → codemod → 类型检查 → 测试 → 切片上线 — 每片重复一次。","## 这个 pack 解决什么\n\n真正的迁移 — JavaScript → TypeScript、CommonJS → ESM、React class 组件 → hooks、Express → Hono、Python 2 → Python 3、Vue 2 → Vue 3 — 失败几乎都是同一个原因：有人想在一个巨型 branch 里一次性做完。六周后，那个 branch 改了 800 个文件，每次 main 合并都冲突，谁也不敢把它上线。\n\n这个 pack 是 AI 时代真把一次迁移做完的方式。无论源\u002F目标是什么，模式都一样：**基线 → codemod → 类型检查 → 测试 → 上线一片 → 再来一片**。下面的工具让每一步几分钟就能跑完，而不是几天，于是每片可以小到午饭前合掉。\n\n## 推荐安装顺序\n\n1. **Codemod — AI-Powered Code Migration CLI** *(从这里开始)*。整套的中心。把大规模代码迁移脚手架成多步 YAML 工作流，可分享可复用。一等公民支持 ast-grep，社区注册表里有现成的预制 codemod（React class→hooks、Mocha→Jest、CommonJS→ESM 等等），注册表里没有的还能用 AI 协助写。\n2. **ast-grep — Structural Code Search and Rewrite Tool**。绝大多数现代 codemod 底下的真正重写引擎。按 AST 形状匹配模式而不是正则 — `$VAR.then($CB)` 能匹配你要改成 await 的所有 promise 回调，不管空格和变量名。可以单独用做一次性改写，也可以作为 Codemod CLI 的后端。\n3. **TypeScript — JavaScript with Syntax for Types**。JS→TS 迁移的目的地。一开始 `--noImplicitAny` 别打开，按目录一个个迁过去再打开。\n4. **TypeScript Go — Native TypeScript Compiler Port in Go**。`tsc` 的直接替代，类型检查快约 10 倍。在迁移过程中是关键，因为你每跑完一批 codemod 就要重新跑一次类型检查 — 2 分钟的 tsc 变成 12 秒的环，而 12 秒就是「保持心流」和「切去看 Slack」的分界。\n5. **tsx — The Fastest Way to Run TypeScript in Node.js**。让你迁移期间直接执行 `.ts` 文件，不需要构建步骤。当一半代码是 JS、一半是 TS，又不想搭两套并行构建管道时至关重要。\n6. **Mypy — Optional Static Type Checker for Python**。Python 版的「按目录打开类型检查」。按模块用 `--strict`，不要整个项目同时开。配上 `py.typed` 标记，下游消费者就能看到你的类型。\n7. **Ruff — Python Linter and Formatter in One Fast CLI**。专门给 Python 2→3 迁移用：Ruff 的 `pyupgrade` 规则集会自动修绝大多数现代化模式：`print x` → `print(x)`、`u\"str\"` → `\"str\"`、`super(Foo, self)` → `super()`、`dict.iteritems()` → `dict.items()`。一次 `ruff check --select UP --fix` 就能处理掉几千个机械改动。\n8. **Ty — Astral's Fast Python Type Checker**。Mypy 的 Rust 替代品，和 Ruff 同一拨人做的。值得并行试用 — 反馈延迟从 8 秒降到 200ms 之后，你才会真的保持边写边跑。\n9. **Hono — Ultrafast Web Framework for the Edge**。从 Express 迁出去的目的地。API 表面足够接近，handler 一个一个迁就行：`req.body` → `await c.req.json()`、`res.json(x)` → `c.json(x)`，中间件签名也相似。加分项：能跑在 Cloudflare\u002FBun\u002FNode 上，迁完的路由想放哪都可以。\n10. **Claude Code Agent: Legacy Modernizer**。codemod 搞不定那部分的兜底：废弃的配置、没人维护的模块、自从 IE 11 后就再没触发过的 version-sniff 分支。Agent 读代码、给出拆除顺序、写 PR。用它干那 20% 需要判断的活，别让它干 80% 的机械活。\n\n## 它们怎么协同\n\n```\n        ┌──────────────────────────────────┐\n        │  Codemod CLI  (编排者)            │\n        │    └─ ast-grep  (重写引擎)        │\n        └──────────────────────────────────┘\n                       │\n      ┌────────────────┼────────────────┐\n      ▼                ▼                ▼\n   JS → TS         Python 2 → 3      遗留考古\n   ─────────       ──────────       ──────────────\n   TypeScript      Ruff (--select UP)  Legacy Modernizer\n   TypeScript-Go   Mypy \u002F Ty             (agent)\n   tsx (跑 TS)\n                                  ┌──────────────┐\n                                  │ Express→Hono │\n                                  │   Hono       │\n                                  └──────────────┘\n                       │\n                       ▼\n             一片切片 1-3 个 PR 上线\n```\n\n每一片要跑的迁移环：\n\n1. **基线** — 选下一组约 20-50 个文件。快照测试输出和 bundle 大小。\n2. **Codemod** — 只对这一片跑 Codemod CLI（或直接 ast-grep）。检查 diff。\n3. **类型检查** — TypeScript-Go \u002F Ty 开 watch 模式。修 codemod 推不出来的错误。\n4. **测试** — 对这一片跑现有测试套件。tsx 让你不用重新构建就能做。\n5. **上线** — 开 PR、合掉、上线。明天换下一片。\n\n如果任何一片超过 2 天还没合，那片太大。切。\n\n## 你会遇到的取舍\n\n- **Codemod CLI vs 手写 jscodeshift** — Codemod CLI 包装了 ast-grep 和注册表。手写 jscodeshift 给你完整的 JS API 控制。先用 Codemod CLI；只有当注册表没有你要的转换、且 ast-grep 模式也表达不了时，才往下掉到 jscodeshift。\n- **Mypy vs Ty** — Mypy 是老牌，更成熟，更慢。Ty 快到可以一直开在编辑器里不卡。迁移过程中两个都跑：Mypy 在 CI 里保彻底，Ty 在本地保速度。\n- **TypeScript-Go vs tsc** — TypeScript-Go 是微软官方移植，更快但还没完全特性对齐。迁移时用它跑内环类型检查；CI 里继续用 tsc 作为权威，直到对齐版本上线。\n- **Express→Hono vs Express→Fastify** — Hono 跑在边缘运行时（Cloudflare Workers、Bun、Deno）也跑在 Node，handler API 几乎一样。Fastify 只跑 Node，但在传统服务器上更成熟。要往边缘现代化就选 Hono；要留在 Node 用最成熟的就选 Fastify。\n- **全靠 codemod vs Legacy Modernizer** — codemod 几分钟内干掉 80% 机械工作。Legacy Modernizer agent 处理需要判断的 20%（死代码、被弃功能、条件分支）。别让 agent 干机械活；别让 codemod 干考古活。\n\n## 常见踩坑\n\n- **codemod 切片太大** — 「把 800 个文件一次全转 TS」保证那个 PR 永远合不掉。按目录迁，不按语言整体迁。每个 PR 都要小到一次坐下来能 review 完。\n- **忘了类型检查环很慢** — 每跑完一批 codemod 就跑 `tsc --noEmit` 是杀掉你一天的那一步。第一天就装 TypeScript-Go。10 倍提速的差别就是这事到底有趣还是苦差。\n- **盲抄注册表 codemod** — 注册表 codemod 是起点不是圣经。打开 YAML，读模式，先跑一个文件，目视检查 diff 后再放出去打全库。\n- **第一天就 Mypy `--strict` 全开** — 放弃最快的方式。按模块在 `[mypy-yourpackage.submodule]` 块里启用，向外扩。\n- **Express→Hono 一次性大改写** — 路由分组迁，两个 server 跑在同一个 router 后面（Hono 挂在 `\u002Fv2` 下），endpoint 一个个切。别把整个 app 一次性翻。\n- **盲信 codemod 处理测试** — codemod 会很高兴地把一个坏的测试套件「迁移」成一个还是坏的测试套件。每批 codemod 后跑一次测试。如果迁之前绿，迁之后红，那就是 codemod 漏了什么 — 这个 bug 你想在那一刻就抓到，不是三周后线上才发现。",[106,109,112,115,118],{"q":107,"a":108},"每片迁移应该多大？","小到一个 PR 30 分钟能 review 完、当天能上线。实际上通常就是单个目录，20-50 个文件，净 diff 不超过约 1000 行。如果某片超过这个量级，拆。增量迁移的全部意义就在于：你随时可以停下来，把已经做好的上线，明天再继续，而代码库不会处于半坏状态。",{"q":110,"a":111},"已经直接用 ast-grep 了，还需要 Codemod CLI 吗？","不严格需要，但 Codemod CLI 值两个理由。第一，社区注册表里有常见迁移的预制 codemod（React class→hooks、Mocha→Jest、CommonJS→ESM），不然你得自己写。第二，YAML 工作流格式让你把多步 ast-grep 加 shell 步骤（跑测试、格式化、commit）串成一个可复现单元。一次性改写就单独用 ast-grep；迁移超过 2-3 步或要和队友共享迁移流程时，用 Codemod CLI。",{"q":113,"a":114},"Python 迁移为什么 Mypy 和 Ty 都要？","Mypy 是事实标准，插件\u002Fstub 生态最大 — 你想要它在 CI 里作为权威。Ty 显著更快（Rust 底层），在编辑器里几乎瞬时 — 你想要它在迁移内环用。它们检查同样的 `# type:` 注解，所以同时跑不需要改任何代码。这个分工纯粹是反馈延迟的考虑：Mypy 保正确性，Ty 保速度。",{"q":116,"a":117},"测试还没写齐的迁移怎么做？","先加一层薄的特征化测试（characterization test），再做迁移。挑公开边界（HTTP 路由、CLI 命令、导出函数），写测试锁住当前行为 — 哪怕是有 bug 的行为 — 然后在迁移期间跑这些测试。codemod 是机械的，它会忠实地保留 bug。没有特征化测试，一次 codemod 后行为变了你分不清是 codemod 引入了 bug 还是它保留了 bug。在迁移片的前一片把测试加上。",{"q":119,"a":120},"Legacy Modernizer agent 和写 codemod 怎么选？","codemod 适合能用模式描述的转换：「每个 `var x =` 改成 `let x =`」「每个 `.then(cb)` 改成 await」。Legacy Modernizer agent 适合需要上下文判断的决定：「这个 2018 年的 feature flag 死了，移除」「这个模块全库没人引用，删掉」「这个条件路径只在 IE 11 跑，剪掉」。规则能用 ast-grep 模式写出来就用 codemod；规则是「读代码再判断」就用 agent。混用两边的活只会两边都浪费。",{"@context":122,"@type":123,"name":13,"description":124,"numberOfItems":125,"inLanguage":126},"https:\u002F\u002Fschema.org","ItemList","十个 AI 时代用来做真实框架与语言迁移的工具：JS 到 TypeScript、CommonJS 到 ESM、React class 到 hooks、Express 到 Hono、Python 2 到 3、Vue 2 到 3。Codemod CLI、ast-grep、TypeScript、TypeScript-Go、tsx、Mypy、Ruff、Ty、Hono、Legacy Modernizer agent。",10,"zh-CN",[128,132,136],{"url":129,"anchor":130,"reason":131},"\u002Fzh\u002Fai-tools-for\u002Fcoding","AI 编程工具总览","Codemod 与 ast-grep 属于更大的 AI 编程工具链，旁边还有 agent 和 linter",{"url":133,"anchor":134,"reason":135},"\u002Fzh\u002Ffeatured","TokRepo 精选资产","本 pack 的十个工具属于更大的精选目录",{"url":137,"anchor":138,"reason":139},"\u002Fzh\u002Ftopics","浏览其他主题 pack","重构、测试、CI 工作流等相关 pack 可与迁移工具配套使用",[141,145,149],{"claim":142,"source_name":143,"source_url":144},"Codemod CLI 一等公民支持 ast-grep，含社区代码迁移注册表","Codemod CLI on TokRepo","https:\u002F\u002Ftokrepo.com\u002Fen\u002Fworkflows\u002Fcodemod-ai-powered-code-migration-cli-a414acda",{"claim":146,"source_name":147,"source_url":148},"ast-grep 通过 AST 模式做结构化代码搜索与重写","ast-grep 官方文档","https:\u002F\u002Fast-grep.github.io\u002F",{"claim":150,"source_name":151,"source_url":152},"Ruff 在 UP 选择器下提供 pyupgrade 规则用于 Python 2 到 3 现代化修复","Ruff 规则参考","https:\u002F\u002Fdocs.astral.sh\u002Fruff\u002Frules\u002F",1180,"2026-05-22T09:30:00Z"]