chattercatcher 0.1.7 → 0.1.8
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
|
@@ -151,6 +151,75 @@ import { input, password, select, confirm, number } from "@inquirer/prompts";
|
|
|
151
151
|
import { Command } from "commander";
|
|
152
152
|
import fs14 from "fs/promises";
|
|
153
153
|
|
|
154
|
+
// package.json
|
|
155
|
+
var package_default = {
|
|
156
|
+
name: "chattercatcher",
|
|
157
|
+
version: "0.1.8",
|
|
158
|
+
description: "\u672C\u5730\u4F18\u5148\u7684\u98DE\u4E66/Lark \u5BB6\u5EAD\u7FA4\u77E5\u8BC6\u5E93\u673A\u5668\u4EBA",
|
|
159
|
+
type: "module",
|
|
160
|
+
main: "dist/index.js",
|
|
161
|
+
types: "dist/index.d.ts",
|
|
162
|
+
homepage: "https://github.com/FlashingChen2024/chattercatcher#readme",
|
|
163
|
+
repository: {
|
|
164
|
+
type: "git",
|
|
165
|
+
url: "git+https://github.com/FlashingChen2024/chattercatcher.git"
|
|
166
|
+
},
|
|
167
|
+
bugs: {
|
|
168
|
+
url: "https://github.com/FlashingChen2024/chattercatcher/issues"
|
|
169
|
+
},
|
|
170
|
+
bin: {
|
|
171
|
+
chattercatcher: "dist/cli.js"
|
|
172
|
+
},
|
|
173
|
+
files: [
|
|
174
|
+
"assets",
|
|
175
|
+
"dist",
|
|
176
|
+
"docs",
|
|
177
|
+
"README.md",
|
|
178
|
+
"AGENTS.md"
|
|
179
|
+
],
|
|
180
|
+
directories: {
|
|
181
|
+
doc: "docs"
|
|
182
|
+
},
|
|
183
|
+
scripts: {
|
|
184
|
+
build: "tsup",
|
|
185
|
+
dev: "tsx src/cli.ts",
|
|
186
|
+
lint: "tsc --noEmit",
|
|
187
|
+
typecheck: "tsc --noEmit",
|
|
188
|
+
test: "vitest run"
|
|
189
|
+
},
|
|
190
|
+
keywords: [
|
|
191
|
+
"feishu",
|
|
192
|
+
"lark",
|
|
193
|
+
"rag",
|
|
194
|
+
"local-first",
|
|
195
|
+
"knowledge-base"
|
|
196
|
+
],
|
|
197
|
+
author: "FlashingChen2024",
|
|
198
|
+
license: "MIT",
|
|
199
|
+
dependencies: {
|
|
200
|
+
"@inquirer/prompts": "^8.4.2",
|
|
201
|
+
"@lancedb/lancedb": "0.23.0",
|
|
202
|
+
"@larksuiteoapi/node-sdk": "^1.62.0",
|
|
203
|
+
"better-sqlite3": "^12.9.0",
|
|
204
|
+
commander: "^14.0.3",
|
|
205
|
+
fastify: "^5.8.5",
|
|
206
|
+
mammoth: "^1.12.0",
|
|
207
|
+
"pdf-parse": "^2.4.5",
|
|
208
|
+
pino: "^10.3.1",
|
|
209
|
+
zod: "^4.3.6"
|
|
210
|
+
},
|
|
211
|
+
devDependencies: {
|
|
212
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
213
|
+
"@types/node": "^25.6.0",
|
|
214
|
+
"@types/yazl": "^3.3.1",
|
|
215
|
+
tsup: "^8.5.1",
|
|
216
|
+
tsx: "^4.21.0",
|
|
217
|
+
typescript: "^6.0.3",
|
|
218
|
+
vitest: "^4.1.5",
|
|
219
|
+
yazl: "^3.3.1"
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
154
223
|
// src/config/store.ts
|
|
155
224
|
import fs from "fs/promises";
|
|
156
225
|
import path3 from "path";
|
|
@@ -2912,6 +2981,108 @@ async function processMessagesNow(input2) {
|
|
|
2912
2981
|
}
|
|
2913
2982
|
}
|
|
2914
2983
|
|
|
2984
|
+
// src/update/npm-updater.ts
|
|
2985
|
+
import { execFile } from "child_process";
|
|
2986
|
+
import { promisify } from "util";
|
|
2987
|
+
var execFileAsync = promisify(execFile);
|
|
2988
|
+
var packageName = "chattercatcher";
|
|
2989
|
+
var installArgs = ["install", "-g", `${packageName}@latest`];
|
|
2990
|
+
var latestVersionArgs = ["view", packageName, "version", "--json"];
|
|
2991
|
+
function formatCommand(command, args) {
|
|
2992
|
+
return [command, ...args].join(" ");
|
|
2993
|
+
}
|
|
2994
|
+
function getErrorMessage(error) {
|
|
2995
|
+
if (error instanceof Error) {
|
|
2996
|
+
return error.message;
|
|
2997
|
+
}
|
|
2998
|
+
return String(error);
|
|
2999
|
+
}
|
|
3000
|
+
function parseLatestVersion(stdout) {
|
|
3001
|
+
const trimmed = stdout.trim();
|
|
3002
|
+
if (!trimmed) {
|
|
3003
|
+
throw new Error("npm registry returned an empty version");
|
|
3004
|
+
}
|
|
3005
|
+
let parsed;
|
|
3006
|
+
try {
|
|
3007
|
+
parsed = JSON.parse(trimmed);
|
|
3008
|
+
} catch {
|
|
3009
|
+
throw new Error("npm registry returned an invalid version");
|
|
3010
|
+
}
|
|
3011
|
+
if (typeof parsed !== "string" || !parsed) {
|
|
3012
|
+
throw new Error("npm registry returned an invalid version");
|
|
3013
|
+
}
|
|
3014
|
+
return parsed;
|
|
3015
|
+
}
|
|
3016
|
+
function compareVersions(left, right) {
|
|
3017
|
+
const leftParts = left.split(".").map((part) => Number(part));
|
|
3018
|
+
const rightParts = right.split(".").map((part) => Number(part));
|
|
3019
|
+
const length = Math.max(leftParts.length, rightParts.length);
|
|
3020
|
+
for (let index2 = 0; index2 < length; index2 += 1) {
|
|
3021
|
+
const leftPart = leftParts[index2] ?? 0;
|
|
3022
|
+
const rightPart = rightParts[index2] ?? 0;
|
|
3023
|
+
if (leftPart > rightPart) {
|
|
3024
|
+
return 1;
|
|
3025
|
+
}
|
|
3026
|
+
if (leftPart < rightPart) {
|
|
3027
|
+
return -1;
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
return 0;
|
|
3031
|
+
}
|
|
3032
|
+
async function defaultUpdateCommandRunner(command, args) {
|
|
3033
|
+
const { stdout, stderr } = await execFileAsync(command, args);
|
|
3034
|
+
return { stdout, stderr };
|
|
3035
|
+
}
|
|
3036
|
+
async function updateChatterCatcher(options) {
|
|
3037
|
+
const runner = options.runner ?? defaultUpdateCommandRunner;
|
|
3038
|
+
const command = formatCommand("npm", installArgs);
|
|
3039
|
+
let latestVersion;
|
|
3040
|
+
try {
|
|
3041
|
+
const output = await runner("npm", latestVersionArgs);
|
|
3042
|
+
latestVersion = parseLatestVersion(output.stdout);
|
|
3043
|
+
} catch (error) {
|
|
3044
|
+
return {
|
|
3045
|
+
status: "query-failed",
|
|
3046
|
+
currentVersion: options.currentVersion,
|
|
3047
|
+
command,
|
|
3048
|
+
error: getErrorMessage(error)
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
if (compareVersions(latestVersion, options.currentVersion) <= 0) {
|
|
3052
|
+
return {
|
|
3053
|
+
status: "up-to-date",
|
|
3054
|
+
currentVersion: options.currentVersion,
|
|
3055
|
+
latestVersion,
|
|
3056
|
+
command
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
if (options.dryRun) {
|
|
3060
|
+
return {
|
|
3061
|
+
status: "dry-run",
|
|
3062
|
+
currentVersion: options.currentVersion,
|
|
3063
|
+
latestVersion,
|
|
3064
|
+
command
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
try {
|
|
3068
|
+
await runner("npm", installArgs);
|
|
3069
|
+
} catch (error) {
|
|
3070
|
+
return {
|
|
3071
|
+
status: "install-failed",
|
|
3072
|
+
currentVersion: options.currentVersion,
|
|
3073
|
+
latestVersion,
|
|
3074
|
+
command,
|
|
3075
|
+
error: getErrorMessage(error)
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
3078
|
+
return {
|
|
3079
|
+
status: "updated",
|
|
3080
|
+
currentVersion: options.currentVersion,
|
|
3081
|
+
latestVersion,
|
|
3082
|
+
command
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
|
|
2915
3086
|
// src/web/server.ts
|
|
2916
3087
|
import Fastify from "fastify";
|
|
2917
3088
|
function buildHtml() {
|
|
@@ -3429,7 +3600,7 @@ function printSettings(config, secrets) {
|
|
|
3429
3600
|
2
|
|
3430
3601
|
));
|
|
3431
3602
|
}
|
|
3432
|
-
program.name("chattercatcher").description("\u672C\u5730\u4F18\u5148\u7684\u98DE\u4E66/Lark \u5BB6\u5EAD\u7FA4\u77E5\u8BC6\u673A\u5668\u4EBA").version(
|
|
3603
|
+
program.name("chattercatcher").description("\u672C\u5730\u4F18\u5148\u7684\u98DE\u4E66/Lark \u5BB6\u5EAD\u7FA4\u77E5\u8BC6\u673A\u5668\u4EBA").version(package_default.version);
|
|
3433
3604
|
program.command("setup").description("\u4EA4\u4E92\u5F0F\u521D\u59CB\u5316\u914D\u7F6E").action(async () => {
|
|
3434
3605
|
const { config, secrets } = await ensureConfigFiles();
|
|
3435
3606
|
await promptForConfiguration(config, secrets);
|
|
@@ -3465,6 +3636,32 @@ program.command("doctor").description("\u68C0\u67E5\u672C\u5730\u914D\u7F6E\u300
|
|
|
3465
3636
|
const checks = await runDoctor(config, secrets, { online: options.online });
|
|
3466
3637
|
console.log(formatDoctorChecks(checks));
|
|
3467
3638
|
});
|
|
3639
|
+
program.command("update").description("\u5347\u7EA7 ChatterCatcher \u5230 npm \u6700\u65B0\u7248\u672C").option("--dry-run", "\u53EA\u68C0\u67E5\u5E76\u663E\u793A\u5C06\u6267\u884C\u7684\u5347\u7EA7\u547D\u4EE4").action(async (options) => {
|
|
3640
|
+
const result = await updateChatterCatcher({ currentVersion: package_default.version, dryRun: options.dryRun });
|
|
3641
|
+
if (result.status === "up-to-date") {
|
|
3642
|
+
console.log(`ChatterCatcher \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF1A${result.currentVersion}`);
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
if (result.status === "dry-run") {
|
|
3646
|
+
console.log(`\u5F53\u524D\u7248\u672C\uFF1A${result.currentVersion}`);
|
|
3647
|
+
console.log(`\u6700\u65B0\u7248\u672C\uFF1A${result.latestVersion}`);
|
|
3648
|
+
console.log(`\u5C06\u6267\u884C\uFF1A${result.command}`);
|
|
3649
|
+
return;
|
|
3650
|
+
}
|
|
3651
|
+
if (result.status === "updated") {
|
|
3652
|
+
console.log(`\u5347\u7EA7\u5B8C\u6210\uFF1A${result.currentVersion} -> ${result.latestVersion}`);
|
|
3653
|
+
console.log("\u8BF7\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF\u6216\u91CD\u65B0\u8FD0\u884C chattercatcher --version \u786E\u8BA4\u7248\u672C\u3002");
|
|
3654
|
+
return;
|
|
3655
|
+
}
|
|
3656
|
+
if (result.status === "query-failed") {
|
|
3657
|
+
console.error(`\u65E0\u6CD5\u83B7\u53D6\u6700\u65B0\u7248\u672C\uFF1A${result.error}`);
|
|
3658
|
+
process.exitCode = 1;
|
|
3659
|
+
return;
|
|
3660
|
+
}
|
|
3661
|
+
console.error(`\u5347\u7EA7\u5931\u8D25\uFF1A${result.error}`);
|
|
3662
|
+
console.error(`\u53EF\u624B\u52A8\u8FD0\u884C\uFF1A${result.command}`);
|
|
3663
|
+
process.exitCode = 1;
|
|
3664
|
+
});
|
|
3468
3665
|
var gateway = program.command("gateway").description("\u7BA1\u7406\u672C\u5730\u98DE\u4E66 Gateway");
|
|
3469
3666
|
async function startGatewayForegroundCommand() {
|
|
3470
3667
|
const config = await loadConfig();
|