()
| 60 | } |
| 61 | |
| 62 | function main() { |
| 63 | const packageRoot = findPackageRoot(__dirname) |
| 64 | const pkg = readPackageJson(packageRoot) |
| 65 | const version = pkg?.version || '' |
| 66 | |
| 67 | const args = ['--acp', ...process.argv.slice(2)] |
| 68 | |
| 69 | // Native binary (npm optionalDependencies, no GitHub postinstall). |
| 70 | const nativeBin = tryResolveNativeBinaryFromOptionalDeps() |
| 71 | if (nativeBin) { |
| 72 | run(nativeBin, args) |
| 73 | } |
| 74 | |
| 75 | // Node.js runtime fallback. |
| 76 | const distEntry = path.join(packageRoot, 'dist', 'index.js') |
| 77 | if (fs.existsSync(distEntry)) { |
| 78 | run(process.execPath, [distEntry, ...args]) |
| 79 | } |
| 80 | |
| 81 | process.stderr.write( |
| 82 | [ |
| 83 | '❌ kode-acp is not runnable on this system.', |
| 84 | '', |
| 85 | 'Tried:', |
| 86 | '- Native binary (optionalDependencies)', |
| 87 | '- Node.js runtime fallback', |
| 88 | '', |
| 89 | 'Fix:', |
| 90 | '- Reinstall with optionalDependencies enabled (avoid --no-optional/--omit=optional)', |
| 91 | '- Or install a platform binary package: @shareai-lab/kode-bin-<platform>-<arch>', |
| 92 | '- Or run from source: bun run apps/cli/src/dispatch.ts --acp', |
| 93 | '', |
| 94 | version ? `Package version: ${version}` : '', |
| 95 | ] |
| 96 | .filter(Boolean) |
| 97 | .join('\n'), |
| 98 | ) |
| 99 | process.exit(1) |
| 100 | } |
| 101 | |
| 102 | if (require.main === module) { |
| 103 | main() |
no test coverage detected