Compare commits

..

1 Commits

Author SHA1 Message Date
github-actions[bot]
feb87cf716 release: v0.1.20 2025-12-05 12:58:56 +00:00
3 changed files with 12 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "oh-my-opencode",
"version": "0.1.23",
"version": "0.1.20",
"description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@@ -1,18 +1,10 @@
import { createRequire } from "module"
import { dirname, join } from "path"
import { existsSync, statSync } from "fs"
import { existsSync } from "fs"
import { getCachedBinaryPath } from "./downloader"
type Platform = "darwin" | "linux" | "win32" | "unsupported"
function isValidBinary(filePath: string): boolean {
try {
return statSync(filePath).size > 10000
} catch {
return false
}
}
function getPlatformPackageName(): string | null {
const platform = process.platform as Platform
const arch = process.arch
@@ -33,18 +25,13 @@ function getPlatformPackageName(): string | null {
export function findSgCliPathSync(): string | null {
const binaryName = process.platform === "win32" ? "sg.exe" : "sg"
const cachedPath = getCachedBinaryPath()
if (cachedPath && isValidBinary(cachedPath)) {
return cachedPath
}
try {
const require = createRequire(import.meta.url)
const cliPkgPath = require.resolve("@ast-grep/cli/package.json")
const cliDir = dirname(cliPkgPath)
const sgPath = join(cliDir, binaryName)
if (existsSync(sgPath) && isValidBinary(sgPath)) {
if (existsSync(sgPath)) {
return sgPath
}
} catch {
@@ -60,7 +47,7 @@ export function findSgCliPathSync(): string | null {
const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep"
const binaryPath = join(pkgDir, astGrepName)
if (existsSync(binaryPath) && isValidBinary(binaryPath)) {
if (existsSync(binaryPath)) {
return binaryPath
}
} catch {
@@ -71,12 +58,17 @@ export function findSgCliPathSync(): string | null {
if (process.platform === "darwin") {
const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"]
for (const path of homebrewPaths) {
if (existsSync(path) && isValidBinary(path)) {
if (existsSync(path)) {
return path
}
}
}
const cachedPath = getCachedBinaryPath()
if (cachedPath) {
return cachedPath
}
return null
}

View File

@@ -15,12 +15,10 @@ function getEmptyResultHint(pattern: string, lang: CliLanguage): string | null {
if (lang === "python") {
if (src.startsWith("class ") && src.endsWith(":")) {
const withoutColon = src.slice(0, -1)
return `💡 Hint: Remove trailing colon. Try: "${withoutColon}"`
return `💡 Hint: Python class patterns need body. Try "class $NAME" or include body with $$$BODY`
}
if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
const withoutColon = src.slice(0, -1)
return `💡 Hint: Remove trailing colon. Try: "${withoutColon}"`
return `💡 Hint: Python function patterns need body. Try "def $FUNC($$$):\\n $$$BODY"`
}
}