refactor(cli): split doctor/model-resolution and run/events into focused modules

Doctor checks:
- model-resolution-cache.ts, model-resolution-config.ts
- model-resolution-details.ts, model-resolution-effective-model.ts
- model-resolution-types.ts, model-resolution-variant.ts

Run events:
- event-formatting.ts, event-handlers.ts
- event-state.ts, event-stream-processor.ts
This commit is contained in:
YeonGyu-Kim
2026-02-08 16:25:01 +09:00
parent 4e5792ce4d
commit 3c1e71f256
14 changed files with 577 additions and 561 deletions
@@ -0,0 +1,34 @@
import { readFileSync } from "node:fs"
import { homedir } from "node:os"
import { join } from "node:path"
import { detectConfigFile, parseJsonc } from "../../../shared"
import type { OmoConfig } from "./model-resolution-types"
const PACKAGE_NAME = "oh-my-opencode"
const USER_CONFIG_DIR = join(homedir(), ".config", "opencode")
const USER_CONFIG_BASE = join(USER_CONFIG_DIR, PACKAGE_NAME)
const PROJECT_CONFIG_BASE = join(process.cwd(), ".opencode", PACKAGE_NAME)
export function loadOmoConfig(): OmoConfig | null {
const projectDetected = detectConfigFile(PROJECT_CONFIG_BASE)
if (projectDetected.format !== "none") {
try {
const content = readFileSync(projectDetected.path, "utf-8")
return parseJsonc<OmoConfig>(content)
} catch {
return null
}
}
const userDetected = detectConfigFile(USER_CONFIG_BASE)
if (userDetected.format !== "none") {
try {
const content = readFileSync(userDetected.path, "utf-8")
return parseJsonc<OmoConfig>(content)
} catch {
return null
}
}
return null
}