refactor: rename OhMyOpenCode types to OhMyOpenAgent and centralize PACKAGE_NAME

- Rename all PascalCase types: OhMyOpenCodePlugin → OhMyOpenAgentPlugin, etc.
- 231 OhMyOpenAgent references across ~60 files
- Centralize 4 PACKAGE_NAME constants to import from plugin-identity.ts
- Update src/plugin-config.ts to use CONFIG_BASENAME from plugin-identity

Wave 3 Tasks 5 & 6 complete.
This commit is contained in:
YeonGyu-Kim
2026-03-13 18:06:12 +09:00
parent b9eda3882f
commit cdf063a0a3
65 changed files with 290 additions and 345 deletions
@@ -1,5 +1,5 @@
import type { AutoCompactState } from "./types";
import type { OhMyOpenCodeConfig } from "../../config";
import type { OhMyOpenAgentConfig } from "../../config";
import type { ExperimentalConfig } from "../../config";
import { TRUNCATE_CONFIG } from "./types";
@@ -18,7 +18,7 @@ export async function executeCompact(
autoCompactState: AutoCompactState,
client: Client,
directory: string,
pluginConfig: OhMyOpenCodeConfig,
pluginConfig: OhMyOpenAgentConfig,
_experimental?: ExperimentalConfig
): Promise<void> {
void _experimental
@@ -1,7 +1,7 @@
import type { PluginInput } from "@opencode-ai/plugin"
import type { Client } from "./client"
import type { AutoCompactState, ParsedTokenLimitError } from "./types"
import type { ExperimentalConfig, OhMyOpenCodeConfig } from "../../config"
import type { ExperimentalConfig, OhMyOpenAgentConfig } from "../../config"
import { parseAnthropicTokenLimitError } from "./parser"
import { executeCompact, getLastAssistant } from "./executor"
import { attemptDeduplicationRecovery } from "./deduplication-recovery"
@@ -9,7 +9,7 @@ import { log } from "../../shared/logger"
export interface AnthropicContextWindowLimitRecoveryOptions {
experimental?: ExperimentalConfig
pluginConfig: OhMyOpenCodeConfig
pluginConfig: OhMyOpenAgentConfig
}
function createRecoveryState(): AutoCompactState {
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"
import { runSummarizeRetryStrategy } from "./summarize-retry-strategy"
import type { AutoCompactState, ParsedTokenLimitError, RetryState } from "./types"
import type { OhMyOpenCodeConfig } from "../../config"
import type { OhMyOpenAgentConfig } from "../../config"
type TimeoutCall = {
delay: number
@@ -72,7 +72,7 @@ describe("runSummarizeRetryStrategy", () => {
autoCompactState,
client: client as never,
directory,
pluginConfig: {} as OhMyOpenCodeConfig,
pluginConfig: {} as OhMyOpenAgentConfig,
})
//#then
@@ -111,7 +111,7 @@ describe("runSummarizeRetryStrategy", () => {
autoCompactState,
client: client as never,
directory,
pluginConfig: {} as OhMyOpenCodeConfig,
pluginConfig: {} as OhMyOpenAgentConfig,
})
//#then
@@ -1,5 +1,5 @@
import type { AutoCompactState } from "./types"
import type { OhMyOpenCodeConfig } from "../../config"
import type { OhMyOpenAgentConfig } from "../../config"
import { RETRY_CONFIG } from "./types"
import type { Client } from "./client"
import { clearSessionState, getEmptyContentAttempt, getOrCreateRetryState } from "./state"
@@ -15,7 +15,7 @@ export async function runSummarizeRetryStrategy(params: {
autoCompactState: AutoCompactState
client: Client
directory: string
pluginConfig: OhMyOpenCodeConfig
pluginConfig: OhMyOpenAgentConfig
errorType?: string
messageIndex?: number
}): Promise<void> {
@@ -2,7 +2,7 @@
import { describe, expect, it, mock } from "bun:test"
import { OhMyOpenCodeConfigSchema } from "../config"
import { OhMyOpenAgentConfigSchema } from "../config"
const { createPreemptiveCompactionHook } = await import("./preemptive-compaction")
@@ -27,7 +27,7 @@ describe("preemptive-compaction aws-bedrock-anthropic", () => {
it("triggers compaction for aws-bedrock-anthropic provider when usage exceeds threshold", async () => {
// given
const ctx = createMockContext()
const pluginConfig = OhMyOpenCodeConfigSchema.parse({})
const pluginConfig = OhMyOpenAgentConfigSchema.parse({})
const hook = createPreemptiveCompactionHook(ctx, pluginConfig)
const sessionID = "ses_aws_bedrock_anthropic_high"
+2 -2
View File
@@ -1,5 +1,5 @@
import { log } from "../shared/logger"
import type { OhMyOpenCodeConfig } from "../config"
import type { OhMyOpenAgentConfig } from "../config"
import {
resolveActualContextLimit,
type ContextLimitModelCacheState,
@@ -61,7 +61,7 @@ type PluginInput = {
export function createPreemptiveCompactionHook(
ctx: PluginInput,
pluginConfig: OhMyOpenCodeConfig,
pluginConfig: OhMyOpenAgentConfig,
modelCacheState?: ContextLimitModelCacheState,
) {
const compactionInProgress = new Set<string>()
@@ -1,4 +1,4 @@
import type { OhMyOpenCodeConfig } from "../../config"
import type { OhMyOpenAgentConfig } from "../../config"
import { HOOK_NAME } from "./constants"
import { log } from "../../shared/logger"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
@@ -8,7 +8,7 @@ type ResolveFallbackBootstrapModelOptions = {
source: string
eventModel?: string
resolvedAgent?: string
pluginConfig?: OhMyOpenCodeConfig
pluginConfig?: OhMyOpenAgentConfig
}
export function resolveFallbackBootstrapModel(
@@ -1,4 +1,4 @@
import type { OhMyOpenCodeConfig } from "../../config"
import type { OhMyOpenAgentConfig } from "../../config"
import { agentPattern } from "./agent-resolver"
import { HOOK_NAME } from "./constants"
import { log } from "../../shared/logger"
@@ -8,7 +8,7 @@ import { normalizeFallbackModels } from "../../shared/model-resolver"
export function getFallbackModelsForSession(
sessionID: string,
agent: string | undefined,
pluginConfig: OhMyOpenCodeConfig | undefined
pluginConfig: OhMyOpenAgentConfig | undefined
): string[] {
if (!pluginConfig) return []
+24 -32
View File
@@ -1,6 +1,6 @@
import { describe, expect, test, beforeEach, afterEach, spyOn } from "bun:test"
import { createRuntimeFallbackHook } from "./index"
import type { RuntimeFallbackConfig, OhMyOpenCodeConfig } from "../../config"
import type { RuntimeFallbackConfig, OhMyOpenAgentConfig } from "../../config"
import * as sharedModule from "../../shared"
import { SessionCategoryRegistry } from "../../shared/session-category-registry"
@@ -62,32 +62,26 @@ describe("runtime-fallback", () => {
}
}
function createMockPluginConfigWithCategoryFallback(fallbackModels: string[]): OhMyOpenCodeConfig {
return {
categories: {
test: {
fallback_models: fallbackModels,
},
function createMockPluginConfigWithCategoryFallback(fallbackModels: string[]): OhMyOpenAgentConfig { return {
categories: {
test: {
fallback_models: fallbackModels,
},
}
}
},
} }
function createMockPluginConfigWithCategoryModel(
categoryName: string,
model: string,
fallbackModels: string[],
variant?: string,
): OhMyOpenCodeConfig {
return {
categories: {
[categoryName]: {
model,
fallback_models: fallbackModels,
...(variant ? { variant } : {}),
},
function createMockPluginConfigWithCategoryModel(categoryName: string,
model: string,
fallbackModels: string[],
variant?: string,): OhMyOpenAgentConfig { return {
categories: {
[categoryName]: {
model,
fallback_models: fallbackModels,
...(variant ? { variant } : {}),
},
}
}
},
} }
describe("session.error handling", () => {
test("should detect retryable error with status code 429", async () => {
@@ -2297,15 +2291,13 @@ describe("runtime-fallback", () => {
})
describe("fallback models configuration", () => {
function createMockPluginConfigWithAgentFallback(agentName: string, fallbackModels: string[]): OhMyOpenCodeConfig {
return {
agents: {
[agentName]: {
fallback_models: fallbackModels,
},
function createMockPluginConfigWithAgentFallback(agentName: string, fallbackModels: string[]): OhMyOpenAgentConfig { return {
agents: {
[agentName]: {
fallback_models: fallbackModels,
},
}
}
},
} }
test("should use agent-level fallback_models", async () => {
const input = createMockPluginInput()
+3 -3
View File
@@ -1,4 +1,4 @@
import type { RuntimeFallbackConfig, OhMyOpenCodeConfig } from "../../config"
import type { RuntimeFallbackConfig, OhMyOpenAgentConfig } from "../../config"
export interface RuntimeFallbackInterval {
unref: () => void
@@ -53,7 +53,7 @@ export interface FallbackResult {
export interface RuntimeFallbackOptions {
config?: RuntimeFallbackConfig
pluginConfig?: OhMyOpenCodeConfig
pluginConfig?: OhMyOpenAgentConfig
session_timeout_ms?: number
}
@@ -67,7 +67,7 @@ export interface HookDeps {
ctx: RuntimeFallbackPluginInput
config: Required<RuntimeFallbackConfig>
options: RuntimeFallbackOptions | undefined
pluginConfig: OhMyOpenCodeConfig | undefined
pluginConfig: OhMyOpenAgentConfig | undefined
sessionStates: Map<string, FallbackState>
sessionLastAccess: Map<string, number>
sessionRetryInFlight: Set<string>
@@ -1,9 +1,9 @@
import type { OhMyOpenCodeConfig } from "../../config"
import type { OhMyOpenAgentConfig } from "../../config"
import { getSessionAgent } from "../../features/claude-code-session-state"
import { getAgentConfigKey } from "../../shared/agent-display-names"
export function resolveCompactionModel(
pluginConfig: OhMyOpenCodeConfig,
pluginConfig: OhMyOpenAgentConfig,
sessionID: string,
originalProviderID: string,
originalModelID: string