diff options
Diffstat (limited to 'plugins/code-modernization/commands/modernize-transform.md')
| -rw-r--r-- | plugins/code-modernization/commands/modernize-transform.md | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/plugins/code-modernization/commands/modernize-transform.md b/plugins/code-modernization/commands/modernize-transform.md index d946b93f..1e590135 100644 --- a/plugins/code-modernization/commands/modernize-transform.md +++ b/plugins/code-modernization/commands/modernize-transform.md @@ -1,25 +1,26 @@ --- description: Transform one legacy module to the target stack — idiomatic rewrite with behavior-equivalence tests argument-hint: <system-dir> <module> <target-stack> +arguments: system module target_stack --- -Transform `legacy/$1` module **`$2`** into **$3**, with proof of behavioral +Transform `legacy/$system` module **`$module`** into **$target_stack**, with proof of behavioral equivalence. This is a surgical, single-module transformation — one vertical slice of the -strangler fig. Output goes to `modernized/$1/$2/`. +strangler fig. Output goes to `modernized/$system/$module/`. ## Step 0a — Toolchain check (fail fast on target, adapt on legacy) Verify the build environment **before** planning, not when the tests first run: -- **Target stack ($3) — required.** Runtime, package manager, and test +- **Target stack ($target_stack) — required.** Runtime, package manager, and test framework all respond (`java -version` + `mvn -v`, `node -v` + `npm -v`, `python3 -V` + `pytest --version`, …). If any are missing, stop and report what to install — the new code and its tests cannot run without them, so a plan gate now would just defer the failure an hour. Suggest - `/modernize-preflight $1 $3` for the full readiness report. + `/code-modernization:modernize-preflight $system $target_stack` for the full readiness report. - **Legacy stack — advisory, never a blocker.** Try a syntax-only compile of the module being transformed (e.g. `cobc -fsyntax-only`). Legacy code often *cannot* build locally by nature, not by misconfiguration — @@ -37,19 +38,19 @@ first run: ## Step 0b — Plan (HITL gate) -**The brief is binding — read it first.** If `analysis/$1/MODERNIZATION_BRIEF.md` +**The brief is binding — read it first.** If `analysis/$system/MODERNIZATION_BRIEF.md` exists, this transform is one phase (or one module of a phase) of that plan: read it before deciding anything below. Find the phase that names this -command with `$2` in scope, and treat that phase's **scope, entry criteria, +command with `$module` in scope, and treat that phase's **scope, entry criteria, exit criteria, and any edits the user made to it** as binding on the plan you present below. Entry criteria are *gates*, not context: if one is not met (a prior phase's exit criteria, an SME sign-off the brief requires), meeting it **is** the next step — do not proceed past it and do not silently -re-plan around it. If the brief exists but no phase covers `$2`, stop and +re-plan around it. If the brief exists but no phase covers `$module`, stop and ask which phase this is. The user steers execution by editing the brief; a brief the execution command never reads cannot steer anything. -Read the source module and any business rules in `analysis/$1/BUSINESS_RULES.md` +Read the source module and any business rules in `analysis/$system/BUSINESS_RULES.md` that reference it. Then present the plan and **stop — write no code until the user explicitly approves** (use plan mode if the session supports it): - Which source files are in scope @@ -64,11 +65,11 @@ Wait for approval before writing any code. Before writing target code, spawn the **test-engineer** subagent: -"Write characterization tests for legacy/$1 module $2. Read the source, +"Write characterization tests for legacy/$system module $module. Read the source, identify every observable behavior, and encode each as a test case with concrete input → expected output pairs derived from the legacy logic. -Target framework: <appropriate for $3>. Write to -`modernized/$1/$2/src/test/`. These tests define 'done' — the new code +Target framework: <appropriate for $target_stack>. Write to +`modernized/$system/$module/src/test/`. These tests define 'done' — the new code must pass all of them. Follow your secret-handling rules: no credential literal from legacy code becomes a fixture; substitute fake same-shape values and read anything genuinely live from environment variables." @@ -77,9 +78,9 @@ Show the user the test file. Get a 👍 before proceeding. ## Step 2 — Idiomatic transformation -Write the target implementation in `modernized/$1/$2/src/main/`. +Write the target implementation in `modernized/$system/$module/src/main/`. -**Critical:** Write code a senior $3 engineer would write from the +**Critical:** Write code a senior $target_stack engineer would write from the *specification*, not from the legacy structure. Do NOT mirror COBOL paragraphs as methods, do NOT preserve legacy variable names like `WS-TEMP-AMT-X`. Use the target language's idioms: records/dataclasses, streams, dependency @@ -93,13 +94,13 @@ class back to the rule IDs it implements. Run the characterization tests: ```bash -cd modernized/$1/$2 && <appropriate test command for $3> +cd modernized/$system/$module && <appropriate test command for $target_stack> ``` Show the output. If anything fails, fix and re-run until green. ## Step 4 — Side-by-side review -Generate `modernized/$1/$2/TRANSFORMATION_NOTES.md`: +Generate `modernized/$system/$module/TRANSFORMATION_NOTES.md`: - Mapping table: legacy file:lines → target file:lines, per behavior - Deliberate deviations from legacy behavior (with rationale) - What was NOT migrated (dead code, unreachable branches) and why @@ -107,7 +108,7 @@ Generate `modernized/$1/$2/TRANSFORMATION_NOTES.md`: Then show a visual diff of one representative behavior, legacy vs modern: ```bash -delta --side-by-side <(sed -n '<lines>p' legacy/$1/<file>) modernized/$1/$2/src/main/<file> +delta --side-by-side <(sed -n '<lines>p' legacy/$system/<file>) modernized/$system/$module/src/main/<file> ``` (Fall back to `diff -y --width=160` if `delta` isn't installed.) Never pick a credential-bearing line range for this diff, and mask any @@ -117,7 +118,7 @@ live in `modernized/` and get committed. ## Step 5 — Architecture review Spawn the **architecture-critic** subagent to review the transformed code -against $3 best practices. Apply any HIGH-severity feedback; list the rest +against $target_stack best practices. Apply any HIGH-severity feedback; list the rest in TRANSFORMATION_NOTES.md. Report: tests passing, lines of legacy retired, location of artifacts. |
