oh-my-opencode 1.2.4 → 2.0.0
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/hooks/auto-update-checker/checker.d.ts +2 -0
- package/dist/index.js +60 -32
- package/package.json +1 -1
- package/dist/google-auth.js +0 -1599
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UpdateCheckResult } from "./types";
|
|
2
2
|
export declare function isLocalDevMode(directory: string): boolean;
|
|
3
|
+
export declare function getLocalDevPath(directory: string): string | null;
|
|
4
|
+
export declare function getLocalDevVersion(directory: string): string | null;
|
|
3
5
|
export interface PluginEntryInfo {
|
|
4
6
|
entry: string;
|
|
5
7
|
isPinned: boolean;
|
package/dist/index.js
CHANGED
|
@@ -7016,6 +7016,9 @@ var USER_OPENCODE_CONFIG = path3.join(USER_CONFIG_DIR, "opencode", "opencode.jso
|
|
|
7016
7016
|
|
|
7017
7017
|
// src/hooks/auto-update-checker/checker.ts
|
|
7018
7018
|
function isLocalDevMode(directory) {
|
|
7019
|
+
return getLocalDevPath(directory) !== null;
|
|
7020
|
+
}
|
|
7021
|
+
function getLocalDevPath(directory) {
|
|
7019
7022
|
const projectConfig = path4.join(directory, ".opencode", "opencode.json");
|
|
7020
7023
|
for (const configPath of [projectConfig, USER_OPENCODE_CONFIG]) {
|
|
7021
7024
|
try {
|
|
@@ -7026,14 +7029,29 @@ function isLocalDevMode(directory) {
|
|
|
7026
7029
|
const plugins = config.plugin ?? [];
|
|
7027
7030
|
for (const entry of plugins) {
|
|
7028
7031
|
if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
|
|
7029
|
-
return
|
|
7032
|
+
return entry.replace("file://", "");
|
|
7030
7033
|
}
|
|
7031
7034
|
}
|
|
7032
7035
|
} catch {
|
|
7033
7036
|
continue;
|
|
7034
7037
|
}
|
|
7035
7038
|
}
|
|
7036
|
-
return
|
|
7039
|
+
return null;
|
|
7040
|
+
}
|
|
7041
|
+
function getLocalDevVersion(directory) {
|
|
7042
|
+
const localPath = getLocalDevPath(directory);
|
|
7043
|
+
if (!localPath)
|
|
7044
|
+
return null;
|
|
7045
|
+
try {
|
|
7046
|
+
const pkgPath = path4.join(localPath, "package.json");
|
|
7047
|
+
if (!fs4.existsSync(pkgPath))
|
|
7048
|
+
return null;
|
|
7049
|
+
const content = fs4.readFileSync(pkgPath, "utf-8");
|
|
7050
|
+
const pkg = JSON.parse(content);
|
|
7051
|
+
return pkg.version ?? null;
|
|
7052
|
+
} catch {
|
|
7053
|
+
return null;
|
|
7054
|
+
}
|
|
7037
7055
|
}
|
|
7038
7056
|
function findPluginEntry(directory) {
|
|
7039
7057
|
const projectConfig = path4.join(directory, ".opencode", "opencode.json");
|
|
@@ -7062,14 +7080,23 @@ function findPluginEntry(directory) {
|
|
|
7062
7080
|
}
|
|
7063
7081
|
function getCachedVersion() {
|
|
7064
7082
|
try {
|
|
7065
|
-
if (
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7083
|
+
if (fs4.existsSync(INSTALLED_PACKAGE_JSON)) {
|
|
7084
|
+
const content = fs4.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
|
|
7085
|
+
const pkg = JSON.parse(content);
|
|
7086
|
+
if (pkg.version)
|
|
7087
|
+
return pkg.version;
|
|
7088
|
+
}
|
|
7089
|
+
} catch {}
|
|
7090
|
+
try {
|
|
7091
|
+
const pkgPath = path4.resolve(import.meta.dirname, "..", "..", "..", "package.json");
|
|
7092
|
+
if (fs4.existsSync(pkgPath)) {
|
|
7093
|
+
const content = fs4.readFileSync(pkgPath, "utf-8");
|
|
7094
|
+
const pkg = JSON.parse(content);
|
|
7095
|
+
if (pkg.version)
|
|
7096
|
+
return pkg.version;
|
|
7097
|
+
}
|
|
7098
|
+
} catch {}
|
|
7099
|
+
return null;
|
|
7073
7100
|
}
|
|
7074
7101
|
async function getLatestVersion() {
|
|
7075
7102
|
const controller = new AbortController;
|
|
@@ -7172,7 +7199,8 @@ function createAutoUpdateCheckerHook(ctx, options = {}) {
|
|
|
7172
7199
|
if (result.isLocalDev) {
|
|
7173
7200
|
log("[auto-update-checker] Skipped: local development mode");
|
|
7174
7201
|
if (showStartupToast) {
|
|
7175
|
-
|
|
7202
|
+
const version = getLocalDevVersion(ctx.directory) ?? getCachedVersion();
|
|
7203
|
+
await showVersionToast(ctx, version);
|
|
7176
7204
|
}
|
|
7177
7205
|
return;
|
|
7178
7206
|
}
|
|
@@ -7733,8 +7761,8 @@ function startCallbackServer(timeoutMs = 5 * 60 * 1000) {
|
|
|
7733
7761
|
});
|
|
7734
7762
|
const actualPort = server.port;
|
|
7735
7763
|
const waitForCallback = () => {
|
|
7736
|
-
return new Promise((
|
|
7737
|
-
resolveCallback =
|
|
7764
|
+
return new Promise((resolve6, reject) => {
|
|
7765
|
+
resolveCallback = resolve6;
|
|
7738
7766
|
rejectCallback = reject;
|
|
7739
7767
|
timeoutId = setTimeout(() => {
|
|
7740
7768
|
cleanup();
|
|
@@ -8684,7 +8712,7 @@ async function attemptFetch(options) {
|
|
|
8684
8712
|
if (attempt < maxPermissionRetries) {
|
|
8685
8713
|
const delay = calculateRetryDelay2(attempt);
|
|
8686
8714
|
debugLog6(`[RETRY] GCP permission error, retry ${attempt + 1}/${maxPermissionRetries} after ${delay}ms`);
|
|
8687
|
-
await new Promise((
|
|
8715
|
+
await new Promise((resolve6) => setTimeout(resolve6, delay));
|
|
8688
8716
|
continue;
|
|
8689
8717
|
}
|
|
8690
8718
|
debugLog6(`[RETRY] GCP permission error, max retries exceeded`);
|
|
@@ -9788,7 +9816,7 @@ function getAllServers() {
|
|
|
9788
9816
|
// src/tools/lsp/client.ts
|
|
9789
9817
|
var {spawn: spawn4 } = globalThis.Bun;
|
|
9790
9818
|
import { readFileSync as readFileSync17 } from "fs";
|
|
9791
|
-
import { extname, resolve as
|
|
9819
|
+
import { extname, resolve as resolve6 } from "path";
|
|
9792
9820
|
class LSPServerManager {
|
|
9793
9821
|
static instance;
|
|
9794
9822
|
clients = new Map;
|
|
@@ -9938,7 +9966,7 @@ class LSPClient {
|
|
|
9938
9966
|
}
|
|
9939
9967
|
this.startReading();
|
|
9940
9968
|
this.startStderrReading();
|
|
9941
|
-
await new Promise((
|
|
9969
|
+
await new Promise((resolve7) => setTimeout(resolve7, 100));
|
|
9942
9970
|
if (this.proc.exitCode !== null) {
|
|
9943
9971
|
const stderr = this.stderrBuffer.join(`
|
|
9944
9972
|
`);
|
|
@@ -10075,8 +10103,8 @@ stderr: ${stderr}` : ""));
|
|
|
10075
10103
|
\r
|
|
10076
10104
|
`;
|
|
10077
10105
|
this.proc.stdin.write(header + msg);
|
|
10078
|
-
return new Promise((
|
|
10079
|
-
this.pending.set(id, { resolve:
|
|
10106
|
+
return new Promise((resolve7, reject) => {
|
|
10107
|
+
this.pending.set(id, { resolve: resolve7, reject });
|
|
10080
10108
|
setTimeout(() => {
|
|
10081
10109
|
if (this.pending.has(id)) {
|
|
10082
10110
|
this.pending.delete(id);
|
|
@@ -10184,7 +10212,7 @@ ${msg}`);
|
|
|
10184
10212
|
await new Promise((r) => setTimeout(r, 300));
|
|
10185
10213
|
}
|
|
10186
10214
|
async openFile(filePath) {
|
|
10187
|
-
const absPath =
|
|
10215
|
+
const absPath = resolve6(filePath);
|
|
10188
10216
|
if (this.openedFiles.has(absPath))
|
|
10189
10217
|
return;
|
|
10190
10218
|
const text = readFileSync17(absPath, "utf-8");
|
|
@@ -10202,7 +10230,7 @@ ${msg}`);
|
|
|
10202
10230
|
await new Promise((r) => setTimeout(r, 1000));
|
|
10203
10231
|
}
|
|
10204
10232
|
async hover(filePath, line, character) {
|
|
10205
|
-
const absPath =
|
|
10233
|
+
const absPath = resolve6(filePath);
|
|
10206
10234
|
await this.openFile(absPath);
|
|
10207
10235
|
return this.send("textDocument/hover", {
|
|
10208
10236
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10210,7 +10238,7 @@ ${msg}`);
|
|
|
10210
10238
|
});
|
|
10211
10239
|
}
|
|
10212
10240
|
async definition(filePath, line, character) {
|
|
10213
|
-
const absPath =
|
|
10241
|
+
const absPath = resolve6(filePath);
|
|
10214
10242
|
await this.openFile(absPath);
|
|
10215
10243
|
return this.send("textDocument/definition", {
|
|
10216
10244
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10218,7 +10246,7 @@ ${msg}`);
|
|
|
10218
10246
|
});
|
|
10219
10247
|
}
|
|
10220
10248
|
async references(filePath, line, character, includeDeclaration = true) {
|
|
10221
|
-
const absPath =
|
|
10249
|
+
const absPath = resolve6(filePath);
|
|
10222
10250
|
await this.openFile(absPath);
|
|
10223
10251
|
return this.send("textDocument/references", {
|
|
10224
10252
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10227,7 +10255,7 @@ ${msg}`);
|
|
|
10227
10255
|
});
|
|
10228
10256
|
}
|
|
10229
10257
|
async documentSymbols(filePath) {
|
|
10230
|
-
const absPath =
|
|
10258
|
+
const absPath = resolve6(filePath);
|
|
10231
10259
|
await this.openFile(absPath);
|
|
10232
10260
|
return this.send("textDocument/documentSymbol", {
|
|
10233
10261
|
textDocument: { uri: `file://${absPath}` }
|
|
@@ -10237,7 +10265,7 @@ ${msg}`);
|
|
|
10237
10265
|
return this.send("workspace/symbol", { query });
|
|
10238
10266
|
}
|
|
10239
10267
|
async diagnostics(filePath) {
|
|
10240
|
-
const absPath =
|
|
10268
|
+
const absPath = resolve6(filePath);
|
|
10241
10269
|
const uri = `file://${absPath}`;
|
|
10242
10270
|
await this.openFile(absPath);
|
|
10243
10271
|
await new Promise((r) => setTimeout(r, 500));
|
|
@@ -10252,7 +10280,7 @@ ${msg}`);
|
|
|
10252
10280
|
return { items: this.diagnosticsStore.get(uri) ?? [] };
|
|
10253
10281
|
}
|
|
10254
10282
|
async prepareRename(filePath, line, character) {
|
|
10255
|
-
const absPath =
|
|
10283
|
+
const absPath = resolve6(filePath);
|
|
10256
10284
|
await this.openFile(absPath);
|
|
10257
10285
|
return this.send("textDocument/prepareRename", {
|
|
10258
10286
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10260,7 +10288,7 @@ ${msg}`);
|
|
|
10260
10288
|
});
|
|
10261
10289
|
}
|
|
10262
10290
|
async rename(filePath, line, character, newName) {
|
|
10263
|
-
const absPath =
|
|
10291
|
+
const absPath = resolve6(filePath);
|
|
10264
10292
|
await this.openFile(absPath);
|
|
10265
10293
|
return this.send("textDocument/rename", {
|
|
10266
10294
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10269,7 +10297,7 @@ ${msg}`);
|
|
|
10269
10297
|
});
|
|
10270
10298
|
}
|
|
10271
10299
|
async codeAction(filePath, startLine, startChar, endLine, endChar, only) {
|
|
10272
|
-
const absPath =
|
|
10300
|
+
const absPath = resolve6(filePath);
|
|
10273
10301
|
await this.openFile(absPath);
|
|
10274
10302
|
return this.send("textDocument/codeAction", {
|
|
10275
10303
|
textDocument: { uri: `file://${absPath}` },
|
|
@@ -10301,10 +10329,10 @@ ${msg}`);
|
|
|
10301
10329
|
}
|
|
10302
10330
|
}
|
|
10303
10331
|
// src/tools/lsp/utils.ts
|
|
10304
|
-
import { extname as extname2, resolve as
|
|
10332
|
+
import { extname as extname2, resolve as resolve7 } from "path";
|
|
10305
10333
|
import { existsSync as existsSync25, readFileSync as readFileSync18, writeFileSync as writeFileSync9 } from "fs";
|
|
10306
10334
|
function findWorkspaceRoot(filePath) {
|
|
10307
|
-
let dir =
|
|
10335
|
+
let dir = resolve7(filePath);
|
|
10308
10336
|
if (!existsSync25(dir) || !__require("fs").statSync(dir).isDirectory()) {
|
|
10309
10337
|
dir = __require("path").dirname(dir);
|
|
10310
10338
|
}
|
|
@@ -10317,10 +10345,10 @@ function findWorkspaceRoot(filePath) {
|
|
|
10317
10345
|
}
|
|
10318
10346
|
dir = __require("path").dirname(dir);
|
|
10319
10347
|
}
|
|
10320
|
-
return __require("path").dirname(
|
|
10348
|
+
return __require("path").dirname(resolve7(filePath));
|
|
10321
10349
|
}
|
|
10322
10350
|
async function withLspClient(filePath, fn) {
|
|
10323
|
-
const absPath =
|
|
10351
|
+
const absPath = resolve7(filePath);
|
|
10324
10352
|
const ext = extname2(absPath);
|
|
10325
10353
|
const server = findServerForExtension(ext);
|
|
10326
10354
|
if (!server) {
|
|
@@ -24717,7 +24745,7 @@ Use \`background_output\` tool with task_id="${task.id}" to check progress:
|
|
|
24717
24745
|
});
|
|
24718
24746
|
}
|
|
24719
24747
|
function delay(ms) {
|
|
24720
|
-
return new Promise((
|
|
24748
|
+
return new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
24721
24749
|
}
|
|
24722
24750
|
function truncateText(text, maxLength) {
|
|
24723
24751
|
if (text.length <= maxLength)
|