Skip to content

refactor(session): replace MigrationEngine and isolate migrate command - #1195

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
ousamabenyounes:refactor/migration-preview
Oct 17, 2026
Merged

jeff-r2026 merged 2 commits into
Tencent:mainfrom
ousamabenyounes:refactor/migration-preview

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Summary

Replace the one-method MigrationEngine with previewMigration(session, sourcePlatform, targetPlatform) beside fidelityFromSession. The migration command calls the function directly; copy behavior still lives in AgentSession.copy.

Move migration command registration into its own module and shared session helpers into another, leaving session-cmd.ts focused on the remaining commands. The extracted command bodies are unchanged apart from imports, exports, and the preview call.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npm run lint passes
  • npx vitest run passes
  • Added/updated tests for the change

A new contract test failed on the unmodified base (previewMigration is not a function: 1 failed, 6 passed). With the implementation, both focused suites passed (72 tests). Reverting the implementation reproduced the same failure. This RED verifies the requested refactor contract; it is not evidence of a pre-existing user-facing bug.

On the final commit, 72 focused tests and the real CLI migration E2E with OpenCode 2 passed. The changed executable logic has 17/17 covered lines; exact code moves were audited separately.

Full local run-ci.sh (baseline comparison): lint, typecheck, and build pass. The host suite has 6 failures on both base and PR; the only PR-only failure passed on isolated rerun and with its entire 166-test file. Every Node 20/22 failure in this run also occurred in at least one of the base branch’s Node 20/22 runs; Node 22 has 224 versus 225 on base. The full E2E suite has the same single failing test on base and PR (1 failed, 150 passed, 6 skipped test files on each).

Related Issues

Refs #1140, proposal 3 only. Proposals 1, 2, and 4 remain open.

Notes for Reviewers

The second commit moves the existing migration command and shared helpers out of session-cmd.ts; it does not rewrite their behavior. The API surface change is the removal of MigrationEngine in favor of previewMigration.

Keep session command modules below the production file-size limit without changing CLI behavior.
@github-actions

Copy link
Copy Markdown

No findings in the specified PR diff.

  • The extracted migration command preserves its behavior apart from replacing MigrationEngine.preview with previewMigration.
  • The PR description documents sufficient testing, including a representative real-CLI migration E2E with OpenCode 2.

Review was read-only; I did not run, build, or install PR code.

@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Validation on c4e4f24: the new preview contract was RED on the unmodified base (1 failed, 6 passed), then GREEN (72 focused tests passed). The real CLI migration E2E passed with OpenCode 2. GitHub's six Node jobs, fork-safe E2E, build, metrics, and scan are green. The local full-suite baseline failures and the isolated transient test are documented in the PR description.

@jeff-r2026
jeff-r2026 merged commit 9c797b7 into Tencent:main Oct 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants