@kahinmcp/kahin 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 (2) hide show
  1. package/bin/kahin.mjs +65 -0
  2. package/package.json +15 -0
package/bin/kahin.mjs ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ // kahin global launcher — ilk çalıştırmada Python venv kurar, PyPI'dan kahin indirir.
3
+ // Kurulum: pnpm add -g kahin
4
+
5
+ import { spawn } from "node:child_process";
6
+ import { mkdirSync, existsSync } from "node:fs";
7
+ import { homedir, tmpdir } from "node:os";
8
+ import { join } from "node:path";
9
+
10
+ const KAHIN_VERSION = "0.1.0";
11
+ const HOME = process.env.KAHIN_HOME || join(homedir(), ".local", "share", "kahin");
12
+ const VENV = join(HOME, "venv");
13
+ const PY = process.platform === "win32" ? join(VENV, "Scripts", "python.exe") : join(VENV, "bin", "python");
14
+ const MARKER = join(HOME, "version");
15
+ const LOG = join(tmpdir(), "kahin-setup.log");
16
+
17
+ function sh(cmd, args, opts = {}) {
18
+ return new Promise((resolve) => {
19
+ const c = spawn(cmd, args, { stdio: ["ignore", "ignore", "pipe"], ...opts });
20
+ c.stderr.on("data", (d) => process.stderr.write(`[kahin] ${d}`));
21
+ c.on("close", (code) => resolve(code));
22
+ });
23
+ }
24
+
25
+ async function setup() {
26
+ mkdirSync(HOME, { recursive: true });
27
+ const needsInstall = !existsSync(PY) || !existsSync(MARKER) || (await import("node:fs/promises")).readFile(MARKER, "utf8").catch(() => "") !== KAHIN_VERSION;
28
+ if (!needsInstall) return;
29
+
30
+ process.stderr.write("[kahin] Python ortamı kuruluyor (ilk sefer) — ~30 sn...\n");
31
+ const start = Date.now();
32
+ const index = process.env.KAHIN_FIND_LINKS ? ["--find-links", process.env.KAHIN_FIND_LINKS] : [];
33
+ let code;
34
+ if (process.env.UV && existsSync(process.env.UV)) {
35
+ code = await sh(process.env.UV, ["venv", "--python", "3.12", VENV]);
36
+ if (code === 0) code = await sh(process.env.UV, ["pip", "install", "--python", PY, `kahin==${KAHIN_VERSION}`, ...index]);
37
+ } else if (existsSync(join(homedir(), ".local", "bin", "uv"))) {
38
+ code = await sh(join(homedir(), ".local", "bin", "uv"), ["venv", "--python", "3.12", VENV]);
39
+ if (code === 0) code = await sh(join(homedir(), ".local", "bin", "uv"), ["pip", "install", "--python", PY, `kahin==${KAHIN_VERSION}`, ...index]);
40
+ } else {
41
+ code = await sh("python3", ["-m", "venv", VENV]);
42
+ if (code === 0) code = await sh(PY, ["-m", "pip", "install", "-U", "pip", "-q"], { env: { ...process.env, PIP_DISABLE_PIP_VERSION_CHECK: "1" } });
43
+ if (code === 0) code = await sh(PY, ["-m", "pip", "install", `kahin==${KAHIN_VERSION}`, ...index]);
44
+ }
45
+ if (code !== 0) {
46
+ process.stderr.write(`[kahin] Kurulum başarısız. Log: ${LOG} — elle kur: python3 -m venv ${VENV} && ${PY} -m pip install kahin==${KAHIN_VERSION}\n`);
47
+ process.exit(1);
48
+ }
49
+ (await import("node:fs/promises")).writeFile(MARKER, KAHIN_VERSION);
50
+ process.stderr.write(`[kahin] Hazır (${((Date.now() - start) / 1000).toFixed(0)} sn).\n`);
51
+ }
52
+
53
+ const argv = process.argv.slice(2);
54
+ const upgrade = argv.includes("--upgrade") || argv.includes("--update");
55
+ const args = argv.filter((a) => a !== "--upgrade" && a !== "--update");
56
+ if (upgrade) {
57
+ await import("node:fs/promises").then((fs) => fs.rm(MARKER, { force: true }));
58
+ }
59
+
60
+ await setup();
61
+ const child = spawn(PY, ["-m", "kahin.oracle", ...args], { stdio: "inherit" });
62
+ child.on("exit", (code, signal) => {
63
+ if (signal) process.kill(process.pid, signal);
64
+ process.exit(code ?? 0);
65
+ });
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@kahinmcp/kahin",
3
+ "version": "0.1.0",
4
+ "description": "CDP bilgisine sahip MCP server — global launcher. `pnpm add -g kahin`, sonra `kahin`.",
5
+ "bin": {
6
+ "kahin": "bin/kahin.mjs"
7
+ },
8
+ "files": [
9
+ "bin"
10
+ ],
11
+ "engines": {
12
+ "node": ">=18"
13
+ },
14
+ "license": "MIT"
15
+ }