exomind 0.3.7 → 0.3.9

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/dist/cli.js CHANGED
@@ -3119,7 +3119,7 @@ var {
3119
3119
  // package.json
3120
3120
  var package_default = {
3121
3121
  name: "exomind",
3122
- version: "0.3.7",
3122
+ version: "0.3.9",
3123
3123
  description: "ExoMind \u8DE8\u5E73\u53F0\u547D\u4EE4\u884C\u5BA2\u6237\u7AEF \u2014 \u901A\u8FC7 REST \u4E0E ExoMind \u77E5\u8BC6\u5E93\u4EA4\u4E92(ingest/query/search/review),\u66FF\u4EE3 Windows \u4E0D\u53EF\u7528\u7684 MCP \u5BA2\u6237\u7AEF\u3002",
3124
3124
  bin: {
3125
3125
  exomind: "dist/cli.js"
@@ -4360,6 +4360,7 @@ async function whoami(client) {
4360
4360
  var fs6 = __toESM(require("fs"));
4361
4361
  var path6 = __toESM(require("path"));
4362
4362
  var os2 = __toESM(require("os"));
4363
+ var import_node_child_process = require("child_process");
4363
4364
  var PKG_ROOT = path6.resolve(__dirname, "..");
4364
4365
  var SKILL_SRC = path6.join(PKG_ROOT, "skill", "SKILL.md");
4365
4366
  function readJson2(file) {
@@ -4405,7 +4406,51 @@ function purgeMcpExomind(file) {
4405
4406
  fs6.writeFileSync(file, JSON.stringify(d, null, 2) + "\n");
4406
4407
  return true;
4407
4408
  }
4408
- async function install(_client, opts) {
4409
+ function checkMcp(timeoutMs = 6e3) {
4410
+ return new Promise((resolve6) => {
4411
+ let child;
4412
+ try {
4413
+ child = (0, import_node_child_process.spawn)("exomind", ["mcp"], { stdio: ["pipe", "pipe", "pipe"], shell: true });
4414
+ } catch (e) {
4415
+ resolve6({ ok: false, detail: `\u65E0\u6CD5\u542F\u52A8: ${e instanceof Error ? e.message : e}` });
4416
+ return;
4417
+ }
4418
+ let out = "";
4419
+ let done = false;
4420
+ const finish = (r) => {
4421
+ if (done) return;
4422
+ done = true;
4423
+ clearTimeout(timer);
4424
+ try {
4425
+ child.kill();
4426
+ } catch {
4427
+ }
4428
+ resolve6(r);
4429
+ };
4430
+ const timer = setTimeout(() => finish({ ok: false, detail: "\u8D85\u65F6\u672A\u54CD\u5E94 initialize" }), timeoutMs);
4431
+ child.stdout?.on("data", (d) => {
4432
+ out += d.toString();
4433
+ if (out.includes('"serverInfo"')) finish({ ok: true, detail: "initialize \u54CD\u5E94\u6B63\u5E38" });
4434
+ });
4435
+ child.on("error", (e) => finish({ ok: false, detail: `\u542F\u52A8\u5931\u8D25: ${e.message}` }));
4436
+ child.on("close", () => {
4437
+ if (!out.includes('"serverInfo"')) finish({ ok: false, detail: "\u672A\u54CD\u5E94 initialize \u5373\u9000\u51FA" });
4438
+ });
4439
+ try {
4440
+ child.stdin?.write(
4441
+ JSON.stringify({
4442
+ jsonrpc: "2.0",
4443
+ method: "initialize",
4444
+ params: { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "install-check", version: "1" } },
4445
+ id: 1
4446
+ }) + "\n"
4447
+ );
4448
+ } catch {
4449
+ finish({ ok: false, detail: "\u5199\u5165 stdin \u5931\u8D25" });
4450
+ }
4451
+ });
4452
+ }
4453
+ async function install(client, opts) {
4409
4454
  const claudeDir = path6.join(os2.homedir(), ".claude");
4410
4455
  const skillDestDir = path6.join(claudeDir, "skills", "exomind");
4411
4456
  if (!fs6.existsSync(SKILL_SRC)) {
@@ -4473,9 +4518,34 @@ async function install(_client, opts) {
4473
4518
  console.log(ok(`\u5DF2\u8FC1\u79FB base_url: d.youhuale.cn \u2192 ${DEFAULT_BASE_URL}`));
4474
4519
  console.log(dim(" (stdio MCP \u5B50\u8FDB\u7A0B\u8BFB\u6B64\u914D\u7F6E\uFF0C\u91CD\u542F Agent \u540E\u7528\u65B0\u57DF\u540D)"));
4475
4520
  }
4521
+ const live = loadConfig();
4522
+ const keyHint = live.api_key ? `${live.api_key.slice(0, 8)}\u2026${live.api_key.slice(-4)}` : "";
4523
+ let me = null;
4524
+ if (live.api_key) {
4525
+ try {
4526
+ me = await client.get("/auth/me");
4527
+ } catch {
4528
+ me = null;
4529
+ }
4530
+ }
4531
+ const mcp = live.api_key ? await checkMcp() : { ok: false, detail: "\u672A\u914D\u7F6E API Key" };
4532
+ console.log(yellow("\n\u53EF\u7528\u6027\u81EA\u68C0:"));
4533
+ if (!live.api_key) {
4534
+ console.log(dim(" \uFF08\u672A\u914D\u7F6E API Key\uFF0C\u8DF3\u8FC7\u81EA\u68C0\uFF1Bexomind login \u540E\u91CD\u8DD1 install \u53EF\u81EA\u68C0\uFF09"));
4535
+ } else {
4536
+ console.log(me && me.authenticated ? ok(" \u670D\u52A1\u5668\u8FDE\u901A + \u9274\u6743\u6709\u6548") : yellow(" \u2717 \u670D\u52A1\u5668\u8FDE\u901A/\u9274\u6743\u5F02\u5E38 \u2192 exomind whoami \u6838\u9A8C"));
4537
+ console.log(mcp.ok ? ok(` MCP \u670D\u52A1\u7AEF\u53EF\u7528\uFF08${mcp.detail}\uFF09`) : yellow(` \u2717 MCP \u670D\u52A1\u7AEF\u5F02\u5E38\uFF1A${mcp.detail}`));
4538
+ }
4476
4539
  console.log(yellow("\n\u4E0B\u4E00\u6B65:"));
4477
- console.log(dim(" 1. \u82E5\u672A\u914D\u7F6E\u51ED\u8BC1: exomind login"));
4478
- console.log(dim(" 2. \u91CD\u542F Claude Code \u2192 skill + hook + mcp__exomind__* \u5168\u90E8\u751F\u6548"));
4540
+ if (!live.api_key) {
4541
+ console.log(dim(" 1. exomind login\uFF08\u7C98\u8D34 API Key\uFF09"));
4542
+ console.log(dim(" 2. \u91CD\u542F Claude Code\uFF08\u52A0\u8F7D skill/hook/MCP\uFF09\u2192 mcp__exomind__* \u751F\u6548"));
4543
+ } else if (me && me.authenticated && mcp.ok) {
4544
+ console.log(ok(`\u51ED\u8BC1\u6709\u6548\uFF1A${live.base_url}\uFF08${keyHint}\uFF09\xB7 tenant ${me.tenant_id}`));
4545
+ console.log(dim(" \u81EA\u68C0\u5168\u8FC7 \u2192 \u91CD\u542F Claude Code\uFF08skill/hook/MCP \u542F\u52A8\u65F6\u8F7D\u5165\uFF09\u5373\u751F\u6548"));
4546
+ } else {
4547
+ console.log(yellow("\u81EA\u68C0\u6709\u5F02\u5E38\uFF0C\u8BF7\u6309\u4E0A\u65B9 \u2717 \u63D0\u793A\u6838\u9A8C\u540E\u518D\u91CD\u542F\u4F7F\u7528\u3002"));
4548
+ }
4479
4549
  }
4480
4550
 
4481
4551
  // src/cli.ts