@diologue/local-agent 0.1.5 → 0.2.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/cli.mjs CHANGED
@@ -81,9 +81,11 @@ var init_engine_release = __esm({
81
81
 
82
82
  // src/lib/engine-bundle.ts
83
83
  import { access as access2, constants } from "node:fs/promises";
84
+ import { readFileSync } from "node:fs";
85
+ import { createRequire } from "node:module";
84
86
  import path3 from "node:path";
85
87
  import { fileURLToPath } from "node:url";
86
- var engineRelease, __filename, __dirname, LOCAL_AGENT_ROOT, REPO_ROOT, BUNDLE_DIR_INSTALLED, BUNDLE_DIR_LOCAL_BUILD, ENGINE_BUNDLE_ENV, exists2, bundleFilename, findEngineBundle;
88
+ var engineRelease, __filename, __dirname, LOCAL_AGENT_ROOT, REPO_ROOT, BUNDLE_DIR_INSTALLED, BUNDLE_DIR_LOCAL_BUILD, ENGINE_BUNDLE_ENV, exists2, resolveOpencodeAiBinary, bundleFilename, findEngineBundle;
87
89
  var init_engine_bundle = __esm({
88
90
  "src/lib/engine-bundle.ts"() {
89
91
  "use strict";
@@ -111,6 +113,19 @@ var init_engine_bundle = __esm({
111
113
  return false;
112
114
  }
113
115
  };
116
+ resolveOpencodeAiBinary = () => {
117
+ try {
118
+ const require2 = createRequire(import.meta.url);
119
+ const pkgJsonPath = require2.resolve("opencode-ai/package.json");
120
+ const pkgDir = path3.dirname(pkgJsonPath);
121
+ const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
122
+ const binRel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.opencode;
123
+ if (!binRel) return null;
124
+ return path3.join(pkgDir, binRel);
125
+ } catch {
126
+ return null;
127
+ }
128
+ };
114
129
  bundleFilename = (platform = process.platform, arch = process.arch) => {
115
130
  const target = engineRelease.targets.find(
116
131
  (t) => t.platform === platform && t.arch === arch
@@ -125,6 +140,10 @@ var init_engine_bundle = __esm({
125
140
  return { path: fromEnv, source: "env" };
126
141
  }
127
142
  }
143
+ const opencodeAi = resolveOpencodeAiBinary();
144
+ if (opencodeAi && await exists2(opencodeAi)) {
145
+ return { path: opencodeAi, source: "opencode-ai" };
146
+ }
128
147
  const filename = bundleFilename();
129
148
  const installed = path3.join(BUNDLE_DIR_INSTALLED, filename);
130
149
  if (await exists2(installed)) {