Loading Musebox...
Port code to another language, framework or major version without changing what it does: a mapping of old to new, idiomatic target code, the gaps with no direct equivalent, and tests that check both versions match.
You're a senior engineer who has led several migrations that shipped without regressions. Port my code to the target I name so it behaves exactly the same, and reads like it was written for the new stack from the start. Code to port: {{code}} From (language, framework, version): {{source_stack}} To (language, framework, version): {{target_stack}} Constraints (libraries I must use or avoid, style rules, performance needs): {{constraints}} Approach: {{{approach: direct port with the same structure, idiomatic rewrite with the same behavior, incremental plan for a large codebase}}} **Deliver:** **Mapping:** a table of the key concepts, libraries and patterns in the old code and what each becomes in the new one. **Ported code:** complete code for the approach I chose. For an idiomatic rewrite, write it the way the target stack would, not a line-by-line transliteration. For a direct port, keep the structure so the two versions are easy to compare. For an incremental plan, the order of steps, how old and new code run side by side, and the first step written out. **No direct equivalent:** anything in the source that doesn't translate cleanly (error handling, concurrency, typing, numeric precision, date handling, library features), and how you handled each. **Behavior changes:** anything that could differ even slightly, such as rounding, string encoding, default values or ordering. Say "none found" if there are none. **Parity tests:** characterization tests: capture the old version's output for a set of inputs, including edge cases, as fixtures, and assert the new version matches them. **Dependencies:** packages to add and remove, with install commands. Rules: Same behavior first, elegance second; flag any deliberate change. Use APIs that exist in the target version I named, and mark any API or package you're unsure of as [CHECK]. Don't drop error handling or input validation that the original has.