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
@@ -0,0 +1,166 @@
1
+ import {
2
+ getToolPermission
3
+ } from "./chunk-GU2FZQ6A.js";
4
+
5
+ // src/core/agent.ts
6
+ import chalk from "chalk";
7
+ async function runSubAgent(task, client, config, tools, parentSystemPrompt) {
8
+ const startTime = Date.now();
9
+ const maxTurns = task.maxTurns || 15;
10
+ const timeout = task.timeout || 12e4;
11
+ const toolCalls = [];
12
+ const tokenUsage = { inputTokens: 0, outputTokens: 0 };
13
+ const isSafeTool = (tool) => getToolPermission(tool.definition.name) === "safe";
14
+ const isDangerousTool = (tool) => getToolPermission(tool.definition.name) === "dangerous";
15
+ let filteredTools = tools;
16
+ if (task.type === "explore" || task.type === "plan") {
17
+ filteredTools = tools.filter(isSafeTool);
18
+ } else if (task.type === "research") {
19
+ filteredTools = tools.filter((t) => !isDangerousTool(t));
20
+ }
21
+ const allowedTools = task.allowedTools ? filteredTools.filter((t) => task.allowedTools.includes(t.definition.name)) : filteredTools;
22
+ const typeHints = {
23
+ explore: "\u4F60\u662F\u4E00\u4E2A\u4EE3\u7801\u63A2\u7D22\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u641C\u7D22\u6587\u4EF6\u3001\u8BFB\u53D6\u4EE3\u7801\u3001\u7406\u89E3\u67B6\u6784\u3002\u4E0D\u8981\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\u3002",
24
+ code: "\u4F60\u662F\u4E00\u4E2A\u4EE3\u7801\u7F16\u5199\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u5B9E\u73B0\u529F\u80FD\u3001\u4FEE\u6539\u4EE3\u7801\u3001\u521B\u5EFA\u6587\u4EF6\u3002",
25
+ research: "\u4F60\u662F\u4E00\u4E2A\u7814\u7A76\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u641C\u7D22\u4FE1\u606F\u3001\u9605\u8BFB\u6587\u6863\u3001\u5206\u6790\u6570\u636E\u3002",
26
+ plan: "\u4F60\u662F\u4E00\u4E2A\u89C4\u5212\u4EE3\u7406\uFF0C\u4E13\u6CE8\u4E8E\u5206\u6790\u9700\u6C42\u3001\u8BBE\u8BA1\u65B9\u6848\u3001\u5236\u5B9A\u8BA1\u5212\u3002\u4E0D\u8981\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\u3002",
27
+ general: "\u4F60\u662F\u4E00\u4E2A\u901A\u7528\u52A9\u624B\u4EE3\u7406\u3002"
28
+ };
29
+ let systemPrompt = task.systemPrompt || "";
30
+ if (!systemPrompt && task.type) {
31
+ systemPrompt = typeHints[task.type] || typeHints.general;
32
+ }
33
+ if (!systemPrompt) {
34
+ systemPrompt = typeHints.general;
35
+ }
36
+ systemPrompt += `
37
+
38
+ \u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55: ${process.cwd()}`;
39
+ systemPrompt += `
40
+
41
+ \u4EFB\u52A1:
42
+ ${task.description}`;
43
+ if (task.planMode) {
44
+ systemPrompt += `
45
+
46
+ \u91CD\u8981\uFF1A\u4F60\u5904\u4E8E\u89C4\u5212\u6A21\u5F0F\u3002\u8BF7\u5206\u6790\u4EFB\u52A1\uFF0C\u63A2\u7D22\u4EE3\u7801\uFF0C\u8F93\u51FA\u8BE6\u7EC6\u7684\u5B9E\u65BD\u65B9\u6848\u3002`;
47
+ systemPrompt += `\u4E0D\u8981\u76F4\u63A5\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\uFF0C\u53EA\u8F93\u51FA\u65B9\u6848\uFF08\u5305\u542B\uFF1A\u9700\u8981\u4FEE\u6539\u7684\u6587\u4EF6\u3001\u5177\u4F53\u6539\u52A8\u3001\u5B9E\u65BD\u6B65\u9AA4\uFF09\u3002`;
48
+ } else {
49
+ systemPrompt += `
50
+
51
+ \u5B8C\u6210\u4EFB\u52A1\u540E\uFF0C\u8F93\u51FA\u6700\u7EC8\u7ED3\u679C\u3002\u4FDD\u6301\u7B80\u6D01\u3002`;
52
+ }
53
+ let output = "";
54
+ let timedOut = false;
55
+ try {
56
+ const timeoutPromise = new Promise((_, reject) => {
57
+ setTimeout(() => reject(new Error("timeout")), timeout);
58
+ });
59
+ const executionPromise = (async () => {
60
+ if (config.modelConfig.sdkType === "openai") {
61
+ const { streamOpenAIChat } = await import("./openai-compat-UQWJXBEK.js");
62
+ const OpenAI = (await import("openai")).default;
63
+ const openaiClient = client;
64
+ const messages = [
65
+ { role: "system", content: systemPrompt },
66
+ { role: "user", content: task.description }
67
+ ];
68
+ const result = await streamOpenAIChat(openaiClient, messages, {
69
+ model: config.modelConfig.model,
70
+ tools: allowedTools,
71
+ // maxToolRounds: maxTurns, // TODO: 支持自定义工具轮数
72
+ onChunk: (text) => {
73
+ process.stdout.write(chalk.dim(text));
74
+ },
75
+ onToolCall: (name) => {
76
+ toolCalls.push({ name, input: "" });
77
+ console.log(chalk.dim(` \u{1F527} [\u5B50\u4EE3\u7406] ${name}`));
78
+ }
79
+ });
80
+ output = result.content;
81
+ tokenUsage.inputTokens += result.tokenUsage.inputTokens;
82
+ tokenUsage.outputTokens += result.tokenUsage.outputTokens;
83
+ } else {
84
+ const { streamCallLLM } = await import("./claude-NSQ442XD.js");
85
+ const Anthropic = (await import("@anthropic-ai/sdk")).default;
86
+ const anthropicClient = client;
87
+ const result = await streamCallLLM(anthropicClient, {
88
+ systemPrompt,
89
+ userPrompt: task.description,
90
+ history: [],
91
+ tools: allowedTools,
92
+ model: config.modelConfig.model,
93
+ // maxToolRounds: maxTurns, // TODO: 支持自定义工具轮数
94
+ onText: (text) => {
95
+ process.stdout.write(chalk.dim(text));
96
+ },
97
+ onToolCall: (name) => {
98
+ toolCalls.push({ name, input: "" });
99
+ console.log(chalk.dim(` \u{1F527} [\u5B50\u4EE3\u7406] ${name}`));
100
+ }
101
+ });
102
+ output = result.output;
103
+ tokenUsage.inputTokens += result.tokenUsage.inputTokens;
104
+ tokenUsage.outputTokens += result.tokenUsage.outputTokens;
105
+ }
106
+ })();
107
+ await Promise.race([executionPromise, timeoutPromise]);
108
+ } catch (err) {
109
+ if (err instanceof Error && err.message === "timeout") {
110
+ timedOut = true;
111
+ output = "[\u5B50\u4EE3\u7406\u8D85\u65F6]";
112
+ } else {
113
+ output = `[\u5B50\u4EE3\u7406\u9519\u8BEF: ${err instanceof Error ? err.message : String(err)}]`;
114
+ }
115
+ }
116
+ const elapsed = Date.now() - startTime;
117
+ return {
118
+ output,
119
+ tokenUsage,
120
+ toolCalls,
121
+ timedOut,
122
+ elapsed
123
+ };
124
+ }
125
+ function createSubAgentTool(getClient, config, tools, systemPrompt) {
126
+ return {
127
+ definition: {
128
+ name: "sub_agent",
129
+ description: "\u542F\u52A8\u5B50\u4EE3\u7406\u6267\u884C\u590D\u6742\u4EFB\u52A1\u3002\u9002\u7528\u4E8E\u9700\u8981\u591A\u6B65\u9AA4\u5DE5\u5177\u8C03\u7528\u7684\u573A\u666F\uFF08\u5982\u63A2\u7D22\u4EE3\u7801\u3001\u7814\u7A76\u95EE\u9898\u3001\u6267\u884C\u8BA1\u5212\uFF09\u3002\u5B50\u4EE3\u7406\u62E5\u6709\u72EC\u7ACB\u4E0A\u4E0B\u6587\u3002",
130
+ input_schema: {
131
+ type: "object",
132
+ properties: {
133
+ description: {
134
+ type: "string",
135
+ description: "\u4EFB\u52A1\u63CF\u8FF0\uFF1A\u6E05\u6670\u63CF\u8FF0\u5B50\u4EE3\u7406\u9700\u8981\u5B8C\u6210\u7684\u4EFB\u52A1"
136
+ },
137
+ type: {
138
+ type: "string",
139
+ enum: ["explore", "code", "research", "plan", "general"],
140
+ description: "\u5B50\u4EE3\u7406\u7C7B\u578B\uFF1Aexplore\uFF08\u63A2\u7D22\u4EE3\u7801\uFF09, code\uFF08\u7F16\u5199\u4EE3\u7801\uFF09, research\uFF08\u7814\u7A76\uFF09, plan\uFF08\u89C4\u5212\uFF09, general\uFF08\u901A\u7528\uFF09"
141
+ }
142
+ },
143
+ required: ["description"]
144
+ }
145
+ },
146
+ handler: async (input) => {
147
+ const task = {
148
+ description: input.description,
149
+ type: input.type || "general"
150
+ };
151
+ console.log(chalk.dim(`
152
+ \u{1F916} \u542F\u52A8\u5B50\u4EE3\u7406 [${task.type}]...
153
+ `));
154
+ const result = await runSubAgent(task, getClient(), config, tools, systemPrompt);
155
+ console.log(chalk.dim(`
156
+ \u2705 \u5B50\u4EE3\u7406\u5B8C\u6210 (${(result.elapsed / 1e3).toFixed(1)}s, ${result.toolCalls.length} \u6B21\u5DE5\u5177\u8C03\u7528)
157
+ `));
158
+ return result.output;
159
+ }
160
+ };
161
+ }
162
+
163
+ export {
164
+ runSubAgent,
165
+ createSubAgentTool
166
+ };
@@ -0,0 +1,393 @@
1
+ import {
2
+ displayWidth
3
+ } from "./chunk-BE46C7JW.js";
4
+ import {
5
+ getTheme
6
+ } from "./chunk-RNG3K465.js";
7
+
8
+ // src/ui/display.ts
9
+ import chalk from "chalk";
10
+ var CLI_VERSION = "1.1.0";
11
+ var LINE_W = 44;
12
+ function boxTop(w) {
13
+ return chalk.dim(`\u256D${"\u2500".repeat(w)}\u256E`);
14
+ }
15
+ function boxBot(w) {
16
+ return chalk.dim(`\u2570${"\u2500".repeat(w)}\u256F`);
17
+ }
18
+ function boxRow(content, w) {
19
+ const pad = Math.max(w - displayWidth(content), 0);
20
+ return chalk.dim("\u2502") + content + " ".repeat(pad) + chalk.dim("\u2502");
21
+ }
22
+ function showBanner() {
23
+ }
24
+ function showWelcome(info) {
25
+ const t = getTheme();
26
+ const cwd = info.cwd || process.cwd();
27
+ const home = process.env.HOME || "";
28
+ const shortCwd = home && cwd.startsWith(home) ? `~${cwd.slice(home.length)}` : cwd;
29
+ console.log();
30
+ console.log(` ${t.bold("Hypercore")} ${t.dim(`v${CLI_VERSION}`)}`);
31
+ console.log(` ${t.dim(info.model)}`);
32
+ console.log(` ${t.dim(shortCwd)}`);
33
+ }
34
+ function showREPLWelcome() {
35
+ console.log();
36
+ }
37
+ function showStationStart(index, total, name, agentName) {
38
+ const t = getTheme();
39
+ console.log();
40
+ console.log(` ${t.dim("\u2501".repeat(LINE_W))}`);
41
+ console.log(
42
+ ` ${t.bold(`\u5DE5\u4F4D ${index}/${total}`)} ${t.dim("\xB7")} ${chalk.white(name)}` + t.dim(`${" ".repeat(Math.max(1, 20 - name.length))}[${agentName}]`)
43
+ );
44
+ console.log(` ${t.dim("\u2501".repeat(LINE_W))}`);
45
+ }
46
+ function showThinking(text) {
47
+ const t = getTheme();
48
+ const lines = text.split("\n").filter((l) => l.trim());
49
+ const display = lines[0]?.trim() || text.trim();
50
+ const truncated = display.length > 80 ? display.slice(0, 77) + "..." : display;
51
+ console.log(`
52
+ ${t.dim(chalk.italic(truncated))}
53
+ `);
54
+ }
55
+ function extractToolSummary(name, input) {
56
+ if (!input) return "";
57
+ if (name === "bash" && input.command) {
58
+ return String(input.command).slice(0, 60);
59
+ }
60
+ if (["file_read", "file_write", "read", "write", "edit", "glob"].includes(name) && input.path) {
61
+ const home = process.env.HOME || "";
62
+ let p = String(input.path);
63
+ if (home && p.startsWith(home)) p = "~" + p.slice(home.length);
64
+ return p.length > 60 ? "..." + p.slice(-57) : p;
65
+ }
66
+ if (["grep", "search", "web_search"].includes(name) && (input.pattern || input.query)) {
67
+ return String(input.pattern || input.query).slice(0, 60);
68
+ }
69
+ if (["web_fetch", "fetch"].includes(name) && (input.url || input.query)) {
70
+ const raw = String(input.url || input.query);
71
+ try {
72
+ const url = new URL(raw);
73
+ const path = url.pathname.length > 1 ? url.pathname.slice(0, 30) : "";
74
+ return url.hostname + path;
75
+ } catch {
76
+ return raw.slice(0, 60);
77
+ }
78
+ }
79
+ if (["list_directory", "ls"].includes(name) && input.path) {
80
+ return String(input.path).slice(0, 60);
81
+ }
82
+ const firstVal = Object.values(input)[0];
83
+ if (firstVal !== void 0) {
84
+ return String(firstVal).slice(0, 50);
85
+ }
86
+ return "";
87
+ }
88
+ function showToolCall(name, input) {
89
+ const t = getTheme();
90
+ const summary = extractToolSummary(name, input);
91
+ const icon = t.accent("\u25CF");
92
+ if (summary) {
93
+ console.log(` ${icon} ${t.bold(name)}${t.dim(`("${summary}")`)}`);
94
+ } else {
95
+ console.log(` ${icon} ${t.bold(name)}`);
96
+ }
97
+ }
98
+ function showToolCallDone(_name, durationMs) {
99
+ if (durationMs == null) return;
100
+ const t = getTheme();
101
+ const dur = durationMs < 1e3 ? `${durationMs}ms` : `${(durationMs / 1e3).toFixed(1)}s`;
102
+ console.log(` ${t.dim(`\u2514 ${dur}`)}`);
103
+ }
104
+ function showStationComplete(index, name, tokens, durationMs) {
105
+ const t = getTheme();
106
+ const parts = [t.success(`\u2713 ${name}`)];
107
+ if (tokens && tokens > 0) {
108
+ parts.push(t.dim(`${tokens.toLocaleString()} tokens`));
109
+ }
110
+ if (durationMs && durationMs > 0) {
111
+ const durStr = durationMs < 1e3 ? `${durationMs}ms` : `${(durationMs / 1e3).toFixed(1)}s`;
112
+ parts.push(t.dim(durStr));
113
+ }
114
+ console.log(` ${parts.join(t.dim(" \xB7 "))}`);
115
+ }
116
+ function showStationSkipped(index, name, reason) {
117
+ const t = getTheme();
118
+ console.log(t.warning(`
119
+ \u23ED \u5DE5\u4F4D ${index} \u8DF3\u8FC7\uFF1A${name}`));
120
+ console.log(t.dim(` ${reason}`));
121
+ }
122
+ function showStationRetry(index, name, attempt, maxRetry, error) {
123
+ const t = getTheme();
124
+ console.log(t.warning(`
125
+ \u21BB \u5DE5\u4F4D ${index} \u91CD\u8BD5 (${attempt}/${maxRetry})\uFF1A${name}`));
126
+ console.log(t.dim(` \u9519\u8BEF\uFF1A${error}`));
127
+ }
128
+ function showCheckpoint(type, description) {
129
+ const t = getTheme();
130
+ console.log();
131
+ if (type === "decision") {
132
+ console.log(t.warning(" \u23F8 \u68C0\u67E5\u70B9\uFF1A\u8BF7\u505A\u51FA\u9009\u62E9"));
133
+ } else {
134
+ console.log(t.warning(" \u23F8 \u68C0\u67E5\u70B9\uFF1A\u8BF7\u5BA1\u9605"));
135
+ }
136
+ if (description) {
137
+ console.log(t.dim(` ${description}`));
138
+ }
139
+ console.log();
140
+ }
141
+ function showRunComplete(result, model) {
142
+ const t = getTheme();
143
+ const durationMs = result.endTime.getTime() - result.startTime.getTime();
144
+ const durationMin = (durationMs / 6e4).toFixed(1);
145
+ const totalTokens = result.totalTokens.inputTokens + result.totalTokens.outputTokens;
146
+ const toolCallCount = result.stationResults.reduce(
147
+ (sum, s) => sum + s.toolCalls.length,
148
+ 0
149
+ );
150
+ const cost = model ? estimateCost(model, result.totalTokens.inputTokens, result.totalTokens.outputTokens) : null;
151
+ const shortPath = result.outputPath.replace(process.env.HOME || "~", "~");
152
+ console.log();
153
+ const w = LINE_W;
154
+ console.log(` ${t.dim(`\u250C${"\u2500".repeat(w)}\u2510`)}`);
155
+ console.log(` ${boxRow(` ${t.success("\u2713 \u751F\u4EA7\u7EBF\u5B8C\u6210")} ${t.dim("\xB7")} ${chalk.white(result.lineName || "\u751F\u4EA7\u7EBF")}`, w)}`);
156
+ console.log(` ${t.dim(`\u251C${"\u2500".repeat(w)}\u2524`)}`);
157
+ console.log(` ${boxRow(` \u8F93\u51FA ${t.accent(shortPath)}`, w)}`);
158
+ console.log(` ${boxRow(` \u8017\u65F6 ${chalk.white(durationMin + " \u5206\u949F")}`, w)}`);
159
+ console.log(` ${boxRow(` Token ${chalk.white(totalTokens.toLocaleString())} ${t.dim(`(\u5165 ${(result.totalTokens.inputTokens / 1e3).toFixed(0)}k + \u51FA ${(result.totalTokens.outputTokens / 1e3).toFixed(0)}k)`)}`, w)}`);
160
+ if (cost) {
161
+ console.log(` ${boxRow(` \u8D39\u7528 ${chalk.white(formatCost(cost))}`, w)}`);
162
+ }
163
+ if (toolCallCount > 0) {
164
+ console.log(` ${boxRow(` \u5DE5\u5177 ${chalk.white(toolCallCount + " \u6B21\u8C03\u7528")}`, w)}`);
165
+ }
166
+ console.log(` ${t.dim(`\u2514${"\u2500".repeat(w)}\u2518`)}`);
167
+ console.log();
168
+ }
169
+ function showError(message) {
170
+ const t = getTheme();
171
+ console.error(t.error(`
172
+ \u2717 ${message}
173
+ `));
174
+ }
175
+ var CATEGORY_LABELS = {
176
+ model: "\u6A21\u578B",
177
+ session: "\u4F1A\u8BDD",
178
+ context: "\u4E0A\u4E0B\u6587",
179
+ git: "Git",
180
+ team: "\u56E2\u961F",
181
+ util: "\u5DE5\u5177",
182
+ debug: "\u8C03\u8BD5"
183
+ };
184
+ function showREPLHelp() {
185
+ const t = getTheme();
186
+ console.log(t.bold("\n \u5FEB\u901F\u4E0A\u624B\n"));
187
+ console.log(` ${t.accent("/help")} ${t.dim("\u67E5\u770B\u5168\u90E8 slash \u547D\u4EE4")}`);
188
+ console.log(` ${t.accent("/palette")} ${t.dim("\u547D\u4EE4\u9762\u677F\uFF08Ctrl+K \u5FEB\u901F\u5524\u8D77\uFF09")}`);
189
+ console.log(` ${t.accent("/model deepseek")} ${t.dim("\u5207\u6362\u6A21\u578B\uFF08\u6216 /model \u67E5\u770B\u522B\u540D\uFF09")}`);
190
+ console.log(` ${t.accent("/doctor")} ${t.dim("\u68C0\u67E5\u914D\u7F6E\u3001\u6743\u9650\u3001\u73AF\u5883\u5065\u5EB7")}`);
191
+ console.log(` ${t.accent("/history")} ${t.dim("\u67E5\u770B/\u6062\u590D\u4F1A\u8BDD")}`);
192
+ console.log(` ${t.accent("/context")} ${t.dim("\u67E5\u770B\u4E0A\u4E0B\u6587\u5360\u7528")}`);
193
+ console.log(` ${t.accent("!git status")} ${t.dim("\u76F4\u63A5\u6267\u884C shell \u547D\u4EE4")}`);
194
+ console.log(` ${t.accent("run <\u7EBF\u540D>")} ${t.dim("\u8FD0\u884C\u751F\u4EA7\u7EBF")}`);
195
+ console.log(` ${t.accent("exit")} ${t.dim("\u9000\u51FA REPL")}`);
196
+ console.log(t.dim("\n \u63D0\u793A: \u8F93\u5165 /help <\u547D\u4EE4> \u53EF\u67E5\u770B\u8BE5\u547D\u4EE4\u8BE6\u7EC6\u7528\u6CD5\n"));
197
+ }
198
+ function showCapabilityQuickGuide() {
199
+ const t = getTheme();
200
+ console.log(t.bold("\n \u6211\u53EF\u4EE5\u76F4\u63A5\u5E2E\u4F60\u6267\u884C\u8FD9\u4E9B\u4EFB\u52A1\uFF1A\n"));
201
+ console.log(` ${t.accent("\u4EE3\u7801\u5DE5\u7A0B")} \u4FEE\u590D bug\u3001\u91CD\u6784\u3001\u8865\u6D4B\u8BD5\u3001\u505A\u4EE3\u7801\u5BA1\u67E5`);
202
+ console.log(` ${t.accent("\u547D\u4EE4\u6267\u884C")} \u8DD1\u6784\u5EFA/\u6D4B\u8BD5\u3001\u5B9A\u4F4D\u62A5\u9519\u3001\u81EA\u52A8\u5316\u811A\u672C`);
203
+ console.log(` ${t.accent("\u9879\u76EE\u5206\u6790")} \u626B\u63CF\u76EE\u5F55\u7ED3\u6784\u3001\u68B3\u7406\u4F9D\u8D56\u548C\u98CE\u9669\u70B9`);
204
+ console.log(` ${t.accent("\u6587\u6863\u4EA7\u51FA")} \u751F\u6210 README\u3001\u53D8\u66F4\u8BF4\u660E\u3001\u53D1\u5E03\u8BF4\u660E`);
205
+ console.log(` ${t.accent("\u534F\u4F5C\u6D41\u7A0B")} \u5206\u652F/\u63D0\u4EA4/PR \u8F85\u52A9\u3001\u56E2\u961F\u4EFB\u52A1\u62C6\u89E3`);
206
+ console.log(` ${t.accent("\u5185\u89C2\u8BCA\u65AD")} /mirror \u53EF\u89C6\u5316\u3001/doctor \u5065\u5EB7\u68C0\u67E5`);
207
+ console.log(t.dim("\n \u4F60\u53EF\u4EE5\u76F4\u63A5\u8BF4\uFF1A"));
208
+ console.log(t.dim(' - "\u68C0\u67E5\u8FD9\u4E2A\u9879\u76EE\u7684\u95EE\u9898\u5E76\u4FEE\u590D"'));
209
+ console.log(t.dim(' - "\u628A dashboard \u9ED8\u8BA4\u6A21\u578B\u548C\u7EC8\u7AEF\u4FDD\u6301\u4E00\u81F4"'));
210
+ console.log(t.dim(' - "\u7ED9\u6211\u8BBE\u8BA1\u5E76\u63A5\u5165\u81EA\u52A8\u56DE\u5F52\u6D4B\u8BD5"'));
211
+ console.log(t.dim("\n \u547D\u4EE4\u5165\u53E3: /help \xB7 /model \xB7 /doctor \xB7 /history \xB7 /mirror\n"));
212
+ }
213
+ function showSlashCommandsGrouped(commands) {
214
+ const t = getTheme();
215
+ const groups = {};
216
+ for (const cmd of commands) {
217
+ const cat = cmd.category || "util";
218
+ if (!groups[cat]) groups[cat] = [];
219
+ groups[cat].push(cmd);
220
+ }
221
+ const categoryOrder = ["model", "session", "context", "git", "team", "util", "debug"];
222
+ const maxLen = Math.max(...commands.map((c) => c.name.length), 8);
223
+ for (const cat of categoryOrder) {
224
+ const cmds = groups[cat];
225
+ if (!cmds || cmds.length === 0) continue;
226
+ const label = CATEGORY_LABELS[cat] || cat;
227
+ console.log(`
228
+ ${t.dim(`\u2500\u2500\u2500 ${label} \u2500\u2500\u2500`)}`);
229
+ for (const c of cmds) {
230
+ const aliases = c.aliases?.length ? t.dim(` (${c.aliases.join(", ")})`) : "";
231
+ console.log(` ${t.accent("/" + c.name.padEnd(maxLen))} ${t.dim(c.description)}${aliases}`);
232
+ }
233
+ }
234
+ console.log();
235
+ console.log(t.dim(" ! \u524D\u7F00\u76F4\u63A5\u6267\u884C Shell\uFF08\u5982 !git status\uFF09"));
236
+ console.log(t.dim(' """ \u4E09\u5F15\u53F7\u6216 \\ \u7EED\u884C\u652F\u6301\u591A\u884C\u8F93\u5165'));
237
+ console.log(t.dim(" Tab \u952E\u81EA\u52A8\u8865\u5168\u547D\u4EE4"));
238
+ console.log();
239
+ }
240
+ function showLineList(lines) {
241
+ const t = getTheme();
242
+ if (lines.length === 0) {
243
+ console.log(t.dim(" \u6CA1\u6709\u53EF\u7528\u7684\u751F\u4EA7\u7EBF\u3002\u8FD0\u884C hypercore init \u521D\u59CB\u5316\u3002"));
244
+ return;
245
+ }
246
+ console.log(t.bold("\n \u53EF\u7528\u7684\u751F\u4EA7\u7EBF\uFF1A\n"));
247
+ for (const line of lines) {
248
+ const icon = line.icon || "\u25CF";
249
+ console.log(` ${icon} ${t.bold(line.name)}`);
250
+ console.log(t.dim(` ${line.description}`));
251
+ console.log();
252
+ }
253
+ }
254
+ var MODEL_PRICING = {
255
+ "claude-sonnet-4-20250514": { input: 3, output: 15 },
256
+ "claude-haiku-4-5-20251001": { input: 0.8, output: 4 },
257
+ "claude-opus-4-20250514": { input: 15, output: 75 },
258
+ "MiniMax-M2.5": { input: 1.1, output: 1.1 },
259
+ "gemini-2.5-flash": { input: 0.15, output: 0.6 },
260
+ "gemini-2.5-pro": { input: 1.25, output: 10 },
261
+ "deepseek-chat": { input: 0.27, output: 1.1 },
262
+ "deepseek-reasoner": { input: 0.55, output: 2.19 }
263
+ };
264
+ var USD_TO_CNY = 7.2;
265
+ function estimateCost(model, inputTokens, outputTokens) {
266
+ const pricing = MODEL_PRICING[model];
267
+ if (!pricing) return null;
268
+ const usd = (inputTokens * pricing.input + outputTokens * pricing.output) / 1e6;
269
+ return { usd, cny: usd * USD_TO_CNY };
270
+ }
271
+ function formatCost(cost) {
272
+ if (cost.cny < 0.01) return "< \xA50.01";
273
+ return `~\xA5${cost.cny.toFixed(2)}`;
274
+ }
275
+ function showResponseStats(durationMs, inputTokens, outputTokens, model) {
276
+ const t = getTheme();
277
+ const totalTokens = inputTokens + outputTokens;
278
+ const durationStr = durationMs < 1e3 ? `${durationMs}ms` : `${(durationMs / 1e3).toFixed(1)}s`;
279
+ const parts = [durationStr, `${totalTokens.toLocaleString()} tokens`];
280
+ const cost = estimateCost(model, inputTokens, outputTokens);
281
+ if (cost) {
282
+ parts.push(formatCost(cost));
283
+ }
284
+ console.log(t.dim(`
285
+ ${parts.join(" \xB7 ")}`));
286
+ }
287
+ function showSessionCost(inputTokens, outputTokens, model, rounds) {
288
+ const t = getTheme();
289
+ const total = inputTokens + outputTokens;
290
+ console.log(t.bold("\n \u672C\u6B21\u4F1A\u8BDD Token \u7528\u91CF\uFF1A"));
291
+ console.log(t.dim(` \u8F93\u5165: ${inputTokens.toLocaleString()}`));
292
+ console.log(t.dim(` \u8F93\u51FA: ${outputTokens.toLocaleString()}`));
293
+ console.log(t.dim(` \u5408\u8BA1: ${total.toLocaleString()}`));
294
+ console.log(t.dim(` \u5BF9\u8BDD\u8F6E\u6570: ${rounds}`));
295
+ const cost = estimateCost(model, inputTokens, outputTokens);
296
+ if (cost) {
297
+ console.log(t.dim(` \u4F30\u7B97\u8D39\u7528: ${formatCost(cost)} ($${cost.usd.toFixed(4)})`));
298
+ }
299
+ console.log();
300
+ }
301
+ function showExitSummary(inputTokens, outputTokens, model, rounds, durationMs) {
302
+ const t = getTheme();
303
+ const total = inputTokens + outputTokens;
304
+ const durationMin = (durationMs / 6e4).toFixed(1);
305
+ const cost = estimateCost(model, inputTokens, outputTokens);
306
+ const costStr = cost ? ` \xB7 ${formatCost(cost)}` : "";
307
+ console.log();
308
+ console.log(t.dim(` ${rounds} \u8F6E\u5BF9\u8BDD \xB7 ${total.toLocaleString()} tokens \xB7 ${durationMin} \u5206\u949F${costStr}`));
309
+ console.log(t.dim("\n \u518D\u89C1\n"));
310
+ }
311
+ function showTeamBanner() {
312
+ const t = getTheme();
313
+ const w = LINE_W;
314
+ console.log();
315
+ console.log(` ${boxTop(w)}`);
316
+ console.log(` ${boxRow(` ${t.accent("Hypercore Team")} ${t.dim("\xB7")} \u534F\u4F5C\u6A21\u5F0F `, w)}`);
317
+ console.log(` ${boxBot(w)}`);
318
+ }
319
+ function showTeamStatus(team, members, localToken) {
320
+ const t = getTheme();
321
+ showTeamBanner();
322
+ console.log();
323
+ console.log(` ${t.bold(team.name)} ${t.dim(`(${team.id})`)}`);
324
+ console.log(` ${t.dim("\u52A0\u5165\u7801:")} ${t.accent(team.joinCode)}`);
325
+ console.log();
326
+ console.log(t.bold(" \u6210\u5458\u5217\u8868\uFF1A"));
327
+ for (const m of members) {
328
+ const statusIcon = m.status === "online" ? t.success("\u25CF") : t.dim("\u25CB");
329
+ const roleTag = m.role === "owner" ? t.warning(" \u2605") : "";
330
+ const youTag = localToken && m.id === localToken.memberId ? t.dim(" (\u4F60)") : "";
331
+ console.log(` ${statusIcon} ${chalk.white(m.name)}${roleTag}${youTag}`);
332
+ }
333
+ console.log();
334
+ const online = members.filter((m) => m.status === "online").length;
335
+ console.log(t.dim(` ${online}/${members.length} \u5728\u7EBF`));
336
+ console.log();
337
+ }
338
+ function showTaskList(tasks) {
339
+ const t = getTheme();
340
+ if (tasks.length === 0) {
341
+ console.log(t.dim("\n \u6CA1\u6709\u4EFB\u52A1\u3002\u4F7F\u7528 hyper team task add <\u6807\u9898> \u521B\u5EFA\u4EFB\u52A1\n"));
342
+ return;
343
+ }
344
+ console.log(t.bold("\n \u56E2\u961F\u4EFB\u52A1\uFF1A\n"));
345
+ const STATUS_ICONS = {
346
+ todo: "\u25CB",
347
+ doing: "\u25D0",
348
+ review: "\u25D1",
349
+ done: "\u25CF"
350
+ };
351
+ const PRIORITY_COLORS = {
352
+ S: chalk.red,
353
+ A: chalk.yellow,
354
+ B: chalk.white,
355
+ C: chalk.dim
356
+ };
357
+ for (const task of tasks) {
358
+ const icon = STATUS_ICONS[task.status] || "\u25CB";
359
+ const colorFn = PRIORITY_COLORS[task.priority] || chalk.white;
360
+ const assignee = task.assignee ? t.dim(` \u2192 ${task.assignee}`) : "";
361
+ console.log(` ${icon} ${t.dim(`#${task.id}`)} ${colorFn(`[${task.priority}]`)} ${chalk.white(task.title)}${assignee}`);
362
+ }
363
+ console.log();
364
+ }
365
+
366
+ export {
367
+ CLI_VERSION,
368
+ showBanner,
369
+ showWelcome,
370
+ showREPLWelcome,
371
+ showStationStart,
372
+ showThinking,
373
+ showToolCall,
374
+ showToolCallDone,
375
+ showStationComplete,
376
+ showStationSkipped,
377
+ showStationRetry,
378
+ showCheckpoint,
379
+ showRunComplete,
380
+ showError,
381
+ showREPLHelp,
382
+ showCapabilityQuickGuide,
383
+ showSlashCommandsGrouped,
384
+ showLineList,
385
+ estimateCost,
386
+ formatCost,
387
+ showResponseStats,
388
+ showSessionCost,
389
+ showExitSummary,
390
+ showTeamBanner,
391
+ showTeamStatus,
392
+ showTaskList
393
+ };
@@ -0,0 +1,43 @@
1
+ import {
2
+ showCheckpoint
3
+ } from "./chunk-R3GPQC7I.js";
4
+
5
+ // src/ui/checkpoint.ts
6
+ import { select, input } from "@inquirer/prompts";
7
+ import chalk from "chalk";
8
+ async function handleCheckpoint(type, output, description) {
9
+ showCheckpoint(type, description);
10
+ console.log(chalk.dim(" \u2500".repeat(30)));
11
+ console.log();
12
+ const lines = output.split("\n");
13
+ const displayLines = lines.slice(0, 50);
14
+ for (const line of displayLines) {
15
+ console.log(` ${line}`);
16
+ }
17
+ if (lines.length > 50) {
18
+ console.log(chalk.dim(`
19
+ ... \u8FD8\u6709 ${lines.length - 50} \u884C\uFF08\u5B8C\u6574\u5185\u5BB9\u5C06\u4FDD\u5B58\u5230\u6587\u4EF6\uFF09`));
20
+ }
21
+ console.log();
22
+ console.log(chalk.dim(" \u2500".repeat(30)));
23
+ console.log();
24
+ const action = await select({
25
+ message: "\u4F60\u7684\u9009\u62E9\uFF1A",
26
+ choices: [
27
+ { value: "approve", name: "\u2705 \u786E\u8BA4\uFF0C\u7EE7\u7EED" },
28
+ { value: "modify", name: "\u270F\uFE0F \u7ED9\u53CD\u9988\uFF0C\u4FEE\u6539\u540E\u7EE7\u7EED" },
29
+ { value: "rewrite", name: "\u{1F504} \u4E0D\u6EE1\u610F\uFF0C\u91CD\u5199" }
30
+ ]
31
+ });
32
+ if (action === "modify") {
33
+ const feedback = await input({
34
+ message: "\u8BF7\u8F93\u5165\u4F60\u7684\u53CD\u9988\uFF1A"
35
+ });
36
+ return { action: "modify", feedback };
37
+ }
38
+ return { action };
39
+ }
40
+
41
+ export {
42
+ handleCheckpoint
43
+ };
@@ -0,0 +1,80 @@
1
+ // src/ui/theme.ts
2
+ import chalk from "chalk";
3
+ var DARK_THEME = {
4
+ accent: chalk.cyan,
5
+ dim: chalk.dim,
6
+ success: chalk.green,
7
+ warning: chalk.yellow,
8
+ error: chalk.red,
9
+ info: chalk.blue,
10
+ bold: chalk.bold,
11
+ code: chalk.cyan,
12
+ prompt: chalk.cyan,
13
+ statusBg: chalk.bgGray,
14
+ statusText: chalk.white,
15
+ ghost: chalk.gray
16
+ };
17
+ var LIGHT_THEME = {
18
+ accent: chalk.blue,
19
+ dim: chalk.gray,
20
+ success: chalk.green,
21
+ warning: chalk.hex("#B8860B"),
22
+ // dark goldenrod
23
+ error: chalk.red,
24
+ info: chalk.blueBright,
25
+ bold: chalk.bold,
26
+ code: chalk.magenta,
27
+ prompt: chalk.blue,
28
+ statusBg: chalk.bgWhite,
29
+ statusText: chalk.black,
30
+ ghost: chalk.hex("#AAAAAA")
31
+ };
32
+ var HIGH_CONTRAST_THEME = {
33
+ accent: chalk.cyanBright,
34
+ dim: chalk.white,
35
+ success: chalk.greenBright,
36
+ warning: chalk.yellowBright,
37
+ error: chalk.redBright,
38
+ info: chalk.blueBright,
39
+ bold: chalk.bold.whiteBright,
40
+ code: chalk.cyanBright,
41
+ prompt: chalk.whiteBright,
42
+ statusBg: chalk.bgWhiteBright,
43
+ statusText: chalk.black,
44
+ ghost: chalk.gray
45
+ };
46
+ var THEMES = {
47
+ dark: DARK_THEME,
48
+ light: LIGHT_THEME,
49
+ "high-contrast": HIGH_CONTRAST_THEME
50
+ };
51
+ var currentTheme = "dark";
52
+ var currentColors = DARK_THEME;
53
+ function getTheme() {
54
+ return currentColors;
55
+ }
56
+ function getThemeName() {
57
+ return currentTheme;
58
+ }
59
+ function setTheme(name) {
60
+ if (THEMES[name]) {
61
+ currentTheme = name;
62
+ currentColors = THEMES[name];
63
+ }
64
+ }
65
+ function getAvailableThemes() {
66
+ return Object.keys(THEMES);
67
+ }
68
+ var THEME_LABELS = {
69
+ dark: "\u{1F319} \u6697\u8272",
70
+ light: "\u2600\uFE0F \u4EAE\u8272",
71
+ "high-contrast": "\u{1F532} \u9AD8\u5BF9\u6BD4\u5EA6"
72
+ };
73
+
74
+ export {
75
+ getTheme,
76
+ getThemeName,
77
+ setTheme,
78
+ getAvailableThemes,
79
+ THEME_LABELS
80
+ };