exomind 0.10.0 → 0.12.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.
- package/dist/cli.js +111 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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.
|
|
3122
|
+
version: "0.12.0",
|
|
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"
|
|
@@ -3258,6 +3258,9 @@ var ApiClient = class {
|
|
|
3258
3258
|
post(p, body, opts) {
|
|
3259
3259
|
return this.request("POST", p, { ...opts, body });
|
|
3260
3260
|
}
|
|
3261
|
+
del(p, opts) {
|
|
3262
|
+
return this.request("DELETE", p, opts);
|
|
3263
|
+
}
|
|
3261
3264
|
};
|
|
3262
3265
|
|
|
3263
3266
|
// src/config.ts
|
|
@@ -4215,8 +4218,15 @@ async function runDirIngestest(client, opts, dir) {
|
|
|
4215
4218
|
}
|
|
4216
4219
|
|
|
4217
4220
|
// src/commands/ingest.ts
|
|
4221
|
+
function resolveIngestDir(dir, args) {
|
|
4222
|
+
const dirPath = typeof dir === "string" ? dir : args[0];
|
|
4223
|
+
if (!dirPath || dirPath === "-") {
|
|
4224
|
+
throw new Error("--dir \u9700\u8981\u76EE\u5F55\u8DEF\u5F84\u3002\u4E24\u79CD\u5199\u6CD5: exomind ingest --dir <\u76EE\u5F55> \u6216 exomind ingest <\u76EE\u5F55> --dir");
|
|
4225
|
+
}
|
|
4226
|
+
return dirPath;
|
|
4227
|
+
}
|
|
4218
4228
|
async function ingest(client, opts, args) {
|
|
4219
|
-
if (opts.dir) return runDirIngestest(client, opts, opts.dir);
|
|
4229
|
+
if (opts.dir) return runDirIngestest(client, opts, resolveIngestDir(opts.dir, args));
|
|
4220
4230
|
let content = "";
|
|
4221
4231
|
let fileAbs = null;
|
|
4222
4232
|
let fileRaw = null;
|
|
@@ -4303,7 +4313,8 @@ async function search(client, opts, args) {
|
|
|
4303
4313
|
console.log(`
|
|
4304
4314
|
${i + 1}. ${cyan(title)}`);
|
|
4305
4315
|
if (r.path) console.log(dim(` ${r.path}`));
|
|
4306
|
-
|
|
4316
|
+
const snip = r.snippet ?? r.content;
|
|
4317
|
+
if (snip) console.log(dim(` ${truncate(String(snip), 100)}`));
|
|
4307
4318
|
if (r.score != null) console.log(dim(` score: ${r.score}`));
|
|
4308
4319
|
});
|
|
4309
4320
|
});
|
|
@@ -4680,6 +4691,98 @@ async function whoami(client) {
|
|
|
4680
4691
|
);
|
|
4681
4692
|
}
|
|
4682
4693
|
|
|
4694
|
+
// src/commands/delete.ts
|
|
4695
|
+
var readline3 = __toESM(require("readline/promises"));
|
|
4696
|
+
function encPath(p) {
|
|
4697
|
+
return p.split("/").map(encodeURIComponent).join("/");
|
|
4698
|
+
}
|
|
4699
|
+
async function resolvePage(client, page) {
|
|
4700
|
+
const dirs = ["entities", "concepts", "summaries", "synthesis", "qa", "raw/articles"];
|
|
4701
|
+
for (const d of dirs) {
|
|
4702
|
+
const cand = `${d}/${page}.md`;
|
|
4703
|
+
try {
|
|
4704
|
+
await client.get(`/pages/${encPath(cand)}`, void 0, { timeoutMs: 15e3 });
|
|
4705
|
+
return cand;
|
|
4706
|
+
} catch {
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
throw new Error(
|
|
4710
|
+
`\u9875\u9762\u4E0D\u5B58\u5728: ${page}(\u5148 exomind search \u6216 exomind list \u5B9A\u4F4D;\u94FE\u63A5\u6846\u5165\u5E93\u7684\u539F\u6587\u5728 raw/articles/ \u4E0B)`
|
|
4711
|
+
);
|
|
4712
|
+
}
|
|
4713
|
+
async function deletePage(client, opts, args) {
|
|
4714
|
+
const page = args.join(" ").trim();
|
|
4715
|
+
if (!page) throw new Error("\u8BF7\u63D0\u4F9B\u9875\u9762\u8DEF\u5F84\u6216\u5B9E\u4F53\u540D: exomind delete entities/Redis.md");
|
|
4716
|
+
let target = page;
|
|
4717
|
+
if (!page.includes("/") && !page.endsWith(".md")) {
|
|
4718
|
+
target = await resolvePage(client, page);
|
|
4719
|
+
}
|
|
4720
|
+
let title = "";
|
|
4721
|
+
try {
|
|
4722
|
+
const detail = await client.get(`/pages/${encPath(target)}`, void 0, {
|
|
4723
|
+
timeoutMs: 15e3
|
|
4724
|
+
});
|
|
4725
|
+
title = String(detail?.title ?? "");
|
|
4726
|
+
} catch {
|
|
4727
|
+
}
|
|
4728
|
+
if (!opts.yes && !isJsonMode()) {
|
|
4729
|
+
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
4730
|
+
const ans = await rl.question(
|
|
4731
|
+
`\u5220\u9664 ${target}${title ? `\uFF08${title}\uFF09` : ""}\uFF1F\u5165\u670D\u52A1\u7AEF\u56DE\u6536\u7AD9\u3001\u53EF\u6062\u590D [y/N] `
|
|
4732
|
+
);
|
|
4733
|
+
rl.close();
|
|
4734
|
+
if (ans.trim().toLowerCase() !== "y") {
|
|
4735
|
+
console.log("\u5DF2\u53D6\u6D88");
|
|
4736
|
+
return;
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
const r = await client.del(`/pages/${encPath(target)}`);
|
|
4740
|
+
output(r, () => {
|
|
4741
|
+
console.log(ok(`\u5DF2\u5220\u9664: ${r.path}`));
|
|
4742
|
+
if (r.trash_path) console.log(dim(`\u56DE\u6536\u7AD9: ${r.trash_path} \u2014 exomind trash \u67E5\u770B / trash restore \u6062\u590D`));
|
|
4743
|
+
});
|
|
4744
|
+
}
|
|
4745
|
+
|
|
4746
|
+
// src/commands/trash.ts
|
|
4747
|
+
async function trash(client, opts, args) {
|
|
4748
|
+
const action = args[0];
|
|
4749
|
+
switch (action) {
|
|
4750
|
+
case "list":
|
|
4751
|
+
return doList2(client, opts);
|
|
4752
|
+
case "restore":
|
|
4753
|
+
return doRestore(client, args[1]);
|
|
4754
|
+
default:
|
|
4755
|
+
throw new Error(
|
|
4756
|
+
`\u672A\u77E5 trash \u5B50\u547D\u4EE4: ${action ?? "(\u7A7A)"}\u3002\u53EF\u7528: list \u5217\u8868 / restore <\u56DE\u6536\u7AD9\u8DEF\u5F84> \u6062\u590D`
|
|
4757
|
+
);
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4760
|
+
async function doList2(client, opts) {
|
|
4761
|
+
const r = await client.get("/trash", { page: opts.page ?? 1, page_size: 50 });
|
|
4762
|
+
output(r, () => {
|
|
4763
|
+
const items = r.items ?? [];
|
|
4764
|
+
if (!items.length) {
|
|
4765
|
+
console.log("\uFF08\u56DE\u6536\u7AD9\u4E3A\u7A7A\uFF09");
|
|
4766
|
+
return;
|
|
4767
|
+
}
|
|
4768
|
+
for (const it of items) {
|
|
4769
|
+
console.log(
|
|
4770
|
+
`${cyan(it.trash_path)}
|
|
4771
|
+
${dim(`\u539F\u8DEF\u5F84: ${it.path ?? ""} \xB7 \u5220\u9664: ${it.deleted_at ?? ""}`)}${it.restorable ? "" : yellow(" (\u539F\u8DEF\u5F84\u88AB\u5360,\u6062\u590D\u4F1A\u51B2\u7A81)")}`
|
|
4772
|
+
);
|
|
4773
|
+
}
|
|
4774
|
+
console.log(
|
|
4775
|
+
dim(`\u5171 ${r.total} \u6761 \xB7 \u7B2C ${r.page} \u9875 \u2014 \u6062\u590D: exomind trash restore <\u56DE\u6536\u7AD9\u8DEF\u5F84>`)
|
|
4776
|
+
);
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
async function doRestore(client, trashPath) {
|
|
4780
|
+
const p = (trashPath ?? "").trim();
|
|
4781
|
+
if (!p) throw new Error('\u8BF7\u63D0\u4F9B\u56DE\u6536\u7AD9\u8DEF\u5F84: exomind trash restore ".trash/202609/entities/Redis.md"');
|
|
4782
|
+
const r = await client.post("/trash/restore", { trash_path: p });
|
|
4783
|
+
output(r, () => console.log(ok(`\u5DF2\u6062\u590D \u2192 ${r.path}`)));
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4683
4786
|
// src/commands/install.ts
|
|
4684
4787
|
var fs7 = __toESM(require("fs"));
|
|
4685
4788
|
var path7 = __toESM(require("path"));
|
|
@@ -5134,12 +5237,16 @@ program2.name("exomind").description("ExoMind \u8DE8\u5E73\u53F0\u77E5\u8BC6\u5E
|
|
|
5134
5237
|
program2.command("login").description("\u914D\u7F6E\u670D\u52A1\u5668\u5730\u5740\u4E0E\u51ED\u8BC1,\u5199\u5165 ~/.exomind/config.json").option("--base-url <url>", "\u670D\u52A1\u5668\u5730\u5740").option("--api-key <key>", "API Key \u6216\u767B\u5F55 token(\u4E0D\u586B\u5219\u4EA4\u4E92\u8F93\u5165)").action(run(login));
|
|
5135
5238
|
program2.command("me").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u6001\u4E0E\u670D\u52A1\u5668").action(run(whoami));
|
|
5136
5239
|
program2.command("whoami", { hidden: true }).description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u6001\u4E0E\u670D\u52A1\u5668(me \u7684\u65E7\u540D)").action(run(whoami));
|
|
5137
|
-
program2.command("ingest [content...]").description("\u5BFC\u5165\u77E5\u8BC6: \u53C2\u6570\u6587\u672C / --file / stdin / --dir \u76EE\u5F55\u6279\u91CF(\u589E\u91CF)").option("-t, --title <title>", "\u6807\u9898(\u5355\u6587\u4EF6\u6A21\u5F0F)").option("--tag <tag>", "\u6807\u7B7E(\u53EF\u91CD\u590D)", collect, []).option("--file <path>", "\u4ECE\u6587\u4EF6\u8BFB\u53D6\u5185\u5BB9").option("--dir
|
|
5240
|
+
program2.command("ingest [content...]").description("\u5BFC\u5165\u77E5\u8BC6: \u53C2\u6570\u6587\u672C / --file / stdin / --dir \u76EE\u5F55\u6279\u91CF(\u589E\u91CF)").option("-t, --title <title>", "\u6807\u9898(\u5355\u6587\u4EF6\u6A21\u5F0F)").option("--tag <tag>", "\u6807\u7B7E(\u53EF\u91CD\u590D)", collect, []).option("--file <path>", "\u4ECE\u6587\u4EF6\u8BFB\u53D6\u5185\u5BB9").option("--dir [path]", "\u76EE\u5F55\u6279\u91CF\u6444\u5165(\u589E\u91CF: \u5185\u5BB9\u54C8\u5E0C\u8DF3\u8FC7\u672A\u53D8\u6587\u4EF6;\u76EE\u5F55\u53EF\u5199\u5728\u524D: ingest <\u76EE\u5F55> --dir)").option("-r, --recursive", "\u9012\u5F52\u5B50\u76EE\u5F55(\u914D\u5408 --dir)").option("--pattern <glob>", "\u6587\u4EF6\u540D\u5339\u914D,\u9ED8\u8BA4 *.md", "*.md").option("--force", "\u5FFD\u7565 manifest,\u5F3A\u5236\u5168\u91CF\u91CD\u6444(\u914D\u5408 --dir)").option(
|
|
5138
5241
|
"-c, --concurrency <n>",
|
|
5139
5242
|
"\u5E76\u53D1\u6444\u5165\u6570(\u914D\u5408 --dir,\u9ED8\u8BA4 3,\u5F31\u670D\u52A1\u5668\u53CB\u597D)",
|
|
5140
5243
|
(v) => parseInt(v, 10) || 3,
|
|
5141
5244
|
3
|
|
5142
5245
|
).action(run(ingest));
|
|
5246
|
+
program2.command("delete <page...>").description(
|
|
5247
|
+
"\u5220\u9664\u77E5\u8BC6\u9875(\u8F6F\u5220\u9664:\u5165\u670D\u52A1\u7AEF\u56DE\u6536\u7AD9,\u53EF\u6062\u590D)\u3002\u652F\u6301\u8DEF\u5F84(entities/Redis.md)\u6216\u88F8\u5B9E\u4F53\u540D(Redis)"
|
|
5248
|
+
).option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4").action(run((client, opts, args) => deletePage(client, opts, args)));
|
|
5249
|
+
program2.command("trash <action> [target...]").description("\u56DE\u6536\u7AD9: list \u5217\u8868 / restore <\u56DE\u6536\u7AD9\u8DEF\u5F84> \u6062\u590D").option("-p, --page <n>", "\u9875\u7801(list)", "1").action(run((client, opts, args) => trash(client, opts, args)));
|
|
5143
5250
|
program2.command("query [question...]").description("LLM \u95EE\u7B54").option("--tag <tag>", "\u6807\u7B7E\u8FC7\u6EE4(\u53EF\u91CD\u590D)", collect, []).option("--model <name>", "\u6A21\u578B").action(run(query));
|
|
5144
5251
|
program2.command("search [keyword...]").description("\u5168\u6587/\u6DF7\u5408/\u7CBE\u6392\u641C\u7D22").option("-l, --limit <n>", "\u8FD4\u56DE\u6570\u91CF", "10").option("--rerank", "LLM \u7CBE\u6392(\u66F4\u51C6\u4F46\u66F4\u6162)").option("--hybrid", "\u6DF7\u5408\u641C\u7D22(BM25+\u8BED\u4E49)").action(run(search));
|
|
5145
5252
|
program2.command("entity [name...]").description("\u5B9E\u4F53\u8BE6\u60C5 + \u5173\u7CFB").action(run(entity));
|