Skip to content

Fix core migrate binary to call programmatic migration API#13

Merged
ethanj merged 1 commit into
mainfrom
sync/monorepo-6a3b09e
May 21, 2026
Merged

Fix core migrate binary to call programmatic migration API#13
ethanj merged 1 commit into
mainfrom
sync/monorepo-6a3b09e

Conversation

@ethanj
Copy link
Copy Markdown
Contributor

@ethanj ethanj commented May 21, 2026

Summary

Fix the published atomicmemory-core binary so that atomicmemory-core migrate works correctly for npm installs. Previously the migrate command imported the standalone migration CLI, which reparsed process.argv and treated the command word migrate as a migration option, breaking the documented workflow.

Changes

  • bin.ts: Route the migrate command through migration-api.migrate() directly instead of importing the standalone migrate.js CLI.
  • bin.ts: Export runCommand and parseCliArgs so the dispatch logic is testable without spawning a subprocess.
  • bin.test.ts: Add CLI dispatch regression test that guards against migrate.js being re-imported and verifies the programmatic API receives the call.
  • CHANGELOG.md: Document the fix and the new behavior.

Why

The standalone migrate.js module re-reads process.argv when imported, so invoking atomicmemory-core migrate caused the string "migrate" to be reparsed as a migration option rather than the command name. The programmatic migration-api.migrate() function accepts no argv and applies migrations directly, which is the correct path for a CLI dispatch layer.

Validation

  • New bin.test.ts confirms parseCliArgs strips the command word correctly and that runCommand('migrate') calls migration-api.migrate() exactly once without ever importing migrate.js.
  • The mock guard in the test (throw new Error(...)) ensures the regression cannot silently reappear.

## Summary

Fix the published `atomicmemory-core` binary so that `atomicmemory-core migrate` works correctly for npm installs. Previously the `migrate` command imported the standalone migration CLI, which reparsed `process.argv` and treated the command word `migrate` as a migration option, breaking the documented workflow.

## Changes

- `bin.ts`: Route the `migrate` command through `migration-api.migrate()` directly instead of importing the standalone `migrate.js` CLI.
- `bin.ts`: Export `runCommand` and `parseCliArgs` so the dispatch logic is testable without spawning a subprocess.
- `bin.test.ts`: Add CLI dispatch regression test that guards against `migrate.js` being re-imported and verifies the programmatic API receives the call.
- `CHANGELOG.md`: Document the fix and the new behavior.

## Why

The standalone `migrate.js` module re-reads `process.argv` when imported, so invoking `atomicmemory-core migrate` caused the string `"migrate"` to be reparsed as a migration option rather than the command name. The programmatic `migration-api.migrate()` function accepts no argv and applies migrations directly, which is the correct path for a CLI dispatch layer.

## Validation

- New `bin.test.ts` confirms `parseCliArgs` strips the command word correctly and that `runCommand('migrate')` calls `migration-api.migrate()` exactly once without ever importing `migrate.js`.
- The mock guard in the test (`throw new Error(...)`) ensures the regression cannot silently reappear.
@ethanj ethanj merged commit 79c9cf1 into main May 21, 2026
9 checks passed
@ethanj ethanj deleted the sync/monorepo-6a3b09e branch May 21, 2026 06:45
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.

1 participant