Files
oh-my-opencode/src/hooks/auto-update-checker/checker/check-for-update.ts
T
YeonGyu-Kim 119e18c810 refactor: wave 2 - split atlas, auto-update-checker, session-recovery, todo-enforcer, background-task hooks
- Extract atlas/ into 15 focused modules (hook, event handler, tool policies, types, etc.)
- Split auto-update-checker into checker/ and hook/ subdirectories with single-purpose files
- Decompose session-recovery into separate recovery strategy files per error type
- Extract todo-continuation-enforcer from monolith to directory with dedicated modules
- Split background-task/tools.ts into individual tool creator files
- Extract command-executor, tmux-utils into focused sub-modules
- Split config/schema.ts into domain-specific schema files
- Decompose cli/config-manager.ts into focused modules
- Rollback skill-mcp-manager, model-availability, index.ts splits that broke tests
- Fix all import path depths for moved files (../../ -> ../../../)
- Add explicit type annotations to resolve TS7006 implicit any errors

Typecheck: 0 errors
Tests: 2359 pass, 5 fail (all pre-existing)
2026-02-08 15:01:42 +09:00

70 lines
2.0 KiB
TypeScript

import { log } from "../../../shared/logger"
import type { UpdateCheckResult } from "../types"
import { extractChannel } from "../version-channel"
import { isLocalDevMode } from "./local-dev-path"
import { findPluginEntry } from "./plugin-entry"
import { getCachedVersion } from "./cached-version"
import { getLatestVersion } from "./latest-version"
export async function checkForUpdate(directory: string): Promise<UpdateCheckResult> {
if (isLocalDevMode(directory)) {
log("[auto-update-checker] Local dev mode detected, skipping update check")
return {
needsUpdate: false,
currentVersion: null,
latestVersion: null,
isLocalDev: true,
isPinned: false,
}
}
const pluginInfo = findPluginEntry(directory)
if (!pluginInfo) {
log("[auto-update-checker] Plugin not found in config")
return {
needsUpdate: false,
currentVersion: null,
latestVersion: null,
isLocalDev: false,
isPinned: false,
}
}
const currentVersion = getCachedVersion() ?? pluginInfo.pinnedVersion
if (!currentVersion) {
log("[auto-update-checker] No cached version found")
return {
needsUpdate: false,
currentVersion: null,
latestVersion: null,
isLocalDev: false,
isPinned: false,
}
}
const channel = extractChannel(pluginInfo.pinnedVersion ?? currentVersion)
const latestVersion = await getLatestVersion(channel)
if (!latestVersion) {
log("[auto-update-checker] Failed to fetch latest version for channel:", channel)
return {
needsUpdate: false,
currentVersion,
latestVersion: null,
isLocalDev: false,
isPinned: pluginInfo.isPinned,
}
}
const needsUpdate = currentVersion !== latestVersion
log(
`[auto-update-checker] Current: ${currentVersion}, Latest (${channel}): ${latestVersion}, NeedsUpdate: ${needsUpdate}`
)
return {
needsUpdate,
currentVersion,
latestVersion,
isLocalDev: false,
isPinned: pluginInfo.isPinned,
}
}