oh-my-opencode 1.2.4 → 2.0.1

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.
@@ -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
@@ -6989,6 +6989,7 @@ function createBackgroundNotificationHook(manager) {
6989
6989
  // src/hooks/auto-update-checker/checker.ts
6990
6990
  import * as fs4 from "fs";
6991
6991
  import * as path4 from "path";
6992
+ import { fileURLToPath } from "url";
6992
6993
 
6993
6994
  // src/hooks/auto-update-checker/constants.ts
6994
6995
  import * as path3 from "path";
@@ -7016,24 +7017,67 @@ var USER_OPENCODE_CONFIG = path3.join(USER_CONFIG_DIR, "opencode", "opencode.jso
7016
7017
 
7017
7018
  // src/hooks/auto-update-checker/checker.ts
7018
7019
  function isLocalDevMode(directory) {
7020
+ return getLocalDevPath(directory) !== null;
7021
+ }
7022
+ function stripJsonComments(json) {
7023
+ return json.replace(/^\s*\/\/.*$/gm, "").replace(/,(\s*[}\]])/g, "$1");
7024
+ }
7025
+ function getLocalDevPath(directory) {
7019
7026
  const projectConfig = path4.join(directory, ".opencode", "opencode.json");
7020
7027
  for (const configPath of [projectConfig, USER_OPENCODE_CONFIG]) {
7021
7028
  try {
7022
7029
  if (!fs4.existsSync(configPath))
7023
7030
  continue;
7024
7031
  const content = fs4.readFileSync(configPath, "utf-8");
7025
- const config = JSON.parse(content);
7032
+ const config = JSON.parse(stripJsonComments(content));
7026
7033
  const plugins = config.plugin ?? [];
7027
7034
  for (const entry of plugins) {
7028
7035
  if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
7029
- return true;
7036
+ return entry.replace("file://", "");
7030
7037
  }
7031
7038
  }
7032
7039
  } catch {
7033
7040
  continue;
7034
7041
  }
7035
7042
  }
7036
- return false;
7043
+ return null;
7044
+ }
7045
+ function findPackageJsonUp(startPath) {
7046
+ try {
7047
+ const stat = fs4.statSync(startPath);
7048
+ let dir = stat.isDirectory() ? startPath : path4.dirname(startPath);
7049
+ for (let i = 0;i < 10; i++) {
7050
+ const pkgPath = path4.join(dir, "package.json");
7051
+ if (fs4.existsSync(pkgPath)) {
7052
+ try {
7053
+ const content = fs4.readFileSync(pkgPath, "utf-8");
7054
+ const pkg = JSON.parse(content);
7055
+ if (pkg.name === PACKAGE_NAME)
7056
+ return pkgPath;
7057
+ } catch {}
7058
+ }
7059
+ const parent = path4.dirname(dir);
7060
+ if (parent === dir)
7061
+ break;
7062
+ dir = parent;
7063
+ }
7064
+ } catch {}
7065
+ return null;
7066
+ }
7067
+ function getLocalDevVersion(directory) {
7068
+ const localPath = getLocalDevPath(directory);
7069
+ if (!localPath)
7070
+ return null;
7071
+ try {
7072
+ const pkgPath = findPackageJsonUp(localPath);
7073
+ if (!pkgPath)
7074
+ return null;
7075
+ const content = fs4.readFileSync(pkgPath, "utf-8");
7076
+ const pkg = JSON.parse(content);
7077
+ return pkg.version ?? null;
7078
+ } catch {
7079
+ return null;
7080
+ }
7037
7081
  }
7038
7082
  function findPluginEntry(directory) {
7039
7083
  const projectConfig = path4.join(directory, ".opencode", "opencode.json");
@@ -7042,7 +7086,7 @@ function findPluginEntry(directory) {
7042
7086
  if (!fs4.existsSync(configPath))
7043
7087
  continue;
7044
7088
  const content = fs4.readFileSync(configPath, "utf-8");
7045
- const config = JSON.parse(content);
7089
+ const config = JSON.parse(stripJsonComments(content));
7046
7090
  const plugins = config.plugin ?? [];
7047
7091
  for (const entry of plugins) {
7048
7092
  if (entry === PACKAGE_NAME) {
@@ -7062,14 +7106,26 @@ function findPluginEntry(directory) {
7062
7106
  }
7063
7107
  function getCachedVersion() {
7064
7108
  try {
7065
- if (!fs4.existsSync(INSTALLED_PACKAGE_JSON))
7066
- return null;
7067
- const content = fs4.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
7068
- const pkg = JSON.parse(content);
7069
- return pkg.version ?? null;
7070
- } catch {
7071
- return null;
7109
+ if (fs4.existsSync(INSTALLED_PACKAGE_JSON)) {
7110
+ const content = fs4.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
7111
+ const pkg = JSON.parse(content);
7112
+ if (pkg.version)
7113
+ return pkg.version;
7114
+ }
7115
+ } catch {}
7116
+ try {
7117
+ const currentDir = path4.dirname(fileURLToPath(import.meta.url));
7118
+ const pkgPath = findPackageJsonUp(currentDir);
7119
+ if (pkgPath) {
7120
+ const content = fs4.readFileSync(pkgPath, "utf-8");
7121
+ const pkg = JSON.parse(content);
7122
+ if (pkg.version)
7123
+ return pkg.version;
7124
+ }
7125
+ } catch (err) {
7126
+ log("[auto-update-checker] Failed to resolve version from current directory:", err);
7072
7127
  }
7128
+ return null;
7073
7129
  }
7074
7130
  async function getLatestVersion() {
7075
7131
  const controller = new AbortController;
@@ -7172,7 +7228,8 @@ function createAutoUpdateCheckerHook(ctx, options = {}) {
7172
7228
  if (result.isLocalDev) {
7173
7229
  log("[auto-update-checker] Skipped: local development mode");
7174
7230
  if (showStartupToast) {
7175
- await showVersionToast(ctx, getCachedVersion());
7231
+ const version = getLocalDevVersion(ctx.directory) ?? getCachedVersion();
7232
+ await showVersionToast(ctx, version);
7176
7233
  }
7177
7234
  return;
7178
7235
  }
@@ -23236,8 +23293,8 @@ var lsp_code_action_resolve = tool({
23236
23293
  });
23237
23294
  // src/tools/ast-grep/constants.ts
23238
23295
  import { createRequire as createRequire4 } from "module";
23239
- import { dirname as dirname5, join as join33 } from "path";
23240
- import { existsSync as existsSync27, statSync as statSync3 } from "fs";
23296
+ import { dirname as dirname6, join as join33 } from "path";
23297
+ import { existsSync as existsSync27, statSync as statSync4 } from "fs";
23241
23298
 
23242
23299
  // src/tools/ast-grep/downloader.ts
23243
23300
  var {spawn: spawn5 } = globalThis.Bun;
@@ -23351,7 +23408,7 @@ async function ensureAstGrepBinary() {
23351
23408
  // src/tools/ast-grep/constants.ts
23352
23409
  function isValidBinary(filePath) {
23353
23410
  try {
23354
- return statSync3(filePath).size > 1e4;
23411
+ return statSync4(filePath).size > 1e4;
23355
23412
  } catch {
23356
23413
  return false;
23357
23414
  }
@@ -23379,7 +23436,7 @@ function findSgCliPathSync() {
23379
23436
  try {
23380
23437
  const require2 = createRequire4(import.meta.url);
23381
23438
  const cliPkgPath = require2.resolve("@ast-grep/cli/package.json");
23382
- const cliDir = dirname5(cliPkgPath);
23439
+ const cliDir = dirname6(cliPkgPath);
23383
23440
  const sgPath = join33(cliDir, binaryName);
23384
23441
  if (existsSync27(sgPath) && isValidBinary(sgPath)) {
23385
23442
  return sgPath;
@@ -23390,7 +23447,7 @@ function findSgCliPathSync() {
23390
23447
  try {
23391
23448
  const require2 = createRequire4(import.meta.url);
23392
23449
  const pkgPath = require2.resolve(`${platformPkg}/package.json`);
23393
- const pkgDir = dirname5(pkgPath);
23450
+ const pkgDir = dirname6(pkgPath);
23394
23451
  const astGrepName = process.platform === "win32" ? "ast-grep.exe" : "ast-grep";
23395
23452
  const binaryPath = join33(pkgDir, astGrepName);
23396
23453
  if (existsSync27(binaryPath) && isValidBinary(binaryPath)) {
@@ -23768,7 +23825,7 @@ var {spawn: spawn7 } = globalThis.Bun;
23768
23825
 
23769
23826
  // src/tools/grep/constants.ts
23770
23827
  import { existsSync as existsSync30 } from "fs";
23771
- import { join as join35, dirname as dirname6 } from "path";
23828
+ import { join as join35, dirname as dirname7 } from "path";
23772
23829
  import { spawnSync } from "child_process";
23773
23830
 
23774
23831
  // src/tools/grep/downloader.ts
@@ -23803,7 +23860,7 @@ function findExecutable(name) {
23803
23860
  }
23804
23861
  function getOpenCodeBundledRg() {
23805
23862
  const execPath = process.execPath;
23806
- const execDir = dirname6(execPath);
23863
+ const execDir = dirname7(execPath);
23807
23864
  const isWindows = process.platform === "win32";
23808
23865
  const rgName = isWindows ? "rg.exe" : "rg";
23809
23866
  const candidates = [
@@ -24218,7 +24275,7 @@ var glob = tool({
24218
24275
  // src/tools/slashcommand/tools.ts
24219
24276
  import { existsSync as existsSync31, readdirSync as readdirSync8, readFileSync as readFileSync19 } from "fs";
24220
24277
  import { homedir as homedir15 } from "os";
24221
- import { join as join36, basename as basename3, dirname as dirname7 } from "path";
24278
+ import { join as join36, basename as basename3, dirname as dirname8 } from "path";
24222
24279
  function discoverCommandsFromDir(commandsDir, scope) {
24223
24280
  if (!existsSync31(commandsDir)) {
24224
24281
  return [];
@@ -24302,7 +24359,7 @@ async function formatLoadedCommand(cmd) {
24302
24359
  `);
24303
24360
  sections.push(`## Command Instructions
24304
24361
  `);
24305
- const commandDir = dirname7(cmd.path);
24362
+ const commandDir = dirname8(cmd.path);
24306
24363
  const withFileRefs = await resolveFileReferencesInText(cmd.content, commandDir);
24307
24364
  const resolvedContent = await resolveCommandsInText(withFileRefs);
24308
24365
  sections.push(resolvedContent.trim());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode",
3
- "version": "1.2.4",
3
+ "version": "2.0.1",
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",