Files
orcs-code/src/migrations/migrateOpusToOpus1m.ts
did:key:z6MkqDnb7Siv3Cwj7pGJq4T5EsUisECqR8KpnDLwcaZq5TPr d2542c9a62 asdf
Squash the current repository state back into one baseline commit while
preserving the README reframing and repository contents.

Constraint: User explicitly requested a single squashed commit with subject "asdf"
Confidence: high
Scope-risk: broad
Reversibility: clean
Directive: This commit intentionally rewrites published history; coordinate before future force-pushes
Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr
Not-tested: Fresh clone verification after push
2026-03-31 03:34:03 -07:00

44 lines
1.3 KiB
TypeScript

import { logEvent } from '../services/analytics/index.js'
import {
getDefaultMainLoopModelSetting,
isOpus1mMergeEnabled,
parseUserSpecifiedModel,
} from '../utils/model/model.js'
import {
getSettingsForSource,
updateSettingsForSource,
} from '../utils/settings/settings.js'
/**
* Migrate users with 'opus' pinned in their settings to 'opus[1m]' when they
* are eligible for the merged Opus 1M experience (Max/Team Premium on 1P).
*
* CLI invocations with --model opus are unaffected: that flag is a runtime
* override and does not touch userSettings, so it continues to use plain Opus.
*
* Pro subscribers are skipped — they retain separate Opus and Opus 1M options.
* 3P users are skipped — their model strings are full model IDs, not aliases.
*
* Idempotent: only writes if userSettings.model is exactly 'opus'.
*/
export function migrateOpusToOpus1m(): void {
if (!isOpus1mMergeEnabled()) {
return
}
const model = getSettingsForSource('userSettings')?.model
if (model !== 'opus') {
return
}
const migrated = 'opus[1m]'
const modelToSet =
parseUserSpecifiedModel(migrated) ===
parseUserSpecifiedModel(getDefaultMainLoopModelSetting())
? undefined
: migrated
updateSettingsForSource('userSettings', { model: modelToSet })
logEvent('tengu_opus_to_opus1m_migration', {})
}