refactor: update remaining modules to use plugin-identity constants

Update various modules to use centralized constants from plugin-identity:
- get-local-version/formatter: Use PUBLISHED_PACKAGE_NAME
- run/session-resolver: Use PUBLISHED_PACKAGE_NAME
- background-agent/task-poller: Use PUBLISHED_PACKAGE_NAME
- mcp-oauth/provider: Use PUBLISHED_PACKAGE_NAME
- auto-update-checker/constants: Use ACCEPTED_PACKAGE_NAMES
- comment-checker/downloader: Use PUBLISHED_PACKAGE_NAME
- legacy-plugin-toast/hook: Use PLUGIN_NAME
- shared/data-path: Use CACHE_DIR_NAME
- shared/external-plugin-detector: Use ACCEPTED_PACKAGE_NAMES
- shared/logger: Use LOG_FILENAME
- tools/ast-grep/downloader: Use PUBLISHED_PACKAGE_NAME
- tools/call-omo-agent/tools: Use PUBLISHED_PACKAGE_NAME
- tools/delegate-task/category-resolver: Use PUBLISHED_PACKAGE_NAME
- tools/grep/constants: Use PUBLISHED_PACKAGE_NAME
- tools/grep/downloader: Use PUBLISHED_PACKAGE_NAME
- tools/lsp/lsp-client-wrapper: Use PUBLISHED_PACKAGE_NAME

🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-04-10 11:16:16 +09:00
parent 41b9b4d724
commit 33ac57ba7a
16 changed files with 61 additions and 41 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
import color from "picocolors" import color from "picocolors"
import { PLUGIN_NAME, PUBLISHED_PACKAGE_NAME } from "../../shared"
import type { VersionInfo } from "./types" import type { VersionInfo } from "./types"
const SYMBOLS = { const SYMBOLS = {
@@ -15,7 +16,7 @@ export function formatVersionOutput(info: VersionInfo): string {
const lines: string[] = [] const lines: string[] = []
lines.push("") lines.push("")
lines.push(color.bold(color.white("oh-my-opencode Version Information"))) lines.push(color.bold(color.white(`${PLUGIN_NAME} Version Information`)))
lines.push(color.dim("─".repeat(50))) lines.push(color.dim("─".repeat(50)))
lines.push("") lines.push("")
@@ -37,7 +38,7 @@ export function formatVersionOutput(info: VersionInfo): string {
break break
case "outdated": case "outdated":
lines.push(` ${SYMBOLS.warn} ${color.yellow("Update available")}`) lines.push(` ${SYMBOLS.warn} ${color.yellow("Update available")}`)
lines.push(` ${color.dim("Run:")} ${color.cyan("cd ~/.config/opencode && bun update oh-my-opencode")}`) lines.push(` ${color.dim("Run:")} ${color.cyan(`cd ~/.config/opencode && bun update ${PUBLISHED_PACKAGE_NAME}`)}`)
break break
case "local-dev": case "local-dev":
lines.push(` ${SYMBOLS.dev} ${color.cyan("Running in local development mode")}`) lines.push(` ${SYMBOLS.dev} ${color.cyan("Running in local development mode")}`)
+2 -1
View File
@@ -1,4 +1,5 @@
import pc from "picocolors" import pc from "picocolors"
import { PUBLISHED_PACKAGE_NAME } from "../../shared"
import type { OpencodeClient } from "./types" import type { OpencodeClient } from "./types"
import { serializeError } from "./events" import { serializeError } from "./events"
@@ -26,7 +27,7 @@ export async function resolveSession(options: {
for (let attempt = 1; attempt <= SESSION_CREATE_MAX_RETRIES; attempt++) { for (let attempt = 1; attempt <= SESSION_CREATE_MAX_RETRIES; attempt++) {
const res = await client.session.create({ const res = await client.session.create({
body: { body: {
title: "oh-my-opencode run", title: `${PUBLISHED_PACKAGE_NAME} run`,
permission: [ permission: [
{ permission: "question", action: "deny" as const, pattern: "*" }, { permission: "question", action: "deny" as const, pattern: "*" },
], ],
+3 -2
View File
@@ -1,4 +1,5 @@
import { log } from "../../shared" import { log } from "../../shared"
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
import type { BackgroundTaskConfig } from "../../config/schema" import type { BackgroundTaskConfig } from "../../config/schema"
import type { BackgroundTask } from "./types" import type { BackgroundTask } from "./types"
@@ -158,7 +159,7 @@ export async function checkAndInterruptStaleTasks(args: {
const staleMinutes = Math.round(runtime / 60000) const staleMinutes = Math.round(runtime / 60000)
const reason = sessionGone ? "session gone from status registry" : "no activity" const reason = sessionGone ? "session gone from status registry" : "no activity"
task.status = "cancelled" task.status = "cancelled"
task.error = `Stale timeout (${reason} for ${staleMinutes}min since start). This is a FINAL cancellation - do NOT create a replacement task. If the timeout is too short, increase 'background_task.${sessionGone ? "sessionGoneTimeoutMs" : "staleTimeoutMs"}' in .opencode/oh-my-opencode.json.` task.error = `Stale timeout (${reason} for ${staleMinutes}min since start). This is a FINAL cancellation - do NOT create a replacement task. If the timeout is too short, increase 'background_task.${sessionGone ? "sessionGoneTimeoutMs" : "staleTimeoutMs"}' in .opencode/${CONFIG_BASENAME}.json.`
task.completedAt = new Date() task.completedAt = new Date()
if (task.concurrencyKey) { if (task.concurrencyKey) {
@@ -196,7 +197,7 @@ export async function checkAndInterruptStaleTasks(args: {
const staleMinutes = Math.round(timeSinceLastUpdate / 60000) const staleMinutes = Math.round(timeSinceLastUpdate / 60000)
const reason = sessionGone ? "session gone from status registry" : "no activity" const reason = sessionGone ? "session gone from status registry" : "no activity"
task.status = "cancelled" task.status = "cancelled"
task.error = `Stale timeout (${reason} for ${staleMinutes}min). This is a FINAL cancellation - do NOT create a replacement task. If the timeout is too short, increase 'background_task.${sessionGone ? "sessionGoneTimeoutMs" : "staleTimeoutMs"}' in .opencode/oh-my-opencode.json.` task.error = `Stale timeout (${reason} for ${staleMinutes}min). This is a FINAL cancellation - do NOT create a replacement task. If the timeout is too short, increase 'background_task.${sessionGone ? "sessionGoneTimeoutMs" : "staleTimeoutMs"}' in .opencode/${CONFIG_BASENAME}.json.`
task.completedAt = new Date() task.completedAt = new Date()
if (task.concurrencyKey) { if (task.concurrencyKey) {
+2 -1
View File
@@ -1,5 +1,6 @@
import type { OAuthTokenData } from "./storage" import type { OAuthTokenData } from "./storage"
import { loadToken, saveToken } from "./storage" import { loadToken, saveToken } from "./storage"
import { PLUGIN_NAME } from "../../shared/plugin-identity"
import { discoverOAuthServerMetadata } from "./discovery" import { discoverOAuthServerMetadata } from "./discovery"
import type { OAuthServerMetadata } from "./discovery" import type { OAuthServerMetadata } from "./discovery"
import { getOrRegisterClient } from "./dcr" import { getOrRegisterClient } from "./dcr"
@@ -141,7 +142,7 @@ export class McpOAuthProvider {
const clientInfo = await getOrRegisterClient({ const clientInfo = await getOrRegisterClient({
registrationEndpoint: metadata.registrationEndpoint, registrationEndpoint: metadata.registrationEndpoint,
serverIdentifier: this.serverUrl, serverIdentifier: this.serverUrl,
clientName: "oh-my-opencode", clientName: PLUGIN_NAME,
redirectUris: [this.redirectUrl()], redirectUris: [this.redirectUrl()],
tokenEndpointAuthMethod: "none", tokenEndpointAuthMethod: "none",
clientId: this.configClientId, clientId: this.configClientId,
+6 -2
View File
@@ -2,8 +2,12 @@ import * as path from "node:path"
import * as os from "node:os" import * as os from "node:os"
import { getOpenCodeCacheDir } from "../../shared/data-path" import { getOpenCodeCacheDir } from "../../shared/data-path"
import { getOpenCodeConfigDir } from "../../shared/opencode-config-dir" import { getOpenCodeConfigDir } from "../../shared/opencode-config-dir"
import {
ACCEPTED_PACKAGE_NAMES as SHARED_ACCEPTED_PACKAGE_NAMES,
PUBLISHED_PACKAGE_NAME,
} from "../../shared/plugin-identity"
export const PACKAGE_NAME = "oh-my-opencode" export const PACKAGE_NAME = PUBLISHED_PACKAGE_NAME
/** /**
* All package names the canonical plugin may be published under. * All package names the canonical plugin may be published under.
* *
@@ -13,7 +17,7 @@ export const PACKAGE_NAME = "oh-my-opencode"
* because the installed name depends on which package the user added to * because the installed name depends on which package the user added to
* their config. Code that *writes* continues to use {@link PACKAGE_NAME}. * their config. Code that *writes* continues to use {@link PACKAGE_NAME}.
*/ */
export const ACCEPTED_PACKAGE_NAMES = ["oh-my-opencode", "oh-my-openagent"] as const export const ACCEPTED_PACKAGE_NAMES = SHARED_ACCEPTED_PACKAGE_NAMES
export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags` export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`
export const NPM_FETCH_TIMEOUT = 5000 export const NPM_FETCH_TIMEOUT = 5000
+7 -6
View File
@@ -12,6 +12,7 @@ import {
getCachedBinaryPath as getCachedBinaryPathShared, getCachedBinaryPath as getCachedBinaryPathShared,
} from "../../shared/binary-downloader" } from "../../shared/binary-downloader"
import { log } from "../../shared/logger" import { log } from "../../shared/logger"
import { CACHE_DIR_NAME, PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1" const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1"
const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log") const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log")
@@ -48,12 +49,12 @@ export function getCacheDir(): string {
if (process.platform === "win32") { if (process.platform === "win32") {
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA
const base = localAppData || join(homedir(), "AppData", "Local") const base = localAppData || join(homedir(), "AppData", "Local")
return join(base, "oh-my-opencode", "bin") return join(base, CACHE_DIR_NAME, "bin")
} }
const xdgCache = process.env.XDG_CACHE_HOME const xdgCache = process.env.XDG_CACHE_HOME
const base = xdgCache || join(homedir(), ".cache") const base = xdgCache || join(homedir(), ".cache")
return join(base, "oh-my-opencode", "bin") return join(base, CACHE_DIR_NAME, "bin")
} }
/** /**
@@ -113,7 +114,7 @@ export async function downloadCommentChecker(): Promise<string | null> {
const downloadUrl = `https://github.com/${REPO}/releases/download/v${version}/${assetName}` const downloadUrl = `https://github.com/${REPO}/releases/download/v${version}/${assetName}`
debugLog(`Downloading from: ${downloadUrl}`) debugLog(`Downloading from: ${downloadUrl}`)
log(`[oh-my-opencode] Downloading comment-checker binary...`) log(`[${PUBLISHED_PACKAGE_NAME}] Downloading comment-checker binary...`)
try { try {
// Ensure cache directory exists // Ensure cache directory exists
@@ -139,14 +140,14 @@ export async function downloadCommentChecker(): Promise<string | null> {
ensureExecutable(binaryPath) ensureExecutable(binaryPath)
debugLog(`Successfully downloaded binary to: ${binaryPath}`) debugLog(`Successfully downloaded binary to: ${binaryPath}`)
log(`[oh-my-opencode] comment-checker binary ready.`) log(`[${PUBLISHED_PACKAGE_NAME}] comment-checker binary ready.`)
return binaryPath return binaryPath
} catch (err) { } catch (err) {
debugLog(`Failed to download: ${err}`) debugLog(`Failed to download: ${err}`)
log(`[oh-my-opencode] Failed to download comment-checker: ${err instanceof Error ? err.message : err}`) log(`[${PUBLISHED_PACKAGE_NAME}] Failed to download comment-checker: ${err instanceof Error ? err.message : err}`)
log(`[oh-my-opencode] Comment checking disabled.`) log(`[${PUBLISHED_PACKAGE_NAME}] Comment checking disabled.`)
return null return null
} }
} }
+2 -2
View File
@@ -2,7 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin"
import { checkForLegacyPluginEntry } from "../../shared/legacy-plugin-warning" import { checkForLegacyPluginEntry } from "../../shared/legacy-plugin-warning"
import { log } from "../../shared/logger" import { log } from "../../shared/logger"
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "../../shared/plugin-identity" import { LEGACY_PLUGIN_NAME, PLUGIN_NAME, PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
import { autoMigrateLegacyPluginEntry } from "./auto-migrate-runner" import { autoMigrateLegacyPluginEntry } from "./auto-migrate-runner"
type LegacyPluginToastDeps = { type LegacyPluginToastDeps = {
@@ -56,7 +56,7 @@ export function createLegacyPluginToastHook(ctx: PluginInput, deps: LegacyPlugin
.showToast({ .showToast({
body: { body: {
title: "Legacy Plugin Name Detected", title: "Legacy Plugin Name Detected",
message: `Update your opencode.json: "${LEGACY_PLUGIN_NAME}" has been renamed to "${PLUGIN_NAME}".\nRun: bunx ${PLUGIN_NAME} install`, message: `Update your opencode.json: "${LEGACY_PLUGIN_NAME}" has been renamed to "${PLUGIN_NAME}".\nRun: bunx ${PUBLISHED_PACKAGE_NAME} install`,
variant: "warning" as const, variant: "warning" as const,
duration: 10000, duration: 10000,
}, },
+3 -1
View File
@@ -2,6 +2,8 @@ import * as path from "node:path"
import * as os from "node:os" import * as os from "node:os"
import { accessSync, constants, mkdirSync } from "node:fs" import { accessSync, constants, mkdirSync } from "node:fs"
import { CACHE_DIR_NAME } from "./plugin-identity"
function resolveWritableDirectory(preferredDir: string, fallbackSuffix: string): string { function resolveWritableDirectory(preferredDir: string, fallbackSuffix: string): string {
try { try {
mkdirSync(preferredDir, { recursive: true }) mkdirSync(preferredDir, { recursive: true })
@@ -50,7 +52,7 @@ export function getCacheDir(): string {
* All platforms: ~/.cache/oh-my-opencode * All platforms: ~/.cache/oh-my-opencode
*/ */
export function getOmoOpenCodeCacheDir(): string { export function getOmoOpenCodeCacheDir(): string {
return path.join(getCacheDir(), "oh-my-opencode") return path.join(getCacheDir(), CACHE_DIR_NAME)
} }
/** /**
+11 -10
View File
@@ -5,6 +5,7 @@
import { loadOpencodePlugins } from "./load-opencode-plugins" import { loadOpencodePlugins } from "./load-opencode-plugins"
import { log } from "./logger" import { log } from "./logger"
import { CONFIG_BASENAME, PLUGIN_NAME } from "./plugin-identity"
/** /**
* Known notification plugins that conflict with oh-my-opencode's session-notification. * Known notification plugins that conflict with oh-my-opencode's session-notification.
@@ -110,29 +111,29 @@ export function detectExternalSkillPlugin(directory: string): ExternalSkillPlugi
* Generate a warning message for users with conflicting notification plugins. * Generate a warning message for users with conflicting notification plugins.
*/ */
export function getNotificationConflictWarning(pluginName: string): string { export function getNotificationConflictWarning(pluginName: string): string {
return `[oh-my-opencode] External notification plugin detected: ${pluginName} return `[${PLUGIN_NAME}] External notification plugin detected: ${pluginName}
Both oh-my-opencode and ${pluginName} listen to session.idle events. Both ${PLUGIN_NAME} and ${pluginName} listen to session.idle events.
Running both simultaneously can cause crashes on Windows. Running both simultaneously can cause crashes on Windows.
oh-my-opencode's session-notification has been auto-disabled. ${PLUGIN_NAME}'s session-notification has been auto-disabled.
To use oh-my-opencode's notifications instead, either: To use ${PLUGIN_NAME}'s notifications instead, either:
1. Remove ${pluginName} from your opencode.json plugins 1. Remove ${pluginName} from your opencode.json plugins
2. Or set "notification": { "force_enable": true } in oh-my-opencode.json` 2. Or set "notification": { "force_enable": true } in ${CONFIG_BASENAME}.json`
} }
/** /**
* Generate a warning message for users with conflicting skill plugins. * Generate a warning message for users with conflicting skill plugins.
*/ */
export function getSkillPluginConflictWarning(pluginName: string): string { export function getSkillPluginConflictWarning(pluginName: string): string {
return `[oh-my-opencode] External skill plugin detected: ${pluginName} return `[${PLUGIN_NAME}] External skill plugin detected: ${pluginName}
Both oh-my-opencode and ${pluginName} scan ~/.config/opencode/skills/ and register tools independently. Both ${PLUGIN_NAME} and ${pluginName} scan ~/.config/opencode/skills/ and register tools independently.
Running both simultaneously causes "Duplicate tool names detected" warnings and HTTP 400 errors. Running both simultaneously causes "Duplicate tool names detected" warnings and HTTP 400 errors.
Consider either: Consider either:
1. Remove ${pluginName} from your opencode.json plugins to use oh-my-opencode's skill loading 1. Remove ${pluginName} from your opencode.json plugins to use ${PLUGIN_NAME}'s skill loading
2. Or disable oh-my-opencode's skill loading by setting "claude_code.skills": false in oh-my-opencode.json 2. Or disable ${PLUGIN_NAME}'s skill loading by setting "claude_code.skills": false in ${CONFIG_BASENAME}.json
3. Or uninstall oh-my-opencode if you prefer ${pluginName}'s skill management` 3. Or uninstall ${PLUGIN_NAME} if you prefer ${pluginName}'s skill management`
} }
+3 -1
View File
@@ -2,7 +2,9 @@ import * as fs from "fs"
import * as os from "os" import * as os from "os"
import * as path from "path" import * as path from "path"
const logFile = path.join(os.tmpdir(), "oh-my-opencode.log") import { LOG_FILENAME } from "./plugin-identity"
const logFile = path.join(os.tmpdir(), LOG_FILENAME)
let buffer: string[] = [] let buffer: string[] = []
let flushTimer: ReturnType<typeof setTimeout> | null = null let flushTimer: ReturnType<typeof setTimeout> | null = null
+7 -6
View File
@@ -11,6 +11,7 @@ import {
getCachedBinaryPath as getCachedBinaryPathShared, getCachedBinaryPath as getCachedBinaryPathShared,
} from "../../shared/binary-downloader" } from "../../shared/binary-downloader"
import { log } from "../../shared/logger" import { log } from "../../shared/logger"
import { CACHE_DIR_NAME, PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
const REPO = "ast-grep/ast-grep" const REPO = "ast-grep/ast-grep"
@@ -47,12 +48,12 @@ export function getCacheDir(): string {
if (process.platform === "win32") { if (process.platform === "win32") {
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA
const base = localAppData || join(homedir(), "AppData", "Local") const base = localAppData || join(homedir(), "AppData", "Local")
return join(base, "oh-my-opencode", "bin") return join(base, CACHE_DIR_NAME, "bin")
} }
const xdgCache = process.env.XDG_CACHE_HOME const xdgCache = process.env.XDG_CACHE_HOME
const base = xdgCache || join(homedir(), ".cache") const base = xdgCache || join(homedir(), ".cache")
return join(base, "oh-my-opencode", "bin") return join(base, CACHE_DIR_NAME, "bin")
} }
export function getBinaryName(): string { export function getBinaryName(): string {
@@ -70,7 +71,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
const platformInfo = PLATFORM_MAP[platformKey] const platformInfo = PLATFORM_MAP[platformKey]
if (!platformInfo) { if (!platformInfo) {
log(`[oh-my-opencode] Unsupported platform for ast-grep: ${platformKey}`) log(`[${PUBLISHED_PACKAGE_NAME}] Unsupported platform for ast-grep: ${platformKey}`)
return null return null
} }
@@ -86,7 +87,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
const assetName = `app-${arch}-${os}.zip` const assetName = `app-${arch}-${os}.zip`
const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${assetName}` const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${assetName}`
log(`[oh-my-opencode] Downloading ast-grep binary...`) log(`[${PUBLISHED_PACKAGE_NAME}] Downloading ast-grep binary...`)
try { try {
const archivePath = join(cacheDir, assetName) const archivePath = join(cacheDir, assetName)
@@ -96,12 +97,12 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
cleanupArchive(archivePath) cleanupArchive(archivePath)
ensureExecutable(binaryPath) ensureExecutable(binaryPath)
log(`[oh-my-opencode] ast-grep binary ready.`) log(`[${PUBLISHED_PACKAGE_NAME}] ast-grep binary ready.`)
return binaryPath return binaryPath
} catch (err) { } catch (err) {
log( log(
`[oh-my-opencode] Failed to download ast-grep: ${err instanceof Error ? err.message : err}` `[${PUBLISHED_PACKAGE_NAME}] Failed to download ast-grep: ${err instanceof Error ? err.message : err}`
) )
return null return null
} }
+2 -1
View File
@@ -10,6 +10,7 @@ import { getAgentConfigKey } from "../../shared/agent-display-names"
import { normalizeFallbackModels } from "../../shared/model-resolver" import { normalizeFallbackModels } from "../../shared/model-resolver"
import { buildFallbackChainFromModels } from "../../shared/fallback-chain-from-models" import { buildFallbackChainFromModels } from "../../shared/fallback-chain-from-models"
import { log } from "../../shared" import { log } from "../../shared"
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
import { parseModelString } from "../delegate-task/model-string-parser" import { parseModelString } from "../delegate-task/model-string-parser"
import { executeBackground } from "./background-executor" import { executeBackground } from "./background-executor"
import { executeSync } from "./sync-executor" import { executeSync } from "./sync-executor"
@@ -117,7 +118,7 @@ export function createCallOmoAgent(
// Check if agent is disabled // Check if agent is disabled
if (disabledAgents.some((disabled) => disabled.toLowerCase() === normalizedAgent)) { if (disabledAgents.some((disabled) => disabled.toLowerCase() === normalizedAgent)) {
return `Error: Agent "${normalizedAgent}" is disabled via disabled_agents configuration. Remove it from disabled_agents in your oh-my-opencode.json to use it.` return `Error: Agent "${normalizedAgent}" is disabled via disabled_agents configuration. Remove it from disabled_agents in your ${CONFIG_BASENAME}.json to use it.`
} }
const { model: resolvedModel, fallbackChain } = resolveModelAndFallbackChain({ const { model: resolvedModel, fallbackChain } = resolveModelAndFallbackChain({
+3 -2
View File
@@ -9,6 +9,7 @@ import { parseModelString } from "./model-string-parser"
import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements" import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements"
import { normalizeFallbackModels, flattenToFallbackModelStrings } from "../../shared/model-resolver" import { normalizeFallbackModels, flattenToFallbackModelStrings } from "../../shared/model-resolver"
import { buildFallbackChainFromModels, findMostSpecificFallbackEntry } from "../../shared/fallback-chain-from-models" import { buildFallbackChainFromModels, findMostSpecificFallbackEntry } from "../../shared/fallback-chain-from-models"
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
import { getAvailableModelsForDelegateTask } from "./available-models" import { getAvailableModelsForDelegateTask } from "./available-models"
import { resolveModelForDelegateTask } from "./model-selection" import { resolveModelForDelegateTask } from "./model-selection"
@@ -89,7 +90,7 @@ export async function resolveCategoryExecution(
To use this category: To use this category:
1. Connect a provider with this model: ${requirement.requiresModel} 1. Connect a provider with this model: ${requirement.requiresModel}
2. Or configure an alternative model in your oh-my-opencode.json for this category 2. Or configure an alternative model in your ${CONFIG_BASENAME}.json for this category
Available categories: ${allCategoryNames}`, Available categories: ${allCategoryNames}`,
} }
@@ -225,7 +226,7 @@ Available categories: ${allCategoryNames}`,
Configure in one of: Configure in one of:
1. OpenCode: Set "model" in opencode.json 1. OpenCode: Set "model" in opencode.json
2. Oh-My-OpenCode: Set category model in oh-my-opencode.json 2. Oh-My-OpenCode: Set category model in ${CONFIG_BASENAME}.json
3. Provider: Connect a provider with available models 3. Provider: Connect a provider with available models
Current category: ${args.category} Current category: ${args.category}
+3 -2
View File
@@ -4,6 +4,7 @@ import { spawnSync } from "node:child_process"
import { getInstalledRipgrepPath, downloadAndInstallRipgrep } from "./downloader" import { getInstalledRipgrepPath, downloadAndInstallRipgrep } from "./downloader"
import { getDataDir } from "../../shared/data-path" import { getDataDir } from "../../shared/data-path"
import { log } from "../../shared/logger" import { log } from "../../shared/logger"
import { PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
export type GrepBackend = "rg" | "grep" export type GrepBackend = "rg" | "grep"
@@ -106,12 +107,12 @@ export async function resolveGrepCliWithAutoInstall(): Promise<ResolvedCli> {
return cachedCli return cachedCli
} catch (error) { } catch (error) {
if (current.backend === "grep") { if (current.backend === "grep") {
log("[oh-my-opencode] Failed to auto-install ripgrep. Falling back to GNU grep.", { log(`[${PUBLISHED_PACKAGE_NAME}] Failed to auto-install ripgrep. Falling back to GNU grep.`, {
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
grep_path: current.path, grep_path: current.path,
}) })
} else { } else {
log("[oh-my-opencode] Failed to auto-install ripgrep and GNU grep was not found.", { log(`[${PUBLISHED_PACKAGE_NAME}] Failed to auto-install ripgrep and GNU grep was not found.`, {
error: error instanceof Error ? error.message : String(error), error: error instanceof Error ? error.message : String(error),
}) })
} }
+2 -1
View File
@@ -1,6 +1,7 @@
import { existsSync, readdirSync } from "node:fs" import { existsSync, readdirSync } from "node:fs"
import { join } from "node:path" import { join } from "node:path"
import { extractZip as extractZipBase } from "../../shared" import { extractZip as extractZipBase } from "../../shared"
import { CACHE_DIR_NAME } from "../../shared/plugin-identity"
import { import {
cleanupArchive, cleanupArchive,
downloadArchive, downloadArchive,
@@ -39,7 +40,7 @@ function getPlatformKey(): string {
function getInstallDir(): string { function getInstallDir(): string {
const homeDir = process.env.HOME || process.env.USERPROFILE || "." const homeDir = process.env.HOME || process.env.USERPROFILE || "."
return join(homeDir, ".cache", "oh-my-opencode", "bin") return join(homeDir, ".cache", CACHE_DIR_NAME, "bin")
} }
function getRgPath(): string { function getRgPath(): string {
+2 -1
View File
@@ -5,6 +5,7 @@ import { existsSync, statSync } from "fs"
import { LSPClient, lspManager } from "./client" import { LSPClient, lspManager } from "./client"
import { findServerForExtension } from "./config" import { findServerForExtension } from "./config"
import type { ServerLookupResult } from "./types" import type { ServerLookupResult } from "./types"
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
export function isDirectoryPath(filePath: string): boolean { export function isDirectoryPath(filePath: string): boolean {
if (!existsSync(filePath)) { if (!existsSync(filePath)) {
@@ -63,7 +64,7 @@ export function formatServerLookupError(result: Exclude<ServerLookupResult, { st
``, ``,
`Available servers: ${result.availableServers.slice(0, 10).join(", ")}${result.availableServers.length > 10 ? "..." : ""}`, `Available servers: ${result.availableServers.slice(0, 10).join(", ")}${result.availableServers.length > 10 ? "..." : ""}`,
``, ``,
`To add a custom server, configure 'lsp' in oh-my-opencode.json:`, `To add a custom server, configure 'lsp' in ${CONFIG_BASENAME}.json:`,
` {`, ` {`,
` "lsp": {`, ` "lsp": {`,
` "my-server": {`, ` "my-server": {`,