Lines 1-39javascript
2// SPDX-License-Identifier: MIT
3// Copyright (C) 2026 Shogo Technologies, Inc.
5// `shogo` CLI entry shim. Picks an execution mode in this order:
7// 1. Compiled per-platform binary at $PREFIX/dist/shogo (in the
8// tarball release — Bun bundled, no runtime deps).
9// 2. Bundled JS at ../dist/cli.mjs (npm install
10// with no Bun on PATH — Node ESM-loadable).
11// 3. Source TS at ../src/cli.ts (monorepo
12// / `bun link`ed dev, requires Bun or tsx).
13import { fileURLToPath } from 'node:url';
14import { existsSync } from 'node:fs';
15import { dirname, join } from 'node:path';
16import { spawn } from 'node:child_process';
17
HighChild Process
Package source references child process execution.
bin/shogo.mjsView on unpkg · L15 18const __dirname = dirname(fileURLToPath(import.meta.url));
19const args = process.argv.slice(2);
21const compiledBin = join(__dirname, '..', 'dist', process.platform === 'win32' ? 'shogo.exe' : 'shogo');
22const distEntry = join(__dirname, '..', 'dist', 'cli.mjs');
23const srcEntry = join(__dirname, '..', 'src', 'cli.ts');
25if (existsSync(compiledBin)) {
26 const child = spawn(compiledBin, args, { stdio: 'inherit' });
27 child.on('exit', (code) => process.exit(code ?? 0));
28} else if (existsSync(distEntry)) {
29 await import(distEntry);
30} else if (existsSync(srcEntry)) {
MediumDynamic Require
Package source references dynamic require/import behavior.
bin/shogo.mjsView on unpkg · L28 31 const runner = process.versions.bun ? 'bun' : 'tsx';
32 const child = spawn(runner, [srcEntry, ...args], { stdio: 'inherit' });
33 child.on('exit', (code) => process.exit(code ?? 0));
35 console.error('shogo: no executable entry found (looked for dist/shogo, dist/cli.mjs, src/cli.ts)');
36 console.error(' Reinstall with `npm i -g @shogo-ai/worker` or rebuild via `bun run build`.');