opencode-worker 0.1.1 → 0.1.3

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 (3) hide show
  1. package/README.md +13 -1
  2. package/lib/worker.mjs +11 -5
  3. package/package.json +16 -4
package/README.md CHANGED
@@ -5,7 +5,8 @@ Run the official OpenCode CLI as an isolated, time-boxed worker. One package, tw
5
5
  - `opencode-worker run` — CLI, prints one JSON result
6
6
  - `opencode-worker mcp` — MCP stdio server (async jobs)
7
7
 
8
- No dependencies. Node ≥ 20. OpenCode is **not** bundled: pass `--opencode-bin`, set `OPENCODE_WORKER_BIN`, or have `opencode` on `PATH`.
8
+ No dependencies. Node ≥ 20. OpenCode is **not** bundled: pass `--opencode-bin`, set `OPENCODE_WORKER_BIN`, or have `opencode` on `PATH` (checked in that order).
9
+ A set-but-empty `--opencode-bin`/`OPENCODE_WORKER_BIN` fails with `BIN_EMPTY` instead of falling back to `PATH`; this usually means a shell variable was not expanded in your MCP config.
9
10
 
10
11
  ## Safety defaults
11
12
 
@@ -90,3 +91,14 @@ Closing stdin or SIGINT/SIGTERM/SIGHUP cancels running jobs and records them as
90
91
 
91
92
  - `<dir>/.opencode-worker/` holds state, snapshots and logs per run; delete it when done.
92
93
  - The before-snapshot copies the whole directory: use small, task-scoped directories.
94
+
95
+ ## Releasing
96
+
97
+ Publishing runs in GitHub Actions via npm Trusted Publishing (OIDC): no npm token or OTP.
98
+
99
+ ```sh
100
+ npm version patch # bumps package.json, commits, tags vX.Y.Z
101
+ git push --follow-tags # the tag triggers .github/workflows/publish.yml
102
+ ```
103
+
104
+ The workflow fails if the tag does not match `package.json` `version`.
package/lib/worker.mjs CHANGED
@@ -22,14 +22,20 @@ export class WorkerError extends Error {
22
22
  }
23
23
 
24
24
  export function resolveOpencodeBin(explicit) {
25
- const candidates = [explicit, process.env.OPENCODE_WORKER_BIN].filter(Boolean);
26
- for (const c of candidates) {
27
- if (fs.existsSync(c)) return path.resolve(c);
28
- throw new WorkerError("BIN_NOT_FOUND", `opencode binary not found: ${c}`);
25
+ const sources = [
26
+ ["--opencode-bin", explicit],
27
+ ["OPENCODE_WORKER_BIN", process.env.OPENCODE_WORKER_BIN],
28
+ ];
29
+ for (const [name, value] of sources) {
30
+ if (value === undefined || value === null) continue;
31
+ // A set-but-empty value is almost always an unexpanded shell variable; never fall back to PATH silently.
32
+ if (value.trim() === "") throw new WorkerError("BIN_EMPTY", `${name} is set but empty; give the absolute path to the opencode binary`);
33
+ if (!fs.existsSync(value)) throw new WorkerError("BIN_NOT_FOUND", `opencode binary not found at ${name}=${value}`);
34
+ return path.resolve(value);
29
35
  }
30
36
  const which = spawnSync("/usr/bin/env", ["which", "opencode"], { encoding: "utf8" });
31
37
  if (which.status === 0 && which.stdout.trim()) return which.stdout.trim();
32
- throw new WorkerError("BIN_NOT_FOUND", "opencode not found (use --opencode-bin or OPENCODE_WORKER_BIN)");
38
+ throw new WorkerError("BIN_NOT_FOUND", "opencode not found on PATH (set OPENCODE_WORKER_BIN or --opencode-bin)");
33
39
  }
34
40
 
35
41
  function opencodeVersion(bin) {
package/package.json CHANGED
@@ -1,10 +1,22 @@
1
1
  {
2
2
  "name": "opencode-worker",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Run the official OpenCode CLI as an isolated, time-boxed worker. CLI + MCP stdio server.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/goofy1goober4/opencode-worker.git"
8
+ },
5
9
  "type": "module",
6
- "bin": { "opencode-worker": "bin/opencode-worker.mjs" },
7
- "files": ["bin", "lib", "README.md"],
8
- "engines": { "node": ">=20" },
10
+ "bin": {
11
+ "opencode-worker": "bin/opencode-worker.mjs"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "lib",
16
+ "README.md"
17
+ ],
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
9
21
  "license": "MIT"
10
22
  }