polymorph
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePolymorph
Polymorph
Transform one representation into another entirely — formats, schemas, protocols, or interfaces.
将一种表示形式完全转换为另一种——包括格式、模式(schema)、协议或接口。
What This Skill Does
该技能的作用
This spell is about representation change, not:
- Naming changes (same structure, different identifiers)
- Execution changes (same code, different runtime)
- Architecture changes (new system design)
- Duplication (same thing, different place) The key test: Can you point to a source artifact and a target artifact where the same information is expressed in structurally different ways? If yes → Polymorph. In this grimoire, Polymorph is treated as a metaphorical spell with a shipping-now delivery profile. Canonical reference input: Polymorph (spell).
此魔法专注于表示形式的转换,而非:
- 命名变更(结构相同,标识符不同)
- 执行变更(代码相同,运行时不同)
- 架构变更(新的系统设计)
- 重复复制(内容相同,位置不同) 关键测试:你能否指出一个源工件和一个目标工件,其中相同的信息以结构不同的方式呈现?如果可以,则属于Polymorph的范畴。 在这本魔法书(grimoire)中,Polymorph被视为一个具有“即时交付”特性的隐喻性魔法。 标准参考输入:Polymorph(spell)。
When To Use
使用场景
- Activate this spell when the user asks to convert, transform, or migrate data, code, or specifications from one representation format to another where the source and target have different structures and require real semantic mapping.
- Verbs: "convert", "transform", "translate", "migrate" (between formats)
- Explicit format pairs: "CSV to JSON", "Python to JavaScript", "REST to GraphQL", "YAML to HCL", "Swagger to OpenAPI", "Avro to JSON Schema"
- Phrases: "preserve the structure but change the format", "map X concepts to Y", "flag what doesn't translate", "equivalent in [target format]"
- Scope indicators: "150 test files", "50 components", "entire test suite" (still this spell if it's format conversion at scale)
- 当用户要求将数据、代码或规范从一种表示格式转换为另一种,且源格式与目标格式结构不同,需要实际语义映射时,激活此魔法。
- 触发动词:"convert"(转换)、"transform"(变换)、"translate"(转译)、"migrate"(迁移)(用于格式间转换)
- 明确的格式对:"CSV转JSON"、"Python转JavaScript"、"REST转GraphQL"、"YAML转HCL"、"Swagger转OpenAPI"、"Avro转JSON Schema"
- 相关表述:"保留结构但更改格式"、"将X概念映射到Y"、"标记无法转换的内容"、"在[目标格式]中的等效形式"
- 范围指标:"150个测试文件"、"50个组件"、"整个测试套件"(如果是大规模格式转换,仍适用此魔法)
Prerequisites
前置条件
- No extra runtime dependencies beyond Hermes Agent and the normal toolset for this session.
- 除了Hermes Agent和本次会话的常规工具集外,无需额外的运行时依赖。
Procedure
操作步骤
- Restate the target, the success condition, and any no-touch boundaries before taking action.
- Identify source and target representations — name both formats explicitly
- Map structural correspondences — list what maps to what; identify what has no equivalent
- Execute transformation — convert preserving semantics; flag losses immediately
- Validate and report — confirm output is well-formed; document preserved, approximated, and lost elements
- Package the result as the deliverables below, with confidence, assumptions, and unresolved risk called out explicitly.
- 在采取行动前,重述目标、成功条件以及任何不可修改的边界。
- 识别源和目标表示形式——明确命名两种格式
- 映射结构对应关系——列出各元素的映射关系;识别无等效项的内容
- 执行转换——在保留语义的前提下进行转换;立即标记丢失的内容
- 验证并报告——确认输出格式规范;记录保留、近似转换和丢失的元素
- 按照以下交付成果打包结果,并明确说明信心、假设和未解决的风险。
Deliverables
交付成果
- The transformed artifact in the target representation.
- A mapping report showing what was preserved, approximated, and lost in translation.
- Validation that the output is well-formed in the target format.
- 目标表示形式的转换后工件。
- 一份映射报告,展示转换中保留、近似转换和丢失的内容。
- 验证输出符合目标格式的规范要求。
Pitfalls / Guardrails
注意事项/约束
- Keep the metaphor anchored to a real mechanism instead of drifting into lore.
- Always report losses — never claim lossless conversion when formats differ in expressive power
- Flag ambiguous mappings — when source concept has no clean target equivalent, say so
- Validate output format — the result must be syntactically valid in the target representation
- Do NOT activate this spell for:
- Do not use for: Global rename/refactor: "rename module X to Y across the codebase" — same structure, different names
- Do not use for: Disguise/wrapper layers: "make JSON look like XML without changing backend" — not actual transformation
- Do not use for: Workflow orchestration: "chain these scripts into a pipeline", "create a DAG" — about execution order, not representation
- Do not use for: Worker pools/parallelism: "spawn background workers for each record" — about concurrency, not format
- Do not use for: Full redesign from scratch: "rewrite as blockchain-based system" — new architecture, not mapping
- Do not use for: Cloning/duplicating: "make staging look like production" — copying, not transforming
- 保持隐喻与实际机制挂钩,不要脱离实际。
- 始终报告丢失的内容——当格式的表达能力存在差异时,绝不要声称转换是无损耗的
- 标记模糊的映射关系——当源概念在目标格式中没有明确等效项时,需明确说明
- 验证输出格式——结果必须在目标表示形式中语法有效
- 请勿在以下场景激活此魔法:
- 全局重命名/重构:"将代码库中的模块X重命名为Y"——结构相同,仅名称不同
- 伪装/包装层:"让JSON看起来像XML但不修改后端"——并非实际转换
- 工作流编排:"将这些脚本链接成流水线"、"创建DAG"——关乎执行顺序,而非表示形式
- 工作池/并行处理:"为每条记录生成后台工作进程"——关乎并发,而非格式
- 从零开始重新设计:"重写为基于区块链的系统"——新架构,而非映射转换
- 克隆/复制:"让 staging 环境与生产环境一致"——复制操作,而非转换
Verification
验证
- Check that the result includes every deliverable promised above.
- Check that confirmed facts, assumptions, and inferences are visibly separated.
- Check that the metaphor still maps cleanly to a real operational mechanism.
- 检查结果是否包含上述承诺的所有交付成果。
- 检查已确认的事实、假设和推断是否清晰区分。
- 检查隐喻是否仍能清晰对应实际操作机制。
Example Invocation
调用示例
text
/polymorph transform this from its current form into the target format, and tell me what survived the conversion and what did nottext
/polymorph 将当前形式转换为目标格式,并告诉我转换后保留了什么、丢失了什么