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-ZSBHUGWR.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
// src/admin/quality.ts
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { readFile, stat, readdir } from "fs/promises";
|
|
5
|
-
import { existsSync } from "fs";
|
|
6
|
-
function toText(value) {
|
|
7
|
-
if (typeof value === "string") return value;
|
|
8
|
-
if (value instanceof Uint8Array) return Buffer.from(value).toString("utf-8");
|
|
9
|
-
return "";
|
|
10
|
-
}
|
|
11
|
-
function getExecErrorOutput(err) {
|
|
12
|
-
if (err && typeof err === "object") {
|
|
13
|
-
const stdout = toText(err.stdout);
|
|
14
|
-
const stderr = toText(err.stderr);
|
|
15
|
-
const merged = [stdout, stderr].filter(Boolean).join("\n").trim();
|
|
16
|
-
if (merged) return merged;
|
|
17
|
-
}
|
|
18
|
-
return err instanceof Error ? err.message : String(err);
|
|
19
|
-
}
|
|
20
|
-
async function walkFiles(dir, accept, out = []) {
|
|
21
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
22
|
-
for (const entry of entries) {
|
|
23
|
-
const fullPath = join(dir, entry.name);
|
|
24
|
-
if (entry.isDirectory()) {
|
|
25
|
-
await walkFiles(fullPath, accept, out);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (entry.isFile() && accept(fullPath)) {
|
|
29
|
-
out.push(fullPath);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return out;
|
|
33
|
-
}
|
|
34
|
-
async function checkTests(projectRoot) {
|
|
35
|
-
try {
|
|
36
|
-
const output = execSync("npm test -- --reporter=verbose", {
|
|
37
|
-
cwd: projectRoot,
|
|
38
|
-
encoding: "utf-8",
|
|
39
|
-
timeout: 6e4,
|
|
40
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
41
|
-
});
|
|
42
|
-
const passMatch = output.match(/(\d+)\s+passed/);
|
|
43
|
-
const failMatch = output.match(/(\d+)\s+failed/);
|
|
44
|
-
const passed = passMatch ? parseInt(passMatch[1]) : 0;
|
|
45
|
-
const failed = failMatch ? parseInt(failMatch[1]) : 0;
|
|
46
|
-
const total = passed + failed;
|
|
47
|
-
return {
|
|
48
|
-
name: "\u6D4B\u8BD5\u901A\u8FC7\u7387",
|
|
49
|
-
ok: failed === 0 && passed > 0,
|
|
50
|
-
detail: `${passed}/${total} \u901A\u8FC7${failed > 0 ? `\uFF0C${failed} \u5931\u8D25` : ""}`,
|
|
51
|
-
value: total > 0 ? Math.round(passed / total * 100) : 0,
|
|
52
|
-
unit: "%"
|
|
53
|
-
};
|
|
54
|
-
} catch (err) {
|
|
55
|
-
const output = getExecErrorOutput(err);
|
|
56
|
-
const passMatch = output.match(/(\d+)\s+passed/);
|
|
57
|
-
const failMatch = output.match(/(\d+)\s+failed/);
|
|
58
|
-
if (passMatch || failMatch) {
|
|
59
|
-
const passed = passMatch ? parseInt(passMatch[1]) : 0;
|
|
60
|
-
const failed = failMatch ? parseInt(failMatch[1]) : 0;
|
|
61
|
-
return {
|
|
62
|
-
name: "\u6D4B\u8BD5\u901A\u8FC7\u7387",
|
|
63
|
-
ok: false,
|
|
64
|
-
detail: `${passed}/${passed + failed} \u901A\u8FC7\uFF0C${failed} \u5931\u8D25`,
|
|
65
|
-
value: passed + failed > 0 ? Math.round(passed / (passed + failed) * 100) : 0,
|
|
66
|
-
unit: "%"
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
name: "\u6D4B\u8BD5\u901A\u8FC7\u7387",
|
|
71
|
-
ok: false,
|
|
72
|
-
detail: `\u6D4B\u8BD5\u8FD0\u884C\u5931\u8D25: ${output.slice(0, 100)}`
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async function checkTodos(projectRoot) {
|
|
77
|
-
try {
|
|
78
|
-
const srcDir = join(projectRoot, "src");
|
|
79
|
-
if (!existsSync(srcDir)) {
|
|
80
|
-
return { name: "TODO \u626B\u63CF", ok: true, detail: "src \u76EE\u5F55\u4E0D\u5B58\u5728", value: 0, unit: "\u4E2A" };
|
|
81
|
-
}
|
|
82
|
-
const todos = [];
|
|
83
|
-
const files = await walkFiles(srcDir, (file) => file.endsWith(".ts") || file.endsWith(".js"));
|
|
84
|
-
for (const file of files) {
|
|
85
|
-
const content = await readFile(file, "utf-8");
|
|
86
|
-
const lines = content.split(/\r?\n/);
|
|
87
|
-
for (let i = 0; i < lines.length; i++) {
|
|
88
|
-
const text = lines[i];
|
|
89
|
-
const typeMatch = text.match(/(TODO|FIXME|HACK|XXX)/i);
|
|
90
|
-
if (!typeMatch) continue;
|
|
91
|
-
todos.push({
|
|
92
|
-
file: file.replace(`${projectRoot}/`, ""),
|
|
93
|
-
line: i + 1,
|
|
94
|
-
text: text.trim().slice(0, 80),
|
|
95
|
-
type: typeMatch[1].toUpperCase()
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const byType = {};
|
|
100
|
-
for (const t of todos) {
|
|
101
|
-
byType[t.type] = (byType[t.type] || 0) + 1;
|
|
102
|
-
}
|
|
103
|
-
const typeSummary = Object.entries(byType).map(([t, c]) => `${t}:${c}`).join(" ");
|
|
104
|
-
return {
|
|
105
|
-
name: "TODO \u626B\u63CF",
|
|
106
|
-
ok: todos.length <= 10,
|
|
107
|
-
detail: todos.length === 0 ? "\u65E0\u672A\u5904\u7406\u6807\u8BB0" : `${todos.length} \u4E2A\u6807\u8BB0 (${typeSummary})`,
|
|
108
|
-
value: todos.length,
|
|
109
|
-
unit: "\u4E2A"
|
|
110
|
-
};
|
|
111
|
-
} catch {
|
|
112
|
-
return { name: "TODO \u626B\u63CF", ok: true, detail: "\u626B\u63CF\u5931\u8D25\uFF0C\u8DF3\u8FC7", value: 0, unit: "\u4E2A" };
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async function checkDeps(projectRoot) {
|
|
116
|
-
try {
|
|
117
|
-
let auditIssues = 0;
|
|
118
|
-
try {
|
|
119
|
-
execSync("npm audit --json", {
|
|
120
|
-
cwd: projectRoot,
|
|
121
|
-
encoding: "utf-8",
|
|
122
|
-
timeout: 3e4,
|
|
123
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
124
|
-
});
|
|
125
|
-
} catch (err) {
|
|
126
|
-
const msg = getExecErrorOutput(err);
|
|
127
|
-
if (msg) {
|
|
128
|
-
try {
|
|
129
|
-
const audit = JSON.parse(msg);
|
|
130
|
-
auditIssues = audit?.metadata?.vulnerabilities?.total || 0;
|
|
131
|
-
} catch {
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
let outdated = 0;
|
|
136
|
-
try {
|
|
137
|
-
execSync("npm outdated --json", {
|
|
138
|
-
cwd: projectRoot,
|
|
139
|
-
encoding: "utf-8",
|
|
140
|
-
timeout: 3e4,
|
|
141
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
142
|
-
});
|
|
143
|
-
} catch (err) {
|
|
144
|
-
const msg = getExecErrorOutput(err);
|
|
145
|
-
if (msg) {
|
|
146
|
-
try {
|
|
147
|
-
const pkgs = JSON.parse(msg);
|
|
148
|
-
outdated = Object.keys(pkgs).length;
|
|
149
|
-
} catch {
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const parts = [];
|
|
154
|
-
if (auditIssues > 0) parts.push(`${auditIssues} \u5B89\u5168\u6F0F\u6D1E`);
|
|
155
|
-
if (outdated > 0) parts.push(`${outdated} \u8FC7\u671F\u4F9D\u8D56`);
|
|
156
|
-
if (parts.length === 0) parts.push("\u4F9D\u8D56\u5065\u5EB7");
|
|
157
|
-
return {
|
|
158
|
-
name: "\u4F9D\u8D56\u68C0\u67E5",
|
|
159
|
-
ok: auditIssues === 0,
|
|
160
|
-
detail: parts.join(", "),
|
|
161
|
-
value: auditIssues,
|
|
162
|
-
unit: "\u6F0F\u6D1E"
|
|
163
|
-
};
|
|
164
|
-
} catch {
|
|
165
|
-
return { name: "\u4F9D\u8D56\u68C0\u67E5", ok: true, detail: "\u68C0\u67E5\u5931\u8D25\uFF0C\u8DF3\u8FC7" };
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async function checkPackageSize(projectRoot) {
|
|
169
|
-
const distDir = join(projectRoot, "dist");
|
|
170
|
-
if (!existsSync(distDir)) {
|
|
171
|
-
return { name: "\u5305\u4F53\u79EF", ok: false, detail: "dist/ \u4E0D\u5B58\u5728\uFF0C\u5148\u8FD0\u884C build" };
|
|
172
|
-
}
|
|
173
|
-
try {
|
|
174
|
-
const files = await walkFiles(
|
|
175
|
-
distDir,
|
|
176
|
-
(file) => file.endsWith(".js") || file.endsWith(".mjs") || file.endsWith(".cjs")
|
|
177
|
-
);
|
|
178
|
-
let totalBytes = 0;
|
|
179
|
-
for (const file of files) {
|
|
180
|
-
const fileStat = await stat(file);
|
|
181
|
-
totalBytes += fileStat.size;
|
|
182
|
-
}
|
|
183
|
-
const sizeMB = (totalBytes / 1024 / 1024).toFixed(2);
|
|
184
|
-
return {
|
|
185
|
-
name: "\u5305\u4F53\u79EF",
|
|
186
|
-
ok: totalBytes < 5 * 1024 * 1024,
|
|
187
|
-
// < 5MB
|
|
188
|
-
detail: `${sizeMB} MB`,
|
|
189
|
-
value: totalBytes,
|
|
190
|
-
unit: "bytes"
|
|
191
|
-
};
|
|
192
|
-
} catch {
|
|
193
|
-
return { name: "\u5305\u4F53\u79EF", ok: true, detail: "\u4F53\u79EF\u8BA1\u7B97\u5931\u8D25\uFF0C\u8DF3\u8FC7" };
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
async function checkBuild(projectRoot) {
|
|
197
|
-
try {
|
|
198
|
-
execSync("npm run build", {
|
|
199
|
-
cwd: projectRoot,
|
|
200
|
-
encoding: "utf-8",
|
|
201
|
-
timeout: 6e4,
|
|
202
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
203
|
-
});
|
|
204
|
-
return { name: "Build", ok: true, detail: "\u7F16\u8BD1\u6210\u529F" };
|
|
205
|
-
} catch (err) {
|
|
206
|
-
const msg = getExecErrorOutput(err);
|
|
207
|
-
return { name: "Build", ok: false, detail: `\u7F16\u8BD1\u5931\u8D25: ${msg.slice(0, 100)}` };
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async function runQualityReport(projectRoot, options) {
|
|
211
|
-
const checks = [];
|
|
212
|
-
const [todoResult, depResult, sizeResult] = await Promise.all([
|
|
213
|
-
checkTodos(projectRoot),
|
|
214
|
-
checkDeps(projectRoot),
|
|
215
|
-
checkPackageSize(projectRoot)
|
|
216
|
-
]);
|
|
217
|
-
checks.push(todoResult, depResult, sizeResult);
|
|
218
|
-
if (!options?.skipBuild) {
|
|
219
|
-
checks.push(await checkBuild(projectRoot));
|
|
220
|
-
}
|
|
221
|
-
if (!options?.skipTests) {
|
|
222
|
-
checks.push(await checkTests(projectRoot));
|
|
223
|
-
}
|
|
224
|
-
const score = calculateScore(checks);
|
|
225
|
-
return {
|
|
226
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
227
|
-
projectRoot,
|
|
228
|
-
checks,
|
|
229
|
-
score
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function calculateScore(checks) {
|
|
233
|
-
if (checks.length === 0) return 0;
|
|
234
|
-
const weights = {
|
|
235
|
-
"\u6D4B\u8BD5\u901A\u8FC7\u7387": 30,
|
|
236
|
-
"Build": 25,
|
|
237
|
-
"\u4F9D\u8D56\u68C0\u67E5": 20,
|
|
238
|
-
"TODO \u626B\u63CF": 15,
|
|
239
|
-
"\u5305\u4F53\u79EF": 10
|
|
240
|
-
};
|
|
241
|
-
let totalWeight = 0;
|
|
242
|
-
let weightedScore = 0;
|
|
243
|
-
for (const c of checks) {
|
|
244
|
-
const w = weights[c.name] || 10;
|
|
245
|
-
totalWeight += w;
|
|
246
|
-
if (c.ok) {
|
|
247
|
-
weightedScore += w;
|
|
248
|
-
} else if (c.value !== void 0 && c.unit === "%") {
|
|
249
|
-
weightedScore += w * (c.value / 100);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return totalWeight > 0 ? Math.round(weightedScore / totalWeight * 100) : 0;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export {
|
|
256
|
-
checkTests,
|
|
257
|
-
checkTodos,
|
|
258
|
-
checkDeps,
|
|
259
|
-
checkPackageSize,
|
|
260
|
-
checkBuild,
|
|
261
|
-
runQualityReport
|
|
262
|
-
};
|
package/dist/claude-O5FSOXZC.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadLocalToken
|
|
3
|
-
} from "./chunk-XMGHVNH2.js";
|
|
4
|
-
import {
|
|
5
|
-
showError,
|
|
6
|
-
showTaskList,
|
|
7
|
-
showTeamStatus
|
|
8
|
-
} from "./chunk-R3GPQC7I.js";
|
|
9
|
-
import "./chunk-BE46C7JW.js";
|
|
10
|
-
import "./chunk-RNG3K465.js";
|
|
11
|
-
import "./chunk-SVF2VWOZ.js";
|
|
12
|
-
|
|
13
|
-
// src/team/commands.ts
|
|
14
|
-
import chalk from "chalk";
|
|
15
|
-
function createTeamSlashCommands() {
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
name: "team",
|
|
19
|
-
description: "\u67E5\u770B\u56E2\u961F\u72B6\u6001",
|
|
20
|
-
category: "team",
|
|
21
|
-
handler: async (_args, _ctx) => {
|
|
22
|
-
const token = await loadLocalToken();
|
|
23
|
-
if (!token) {
|
|
24
|
-
console.log(chalk.dim("\n \u672A\u52A0\u5165\u56E2\u961F\u3002\u8BF7\u4F7F\u7528 hyper team create \u6216 hyper team join\n"));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const resp = await fetch(`${token.serverUrl}/api/team/${token.teamId}/status`, {
|
|
29
|
-
headers: { "Authorization": `Bearer ${token.token}` }
|
|
30
|
-
});
|
|
31
|
-
if (!resp.ok) {
|
|
32
|
-
showError("\u65E0\u6CD5\u83B7\u53D6\u56E2\u961F\u72B6\u6001");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const data = await resp.json();
|
|
36
|
-
showTeamStatus(data.team, data.members, token);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
showError(`\u8FDE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
39
|
-
console.log(chalk.dim(" \u8BF7\u786E\u4FDD\u56E2\u961F\u670D\u52A1\u5668\u5DF2\u542F\u52A8\uFF08hypercore web\uFF09"));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "task",
|
|
45
|
-
aliases: ["tasks"],
|
|
46
|
-
description: "\u56E2\u961F\u4EFB\u52A1 (add/list/done)",
|
|
47
|
-
category: "team",
|
|
48
|
-
handler: async (args, _ctx) => {
|
|
49
|
-
const token = await loadLocalToken();
|
|
50
|
-
if (!token) {
|
|
51
|
-
console.log(chalk.dim("\n \u672A\u52A0\u5165\u56E2\u961F\n"));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const sub = args[0] || "list";
|
|
55
|
-
const baseUrl = `${token.serverUrl}/api/team/${token.teamId}`;
|
|
56
|
-
const headers = {
|
|
57
|
-
"Authorization": `Bearer ${token.token}`,
|
|
58
|
-
"Content-Type": "application/json"
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
if (sub === "list" || sub === "ls") {
|
|
62
|
-
const resp = await fetch(`${baseUrl}/tasks`, { headers });
|
|
63
|
-
const data = await resp.json();
|
|
64
|
-
showTaskList(data.tasks);
|
|
65
|
-
} else if (sub === "add") {
|
|
66
|
-
const title = args.slice(1).join(" ");
|
|
67
|
-
if (!title) {
|
|
68
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /task add <\u6807\u9898>\n"));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const resp = await fetch(`${baseUrl}/tasks`, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers,
|
|
74
|
-
body: JSON.stringify({ title })
|
|
75
|
-
});
|
|
76
|
-
const data = await resp.json();
|
|
77
|
-
console.log(chalk.green(`
|
|
78
|
-
\u2705 \u4EFB\u52A1 #${data.task.id} \u5DF2\u521B\u5EFA: ${data.task.title}
|
|
79
|
-
`));
|
|
80
|
-
} else if (sub === "done") {
|
|
81
|
-
const taskId = args[1];
|
|
82
|
-
if (!taskId) {
|
|
83
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /task done <id>\n"));
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
await fetch(`${baseUrl}/tasks/${taskId}`, {
|
|
87
|
-
method: "PUT",
|
|
88
|
-
headers,
|
|
89
|
-
body: JSON.stringify({ status: "done" })
|
|
90
|
-
});
|
|
91
|
-
console.log(chalk.green(`
|
|
92
|
-
\u2705 \u4EFB\u52A1 #${taskId} \u5DF2\u5B8C\u6210
|
|
93
|
-
`));
|
|
94
|
-
} else if (sub === "assign") {
|
|
95
|
-
const taskId = args[1];
|
|
96
|
-
const memberName = args[2];
|
|
97
|
-
if (!taskId || !memberName) {
|
|
98
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /task assign <id> <\u6210\u5458>\n"));
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const statusResp = await fetch(`${token.serverUrl}/api/team/${token.teamId}/status`, { headers });
|
|
102
|
-
const statusData = await statusResp.json();
|
|
103
|
-
const target = statusData.members.find((m) => m.name === memberName || m.id === memberName);
|
|
104
|
-
if (!target) {
|
|
105
|
-
showError(`\u672A\u627E\u5230\u6210\u5458: ${memberName}`);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
await fetch(`${baseUrl}/tasks/${taskId}`, {
|
|
109
|
-
method: "PUT",
|
|
110
|
-
headers,
|
|
111
|
-
body: JSON.stringify({ assignee: target.id, status: "doing" })
|
|
112
|
-
});
|
|
113
|
-
console.log(chalk.green(`
|
|
114
|
-
\u2705 \u4EFB\u52A1 #${taskId} \u5DF2\u5206\u914D\u7ED9 ${target.name}
|
|
115
|
-
`));
|
|
116
|
-
} else {
|
|
117
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /task [list|add|done|assign]\n"));
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
showError(`\u8BF7\u6C42\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
];
|
|
125
|
-
}
|
|
126
|
-
export {
|
|
127
|
-
createTeamSlashCommands
|
|
128
|
-
};
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CATEGORY_LABELS,
|
|
3
|
-
addMemory,
|
|
4
|
-
getMemoryStats,
|
|
5
|
-
listMemories,
|
|
6
|
-
removeMemory,
|
|
7
|
-
searchMemories
|
|
8
|
-
} from "./chunk-7ZYMJFCA.js";
|
|
9
|
-
import "./chunk-SVF2VWOZ.js";
|
|
10
|
-
|
|
11
|
-
// src/memory/commands.ts
|
|
12
|
-
import chalk from "chalk";
|
|
13
|
-
function createMemorySlashCommands() {
|
|
14
|
-
return [
|
|
15
|
-
// /remember <内容> — 手动保存记忆
|
|
16
|
-
{
|
|
17
|
-
name: "remember",
|
|
18
|
-
aliases: ["rem"],
|
|
19
|
-
description: "\u4FDD\u5B58\u4E00\u6761\u8BB0\u5FC6\uFF08/remember <\u5185\u5BB9>\uFF09",
|
|
20
|
-
category: "memory",
|
|
21
|
-
handler: async (args, _ctx) => {
|
|
22
|
-
const content = args.join(" ").trim();
|
|
23
|
-
if (!content) {
|
|
24
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /remember <\u8981\u8BB0\u4F4F\u7684\u5185\u5BB9>\n"));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (content.length > 500) {
|
|
28
|
-
console.log(chalk.yellow("\n \u26A0\uFE0F \u5185\u5BB9\u8FC7\u957F\uFF08\u4E0A\u9650 500 \u5B57\u7B26\uFF09\uFF0C\u5DF2\u622A\u65AD\n"));
|
|
29
|
-
}
|
|
30
|
-
const tagMatches = content.match(/#(\w+)/g);
|
|
31
|
-
const tags = tagMatches ? tagMatches.map((t) => t.slice(1).toLowerCase()) : [];
|
|
32
|
-
const cleanContent = content.replace(/#\w+/g, "").trim().slice(0, 500);
|
|
33
|
-
const record = await addMemory("personal", {
|
|
34
|
-
layer: "personal",
|
|
35
|
-
category: "manual",
|
|
36
|
-
content: cleanContent,
|
|
37
|
-
tags: tags.length > 0 ? tags : extractAutoTags(cleanContent),
|
|
38
|
-
confidence: 1
|
|
39
|
-
});
|
|
40
|
-
console.log(chalk.green(`
|
|
41
|
-
\u2705 \u5DF2\u4FDD\u5B58\u8BB0\u5FC6: ${record.id}`));
|
|
42
|
-
console.log(chalk.dim(` ${cleanContent}`));
|
|
43
|
-
if (record.tags.length > 0) {
|
|
44
|
-
console.log(chalk.dim(` \u6807\u7B7E: ${record.tags.map((t) => `#${t}`).join(" ")}`));
|
|
45
|
-
}
|
|
46
|
-
console.log();
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
// /recall [主题] — 搜索记忆
|
|
50
|
-
{
|
|
51
|
-
name: "recall",
|
|
52
|
-
aliases: ["search-mem"],
|
|
53
|
-
description: "\u641C\u7D22\u8BB0\u5FC6\uFF08/recall [\u4E3B\u9898]\uFF09",
|
|
54
|
-
category: "memory",
|
|
55
|
-
handler: async (args, _ctx) => {
|
|
56
|
-
const query = args.join(" ").trim();
|
|
57
|
-
if (!query) {
|
|
58
|
-
const records = await listMemories("personal");
|
|
59
|
-
if (records.length === 0) {
|
|
60
|
-
console.log(chalk.dim("\n \u6682\u65E0\u8BB0\u5FC6\u3002\u4F7F\u7528 /remember <\u5185\u5BB9> \u4FDD\u5B58\n"));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
console.log(chalk.bold(`
|
|
64
|
-
\u{1F9E0} \u5168\u90E8\u8BB0\u5FC6 (${records.length} \u6761)
|
|
65
|
-
`));
|
|
66
|
-
for (const r of records.slice(0, 20)) {
|
|
67
|
-
const catLabel = CATEGORY_LABELS[r.category] || r.category;
|
|
68
|
-
const tags = r.tags.map((t) => chalk.dim(`#${t}`)).join(" ");
|
|
69
|
-
console.log(` ${chalk.dim(r.id.slice(4, 22))} [${chalk.cyan(catLabel)}] ${r.content} ${tags}`);
|
|
70
|
-
}
|
|
71
|
-
if (records.length > 20) {
|
|
72
|
-
console.log(chalk.dim(` ... \u8FD8\u6709 ${records.length - 20} \u6761`));
|
|
73
|
-
}
|
|
74
|
-
console.log();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const results = await searchMemories("personal", query);
|
|
78
|
-
if (results.length === 0) {
|
|
79
|
-
console.log(chalk.dim(`
|
|
80
|
-
\u672A\u627E\u5230\u4E0E "${query}" \u76F8\u5173\u7684\u8BB0\u5FC6
|
|
81
|
-
`));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
console.log(chalk.bold(`
|
|
85
|
-
\u{1F50D} \u641C\u7D22\u7ED3\u679C: "${query}" (${results.length} \u6761)
|
|
86
|
-
`));
|
|
87
|
-
for (const { record: r, score } of results) {
|
|
88
|
-
const catLabel = CATEGORY_LABELS[r.category] || r.category;
|
|
89
|
-
const tags = r.tags.map((t) => chalk.dim(`#${t}`)).join(" ");
|
|
90
|
-
const scoreStr = chalk.dim(`${Math.round(score * 100)}%`);
|
|
91
|
-
console.log(` ${scoreStr} [${chalk.cyan(catLabel)}] ${r.content} ${tags}`);
|
|
92
|
-
}
|
|
93
|
-
console.log();
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
// /memory — 记忆统计
|
|
97
|
-
{
|
|
98
|
-
name: "memory",
|
|
99
|
-
aliases: ["mem"],
|
|
100
|
-
description: "\u663E\u793A\u8BB0\u5FC6\u7CFB\u7EDF\u72B6\u6001",
|
|
101
|
-
category: "memory",
|
|
102
|
-
handler: async (_args, _ctx) => {
|
|
103
|
-
const stats = await getMemoryStats("personal");
|
|
104
|
-
console.log(chalk.bold("\n \u{1F9E0} \u8BB0\u5FC6\u7CFB\u7EDF\u72B6\u6001\n"));
|
|
105
|
-
console.log(` ${chalk.dim("\u5C42\u7EA7:")} \u4E2A\u4EBA (personal)`);
|
|
106
|
-
console.log(` ${chalk.dim("\u603B\u6761\u6570:")} ${stats.total}`);
|
|
107
|
-
if (Object.keys(stats.byCategory).length > 0) {
|
|
108
|
-
console.log(` ${chalk.dim("\u5206\u7C7B\u5206\u5E03:")}`);
|
|
109
|
-
for (const [cat, count] of Object.entries(stats.byCategory)) {
|
|
110
|
-
const label = CATEGORY_LABELS[cat] || cat;
|
|
111
|
-
console.log(` ${chalk.dim(label + ":")} ${count}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (stats.lastExtractionAt) {
|
|
115
|
-
const lastTime = new Date(stats.lastExtractionAt).toLocaleString("zh-CN");
|
|
116
|
-
console.log(` ${chalk.dim("\u4E0A\u6B21\u63D0\u53D6:")} ${lastTime}`);
|
|
117
|
-
} else {
|
|
118
|
-
console.log(` ${chalk.dim("\u4E0A\u6B21\u63D0\u53D6:")} \u4ECE\u672A`);
|
|
119
|
-
}
|
|
120
|
-
console.log(` ${chalk.dim("\u603B\u63D0\u53D6\u6B21\u6570:")} ${stats.totalExtractions}`);
|
|
121
|
-
console.log();
|
|
122
|
-
try {
|
|
123
|
-
const projectStats = await getMemoryStats("project");
|
|
124
|
-
if (projectStats.total > 0) {
|
|
125
|
-
console.log(` ${chalk.dim("\u9879\u76EE\u8BB0\u5FC6:")} ${projectStats.total} \u6761`);
|
|
126
|
-
console.log();
|
|
127
|
-
}
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
// /forget <id> — 删除记忆
|
|
133
|
-
{
|
|
134
|
-
name: "forget",
|
|
135
|
-
description: "\u5220\u9664\u6307\u5B9A\u8BB0\u5FC6\uFF08/forget <id>\uFF09",
|
|
136
|
-
category: "memory",
|
|
137
|
-
handler: async (args, _ctx) => {
|
|
138
|
-
const idFragment = args[0]?.trim();
|
|
139
|
-
if (!idFragment) {
|
|
140
|
-
console.log(chalk.dim("\n \u7528\u6CD5: /forget <id> \uFF08\u4F7F\u7528 /recall \u67E5\u770B ID\uFF09\n"));
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const records = await listMemories("personal");
|
|
144
|
-
const match = records.find((r) => r.id.includes(idFragment));
|
|
145
|
-
if (!match) {
|
|
146
|
-
console.log(chalk.red(`
|
|
147
|
-
\u672A\u627E\u5230 ID \u5305\u542B "${idFragment}" \u7684\u8BB0\u5FC6
|
|
148
|
-
`));
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const removed = await removeMemory("personal", match.id);
|
|
152
|
-
if (removed) {
|
|
153
|
-
console.log(chalk.green(`
|
|
154
|
-
\u2705 \u5DF2\u5220\u9664: ${match.content.slice(0, 60)}
|
|
155
|
-
`));
|
|
156
|
-
} else {
|
|
157
|
-
console.log(chalk.red(`
|
|
158
|
-
\u5220\u9664\u5931\u8D25
|
|
159
|
-
`));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
// /mem-extract — 手动触发提取
|
|
164
|
-
{
|
|
165
|
-
name: "mem-extract",
|
|
166
|
-
aliases: ["extract"],
|
|
167
|
-
description: "\u4ECE\u5F53\u524D\u4F1A\u8BDD\u63D0\u53D6\u8BB0\u5FC6",
|
|
168
|
-
category: "memory",
|
|
169
|
-
handler: async (_args, ctx) => {
|
|
170
|
-
if (ctx.chatHistory.length < 4) {
|
|
171
|
-
console.log(chalk.dim("\n \u5BF9\u8BDD\u592A\u77ED\uFF08\u81F3\u5C11 4 \u6761\u6D88\u606F\uFF09\uFF0C\u6682\u65E0\u6CD5\u63D0\u53D6\n"));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
console.log(chalk.dim("\n \u{1F504} \u6B63\u5728\u4ECE\u5F53\u524D\u4F1A\u8BDD\u63D0\u53D6\u8BB0\u5FC6...\n"));
|
|
175
|
-
try {
|
|
176
|
-
const { extractMemories } = await import("./extractor-R5ABXNTJ.js");
|
|
177
|
-
const extracted = await extractMemories(
|
|
178
|
-
ctx.chatHistory,
|
|
179
|
-
ctx.getClient(),
|
|
180
|
-
ctx.config,
|
|
181
|
-
"personal"
|
|
182
|
-
);
|
|
183
|
-
if (extracted.length === 0) {
|
|
184
|
-
console.log(chalk.dim(" \u672A\u53D1\u73B0\u65B0\u7684\u8BB0\u5FC6\u5185\u5BB9\n"));
|
|
185
|
-
} else {
|
|
186
|
-
console.log(chalk.green(` \u2705 \u63D0\u53D6\u4E86 ${extracted.length} \u6761\u8BB0\u5FC6:
|
|
187
|
-
`));
|
|
188
|
-
for (const r of extracted) {
|
|
189
|
-
const catLabel = CATEGORY_LABELS[r.category] || r.category;
|
|
190
|
-
console.log(` [${chalk.cyan(catLabel)}] ${r.content}`);
|
|
191
|
-
}
|
|
192
|
-
console.log();
|
|
193
|
-
}
|
|
194
|
-
} catch (err) {
|
|
195
|
-
console.log(chalk.red(` \u63D0\u53D6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}
|
|
196
|
-
`));
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
];
|
|
201
|
-
}
|
|
202
|
-
function extractAutoTags(content) {
|
|
203
|
-
const tags = [];
|
|
204
|
-
const lower = content.toLowerCase();
|
|
205
|
-
const techTerms = [
|
|
206
|
-
"typescript",
|
|
207
|
-
"javascript",
|
|
208
|
-
"python",
|
|
209
|
-
"react",
|
|
210
|
-
"vue",
|
|
211
|
-
"node",
|
|
212
|
-
"git",
|
|
213
|
-
"npm",
|
|
214
|
-
"pnpm",
|
|
215
|
-
"docker",
|
|
216
|
-
"api",
|
|
217
|
-
"css",
|
|
218
|
-
"html",
|
|
219
|
-
"json",
|
|
220
|
-
"markdown",
|
|
221
|
-
"bash",
|
|
222
|
-
"linux",
|
|
223
|
-
"macos"
|
|
224
|
-
];
|
|
225
|
-
for (const term of techTerms) {
|
|
226
|
-
if (lower.includes(term)) tags.push(term);
|
|
227
|
-
}
|
|
228
|
-
return tags.slice(0, 3);
|
|
229
|
-
}
|
|
230
|
-
export {
|
|
231
|
-
createMemorySlashCommands
|
|
232
|
-
};
|