oh-my-opencode 0.1.20 → 0.1.22
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.
- package/dist/index.js +18 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15258,9 +15258,7 @@ var lsp_code_action_resolve = tool({
|
|
|
15258
15258
|
}
|
|
15259
15259
|
});
|
|
15260
15260
|
// src/tools/ast-grep/constants.ts
|
|
15261
|
-
import {
|
|
15262
|
-
import { dirname as dirname2, join as join5 } from "path";
|
|
15263
|
-
import { existsSync as existsSync7 } from "fs";
|
|
15261
|
+
import { existsSync as existsSync7, statSync } from "fs";
|
|
15264
15262
|
|
|
15265
15263
|
// src/tools/ast-grep/downloader.ts
|
|
15266
15264
|
var {spawn: spawn4 } = globalThis.Bun;
|
|
@@ -15372,54 +15370,16 @@ async function ensureAstGrepBinary() {
|
|
|
15372
15370
|
}
|
|
15373
15371
|
|
|
15374
15372
|
// src/tools/ast-grep/constants.ts
|
|
15375
|
-
function
|
|
15376
|
-
const platform = process.platform;
|
|
15377
|
-
const arch = process.arch;
|
|
15378
|
-
const platformMap = {
|
|
15379
|
-
"darwin-arm64": "@ast-grep/cli-darwin-arm64",
|
|
15380
|
-
"darwin-x64": "@ast-grep/cli-darwin-x64",
|
|
15381
|
-
"linux-arm64": "@ast-grep/cli-linux-arm64-gnu",
|
|
15382
|
-
"linux-x64": "@ast-grep/cli-linux-x64-gnu",
|
|
15383
|
-
"win32-x64": "@ast-grep/cli-win32-x64-msvc",
|
|
15384
|
-
"win32-arm64": "@ast-grep/cli-win32-arm64-msvc",
|
|
15385
|
-
"win32-ia32": "@ast-grep/cli-win32-ia32-msvc"
|
|
15386
|
-
};
|
|
15387
|
-
return platformMap[`${platform}-${arch}`] ?? null;
|
|
15388
|
-
}
|
|
15389
|
-
function findSgCliPathSync() {
|
|
15390
|
-
const binaryName = process.platform === "win32" ? "sg.exe" : "sg";
|
|
15373
|
+
function isValidBinary(filePath) {
|
|
15391
15374
|
try {
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
const sgPath = join5(cliDir, binaryName);
|
|
15396
|
-
if (existsSync7(sgPath)) {
|
|
15397
|
-
return sgPath;
|
|
15398
|
-
}
|
|
15399
|
-
} catch {}
|
|
15400
|
-
const platformPkg = getPlatformPackageName2();
|
|
15401
|
-
if (platformPkg) {
|
|
15402
|
-
try {
|
|
15403
|
-
const require2 = createRequire4(import.meta.url);
|
|
15404
|
-
const pkgPath = require2.resolve(`${platformPkg}/package.json`);
|
|
15405
|
-
const pkgDir = dirname2(pkgPath);
|
|
15406
|
-
const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
|
|
15407
|
-
const binaryPath = join5(pkgDir, astGrepName);
|
|
15408
|
-
if (existsSync7(binaryPath)) {
|
|
15409
|
-
return binaryPath;
|
|
15410
|
-
}
|
|
15411
|
-
} catch {}
|
|
15412
|
-
}
|
|
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
|
-
}
|
|
15375
|
+
return statSync(filePath).size > 1e4;
|
|
15376
|
+
} catch {
|
|
15377
|
+
return false;
|
|
15420
15378
|
}
|
|
15379
|
+
}
|
|
15380
|
+
function findSgCliPathSync() {
|
|
15421
15381
|
const cachedPath = getCachedBinaryPath2();
|
|
15422
|
-
if (cachedPath) {
|
|
15382
|
+
if (cachedPath && isValidBinary(cachedPath)) {
|
|
15423
15383
|
return cachedPath;
|
|
15424
15384
|
}
|
|
15425
15385
|
return null;
|
|
@@ -15763,10 +15723,12 @@ function getEmptyResultHint(pattern, lang) {
|
|
|
15763
15723
|
const src = pattern.trim();
|
|
15764
15724
|
if (lang === "python") {
|
|
15765
15725
|
if (src.startsWith("class ") && src.endsWith(":")) {
|
|
15766
|
-
|
|
15726
|
+
const withoutColon = src.slice(0, -1);
|
|
15727
|
+
return `\uD83D\uDCA1 Hint: Remove trailing colon. Try: "${withoutColon}"`;
|
|
15767
15728
|
}
|
|
15768
15729
|
if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
|
|
15769
|
-
|
|
15730
|
+
const withoutColon = src.slice(0, -1);
|
|
15731
|
+
return `\uD83D\uDCA1 Hint: Remove trailing colon. Try: "${withoutColon}"`;
|
|
15770
15732
|
}
|
|
15771
15733
|
}
|
|
15772
15734
|
if (["javascript", "typescript", "tsx"].includes(lang)) {
|
|
@@ -15913,7 +15875,7 @@ var {spawn: spawn6 } = globalThis.Bun;
|
|
|
15913
15875
|
|
|
15914
15876
|
// src/tools/safe-grep/constants.ts
|
|
15915
15877
|
import { existsSync as existsSync9 } from "fs";
|
|
15916
|
-
import { join as
|
|
15878
|
+
import { join as join5, dirname as dirname2 } from "path";
|
|
15917
15879
|
import { spawnSync } from "child_process";
|
|
15918
15880
|
var cachedCli = null;
|
|
15919
15881
|
function findExecutable(name) {
|
|
@@ -15930,14 +15892,14 @@ function findExecutable(name) {
|
|
|
15930
15892
|
}
|
|
15931
15893
|
function getOpenCodeBundledRg() {
|
|
15932
15894
|
const execPath = process.execPath;
|
|
15933
|
-
const execDir =
|
|
15895
|
+
const execDir = dirname2(execPath);
|
|
15934
15896
|
const isWindows = process.platform === "win32";
|
|
15935
15897
|
const rgName = isWindows ? "rg.exe" : "rg";
|
|
15936
15898
|
const candidates = [
|
|
15937
|
-
|
|
15938
|
-
|
|
15939
|
-
|
|
15940
|
-
|
|
15899
|
+
join5(execDir, rgName),
|
|
15900
|
+
join5(execDir, "bin", rgName),
|
|
15901
|
+
join5(execDir, "..", "bin", rgName),
|
|
15902
|
+
join5(execDir, "..", "libexec", rgName)
|
|
15941
15903
|
];
|
|
15942
15904
|
for (const candidate of candidates) {
|
|
15943
15905
|
if (existsSync9(candidate)) {
|