Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1jehuang Jcode Platform Binary Resolution

From Leeroopedia
Knowledge Sources
Domains SDK, Package_Management
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tool for resolving the platform-specific jcode binary from optional NPM dependencies, provided by the TypeScript SDK.

Description

The binary module maps the current platform and architecture to an optional NPM package name (e.g. @1jehuang/jcode-linux-x64) and resolves the bundled executable path. platformBinaryPackage() returns the package name for the current platform-arch pair, returning undefined on unsupported platforms. bundledJcodeBinary() uses require.resolve to locate the package's package.json and derives the binary path, returning undefined when the optional dependency was deliberately omitted so that launch() can fall back to a PATH lookup.

Usage

  • SDK launch: Call bundledJcodeBinary() before spawning the server to find the bundled binary.
  • PATH fallback: When bundledJcodeBinary() returns undefined, fall back to jcode on PATH.
  • Platform detection: Call platformBinaryPackage() to check if the current platform has a dedicated package.

Code Reference

Source Location

Signature

export function platformBinaryPackage(
  platform = process.platform,
  arch = process.arch,
): string | undefined

export function bundledJcodeBinary(): string | undefined

Import

import { platformBinaryPackage, bundledJcodeBinary } from "@1jehuang/jcode/binary";

I/O Contract

Inputs

Name Type Required Description
platform string No (defaults to process.platform) OS platform identifier
arch string No (defaults to process.arch) CPU architecture identifier

Outputs

Name Type Description
platformBinaryPackage undefined NPM package name for the platform, or undefined if unsupported
bundledJcodeBinary undefined Absolute path to the bundled binary, or undefined if not installed

Usage Examples

Resolve Binary with PATH Fallback

import { bundledJcodeBinary } from "@1jehuang/jcode/binary";

const binary = bundledJcodeBinary() ?? "jcode";
// If bundled binary exists, use it; otherwise fall back to PATH
const child = spawn(binary, ["run", "--socket", socketPath, prompt]);

Check Platform Support

import { platformBinaryPackage } from "@1jehuang/jcode/binary";

const pkg = platformBinaryPackage();
if (!pkg) {
  console.error(`No bundled binary for ${process.platform}-${process.arch}`);
  console.error("Install jcode globally or ensure it is on PATH.");
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment