@zatsepin/jigor 0.1.1

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/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # jigor-cli — the `jigor` binary (CLI + HTTP gateway)
2
+
3
+ Ask System One decision models from the terminal or over HTTP. `von` and
4
+ `laya` run locally as ONNX; `jev` runs remote on OpenRouter Decisions — one
5
+ wire protocol across all of them: `noul`/`choice`/`score` questions in,
6
+ typed answers out.
7
+
8
+ ```bash
9
+ cargo install jigor-cli # or: npm install --global @zatsepin/jigor / pip install jigor
10
+ jigor serve --host 127.0.0.1 --port 8000 # HTTP gateway: POST /v1/systemone, GET /healthz
11
+ jigor ask [--model <id>] [--provider <p>] # the same wire over stdin, no HTTP layer
12
+ jigor models # provider x model pairs
13
+ ```
14
+
15
+ Model aliases: `von`, `laya`, `jev`, `jev-latest`. The local ONNX models
16
+ download to `~/.cache/huggingface` on first use; set `OPENROUTER_API_KEY`
17
+ for the remote `jev` backend.
18
+
19
+ ## Example
20
+
21
+ ```bash
22
+ jigor ask --model von <<'JSON'
23
+ {
24
+ "state": { "error": "Disk volume /var/log at 98% capacity." },
25
+ "questions": {
26
+ "requires_intervention": {
27
+ "type": "noul",
28
+ "instructions": "Does this disk space condition require operational intervention?"
29
+ }
30
+ }
31
+ }
32
+ JSON
33
+ # {"model":"von-1.0.0","backend":"local","answers":{"requires_intervention":{"type":"noul","noul":0.2739}}}
34
+ ```
35
+
36
+ ## The jigor Rust library
37
+
38
+ This binary is a thin shell over the
39
+ [`jigor`](https://crates.io/crates/jigor) crate — local ONNX backends in
40
+ `von`/`laya`, remote `jev` via OpenRouter Decisions, and one `answers()`
41
+ call for all three. Use the library directly when you want decisions inside
42
+ a Rust program: [crate docs](https://docs.rs/jigor) ·
43
+ [full project README](https://github.com/Partysun/jigor#readme).
package/jigor ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Fallback shim. On Unix, `postinstall` replaces this file with the native
4
+ // binary. On Windows, npm-generated global wrappers call this JS bin target
5
+ // through node, so it must stay in place and spawn the `.exe`.
6
+
7
+ const { spawn } = require("node:child_process");
8
+ const { resolveBinaryPath } = require("./postinstall");
9
+
10
+ if (process.platform !== "win32") {
11
+ console.error(
12
+ "[warn] postinstall script did not run; falling back to runtime binary resolution.",
13
+ );
14
+ console.error("Enable postinstall to avoid the per-invocation overhead.");
15
+ }
16
+
17
+ const binaryPath = resolveBinaryPath();
18
+ if (!binaryPath) {
19
+ console.error(
20
+ "[jigor] Failed to locate the native binary. " +
21
+ "Ensure optional dependencies are installed (do not pass --no-optional).",
22
+ );
23
+ process.exit(1);
24
+ }
25
+
26
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
27
+
28
+ child.on("error", (error) => {
29
+ console.error("[jigor] Failed to execute native binary:", error);
30
+ process.exit(1);
31
+ });
32
+
33
+ const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
34
+ const handlers = signals.map((signal) => {
35
+ const handler = () => {
36
+ if (!child.killed) {
37
+ try { child.kill(signal); } catch (_) {}
38
+ }
39
+ };
40
+ process.on(signal, handler);
41
+ return [signal, handler];
42
+ });
43
+
44
+ child.on("exit", (code, signal) => {
45
+ for (const [s, h] of handlers) process.removeListener(s, h);
46
+ if (signal) process.kill(process.pid, signal);
47
+ else process.exit(code == null ? 1 : code);
48
+ });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@zatsepin/jigor",
3
+ "version": "0.1.1",
4
+ "description": "System One decision gateway CLI + server — von/laya local ONNX backends, jev on OpenRouter Decisions. One wire protocol: noul/choice/score questions in, typed answers out.",
5
+ "homepage": "https://github.com/Partysun/jigor",
6
+ "repository": "https://github.com/Partysun/jigor",
7
+ "license": "Apache-2.0",
8
+ "keywords": [
9
+ "system-one",
10
+ "decisions",
11
+ "onnx",
12
+ "cli",
13
+ "gateway"
14
+ ],
15
+ "engines": {
16
+ "node": ">= 18.0.0"
17
+ },
18
+ "files": [
19
+ "jigor",
20
+ "postinstall.js"
21
+ ],
22
+ "dependencies": {
23
+ "detect-libc": "2.1.2"
24
+ },
25
+ "scripts": {
26
+ "postinstall": "node postinstall.js"
27
+ },
28
+ "optionalDependencies": {
29
+ "@zatsepin/jigor-darwin": "0.1.1",
30
+ "@zatsepin/jigor-linux-arm64-gnu": "0.1.1",
31
+ "@zatsepin/jigor-linux-x64-gnu": "0.1.1",
32
+ "@zatsepin/jigor-win32-x64-msvc": "0.1.1"
33
+ },
34
+ "bin": {
35
+ "jigor": "jigor"
36
+ },
37
+ "publishConfig": {
38
+ "registry": "https://registry.npmjs.org/",
39
+ "access": "public"
40
+ }
41
+ }
package/postinstall.js ADDED
@@ -0,0 +1,94 @@
1
+ // Port of ast-grep's @ast-grep/cli postinstall: locate the native `jigor`
2
+ // binary for the current platform (a platform package installed as an
3
+ // optional dependency, or a local `target/release|debug/jigor` dev build)
4
+ // and hard-link it over the JS shims.
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+
8
+ const binaryName = process.platform === "win32" ? "jigor.exe" : "jigor";
9
+
10
+ function detectPackageName() {
11
+ const { platform, arch } = process;
12
+ switch (platform) {
13
+ case "darwin":
14
+ // one universal2 fat binary covers Intel (x64) and Apple Silicon (arm64)
15
+ if (arch === "x64" || arch === "arm64") return "@zatsepin/jigor-darwin";
16
+ break;
17
+ case "linux": {
18
+ const { MUSL, familySync } = require("detect-libc");
19
+ if (familySync() === MUSL) return null;
20
+ if (arch === "arm64") return "@zatsepin/jigor-linux-arm64-gnu";
21
+ if (arch === "x64") return "@zatsepin/jigor-linux-x64-gnu";
22
+ break;
23
+ }
24
+ case "win32":
25
+ if (arch === "x64") return "@zatsepin/jigor-win32-x64-msvc";
26
+ break;
27
+ }
28
+ return null;
29
+ }
30
+
31
+ function resolveBinaryDir() {
32
+ const pkgName = detectPackageName();
33
+ if (pkgName) {
34
+ try {
35
+ const dir = path.dirname(
36
+ require.resolve(`${pkgName}/package.json`, { paths: [__dirname] }),
37
+ );
38
+ if (fs.existsSync(path.join(dir, binaryName))) return dir;
39
+ } catch (_) {
40
+ // fall through to local dev paths
41
+ }
42
+ }
43
+ for (const profile of ["release", "debug"]) {
44
+ const dir = path.join(__dirname, "..", "target", profile);
45
+ if (fs.existsSync(path.join(dir, binaryName))) return dir;
46
+ }
47
+ return null;
48
+ }
49
+
50
+ function resolveBinaryPath() {
51
+ const dir = resolveBinaryDir();
52
+ return dir ? path.join(dir, binaryName) : null;
53
+ }
54
+
55
+ function installBinary(src, dest) {
56
+ try {
57
+ fs.linkSync(src, dest);
58
+ } catch (_) {
59
+ fs.copyFileSync(src, dest);
60
+ }
61
+ }
62
+
63
+ function main() {
64
+ const sourceDir = resolveBinaryDir();
65
+ if (!sourceDir) {
66
+ console.error(
67
+ "[jigor] No native binary found for " +
68
+ `${process.platform ?? "?"}/${process.arch ?? "?"}. ` +
69
+ "Supported: linux x64/arm64 (glibc), macos (universal2: Intel + Apple Silicon), windows x64. " +
70
+ "Musl and other platforms are not packaged yet.",
71
+ );
72
+ process.exit(1);
73
+ }
74
+
75
+ const src = path.join(sourceDir, binaryName);
76
+ const destBin = path.join(__dirname, binaryName);
77
+ try {
78
+ installBinary(src, destBin);
79
+ } catch (_) {
80
+ console.error("[jigor] Failed to move the native binary into place.");
81
+ process.exit(1);
82
+ }
83
+ }
84
+
85
+ module.exports = {
86
+ binaryName,
87
+ detectPackageName,
88
+ resolveBinaryDir,
89
+ resolveBinaryPath,
90
+ };
91
+
92
+ if (require.main === module) {
93
+ main();
94
+ }