jinzd-ai-cli 0.4.218 → 0.4.219
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/README.md +1 -0
- package/dist/{batch-7V7OTMUP.js → batch-CHAPYRVM.js} +2 -2
- package/dist/chunk-3I4RZYYO.js +638 -0
- package/dist/{chunk-L4UREAID.js → chunk-4ZN6L6K5.js} +3 -3
- package/dist/{chunk-VGFTM3XT.js → chunk-64NUW3WL.js} +1 -1
- package/dist/{chunk-C2Z42DI5.js → chunk-EGMORH5W.js} +1 -1
- package/dist/{chunk-GX3HSGJX.js → chunk-GEN4O5QH.js} +165 -637
- package/dist/chunk-GGKQHPB3.js +604 -0
- package/dist/{chunk-P4VBLXKS.js → chunk-KIEZBTVD.js} +1 -1
- package/dist/{chunk-H2UIHGHH.js → chunk-QUFYBR6Q.js} +29 -189
- package/dist/{chunk-NTCB7CMT.js → chunk-U7KVU25H.js} +1 -1
- package/dist/{chunk-5CA2TJ5F.js → chunk-VADHBW7T.js} +1 -1
- package/dist/{ci-L6GH2WVC.js → ci-QPP66T53.js} +4 -4
- package/dist/{ci-format-WW7454AY.js → ci-format-5S3EEYRK.js} +2 -2
- package/dist/{constants-NCTFSHDU.js → constants-FJOLBABC.js} +1 -1
- package/dist/doctor-cli-KB2LUDF3.js +17 -0
- package/dist/electron-server.js +419 -116
- package/dist/{hub-CDL6T7CP.js → hub-DIM7SKKY.js} +1 -1
- package/dist/index.js +71 -181
- package/dist/{pr-D6PEKEGK.js → pr-YQGH72N6.js} +4 -4
- package/dist/{run-tests-SWU2XEV7.js → run-tests-GEZSSNJM.js} +2 -2
- package/dist/{run-tests-NXVVKAK2.js → run-tests-O76JIBCW.js} +1 -1
- package/dist/{server-LHYSS6CK.js → server-5E2AIXVX.js} +39 -75
- package/dist/{server-WUT7VYTD.js → server-Z6O3G2LY.js} +9 -9
- package/dist/{task-orchestrator-C5AA2BI5.js → task-orchestrator-5HBW4O64.js} +9 -9
- package/dist/{usage-6ZUUJBI2.js → usage-BMK6M5U3.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-MWKE2TNS.js +0 -129
- package/dist/chunk-OUC75QCF.js +0 -166
- package/dist/doctor-cli-EWMFBP5Q.js +0 -226
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
getConfigDirUsage,
|
|
4
|
-
listRecentCrashes
|
|
5
|
-
} from "./chunk-OUC75QCF.js";
|
|
6
|
-
import {
|
|
7
|
-
ProviderRegistry
|
|
8
|
-
} from "./chunk-QMXC327F.js";
|
|
9
|
-
import {
|
|
10
|
-
getStatsSnapshot,
|
|
11
|
-
getTopFailingTools,
|
|
12
|
-
getTopUsedTools,
|
|
13
|
-
resetStats
|
|
14
|
-
} from "./chunk-MWKE2TNS.js";
|
|
15
|
-
import "./chunk-XPBEJB27.js";
|
|
16
|
-
import {
|
|
17
|
-
ConfigManager
|
|
18
|
-
} from "./chunk-P4VBLXKS.js";
|
|
19
|
-
import "./chunk-TZQHYZKT.js";
|
|
20
|
-
import {
|
|
21
|
-
DEV_STATE_FILE_NAME,
|
|
22
|
-
MEMORY_FILE_NAME,
|
|
23
|
-
VERSION
|
|
24
|
-
} from "./chunk-NTCB7CMT.js";
|
|
25
|
-
import "./chunk-IW3Q7AE5.js";
|
|
26
|
-
|
|
27
|
-
// src/diagnostics/doctor-cli.ts
|
|
28
|
-
import { existsSync, statSync } from "fs";
|
|
29
|
-
import { join } from "path";
|
|
30
|
-
import { platform, release, arch } from "os";
|
|
31
|
-
function compareVersion(a, b) {
|
|
32
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
33
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
34
|
-
const len = Math.max(pa.length, pb.length);
|
|
35
|
-
for (let i = 0; i < len; i++) {
|
|
36
|
-
const da = pa[i] ?? 0;
|
|
37
|
-
const db = pb[i] ?? 0;
|
|
38
|
-
if (da !== db) return da - db;
|
|
39
|
-
}
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
async function checkNpmLatest() {
|
|
43
|
-
const controller = new AbortController();
|
|
44
|
-
const timer = setTimeout(() => controller.abort(), 3e3);
|
|
45
|
-
try {
|
|
46
|
-
const res = await fetch("https://registry.npmjs.org/jinzd-ai-cli/latest", {
|
|
47
|
-
signal: controller.signal,
|
|
48
|
-
headers: { accept: "application/json" }
|
|
49
|
-
});
|
|
50
|
-
if (!res.ok) {
|
|
51
|
-
return { latest: null, status: "skipped", reason: `HTTP ${res.status}` };
|
|
52
|
-
}
|
|
53
|
-
const data = await res.json();
|
|
54
|
-
const latest = typeof data.version === "string" ? data.version : null;
|
|
55
|
-
if (!latest) return { latest: null, status: "skipped", reason: "no version in response" };
|
|
56
|
-
const cmp = compareVersion(latest, VERSION);
|
|
57
|
-
return { latest, status: cmp > 0 ? "outdated" : "up-to-date" };
|
|
58
|
-
} catch (err) {
|
|
59
|
-
const reason = err?.name === "AbortError" ? "timeout (3s)" : err?.message ?? "network error";
|
|
60
|
-
return { latest: null, status: "skipped", reason };
|
|
61
|
-
} finally {
|
|
62
|
-
clearTimeout(timer);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async function collect() {
|
|
66
|
-
const config = new ConfigManager();
|
|
67
|
-
const registry = new ProviderRegistry();
|
|
68
|
-
await registry.initialize(
|
|
69
|
-
(id) => config.getApiKey(id),
|
|
70
|
-
(id) => ({
|
|
71
|
-
baseUrl: config.get("customBaseUrls")[id],
|
|
72
|
-
timeout: config.get("timeouts")[id]
|
|
73
|
-
}),
|
|
74
|
-
config.get("customProviders")
|
|
75
|
-
);
|
|
76
|
-
const providers = registry.listAll().map((p) => ({
|
|
77
|
-
id: p.id,
|
|
78
|
-
displayName: p.displayName,
|
|
79
|
-
configured: p.configured
|
|
80
|
-
}));
|
|
81
|
-
const configDir = config.getConfigDir();
|
|
82
|
-
const checkFile = (label, path) => {
|
|
83
|
-
const exists = existsSync(path);
|
|
84
|
-
let sizeBytes = null;
|
|
85
|
-
if (exists) {
|
|
86
|
-
try {
|
|
87
|
-
sizeBytes = statSync(path).size;
|
|
88
|
-
} catch {
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return { label, path, exists, sizeBytes };
|
|
92
|
-
};
|
|
93
|
-
const npmCheck = await checkNpmLatest();
|
|
94
|
-
return {
|
|
95
|
-
version: VERSION,
|
|
96
|
-
npmCheck,
|
|
97
|
-
node: process.version,
|
|
98
|
-
platform: `${platform()} ${release()} (${arch()})`,
|
|
99
|
-
configDir,
|
|
100
|
-
providers,
|
|
101
|
-
files: [
|
|
102
|
-
checkFile("config.json", join(configDir, "config.json")),
|
|
103
|
-
checkFile("memory.md", join(configDir, MEMORY_FILE_NAME)),
|
|
104
|
-
checkFile("dev-state.md", join(configDir, DEV_STATE_FILE_NAME))
|
|
105
|
-
],
|
|
106
|
-
recentCrashes: listRecentCrashes(5, configDir),
|
|
107
|
-
diskUsage: getConfigDirUsage(configDir),
|
|
108
|
-
toolStats: (() => {
|
|
109
|
-
const all = getStatsSnapshot();
|
|
110
|
-
const totalCalls = all.reduce((a, b) => a + b.calls, 0);
|
|
111
|
-
const totalFailures = all.reduce((a, b) => a + b.failures, 0);
|
|
112
|
-
return {
|
|
113
|
-
totalCalls,
|
|
114
|
-
totalFailures,
|
|
115
|
-
topUsed: getTopUsedTools(5),
|
|
116
|
-
topFailing: getTopFailingTools(5)
|
|
117
|
-
};
|
|
118
|
-
})()
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function formatBytes(n) {
|
|
122
|
-
if (n < 1024) return `${n} B`;
|
|
123
|
-
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
|
124
|
-
if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
125
|
-
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
126
|
-
}
|
|
127
|
-
async function runDoctorCli(options = {}) {
|
|
128
|
-
if (options.resetStats) {
|
|
129
|
-
resetStats();
|
|
130
|
-
process.stdout.write("Tool stats reset.\n");
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const report = await collect();
|
|
134
|
-
if (options.json) {
|
|
135
|
-
process.stdout.write(JSON.stringify(report, null, 2) + "\n");
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const B = "\x1B[1m";
|
|
139
|
-
const D = "\x1B[2m";
|
|
140
|
-
const G = "\x1B[32m";
|
|
141
|
-
const Y = "\x1B[33m";
|
|
142
|
-
const R_ = "\x1B[31m";
|
|
143
|
-
const RESET = "\x1B[0m";
|
|
144
|
-
const out = [];
|
|
145
|
-
out.push("");
|
|
146
|
-
out.push(`${B}\u{1FA7A} AI-CLI Health Check${RESET}`);
|
|
147
|
-
out.push("");
|
|
148
|
-
const nc = report.npmCheck;
|
|
149
|
-
let versionLine = ` version: ${report.version}`;
|
|
150
|
-
if (nc.status === "up-to-date") {
|
|
151
|
-
versionLine += ` ${D}(latest on npm)${RESET}`;
|
|
152
|
-
} else if (nc.status === "outdated" && nc.latest) {
|
|
153
|
-
versionLine += ` ${Y}\u2192 ${nc.latest} available${RESET} ${D}(npm i -g jinzd-ai-cli@latest)${RESET}`;
|
|
154
|
-
} else if (nc.status === "skipped") {
|
|
155
|
-
versionLine += ` ${D}(npm check skipped: ${nc.reason ?? "unknown"})${RESET}`;
|
|
156
|
-
}
|
|
157
|
-
out.push(versionLine);
|
|
158
|
-
out.push(` node: ${report.node}`);
|
|
159
|
-
out.push(` platform: ${report.platform}`);
|
|
160
|
-
out.push(` config: ${report.configDir}`);
|
|
161
|
-
out.push("");
|
|
162
|
-
out.push(`${B}API Keys:${RESET}`);
|
|
163
|
-
for (const p of report.providers) {
|
|
164
|
-
const icon = p.configured ? `${G}\u2713${RESET}` : `${D}\u25CB${RESET}`;
|
|
165
|
-
const status = p.configured ? `${G}configured${RESET}` : `${D}not configured${RESET}`;
|
|
166
|
-
out.push(` ${icon} ${p.id.padEnd(14)} ${status}`);
|
|
167
|
-
}
|
|
168
|
-
out.push("");
|
|
169
|
-
out.push(`${B}Config Files:${RESET}`);
|
|
170
|
-
for (const f of report.files) {
|
|
171
|
-
const icon = f.exists ? `${G}\u2713${RESET}` : `${D}\u2013${RESET}`;
|
|
172
|
-
const extra = f.exists && f.sizeBytes !== null ? ` ${D}(${formatBytes(f.sizeBytes)})${RESET}` : "";
|
|
173
|
-
out.push(` ${icon} ${f.label.padEnd(14)} ${f.exists ? f.path : `${D}(not found)${RESET}`}${extra}`);
|
|
174
|
-
}
|
|
175
|
-
out.push("");
|
|
176
|
-
out.push(`${B}Recent Crashes (last 5):${RESET}`);
|
|
177
|
-
if (report.recentCrashes.length === 0) {
|
|
178
|
-
out.push(` ${D}(none \u2014 clean!)${RESET}`);
|
|
179
|
-
} else {
|
|
180
|
-
for (const c of report.recentCrashes) {
|
|
181
|
-
out.push(` ${R_}\u2717${RESET} ${c.timestamp} ${Y}${c.kind}${RESET}`);
|
|
182
|
-
out.push(` ${D}${c.message}${RESET}`);
|
|
183
|
-
out.push(` ${D}${c.file}${RESET}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
out.push("");
|
|
187
|
-
out.push(`${B}Tool Usage:${RESET}`);
|
|
188
|
-
const ts = report.toolStats;
|
|
189
|
-
out.push(` total: ${ts.totalCalls} calls \xB7 ${ts.totalFailures} failures (${ts.totalCalls ? (ts.totalFailures * 100 / ts.totalCalls).toFixed(1) : "0.0"}%)`);
|
|
190
|
-
if (ts.topUsed.length > 0) {
|
|
191
|
-
out.push(` ${D}top used:${RESET}`);
|
|
192
|
-
for (const t of ts.topUsed) {
|
|
193
|
-
const avg = t.calls ? (t.totalDurationMs / t.calls).toFixed(0) : "0";
|
|
194
|
-
out.push(` ${t.name.padEnd(20)} ${String(t.calls).padStart(6)} calls \xB7 avg ${avg}ms`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (ts.topFailing.length > 0) {
|
|
198
|
-
out.push(` ${D}top failing:${RESET}`);
|
|
199
|
-
for (const t of ts.topFailing) {
|
|
200
|
-
const rate = (t.failures * 100 / Math.max(1, t.calls)).toFixed(1);
|
|
201
|
-
out.push(` ${R_}${t.name.padEnd(20)}${RESET} ${t.failures}/${t.calls} (${rate}%) ${D}${t.lastFailureMessage ?? ""}${RESET}`.slice(0, 200));
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
out.push("");
|
|
205
|
-
const dirAnnotations = {
|
|
206
|
-
models: "semantic search model \u2192 aicli: /index semantic-clear",
|
|
207
|
-
index: "symbol index \u2192 aicli: /index clear",
|
|
208
|
-
history: "conversation history \u2192 auto-pruned after 30 days",
|
|
209
|
-
logs: "crash logs",
|
|
210
|
-
"memory-index": "chat memory index \u2192 aicli: /memory index-clear"
|
|
211
|
-
};
|
|
212
|
-
out.push(`${B}Disk Usage (~/.aicli):${RESET}`);
|
|
213
|
-
out.push(` total: ${formatBytes(report.diskUsage.totalBytes)}`);
|
|
214
|
-
for (const e of report.diskUsage.entries.slice(0, 10)) {
|
|
215
|
-
const note = dirAnnotations[e.name];
|
|
216
|
-
const noteStr = note ? ` ${D}\xB7 ${note}${RESET}` : "";
|
|
217
|
-
out.push(` ${e.name.padEnd(18)} ${formatBytes(e.bytes)}${noteStr}`);
|
|
218
|
-
}
|
|
219
|
-
out.push("");
|
|
220
|
-
out.push(`${G}\u2713 Health check complete${RESET}`);
|
|
221
|
-
out.push("");
|
|
222
|
-
process.stdout.write(out.join("\n"));
|
|
223
|
-
}
|
|
224
|
-
export {
|
|
225
|
-
runDoctorCli
|
|
226
|
-
};
|