hypercore-cli 1.1.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 +21 -0
- package/README.md +110 -0
- package/dist/api-XGC7D5AW.js +162 -0
- package/dist/auth-DNQWYQKT.js +21 -0
- package/dist/background-2EGCAAQH.js +14 -0
- package/dist/backlog-Q2NZCLNY.js +24 -0
- package/dist/chunk-2CMSCWQW.js +162 -0
- package/dist/chunk-2LJ2DVEB.js +167 -0
- package/dist/chunk-3RPFCQKJ.js +288 -0
- package/dist/chunk-43OLRXM5.js +263 -0
- package/dist/chunk-4DVYJAJL.js +57 -0
- package/dist/chunk-6OL3GA3P.js +173 -0
- package/dist/chunk-AUHU7ALH.js +2023 -0
- package/dist/chunk-B6A2AKLN.js +139 -0
- package/dist/chunk-BE46C7JW.js +46 -0
- package/dist/chunk-CUVAUOXL.js +58 -0
- package/dist/chunk-GH7E2OJE.js +223 -0
- package/dist/chunk-GOOTEPBK.js +271 -0
- package/dist/chunk-GPPMJYSM.js +133 -0
- package/dist/chunk-GU2FZQ6A.js +69 -0
- package/dist/chunk-IOPKN5GD.js +190 -0
- package/dist/chunk-IXOIOGR5.js +1505 -0
- package/dist/chunk-KRPOPWGA.js +251 -0
- package/dist/chunk-MGLJ53QN.js +219 -0
- package/dist/chunk-MV4TTRYX.js +533 -0
- package/dist/chunk-OPZYEVYR.js +150 -0
- package/dist/chunk-QTSLP47C.js +166 -0
- package/dist/chunk-R3GPQC7I.js +393 -0
- package/dist/chunk-RKB2JOV2.js +43 -0
- package/dist/chunk-RNG3K465.js +80 -0
- package/dist/chunk-TGTYKBGC.js +86 -0
- package/dist/chunk-U5SGAIMM.js +681 -0
- package/dist/chunk-V5UHPPSY.js +140 -0
- package/dist/chunk-WHLVZCQY.js +245 -0
- package/dist/chunk-XDRCBMZZ.js +66 -0
- package/dist/chunk-XOS6HPEF.js +134 -0
- package/dist/chunk-ZSBHUGWR.js +262 -0
- package/dist/claude-NSQ442XD.js +12 -0
- package/dist/commands-CK3WFAGI.js +128 -0
- package/dist/commands-U63OEO5J.js +1044 -0
- package/dist/commands-ZE6GD3WC.js +232 -0
- package/dist/config-4EW42BSF.js +8 -0
- package/dist/config-loader-SXO674TF.js +24 -0
- package/dist/diagnose-AFW3ZTZ4.js +12 -0
- package/dist/display-IIUBEYWN.js +58 -0
- package/dist/extractor-QV53W2YJ.js +129 -0
- package/dist/history-WMSCHERZ.js +180 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +406 -0
- package/dist/instance-registry-YSIJXSO7.js +15 -0
- package/dist/keybindings-JAAMLH3G.js +15 -0
- package/dist/loader-WHNTZTLP.js +58 -0
- package/dist/network-MM6YWPGO.js +279 -0
- package/dist/notify-HPTALZDC.js +14 -0
- package/dist/openai-compat-UQWJXBEK.js +12 -0
- package/dist/permissions-JUKXMNDH.js +10 -0
- package/dist/prompt-QV45TXRL.js +166 -0
- package/dist/quality-ST7PPNFR.js +16 -0
- package/dist/repl-RT3AHL7M.js +3375 -0
- package/dist/roadmap-5OBEKROY.js +17 -0
- package/dist/server-PORT7OEG.js +57 -0
- package/dist/session-4VUNDWLH.js +21 -0
- package/dist/skills-V4A35XKG.js +175 -0
- package/dist/store-Y4LU5QTO.js +25 -0
- package/dist/team-HO7Z4SIM.js +385 -0
- package/dist/telemetry-6R4EIE6O.js +30 -0
- package/dist/test-runner-ZQH5Y6OJ.js +619 -0
- package/dist/theme-3SYJ3UQA.js +14 -0
- package/dist/upgrade-7TGI3SXO.js +83 -0
- package/dist/verify-JUDKTPKZ.js +14 -0
- package/dist/web/static/app.js +562 -0
- package/dist/web/static/index.html +132 -0
- package/dist/web/static/mirror.css +1001 -0
- package/dist/web/static/mirror.html +184 -0
- package/dist/web/static/mirror.js +1125 -0
- package/dist/web/static/onboard.css +302 -0
- package/dist/web/static/onboard.html +140 -0
- package/dist/web/static/onboard.js +260 -0
- package/dist/web/static/style.css +602 -0
- package/dist/web/static/workspace.css +1568 -0
- package/dist/web/static/workspace.html +408 -0
- package/dist/web/static/workspace.js +1683 -0
- package/dist/web-Z5HSCQHW.js +39 -0
- package/package.json +67 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeRound,
|
|
3
|
+
gatherProfile,
|
|
4
|
+
getLatestRound,
|
|
5
|
+
listRounds,
|
|
6
|
+
loadNetworkConfig,
|
|
7
|
+
saveNetworkConfig,
|
|
8
|
+
startAutoRound,
|
|
9
|
+
stopAutoRound,
|
|
10
|
+
updateProfileField
|
|
11
|
+
} from "./chunk-U5SGAIMM.js";
|
|
12
|
+
import "./chunk-2LJ2DVEB.js";
|
|
13
|
+
import "./chunk-6OL3GA3P.js";
|
|
14
|
+
import {
|
|
15
|
+
loadLocalToken
|
|
16
|
+
} from "./chunk-XDRCBMZZ.js";
|
|
17
|
+
import {
|
|
18
|
+
showError
|
|
19
|
+
} from "./chunk-R3GPQC7I.js";
|
|
20
|
+
import "./chunk-BE46C7JW.js";
|
|
21
|
+
import "./chunk-RNG3K465.js";
|
|
22
|
+
import "./chunk-43OLRXM5.js";
|
|
23
|
+
import "./chunk-GOOTEPBK.js";
|
|
24
|
+
import "./chunk-B6A2AKLN.js";
|
|
25
|
+
import {
|
|
26
|
+
loadConfig
|
|
27
|
+
} from "./chunk-V5UHPPSY.js";
|
|
28
|
+
|
|
29
|
+
// src/commands/network.ts
|
|
30
|
+
import chalk from "chalk";
|
|
31
|
+
async function requireToken() {
|
|
32
|
+
const token = await loadLocalToken();
|
|
33
|
+
if (!token) {
|
|
34
|
+
showError("\u672A\u52A0\u5165\u4EFB\u4F55\u56E2\u961F\u3002\u8BF7\u5148 hyper team create \u6216 hyper team join");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return token;
|
|
38
|
+
}
|
|
39
|
+
async function networkProfileCommand(field, values) {
|
|
40
|
+
const token = await requireToken();
|
|
41
|
+
if (!token) return;
|
|
42
|
+
if (!field) {
|
|
43
|
+
const profile2 = await gatherProfile(token.teamId, token.memberId, token.memberName);
|
|
44
|
+
displayProfile(profile2);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const validFields = ["skills", "needs", "offerings", "customNote"];
|
|
48
|
+
if (!validFields.includes(field)) {
|
|
49
|
+
console.log(chalk.dim(`
|
|
50
|
+
\u7528\u6CD5: hyper network profile [${validFields.join("|")}] <\u503C>
|
|
51
|
+
`));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!values || values.length === 0) {
|
|
55
|
+
showError(`\u8BF7\u63D0\u4F9B ${field} \u7684\u503C`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const valueStr = values.join(" ");
|
|
59
|
+
let parsedValue;
|
|
60
|
+
if (field === "customNote") {
|
|
61
|
+
parsedValue = valueStr;
|
|
62
|
+
} else {
|
|
63
|
+
parsedValue = valueStr.split(/[,,]/).map((s) => s.trim()).filter(Boolean);
|
|
64
|
+
}
|
|
65
|
+
const profile = await updateProfileField(
|
|
66
|
+
token.teamId,
|
|
67
|
+
token.memberId,
|
|
68
|
+
field,
|
|
69
|
+
parsedValue
|
|
70
|
+
);
|
|
71
|
+
if (!profile) {
|
|
72
|
+
await gatherProfile(token.teamId, token.memberId, token.memberName);
|
|
73
|
+
const updated = await updateProfileField(
|
|
74
|
+
token.teamId,
|
|
75
|
+
token.memberId,
|
|
76
|
+
field,
|
|
77
|
+
parsedValue
|
|
78
|
+
);
|
|
79
|
+
if (updated) displayProfile(updated);
|
|
80
|
+
} else {
|
|
81
|
+
displayProfile(profile);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function networkRunCommand() {
|
|
85
|
+
const token = await requireToken();
|
|
86
|
+
if (!token) return;
|
|
87
|
+
const config = await loadConfig();
|
|
88
|
+
console.log(chalk.cyan("\n \u{1F310} Hyper Network \u2014 \u6267\u884C\u7F51\u7EDC\u5339\u914D\u8F6E\u6B21\n"));
|
|
89
|
+
try {
|
|
90
|
+
const round = await executeRound(token.teamId, token.memberId, config, (stage, detail) => {
|
|
91
|
+
const icons = {
|
|
92
|
+
gather: "\u{1F4CB}",
|
|
93
|
+
match: "\u{1F50D}",
|
|
94
|
+
dialogue: "\u{1F4AC}",
|
|
95
|
+
digest: "\u{1F4DD}",
|
|
96
|
+
done: "\u2705"
|
|
97
|
+
};
|
|
98
|
+
console.log(` ${icons[stage] || "\xB7"} ${chalk.dim(detail || stage)}`);
|
|
99
|
+
});
|
|
100
|
+
console.log();
|
|
101
|
+
displayRoundSummary(round);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
showError(`\u6267\u884C\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function networkDigestCommand() {
|
|
107
|
+
const token = await requireToken();
|
|
108
|
+
if (!token) return;
|
|
109
|
+
const latestRound = await getLatestRound(token.teamId);
|
|
110
|
+
if (!latestRound) {
|
|
111
|
+
console.log(chalk.dim("\n \u6682\u65E0\u7F51\u7EDC\u5339\u914D\u8BB0\u5F55\u3002\u8BF7\u5148\u8FD0\u884C hyper network run\n"));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const myDigest = latestRound.digests.find((d) => d.memberId === token.memberId);
|
|
115
|
+
if (!myDigest) {
|
|
116
|
+
console.log(chalk.dim("\n \u6700\u8FD1\u4E00\u8F6E\u6CA1\u6709\u4F60\u7684\u5339\u914D\u7ED3\u679C\n"));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
displayDigest(myDigest);
|
|
120
|
+
}
|
|
121
|
+
async function networkAutoCommand(action) {
|
|
122
|
+
const token = await requireToken();
|
|
123
|
+
if (!token) return;
|
|
124
|
+
const netConfig = await loadNetworkConfig(token.teamId);
|
|
125
|
+
if (action === "on") {
|
|
126
|
+
netConfig.autoEnabled = true;
|
|
127
|
+
await saveNetworkConfig(token.teamId, netConfig);
|
|
128
|
+
const config = await loadConfig();
|
|
129
|
+
await startAutoRound(token.teamId, config);
|
|
130
|
+
const hours = netConfig.autoIntervalMs / (60 * 60 * 1e3);
|
|
131
|
+
console.log(chalk.green(`
|
|
132
|
+
\u2705 \u81EA\u52A8\u7F51\u7EDC\u5339\u914D\u5DF2\u5F00\u542F\uFF08\u6BCF ${hours} \u5C0F\u65F6\uFF09
|
|
133
|
+
`));
|
|
134
|
+
} else if (action === "off") {
|
|
135
|
+
netConfig.autoEnabled = false;
|
|
136
|
+
await saveNetworkConfig(token.teamId, netConfig);
|
|
137
|
+
stopAutoRound();
|
|
138
|
+
console.log(chalk.dim("\n \u81EA\u52A8\u7F51\u7EDC\u5339\u914D\u5DF2\u5173\u95ED\n"));
|
|
139
|
+
} else {
|
|
140
|
+
console.log(chalk.dim("\n \u7528\u6CD5: hyper network auto [on|off]\n"));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function networkRoundsCommand() {
|
|
144
|
+
const token = await requireToken();
|
|
145
|
+
if (!token) return;
|
|
146
|
+
const rounds = await listRounds(token.teamId);
|
|
147
|
+
if (rounds.length === 0) {
|
|
148
|
+
console.log(chalk.dim("\n \u6682\u65E0\u8F6E\u6B21\u8BB0\u5F55\n"));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
console.log(chalk.bold("\n \u{1F4CB} \u7F51\u7EDC\u5339\u914D\u5386\u53F2\n"));
|
|
152
|
+
for (const round of rounds.slice(0, 10)) {
|
|
153
|
+
const status = round.status === "completed" ? chalk.green("\u2713") : round.status === "failed" ? chalk.red("\u2717") : chalk.yellow("\u2026");
|
|
154
|
+
const time = new Date(round.startedAt).toLocaleString("zh-CN");
|
|
155
|
+
const trigger = round.triggeredBy === "auto" ? "\u81EA\u52A8" : "\u624B\u52A8";
|
|
156
|
+
console.log(` ${status} ${chalk.white(round.id.slice(0, 8))} ${chalk.dim(time)} ${chalk.dim(trigger)} ${round.matches.length}\u5BF9\u5339\u914D ${round.dialogues.length}\u573A\u5BF9\u8BDD`);
|
|
157
|
+
if (round.error) {
|
|
158
|
+
console.log(` ${chalk.red(round.error)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
console.log();
|
|
162
|
+
}
|
|
163
|
+
async function networkConfigCommand(key, value) {
|
|
164
|
+
const token = await requireToken();
|
|
165
|
+
if (!token) return;
|
|
166
|
+
const netConfig = await loadNetworkConfig(token.teamId);
|
|
167
|
+
if (!key) {
|
|
168
|
+
console.log(chalk.bold("\n \u2699\uFE0F Network \u914D\u7F6E\n"));
|
|
169
|
+
console.log(` ${chalk.dim("\u81EA\u52A8\u8F6E\u6B21:")} ${netConfig.autoEnabled ? chalk.green("\u5F00\u542F") : chalk.dim("\u5173\u95ED")}`);
|
|
170
|
+
console.log(` ${chalk.dim("\u95F4\u9694\u65F6\u95F4:")} ${netConfig.autoIntervalMs / (60 * 60 * 1e3)} \u5C0F\u65F6`);
|
|
171
|
+
console.log(` ${chalk.dim("\u8F6E\u6B21\u9884\u7B97:")} $${netConfig.budgetPerRoundUSD}`);
|
|
172
|
+
console.log(` ${chalk.dim("\u5339\u914D\u6A21\u578B:")} ${netConfig.matchmakerModel}`);
|
|
173
|
+
console.log(` ${chalk.dim("\u5BF9\u8BDD\u6A21\u578B:")} ${netConfig.dialogueModel}`);
|
|
174
|
+
console.log(` ${chalk.dim("\u5BF9\u8BDD\u8F6E\u6570:")} ${netConfig.maxDialogueTurns}`);
|
|
175
|
+
console.log(` ${chalk.dim("\u6700\u5927\u914D\u5BF9:")} ${netConfig.maxMatchPairs}`);
|
|
176
|
+
console.log();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (!value) {
|
|
180
|
+
showError(`\u8BF7\u63D0\u4F9B ${key} \u7684\u503C`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const configMap = {
|
|
184
|
+
model: (v) => {
|
|
185
|
+
netConfig.matchmakerModel = v;
|
|
186
|
+
netConfig.dialogueModel = v;
|
|
187
|
+
},
|
|
188
|
+
matchModel: (v) => {
|
|
189
|
+
netConfig.matchmakerModel = v;
|
|
190
|
+
},
|
|
191
|
+
dialogueModel: (v) => {
|
|
192
|
+
netConfig.dialogueModel = v;
|
|
193
|
+
},
|
|
194
|
+
budget: (v) => {
|
|
195
|
+
netConfig.budgetPerRoundUSD = parseFloat(v);
|
|
196
|
+
},
|
|
197
|
+
interval: (v) => {
|
|
198
|
+
netConfig.autoIntervalMs = parseFloat(v) * 60 * 60 * 1e3;
|
|
199
|
+
},
|
|
200
|
+
turns: (v) => {
|
|
201
|
+
netConfig.maxDialogueTurns = parseInt(v, 10);
|
|
202
|
+
},
|
|
203
|
+
maxPairs: (v) => {
|
|
204
|
+
netConfig.maxMatchPairs = parseInt(v, 10);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
if (!configMap[key]) {
|
|
208
|
+
console.log(chalk.dim(`
|
|
209
|
+
\u53EF\u914D\u7F6E\u9879: ${Object.keys(configMap).join(", ")}
|
|
210
|
+
`));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
configMap[key](value);
|
|
214
|
+
await saveNetworkConfig(token.teamId, netConfig);
|
|
215
|
+
console.log(chalk.green(`
|
|
216
|
+
\u2705 ${key} \u5DF2\u66F4\u65B0
|
|
217
|
+
`));
|
|
218
|
+
}
|
|
219
|
+
function displayProfile(profile) {
|
|
220
|
+
console.log(chalk.bold(`
|
|
221
|
+
\u{1F9EC} Agent Profile \u2014 ${profile.memberName}
|
|
222
|
+
`));
|
|
223
|
+
console.log(` ${chalk.dim("\u6280\u80FD:")} ${profile.skills.length > 0 ? profile.skills.join(", ") : chalk.dim("\u672A\u8BBE\u7F6E")}`);
|
|
224
|
+
console.log(` ${chalk.dim("\u9700\u6C42:")} ${profile.needs.length > 0 ? profile.needs.join(", ") : chalk.dim("\u672A\u8BBE\u7F6E")}`);
|
|
225
|
+
console.log(` ${chalk.dim("\u53EF\u63D0\u4F9B:")} ${profile.offerings.length > 0 ? profile.offerings.join(", ") : chalk.dim("\u672A\u8BBE\u7F6E")}`);
|
|
226
|
+
console.log(` ${chalk.dim("\u8FD1\u671F:")} ${profile.recentContext}`);
|
|
227
|
+
if (profile.customNote) {
|
|
228
|
+
console.log(` ${chalk.dim("\u5907\u6CE8:")} ${profile.customNote}`);
|
|
229
|
+
}
|
|
230
|
+
console.log(` ${chalk.dim("\u4EFB\u52A1\u6570:")} ${profile.currentTasks.length}`);
|
|
231
|
+
console.log();
|
|
232
|
+
}
|
|
233
|
+
function displayDigest(digest) {
|
|
234
|
+
console.log(chalk.bold(`
|
|
235
|
+
\u{1F4E8} Hyper Network \u6458\u8981 \u2014 ${digest.memberName}
|
|
236
|
+
`));
|
|
237
|
+
console.log(chalk.dim(` \u751F\u6210\u65F6\u95F4: ${new Date(digest.generatedAt).toLocaleString("zh-CN")}
|
|
238
|
+
`));
|
|
239
|
+
for (const match of digest.matches) {
|
|
240
|
+
console.log(` ${chalk.cyan("\u2194")} \u4E0E ${chalk.bold(match.partnerName)} \u7684\u4EA4\u6D41`);
|
|
241
|
+
console.log(` ${chalk.dim("\u5339\u914D\u539F\u56E0:")} ${match.reason}`);
|
|
242
|
+
console.log(` ${chalk.dim("\u5BF9\u4F60\u7684\u4EF7\u503C:")} ${match.valueForMe}`);
|
|
243
|
+
if (match.keyInsights.length > 0) {
|
|
244
|
+
console.log(` ${chalk.dim("\u5173\u952E\u4FE1\u606F:")}`);
|
|
245
|
+
for (const insight of match.keyInsights) {
|
|
246
|
+
console.log(` \xB7 ${insight}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (match.actionItems.length > 0) {
|
|
250
|
+
console.log(` ${chalk.dim("\u5EFA\u8BAE\u884C\u52A8:")}`);
|
|
251
|
+
for (const item of match.actionItems) {
|
|
252
|
+
console.log(` \u2192 ${item}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
console.log();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function displayRoundSummary(round) {
|
|
259
|
+
const duration = round.completedAt ? ((new Date(round.completedAt).getTime() - new Date(round.startedAt).getTime()) / 1e3).toFixed(1) : "?";
|
|
260
|
+
console.log(chalk.bold(` \u{1F4CA} \u8F6E\u6B21\u603B\u7ED3 #${round.id.slice(0, 8)}`));
|
|
261
|
+
console.log(` ${chalk.dim("\u72B6\u6001:")} ${round.status === "completed" ? chalk.green("\u5B8C\u6210") : chalk.red(round.status)}`);
|
|
262
|
+
console.log(` ${chalk.dim("\u8017\u65F6:")} ${duration}s`);
|
|
263
|
+
console.log(` ${chalk.dim("\u5339\u914D:")} ${round.matches.length} \u5BF9`);
|
|
264
|
+
console.log(` ${chalk.dim("\u5BF9\u8BDD:")} ${round.dialogues.length} \u573A`);
|
|
265
|
+
console.log(` ${chalk.dim("\u6458\u8981:")} ${round.digests.length} \u4EFD`);
|
|
266
|
+
console.log(` ${chalk.dim("Token:")} ${round.totalTokenUsage.inputTokens + round.totalTokenUsage.outputTokens} (in: ${round.totalTokenUsage.inputTokens}, out: ${round.totalTokenUsage.outputTokens})`);
|
|
267
|
+
if (round.error) {
|
|
268
|
+
console.log(` ${chalk.red("\u9519\u8BEF:")} ${round.error}`);
|
|
269
|
+
}
|
|
270
|
+
console.log();
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
networkAutoCommand,
|
|
274
|
+
networkConfigCommand,
|
|
275
|
+
networkDigestCommand,
|
|
276
|
+
networkProfileCommand,
|
|
277
|
+
networkRoundsCommand,
|
|
278
|
+
networkRunCommand
|
|
279
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bellNotify,
|
|
3
|
+
isNotificationsEnabled,
|
|
4
|
+
notifyIfLong,
|
|
5
|
+
sendNotification,
|
|
6
|
+
setNotificationsEnabled
|
|
7
|
+
} from "./chunk-4DVYJAJL.js";
|
|
8
|
+
export {
|
|
9
|
+
bellNotify,
|
|
10
|
+
isNotificationsEnabled,
|
|
11
|
+
notifyIfLong,
|
|
12
|
+
sendNotification,
|
|
13
|
+
setNotificationsEnabled
|
|
14
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
closeMCPConnections,
|
|
3
|
+
createToolRegistry
|
|
4
|
+
} from "./chunk-IXOIOGR5.js";
|
|
5
|
+
import "./chunk-KRPOPWGA.js";
|
|
6
|
+
import "./chunk-GU2FZQ6A.js";
|
|
7
|
+
import {
|
|
8
|
+
createLLMClient,
|
|
9
|
+
streamCallLLM
|
|
10
|
+
} from "./chunk-43OLRXM5.js";
|
|
11
|
+
import {
|
|
12
|
+
createOpenAIClient,
|
|
13
|
+
streamOpenAIChat
|
|
14
|
+
} from "./chunk-GOOTEPBK.js";
|
|
15
|
+
import "./chunk-B6A2AKLN.js";
|
|
16
|
+
import {
|
|
17
|
+
HYPERCORE_DIR,
|
|
18
|
+
loadConfig
|
|
19
|
+
} from "./chunk-V5UHPPSY.js";
|
|
20
|
+
import "./chunk-TGTYKBGC.js";
|
|
21
|
+
|
|
22
|
+
// src/commands/prompt.ts
|
|
23
|
+
import { existsSync, readdirSync } from "fs";
|
|
24
|
+
import { readFile } from "fs/promises";
|
|
25
|
+
import { join, basename } from "path";
|
|
26
|
+
async function runPrompt(options) {
|
|
27
|
+
if (!existsSync(HYPERCORE_DIR)) {
|
|
28
|
+
console.error("\u9519\u8BEF: \u8BF7\u5148\u8FD0\u884C hypercore init \u521D\u59CB\u5316");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
const config = await loadConfig();
|
|
32
|
+
const tools = await createToolRegistry(config);
|
|
33
|
+
let systemPrompt = "";
|
|
34
|
+
const hyperPath = join(HYPERCORE_DIR, "HYPER.md");
|
|
35
|
+
if (existsSync(hyperPath)) {
|
|
36
|
+
try {
|
|
37
|
+
systemPrompt = await readFile(hyperPath, "utf-8");
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!systemPrompt) {
|
|
42
|
+
systemPrompt = "\u4F60\u662F\u8D85\u534F\u4F53 AI \u52A9\u624B\u3002\u7B80\u6D01\u3001\u4E13\u4E1A\u5730\u56DE\u7B54\u95EE\u9898\u3002";
|
|
43
|
+
}
|
|
44
|
+
systemPrompt += `
|
|
45
|
+
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${process.cwd()}`;
|
|
46
|
+
const cwd = process.cwd();
|
|
47
|
+
const rulesDirs = [
|
|
48
|
+
join(HYPERCORE_DIR, "rules"),
|
|
49
|
+
join(cwd, ".hyper", "rules")
|
|
50
|
+
];
|
|
51
|
+
for (const rulesDir of rulesDirs) {
|
|
52
|
+
if (existsSync(rulesDir)) {
|
|
53
|
+
try {
|
|
54
|
+
const files = readdirSync(rulesDir).filter((f) => f.endsWith(".md")).sort();
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
try {
|
|
57
|
+
const content = await readFile(join(rulesDir, file), "utf-8");
|
|
58
|
+
systemPrompt += `
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
<!-- rule: ${file} -->
|
|
62
|
+
${content}`;
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const pkgPath = join(process.cwd(), "package.json");
|
|
71
|
+
if (existsSync(pkgPath)) {
|
|
72
|
+
try {
|
|
73
|
+
const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
74
|
+
systemPrompt += `
|
|
75
|
+
\u9879\u76EE: ${pkg.name || basename(process.cwd())}`;
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
let history = [];
|
|
80
|
+
if (options.continueSession || options.resumeId) {
|
|
81
|
+
try {
|
|
82
|
+
const { loadSession, listSessions } = await import("./session-4VUNDWLH.js");
|
|
83
|
+
if (options.resumeId) {
|
|
84
|
+
const msgs = await loadSession(options.resumeId);
|
|
85
|
+
history = msgs;
|
|
86
|
+
} else {
|
|
87
|
+
const sessions = await listSessions();
|
|
88
|
+
if (sessions.length > 0) {
|
|
89
|
+
const msgs = await loadSession(sessions[0].id);
|
|
90
|
+
history = msgs;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
if (config.modelConfig.sdkType === "openai") {
|
|
98
|
+
const client = createOpenAIClient(config.modelConfig);
|
|
99
|
+
const messages = [
|
|
100
|
+
{ role: "system", content: systemPrompt },
|
|
101
|
+
...history.map((m) => ({
|
|
102
|
+
role: m.role,
|
|
103
|
+
content: m.content
|
|
104
|
+
})),
|
|
105
|
+
{ role: "user", content: options.prompt }
|
|
106
|
+
];
|
|
107
|
+
const result = await streamOpenAIChat(client, messages, {
|
|
108
|
+
model: config.modelConfig.model,
|
|
109
|
+
tools,
|
|
110
|
+
onChunk: (text) => {
|
|
111
|
+
if (options.outputFormat !== "json") {
|
|
112
|
+
process.stdout.write(text);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
onToolCall: () => {
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
if (options.outputFormat === "json") {
|
|
119
|
+
console.log(JSON.stringify({
|
|
120
|
+
result: result.content,
|
|
121
|
+
token_usage: result.tokenUsage
|
|
122
|
+
}, null, 2));
|
|
123
|
+
} else {
|
|
124
|
+
console.log();
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
const client = createLLMClient(config.modelConfig);
|
|
128
|
+
const result = await streamCallLLM(client, {
|
|
129
|
+
systemPrompt,
|
|
130
|
+
userPrompt: options.prompt,
|
|
131
|
+
history,
|
|
132
|
+
tools,
|
|
133
|
+
model: config.modelConfig.model,
|
|
134
|
+
onText: (text) => {
|
|
135
|
+
if (options.outputFormat !== "json") {
|
|
136
|
+
process.stdout.write(text);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
onToolCall: () => {
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
if (options.outputFormat === "json") {
|
|
143
|
+
console.log(JSON.stringify({
|
|
144
|
+
result: result.output,
|
|
145
|
+
response_text: result.responseText,
|
|
146
|
+
tool_calls: result.toolCalls,
|
|
147
|
+
token_usage: result.tokenUsage
|
|
148
|
+
}, null, 2));
|
|
149
|
+
} else {
|
|
150
|
+
console.log();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
155
|
+
if (options.outputFormat === "json") {
|
|
156
|
+
console.log(JSON.stringify({ error: msg }));
|
|
157
|
+
} else {
|
|
158
|
+
console.error(`\u9519\u8BEF: ${msg}`);
|
|
159
|
+
}
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
await closeMCPConnections();
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
runPrompt
|
|
166
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkBuild,
|
|
3
|
+
checkDeps,
|
|
4
|
+
checkPackageSize,
|
|
5
|
+
checkTests,
|
|
6
|
+
checkTodos,
|
|
7
|
+
runQualityReport
|
|
8
|
+
} from "./chunk-ZSBHUGWR.js";
|
|
9
|
+
export {
|
|
10
|
+
checkBuild,
|
|
11
|
+
checkDeps,
|
|
12
|
+
checkPackageSize,
|
|
13
|
+
checkTests,
|
|
14
|
+
checkTodos,
|
|
15
|
+
runQualityReport
|
|
16
|
+
};
|