chatlab-cli 0.31.0 → 0.31.1
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/{chat-command-CHV7RLBH.mjs → chat-command-MOETAGU5.mjs} +8 -8
- package/dist/{chunk-DBBL74RK.mjs → chunk-2IXPWPLR.mjs} +164 -82
- package/dist/chunk-2IXPWPLR.mjs.map +1 -0
- package/dist/{chunk-YPQ72HMX.mjs → chunk-3VMKS7PU.mjs} +44 -5
- package/dist/chunk-3VMKS7PU.mjs.map +1 -0
- package/dist/{chunk-SNCXU2QL.mjs → chunk-7HBVGVOB.mjs} +2 -2
- package/dist/{chunk-UWWFOEGF.mjs → chunk-DQ45LDKZ.mjs} +19 -2
- package/dist/chunk-DQ45LDKZ.mjs.map +1 -0
- package/dist/{chunk-WQCY45U2.mjs → chunk-E6W2RURS.mjs} +3 -3
- package/dist/{chunk-T64GA5HP.mjs → chunk-KCPGEILH.mjs} +388 -185
- package/dist/chunk-KCPGEILH.mjs.map +1 -0
- package/dist/{chunk-RDCUGC24.mjs → chunk-LJXSUN25.mjs} +2 -2
- package/dist/{chunk-EXD2SXWL.mjs → chunk-N5AGDT7I.mjs} +40 -7
- package/dist/chunk-N5AGDT7I.mjs.map +1 -0
- package/dist/{chunk-JH5RAJT2.mjs → chunk-SZEBCNBB.mjs} +121 -56
- package/dist/chunk-SZEBCNBB.mjs.map +1 -0
- package/dist/{chunk-RD335EMA.mjs → chunk-VOVLPSG6.mjs} +29 -52
- package/dist/chunk-VOVLPSG6.mjs.map +1 -0
- package/dist/{chunk-DA5T64RY.mjs → chunk-ZVWUR7ET.mjs} +2 -2
- package/dist/cli.mjs +9 -7
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +1 -1
- package/dist/{http-3B5ARN7A.mjs → http-M6NHWJZD.mjs} +11 -11
- package/dist/{import-2DZGNSEX.mjs → import-SEYHFXS5.mjs} +9 -7
- package/dist/index.mjs +12 -12
- package/dist/{mcp-44I6FUUQ.mjs → mcp-MIPFYRLV.mjs} +8 -8
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-R3QX6L3L.mjs → src-7OD6RD5V.mjs} +18 -6
- package/dist/{stream-import-VUEL2TTU.mjs → stream-import-AWEHGQJY.mjs} +9 -7
- package/dist/{worker-runtime-GJAOIIZW.mjs → worker-runtime-TGYMASIE.mjs} +5 -5
- package/dist-web/assets/{ActionToolsPanel.vue_vue_type_script_setup_true_lang-CdJT0t2f.js → ActionToolsPanel.vue_vue_type_script_setup_true_lang-CkDGVRXe.js} +4 -4
- package/dist-web/assets/{BufferResource-BPGkshPa.js → BufferResource-CHI62pIA.js} +1 -1
- package/dist-web/assets/{CanvasRenderer-DTKkZhq4.js → CanvasRenderer-OZRoiF0j.js} +1 -1
- package/dist-web/assets/{Filter-CHXKzS2l.js → Filter-DNb5VErW.js} +1 -1
- package/dist-web/assets/{MessageExportModal-h-zl0dx1.js → MessageExportModal-CqP-w7HP.js} +1 -1
- package/dist-web/assets/{PageHeader-CK0hTsdx.js → PageHeader-Ck8ULyZH.js} +1 -1
- package/dist-web/assets/{RelationshipGalaxyCanvas-Dwdy5flh.js → RelationshipGalaxyCanvas-ioRNObb5.js} +3 -3
- package/dist-web/assets/{RelationshipGalaxyThreeCanvas-CtY4TGen.js → RelationshipGalaxyThreeCanvas-L1Y43p1A.js} +1 -1
- package/dist-web/assets/{RenderTargetSystem-BE56mKRG.js → RenderTargetSystem-fJ7D7Chv.js} +1 -1
- package/dist-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-27hMyAUE.js → TimeSelect.vue_vue_type_script_setup_true_lang-7SEaCxDL.js} +1 -1
- package/dist-web/assets/{WebGLRenderer-Dm18dxOf.js → WebGLRenderer-BD3ZUtxH.js} +1 -1
- package/dist-web/assets/{WebGPURenderer-BF6TF-is.js → WebGPURenderer-DZXYsT6D.js} +1 -1
- package/dist-web/assets/{base-CFPyD9Gy.js → base-DTElkJcC.js} +1 -1
- package/dist-web/assets/{browserAll-Cn_CfkXl.js → browserAll-ChT6N6a9.js} +1 -1
- package/dist-web/assets/{dateFormat-BcqNKTQ1.js → dateFormat-D9WibwOu.js} +1 -1
- package/dist-web/assets/{electron-B6xOabTq.js → electron-CIzyGxH_.js} +1 -1
- package/dist-web/assets/{fetch-C_EfVFJi.js → fetch-Avtnh8cJ.js} +1 -1
- package/dist-web/assets/{fetch-DL_u25Ui.js → fetch-BFnrBahy.js} +1 -1
- package/dist-web/assets/fetch-C9rx2isC.js +31 -0
- package/dist-web/assets/{fetch-BPkgnY0R.js → fetch-Ccq_0ecb.js} +1 -1
- package/dist-web/assets/{fetch-DMLq3xPG.js → fetch-CuiQUcO_.js} +1 -1
- package/dist-web/assets/{fetch-BRXmDI_2.js → fetch-CyKILLnB.js} +1 -1
- package/dist-web/assets/fetch-Dd6t3p1r.js +6 -0
- package/dist-web/assets/{fetch-DylpNKCR.js → fetch-DnGx-1_t.js} +1 -1
- package/dist-web/assets/{fetch-CEhUu1Yu.js → fetch-qC7om4QG.js} +1 -1
- package/dist-web/assets/{fetch-etgwVKIw.js → fetch-wSSfDBdV.js} +1 -1
- package/dist-web/assets/index-BH9jI5kV.js +173 -0
- package/dist-web/assets/index-BWtNqcYK.js +22 -0
- package/dist-web/assets/{index-FoTy2Cce.js → index-Bkq7-GBp.js} +1 -1
- package/dist-web/assets/index-Bqr-LkS1.css +1 -0
- package/dist-web/assets/{index-aMIgqj43.js → index-C6qtsaP7.js} +1 -1
- package/dist-web/assets/{index-zZVsV5HB.js → index-ChFGuu70.js} +1 -1
- package/dist-web/assets/{index-C3TnydSt.js → index-CiS20iAR.js} +1 -1
- package/dist-web/assets/{index-BS6loLHW.js → index-CqD6u57u.js} +1 -1
- package/dist-web/assets/{index-CAWO10k1.js → index-CzDG8LVr.js} +2 -2
- package/dist-web/assets/{index-BrTlAl8b.js → index-D0Euk-vQ.js} +1 -1
- package/dist-web/assets/{index-B5S9FnfP.js → index-D26BWhHz.js} +1 -1
- package/dist-web/assets/{index-0x1QPzKZ.js → index-DXHYzIIj.js} +1 -1
- package/dist-web/assets/{index-Chm17wNe.js → index-Dq8u7gMb.js} +2 -2
- package/dist-web/assets/{index-Em6upenM.js → index-u_UH6rDY.js} +3 -3
- package/dist-web/assets/{web-BUZ-dZy0.js → web-BDBdpdK7.js} +1 -1
- package/dist-web/assets/{webworkerAll-BKGP--A4.js → webworkerAll-C3dAOQj4.js} +1 -1
- package/dist-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-DBBL74RK.mjs.map +0 -1
- package/dist/chunk-EXD2SXWL.mjs.map +0 -1
- package/dist/chunk-JH5RAJT2.mjs.map +0 -1
- package/dist/chunk-RD335EMA.mjs.map +0 -1
- package/dist/chunk-T64GA5HP.mjs.map +0 -1
- package/dist/chunk-UWWFOEGF.mjs.map +0 -1
- package/dist/chunk-YPQ72HMX.mjs.map +0 -1
- package/dist-web/assets/fetch-BUm1isWe.js +0 -5
- package/dist-web/assets/fetch-CBOJwwJp.js +0 -17
- package/dist-web/assets/index-DAr_2DlV.js +0 -173
- package/dist-web/assets/index-YADL4XIp.js +0 -22
- package/dist-web/assets/index-_6lck7Bv.css +0 -1
- /package/dist/{chat-command-CHV7RLBH.mjs.map → chat-command-MOETAGU5.mjs.map} +0 -0
- /package/dist/{chunk-SNCXU2QL.mjs.map → chunk-7HBVGVOB.mjs.map} +0 -0
- /package/dist/{chunk-WQCY45U2.mjs.map → chunk-E6W2RURS.mjs.map} +0 -0
- /package/dist/{chunk-RDCUGC24.mjs.map → chunk-LJXSUN25.mjs.map} +0 -0
- /package/dist/{chunk-DA5T64RY.mjs.map → chunk-ZVWUR7ET.mjs.map} +0 -0
- /package/dist/{http-3B5ARN7A.mjs.map → http-M6NHWJZD.mjs.map} +0 -0
- /package/dist/{import-2DZGNSEX.mjs.map → import-SEYHFXS5.mjs.map} +0 -0
- /package/dist/{mcp-44I6FUUQ.mjs.map → mcp-MIPFYRLV.mjs.map} +0 -0
- /package/dist/{src-R3QX6L3L.mjs.map → src-7OD6RD5V.mjs.map} +0 -0
- /package/dist/{stream-import-VUEL2TTU.mjs.map → stream-import-AWEHGQJY.mjs.map} +0 -0
- /package/dist/{worker-runtime-GJAOIIZW.mjs.map → worker-runtime-TGYMASIE.mjs.map} +0 -0
|
@@ -6,14 +6,14 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
createCliRunAgentStream
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-VOVLPSG6.mjs";
|
|
10
|
+
import "./chunk-3VMKS7PU.mjs";
|
|
11
|
+
import "./chunk-E6W2RURS.mjs";
|
|
12
|
+
import "./chunk-KCPGEILH.mjs";
|
|
13
|
+
import "./chunk-7HBVGVOB.mjs";
|
|
14
|
+
import "./chunk-LJXSUN25.mjs";
|
|
15
15
|
import "./chunk-YAQLYL52.mjs";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-DQ45LDKZ.mjs";
|
|
17
17
|
import "./chunk-GFHSSCCR.mjs";
|
|
18
18
|
|
|
19
19
|
// src/ai/chat-command.ts
|
|
@@ -306,4 +306,4 @@ export {
|
|
|
306
306
|
runChatCommand,
|
|
307
307
|
runChatTurn
|
|
308
308
|
};
|
|
309
|
-
//# sourceMappingURL=chat-command-
|
|
309
|
+
//# sourceMappingURL=chat-command-MOETAGU5.mjs.map
|
|
@@ -4,9 +4,13 @@ import { fileURLToPath as __fileURLToPath } from 'url';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
analyzeAutoImport,
|
|
9
|
+
autoImport
|
|
10
|
+
} from "./chunk-N5AGDT7I.mjs";
|
|
7
11
|
import {
|
|
8
12
|
assertCliDataDirCompatible
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZVWUR7ET.mjs";
|
|
10
14
|
import {
|
|
11
15
|
getVersion
|
|
12
16
|
} from "./chunk-5ADKYYNA.mjs";
|
|
@@ -16,18 +20,20 @@ import {
|
|
|
16
20
|
applyPendingNodeDataDirMigrationIfNeeded,
|
|
17
21
|
getSystemLogsDir,
|
|
18
22
|
hasPendingElectronDataWarning
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-E6W2RURS.mjs";
|
|
20
24
|
import {
|
|
21
25
|
AIChatManager,
|
|
22
26
|
IMPORT_IN_PROGRESS_ERROR_KEY,
|
|
23
27
|
applyPreprocessingPipeline,
|
|
24
28
|
computeWordFrequency,
|
|
25
29
|
desensitizeText,
|
|
30
|
+
detectFormat,
|
|
26
31
|
logNativeParserStatus,
|
|
27
32
|
matchesBlacklist,
|
|
28
33
|
mergeRulesForLocale,
|
|
34
|
+
owner_profile_service_exports,
|
|
29
35
|
preprocessMessages
|
|
30
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-KCPGEILH.mjs";
|
|
31
37
|
import {
|
|
32
38
|
resolveCliPath
|
|
33
39
|
} from "./chunk-FJ35V3TE.mjs";
|
|
@@ -37,6 +43,7 @@ import {
|
|
|
37
43
|
DatabaseManager,
|
|
38
44
|
appLogger,
|
|
39
45
|
computeResponseTimeStats,
|
|
46
|
+
createDatabaseManagerAdapter,
|
|
40
47
|
executeParameterizedSql,
|
|
41
48
|
executeReadonlySql,
|
|
42
49
|
getChatOverview,
|
|
@@ -66,10 +73,10 @@ import {
|
|
|
66
73
|
searchMessagesLike,
|
|
67
74
|
setConfigField,
|
|
68
75
|
verifyCliDataPath
|
|
69
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-DQ45LDKZ.mjs";
|
|
70
77
|
|
|
71
78
|
// src/cli.ts
|
|
72
|
-
import * as
|
|
79
|
+
import * as fs3 from "fs";
|
|
73
80
|
import { execSync } from "child_process";
|
|
74
81
|
import { Command } from "commander";
|
|
75
82
|
|
|
@@ -2048,6 +2055,150 @@ function registerManifestCommand(program2, version) {
|
|
|
2048
2055
|
});
|
|
2049
2056
|
}
|
|
2050
2057
|
|
|
2058
|
+
// src/import/command.ts
|
|
2059
|
+
import fs2 from "fs";
|
|
2060
|
+
function normalizeImportError(message) {
|
|
2061
|
+
if (message.startsWith("File not found:")) {
|
|
2062
|
+
return {
|
|
2063
|
+
code: "FILE_NOT_FOUND",
|
|
2064
|
+
message,
|
|
2065
|
+
hint: "Pass an absolute path or a path relative to the current working directory."
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
if (message === IMPORT_IN_PROGRESS_ERROR_KEY) {
|
|
2069
|
+
return {
|
|
2070
|
+
code: "IMPORT_IN_PROGRESS",
|
|
2071
|
+
message: "Another import is already in progress.",
|
|
2072
|
+
hint: "Wait for the active import to finish, then retry."
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
if (message === "error.unrecognized_format" || message.toLowerCase().includes("unrecognized")) {
|
|
2076
|
+
return {
|
|
2077
|
+
code: "UNRECOGNIZED_FORMAT",
|
|
2078
|
+
message: "The chat export format could not be recognized.",
|
|
2079
|
+
hint: 'Run "chatlab formats" and retry with --format <id>.'
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
if (message.includes("sessionId contains invalid characters")) {
|
|
2083
|
+
return {
|
|
2084
|
+
code: "INVALID_SESSION_ID",
|
|
2085
|
+
message,
|
|
2086
|
+
hint: "Use only letters, numbers, underscores, and hyphens (maximum 128 characters)."
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
return { code: "IMPORT_FAILED", message };
|
|
2090
|
+
}
|
|
2091
|
+
function buildImportCommandEnvelope(result, dryRun) {
|
|
2092
|
+
return result.success ? { ok: true, command: "import", data: result, meta: { dryRun, apiVersion: 1 } } : {
|
|
2093
|
+
ok: false,
|
|
2094
|
+
command: "import",
|
|
2095
|
+
error: normalizeImportError(result.error || "Import failed"),
|
|
2096
|
+
meta: { dryRun, apiVersion: 1 }
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
function printHumanResult(result, dryRun) {
|
|
2100
|
+
if (!result.success) {
|
|
2101
|
+
const error = normalizeImportError(result.error || "Import failed");
|
|
2102
|
+
console.error(`
|
|
2103
|
+
|
|
2104
|
+
Import failed: ${error.message}`);
|
|
2105
|
+
if (error.hint) console.error(` Hint: ${error.hint}`);
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
console.log(dryRun ? "\n\nDry run completed." : "\n\nImport succeeded!");
|
|
2109
|
+
console.log(` Mode: ${result.importMode ?? "unknown"}`);
|
|
2110
|
+
if (result.sessionId) console.log(` Session ID: ${result.sessionId}`);
|
|
2111
|
+
if (result.matchedBy) console.log(` Matched by: ${result.matchedBy}`);
|
|
2112
|
+
if (result.createReason) console.log(` Create reason: ${result.createReason}`);
|
|
2113
|
+
if (dryRun && "totalMessageCount" in result && result.totalMessageCount !== void 0) {
|
|
2114
|
+
console.log(` Messages scanned: ${result.totalMessageCount}`);
|
|
2115
|
+
}
|
|
2116
|
+
console.log(` New messages: ${result.newMessageCount ?? 0}`);
|
|
2117
|
+
console.log(` Duplicates skipped: ${result.duplicateCount ?? 0}`);
|
|
2118
|
+
}
|
|
2119
|
+
function printJsonResult(result, dryRun) {
|
|
2120
|
+
process.stdout.write(`${JSON.stringify(buildImportCommandEnvelope(result, dryRun))}
|
|
2121
|
+
`);
|
|
2122
|
+
}
|
|
2123
|
+
async function withJsonDiagnosticsOnStderr(enabled, run2) {
|
|
2124
|
+
if (!enabled) return run2();
|
|
2125
|
+
const originalConsoleLog = console.log;
|
|
2126
|
+
console.log = (...args) => console.error(...args);
|
|
2127
|
+
try {
|
|
2128
|
+
return await run2();
|
|
2129
|
+
} finally {
|
|
2130
|
+
console.log = originalConsoleLog;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
async function applyOwnerProfile(result, systemDir, dbManager) {
|
|
2134
|
+
if (!result.sessionId) return;
|
|
2135
|
+
try {
|
|
2136
|
+
const applied = owner_profile_service_exports.tryApplyOwnerProfile(
|
|
2137
|
+
createDatabaseManagerAdapter(dbManager),
|
|
2138
|
+
new PreferencesManager(systemDir),
|
|
2139
|
+
result.sessionId
|
|
2140
|
+
);
|
|
2141
|
+
if (applied.applied) console.error(`Owner auto-detected: ${applied.ownerId}`);
|
|
2142
|
+
} catch (error) {
|
|
2143
|
+
console.error(`Owner profile apply skipped: ${error instanceof Error ? error.message : error}`);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function registerImportCommand(program2) {
|
|
2147
|
+
program2.command("import <file>").description("Import a chat history file (14+ formats: QQ/WeChat/Telegram/WhatsApp/LINE/Discord, etc.)").option("--session-id <id>", "Force an existing session target, or create with this ID if missing").option("--format <id>", "Specify the input format ID (skip auto-detection)").option("--dry-run", "Analyze the target and message counts without writing data").option("--json", "Output one machine-readable JSON envelope").action(async (file, options) => {
|
|
2148
|
+
if (!fs2.existsSync(file)) {
|
|
2149
|
+
const result2 = { success: false, error: `File not found: ${file}` };
|
|
2150
|
+
if (options.json) printJsonResult(result2, Boolean(options.dryRun));
|
|
2151
|
+
else printHumanResult(result2, Boolean(options.dryRun));
|
|
2152
|
+
process.exitCode = 3;
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
const result = await withJsonDiagnosticsOnStderr(Boolean(options.json), async () => {
|
|
2156
|
+
let dbManager;
|
|
2157
|
+
try {
|
|
2158
|
+
const runtime = initRuntime();
|
|
2159
|
+
dbManager = runtime.dbManager;
|
|
2160
|
+
const nativeBinding = resolveNativeBinding();
|
|
2161
|
+
logNativeParserStatus();
|
|
2162
|
+
const detectedFormat = options.format ? void 0 : detectFormat(file);
|
|
2163
|
+
if (!detectedFormat && !options.format) {
|
|
2164
|
+
return { success: false, error: "error.unrecognized_format" };
|
|
2165
|
+
}
|
|
2166
|
+
if (!options.json) {
|
|
2167
|
+
console.log(`${options.dryRun ? "Analyzing" : "Importing"}: ${file}`);
|
|
2168
|
+
if (detectedFormat) console.log(` Format: ${detectedFormat.name} (${detectedFormat.platform})`);
|
|
2169
|
+
else if (options.format) console.log(` Format ID: ${options.format} (explicit)`);
|
|
2170
|
+
}
|
|
2171
|
+
const importOptions = {
|
|
2172
|
+
formatId: options.format,
|
|
2173
|
+
sessionId: options.sessionId,
|
|
2174
|
+
nativeBinding,
|
|
2175
|
+
onProgress: options.json ? void 0 : (progress) => {
|
|
2176
|
+
process.stdout.write(`\r ${progress.stage}: ${progress.progress}%`);
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
const importResult = options.dryRun ? await analyzeAutoImport(dbManager, file, importOptions) : await autoImport(dbManager, file, importOptions);
|
|
2180
|
+
if (importResult.success && !options.dryRun) {
|
|
2181
|
+
await applyOwnerProfile(importResult, runtime.pathProvider.getSystemDir(), dbManager);
|
|
2182
|
+
}
|
|
2183
|
+
return importResult;
|
|
2184
|
+
} catch (error) {
|
|
2185
|
+
return {
|
|
2186
|
+
success: false,
|
|
2187
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2188
|
+
};
|
|
2189
|
+
} finally {
|
|
2190
|
+
dbManager?.closeAll();
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
if (options.json) printJsonResult(result, Boolean(options.dryRun));
|
|
2194
|
+
else printHumanResult(result, Boolean(options.dryRun));
|
|
2195
|
+
if (!result.success) {
|
|
2196
|
+
if (result.error === "error.unrecognized_format") process.exitCode = 2;
|
|
2197
|
+
else process.exitCode = result.error === IMPORT_IN_PROGRESS_ERROR_KEY ? 4 : 1;
|
|
2198
|
+
}
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2051
2202
|
// src/cli.ts
|
|
2052
2203
|
var program = new Command();
|
|
2053
2204
|
program.name("chatlab").description("ChatLab - Chat history analysis tool").version(getVersion(), "-v, --version");
|
|
@@ -2071,78 +2222,9 @@ program.command("update").description("Update ChatLab CLI to the latest version"
|
|
|
2071
2222
|
});
|
|
2072
2223
|
registerQueryCommands(program);
|
|
2073
2224
|
registerManifestCommand(program, getVersion());
|
|
2074
|
-
program
|
|
2075
|
-
if (!fs2.existsSync(file)) {
|
|
2076
|
-
console.error(`File not found: ${file}`);
|
|
2077
|
-
process.exit(1);
|
|
2078
|
-
}
|
|
2079
|
-
const { autoImport, detectFormat } = await import("./import-2DZGNSEX.mjs");
|
|
2080
|
-
const { dbManager, pathProvider } = initRuntime();
|
|
2081
|
-
const nativeBinding = resolveNativeBinding();
|
|
2082
|
-
logNativeParserStatus();
|
|
2083
|
-
const format = detectFormat(file);
|
|
2084
|
-
if (!format && !options.format) {
|
|
2085
|
-
console.error(`Unrecognized file format: ${file}`);
|
|
2086
|
-
console.error('Use --format <id> to specify manually, or run "chatlab formats" to see supported formats');
|
|
2087
|
-
process.exit(1);
|
|
2088
|
-
}
|
|
2089
|
-
console.log(`Importing: ${file}`);
|
|
2090
|
-
if (format) console.log(` Format: ${format.name} (${format.platform})`);
|
|
2091
|
-
try {
|
|
2092
|
-
const result = await autoImport(dbManager, file, {
|
|
2093
|
-
formatId: options.format,
|
|
2094
|
-
sessionId: options.sessionId,
|
|
2095
|
-
nativeBinding,
|
|
2096
|
-
onProgress: (p) => {
|
|
2097
|
-
process.stdout.write(`\r ${p.stage}: ${p.progress}%`);
|
|
2098
|
-
}
|
|
2099
|
-
});
|
|
2100
|
-
if (result.success) {
|
|
2101
|
-
console.log(`
|
|
2102
|
-
|
|
2103
|
-
Import succeeded!`);
|
|
2104
|
-
console.log(` Session ID: ${result.sessionId}`);
|
|
2105
|
-
console.log(` Mode: ${result.importMode ?? "unknown"}`);
|
|
2106
|
-
if (result.matchedBy) console.log(` Matched by: ${result.matchedBy}`);
|
|
2107
|
-
if (result.createReason) console.log(` Create reason: ${result.createReason}`);
|
|
2108
|
-
if (result.createReason === "ambiguous") {
|
|
2109
|
-
console.warn(" Warning: multiple existing sessions matched, so a new session was created.");
|
|
2110
|
-
}
|
|
2111
|
-
console.log(` New messages: ${result.newMessageCount ?? 0}`);
|
|
2112
|
-
console.log(` Duplicates skipped: ${result.duplicateCount ?? 0}`);
|
|
2113
|
-
if (result.sessionId) {
|
|
2114
|
-
try {
|
|
2115
|
-
const { PreferencesManager: PreferencesManager2, createDatabaseManagerAdapter, ownerProfileService } = await import("./src-R3QX6L3L.mjs");
|
|
2116
|
-
const applied = ownerProfileService.tryApplyOwnerProfile(
|
|
2117
|
-
createDatabaseManagerAdapter(dbManager),
|
|
2118
|
-
new PreferencesManager2(pathProvider.getSystemDir()),
|
|
2119
|
-
result.sessionId
|
|
2120
|
-
);
|
|
2121
|
-
if (applied.applied) {
|
|
2122
|
-
console.log(` Owner auto-detected: ${applied.ownerId}`);
|
|
2123
|
-
}
|
|
2124
|
-
} catch (ownerErr) {
|
|
2125
|
-
console.warn(` Owner profile apply skipped: ${ownerErr instanceof Error ? ownerErr.message : ownerErr}`);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
} else {
|
|
2129
|
-
const errorMessage = result.error === IMPORT_IN_PROGRESS_ERROR_KEY ? "Another import is already in progress. Please retry later." : result.error;
|
|
2130
|
-
console.error(`
|
|
2131
|
-
|
|
2132
|
-
Import failed: ${errorMessage}`);
|
|
2133
|
-
process.exitCode = 1;
|
|
2134
|
-
}
|
|
2135
|
-
} catch (err) {
|
|
2136
|
-
console.error(`
|
|
2137
|
-
|
|
2138
|
-
Import error: ${err instanceof Error ? err.message : err}`);
|
|
2139
|
-
process.exitCode = 1;
|
|
2140
|
-
} finally {
|
|
2141
|
-
dbManager.closeAll();
|
|
2142
|
-
}
|
|
2143
|
-
});
|
|
2225
|
+
registerImportCommand(program);
|
|
2144
2226
|
program.command("formats").description("List all supported chat history formats").action(async () => {
|
|
2145
|
-
const { getSupportedFormats } = await import("./import-
|
|
2227
|
+
const { getSupportedFormats } = await import("./import-SEYHFXS5.mjs");
|
|
2146
2228
|
const formats = getSupportedFormats();
|
|
2147
2229
|
console.log(`${formats.length} supported format(s):
|
|
2148
2230
|
`);
|
|
@@ -2151,11 +2233,11 @@ program.command("formats").description("List all supported chat history formats"
|
|
|
2151
2233
|
}
|
|
2152
2234
|
});
|
|
2153
2235
|
program.command("mcp").description("Start MCP Server (stdio transport, for ClaudeCode / Cursor / AI agents)").action(async () => {
|
|
2154
|
-
const { startCliMcpServer } = await import("./mcp-
|
|
2236
|
+
const { startCliMcpServer } = await import("./mcp-MIPFYRLV.mjs");
|
|
2155
2237
|
await startCliMcpServer();
|
|
2156
2238
|
});
|
|
2157
2239
|
program.command("chat").description("Ask ChatLab AI about an imported chat session").option("--session-id <id>", "Source chat session ID").option("--ai-chat-id <id>", "Existing AI chat ID to continue").option("-q, --question <text>", "Question to ask").option("--json", "Output structured JSON").option("--include-events", "Include all agent stream chunks in JSON output").option("--no-stream", "Disable streaming output").option("--locale <locale>", "AI response locale", "zh-CN").action(async (options) => {
|
|
2158
|
-
const { runChatCommand } = await import("./chat-command-
|
|
2240
|
+
const { runChatCommand } = await import("./chat-command-MOETAGU5.mjs");
|
|
2159
2241
|
const { dbManager, pathProvider } = initRuntime();
|
|
2160
2242
|
const aiChatManager = new AIChatManager(pathProvider.getAiDataDir(), { nativeBinding: resolveNativeBinding() });
|
|
2161
2243
|
try {
|
|
@@ -2191,12 +2273,12 @@ program.command("start").description("Start ChatLab (HTTP API + Web UI)").option
|
|
|
2191
2273
|
});
|
|
2192
2274
|
return;
|
|
2193
2275
|
}
|
|
2194
|
-
const { startHttpServer } = await import("./http-
|
|
2276
|
+
const { startHttpServer } = await import("./http-M6NHWJZD.mjs");
|
|
2195
2277
|
const port = parseInt(options.port, 10);
|
|
2196
2278
|
let webRoot;
|
|
2197
2279
|
if (!options.headless) {
|
|
2198
2280
|
const webDir = resolveCliPath("dist-web");
|
|
2199
|
-
if (
|
|
2281
|
+
if (fs3.existsSync(webDir)) {
|
|
2200
2282
|
webRoot = webDir;
|
|
2201
2283
|
} else {
|
|
2202
2284
|
console.warn("Warning: dist-web/ not found, starting in API-only mode");
|
|
@@ -2238,7 +2320,7 @@ Press Ctrl+C to stop.
|
|
|
2238
2320
|
}
|
|
2239
2321
|
const shutdown = async () => {
|
|
2240
2322
|
console.log("\nShutting down...");
|
|
2241
|
-
const { stopHttpServer } = await import("./http-
|
|
2323
|
+
const { stopHttpServer } = await import("./http-M6NHWJZD.mjs");
|
|
2242
2324
|
await stopHttpServer();
|
|
2243
2325
|
process.exit(0);
|
|
2244
2326
|
};
|
|
@@ -2331,4 +2413,4 @@ if (isDirectRun) {
|
|
|
2331
2413
|
export {
|
|
2332
2414
|
run
|
|
2333
2415
|
};
|
|
2334
|
-
//# sourceMappingURL=chunk-
|
|
2416
|
+
//# sourceMappingURL=chunk-2IXPWPLR.mjs.map
|