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:
@@ -11,6 +11,7 @@ import {
|
||||
getCachedBinaryPath as getCachedBinaryPathShared,
|
||||
} from "../../shared/binary-downloader"
|
||||
import { log } from "../../shared/logger"
|
||||
import { CACHE_DIR_NAME, PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
|
||||
|
||||
const REPO = "ast-grep/ast-grep"
|
||||
|
||||
@@ -47,12 +48,12 @@ export function getCacheDir(): string {
|
||||
if (process.platform === "win32") {
|
||||
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA
|
||||
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 base = xdgCache || join(homedir(), ".cache")
|
||||
return join(base, "oh-my-opencode", "bin")
|
||||
return join(base, CACHE_DIR_NAME, "bin")
|
||||
}
|
||||
|
||||
export function getBinaryName(): string {
|
||||
@@ -70,7 +71,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
|
||||
const platformInfo = PLATFORM_MAP[platformKey]
|
||||
|
||||
if (!platformInfo) {
|
||||
log(`[oh-my-opencode] Unsupported platform for ast-grep: ${platformKey}`)
|
||||
log(`[${PUBLISHED_PACKAGE_NAME}] Unsupported platform for ast-grep: ${platformKey}`)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
|
||||
const assetName = `app-${arch}-${os}.zip`
|
||||
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 {
|
||||
const archivePath = join(cacheDir, assetName)
|
||||
@@ -96,12 +97,12 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
|
||||
cleanupArchive(archivePath)
|
||||
ensureExecutable(binaryPath)
|
||||
|
||||
log(`[oh-my-opencode] ast-grep binary ready.`)
|
||||
log(`[${PUBLISHED_PACKAGE_NAME}] ast-grep binary ready.`)
|
||||
|
||||
return binaryPath
|
||||
} catch (err) {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { getAgentConfigKey } from "../../shared/agent-display-names"
|
||||
import { normalizeFallbackModels } from "../../shared/model-resolver"
|
||||
import { buildFallbackChainFromModels } from "../../shared/fallback-chain-from-models"
|
||||
import { log } from "../../shared"
|
||||
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
|
||||
import { parseModelString } from "../delegate-task/model-string-parser"
|
||||
import { executeBackground } from "./background-executor"
|
||||
import { executeSync } from "./sync-executor"
|
||||
@@ -117,7 +118,7 @@ export function createCallOmoAgent(
|
||||
|
||||
// Check if agent is disabled
|
||||
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({
|
||||
|
||||
@@ -9,6 +9,7 @@ import { parseModelString } from "./model-string-parser"
|
||||
import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements"
|
||||
import { normalizeFallbackModels, flattenToFallbackModelStrings } from "../../shared/model-resolver"
|
||||
import { buildFallbackChainFromModels, findMostSpecificFallbackEntry } from "../../shared/fallback-chain-from-models"
|
||||
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
|
||||
import { getAvailableModelsForDelegateTask } from "./available-models"
|
||||
import { resolveModelForDelegateTask } from "./model-selection"
|
||||
|
||||
@@ -89,7 +90,7 @@ export async function resolveCategoryExecution(
|
||||
|
||||
To use this category:
|
||||
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}`,
|
||||
}
|
||||
@@ -225,7 +226,7 @@ Available categories: ${allCategoryNames}`,
|
||||
|
||||
Configure in one of:
|
||||
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
|
||||
|
||||
Current category: ${args.category}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { spawnSync } from "node:child_process"
|
||||
import { getInstalledRipgrepPath, downloadAndInstallRipgrep } from "./downloader"
|
||||
import { getDataDir } from "../../shared/data-path"
|
||||
import { log } from "../../shared/logger"
|
||||
import { PUBLISHED_PACKAGE_NAME } from "../../shared/plugin-identity"
|
||||
|
||||
export type GrepBackend = "rg" | "grep"
|
||||
|
||||
@@ -106,12 +107,12 @@ export async function resolveGrepCliWithAutoInstall(): Promise<ResolvedCli> {
|
||||
return cachedCli
|
||||
} catch (error) {
|
||||
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),
|
||||
grep_path: current.path,
|
||||
})
|
||||
} 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),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { existsSync, readdirSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
import { extractZip as extractZipBase } from "../../shared"
|
||||
import { CACHE_DIR_NAME } from "../../shared/plugin-identity"
|
||||
import {
|
||||
cleanupArchive,
|
||||
downloadArchive,
|
||||
@@ -39,7 +40,7 @@ function getPlatformKey(): string {
|
||||
|
||||
function getInstallDir(): string {
|
||||
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 {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { existsSync, statSync } from "fs"
|
||||
import { LSPClient, lspManager } from "./client"
|
||||
import { findServerForExtension } from "./config"
|
||||
import type { ServerLookupResult } from "./types"
|
||||
import { CONFIG_BASENAME } from "../../shared/plugin-identity"
|
||||
|
||||
export function isDirectoryPath(filePath: string): boolean {
|
||||
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 ? "..." : ""}`,
|
||||
``,
|
||||
`To add a custom server, configure 'lsp' in oh-my-opencode.json:`,
|
||||
`To add a custom server, configure 'lsp' in ${CONFIG_BASENAME}.json:`,
|
||||
` {`,
|
||||
` "lsp": {`,
|
||||
` "my-server": {`,
|
||||
|
||||
Reference in New Issue
Block a user