MCPcopy Create free account
hub / github.com/cortexkit/magic-context / ensureValidOptions

Function ensureValidOptions

packages/cli/src/commands/migrate.ts:869–892  ·  view source on GitHub ↗
(
    opts: MigrateCliOptions,
)

Source from the content-addressed store, hash-verified

867}
868
869function ensureValidOptions(
870 opts: MigrateCliOptions,
871): asserts opts is Required<Pick<MigrateCliOptions, "from" | "to" | "session">> &
872 MigrateCliOptions {
873 if (!opts.from) throw new Error("Missing required flag: --from <opencode>");
874 if (!opts.to) throw new Error("Missing required flag: --to <pi>");
875 if (opts.from !== "opencode" || opts.to !== "pi") {
876 if (opts.from === "pi" && opts.to === "opencode") {
877 throw new Error(
878 "Migration pi → opencode is not yet supported (V1 supports only opencode → pi)",
879 );
880 }
881 throw new Error(
882 `Unsupported migration: ${opts.from} → ${opts.to} (V1 supports only opencode → pi)`,
883 );
884 }
885 if (!opts.session) throw new Error("Missing required flag: --session <id>");
886 if (
887 opts.maxMessages !== undefined &&
888 (!Number.isInteger(opts.maxMessages) || opts.maxMessages <= 0)
889 ) {
890 throw new Error("--max-messages must be a positive integer");
891 }
892}
893
894export function migrateOpenCodeSessionToPi(
895 opts: MigrateOpenCodeSessionToPiOptions,

Callers 1

runMigrateCliFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected