@kahinmcp/kahin 0.3.0 → 0.3.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/bin/kahin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // kahin global launcher — kod tabanındaki kahin MCP server'ı çalıştırır.
3
- // Kurulum: pnpm add -g @kahinmcp/kahin
2
+ // kahin global launcher — gömülü wheel'den kahin MCP server'ı çalıştırır.
3
+ // Kurulum: pnpm add -g @kahinmcp/kahin (postinstall venv + wheel kurar)
4
4
 
5
5
  import { spawn } from "node:child_process";
6
6
  import { existsSync } from "node:fs";
@@ -20,6 +20,13 @@ function sh(cmd, args, opts = {}) {
20
20
  }
21
21
 
22
22
  async function setup() {
23
+ // venv yoksa gömülü wheel'den kur (postinstall atlanmışsa / bozuksa)
24
+ const { installPython } = await import("./setup.mjs");
25
+ const res = await installPython();
26
+ if (res && res.error) {
27
+ process.stderr.write(`[kahin] python kurulumu başarısız (çıkış ${res.error})\n`);
28
+ process.exit(1);
29
+ }
23
30
  const python = existsSync(PY) ? PY : (process.env.KAHIN_PY || "python3");
24
31
  const check = await sh(python, ["-c", "import kahin"], { stdio: ["ignore", "pipe", "pipe"] });
25
32
  if (check !== 0) {
@@ -32,8 +39,8 @@ async function setup() {
32
39
  const args = process.argv.slice(2);
33
40
 
34
41
  if (args[0] === "setup") {
35
- const { setup } = await import("./setup.mjs");
36
- setup();
42
+ const { setup: registerClients } = await import("./setup.mjs");
43
+ registerClients();
37
44
  process.exit(0);
38
45
  }
39
46
 
package/bin/setup.mjs CHANGED
@@ -10,6 +10,8 @@
10
10
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
11
11
  import { homedir } from "node:os";
12
12
  import { join, dirname } from "node:path";
13
+ import { spawn } from "node:child_process";
14
+ import { fileURLToPath } from "node:url";
13
15
 
14
16
  const HOME = homedir();
15
17
  const isWin = process.platform === "win32";
@@ -319,6 +321,56 @@ export function setup() {
319
321
  return { installed };
320
322
  }
321
323
 
324
+ const KAHIN_HOME = process.env.KAHIN_HOME || join(homedir(), ".local", "share", "kahin");
325
+ const KAHIN_VENV = join(KAHIN_HOME, "venv");
326
+ const KAHIN_PY = process.platform === "win32" ? join(KAHIN_VENV, "Scripts", "python.exe") : join(KAHIN_VENV, "bin", "python");
327
+ const KAHIN_WHEEL = join(dirname(fileURLToPath(import.meta.url)), "..", "lib", "kahin-0.3.1-py3-none-any.whl");
328
+
329
+ // Gömülü wheel'i venv'e kurar. Postinstall'da ve `kahin setup`'ta çalışır.
330
+ // PyPI'a bağımlı DEĞİL — wheel paketle birlikte gelir.
331
+ export async function installPython() {
332
+ if (process.env.KAHIN_SKIP_PYTHON) {
333
+ log("python kurulumu atlandı (KAHIN_SKIP_PYTHON)");
334
+ return { skipped: true };
335
+ }
336
+ if (!existsSync(KAHIN_WHEEL)) {
337
+ log(`wheel bulunamadı: ${KAHIN_WHEEL} — kurulum atlandı (geliştirme ortamı?)`);
338
+ return { skipped: true };
339
+ }
340
+ const python3 = process.env.KAHIN_PYTHON || "python3";
341
+ const args = ["-m", "venv", KAHIN_VENV];
342
+ if (!existsSync(join(KAHIN_VENV, "pyvenv.cfg"))) {
343
+ log(`venv oluşturuluyor: ${KAHIN_VENV}`);
344
+ const code = await run(python3, args);
345
+ if (code !== 0) {
346
+ log(`venv oluşturulamadı (${python3} ${args.join(" ")} — çıkış ${code})`);
347
+ return { error: code };
348
+ }
349
+ }
350
+ const check = await run(KAHIN_PY, ["-c", "import kahin; print(kahin.__version__)"]);
351
+ if (check === 0) {
352
+ log("kahin zaten kurulu, atlandı");
353
+ return { installed: true };
354
+ }
355
+ log(`wheel kuruluyor: ${KAHIN_WHEEL}`);
356
+ const code = await run(KAHIN_PY, ["-m", "pip", "install", "--upgrade", KAHIN_WHEEL]);
357
+ if (code !== 0) {
358
+ log(`wheel kurulamadı (çıkış ${code})`);
359
+ return { error: code };
360
+ }
361
+ log("kahin python paketi kuruldu");
362
+ return { installed: true };
363
+ }
364
+
365
+ function run(cmd, args) {
366
+ return new Promise((resolve) => {
367
+ const c = spawn(cmd, args, { stdio: ["ignore", "ignore", "pipe"] });
368
+ c.stderr.on("data", (d) => process.stderr.write(`[kahin] ${d}`));
369
+ c.on("close", (code) => resolve(code));
370
+ });
371
+ }
372
+
322
373
  if (process.argv[1] && process.argv[1].endsWith("setup.mjs")) {
323
374
  setup();
375
+ installPython();
324
376
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kahinmcp/kahin",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Kahin — CDP ansiklopedisi + anti-detect browser otomasyon MCP sunucusu. Kurulumda 22 AI CLI aracını otomatik tespit edip kendini kaydeder. Obscura ve Camoufox motorlarını kullanır, motor seçimini ajana bırakır.",
5
5
  "bin": {
6
6
  "kahin": "bin/kahin.mjs"
@@ -11,8 +11,10 @@
11
11
  },
12
12
  "files": [
13
13
  "bin",
14
+ "lib",
14
15
  "LICENSE",
15
- "CHANGELOG.md"
16
+ "CHANGELOG.md",
17
+ "README.md"
16
18
  ],
17
19
  "engines": {
18
20
  "node": ">=18"