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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +110 -0
  3. package/dist/api-XGC7D5AW.js +162 -0
  4. package/dist/auth-DNQWYQKT.js +21 -0
  5. package/dist/background-2EGCAAQH.js +14 -0
  6. package/dist/backlog-Q2NZCLNY.js +24 -0
  7. package/dist/chunk-2CMSCWQW.js +162 -0
  8. package/dist/chunk-2LJ2DVEB.js +167 -0
  9. package/dist/chunk-3RPFCQKJ.js +288 -0
  10. package/dist/chunk-43OLRXM5.js +263 -0
  11. package/dist/chunk-4DVYJAJL.js +57 -0
  12. package/dist/chunk-6OL3GA3P.js +173 -0
  13. package/dist/chunk-AUHU7ALH.js +2023 -0
  14. package/dist/chunk-B6A2AKLN.js +139 -0
  15. package/dist/chunk-BE46C7JW.js +46 -0
  16. package/dist/chunk-CUVAUOXL.js +58 -0
  17. package/dist/chunk-GH7E2OJE.js +223 -0
  18. package/dist/chunk-GOOTEPBK.js +271 -0
  19. package/dist/chunk-GPPMJYSM.js +133 -0
  20. package/dist/chunk-GU2FZQ6A.js +69 -0
  21. package/dist/chunk-IOPKN5GD.js +190 -0
  22. package/dist/chunk-IXOIOGR5.js +1505 -0
  23. package/dist/chunk-KRPOPWGA.js +251 -0
  24. package/dist/chunk-MGLJ53QN.js +219 -0
  25. package/dist/chunk-MV4TTRYX.js +533 -0
  26. package/dist/chunk-OPZYEVYR.js +150 -0
  27. package/dist/chunk-QTSLP47C.js +166 -0
  28. package/dist/chunk-R3GPQC7I.js +393 -0
  29. package/dist/chunk-RKB2JOV2.js +43 -0
  30. package/dist/chunk-RNG3K465.js +80 -0
  31. package/dist/chunk-TGTYKBGC.js +86 -0
  32. package/dist/chunk-U5SGAIMM.js +681 -0
  33. package/dist/chunk-V5UHPPSY.js +140 -0
  34. package/dist/chunk-WHLVZCQY.js +245 -0
  35. package/dist/chunk-XDRCBMZZ.js +66 -0
  36. package/dist/chunk-XOS6HPEF.js +134 -0
  37. package/dist/chunk-ZSBHUGWR.js +262 -0
  38. package/dist/claude-NSQ442XD.js +12 -0
  39. package/dist/commands-CK3WFAGI.js +128 -0
  40. package/dist/commands-U63OEO5J.js +1044 -0
  41. package/dist/commands-ZE6GD3WC.js +232 -0
  42. package/dist/config-4EW42BSF.js +8 -0
  43. package/dist/config-loader-SXO674TF.js +24 -0
  44. package/dist/diagnose-AFW3ZTZ4.js +12 -0
  45. package/dist/display-IIUBEYWN.js +58 -0
  46. package/dist/extractor-QV53W2YJ.js +129 -0
  47. package/dist/history-WMSCHERZ.js +180 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.js +406 -0
  50. package/dist/instance-registry-YSIJXSO7.js +15 -0
  51. package/dist/keybindings-JAAMLH3G.js +15 -0
  52. package/dist/loader-WHNTZTLP.js +58 -0
  53. package/dist/network-MM6YWPGO.js +279 -0
  54. package/dist/notify-HPTALZDC.js +14 -0
  55. package/dist/openai-compat-UQWJXBEK.js +12 -0
  56. package/dist/permissions-JUKXMNDH.js +10 -0
  57. package/dist/prompt-QV45TXRL.js +166 -0
  58. package/dist/quality-ST7PPNFR.js +16 -0
  59. package/dist/repl-RT3AHL7M.js +3375 -0
  60. package/dist/roadmap-5OBEKROY.js +17 -0
  61. package/dist/server-PORT7OEG.js +57 -0
  62. package/dist/session-4VUNDWLH.js +21 -0
  63. package/dist/skills-V4A35XKG.js +175 -0
  64. package/dist/store-Y4LU5QTO.js +25 -0
  65. package/dist/team-HO7Z4SIM.js +385 -0
  66. package/dist/telemetry-6R4EIE6O.js +30 -0
  67. package/dist/test-runner-ZQH5Y6OJ.js +619 -0
  68. package/dist/theme-3SYJ3UQA.js +14 -0
  69. package/dist/upgrade-7TGI3SXO.js +83 -0
  70. package/dist/verify-JUDKTPKZ.js +14 -0
  71. package/dist/web/static/app.js +562 -0
  72. package/dist/web/static/index.html +132 -0
  73. package/dist/web/static/mirror.css +1001 -0
  74. package/dist/web/static/mirror.html +184 -0
  75. package/dist/web/static/mirror.js +1125 -0
  76. package/dist/web/static/onboard.css +302 -0
  77. package/dist/web/static/onboard.html +140 -0
  78. package/dist/web/static/onboard.js +260 -0
  79. package/dist/web/static/style.css +602 -0
  80. package/dist/web/static/workspace.css +1568 -0
  81. package/dist/web/static/workspace.html +408 -0
  82. package/dist/web/static/workspace.js +1683 -0
  83. package/dist/web-Z5HSCQHW.js +39 -0
  84. package/package.json +67 -0
package/dist/index.js ADDED
@@ -0,0 +1,406 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ handleCheckpoint
4
+ } from "./chunk-RKB2JOV2.js";
5
+ import {
6
+ renderMarkdown
7
+ } from "./chunk-GH7E2OJE.js";
8
+ import {
9
+ Engine,
10
+ HYPERCORE_DIR,
11
+ initializeWorkspace
12
+ } from "./chunk-MV4TTRYX.js";
13
+ import "./chunk-IXOIOGR5.js";
14
+ import "./chunk-KRPOPWGA.js";
15
+ import "./chunk-GU2FZQ6A.js";
16
+ import {
17
+ showBanner,
18
+ showError,
19
+ showLineList,
20
+ showRunComplete,
21
+ showStationComplete,
22
+ showStationRetry,
23
+ showStationSkipped,
24
+ showStationStart,
25
+ showThinking,
26
+ showToolCall,
27
+ showToolCallDone
28
+ } from "./chunk-R3GPQC7I.js";
29
+ import "./chunk-BE46C7JW.js";
30
+ import "./chunk-RNG3K465.js";
31
+ import {
32
+ createLLMClient
33
+ } from "./chunk-43OLRXM5.js";
34
+ import {
35
+ createOpenAIClient
36
+ } from "./chunk-GOOTEPBK.js";
37
+ import "./chunk-B6A2AKLN.js";
38
+ import {
39
+ HYPERCORE_DIR as HYPERCORE_DIR2,
40
+ MODEL_PROVIDERS,
41
+ loadConfig
42
+ } from "./chunk-V5UHPPSY.js";
43
+ import {
44
+ listLines,
45
+ loadLine
46
+ } from "./chunk-WHLVZCQY.js";
47
+ import "./chunk-TGTYKBGC.js";
48
+
49
+ // src/index.ts
50
+ import { Command } from "commander";
51
+
52
+ // src/commands/init.ts
53
+ import { input, select } from "@inquirer/prompts";
54
+ import chalk from "chalk";
55
+ import { existsSync } from "fs";
56
+ async function initCommand() {
57
+ showBanner();
58
+ if (existsSync(HYPERCORE_DIR)) {
59
+ const overwrite = await select({
60
+ message: `${HYPERCORE_DIR} \u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u91CD\u65B0\u521D\u59CB\u5316\uFF1F`,
61
+ choices: [
62
+ { value: "no", name: "\u5426\uFF0C\u4FDD\u7559\u73B0\u6709\u914D\u7F6E" },
63
+ { value: "yes", name: "\u662F\uFF0C\u91CD\u65B0\u521D\u59CB\u5316\uFF08\u5DF2\u6709\u6587\u4EF6\u4E0D\u4F1A\u88AB\u8986\u76D6\uFF09" }
64
+ ]
65
+ });
66
+ if (overwrite === "no") {
67
+ console.log(chalk.dim("\n \u5DF2\u53D6\u6D88\u3002\n"));
68
+ return;
69
+ }
70
+ }
71
+ console.log(chalk.dim(" \u6211\u9700\u8981\u4E86\u89E3\u4F60\u4E00\u70B9\u70B9\uFF0C\u624D\u80FD\u5E2E\u4F60\u5DE5\u4F5C\u3002\n"));
72
+ const role = await input({
73
+ message: "\u4F60\u4E3B\u8981\u505A\u4EC0\u4E48\u5DE5\u4F5C\uFF1F",
74
+ default: "\u521B\u4E1A\u8005\uFF0C\u505A AI \u65B9\u5411\u7684\u4EA7\u54C1"
75
+ });
76
+ const mainNeed = await select({
77
+ message: "\u6700\u60F3\u8BA9 AI \u5E2E\u4F60\u505A\u7684\u4E00\u4EF6\u4E8B\uFF1F",
78
+ choices: [
79
+ { value: "content", name: "\u{1F4DD} \u5E2E\u6211\u5199\u516C\u4F17\u53F7/\u5185\u5BB9" },
80
+ { value: "research", name: "\u{1F50D} \u5E2E\u6211\u505A\u8C03\u7814/\u7ADE\u54C1\u5206\u6790" },
81
+ { value: "report", name: "\u{1F4CA} \u5E2E\u6211\u5199\u62A5\u544A/\u5468\u62A5" },
82
+ { value: "other", name: "\u{1F3AF} \u5176\u4ED6" }
83
+ ]
84
+ });
85
+ const provider = await select({
86
+ message: "\u9009\u62E9 AI \u6A21\u578B\u63D0\u4F9B\u5546\uFF1A",
87
+ choices: [
88
+ { value: "gemini", name: "\u2728 Google Gemini 2.5 Flash\uFF08\u63A8\u8350\uFF0C\u514D\u8D39\u989D\u5EA6\uFF09" },
89
+ { value: "minimax", name: "\u{1F916} MiniMax M2.5\uFF08\u6027\u4EF7\u6BD4\u9AD8\uFF09" },
90
+ { value: "anthropic", name: "\u{1F9E0} Anthropic Claude\uFF08\u9700\u8981 Anthropic API Key\uFF09" }
91
+ ]
92
+ });
93
+ const apiKeyLabels = {
94
+ gemini: "Google AI API Key",
95
+ minimax: "MiniMax API Key",
96
+ anthropic: "Anthropic API Key"
97
+ };
98
+ const apiKeyPrompt = `${apiKeyLabels[provider] || "API Key"}\uFF08\u5B58\u50A8\u5728\u672C\u5730\uFF0C\u4E0D\u4F1A\u4E0A\u4F20\uFF09\uFF1A`;
99
+ const apiKey = await input({
100
+ message: apiKeyPrompt,
101
+ validate: (v) => v.length > 5 ? true : "\u8BF7\u8F93\u5165\u6709\u6548\u7684 API Key"
102
+ });
103
+ const tavilyKey = await input({
104
+ message: "Tavily API Key\uFF08\u53EF\u9009\uFF0C\u7528\u4E8E\u7F51\u7EDC\u641C\u7D22\uFF0C\u56DE\u8F66\u8DF3\u8FC7\uFF09\uFF1A"
105
+ });
106
+ console.log(chalk.dim("\n \u6B63\u5728\u521D\u59CB\u5316\u2026"));
107
+ await initializeWorkspace({
108
+ provider,
109
+ apiKey,
110
+ tavilyKey: tavilyKey || void 0,
111
+ role
112
+ });
113
+ console.log(chalk.green("\n \u2705 \u521D\u59CB\u5316\u5B8C\u6210\uFF01"));
114
+ console.log(chalk.dim(` \u{1F4C1} \u914D\u7F6E\u76EE\u5F55\uFF1A${HYPERCORE_DIR}`));
115
+ console.log(chalk.dim(` \u{1F4C4} PWP.md \u2014 \u4F60\u7684\u5DE5\u4F5C\u7A7A\u95F4\u534F\u8BAE`));
116
+ console.log(chalk.dim(` \u{1F916} \u9884\u7F6E Agent\uFF1A\u8C03\u7814\u5458\u3001\u5199\u624B`));
117
+ console.log(chalk.dim(` \u{1F4DA} \u9884\u7F6E Skill\uFF1A\u516C\u4F17\u53F7\u5199\u4F5C\u3001\u7ADE\u54C1\u5206\u6790\u3001\u5E02\u573A\u8C03\u7814`));
118
+ console.log(chalk.bold("\n \u73B0\u5728\u8BD5\u8BD5\uFF1A"));
119
+ if (mainNeed === "content") {
120
+ console.log(chalk.cyan(' $ hypercore run \u516C\u4F17\u53F7\u6587\u7AE0 --topic "AI Agent \u7684\u73B0\u72B6\u548C\u672A\u6765"'));
121
+ } else if (mainNeed === "research") {
122
+ console.log(chalk.cyan(' $ hypercore run \u7ADE\u54C1\u5206\u6790 --topic "Dify, Coze, LangChain"'));
123
+ } else {
124
+ console.log(chalk.cyan(" $ hypercore line ls"));
125
+ }
126
+ console.log();
127
+ }
128
+
129
+ // src/commands/run.ts
130
+ import { existsSync as existsSync2 } from "fs";
131
+ import chalk2 from "chalk";
132
+ import ora from "ora";
133
+ import { input as inquirerInput } from "@inquirer/prompts";
134
+ function formatCharCount(n) {
135
+ if (n < 1e3) return `${n}`;
136
+ return `${(n / 1e3).toFixed(1)}k`;
137
+ }
138
+ async function runCommand(lineName, options) {
139
+ showBanner();
140
+ if (!existsSync2(HYPERCORE_DIR2)) {
141
+ showError("\u8BF7\u5148\u8FD0\u884C hypercore init \u521D\u59CB\u5316");
142
+ process.exit(1);
143
+ }
144
+ let config;
145
+ try {
146
+ config = await loadConfig();
147
+ } catch (err) {
148
+ showError(err instanceof Error ? err.message : String(err));
149
+ process.exit(1);
150
+ }
151
+ const userInputs = {};
152
+ if (options.topic) userInputs["topic"] = options.topic;
153
+ for (const [key, value] of Object.entries(options)) {
154
+ if (key !== "topic" && typeof value === "string") {
155
+ userInputs[key] = value;
156
+ }
157
+ }
158
+ let line;
159
+ try {
160
+ line = await loadLine(HYPERCORE_DIR2, lineName);
161
+ } catch (err) {
162
+ showError(`\u65E0\u6CD5\u52A0\u8F7D\u751F\u4EA7\u7EBF "${lineName}"\uFF1A${err instanceof Error ? err.message : String(err)}`);
163
+ process.exit(1);
164
+ }
165
+ for (const param of line.inputs) {
166
+ if (param.required && !userInputs[param.name]) {
167
+ const value = await inquirerInput({
168
+ message: `\u{1F4DD} ${param.name}\uFF08${param.description}\uFF09\uFF1A`,
169
+ default: param.defaultValue
170
+ });
171
+ if (!value.trim()) {
172
+ showError(`\u5FC5\u586B\u53C2\u6570 "${param.name}" \u4E0D\u80FD\u4E3A\u7A7A`);
173
+ process.exit(1);
174
+ }
175
+ userInputs[param.name] = value.trim();
176
+ }
177
+ }
178
+ console.log(chalk2.bold(`
179
+ \u{1F3ED} \u8FD0\u884C\u751F\u4EA7\u7EBF\uFF1A${lineName}`));
180
+ if (Object.keys(userInputs).length > 0) {
181
+ for (const [key, value] of Object.entries(userInputs)) {
182
+ console.log(chalk2.dim(` ${key}: ${value}`));
183
+ }
184
+ }
185
+ const providerInfo = MODEL_PROVIDERS[config.modelConfig.provider];
186
+ console.log(chalk2.dim(` \u6A21\u578B: ${providerInfo.name} \u2192 ${config.modelConfig.model}`));
187
+ const client = config.modelConfig.sdkType === "openai" ? createOpenAIClient(config.modelConfig) : createLLMClient(config.modelConfig);
188
+ const engine = new Engine(client, config, HYPERCORE_DIR2);
189
+ let stationBuffer = "";
190
+ let stationSpinner = null;
191
+ let stationStartTime = 0;
192
+ try {
193
+ await engine.run(lineName, userInputs, {
194
+ onStationStart: (index, total, name, agentName) => {
195
+ showStationStart(index, total, name, agentName);
196
+ stationBuffer = "";
197
+ stationStartTime = Date.now();
198
+ stationSpinner = ora({
199
+ text: chalk2.dim("\u751F\u6210\u4E2D\u2026"),
200
+ spinner: "dots2",
201
+ indent: 2
202
+ }).start();
203
+ },
204
+ onStationText: (text) => {
205
+ stationBuffer += text;
206
+ if (stationSpinner) {
207
+ stationSpinner.text = chalk2.dim(`\u751F\u6210\u4E2D\u2026 ${formatCharCount(stationBuffer.length)} \u5B57\u7B26`);
208
+ }
209
+ },
210
+ onThinking: (text) => {
211
+ if (stationSpinner) stationSpinner.stop();
212
+ showThinking(text);
213
+ if (stationSpinner) stationSpinner.start();
214
+ },
215
+ onToolCall: (name, input2) => {
216
+ if (stationSpinner) {
217
+ stationSpinner.stop();
218
+ }
219
+ showToolCall(name, input2);
220
+ if (stationSpinner) {
221
+ stationSpinner.start();
222
+ }
223
+ },
224
+ onToolCallDone: (name, durationMs) => {
225
+ if (stationSpinner) stationSpinner.stop();
226
+ showToolCallDone(name, durationMs);
227
+ if (stationSpinner) stationSpinner.start();
228
+ },
229
+ onStationComplete: (index, name) => {
230
+ if (stationSpinner) {
231
+ stationSpinner.stop();
232
+ stationSpinner = null;
233
+ }
234
+ if (stationBuffer.trim()) {
235
+ console.log(chalk2.dim(" \u2500\u2500\u2500 \u8F93\u51FA \u2500\u2500\u2500"));
236
+ const rendered = renderMarkdown(stationBuffer);
237
+ process.stdout.write(rendered);
238
+ }
239
+ stationBuffer = "";
240
+ const elapsed = Date.now() - stationStartTime;
241
+ showStationComplete(index, name, void 0, elapsed);
242
+ },
243
+ onStationSkipped: (index, name, reason) => {
244
+ if (stationSpinner) {
245
+ stationSpinner.stop();
246
+ stationSpinner = null;
247
+ }
248
+ showStationSkipped(index, name, reason);
249
+ },
250
+ onStationRetry: (index, name, attempt, maxRetry, error) => {
251
+ if (stationSpinner) {
252
+ stationSpinner.stop();
253
+ stationSpinner = null;
254
+ }
255
+ showStationRetry(index, name, attempt, maxRetry, error);
256
+ },
257
+ onCheckpoint: handleCheckpoint,
258
+ onComplete: (result) => showRunComplete(result, config.modelConfig.model)
259
+ });
260
+ } catch (err) {
261
+ if (stationSpinner) {
262
+ stationSpinner.stop();
263
+ }
264
+ showError(err instanceof Error ? err.message : String(err));
265
+ process.exit(1);
266
+ }
267
+ }
268
+
269
+ // src/commands/line.ts
270
+ import { join } from "path";
271
+ import { existsSync as existsSync3 } from "fs";
272
+ var HYPERCORE_DIR3 = join(process.env.HOME || "~", ".hypercore");
273
+ async function lineListCommand() {
274
+ showBanner();
275
+ if (!existsSync3(HYPERCORE_DIR3)) {
276
+ showError("\u8BF7\u5148\u8FD0\u884C hypercore init \u521D\u59CB\u5316");
277
+ process.exit(1);
278
+ }
279
+ const lines = await listLines(HYPERCORE_DIR3);
280
+ showLineList(lines);
281
+ }
282
+
283
+ // src/index.ts
284
+ var program = new Command();
285
+ program.name("hypercore").description("\u8D85\u534F\u4F53 \xB7 \u9762\u5411\u901A\u7528\u751F\u4EA7\u529B\u7684 AI-Native Shell \u{1F41A}").version("1.1.0").option("-p, --print <prompt>", "\u975E\u4EA4\u4E92\u6A21\u5F0F\uFF1A\u6267\u884C prompt \u540E\u9000\u51FA").option("--output-format <format>", "\u8F93\u51FA\u683C\u5F0F: text | json", "text").option("-c, --continue", "\u7EE7\u7EED\u4E0A\u4E00\u4E2A\u4F1A\u8BDD").option("-r, --resume <id>", "\u6062\u590D\u6307\u5B9A\u4F1A\u8BDD").option("--host <host>", "\u76D1\u542C\u5730\u5740 (\u9ED8\u8BA4 127.0.0.1, \u56E2\u961F\u6A21\u5F0F\u7528 0.0.0.0)", "127.0.0.1");
286
+ program.command("init").description("\u521D\u59CB\u5316\u8D85\u534F\u4F53\u5DE5\u4F5C\u7A7A\u95F4").action(initCommand);
287
+ program.command("run <line>").description("\u8FD0\u884C\u4E00\u6761\u751F\u4EA7\u7EBF").option("--topic <topic>", "\u4E3B\u9898/\u8BDD\u9898").option("--target <target>", "\u76EE\u6807\u5BF9\u8C61\uFF08\u7ADE\u54C1\u540D\u7B49\uFF09").option("--angle <angle>", "\u5207\u5165\u89D2\u5EA6").allowUnknownOption(true).action(runCommand);
288
+ var lineCmd = program.command("line").description("\u7BA1\u7406\u751F\u4EA7\u7EBF");
289
+ lineCmd.command("ls").description("\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684\u751F\u4EA7\u7EBF").action(lineListCommand);
290
+ var historyCmd = program.command("history").description("\u67E5\u770B\u751F\u4EA7\u7EBF\u8FD0\u884C\u5386\u53F2").action(async () => {
291
+ const { historyCommand } = await import("./history-WMSCHERZ.js");
292
+ await historyCommand();
293
+ });
294
+ historyCmd.command("view <file>").description("\u67E5\u770B\u5355\u6B21\u8FD0\u884C\u7684\u8BE6\u7EC6\u8BB0\u5F55").action(async (fileId) => {
295
+ const { historyViewCommand } = await import("./history-WMSCHERZ.js");
296
+ await historyViewCommand(fileId);
297
+ });
298
+ program.command("upgrade").description("\u540C\u6B65\u65B0\u6A21\u677F\u5230\u5DE5\u4F5C\u7A7A\u95F4\uFF08\u4E0D\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\uFF09").action(async () => {
299
+ const { upgradeCommand } = await import("./upgrade-7TGI3SXO.js");
300
+ await upgradeCommand();
301
+ });
302
+ program.command("web").description("\u542F\u52A8 Web Dashboard \u63A7\u5236\u53F0").option("--port <port>", "\u670D\u52A1\u7AEF\u53E3", "3210").option("--host <host>", "\u76D1\u542C\u5730\u5740 (\u9ED8\u8BA4 127.0.0.1, \u56E2\u961F\u6A21\u5F0F\u7528 0.0.0.0)", "127.0.0.1").action(async (opts) => {
303
+ const { loadConfig: loadConfig2 } = await import("./config-4EW42BSF.js");
304
+ const { startWebServer } = await import("./web-Z5HSCQHW.js");
305
+ const config = await loadConfig2();
306
+ await startWebServer(config, parseInt(opts.port, 10), opts.host);
307
+ });
308
+ program.command("mirror").description("\u542F\u52A8\u5185\u89C2\u5F15\u64CE HyperMirror GUI \u63A7\u5236\u53F0").option("--port <port>", "\u670D\u52A1\u7AEF\u53E3", "3210").option("--no-open", "\u4E0D\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668").action(async (opts) => {
309
+ const { loadConfig: loadConfig2 } = await import("./config-4EW42BSF.js");
310
+ const { createWebServerAutoPort, resolveBrowserHost } = await import("./server-PORT7OEG.js");
311
+ const config = await loadConfig2();
312
+ const port = parseInt(opts.port, 10);
313
+ const { port: actualPort } = await createWebServerAutoPort(config, port);
314
+ const browserHost = resolveBrowserHost("127.0.0.1");
315
+ const url = `http://${browserHost}:${actualPort}/mirror`;
316
+ console.log(`
317
+ \x1B[35mHyperMirror \u5185\u89C2\u5F15\u64CE\x1B[0m \x1B[4m${url}\x1B[0m`);
318
+ console.log(` \x1B[90mPress Ctrl+C to stop\x1B[0m
319
+ `);
320
+ if (opts.open) {
321
+ const { exec } = await import("child_process");
322
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
323
+ exec(`${cmd} ${url}`);
324
+ }
325
+ await new Promise(() => {
326
+ });
327
+ });
328
+ var teamCmd = program.command("team").description("\u56E2\u961F\u534F\u4F5C\u6A21\u5F0F");
329
+ teamCmd.command("create <name>").description("\u521B\u5EFA\u65B0\u56E2\u961F").option("--port <port>", "\u670D\u52A1\u7AEF\u53E3", "3210").action(async (name, opts) => {
330
+ const { teamCreateCommand } = await import("./team-HO7Z4SIM.js");
331
+ await teamCreateCommand(name, opts);
332
+ });
333
+ teamCmd.command("join <code>").description("\u52A0\u5165\u56E2\u961F\uFF08\u8F93\u5165\u52A0\u5165\u7801\uFF09").option("--server <url>", "\u670D\u52A1\u5668\u5730\u5740", "http://localhost:3210").action(async (code, opts) => {
334
+ const { teamJoinCommand } = await import("./team-HO7Z4SIM.js");
335
+ await teamJoinCommand(code, opts);
336
+ });
337
+ teamCmd.command("status").description("\u67E5\u770B\u56E2\u961F\u72B6\u6001").action(async () => {
338
+ const { teamStatusCommand } = await import("./team-HO7Z4SIM.js");
339
+ await teamStatusCommand();
340
+ });
341
+ var taskCmd = teamCmd.command("task").description("\u56E2\u961F\u4EFB\u52A1\u7BA1\u7406");
342
+ taskCmd.command("add <title>").description("\u65B0\u589E\u4EFB\u52A1").option("-p, --priority <priority>", "\u4F18\u5148\u7EA7 S/A/B/C", "B").option("-a, --assignee <member>", "\u5206\u914D\u7ED9\u6210\u5458").option("-d, --description <desc>", "\u4EFB\u52A1\u63CF\u8FF0").action(async (title, opts) => {
343
+ const { teamTaskAddCommand } = await import("./team-HO7Z4SIM.js");
344
+ await teamTaskAddCommand(title, opts);
345
+ });
346
+ taskCmd.command("list").alias("ls").description("\u5217\u51FA\u6240\u6709\u4EFB\u52A1").action(async () => {
347
+ const { teamTaskListCommand } = await import("./team-HO7Z4SIM.js");
348
+ await teamTaskListCommand();
349
+ });
350
+ taskCmd.command("assign <id> <member>").description("\u5206\u914D\u4EFB\u52A1\u7ED9\u6210\u5458").action(async (id, member) => {
351
+ const { teamTaskAssignCommand } = await import("./team-HO7Z4SIM.js");
352
+ await teamTaskAssignCommand(id, member);
353
+ });
354
+ taskCmd.command("done <id>").description("\u6807\u8BB0\u4EFB\u52A1\u5B8C\u6210").action(async (id) => {
355
+ const { teamTaskDoneCommand } = await import("./team-HO7Z4SIM.js");
356
+ await teamTaskDoneCommand(id);
357
+ });
358
+ teamCmd.command("chat").description("\u8FDB\u5165\u56E2\u961F\u5B9E\u65F6\u804A\u5929").action(async () => {
359
+ const { teamChatCommand } = await import("./team-HO7Z4SIM.js");
360
+ await teamChatCommand();
361
+ });
362
+ teamCmd.command("leave").description("\u79BB\u5F00\u5F53\u524D\u56E2\u961F").action(async () => {
363
+ const { teamLeaveCommand } = await import("./team-HO7Z4SIM.js");
364
+ await teamLeaveCommand();
365
+ });
366
+ var networkCmd = program.command("network").alias("net").description("Hyper Network \u2014 Agent \u81EA\u4E3B\u7F51\u7EDC");
367
+ networkCmd.command("profile [field] [values...]").description("\u67E5\u770B/\u8BBE\u7F6E Agent Profile\uFF08skills/needs/offerings/customNote\uFF09").action(async (field, values) => {
368
+ const { networkProfileCommand } = await import("./network-MM6YWPGO.js");
369
+ await networkProfileCommand(field, values);
370
+ });
371
+ networkCmd.command("run").description("\u624B\u52A8\u89E6\u53D1\u4E00\u8F6E\u7F51\u7EDC\u5339\u914D").action(async () => {
372
+ const { networkRunCommand } = await import("./network-MM6YWPGO.js");
373
+ await networkRunCommand();
374
+ });
375
+ networkCmd.command("digest").description("\u67E5\u770B\u6700\u65B0\u4E2A\u4EBA\u6458\u8981").action(async () => {
376
+ const { networkDigestCommand } = await import("./network-MM6YWPGO.js");
377
+ await networkDigestCommand();
378
+ });
379
+ networkCmd.command("auto <action>").description("\u81EA\u52A8\u8F6E\u6B21 (on/off)").action(async (action) => {
380
+ const { networkAutoCommand } = await import("./network-MM6YWPGO.js");
381
+ await networkAutoCommand(action);
382
+ });
383
+ networkCmd.command("rounds").description("\u67E5\u770B\u5386\u53F2\u8F6E\u6B21").action(async () => {
384
+ const { networkRoundsCommand } = await import("./network-MM6YWPGO.js");
385
+ await networkRoundsCommand();
386
+ });
387
+ networkCmd.command("config [key] [value]").description("\u67E5\u770B/\u4FEE\u6539\u7F51\u7EDC\u914D\u7F6E").action(async (key, value) => {
388
+ const { networkConfigCommand } = await import("./network-MM6YWPGO.js");
389
+ await networkConfigCommand(key, value);
390
+ });
391
+ program.action(async () => {
392
+ const opts = program.opts();
393
+ if (opts.print) {
394
+ const { runPrompt } = await import("./prompt-QV45TXRL.js");
395
+ await runPrompt({
396
+ prompt: opts.print,
397
+ outputFormat: opts.outputFormat,
398
+ continueSession: opts.continue,
399
+ resumeId: opts.resume
400
+ });
401
+ } else {
402
+ const { startREPL } = await import("./repl-RT3AHL7M.js");
403
+ await startREPL({ host: opts.host });
404
+ }
405
+ });
406
+ program.parse();
@@ -0,0 +1,15 @@
1
+ import {
2
+ getCanonicalDashboardPort,
3
+ listInstances,
4
+ registerInstance,
5
+ unregisterInstance,
6
+ updateInstanceRuntime
7
+ } from "./chunk-GPPMJYSM.js";
8
+ import "./chunk-V5UHPPSY.js";
9
+ export {
10
+ getCanonicalDashboardPort,
11
+ listInstances,
12
+ registerInstance,
13
+ unregisterInstance,
14
+ updateInstanceRuntime
15
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ getKeyBindings,
3
+ keypressToCombo,
4
+ listKeyBindings,
5
+ loadKeyBindings,
6
+ matchKeyBinding
7
+ } from "./chunk-CUVAUOXL.js";
8
+ import "./chunk-V5UHPPSY.js";
9
+ export {
10
+ getKeyBindings,
11
+ keypressToCombo,
12
+ listKeyBindings,
13
+ loadKeyBindings,
14
+ matchKeyBinding
15
+ };
@@ -0,0 +1,58 @@
1
+ import {
2
+ CATEGORY_LABELS,
3
+ DEFAULT_EXTRACTION_CONFIG,
4
+ loadStore
5
+ } from "./chunk-KRPOPWGA.js";
6
+ import "./chunk-V5UHPPSY.js";
7
+
8
+ // src/memory/loader.ts
9
+ async function loadMemoryForSystemPrompt(opts) {
10
+ const maxChars = opts?.maxChars || DEFAULT_EXTRACTION_CONFIG.maxSystemPromptChars;
11
+ const loadedLayers = [];
12
+ const summaries = [];
13
+ const personalSummary = await buildLayerSummary("personal");
14
+ if (personalSummary) {
15
+ summaries.push(personalSummary);
16
+ loadedLayers.push("personal");
17
+ }
18
+ const projectSummary = await buildLayerSummary("project", { projectPath: opts?.projectPath });
19
+ if (projectSummary) {
20
+ summaries.push(projectSummary);
21
+ loadedLayers.push("project");
22
+ }
23
+ if (opts?.teamId) {
24
+ const teamSummary = await buildLayerSummary("team", { teamId: opts.teamId });
25
+ if (teamSummary) {
26
+ summaries.push(teamSummary);
27
+ loadedLayers.push("team");
28
+ }
29
+ }
30
+ if (summaries.length === 0) {
31
+ return { memoryBlock: "", layers: [] };
32
+ }
33
+ let combined = "\n\n--- Persistent Memory ---\n" + summaries.join("\n") + "\n\u5982\u9700\u8BE6\u60C5\u8BF7\u8C03\u7528 memory_search \u5DE5\u5177\u68C0\u7D22\u3002\n\u53D1\u73B0\u91CD\u8981\u4FE1\u606F\u65F6\u8BF7\u4E3B\u52A8\u8C03\u7528 memory_save \u5DE5\u5177\u4FDD\u5B58\u3002\n--- End Persistent Memory ---\n";
34
+ if (combined.length > maxChars) {
35
+ combined = combined.slice(0, maxChars - 50) + "\n... [\u6458\u8981\u5DF2\u622A\u65AD\uFF0C\u7528 memory_search \u67E5\u8BE2\u8BE6\u60C5] ...\n--- End Persistent Memory ---\n";
36
+ }
37
+ return { memoryBlock: combined, layers: loadedLayers };
38
+ }
39
+ async function buildLayerSummary(layer, opts) {
40
+ const store = await loadStore(layer, opts);
41
+ if (store.records.length === 0) return null;
42
+ const grouped = {};
43
+ for (const r of store.records) {
44
+ if (!grouped[r.category]) grouped[r.category] = [];
45
+ grouped[r.category].push(r);
46
+ }
47
+ const lines = [`[${layer} \u8BB0\u5FC6 \xB7 ${store.records.length} \u6761]`];
48
+ for (const [category, records] of Object.entries(grouped)) {
49
+ const label = CATEGORY_LABELS[category] || category;
50
+ const top = records.sort((a, b) => b.confidence - a.confidence).slice(0, 2).map((r) => r.content);
51
+ const extra = records.length > 2 ? ` (+${records.length - 2}\u6761)` : "";
52
+ lines.push(` ${label}: ${top.join("; ")}${extra}`);
53
+ }
54
+ return lines.join("\n");
55
+ }
56
+ export {
57
+ loadMemoryForSystemPrompt
58
+ };