hypercore-cli 1.1.1 → 1.3.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/LICENSE +92 -21
- package/README.md +8 -1
- package/dist/App-YMX7FSXR.js +1 -0
- package/dist/api-Q2TX5JJL.js +1 -0
- package/dist/auth-X6CUT3DW.js +1 -0
- package/dist/background-ACODXSUG.js +1 -0
- package/dist/backlog-JD2IM336.js +1 -0
- package/dist/chunk-2QI2IU2V.js +1 -0
- package/dist/chunk-3KFRDIPQ.js +1 -0
- package/dist/chunk-42C5J7PN.js +1 -0
- package/dist/chunk-4D7XVJ7Q.js +1 -0
- package/dist/chunk-545IGTXV.js +1 -0
- package/dist/chunk-5KUSGQP2.js +1 -0
- package/dist/chunk-AUQ64BK2.js +1 -0
- package/dist/chunk-AV244H5C.js +1 -0
- package/dist/chunk-BQVBEFS4.js +1 -0
- package/dist/chunk-BYWQLFP2.js +1 -0
- package/dist/chunk-COITWWZJ.js +1 -0
- package/dist/chunk-CR7UUJVX.js +1 -0
- package/dist/chunk-E3MULLBX.js +1 -0
- package/dist/chunk-EWBV7YPP.js +1 -0
- package/dist/chunk-EZHYVJGQ.js +1 -0
- package/dist/chunk-FAKXBY7Q.js +1 -0
- package/dist/chunk-FHGATV5B.js +1 -0
- package/dist/chunk-I2G27Y5P.js +1 -0
- package/dist/chunk-IKF43TX2.js +1 -0
- package/dist/chunk-INSPHCBN.js +1 -0
- package/dist/chunk-LQMDUKIE.js +1 -0
- package/dist/chunk-M3MTKGA5.js +1 -0
- package/dist/chunk-MPO54FU3.js +1 -0
- package/dist/chunk-PVKCZI6A.js +1 -0
- package/dist/chunk-Q7KEPCYL.js +1 -0
- package/dist/chunk-R5XD3NT2.js +1 -0
- package/dist/chunk-ROBZ6PAL.js +1 -0
- package/dist/chunk-RXB5BS2N.js +1 -0
- package/dist/chunk-RZ3HNYMT.js +1 -0
- package/dist/chunk-UCGLRMTG.js +1 -0
- package/dist/chunk-UEHJVRKB.js +1 -0
- package/dist/chunk-UZYX5GGF.js +1 -0
- package/dist/chunk-XQJBB725.js +1 -0
- package/dist/chunk-ZB5ZQSXH.js +1 -0
- package/dist/claude-US2QPRBA.js +1 -0
- package/dist/commands-5TFN74MD.js +1 -0
- package/dist/commands-EKPWCB3T.js +1 -0
- package/dist/commands-QHJLREPM.js +1 -0
- package/dist/config-2OUL5FLS.js +1 -0
- package/dist/config-loader-N7IBWN2P.js +1 -0
- package/dist/diagnose-NLHN4SAJ.js +1 -0
- package/dist/display-TB5YACJV.js +1 -0
- package/dist/extractor-3KTM2IUL.js +1 -0
- package/dist/feature-flag-VVIF5FJG.js +1 -0
- package/dist/history-GVNDPXXQ.js +1 -0
- package/dist/index.js +1 -402
- package/dist/instance-registry-I5AIVJE2.js +1 -0
- package/dist/keybindings-RN3A7CRW.js +1 -0
- package/dist/loader-3IKPXP4R.js +1 -0
- package/dist/network-GI2F3IDE.js +1 -0
- package/dist/notify-O6FNVHC4.js +1 -0
- package/dist/openai-compat-IPCMINVF.js +1 -0
- package/dist/permissions-5O7KVAXU.js +1 -0
- package/dist/prompt-VWFPFM4N.js +1 -0
- package/dist/quality-GPQD25UL.js +1 -0
- package/dist/repl-YNXCDVU4.js +1 -0
- package/dist/roadmap-QRZODSNJ.js +1 -0
- package/dist/server-USQP4GC4.js +1 -0
- package/dist/session-5HDDQQP6.js +1 -0
- package/dist/skills-DXWSVJSU.js +1 -0
- package/dist/store-WXXTKTTL.js +1 -0
- package/dist/team-VTPJ3WRT.js +1 -0
- package/dist/telemetry-NT4UZLBS.js +1 -0
- package/dist/test-runner-F6B6RH3S.js +1 -0
- package/dist/theme-JJJ6ABR2.js +1 -0
- package/dist/upgrade-RUG3R7R5.js +1 -0
- package/dist/verify-6OGRY2PR.js +1 -0
- package/dist/version-DLROA5JN.js +1 -0
- package/dist/web/static/app.js +1 -562
- package/dist/web/static/index.html +114 -126
- package/dist/web/static/mirror.css +1 -1001
- package/dist/web/static/mirror.html +155 -178
- package/dist/web/static/mirror.js +1 -1125
- package/dist/web/static/onboard.css +1 -302
- package/dist/web/static/onboard.html +121 -145
- package/dist/web/static/onboard.js +1 -300
- package/dist/web/static/style.css +1 -602
- package/dist/web/static/utils.js +1 -0
- package/dist/web/static/workspace.css +1 -1568
- package/dist/web/static/workspace.html +369 -402
- package/dist/web/static/workspace.js +1 -1683
- package/dist/web-P5YUKEAU.js +1 -0
- package/package.json +25 -4
- package/dist/api-D4PUN5BN.js +0 -162
- package/dist/auth-UTR4I6QY.js +0 -21
- package/dist/background-2EGCAAQH.js +0 -14
- package/dist/backlog-Q2NZCLNY.js +0 -24
- package/dist/chunk-2CMSCWQW.js +0 -162
- package/dist/chunk-4DVYJAJL.js +0 -57
- package/dist/chunk-77FRUHTU.js +0 -271
- package/dist/chunk-7ZYMJFCA.js +0 -251
- package/dist/chunk-BE46C7JW.js +0 -46
- package/dist/chunk-CM423E2U.js +0 -133
- package/dist/chunk-E4NKO2KI.js +0 -263
- package/dist/chunk-GH7E2OJE.js +0 -223
- package/dist/chunk-GMLQ7GZ5.js +0 -134
- package/dist/chunk-GU2FZQ6A.js +0 -69
- package/dist/chunk-IOPKN5GD.js +0 -190
- package/dist/chunk-LWDNLX6B.js +0 -2025
- package/dist/chunk-MGLJ53QN.js +0 -219
- package/dist/chunk-NHPDLYEW.js +0 -139
- package/dist/chunk-OGQGKMDX.js +0 -173
- package/dist/chunk-OPZYEVYR.js +0 -150
- package/dist/chunk-OWAOKDIN.js +0 -1505
- package/dist/chunk-R3GPQC7I.js +0 -393
- package/dist/chunk-RKB2JOV2.js +0 -43
- package/dist/chunk-RNG3K465.js +0 -80
- package/dist/chunk-SHJQMIJL.js +0 -288
- package/dist/chunk-SVF2VWOZ.js +0 -145
- package/dist/chunk-TGTYKBGC.js +0 -86
- package/dist/chunk-V2EBSFPU.js +0 -575
- package/dist/chunk-VJDQNNSO.js +0 -681
- package/dist/chunk-VQ35XX7B.js +0 -167
- package/dist/chunk-WHLVZCQY.js +0 -245
- package/dist/chunk-XMGHVNH2.js +0 -66
- package/dist/chunk-YWOSOTUO.js +0 -58
- package/dist/chunk-ZQRNV2US.js +0 -166
- package/dist/chunk-ZSBHUGWR.js +0 -262
- package/dist/claude-O5FSOXZC.js +0 -12
- package/dist/commands-43PLOWRU.js +0 -128
- package/dist/commands-5YVUSUMP.js +0 -232
- package/dist/commands-VZMZJFZF.js +0 -1044
- package/dist/config-WXXEEEVW.js +0 -8
- package/dist/config-loader-SXO674TF.js +0 -24
- package/dist/diagnose-BX45APUZ.js +0 -12
- package/dist/display-IIUBEYWN.js +0 -58
- package/dist/extractor-R5ABXNTJ.js +0 -129
- package/dist/history-JPXZEOT3.js +0 -180
- package/dist/index.d.ts +0 -1
- package/dist/instance-registry-6NJTCAE4.js +0 -15
- package/dist/keybindings-ADWNOX5M.js +0 -15
- package/dist/loader-AXDDCB2G.js +0 -58
- package/dist/network-V3O4UZYZ.js +0 -279
- package/dist/notify-HPTALZDC.js +0 -14
- package/dist/openai-compat-UFDV2SCK.js +0 -12
- package/dist/permissions-JUKXMNDH.js +0 -10
- package/dist/prompt-5CZ34WGA.js +0 -166
- package/dist/quality-ST7PPNFR.js +0 -16
- package/dist/repl-EOWP6AAB.js +0 -3374
- package/dist/roadmap-5OBEKROY.js +0 -17
- package/dist/server-BB5AENWU.js +0 -57
- package/dist/session-5NDKKFLN.js +0 -21
- package/dist/skills-JVLIQVJN.js +0 -175
- package/dist/store-G7KRD4PN.js +0 -25
- package/dist/team-FVNNVDBY.js +0 -385
- package/dist/telemetry-6R4EIE6O.js +0 -30
- package/dist/test-runner-REKSVPPY.js +0 -619
- package/dist/theme-3SYJ3UQA.js +0 -14
- package/dist/upgrade-YSXCO63I.js +0 -83
- package/dist/verify-JUDKTPKZ.js +0 -14
- package/dist/web-H2BJXUBZ.js +0 -39
package/dist/chunk-SHJQMIJL.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getEventsSummary,
|
|
3
|
-
readEvents
|
|
4
|
-
} from "./chunk-2CMSCWQW.js";
|
|
5
|
-
import {
|
|
6
|
-
addItem,
|
|
7
|
-
listItems
|
|
8
|
-
} from "./chunk-MGLJ53QN.js";
|
|
9
|
-
|
|
10
|
-
// src/admin/diagnose.ts
|
|
11
|
-
async function runRuleDiagnosis(days = 7) {
|
|
12
|
-
const findings = [];
|
|
13
|
-
const events = await readEvents(days);
|
|
14
|
-
const summary = await getEventsSummary(days);
|
|
15
|
-
if (events.length === 0) {
|
|
16
|
-
return [{
|
|
17
|
-
severity: "warning",
|
|
18
|
-
title: "\u65E0\u4E8B\u4EF6\u6570\u636E",
|
|
19
|
-
detail: `\u8FD1 ${days} \u5929\u6CA1\u6709\u91C7\u96C6\u5230\u4EFB\u4F55\u4E8B\u4EF6`,
|
|
20
|
-
evidence: "\u4E8B\u4EF6\u6587\u4EF6\u4E3A\u7A7A\u6216\u4E0D\u5B58\u5728",
|
|
21
|
-
suggestion: "\u786E\u8BA4 telemetry \u5DF2\u542F\u7528\uFF0C\u6B63\u5E38\u4F7F\u7528 Hypercore \u540E\u4F1A\u81EA\u52A8\u91C7\u96C6",
|
|
22
|
-
suggestedType: "bugfix",
|
|
23
|
-
suggestedPriority: "A",
|
|
24
|
-
suggestedWuxing: "\u6728"
|
|
25
|
-
}];
|
|
26
|
-
}
|
|
27
|
-
for (const [cmd, stats] of Object.entries(summary.cmdCounts)) {
|
|
28
|
-
const failRate = stats.total >= 3 ? stats.fail / stats.total : 0;
|
|
29
|
-
if (failRate > 0.1) {
|
|
30
|
-
const failEvents = events.filter(
|
|
31
|
-
(e) => e.event === "cmd_exec" && e.cmd === cmd && !e.ok
|
|
32
|
-
);
|
|
33
|
-
const errorMessages = failEvents.map((e) => String(e.err || "")).filter(Boolean);
|
|
34
|
-
const topError = mostCommon(errorMessages) || "\u672A\u77E5";
|
|
35
|
-
findings.push({
|
|
36
|
-
severity: "high",
|
|
37
|
-
title: `${cmd} \u5931\u8D25\u7387 ${(failRate * 100).toFixed(0)}%`,
|
|
38
|
-
detail: `\u8FD1 ${days} \u5929\u5185 ${cmd} \u6267\u884C ${stats.total} \u6B21\uFF0C\u5931\u8D25 ${stats.fail} \u6B21`,
|
|
39
|
-
evidence: `\u5E38\u89C1\u9519\u8BEF: ${topError} (${stats.fail}/${stats.total})`,
|
|
40
|
-
suggestion: `\u6392\u67E5 ${cmd} \u547D\u4EE4\u7684\u9519\u8BEF\u5904\u7406\u903B\u8F91`,
|
|
41
|
-
suggestedType: "bugfix",
|
|
42
|
-
suggestedPriority: failRate > 0.2 ? "S" : "A",
|
|
43
|
-
suggestedWuxing: "\u6728"
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
for (const err of summary.errors) {
|
|
48
|
-
if (err.count >= 3) {
|
|
49
|
-
findings.push({
|
|
50
|
-
severity: "high",
|
|
51
|
-
title: `${err.type} \u9519\u8BEF\u9891\u53D1 (${err.count}\u6B21)`,
|
|
52
|
-
detail: `\u8FD1 ${days} \u5929\u5185 ${err.type} \u7C7B\u578B\u9519\u8BEF\u51FA\u73B0 ${err.count} \u6B21`,
|
|
53
|
-
evidence: `\u9519\u8BEF\u7C7B\u578B\u7EDF\u8BA1: ${err.type} = ${err.count}`,
|
|
54
|
-
suggestion: "\u68C0\u67E5\u9519\u8BEF\u6839\u56E0\u5E76\u4FEE\u590D",
|
|
55
|
-
suggestedType: "bugfix",
|
|
56
|
-
suggestedPriority: err.count >= 5 ? "S" : "A",
|
|
57
|
-
suggestedWuxing: "\u6728"
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const lineEvents = events.filter((e) => e.event === "line_run");
|
|
62
|
-
const lineStats = {};
|
|
63
|
-
for (const e of lineEvents) {
|
|
64
|
-
const name = String(e.line || "unknown");
|
|
65
|
-
if (!lineStats[name]) lineStats[name] = { durations: [], fails: 0, total: 0 };
|
|
66
|
-
lineStats[name].total++;
|
|
67
|
-
if (e.duration_ms) lineStats[name].durations.push(e.duration_ms);
|
|
68
|
-
if (!e.ok) lineStats[name].fails++;
|
|
69
|
-
}
|
|
70
|
-
for (const [name, stats] of Object.entries(lineStats)) {
|
|
71
|
-
if (stats.durations.length >= 3) {
|
|
72
|
-
const avg = stats.durations.reduce((a, b) => a + b, 0) / stats.durations.length;
|
|
73
|
-
const p95 = stats.durations.sort((a, b) => a - b)[Math.floor(stats.durations.length * 0.95)];
|
|
74
|
-
if (p95 > 3e4) {
|
|
75
|
-
findings.push({
|
|
76
|
-
severity: "warning",
|
|
77
|
-
title: `\u751F\u4EA7\u7EBF "${name}" \u8017\u65F6\u504F\u9AD8`,
|
|
78
|
-
detail: `\u5E73\u5747 ${(avg / 1e3).toFixed(1)}s, p95 ${(p95 / 1e3).toFixed(1)}s (${stats.total}\u6B21\u8FD0\u884C)`,
|
|
79
|
-
evidence: `\u8017\u65F6\u6570\u636E: avg=${(avg / 1e3).toFixed(1)}s, p95=${(p95 / 1e3).toFixed(1)}s`,
|
|
80
|
-
suggestion: "\u68C0\u67E5 prompt \u957F\u5EA6\u6216\u8003\u8651\u5207\u6362\u66F4\u5FEB\u7684\u6A21\u578B",
|
|
81
|
-
suggestedType: "improvement",
|
|
82
|
-
suggestedPriority: "A",
|
|
83
|
-
suggestedWuxing: "\u6728"
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const allCmds = events.filter((e) => e.event === "cmd_exec").map((e) => String(e.cmd));
|
|
89
|
-
const knownCmds = ["/model", "/team", "/memory", "/network", "/admin", "/run", "/git", "/session"];
|
|
90
|
-
for (const cmd of knownCmds) {
|
|
91
|
-
if (!allCmds.includes(cmd) && events.length > 20) {
|
|
92
|
-
findings.push({
|
|
93
|
-
severity: "opportunity",
|
|
94
|
-
title: `${cmd} \u8FD1 ${days} \u5929\u672A\u4F7F\u7528`,
|
|
95
|
-
detail: `\u5728 ${events.length} \u6761\u4E8B\u4EF6\u4E2D\u6CA1\u6709 ${cmd} \u7684\u4F7F\u7528\u8BB0\u5F55`,
|
|
96
|
-
evidence: `${cmd} \u8C03\u7528\u6B21\u6570: 0`,
|
|
97
|
-
suggestion: "\u8BC4\u4F30\u8BE5\u529F\u80FD\u662F\u5426\u9700\u8981\u6539\u8FDB\u5165\u53E3\u6216\u8003\u8651\u4E0B\u7EBF",
|
|
98
|
-
suggestedType: "idea",
|
|
99
|
-
suggestedPriority: "C",
|
|
100
|
-
suggestedWuxing: "\u91D1"
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const sessionEnds = events.filter((e) => e.event === "session_end");
|
|
105
|
-
if (sessionEnds.length >= 4) {
|
|
106
|
-
const mid = Math.floor(sessionEnds.length / 2);
|
|
107
|
-
const firstHalf = sessionEnds.slice(0, mid);
|
|
108
|
-
const secondHalf = sessionEnds.slice(mid);
|
|
109
|
-
const avgFirst = firstHalf.reduce((s, e) => s + (e.rounds || 0), 0) / firstHalf.length;
|
|
110
|
-
const avgSecond = secondHalf.reduce((s, e) => s + (e.rounds || 0), 0) / secondHalf.length;
|
|
111
|
-
if (avgFirst > 0 && avgSecond / avgFirst < 0.6) {
|
|
112
|
-
findings.push({
|
|
113
|
-
severity: "warning",
|
|
114
|
-
title: `\u4F1A\u8BDD\u6DF1\u5EA6\u4E0B\u964D (${avgFirst.toFixed(1)} \u2192 ${avgSecond.toFixed(1)} \u8F6E)`,
|
|
115
|
-
detail: `\u524D\u534A\u671F\u5E73\u5747 ${avgFirst.toFixed(1)} \u8F6E\uFF0C\u540E\u534A\u671F ${avgSecond.toFixed(1)} \u8F6E`,
|
|
116
|
-
evidence: `\u4E0B\u964D\u5E45\u5EA6: ${((1 - avgSecond / avgFirst) * 100).toFixed(0)}%`,
|
|
117
|
-
suggestion: "\u5206\u6790\u7528\u6237\u662F\u5426\u63D0\u524D\u653E\u5F03\u8FD8\u662F\u9700\u6C42\u53D8\u7B80\u77ED",
|
|
118
|
-
suggestedType: "idea",
|
|
119
|
-
suggestedPriority: "B",
|
|
120
|
-
suggestedWuxing: "\u6C34"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return findings;
|
|
125
|
-
}
|
|
126
|
-
function buildDiagnosePrompt(summary, ruleFindings) {
|
|
127
|
-
const parts = [];
|
|
128
|
-
parts.push(`\u4F60\u662F\u8D85\u534F\u4F53 (Hypercore) \u9879\u76EE\u7684\u5185\u89C2\u8BCA\u65AD\u5F15\u64CE\u3002\u4EE5\u4E0B\u662F\u8FD1 ${summary.period.days} \u5929\u7684\u4F7F\u7528\u6570\u636E\u6458\u8981\u3002`);
|
|
129
|
-
parts.push(`\u8BF7\u5206\u6790\u5E76\u8865\u5145\u89C4\u5219\u5F15\u64CE\u53EF\u80FD\u9057\u6F0F\u7684\u6D1E\u5BDF\u3002
|
|
130
|
-
`);
|
|
131
|
-
parts.push(`## \u57FA\u7840\u7EDF\u8BA1`);
|
|
132
|
-
parts.push(`- \u4E8B\u4EF6\u603B\u6570: ${summary.totalEvents}`);
|
|
133
|
-
parts.push(`- \u4F1A\u8BDD\u6570: ${summary.totalSessions}`);
|
|
134
|
-
parts.push(`- \u5E73\u5747\u4F1A\u8BDD\u8F6E\u6B21: ${summary.avgSessionRounds}`);
|
|
135
|
-
parts.push(`- \u7EDF\u8BA1\u5468\u671F: ${summary.period.from} \u2192 ${summary.period.to}
|
|
136
|
-
`);
|
|
137
|
-
if (Object.keys(summary.cmdCounts).length > 0) {
|
|
138
|
-
parts.push(`## \u547D\u4EE4\u4F7F\u7528\u7EDF\u8BA1`);
|
|
139
|
-
for (const [cmd, stats] of Object.entries(summary.cmdCounts)) {
|
|
140
|
-
const failPart = stats.fail > 0 ? ` (\u5931\u8D25${stats.fail}\u6B21, \u7387${(stats.fail / stats.total * 100).toFixed(0)}%)` : "";
|
|
141
|
-
parts.push(`- ${cmd}: ${stats.total}\u6B21${failPart}`);
|
|
142
|
-
}
|
|
143
|
-
parts.push("");
|
|
144
|
-
}
|
|
145
|
-
if (summary.errors.length > 0) {
|
|
146
|
-
parts.push(`## \u9519\u8BEF\u7EDF\u8BA1`);
|
|
147
|
-
for (const e of summary.errors) {
|
|
148
|
-
parts.push(`- ${e.type}: ${e.count}\u6B21`);
|
|
149
|
-
}
|
|
150
|
-
parts.push("");
|
|
151
|
-
}
|
|
152
|
-
if (ruleFindings.length > 0) {
|
|
153
|
-
parts.push(`## \u89C4\u5219\u5F15\u64CE\u5DF2\u53D1\u73B0`);
|
|
154
|
-
for (const f of ruleFindings) {
|
|
155
|
-
parts.push(`- [${f.severity}] ${f.title}: ${f.detail}`);
|
|
156
|
-
}
|
|
157
|
-
parts.push("");
|
|
158
|
-
}
|
|
159
|
-
parts.push(`## \u4F60\u7684\u4EFB\u52A1`);
|
|
160
|
-
parts.push(`\u57FA\u4E8E\u4EE5\u4E0A\u6570\u636E\uFF0C\u8F93\u51FA\uFF1A`);
|
|
161
|
-
parts.push(`1. \u89C4\u5219\u5F15\u64CE\u53EF\u80FD\u9057\u6F0F\u7684\u95EE\u9898\u6216\u6A21\u5F0F`);
|
|
162
|
-
parts.push(`2. \u4F7F\u7528\u8D8B\u52BF\u7684\u6DF1\u5C42\u89E3\u8BFB`);
|
|
163
|
-
parts.push(`3. \u4EA7\u54C1\u6539\u8FDB\u673A\u4F1A`);
|
|
164
|
-
parts.push(`
|
|
165
|
-
\u6BCF\u6761\u53D1\u73B0\u8BF7\u7528\u4EE5\u4E0B\u683C\u5F0F\uFF1A`);
|
|
166
|
-
parts.push(`### [severity: high/warning/opportunity] \u6807\u9898`);
|
|
167
|
-
parts.push(`- \u8BE6\u60C5: ...`);
|
|
168
|
-
parts.push(`- \u8BC1\u636E: ...`);
|
|
169
|
-
parts.push(`- \u5EFA\u8BAE: ...`);
|
|
170
|
-
parts.push(`- \u7C7B\u578B: bugfix/feature/improvement/idea`);
|
|
171
|
-
parts.push(`- \u4F18\u5148\u7EA7: S/A/B/C`);
|
|
172
|
-
parts.push(`- \u4E94\u884C: \u6728/\u706B/\u6C34/\u91D1/\u571F`);
|
|
173
|
-
parts.push(`
|
|
174
|
-
\u5982\u679C\u6CA1\u6709\u989D\u5916\u53D1\u73B0\uFF0C\u76F4\u63A5\u8BF4"\u89C4\u5219\u5F15\u64CE\u5DF2\u8986\u76D6\u4E3B\u8981\u95EE\u9898"\u3002`);
|
|
175
|
-
return parts.join("\n");
|
|
176
|
-
}
|
|
177
|
-
function parseAIFindings(text) {
|
|
178
|
-
const findings = [];
|
|
179
|
-
const blocks = text.split(/###\s+\[/).filter(Boolean);
|
|
180
|
-
for (const block of blocks) {
|
|
181
|
-
const severityMatch = block.match(/^(high|warning|opportunity)\]\s*(.+)/);
|
|
182
|
-
if (!severityMatch) continue;
|
|
183
|
-
const severity = severityMatch[1];
|
|
184
|
-
const title = severityMatch[2].trim();
|
|
185
|
-
const detail = extractField(block, "\u8BE6\u60C5") || "";
|
|
186
|
-
const evidence = extractField(block, "\u8BC1\u636E") || "";
|
|
187
|
-
const suggestion = extractField(block, "\u5EFA\u8BAE") || "";
|
|
188
|
-
const typeStr = extractField(block, "\u7C7B\u578B") || "idea";
|
|
189
|
-
const priorityStr = extractField(block, "\u4F18\u5148\u7EA7") || "B";
|
|
190
|
-
const wuxingStr = extractField(block, "\u4E94\u884C") || "\u6728";
|
|
191
|
-
findings.push({
|
|
192
|
-
severity,
|
|
193
|
-
title,
|
|
194
|
-
detail,
|
|
195
|
-
evidence,
|
|
196
|
-
suggestion,
|
|
197
|
-
suggestedType: ["bugfix", "feature", "improvement", "idea"].includes(typeStr) ? typeStr : "idea",
|
|
198
|
-
suggestedPriority: ["S", "A", "B", "C"].includes(priorityStr) ? priorityStr : "B",
|
|
199
|
-
suggestedWuxing: ["\u6728", "\u706B", "\u6C34", "\u91D1", "\u571F"].includes(wuxingStr) ? wuxingStr : "\u6728"
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return findings;
|
|
203
|
-
}
|
|
204
|
-
function extractField(block, fieldName) {
|
|
205
|
-
const regex = new RegExp(`-\\s*${fieldName}[\uFF1A:]\\s*(.+)`, "i");
|
|
206
|
-
const match = block.match(regex);
|
|
207
|
-
return match ? match[1].trim() : "";
|
|
208
|
-
}
|
|
209
|
-
async function runAIDiagnosis(ctx, days = 7) {
|
|
210
|
-
const summary = await getEventsSummary(days);
|
|
211
|
-
const ruleFindings = await runRuleDiagnosis(days);
|
|
212
|
-
const prompt = buildDiagnosePrompt(summary, ruleFindings);
|
|
213
|
-
let aiRawText = "";
|
|
214
|
-
const aiFindings = [];
|
|
215
|
-
try {
|
|
216
|
-
if (ctx.config.modelConfig.sdkType === "openai") {
|
|
217
|
-
const { streamOpenAIChat } = await import("./openai-compat-UFDV2SCK.js");
|
|
218
|
-
const OpenAI = (await import("openai")).default;
|
|
219
|
-
const client = ctx.getClient();
|
|
220
|
-
const result = await streamOpenAIChat(client, [
|
|
221
|
-
{ role: "system", content: "\u4F60\u662F\u8D85\u534F\u4F53\u9879\u76EE\u7684\u5185\u89C2\u8BCA\u65AD\u5F15\u64CE\u3002\u5206\u6790\u6570\u636E\uFF0C\u8F93\u51FA\u7CBE\u51C6\u8BCA\u65AD\u3002\u7528\u4E2D\u6587\u56DE\u590D\u3002" },
|
|
222
|
-
{ role: "user", content: prompt }
|
|
223
|
-
], {
|
|
224
|
-
model: ctx.config.modelConfig.model,
|
|
225
|
-
tools: [],
|
|
226
|
-
onChunk: (text) => {
|
|
227
|
-
process.stdout.write(text);
|
|
228
|
-
},
|
|
229
|
-
onToolCall: () => {
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
aiRawText = result.content.trim();
|
|
233
|
-
} else {
|
|
234
|
-
const { streamCallLLM } = await import("./claude-O5FSOXZC.js");
|
|
235
|
-
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
236
|
-
const client = ctx.getClient();
|
|
237
|
-
const result = await streamCallLLM(client, {
|
|
238
|
-
systemPrompt: "\u4F60\u662F\u8D85\u534F\u4F53\u9879\u76EE\u7684\u5185\u89C2\u8BCA\u65AD\u5F15\u64CE\u3002\u5206\u6790\u6570\u636E\uFF0C\u8F93\u51FA\u7CBE\u51C6\u8BCA\u65AD\u3002\u7528\u4E2D\u6587\u56DE\u590D\u3002",
|
|
239
|
-
userPrompt: prompt,
|
|
240
|
-
history: [],
|
|
241
|
-
tools: [],
|
|
242
|
-
model: ctx.config.modelConfig.model,
|
|
243
|
-
onText: (text) => {
|
|
244
|
-
process.stdout.write(text);
|
|
245
|
-
},
|
|
246
|
-
onToolCall: () => {
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
aiRawText = result.output.trim();
|
|
250
|
-
}
|
|
251
|
-
aiFindings.push(...parseAIFindings(aiRawText));
|
|
252
|
-
} catch (err) {
|
|
253
|
-
aiRawText = `AI \u8BCA\u65AD\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`;
|
|
254
|
-
}
|
|
255
|
-
return { ruleFindings, aiFindings, aiRawText };
|
|
256
|
-
}
|
|
257
|
-
async function findingsToBacklog(findings, targetVersion) {
|
|
258
|
-
const existing = await listItems();
|
|
259
|
-
const existingTitles = new Set(existing.map((i) => i.title.toLowerCase()));
|
|
260
|
-
const createdIds = [];
|
|
261
|
-
for (const f of findings) {
|
|
262
|
-
if (existingTitles.has(f.title.toLowerCase())) continue;
|
|
263
|
-
const item = await addItem({
|
|
264
|
-
title: f.title,
|
|
265
|
-
description: f.detail,
|
|
266
|
-
type: f.suggestedType,
|
|
267
|
-
wuxing: f.suggestedWuxing,
|
|
268
|
-
priority: f.suggestedPriority,
|
|
269
|
-
targetVersion,
|
|
270
|
-
source: "auto-diagnose",
|
|
271
|
-
evidence: f.evidence
|
|
272
|
-
});
|
|
273
|
-
createdIds.push(item.id);
|
|
274
|
-
}
|
|
275
|
-
return createdIds;
|
|
276
|
-
}
|
|
277
|
-
function mostCommon(arr) {
|
|
278
|
-
if (arr.length === 0) return void 0;
|
|
279
|
-
const counts = {};
|
|
280
|
-
for (const s of arr) counts[s] = (counts[s] || 0) + 1;
|
|
281
|
-
return Object.entries(counts).sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export {
|
|
285
|
-
runRuleDiagnosis,
|
|
286
|
-
runAIDiagnosis,
|
|
287
|
-
findingsToBacklog
|
|
288
|
-
};
|
package/dist/chunk-SVF2VWOZ.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// src/core/config.ts
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { readFile } from "fs/promises";
|
|
4
|
-
import { existsSync } from "fs";
|
|
5
|
-
|
|
6
|
-
// src/core/types.ts
|
|
7
|
-
var MODEL_PROVIDERS = {
|
|
8
|
-
anthropic: {
|
|
9
|
-
defaultModel: "claude-sonnet-4-20250514",
|
|
10
|
-
name: "Anthropic (Claude)",
|
|
11
|
-
sdkType: "anthropic"
|
|
12
|
-
},
|
|
13
|
-
minimax: {
|
|
14
|
-
baseURL: "https://api.minimax.io/anthropic",
|
|
15
|
-
defaultModel: "MiniMax-M2.5",
|
|
16
|
-
name: "MiniMax (M2.5)",
|
|
17
|
-
sdkType: "anthropic"
|
|
18
|
-
},
|
|
19
|
-
gemini: {
|
|
20
|
-
baseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
21
|
-
defaultModel: "gemini-2.5-flash",
|
|
22
|
-
name: "Google (Gemini)",
|
|
23
|
-
sdkType: "openai"
|
|
24
|
-
},
|
|
25
|
-
deepseek: {
|
|
26
|
-
baseURL: "https://api.deepseek.com/v1",
|
|
27
|
-
defaultModel: "deepseek-chat",
|
|
28
|
-
name: "DeepSeek",
|
|
29
|
-
sdkType: "openai"
|
|
30
|
-
},
|
|
31
|
-
"openai-compatible": {
|
|
32
|
-
defaultModel: "gpt-4o",
|
|
33
|
-
name: "OpenAI Compatible",
|
|
34
|
-
sdkType: "openai"
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var MODEL_ALIASES = {
|
|
38
|
-
// Claude 系列
|
|
39
|
-
"sonnet": { provider: "anthropic", model: "claude-sonnet-4-20250514" },
|
|
40
|
-
"haiku": { provider: "anthropic", model: "claude-3-5-haiku-20241022" },
|
|
41
|
-
"opus": { provider: "anthropic", model: "claude-opus-4-20250514" },
|
|
42
|
-
// Gemini 系列
|
|
43
|
-
"flash": { provider: "gemini", model: "gemini-2.5-flash" },
|
|
44
|
-
"gemini": { provider: "gemini", model: "gemini-2.5-flash" },
|
|
45
|
-
"gemini-pro": { provider: "gemini", model: "gemini-2.5-pro-preview-05-06" },
|
|
46
|
-
// DeepSeek
|
|
47
|
-
"deepseek": { provider: "deepseek", model: "deepseek-chat" },
|
|
48
|
-
"ds": { provider: "deepseek", model: "deepseek-chat" },
|
|
49
|
-
"deepseek-coder": { provider: "deepseek", model: "deepseek-coder" },
|
|
50
|
-
"deepseek-r1": { provider: "deepseek", model: "deepseek-reasoner" },
|
|
51
|
-
// MiniMax
|
|
52
|
-
"minimax": { provider: "minimax", model: "MiniMax-M2.5" },
|
|
53
|
-
"mm": { provider: "minimax", model: "MiniMax-M2.5" }
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/core/config.ts
|
|
57
|
-
var HYPERCORE_DIR = join(process.env.HOME || "~", ".hypercore");
|
|
58
|
-
function parseSectionValues(content, sectionName) {
|
|
59
|
-
const sectionRegex = new RegExp(`\\[${sectionName}\\]([\\s\\S]*?)(?=\\[|$)`);
|
|
60
|
-
const match = content.match(sectionRegex);
|
|
61
|
-
if (!match) return {};
|
|
62
|
-
const result = {};
|
|
63
|
-
const lines = match[1].split("\n");
|
|
64
|
-
for (const rawLine of lines) {
|
|
65
|
-
const kvMatch = rawLine.match(/^\s*([A-Za-z_]\w*)\s*=\s*(?:"((?:\\.|[^"])*)"|(\S+))(?:\s+#.*)?\s*$/);
|
|
66
|
-
if (kvMatch) {
|
|
67
|
-
const key = kvMatch[1];
|
|
68
|
-
const quoted = kvMatch[2];
|
|
69
|
-
const bare = kvMatch[3];
|
|
70
|
-
let value = quoted != null ? quoted : bare;
|
|
71
|
-
value = value.replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
72
|
-
result[key] = value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
async function loadConfig() {
|
|
78
|
-
const configPath = join(HYPERCORE_DIR, "config.toml");
|
|
79
|
-
if (!existsSync(configPath)) {
|
|
80
|
-
throw new Error("\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6\u3002\u8BF7\u5148\u8FD0\u884C hypercore init");
|
|
81
|
-
}
|
|
82
|
-
const content = await readFile(configPath, "utf-8");
|
|
83
|
-
const modelSection = parseSectionValues(content, "model");
|
|
84
|
-
const provider = modelSection["provider"] || "anthropic";
|
|
85
|
-
const apiKey = modelSection["api_key"];
|
|
86
|
-
if (!apiKey) {
|
|
87
|
-
throw new Error("\u914D\u7F6E\u6587\u4EF6 [model] \u6BB5\u672A\u627E\u5230 api_key");
|
|
88
|
-
}
|
|
89
|
-
const providerConfig = MODEL_PROVIDERS[provider];
|
|
90
|
-
if (!providerConfig) {
|
|
91
|
-
throw new Error(`\u4E0D\u652F\u6301\u7684\u6A21\u578B\u63D0\u4F9B\u5546: ${provider}\u3002\u652F\u6301: ${Object.keys(MODEL_PROVIDERS).join(", ")}`);
|
|
92
|
-
}
|
|
93
|
-
const searchSection = parseSectionValues(content, "search");
|
|
94
|
-
const outputSection = parseSectionValues(content, "output");
|
|
95
|
-
const keysSection = parseSectionValues(content, "keys");
|
|
96
|
-
const providerKeys = {};
|
|
97
|
-
providerKeys[provider] = apiKey;
|
|
98
|
-
const keyMapping = {
|
|
99
|
-
anthropic: "anthropic",
|
|
100
|
-
gemini: "gemini",
|
|
101
|
-
deepseek: "deepseek",
|
|
102
|
-
minimax: "minimax",
|
|
103
|
-
openai: "openai-compatible"
|
|
104
|
-
};
|
|
105
|
-
for (const [name, value] of Object.entries(keysSection)) {
|
|
106
|
-
const mappedProvider = keyMapping[name];
|
|
107
|
-
if (mappedProvider && value) {
|
|
108
|
-
providerKeys[mappedProvider] = value;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const uiSection = parseSectionValues(content, "ui");
|
|
112
|
-
const uiConfig = {};
|
|
113
|
-
if (uiSection["theme"]) {
|
|
114
|
-
const t = uiSection["theme"];
|
|
115
|
-
if (t === "dark" || t === "light" || t === "high-contrast") {
|
|
116
|
-
uiConfig.theme = t;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (uiSection["vim_mode"] === "true") uiConfig.vimMode = true;
|
|
120
|
-
if (uiSection["notifications"] === "false") {
|
|
121
|
-
uiConfig.notifications = false;
|
|
122
|
-
} else {
|
|
123
|
-
uiConfig.notifications = true;
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
modelConfig: {
|
|
127
|
-
provider,
|
|
128
|
-
model: modelSection["name"] || providerConfig.defaultModel,
|
|
129
|
-
apiKey,
|
|
130
|
-
baseURL: modelSection["base_url"] || providerConfig.baseURL,
|
|
131
|
-
sdkType: providerConfig.sdkType
|
|
132
|
-
},
|
|
133
|
-
tavilyApiKey: searchSection["api_key"] || void 0,
|
|
134
|
-
outputDir: outputSection["dir"] || join(HYPERCORE_DIR, "outputs"),
|
|
135
|
-
providerKeys,
|
|
136
|
-
uiConfig
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export {
|
|
141
|
-
MODEL_PROVIDERS,
|
|
142
|
-
MODEL_ALIASES,
|
|
143
|
-
HYPERCORE_DIR,
|
|
144
|
-
loadConfig
|
|
145
|
-
};
|
package/dist/chunk-TGTYKBGC.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// src/repl/background.ts
|
|
2
|
-
import { spawn } from "child_process";
|
|
3
|
-
var tasks = /* @__PURE__ */ new Map();
|
|
4
|
-
var processes = /* @__PURE__ */ new Map();
|
|
5
|
-
var counter = 0;
|
|
6
|
-
function spawnBackground(command) {
|
|
7
|
-
counter++;
|
|
8
|
-
const id = `bg-${String(counter).padStart(3, "0")}`;
|
|
9
|
-
const task = {
|
|
10
|
-
id,
|
|
11
|
-
command,
|
|
12
|
-
startTime: /* @__PURE__ */ new Date(),
|
|
13
|
-
status: "running",
|
|
14
|
-
output: "",
|
|
15
|
-
error: ""
|
|
16
|
-
};
|
|
17
|
-
const child = spawn("sh", ["-c", command], {
|
|
18
|
-
cwd: process.cwd(),
|
|
19
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
20
|
-
env: { ...process.env }
|
|
21
|
-
});
|
|
22
|
-
task.pid = child.pid;
|
|
23
|
-
child.stdout?.on("data", (data) => {
|
|
24
|
-
task.output += data.toString();
|
|
25
|
-
if (task.output.length > 512 * 1024) {
|
|
26
|
-
task.output = task.output.slice(-256 * 1024);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
child.stderr?.on("data", (data) => {
|
|
30
|
-
task.error += data.toString();
|
|
31
|
-
if (task.error.length > 128 * 1024) {
|
|
32
|
-
task.error = task.error.slice(-64 * 1024);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
child.on("close", (code) => {
|
|
36
|
-
task.status = code === 0 ? "done" : "error";
|
|
37
|
-
task.exitCode = code;
|
|
38
|
-
processes.delete(id);
|
|
39
|
-
});
|
|
40
|
-
child.on("error", (err) => {
|
|
41
|
-
task.status = "error";
|
|
42
|
-
task.error += `
|
|
43
|
-
\u8FDB\u7A0B\u9519\u8BEF: ${err.message}`;
|
|
44
|
-
processes.delete(id);
|
|
45
|
-
});
|
|
46
|
-
tasks.set(id, task);
|
|
47
|
-
processes.set(id, child);
|
|
48
|
-
return task;
|
|
49
|
-
}
|
|
50
|
-
function getTaskOutput(id) {
|
|
51
|
-
return tasks.get(id);
|
|
52
|
-
}
|
|
53
|
-
function listBackgroundTasks() {
|
|
54
|
-
return [...tasks.values()];
|
|
55
|
-
}
|
|
56
|
-
function stopTask(id) {
|
|
57
|
-
const child = processes.get(id);
|
|
58
|
-
if (child) {
|
|
59
|
-
child.kill("SIGTERM");
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
if (processes.has(id)) {
|
|
62
|
-
child.kill("SIGKILL");
|
|
63
|
-
}
|
|
64
|
-
}, 3e3);
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
function clearCompletedTasks() {
|
|
70
|
-
let count = 0;
|
|
71
|
-
for (const [id, task] of tasks) {
|
|
72
|
-
if (task.status !== "running") {
|
|
73
|
-
tasks.delete(id);
|
|
74
|
-
count++;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return count;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export {
|
|
81
|
-
spawnBackground,
|
|
82
|
-
getTaskOutput,
|
|
83
|
-
listBackgroundTasks,
|
|
84
|
-
stopTask,
|
|
85
|
-
clearCompletedTasks
|
|
86
|
-
};
|