oh-my-opencode 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +26 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15386,14 +15386,34 @@ function getPlatformPackageName2() {
15386
15386
  };
15387
15387
  return platformMap[`${platform}-${arch}`] ?? null;
15388
15388
  }
15389
+ function isValidBinary(filePath) {
15390
+ try {
15391
+ const stats = __require("fs").statSync(filePath);
15392
+ return stats.size > 1e4;
15393
+ } catch {
15394
+ return false;
15395
+ }
15396
+ }
15389
15397
  function findSgCliPathSync() {
15390
15398
  const binaryName = process.platform === "win32" ? "sg.exe" : "sg";
15399
+ if (process.platform === "darwin") {
15400
+ const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
15401
+ for (const path of homebrewPaths) {
15402
+ if (existsSync7(path) && isValidBinary(path)) {
15403
+ return path;
15404
+ }
15405
+ }
15406
+ }
15407
+ const cachedPath = getCachedBinaryPath2();
15408
+ if (cachedPath && isValidBinary(cachedPath)) {
15409
+ return cachedPath;
15410
+ }
15391
15411
  try {
15392
15412
  const require2 = createRequire4(import.meta.url);
15393
15413
  const cliPkgPath = require2.resolve("@ast-grep/cli/package.json");
15394
15414
  const cliDir = dirname2(cliPkgPath);
15395
15415
  const sgPath = join5(cliDir, binaryName);
15396
- if (existsSync7(sgPath)) {
15416
+ if (existsSync7(sgPath) && isValidBinary(sgPath)) {
15397
15417
  return sgPath;
15398
15418
  }
15399
15419
  } catch {}
@@ -15405,23 +15425,11 @@ function findSgCliPathSync() {
15405
15425
  const pkgDir = dirname2(pkgPath);
15406
15426
  const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
15407
15427
  const binaryPath = join5(pkgDir, astGrepName);
15408
- if (existsSync7(binaryPath)) {
15428
+ if (existsSync7(binaryPath) && isValidBinary(binaryPath)) {
15409
15429
  return binaryPath;
15410
15430
  }
15411
15431
  } catch {}
15412
15432
  }
15413
- if (process.platform === "darwin") {
15414
- const homebrewPaths = ["/opt/homebrew/bin/sg", "/usr/local/bin/sg"];
15415
- for (const path of homebrewPaths) {
15416
- if (existsSync7(path)) {
15417
- return path;
15418
- }
15419
- }
15420
- }
15421
- const cachedPath = getCachedBinaryPath2();
15422
- if (cachedPath) {
15423
- return cachedPath;
15424
- }
15425
15433
  return null;
15426
15434
  }
15427
15435
  var resolvedCliPath2 = null;
@@ -15763,10 +15771,12 @@ function getEmptyResultHint(pattern, lang) {
15763
15771
  const src = pattern.trim();
15764
15772
  if (lang === "python") {
15765
15773
  if (src.startsWith("class ") && src.endsWith(":")) {
15766
- return `\uD83D\uDCA1 Hint: Python class patterns need body. Try "class $NAME" or include body with $$$BODY`;
15774
+ const withoutColon = src.slice(0, -1);
15775
+ return `\uD83D\uDCA1 Hint: Remove trailing colon. Try: "${withoutColon}"`;
15767
15776
  }
15768
15777
  if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
15769
- return `\uD83D\uDCA1 Hint: Python function patterns need body. Try "def $FUNC($$$):\\n $$$BODY"`;
15778
+ const withoutColon = src.slice(0, -1);
15779
+ return `\uD83D\uDCA1 Hint: Remove trailing colon. Try: "${withoutColon}"`;
15770
15780
  }
15771
15781
  }
15772
15782
  if (["javascript", "typescript", "tsx"].includes(lang)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",