@kahinmcp/kahin 0.1.4 → 0.1.6
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/bin/kahin.mjs +12 -52
- package/package.json +1 -2
- package/lib/vendor/kahin-0.1.2-py3-none-any.whl +0 -0
package/bin/kahin.mjs
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// kahin global launcher —
|
|
2
|
+
// kahin global launcher — kod tabanındaki kahin MCP server'ı çalıştırır.
|
|
3
3
|
// Kurulum: pnpm add -g @kahinmcp/kahin
|
|
4
4
|
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
|
-
import {
|
|
7
|
-
import { homedir
|
|
8
|
-
import {
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
10
9
|
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const VENDOR = join(__dirname, "..", "lib", "vendor");
|
|
13
|
-
const wheelName = readdirSync(VENDOR).find((f) => f.startsWith("kahin-") && f.endsWith(".whl"));
|
|
14
|
-
if (!wheelName) {
|
|
15
|
-
process.stderr.write(`[kahin] Wheel bulunamadı: ${VENDOR}/kahin-*.whl\n`);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const WHEEL = join(VENDOR, wheelName);
|
|
19
10
|
const HOME = process.env.KAHIN_HOME || join(homedir(), ".local", "share", "kahin");
|
|
20
11
|
const VENV = join(HOME, "venv");
|
|
21
12
|
const PY = process.platform === "win32" ? join(VENV, "Scripts", "python.exe") : join(VENV, "bin", "python");
|
|
22
|
-
const MARKER = join(HOME, "version");
|
|
23
|
-
const LOG = join(tmpdir(), "kahin-setup.log");
|
|
24
13
|
|
|
25
14
|
function sh(cmd, args, opts = {}) {
|
|
26
15
|
return new Promise((resolve) => {
|
|
@@ -31,47 +20,18 @@ function sh(cmd, args, opts = {}) {
|
|
|
31
20
|
}
|
|
32
21
|
|
|
33
22
|
async function setup() {
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const python = existsSync(PY) ? PY : (process.env.KAHIN_PY || "python3");
|
|
24
|
+
const check = await sh(python, ["-c", "import kahin"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
25
|
+
if (check !== 0) {
|
|
26
|
+
process.stderr.write(`[kahin] kahin Python paketi bulunamadı. ${python} ile çalıştırılamıyor.\n`);
|
|
36
27
|
process.exit(1);
|
|
37
28
|
}
|
|
38
|
-
|
|
39
|
-
const needsInstall = !existsSync(PY) || !existsSync(MARKER) || (await import("node:fs/promises")).readFile(MARKER, "utf8").catch(() => "") !== wheelName;
|
|
40
|
-
if (!needsInstall) return;
|
|
41
|
-
|
|
42
|
-
process.stderr.write("[kahin] Python ortamı kuruluyor (ilk sefer) — ~30 sn...\n");
|
|
43
|
-
const start = Date.now();
|
|
44
|
-
const wheelCopy = join(HOME, wheelName);
|
|
45
|
-
copyFileSync(WHEEL, wheelCopy);
|
|
46
|
-
let code;
|
|
47
|
-
if (process.env.UV && existsSync(process.env.UV)) {
|
|
48
|
-
code = await sh(process.env.UV, ["venv", "--python", "3.12", VENV]);
|
|
49
|
-
if (code === 0) code = await sh(process.env.UV, ["pip", "install", "--python", PY, wheelCopy]);
|
|
50
|
-
} else if (existsSync(join(homedir(), ".local", "bin", "uv"))) {
|
|
51
|
-
code = await sh(join(homedir(), ".local", "bin", "uv"), ["venv", "--python", "3.12", VENV]);
|
|
52
|
-
if (code === 0) code = await sh(join(homedir(), ".local", "bin", "uv"), ["pip", "install", "--python", PY, wheelCopy]);
|
|
53
|
-
} else {
|
|
54
|
-
code = await sh("python3", ["-m", "venv", VENV]);
|
|
55
|
-
if (code === 0) code = await sh(PY, ["-m", "pip", "install", "-U", "pip", "-q"], { env: { ...process.env, PIP_DISABLE_PIP_VERSION_CHECK: "1" } });
|
|
56
|
-
if (code === 0) code = await sh(PY, ["-m", "pip", "install", wheelCopy]);
|
|
57
|
-
}
|
|
58
|
-
if (code !== 0) {
|
|
59
|
-
process.stderr.write(`[kahin] Kurulum başarısız. Log: ${LOG} — elle kur: python3 -m venv ${VENV} && ${PY} -m pip install ${wheelCopy}\n`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
(await import("node:fs/promises")).writeFile(MARKER, wheelName);
|
|
63
|
-
process.stderr.write(`[kahin] Hazır (${((Date.now() - start) / 1000).toFixed(0)} sn).\n`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const argv = process.argv.slice(2);
|
|
67
|
-
const upgrade = argv.includes("--upgrade") || argv.includes("--update");
|
|
68
|
-
const args = argv.filter((a) => a !== "--upgrade" && a !== "--update");
|
|
69
|
-
if (upgrade) {
|
|
70
|
-
await import("node:fs/promises").then((fs) => fs.rm(MARKER, { force: true }));
|
|
29
|
+
return python;
|
|
71
30
|
}
|
|
72
31
|
|
|
73
|
-
|
|
74
|
-
const
|
|
32
|
+
const args = process.argv.slice(2);
|
|
33
|
+
const python = await setup();
|
|
34
|
+
const child = spawn(python, ["-m", "kahin.oracle", ...args], { stdio: "inherit" });
|
|
75
35
|
child.on("exit", (code, signal) => {
|
|
76
36
|
if (signal) process.kill(process.pid, signal);
|
|
77
37
|
process.exit(code ?? 0);
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahinmcp/kahin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Kahin — CDP ansiklopedisi + anti-detect browser otomasyon MCP sunucusu. Obscura ve Camoufox motorlarını kullanır, motor seçimini ajana bırakır.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"kahin": "bin/kahin.mjs"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin",
|
|
10
|
-
"lib/vendor",
|
|
11
10
|
"LICENSE"
|
|
12
11
|
],
|
|
13
12
|
"engines": {
|
|
Binary file
|