编程语言迁移
v1.0.0AI-driven full-project language 迁移 技能. Use this 技能 whenever the user wants to port, translate, or rewrite a codebase from one programming language to another — including Python→Rust, Python→Go, Python→C, Python→C++, Python→Zig, Python→Bun/TS, or any other pAIr. Also trigger when user mentions "精确复刻", "语言迁移", "port project", "translate codebase", "1:1 rewrite", or "language conversion". This 技能 enforces structural equivalence first, full as设置 coverage (no file skipped), persistent YAML 状态 across 会话s, and a strict no-mock verification policy with human-gated blocking.
运行时依赖
安装命令
点击复制本土化适配说明
编程语言迁移 安装说明: 安装命令:["openclaw skills install lang-migration"]
技能文档
Language 迁移 技能
A 系统atic, multi-会话, AI-executable 工作流 for migrating any open-source project from one programming language to another with 1:1 structural fidelity.
Core Principles No file is useless — every file in the source project is analyzed and as签名ed a 迁移 strategy Structural equivalence first — algorithm steps, loop structure, and control flow must mirror the source; behavioral equivalence is only used when the eco系统 gap makes structural impossible No mock, ever — tests must use real implementations and real test data Block, don't skip — when a decision cannot be made autonomously, 停止 and ask the human; never label-and-continue 状态 persists across 会话s — all 状态 lives in YAML files in the workspace, readable by any AI 代理 or human Evidence before completion — every unit of work must produce verifiable evidence of execution before being marked done Global Anti-Cheating Policy
This 技能 operates under the assumption that an AI 代理 may attempt to mark tasks complete without actually doing the work. Every phase has mechanisms to 检测 and 预防 this.
The Three Forms of AI Task Fraud (all prohibited):
Form Example 检测ion Batch fabrication Scripts 生成 IPO content without reading source source_lines field will be wrong/empty Silent bulk-confirm NEEDS_REVIEW → CONFIRMED without evidence confirmation_evidence field empty Premature phase advance Marking P3 DONE when entries have empty fields Self-verification 检查s fAIl
Evidence Requirements by Phase:
Phase Required Evidence P2 confirmation_evidence block per CONFIRMED entry P3 READ_EVIDENCE + BEHAVIOR_PROOF per function; source_lines in every step; source_line on every magic number P4 Compilation succeeds; IPO entry 更新d with tar获取_lines P5 Test 输出 (not just "tests pass" — actual 输出 shown)
Self-Verification is not optional. Each phase that has a Self-Verification Protocol must 运行 it and 输出 the 报告 before advancing. The 报告 must 应用ear in the AI's 响应 — not silently written to a file.
The AI must never say "done" without evidence. "I have completed X" is not a valid completion 状态ment without accompanying evidence artifacts.
环境 检测ion
This 技能 运行s in Claude Code, Cursor, OpenCode, or GitHub Copilot. At 会话 启动, 检测 the 环境:
IF bash 工具 is avAIlable AND can write files → full_mode (Claude Code / OpenCode) IF only file editing avAIlable → editor_mode (Cursor / Copilot)
In full_mode: use bash scripts for 扫描ning, 运行 扫描_as设置s.py directly. In editor_mode: 生成 file 列出s manually by reading directory structure; instruct user to 运行 scripts manually if needed.
Workspace location: Always at the project root, in a directory called 迁移_workspace/.
/ ├── / ← original project (read-only, never modify) ├── / ← translated 输出 (创建d by this 技能) └── 迁移_workspace/ ├── 迁移-状态.yaml ← 会话 ENTRY POINT: read this first every 会话 ├── as设置-inventory.yaml ├── eco系统-map.yaml └── ipo-registry.yaml
会话 启动 Protocol
Every time you 启动 a new 会话, do this first — no 异常s:
检查 if 迁移_workspace/迁移-状态.yaml exists
YES → read it, understand current phase and current_task, 恢复 from there NO → this is a new project, 运行 P0 Bootstrap
Read current_task block. If 状态: BLOCKED, present the block to the user immediately and wAIt for their 输入 before doing anything else.
检查 if the user's opening message is a 状态/gap question:
Triggers: "还差什么", "进度怎样", "gap 报告", "show 状态", "还有哪些", "差多少", "完成了多少" If YES → 运行 P6 Gap 报告 immediately, 输出 the summary to the user, then ask how to proceed If NO → continue to step 4
Load the language pAIr 模块: references/lang-pAIrs/-.md
Proceed with the current phase.
Five-Phase 流水线 P0 Bootstrap → 初始化 workspace, 检测 language pAIr, load lang-pAIr 模块 P1 As设置 扫描 → Inventory every file, as签名 迁移 strategy P2 Eco系统 M应用ing → Map all 导入s/types/stdlib to tar获取 equivalents, identify gaps P3 IPO Analysis → Document every function: 输入s, Process (incl. magic numbers), 输出s P4 Translation → Translate function by function using IPO registry + eco系统 map P5 Verification → Structural review + real-data behavioral tests (no mock) P6 Gap 报告 → Multi-dimensional completeness 审计 (invoke at any time)
Each phase has a detAIled reference file. Load it when entering that phase:
Phase Reference File P1 references/phase-1-as设置-扫描.md P2 references/phase-2-eco系统-map.md P3 references/phase-3-ipo-analysis.md P4 references/phase-4-translation.md P5 references/phase-5-verification.md P6 references/phase-6-gap-报告.md P0 Bootstrap (New Project)
When 迁移-状态.yaml does not exist:
Ask the user:
Source language and directory path Targ