saengil-mimikyu 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/README.md +20 -2
  2. package/bin/mimikyu.js +165 -0
  3. package/package.json +45 -4
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # `saengil-mimikyu`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official **Saengil** CLI & MCP binary distribution for [`mimikyu`](https://github.com/YXZYSME/mimikyu) — fast Rust browser automation, two-tier session/profile isolation, background daemon, and 31-tool MCP server over **Chromium (CDP)** and **Firefox (WebDriver BiDi)**.
4
+
5
+ ## Install & Usage
6
+
7
+ ```sh
8
+ # Install the `mimikyu` CLI binary globally
9
+ npm install -g saengil-mimikyu
10
+ mimikyu doctor
11
+
12
+ # Or run directly without global install via npx
13
+ npx -y saengil-mimikyu doctor
14
+ npx -y saengil-mimikyu mcp
15
+ ```
16
+
17
+ On first run, `saengil-mimikyu` downloads the official GitHub Release tarball for your OS/CPU (`darwin-arm64`, `darwin-x64`, `linux-arm64`, `linux-x64`), verifies its `SHA-256` digest against `SHA256SUMS`, caches the native Rust `mimikyu` binary locally, and forwards all CLI arguments verbatim.
18
+
19
+ ## License
20
+
21
+ Dual-licensed under **MIT OR Apache-2.0**. See https://github.com/YXZYSME/mimikyu.
package/bin/mimikyu.js ADDED
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Zero-dependency CLI & MCP launcher for `mimikyu` (`saengil-mimikyu` / `mimikyu-cli`).
6
+ *
7
+ * - Downloads the signed GitHub Release tarball for the current OS/CPU once into the
8
+ * user's cache directory, verifies its SHA-256 checksum against `SHA256SUMS`,
9
+ * and executes the native Rust `mimikyu` binary with all CLI arguments forwarded verbatim.
10
+ * - Never writes diagnostic output to `stdout` so `--json` and `mcp` stdio streams remain clean.
11
+ */
12
+
13
+ const crypto = require("node:crypto");
14
+ const fs = require("node:fs");
15
+ const os = require("node:os");
16
+ const path = require("node:path");
17
+ const { execFileSync, spawn } = require("node:child_process");
18
+
19
+ const pkg = require("../package.json");
20
+ const VERSION = pkg.version;
21
+ const REPO = process.env.MIMIKYU_REPO || "YXZYSME/mimikyu";
22
+
23
+ function resolveTarget() {
24
+ const key = `${process.platform}-${process.arch}`;
25
+ switch (key) {
26
+ case "darwin-arm64":
27
+ return "aarch64-apple-darwin";
28
+ case "darwin-x64":
29
+ return "x86_64-apple-darwin";
30
+ case "linux-arm64":
31
+ return "aarch64-unknown-linux-gnu";
32
+ case "linux-x64":
33
+ return "x86_64-unknown-linux-gnu";
34
+ default:
35
+ throw new Error(
36
+ `Unsupported platform/arch '${key}'. Supported targets: darwin-arm64, darwin-x64, linux-arm64, linux-x64.`
37
+ );
38
+ }
39
+ }
40
+
41
+ function resolveCacheRoot() {
42
+ if (process.env.MIMIKYU_CACHE_DIR) {
43
+ return process.env.MIMIKYU_CACHE_DIR;
44
+ }
45
+ if (process.platform === "darwin") {
46
+ return path.join(os.homedir(), "Library", "Caches", "mimikyu", "npm");
47
+ }
48
+ const xdg = process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
49
+ return path.join(xdg, "mimikyu", "npm");
50
+ }
51
+
52
+ async function fetchBuffer(url) {
53
+ const res = await fetch(url, {
54
+ redirect: "follow",
55
+ headers: { "User-Agent": `${pkg.name}/${VERSION}` },
56
+ });
57
+ if (!res.ok) {
58
+ throw new Error(`HTTP ${res.status} fetching ${url}`);
59
+ }
60
+ const ab = await res.arrayBuffer();
61
+ return Buffer.from(ab);
62
+ }
63
+
64
+ function parseExpectedSha256(sumsText, archiveName) {
65
+ for (const rawLine of sumsText.split(/\r?\n/)) {
66
+ const line = rawLine.trim();
67
+ if (!line) continue;
68
+ const parts = line.split(/\s+/);
69
+ if (parts.length >= 2) {
70
+ const hash = parts[0].toLowerCase();
71
+ const file = parts[1].replace(/^\*/, "");
72
+ if (file === archiveName && /^[a-f0-9]{64}$/.test(hash)) {
73
+ return hash;
74
+ }
75
+ }
76
+ }
77
+ throw new Error(`Entry for '${archiveName}' not found in SHA256SUMS`);
78
+ }
79
+
80
+ async function ensureBinary() {
81
+ if (process.env.MIMIKYU_BIN && fs.existsSync(process.env.MIMIKYU_BIN)) {
82
+ return process.env.MIMIKYU_BIN;
83
+ }
84
+
85
+ const target = resolveTarget();
86
+ const installDir = path.join(resolveCacheRoot(), `v${VERSION}-${target}`);
87
+ const binPath = path.join(installDir, "mimikyu");
88
+
89
+ if (fs.existsSync(binPath)) {
90
+ return binPath;
91
+ }
92
+
93
+ const archiveName = `mimikyu-${target}.tar.gz`;
94
+ const baseUrl = `https://github.com/${REPO}/releases/download/v${VERSION}`;
95
+
96
+ process.stderr.write(
97
+ `[${pkg.name}] Downloading and verifying mimikyu v${VERSION} (${target})...\n`
98
+ );
99
+
100
+ const [sumsBuf, tarBuf] = await Promise.all([
101
+ fetchBuffer(`${baseUrl}/SHA256SUMS`),
102
+ fetchBuffer(`${baseUrl}/${archiveName}`),
103
+ ]);
104
+
105
+ const expectedSha = parseExpectedSha256(sumsBuf.toString("utf8"), archiveName);
106
+ const actualSha = crypto.createHash("sha256").update(tarBuf).digest("hex");
107
+ if (actualSha !== expectedSha) {
108
+ throw new Error(
109
+ `SHA-256 mismatch for ${archiveName}: expected ${expectedSha}, got ${actualSha}`
110
+ );
111
+ }
112
+
113
+ fs.mkdirSync(installDir, { recursive: true });
114
+ const tmpDir = fs.mkdtempSync(path.join(installDir, ".stage-"));
115
+ try {
116
+ const archivePath = path.join(tmpDir, archiveName);
117
+ fs.writeFileSync(archivePath, tarBuf);
118
+ execFileSync("tar", ["-xzf", archivePath, "-C", tmpDir], {
119
+ stdio: ["ignore", "ignore", "pipe"],
120
+ });
121
+ const extractedBin = path.join(tmpDir, "mimikyu");
122
+ if (!fs.existsSync(extractedBin)) {
123
+ throw new Error(`Archive ${archiveName} did not contain 'mimikyu' binary`);
124
+ }
125
+ fs.chmodSync(extractedBin, 0o755);
126
+ fs.renameSync(extractedBin, binPath);
127
+ } finally {
128
+ fs.rmSync(tmpDir, { recursive: true, force: true });
129
+ }
130
+
131
+ return binPath;
132
+ }
133
+
134
+ async function main() {
135
+ const binPath = await ensureBinary();
136
+ const args = process.argv.slice(2);
137
+
138
+ const child = spawn(binPath, args, { stdio: "inherit" });
139
+
140
+ for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
141
+ process.on(sig, () => {
142
+ if (!child.killed) {
143
+ child.kill(sig);
144
+ }
145
+ });
146
+ }
147
+
148
+ child.on("error", (err) => {
149
+ process.stderr.write(`[${pkg.name}] Failed to spawn ${binPath}: ${err.message}\n`);
150
+ process.exit(1);
151
+ });
152
+
153
+ child.on("exit", (code, signal) => {
154
+ if (signal) {
155
+ process.kill(process.pid, signal);
156
+ } else {
157
+ process.exit(code ?? 0);
158
+ }
159
+ });
160
+ }
161
+
162
+ main().catch((err) => {
163
+ process.stderr.write(`[${pkg.name}] Error: ${err.message}\n`);
164
+ process.exit(1);
165
+ });
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "saengil-mimikyu",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Official Saengil CLI & MCP binary installer/launcher for mimikyu — fast Rust browser automation & session isolation over Chromium CDP and Firefox WebDriver BiDi.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "homepage": "https://github.com/YXZYSME/mimikyu",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/YXZYSME/mimikyu.git",
10
+ "directory": "packaging/npm/saengil-mimikyu"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/YXZYSME/mimikyu/issues"
14
+ },
15
+ "engines": {
16
+ "node": ">=18.0.0"
17
+ },
18
+ "os": [
19
+ "darwin",
20
+ "linux"
21
+ ],
22
+ "cpu": [
23
+ "arm64",
24
+ "x64"
25
+ ],
26
+ "bin": {
27
+ "mimikyu": "bin/mimikyu.js",
28
+ "saengil-mimikyu": "bin/mimikyu.js"
29
+ },
30
+ "files": [
31
+ "bin/mimikyu.js",
32
+ "README.md"
33
+ ],
34
+ "keywords": [
35
+ "saengil",
36
+ "mimikyu",
37
+ "browser-automation",
38
+ "mcp",
39
+ "model-context-protocol",
40
+ "cdp",
41
+ "webdriver-bidi",
42
+ "chromium",
43
+ "firefox",
44
+ "ai-agents",
45
+ "cli"
46
+ ]
47
+ }