exomind 0.2.3 → 0.2.4
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 +58 -38
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -965,7 +965,7 @@ var require_command = __commonJS({
|
|
|
965
965
|
"use strict";
|
|
966
966
|
var EventEmitter = require("events").EventEmitter;
|
|
967
967
|
var childProcess = require("child_process");
|
|
968
|
-
var
|
|
968
|
+
var path7 = require("path");
|
|
969
969
|
var fs7 = require("fs");
|
|
970
970
|
var process2 = require("process");
|
|
971
971
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1898,9 +1898,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1898
1898
|
let launchWithNode = false;
|
|
1899
1899
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1900
1900
|
function findFile(baseDir, baseName) {
|
|
1901
|
-
const localBin =
|
|
1901
|
+
const localBin = path7.resolve(baseDir, baseName);
|
|
1902
1902
|
if (fs7.existsSync(localBin)) return localBin;
|
|
1903
|
-
if (sourceExt.includes(
|
|
1903
|
+
if (sourceExt.includes(path7.extname(baseName))) return void 0;
|
|
1904
1904
|
const foundExt = sourceExt.find(
|
|
1905
1905
|
(ext) => fs7.existsSync(`${localBin}${ext}`)
|
|
1906
1906
|
);
|
|
@@ -1918,17 +1918,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1918
1918
|
} catch (err) {
|
|
1919
1919
|
resolvedScriptPath = this._scriptPath;
|
|
1920
1920
|
}
|
|
1921
|
-
executableDir =
|
|
1922
|
-
|
|
1921
|
+
executableDir = path7.resolve(
|
|
1922
|
+
path7.dirname(resolvedScriptPath),
|
|
1923
1923
|
executableDir
|
|
1924
1924
|
);
|
|
1925
1925
|
}
|
|
1926
1926
|
if (executableDir) {
|
|
1927
1927
|
let localFile = findFile(executableDir, executableFile);
|
|
1928
1928
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1929
|
-
const legacyName =
|
|
1929
|
+
const legacyName = path7.basename(
|
|
1930
1930
|
this._scriptPath,
|
|
1931
|
-
|
|
1931
|
+
path7.extname(this._scriptPath)
|
|
1932
1932
|
);
|
|
1933
1933
|
if (legacyName !== this._name) {
|
|
1934
1934
|
localFile = findFile(
|
|
@@ -1939,7 +1939,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1939
1939
|
}
|
|
1940
1940
|
executableFile = localFile || executableFile;
|
|
1941
1941
|
}
|
|
1942
|
-
launchWithNode = sourceExt.includes(
|
|
1942
|
+
launchWithNode = sourceExt.includes(path7.extname(executableFile));
|
|
1943
1943
|
let proc;
|
|
1944
1944
|
if (process2.platform !== "win32") {
|
|
1945
1945
|
if (launchWithNode) {
|
|
@@ -2779,7 +2779,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2779
2779
|
* @return {Command}
|
|
2780
2780
|
*/
|
|
2781
2781
|
nameFromFilename(filename) {
|
|
2782
|
-
this._name =
|
|
2782
|
+
this._name = path7.basename(filename, path7.extname(filename));
|
|
2783
2783
|
return this;
|
|
2784
2784
|
}
|
|
2785
2785
|
/**
|
|
@@ -2793,9 +2793,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2793
2793
|
* @param {string} [path]
|
|
2794
2794
|
* @return {(string|null|Command)}
|
|
2795
2795
|
*/
|
|
2796
|
-
executableDir(
|
|
2797
|
-
if (
|
|
2798
|
-
this._executableDir =
|
|
2796
|
+
executableDir(path8) {
|
|
2797
|
+
if (path8 === void 0) return this._executableDir;
|
|
2798
|
+
this._executableDir = path8;
|
|
2799
2799
|
return this;
|
|
2800
2800
|
}
|
|
2801
2801
|
/**
|
|
@@ -3119,7 +3119,7 @@ var {
|
|
|
3119
3119
|
// package.json
|
|
3120
3120
|
var package_default = {
|
|
3121
3121
|
name: "exomind",
|
|
3122
|
-
version: "0.2.
|
|
3122
|
+
version: "0.2.4",
|
|
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"
|
|
@@ -3624,6 +3624,9 @@ async function runHook(client) {
|
|
|
3624
3624
|
}
|
|
3625
3625
|
}
|
|
3626
3626
|
|
|
3627
|
+
// src/commands/ingest.ts
|
|
3628
|
+
var path5 = __toESM(require("path"));
|
|
3629
|
+
|
|
3627
3630
|
// src/ingest_dir.ts
|
|
3628
3631
|
var fs5 = __toESM(require("fs"));
|
|
3629
3632
|
var path4 = __toESM(require("path"));
|
|
@@ -3651,6 +3654,14 @@ function saveManifest(m) {
|
|
|
3651
3654
|
} catch {
|
|
3652
3655
|
}
|
|
3653
3656
|
}
|
|
3657
|
+
function recordFile(manifest, absPath, rawContent, title) {
|
|
3658
|
+
manifest[absPath] = {
|
|
3659
|
+
hash: sha256(rawContent),
|
|
3660
|
+
ingested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3661
|
+
title,
|
|
3662
|
+
size: rawContent.length
|
|
3663
|
+
};
|
|
3664
|
+
}
|
|
3654
3665
|
function cleanupStale(m, dir, currentFiles) {
|
|
3655
3666
|
const prefix = path3.resolve(dir) + path3.sep;
|
|
3656
3667
|
const current = new Set(currentFiles);
|
|
@@ -3726,7 +3737,7 @@ async function runDirIngestest(client, opts, dir) {
|
|
|
3726
3737
|
const plan = planIngestest(files, manifest, !!opts.force);
|
|
3727
3738
|
const total = files.length;
|
|
3728
3739
|
process.stderr.write(
|
|
3729
|
-
`\u76EE\u5F55 ${dir}: ${total} \u6587\u4EF6 \
|
|
3740
|
+
`\u76EE\u5F55 ${dir}: ${total} \u6587\u4EF6 \u2014 \u5F85\u6444\u5165 ${plan.toIngest.length},\u8DF3\u8FC7 ${plan.toSkip.length}
|
|
3730
3741
|
`
|
|
3731
3742
|
);
|
|
3732
3743
|
let added = 0;
|
|
@@ -3735,28 +3746,28 @@ async function runDirIngestest(client, opts, dir) {
|
|
|
3735
3746
|
for (let i = 0; i < plan.toIngest.length; i++) {
|
|
3736
3747
|
const f = plan.toIngest[i];
|
|
3737
3748
|
const prev = manifest[f.path];
|
|
3738
|
-
process.stderr.write(
|
|
3739
|
-
|
|
3740
|
-
`
|
|
3741
|
-
);
|
|
3749
|
+
process.stderr.write(`\u23F3 [${i + 1}/${plan.toIngest.length}] ${path4.basename(f.path)}\u2026
|
|
3750
|
+
`);
|
|
3742
3751
|
try {
|
|
3743
|
-
await client.post(
|
|
3752
|
+
const res = await client.post(
|
|
3744
3753
|
"/ingest",
|
|
3745
3754
|
{ content: f.content, title: f.title, tags: opts.tag },
|
|
3746
3755
|
{ timeoutMs: opTimeout(3e5) }
|
|
3747
3756
|
);
|
|
3748
|
-
manifest
|
|
3749
|
-
hash: f.hash,
|
|
3750
|
-
ingested_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3751
|
-
title: f.title,
|
|
3752
|
-
size: f.content.length
|
|
3753
|
-
};
|
|
3754
|
-
if (prev) updated++;
|
|
3755
|
-
else added++;
|
|
3757
|
+
recordFile(manifest, f.path, f.content, f.title);
|
|
3756
3758
|
saveManifest(manifest);
|
|
3759
|
+
if (prev) {
|
|
3760
|
+
updated++;
|
|
3761
|
+
process.stderr.write(` ${green("\u2713")} \u66F4\u65B0 \u2014 \u5B9E\u4F53 ${res.entities ?? 0}/\u6982\u5FF5 ${res.concepts ?? 0}
|
|
3762
|
+
`);
|
|
3763
|
+
} else {
|
|
3764
|
+
added++;
|
|
3765
|
+
process.stderr.write(` ${green("\u2713")} \u65B0\u589E \u2014 \u5B9E\u4F53 ${res.entities ?? 0}/\u6982\u5FF5 ${res.concepts ?? 0}
|
|
3766
|
+
`);
|
|
3767
|
+
}
|
|
3757
3768
|
} catch (e) {
|
|
3758
3769
|
failed++;
|
|
3759
|
-
process.stderr.write(` ${red("\u2717")} ${
|
|
3770
|
+
process.stderr.write(` ${red("\u2717")} ${e.message}
|
|
3760
3771
|
`);
|
|
3761
3772
|
}
|
|
3762
3773
|
}
|
|
@@ -3776,8 +3787,12 @@ async function runDirIngestest(client, opts, dir) {
|
|
|
3776
3787
|
async function ingest(client, opts, args) {
|
|
3777
3788
|
if (opts.dir) return runDirIngestest(client, opts, opts.dir);
|
|
3778
3789
|
let content = "";
|
|
3790
|
+
let fileAbs = null;
|
|
3791
|
+
let fileRaw = null;
|
|
3779
3792
|
if (opts.file) {
|
|
3780
|
-
|
|
3793
|
+
fileRaw = readFileText(opts.file);
|
|
3794
|
+
content = fileRaw;
|
|
3795
|
+
fileAbs = path5.resolve(opts.file);
|
|
3781
3796
|
} else if (args.length && args[0] === "-") {
|
|
3782
3797
|
content = await readStdinForced();
|
|
3783
3798
|
} else if (args.length) {
|
|
@@ -3797,6 +3812,11 @@ async function ingest(client, opts, args) {
|
|
|
3797
3812
|
if (opts.tag && opts.tag.length) body.tags = opts.tag;
|
|
3798
3813
|
hint("\u23F3 \u6444\u5165\u4E2D: \u670D\u52A1\u5668\u7528 LLM \u62BD\u53D6\u5B9E\u4F53/\u5173\u7CFB,\u957F\u5185\u5BB9\u53EF\u80FD 1-3 \u5206\u949F\u2026");
|
|
3799
3814
|
const result = await client.post("/ingest", body, { timeoutMs: opTimeout(3e5) });
|
|
3815
|
+
if (fileAbs && fileRaw !== null) {
|
|
3816
|
+
const man = loadManifest();
|
|
3817
|
+
recordFile(man, fileAbs, fileRaw, opts.title || path5.basename(fileAbs));
|
|
3818
|
+
saveManifest(man);
|
|
3819
|
+
}
|
|
3800
3820
|
output(result, () => {
|
|
3801
3821
|
console.log(ok("\u5DF2\u5BFC\u5165\u670D\u52A1\u5668\u77E5\u8BC6\u5E93"));
|
|
3802
3822
|
if (opts.title) console.log(dim(` \u6807\u9898: ${opts.title}`));
|
|
@@ -4096,10 +4116,10 @@ async function whoami(client) {
|
|
|
4096
4116
|
|
|
4097
4117
|
// src/commands/install.ts
|
|
4098
4118
|
var fs6 = __toESM(require("fs"));
|
|
4099
|
-
var
|
|
4119
|
+
var path6 = __toESM(require("path"));
|
|
4100
4120
|
var os2 = __toESM(require("os"));
|
|
4101
|
-
var PKG_ROOT =
|
|
4102
|
-
var SKILL_SRC =
|
|
4121
|
+
var PKG_ROOT = path6.resolve(__dirname, "..");
|
|
4122
|
+
var SKILL_SRC = path6.join(PKG_ROOT, "skill", "SKILL.md");
|
|
4103
4123
|
function readJson2(file) {
|
|
4104
4124
|
try {
|
|
4105
4125
|
return JSON.parse(fs6.readFileSync(file, "utf-8"));
|
|
@@ -4112,22 +4132,22 @@ function backup(file) {
|
|
|
4112
4132
|
const bak = `${file}.bak-${Date.now()}`;
|
|
4113
4133
|
try {
|
|
4114
4134
|
fs6.copyFileSync(file, bak);
|
|
4115
|
-
console.log(dim(` (\u5DF2\u5907\u4EFD\u539F\u914D\u7F6E \u2192 ${
|
|
4135
|
+
console.log(dim(` (\u5DF2\u5907\u4EFD\u539F\u914D\u7F6E \u2192 ${path6.basename(bak)})`));
|
|
4116
4136
|
} catch {
|
|
4117
4137
|
}
|
|
4118
4138
|
}
|
|
4119
4139
|
async function install(_client, opts) {
|
|
4120
|
-
const claudeDir =
|
|
4121
|
-
const skillDestDir =
|
|
4140
|
+
const claudeDir = path6.join(os2.homedir(), ".claude");
|
|
4141
|
+
const skillDestDir = path6.join(claudeDir, "skills", "exomind");
|
|
4122
4142
|
if (!fs6.existsSync(SKILL_SRC)) {
|
|
4123
4143
|
throw new Error(`skill \u6E90\u4E0D\u5B58\u5728: ${SKILL_SRC}(npm \u5305\u53EF\u80FD\u635F\u574F,\u6216\u5F00\u53D1\u6A21\u5F0F\u4E0B\u672A\u6784\u5EFA)`);
|
|
4124
4144
|
}
|
|
4125
4145
|
fs6.mkdirSync(skillDestDir, { recursive: true });
|
|
4126
|
-
fs6.copyFileSync(SKILL_SRC,
|
|
4146
|
+
fs6.copyFileSync(SKILL_SRC, path6.join(skillDestDir, "SKILL.md"));
|
|
4127
4147
|
console.log(ok("\u5DF2\u5B89\u88C5 Claude Code skill"));
|
|
4128
4148
|
console.log(dim(` \u2192 ${skillDestDir}/SKILL.md`));
|
|
4129
4149
|
if (opts.withHook) {
|
|
4130
|
-
const settingsFile =
|
|
4150
|
+
const settingsFile = path6.join(claudeDir, "settings.json");
|
|
4131
4151
|
fs6.mkdirSync(claudeDir, { recursive: true });
|
|
4132
4152
|
backup(settingsFile);
|
|
4133
4153
|
const settings = readJson2(settingsFile) ?? {};
|
|
@@ -4223,7 +4243,7 @@ program2.command("hook").description("UserPromptSubmit \u94A9\u5B50(\u7531 Claud
|
|
|
4223
4243
|
program2.command("install").description("\u5B89\u88C5 Claude Code skill(\u53EF\u9009 --with-hook \u5199\u5165 UserPromptSubmit)").option("--with-hook", "\u540C\u65F6\u5199\u5165 ~/.claude/settings.json \u7684 hook").action(run(install));
|
|
4224
4244
|
async function main() {
|
|
4225
4245
|
const first = process.argv[2];
|
|
4226
|
-
if (first &&
|
|
4246
|
+
if (first && /^(-v|--version)$/.test(first)) {
|
|
4227
4247
|
console.log(VERSION);
|
|
4228
4248
|
process.exit(0);
|
|
4229
4249
|
}
|