exomind 0.3.12 → 0.3.14

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.12",
3122
+ version: "0.3.14",
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"
@@ -4253,6 +4253,125 @@ async function topics(client, opts) {
4253
4253
  });
4254
4254
  }
4255
4255
 
4256
+ // src/commands/draft.ts
4257
+ async function draft(client, opts, args) {
4258
+ const action = args[0];
4259
+ switch (action) {
4260
+ case "new":
4261
+ return doNew(client, opts, args.slice(1));
4262
+ case "list":
4263
+ return doList(client, opts);
4264
+ case "show":
4265
+ return doShow(client, args[1]);
4266
+ case "publish":
4267
+ return doPublish(client, args[1]);
4268
+ case "wechat":
4269
+ return doWechat(client, opts, args[1]);
4270
+ default:
4271
+ throw new Error(
4272
+ `\u672A\u77E5 draft \u5B50\u547D\u4EE4: ${action ?? "(\u7A7A)"}\u3002\u53EF\u7528: new <\u9009\u9898> / list / show <id> / publish <id> / wechat <id>`
4273
+ );
4274
+ }
4275
+ }
4276
+ async function doNew(client, opts, args) {
4277
+ const topic = args.join(" ").trim();
4278
+ if (!topic) throw new Error('\u8BF7\u63D0\u4F9B\u9009\u9898: exomind draft new "\u9009\u9898" [--account <\u516C\u4F17\u53F7>]');
4279
+ const gen = await client.post(
4280
+ "/generate-draft",
4281
+ { topic, target_account: opts.account ?? null },
4282
+ { timeoutMs: opTimeout(3e5) }
4283
+ );
4284
+ const content = String(gen.draft ?? "");
4285
+ if (!content) throw new Error("\u751F\u6210\u5931\u8D25:\u54CD\u5E94\u65E0 draft \u6B63\u6587");
4286
+ const h1 = content.match(/^#\s+(.+?)\s*$/m);
4287
+ const title = h1?.[1] || (Array.isArray(gen.title_candidates) ? String(gen.title_candidates[0]) : "") || topic;
4288
+ const saved = await client.post(
4289
+ "/drafts",
4290
+ {
4291
+ title,
4292
+ topic,
4293
+ content,
4294
+ tags: Array.isArray(gen.tags) ? gen.tags : [],
4295
+ sources: Array.isArray(gen.sources) ? gen.sources.map(String) : [],
4296
+ insights: gen.insights != null ? String(gen.insights) : "",
4297
+ confidence: Number(gen.confidence) || 0,
4298
+ target_account: opts.account ?? gen.target_account ?? null,
4299
+ recommended_account: gen.recommended_account ?? null,
4300
+ routing_reason: gen.routing_reason ?? null,
4301
+ title_candidates: Array.isArray(gen.title_candidates) ? gen.title_candidates.map(String) : []
4302
+ },
4303
+ { timeoutMs: opTimeout(6e4) }
4304
+ );
4305
+ const draftId = String(saved.id ?? "");
4306
+ output({ ...gen, id: draftId, title, content }, () => {
4307
+ console.log(ok("\u2713 \u8349\u7A3F\u5DF2\u751F\u6210\u5E76\u4FDD\u5B58"));
4308
+ console.log(dim(` id: ${draftId}`));
4309
+ console.log(dim(` \u6807\u9898: ${title}`));
4310
+ if (gen.recommended_account) {
4311
+ console.log(dim(` \u63A8\u8350\u516C\u4F17\u53F7: ${gen.recommended_account}${gen.routing_reason ? ` (${gen.routing_reason})` : ""}`));
4312
+ }
4313
+ console.log(dim(` \u6B63\u6587\u9884\u89C8: ${truncate(content, 200)}`));
4314
+ console.log(dim(` \u4E0B\u4E00\u6B65: exomind draft show ${draftId} | publish ${draftId} | wechat ${draftId} --account <\u53F7>`));
4315
+ });
4316
+ }
4317
+ async function doList(client, opts) {
4318
+ const r = await client.get("/drafts", {
4319
+ status: opts.status,
4320
+ page: Number(opts.page ?? 1),
4321
+ page_size: Number(opts.size ?? 20)
4322
+ });
4323
+ const items = r.drafts || [];
4324
+ output(r, () => {
4325
+ console.log(cyan(`\u8349\u7A3F\u5217\u8868 (\u5171 ${r.total ?? items.length}):`));
4326
+ if (!items.length) console.log(dim(" (\u65E0)"));
4327
+ items.forEach((d, i) => {
4328
+ console.log(`
4329
+ ${i + 1}. ${bold(String(d.title ?? ""))} ${dim(`[${d.status ?? "draft"}]`)}`);
4330
+ console.log(dim(` id: ${d.id}`));
4331
+ if (d.recommended_account) console.log(dim(` \u63A8\u8350\u53F7: ${d.recommended_account}`));
4332
+ });
4333
+ });
4334
+ }
4335
+ async function doShow(client, id) {
4336
+ if (!id) throw new Error("\u8BF7\u63D0\u4F9B draft id: exomind draft show <id>");
4337
+ const d = await client.get(`/drafts/${encodeURIComponent(id)}`);
4338
+ output(d, () => {
4339
+ console.log(bold(String(d.title ?? "")));
4340
+ console.log(dim(` id: ${d.id} | status: ${d.status} | \u5B57\u6570: ${d.word_count ?? "?"}`));
4341
+ if (d.recommended_account) console.log(dim(` \u63A8\u8350\u516C\u4F17\u53F7: ${d.recommended_account}`));
4342
+ console.log(dim(" ---"));
4343
+ console.log(String(d.content ?? ""));
4344
+ });
4345
+ }
4346
+ async function doPublish(client, id) {
4347
+ if (!id) throw new Error("\u8BF7\u63D0\u4F9B draft id: exomind draft publish <id>");
4348
+ const r = await client.post(
4349
+ `/drafts/${encodeURIComponent(id)}/publish`,
4350
+ {},
4351
+ { timeoutMs: opTimeout(3e5) }
4352
+ );
4353
+ output(r, () => {
4354
+ console.log(ok("\u2713 \u5DF2\u53D1\u5E03\u5230\u77E5\u8BC6\u5E93"));
4355
+ if (r.summary) console.log(dim(` ${r.summary}`));
4356
+ if (r.entities != null) console.log(dim(` \u5B9E\u4F53 ${r.entities} / \u6982\u5FF5 ${r.concepts ?? 0}`));
4357
+ });
4358
+ }
4359
+ async function doWechat(client, opts, id) {
4360
+ if (!id) throw new Error("\u8BF7\u63D0\u4F9B draft id: exomind draft wechat <id> --account <\u53F7>");
4361
+ if (!opts.account) throw new Error("\u8BF7\u63D0\u4F9B --account: exomind draft wechat <id> --account <\u516C\u4F17\u53F7>");
4362
+ const r = await client.post(
4363
+ `/drafts/${encodeURIComponent(id)}/submit-wechat`,
4364
+ { account: opts.account, digest: opts.digest, author: opts.author },
4365
+ { timeoutMs: opTimeout(12e4) }
4366
+ );
4367
+ output(r, () => {
4368
+ console.log(ok("\u2713 \u5DF2\u6295\u9012\u516C\u4F17\u53F7\u8349\u7A3F\u7BB1"));
4369
+ if (r.message) console.log(dim(` ${r.message}`));
4370
+ if (r.media_id) console.log(dim(` media_id: ${r.media_id}`));
4371
+ console.log(yellow(" \u4E0B\u4E00\u6B65: \u767B\u5F55\u516C\u4F17\u53F7\u540E\u53F0 \u2192 \u8349\u7A3F\u7BB1 \u2192 \u7FA4\u53D1"));
4372
+ });
4373
+ }
4374
+
4256
4375
  // src/commands/gaps.ts
4257
4376
  async function gaps(client, opts) {
4258
4377
  const result = await client.get("/knowledge-gaps", { days: opts.days ?? 30 });
@@ -4569,10 +4688,14 @@ async function install(client, opts) {
4569
4688
  const keyHint = live.api_key ? `${live.api_key.slice(0, 8)}\u2026${live.api_key.slice(-4)}` : "";
4570
4689
  let me = null;
4571
4690
  if (live.api_key) {
4572
- try {
4573
- me = await client.get("/auth/me");
4574
- } catch {
4575
- me = null;
4691
+ for (let i = 0; i < 3; i++) {
4692
+ try {
4693
+ me = await client.get("/auth/me", { timeoutMs: 6e3 });
4694
+ if (me && me.authenticated) break;
4695
+ } catch {
4696
+ me = null;
4697
+ }
4698
+ if (i < 2) await new Promise((r) => setTimeout(r, 1e3));
4576
4699
  }
4577
4700
  }
4578
4701
  const mcp = live.api_key ? await checkMcp() : { ok: false, detail: "\u672A\u914D\u7F6E API Key" };
@@ -4654,6 +4777,7 @@ reviewCmd.action(run((client, opts) => list(client, { limit: toInt(opts.limit) }
4654
4777
  reviewCmd.command("mark [name...]").description("\u6807\u8BB0\u590D\u4E60 (rating: 1=\u5FD8\u8BB0 2=\u5403\u529B 3=\u987A\u5229 4=\u8F7B\u677E)").option("-r, --rating <n>", "1-4", "3").action(run((client, opts, args) => mark(client, { rating: toInt(opts.rating) }, args)));
4655
4778
  program2.command("synthesize [topic...]").description("\u4E3B\u9898\u7EFC\u5408\u62A5\u544A").option("-d, --depth <n>", "\u6DF1\u5EA6 1-5", "2").action(run(synthesize));
4656
4779
  program2.command("topics").description("\u9009\u9898\u63A8\u8350").option("-c, --count <n>", "\u6570\u91CF", "5").action(run((client, opts) => topics(client, { count: toInt(opts.count) })));
4780
+ program2.command("draft <action> [target...]").description("\u8349\u7A3F: new <\u9009\u9898> / list / show <id> / publish <id> / wechat <id>").option("--account <name>", "\u76EE\u6807\u516C\u4F17\u53F7(new/wechat)").option("--status <s>", "\u72B6\u6001\u8FC7\u6EE4(list)").option("-p, --page <n>", "\u9875\u7801(list)", "1").option("-s, --size <n>", "\u6BCF\u9875(list)", "20").option("--digest <text>", "\u6458\u8981(wechat,\u53EF\u9009)").option("--author <name>", "\u7B14\u540D(wechat,\u53EF\u9009)").action(run((client, opts, args) => draft(client, opts, args)));
4657
4781
  program2.command("gaps").description("\u77E5\u8BC6\u7F3A\u53E3(\u88AB\u591A\u6B21\u641C\u7D22\u4F46\u65E0\u7ED3\u679C)").option("-d, --days <n>", "\u56DE\u6EAF\u5929\u6570", "30").action(run((client, opts) => gaps(client, { days: toInt(opts.days) })));
4658
4782
  program2.command("feedback [page...]").description("\u5BF9\u9875\u9762/\u5B9E\u4F53\u6253\u53CD\u9988 (positive|negative)").action(run(feedback));
4659
4783
  program2.command("daily").description("\u6BCF\u65E5\u6D3B\u52A8\u6458\u8981").option("-d, --days <n>", "\u56DE\u6EAF\u5929\u6570", "1").action(run((client, opts) => daily(client, { days: toInt(opts.days) })));