MCPcopy Create free account
hub / github.com/cortexkit/magic-context / runOpenCode

Function runOpenCode

packages/cli/src/lib/opencode-helpers.ts:9–20  ·  view source on GitHub ↗

* Run `opencode `. If a `binary` path is given (an absolute path resolved * for a stock `~/.opencode/bin` install or a version-manager shim that is not on * PATH), call that exact path via execFile; otherwise fall back to a bare * `opencode` on PATH.

(args: string[], binary?: string | null)

Source from the content-addressed store, hash-verified

7 * `opencode` on PATH.
8 */
9function runOpenCode(args: string[], binary?: string | null): string | null {
10 try {
11 if (binary) {
12 return execFileSync(binary, args, { stdio: "pipe" }).toString().trim();
13 }
14 return execSync(`opencode ${args.join(" ")}`, { stdio: "pipe" })
15 .toString()
16 .trim();
17 } catch {
18 return null;
19 }
20}
21
22export function getOpenCodeVersion(binary?: string | null): string | null {
23 return runOpenCode(["--version"], binary);

Callers 2

getOpenCodeVersionFunction · 0.85
getAvailableModelsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected