@mcmcjs/julia 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shravan Goswami
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @mcmcjs/julia
2
+
3
+ The bridge to the Julia ecosystem for [MCMC.js](https://github.com/mcmcjs/mcmcjs):
4
+ detecting the installed Julia toolchain (juliaup and Julia), and (later)
5
+ bootstrapping it and running inference via Turing.jl / JuliaBUGS.
6
+
7
+ > Early alpha: the API is not yet stable.
8
+
9
+ ## License
10
+
11
+ [MIT](./LICENSE) (c) [Shravan Goswami](https://shravangoswami.com)
package/dist/index.cjs ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ detectJulia: () => detectJulia,
24
+ detectJuliaup: () => detectJuliaup,
25
+ runDoctor: () => runDoctor
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/environment.ts
30
+ var import_node_child_process = require("child_process");
31
+ var import_node_os = require("os");
32
+ var import_node_path = require("path");
33
+ var import_node_util = require("util");
34
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
35
+ var defaultRunner = async (command, args) => {
36
+ const { stdout } = await execFileAsync(command, args, { timeout: 1e4 });
37
+ return stdout;
38
+ };
39
+ function candidates(binary) {
40
+ return [(0, import_node_path.join)((0, import_node_os.homedir)(), ".juliaup", "bin", binary), binary];
41
+ }
42
+ async function detect(binary, parseVersion, runner) {
43
+ for (const path of candidates(binary)) {
44
+ try {
45
+ const version = parseVersion(await runner(path, ["--version"]));
46
+ if (version) return { found: true, version, path };
47
+ } catch {
48
+ }
49
+ }
50
+ return { found: false };
51
+ }
52
+ var versionNumber = (stdout) => stdout.match(/(\d+\.\d+\.\d+)/)?.[1];
53
+ function detectJulia(runner = defaultRunner) {
54
+ return detect("julia", versionNumber, runner);
55
+ }
56
+ function detectJuliaup(runner = defaultRunner) {
57
+ return detect("juliaup", versionNumber, runner);
58
+ }
59
+
60
+ // src/doctor.ts
61
+ async function runDoctor(runner) {
62
+ const [juliaup, julia] = await Promise.all([detectJuliaup(runner), detectJulia(runner)]);
63
+ return { juliaup, julia, ready: julia.found };
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ detectJulia,
68
+ detectJuliaup,
69
+ runDoctor
70
+ });
71
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/environment.ts","../src/doctor.ts"],"sourcesContent":["export type { DoctorReport } from \"./doctor\";\nexport { runDoctor } from \"./doctor\";\nexport type { CommandRunner, ToolInfo } from \"./environment\";\nexport { detectJulia, detectJuliaup } from \"./environment\";\n","import { execFile } from \"node:child_process\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\n/** Information about a detected command-line tool. */\nexport interface ToolInfo {\n found: boolean;\n version?: string;\n path?: string;\n}\n\n/** Runs a command and resolves its stdout. Injectable so detection is testable. */\nexport type CommandRunner = (command: string, args: string[]) => Promise<string>;\n\nconst defaultRunner: CommandRunner = async (command, args) => {\n const { stdout } = await execFileAsync(command, args, { timeout: 10_000 });\n return stdout;\n};\n\n// juliaup installs its shims here; we also fall back to whatever is on PATH.\nfunction candidates(binary: string): string[] {\n return [join(homedir(), \".juliaup\", \"bin\", binary), binary];\n}\n\nasync function detect(\n binary: string,\n parseVersion: (stdout: string) => string | undefined,\n runner: CommandRunner,\n): Promise<ToolInfo> {\n for (const path of candidates(binary)) {\n try {\n const version = parseVersion(await runner(path, [\"--version\"]));\n if (version) return { found: true, version, path };\n } catch {\n // not available at this path; try the next candidate\n }\n }\n return { found: false };\n}\n\nconst versionNumber = (stdout: string): string | undefined => stdout.match(/(\\d+\\.\\d+\\.\\d+)/)?.[1];\n\n/** Detects the Julia runtime via `julia --version`. */\nexport function detectJulia(runner: CommandRunner = defaultRunner): Promise<ToolInfo> {\n return detect(\"julia\", versionNumber, runner);\n}\n\n/** Detects the juliaup version manager via `juliaup --version`. */\nexport function detectJuliaup(runner: CommandRunner = defaultRunner): Promise<ToolInfo> {\n return detect(\"juliaup\", versionNumber, runner);\n}\n","import { type CommandRunner, detectJulia, detectJuliaup, type ToolInfo } from \"./environment\";\n\n/** A summary of the Julia toolchain available for inference. */\nexport interface DoctorReport {\n juliaup: ToolInfo;\n julia: ToolInfo;\n /** True when Julia itself is available (the minimum needed to run inference). */\n ready: boolean;\n}\n\n/** Detects the installed Julia toolchain and reports whether inference can run. */\nexport async function runDoctor(runner?: CommandRunner): Promise<DoctorReport> {\n const [juliaup, julia] = await Promise.all([detectJuliaup(runner), detectJulia(runner)]);\n return { juliaup, julia, ready: julia.found };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,gCAAyB;AACzB,qBAAwB;AACxB,uBAAqB;AACrB,uBAA0B;AAE1B,IAAM,oBAAgB,4BAAU,kCAAQ;AAYxC,IAAM,gBAA+B,OAAO,SAAS,SAAS;AAC5D,QAAM,EAAE,OAAO,IAAI,MAAM,cAAc,SAAS,MAAM,EAAE,SAAS,IAAO,CAAC;AACzE,SAAO;AACT;AAGA,SAAS,WAAW,QAA0B;AAC5C,SAAO,KAAC,2BAAK,wBAAQ,GAAG,YAAY,OAAO,MAAM,GAAG,MAAM;AAC5D;AAEA,eAAe,OACb,QACA,cACA,QACmB;AACnB,aAAW,QAAQ,WAAW,MAAM,GAAG;AACrC,QAAI;AACF,YAAM,UAAU,aAAa,MAAM,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9D,UAAI,QAAS,QAAO,EAAE,OAAO,MAAM,SAAS,KAAK;AAAA,IACnD,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO,EAAE,OAAO,MAAM;AACxB;AAEA,IAAM,gBAAgB,CAAC,WAAuC,OAAO,MAAM,iBAAiB,IAAI,CAAC;AAG1F,SAAS,YAAY,SAAwB,eAAkC;AACpF,SAAO,OAAO,SAAS,eAAe,MAAM;AAC9C;AAGO,SAAS,cAAc,SAAwB,eAAkC;AACtF,SAAO,OAAO,WAAW,eAAe,MAAM;AAChD;;;AC1CA,eAAsB,UAAU,QAA+C;AAC7E,QAAM,CAAC,SAAS,KAAK,IAAI,MAAM,QAAQ,IAAI,CAAC,cAAc,MAAM,GAAG,YAAY,MAAM,CAAC,CAAC;AACvF,SAAO,EAAE,SAAS,OAAO,OAAO,MAAM,MAAM;AAC9C;","names":[]}
@@ -0,0 +1,24 @@
1
+ /** Information about a detected command-line tool. */
2
+ interface ToolInfo {
3
+ found: boolean;
4
+ version?: string;
5
+ path?: string;
6
+ }
7
+ /** Runs a command and resolves its stdout. Injectable so detection is testable. */
8
+ type CommandRunner = (command: string, args: string[]) => Promise<string>;
9
+ /** Detects the Julia runtime via `julia --version`. */
10
+ declare function detectJulia(runner?: CommandRunner): Promise<ToolInfo>;
11
+ /** Detects the juliaup version manager via `juliaup --version`. */
12
+ declare function detectJuliaup(runner?: CommandRunner): Promise<ToolInfo>;
13
+
14
+ /** A summary of the Julia toolchain available for inference. */
15
+ interface DoctorReport {
16
+ juliaup: ToolInfo;
17
+ julia: ToolInfo;
18
+ /** True when Julia itself is available (the minimum needed to run inference). */
19
+ ready: boolean;
20
+ }
21
+ /** Detects the installed Julia toolchain and reports whether inference can run. */
22
+ declare function runDoctor(runner?: CommandRunner): Promise<DoctorReport>;
23
+
24
+ export { type CommandRunner, type DoctorReport, type ToolInfo, detectJulia, detectJuliaup, runDoctor };
@@ -0,0 +1,24 @@
1
+ /** Information about a detected command-line tool. */
2
+ interface ToolInfo {
3
+ found: boolean;
4
+ version?: string;
5
+ path?: string;
6
+ }
7
+ /** Runs a command and resolves its stdout. Injectable so detection is testable. */
8
+ type CommandRunner = (command: string, args: string[]) => Promise<string>;
9
+ /** Detects the Julia runtime via `julia --version`. */
10
+ declare function detectJulia(runner?: CommandRunner): Promise<ToolInfo>;
11
+ /** Detects the juliaup version manager via `juliaup --version`. */
12
+ declare function detectJuliaup(runner?: CommandRunner): Promise<ToolInfo>;
13
+
14
+ /** A summary of the Julia toolchain available for inference. */
15
+ interface DoctorReport {
16
+ juliaup: ToolInfo;
17
+ julia: ToolInfo;
18
+ /** True when Julia itself is available (the minimum needed to run inference). */
19
+ ready: boolean;
20
+ }
21
+ /** Detects the installed Julia toolchain and reports whether inference can run. */
22
+ declare function runDoctor(runner?: CommandRunner): Promise<DoctorReport>;
23
+
24
+ export { type CommandRunner, type DoctorReport, type ToolInfo, detectJulia, detectJuliaup, runDoctor };
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ // src/environment.ts
2
+ import { execFile } from "child_process";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
5
+ import { promisify } from "util";
6
+ var execFileAsync = promisify(execFile);
7
+ var defaultRunner = async (command, args) => {
8
+ const { stdout } = await execFileAsync(command, args, { timeout: 1e4 });
9
+ return stdout;
10
+ };
11
+ function candidates(binary) {
12
+ return [join(homedir(), ".juliaup", "bin", binary), binary];
13
+ }
14
+ async function detect(binary, parseVersion, runner) {
15
+ for (const path of candidates(binary)) {
16
+ try {
17
+ const version = parseVersion(await runner(path, ["--version"]));
18
+ if (version) return { found: true, version, path };
19
+ } catch {
20
+ }
21
+ }
22
+ return { found: false };
23
+ }
24
+ var versionNumber = (stdout) => stdout.match(/(\d+\.\d+\.\d+)/)?.[1];
25
+ function detectJulia(runner = defaultRunner) {
26
+ return detect("julia", versionNumber, runner);
27
+ }
28
+ function detectJuliaup(runner = defaultRunner) {
29
+ return detect("juliaup", versionNumber, runner);
30
+ }
31
+
32
+ // src/doctor.ts
33
+ async function runDoctor(runner) {
34
+ const [juliaup, julia] = await Promise.all([detectJuliaup(runner), detectJulia(runner)]);
35
+ return { juliaup, julia, ready: julia.found };
36
+ }
37
+ export {
38
+ detectJulia,
39
+ detectJuliaup,
40
+ runDoctor
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/environment.ts","../src/doctor.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\n/** Information about a detected command-line tool. */\nexport interface ToolInfo {\n found: boolean;\n version?: string;\n path?: string;\n}\n\n/** Runs a command and resolves its stdout. Injectable so detection is testable. */\nexport type CommandRunner = (command: string, args: string[]) => Promise<string>;\n\nconst defaultRunner: CommandRunner = async (command, args) => {\n const { stdout } = await execFileAsync(command, args, { timeout: 10_000 });\n return stdout;\n};\n\n// juliaup installs its shims here; we also fall back to whatever is on PATH.\nfunction candidates(binary: string): string[] {\n return [join(homedir(), \".juliaup\", \"bin\", binary), binary];\n}\n\nasync function detect(\n binary: string,\n parseVersion: (stdout: string) => string | undefined,\n runner: CommandRunner,\n): Promise<ToolInfo> {\n for (const path of candidates(binary)) {\n try {\n const version = parseVersion(await runner(path, [\"--version\"]));\n if (version) return { found: true, version, path };\n } catch {\n // not available at this path; try the next candidate\n }\n }\n return { found: false };\n}\n\nconst versionNumber = (stdout: string): string | undefined => stdout.match(/(\\d+\\.\\d+\\.\\d+)/)?.[1];\n\n/** Detects the Julia runtime via `julia --version`. */\nexport function detectJulia(runner: CommandRunner = defaultRunner): Promise<ToolInfo> {\n return detect(\"julia\", versionNumber, runner);\n}\n\n/** Detects the juliaup version manager via `juliaup --version`. */\nexport function detectJuliaup(runner: CommandRunner = defaultRunner): Promise<ToolInfo> {\n return detect(\"juliaup\", versionNumber, runner);\n}\n","import { type CommandRunner, detectJulia, detectJuliaup, type ToolInfo } from \"./environment\";\n\n/** A summary of the Julia toolchain available for inference. */\nexport interface DoctorReport {\n juliaup: ToolInfo;\n julia: ToolInfo;\n /** True when Julia itself is available (the minimum needed to run inference). */\n ready: boolean;\n}\n\n/** Detects the installed Julia toolchain and reports whether inference can run. */\nexport async function runDoctor(runner?: CommandRunner): Promise<DoctorReport> {\n const [juliaup, julia] = await Promise.all([detectJuliaup(runner), detectJulia(runner)]);\n return { juliaup, julia, ready: julia.found };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAU,QAAQ;AAYxC,IAAM,gBAA+B,OAAO,SAAS,SAAS;AAC5D,QAAM,EAAE,OAAO,IAAI,MAAM,cAAc,SAAS,MAAM,EAAE,SAAS,IAAO,CAAC;AACzE,SAAO;AACT;AAGA,SAAS,WAAW,QAA0B;AAC5C,SAAO,CAAC,KAAK,QAAQ,GAAG,YAAY,OAAO,MAAM,GAAG,MAAM;AAC5D;AAEA,eAAe,OACb,QACA,cACA,QACmB;AACnB,aAAW,QAAQ,WAAW,MAAM,GAAG;AACrC,QAAI;AACF,YAAM,UAAU,aAAa,MAAM,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;AAC9D,UAAI,QAAS,QAAO,EAAE,OAAO,MAAM,SAAS,KAAK;AAAA,IACnD,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO,EAAE,OAAO,MAAM;AACxB;AAEA,IAAM,gBAAgB,CAAC,WAAuC,OAAO,MAAM,iBAAiB,IAAI,CAAC;AAG1F,SAAS,YAAY,SAAwB,eAAkC;AACpF,SAAO,OAAO,SAAS,eAAe,MAAM;AAC9C;AAGO,SAAS,cAAc,SAAwB,eAAkC;AACtF,SAAO,OAAO,WAAW,eAAe,MAAM;AAChD;;;AC1CA,eAAsB,UAAU,QAA+C;AAC7E,QAAM,CAAC,SAAS,KAAK,IAAI,MAAM,QAAQ,IAAI,CAAC,cAAc,MAAM,GAAG,YAAY,MAAM,CAAC,CAAC;AACvF,SAAO,EAAE,SAAS,OAAO,OAAO,MAAM,MAAM;AAC9C;","names":[]}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@mcmcjs/julia",
3
+ "version": "0.1.0",
4
+ "description": "Julia toolchain detection and the inference runner for MCMC.js.",
5
+ "keywords": [
6
+ "mcmc",
7
+ "julia",
8
+ "juliaup",
9
+ "turing",
10
+ "inference",
11
+ "runner"
12
+ ],
13
+ "license": "MIT",
14
+ "author": {
15
+ "name": "Shravan Goswami",
16
+ "email": "contact@shravangoswami.com",
17
+ "url": "https://shravangoswami.com"
18
+ },
19
+ "homepage": "https://github.com/mcmcjs/mcmcjs/tree/main/packages/julia#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/mcmcjs/mcmcjs.git",
23
+ "directory": "packages/julia"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/mcmcjs/mcmcjs/issues"
27
+ },
28
+ "type": "module",
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js",
36
+ "require": "./dist/index.cjs"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "engines": {
43
+ "node": ">=22"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit"
51
+ }
52
+ }