hypercore-cli 1.1.2 → 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.
Files changed (158) hide show
  1. package/LICENSE +92 -21
  2. package/README.md +8 -1
  3. package/dist/App-YMX7FSXR.js +1 -0
  4. package/dist/api-Q2TX5JJL.js +1 -0
  5. package/dist/auth-X6CUT3DW.js +1 -0
  6. package/dist/background-ACODXSUG.js +1 -0
  7. package/dist/backlog-JD2IM336.js +1 -0
  8. package/dist/chunk-2QI2IU2V.js +1 -0
  9. package/dist/chunk-3KFRDIPQ.js +1 -0
  10. package/dist/chunk-42C5J7PN.js +1 -0
  11. package/dist/chunk-4D7XVJ7Q.js +1 -0
  12. package/dist/chunk-545IGTXV.js +1 -0
  13. package/dist/chunk-5KUSGQP2.js +1 -0
  14. package/dist/chunk-AUQ64BK2.js +1 -0
  15. package/dist/chunk-AV244H5C.js +1 -0
  16. package/dist/chunk-BQVBEFS4.js +1 -0
  17. package/dist/chunk-BYWQLFP2.js +1 -0
  18. package/dist/chunk-COITWWZJ.js +1 -0
  19. package/dist/chunk-CR7UUJVX.js +1 -0
  20. package/dist/chunk-E3MULLBX.js +1 -0
  21. package/dist/chunk-EWBV7YPP.js +1 -0
  22. package/dist/chunk-EZHYVJGQ.js +1 -0
  23. package/dist/chunk-FAKXBY7Q.js +1 -0
  24. package/dist/chunk-FHGATV5B.js +1 -0
  25. package/dist/chunk-I2G27Y5P.js +1 -0
  26. package/dist/chunk-IKF43TX2.js +1 -0
  27. package/dist/chunk-INSPHCBN.js +1 -0
  28. package/dist/chunk-LQMDUKIE.js +1 -0
  29. package/dist/chunk-M3MTKGA5.js +1 -0
  30. package/dist/chunk-MPO54FU3.js +1 -0
  31. package/dist/chunk-PVKCZI6A.js +1 -0
  32. package/dist/chunk-Q7KEPCYL.js +1 -0
  33. package/dist/chunk-R5XD3NT2.js +1 -0
  34. package/dist/chunk-ROBZ6PAL.js +1 -0
  35. package/dist/chunk-RXB5BS2N.js +1 -0
  36. package/dist/chunk-RZ3HNYMT.js +1 -0
  37. package/dist/chunk-UCGLRMTG.js +1 -0
  38. package/dist/chunk-UEHJVRKB.js +1 -0
  39. package/dist/chunk-UZYX5GGF.js +1 -0
  40. package/dist/chunk-XQJBB725.js +1 -0
  41. package/dist/chunk-ZB5ZQSXH.js +1 -0
  42. package/dist/claude-US2QPRBA.js +1 -0
  43. package/dist/commands-5TFN74MD.js +1 -0
  44. package/dist/commands-EKPWCB3T.js +1 -0
  45. package/dist/commands-QHJLREPM.js +1 -0
  46. package/dist/config-2OUL5FLS.js +1 -0
  47. package/dist/config-loader-N7IBWN2P.js +1 -0
  48. package/dist/diagnose-NLHN4SAJ.js +1 -0
  49. package/dist/display-TB5YACJV.js +1 -0
  50. package/dist/extractor-3KTM2IUL.js +1 -0
  51. package/dist/feature-flag-VVIF5FJG.js +1 -0
  52. package/dist/history-GVNDPXXQ.js +1 -0
  53. package/dist/index.js +1 -402
  54. package/dist/instance-registry-I5AIVJE2.js +1 -0
  55. package/dist/keybindings-RN3A7CRW.js +1 -0
  56. package/dist/loader-3IKPXP4R.js +1 -0
  57. package/dist/network-GI2F3IDE.js +1 -0
  58. package/dist/notify-O6FNVHC4.js +1 -0
  59. package/dist/openai-compat-IPCMINVF.js +1 -0
  60. package/dist/permissions-5O7KVAXU.js +1 -0
  61. package/dist/prompt-VWFPFM4N.js +1 -0
  62. package/dist/quality-GPQD25UL.js +1 -0
  63. package/dist/repl-YNXCDVU4.js +1 -0
  64. package/dist/roadmap-QRZODSNJ.js +1 -0
  65. package/dist/server-USQP4GC4.js +1 -0
  66. package/dist/session-5HDDQQP6.js +1 -0
  67. package/dist/skills-DXWSVJSU.js +1 -0
  68. package/dist/store-WXXTKTTL.js +1 -0
  69. package/dist/team-VTPJ3WRT.js +1 -0
  70. package/dist/telemetry-NT4UZLBS.js +1 -0
  71. package/dist/test-runner-F6B6RH3S.js +1 -0
  72. package/dist/theme-JJJ6ABR2.js +1 -0
  73. package/dist/upgrade-RUG3R7R5.js +1 -0
  74. package/dist/verify-6OGRY2PR.js +1 -0
  75. package/dist/version-DLROA5JN.js +1 -0
  76. package/dist/web/static/app.js +1 -562
  77. package/dist/web/static/index.html +114 -126
  78. package/dist/web/static/mirror.css +1 -1001
  79. package/dist/web/static/mirror.html +155 -178
  80. package/dist/web/static/mirror.js +1 -1125
  81. package/dist/web/static/onboard.css +1 -302
  82. package/dist/web/static/onboard.html +121 -145
  83. package/dist/web/static/onboard.js +1 -300
  84. package/dist/web/static/style.css +1 -602
  85. package/dist/web/static/utils.js +1 -0
  86. package/dist/web/static/workspace.css +1 -1568
  87. package/dist/web/static/workspace.html +369 -402
  88. package/dist/web/static/workspace.js +1 -1683
  89. package/dist/web-P5YUKEAU.js +1 -0
  90. package/package.json +25 -4
  91. package/dist/api-JHHOZTL6.js +0 -162
  92. package/dist/auth-5QFJLW7J.js +0 -21
  93. package/dist/background-2EGCAAQH.js +0 -14
  94. package/dist/backlog-Q2NZCLNY.js +0 -24
  95. package/dist/chunk-2CMSCWQW.js +0 -162
  96. package/dist/chunk-4DVYJAJL.js +0 -57
  97. package/dist/chunk-5GDYH676.js +0 -271
  98. package/dist/chunk-5NLVGLD7.js +0 -66
  99. package/dist/chunk-6XTEAFZQ.js +0 -575
  100. package/dist/chunk-AQBSMYLT.js +0 -2025
  101. package/dist/chunk-BE46C7JW.js +0 -46
  102. package/dist/chunk-CLKIMCXZ.js +0 -139
  103. package/dist/chunk-DN4ASQ26.js +0 -167
  104. package/dist/chunk-DUWREZXK.js +0 -173
  105. package/dist/chunk-FCW3K6F2.js +0 -263
  106. package/dist/chunk-GFORWAMW.js +0 -251
  107. package/dist/chunk-GH7E2OJE.js +0 -223
  108. package/dist/chunk-GU2FZQ6A.js +0 -69
  109. package/dist/chunk-I7WI3BMB.js +0 -161
  110. package/dist/chunk-IOPKN5GD.js +0 -190
  111. package/dist/chunk-LBVHDGZE.js +0 -133
  112. package/dist/chunk-MGLJ53QN.js +0 -219
  113. package/dist/chunk-NETIY5UB.js +0 -134
  114. package/dist/chunk-NP47L7LG.js +0 -288
  115. package/dist/chunk-O6MG7TOH.js +0 -58
  116. package/dist/chunk-OPZYEVYR.js +0 -150
  117. package/dist/chunk-R3GPQC7I.js +0 -393
  118. package/dist/chunk-R5T3A2NQ.js +0 -166
  119. package/dist/chunk-RKB2JOV2.js +0 -43
  120. package/dist/chunk-RNG3K465.js +0 -80
  121. package/dist/chunk-TGTYKBGC.js +0 -86
  122. package/dist/chunk-UCX4VZCT.js +0 -681
  123. package/dist/chunk-WHLVZCQY.js +0 -245
  124. package/dist/chunk-Y6HMJZDJ.js +0 -1505
  125. package/dist/chunk-ZSBHUGWR.js +0 -262
  126. package/dist/claude-4BX3MJSK.js +0 -12
  127. package/dist/commands-2X4OB5RF.js +0 -128
  128. package/dist/commands-GLBCEVQK.js +0 -1044
  129. package/dist/commands-IINRNBYX.js +0 -232
  130. package/dist/config-RSNQJQPS.js +0 -8
  131. package/dist/config-loader-SXO674TF.js +0 -24
  132. package/dist/diagnose-7UPLS7I4.js +0 -12
  133. package/dist/display-IIUBEYWN.js +0 -58
  134. package/dist/extractor-D3XWOAXI.js +0 -129
  135. package/dist/history-6I6FADAU.js +0 -180
  136. package/dist/index.d.ts +0 -1
  137. package/dist/instance-registry-J7UJ7U4Z.js +0 -15
  138. package/dist/keybindings-PDXIOV3O.js +0 -15
  139. package/dist/loader-GKEYT6Y7.js +0 -58
  140. package/dist/network-JYGHQXAR.js +0 -279
  141. package/dist/notify-HPTALZDC.js +0 -14
  142. package/dist/openai-compat-R7EKWG6Z.js +0 -12
  143. package/dist/permissions-JUKXMNDH.js +0 -10
  144. package/dist/prompt-UWHSZU4P.js +0 -166
  145. package/dist/quality-ST7PPNFR.js +0 -16
  146. package/dist/repl-QHIZ2JGF.js +0 -3374
  147. package/dist/roadmap-5OBEKROY.js +0 -17
  148. package/dist/server-HCNIP7ZQ.js +0 -57
  149. package/dist/session-5EBECDUP.js +0 -21
  150. package/dist/skills-HBQQTYO4.js +0 -175
  151. package/dist/store-FKUTR7GW.js +0 -25
  152. package/dist/team-7BBBP5YQ.js +0 -385
  153. package/dist/telemetry-6R4EIE6O.js +0 -30
  154. package/dist/test-runner-AUAGIBNM.js +0 -619
  155. package/dist/theme-3SYJ3UQA.js +0 -14
  156. package/dist/upgrade-MZFH7OCN.js +0 -83
  157. package/dist/verify-JUDKTPKZ.js +0 -14
  158. package/dist/web-KS3FUGJA.js +0 -39
@@ -1,232 +0,0 @@
1
- import {
2
- CATEGORY_LABELS,
3
- addMemory,
4
- getMemoryStats,
5
- listMemories,
6
- removeMemory,
7
- searchMemories
8
- } from "./chunk-GFORWAMW.js";
9
- import "./chunk-I7WI3BMB.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-D3XWOAXI.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
- };
@@ -1,8 +0,0 @@
1
- import {
2
- HYPERCORE_DIR,
3
- loadConfig
4
- } from "./chunk-I7WI3BMB.js";
5
- export {
6
- HYPERCORE_DIR,
7
- loadConfig
8
- };
@@ -1,24 +0,0 @@
1
- import {
2
- listLines,
3
- loadAgent,
4
- loadFile,
5
- loadLine,
6
- loadPWP,
7
- loadSkill,
8
- parseAgent,
9
- parsePWP,
10
- parseProductionLine,
11
- parseSkill
12
- } from "./chunk-WHLVZCQY.js";
13
- export {
14
- listLines,
15
- loadAgent,
16
- loadFile,
17
- loadLine,
18
- loadPWP,
19
- loadSkill,
20
- parseAgent,
21
- parsePWP,
22
- parseProductionLine,
23
- parseSkill
24
- };
@@ -1,12 +0,0 @@
1
- import {
2
- findingsToBacklog,
3
- runAIDiagnosis,
4
- runRuleDiagnosis
5
- } from "./chunk-NP47L7LG.js";
6
- import "./chunk-2CMSCWQW.js";
7
- import "./chunk-MGLJ53QN.js";
8
- export {
9
- findingsToBacklog,
10
- runAIDiagnosis,
11
- runRuleDiagnosis
12
- };
@@ -1,58 +0,0 @@
1
- import {
2
- CLI_VERSION,
3
- estimateCost,
4
- formatCost,
5
- showBanner,
6
- showCapabilityQuickGuide,
7
- showCheckpoint,
8
- showError,
9
- showExitSummary,
10
- showLineList,
11
- showREPLHelp,
12
- showREPLWelcome,
13
- showResponseStats,
14
- showRunComplete,
15
- showSessionCost,
16
- showSlashCommandsGrouped,
17
- showStationComplete,
18
- showStationRetry,
19
- showStationSkipped,
20
- showStationStart,
21
- showTaskList,
22
- showTeamBanner,
23
- showTeamStatus,
24
- showThinking,
25
- showToolCall,
26
- showToolCallDone,
27
- showWelcome
28
- } from "./chunk-R3GPQC7I.js";
29
- import "./chunk-BE46C7JW.js";
30
- import "./chunk-RNG3K465.js";
31
- export {
32
- CLI_VERSION,
33
- estimateCost,
34
- formatCost,
35
- showBanner,
36
- showCapabilityQuickGuide,
37
- showCheckpoint,
38
- showError,
39
- showExitSummary,
40
- showLineList,
41
- showREPLHelp,
42
- showREPLWelcome,
43
- showResponseStats,
44
- showRunComplete,
45
- showSessionCost,
46
- showSlashCommandsGrouped,
47
- showStationComplete,
48
- showStationRetry,
49
- showStationSkipped,
50
- showStationStart,
51
- showTaskList,
52
- showTeamBanner,
53
- showTeamStatus,
54
- showThinking,
55
- showToolCall,
56
- showToolCallDone,
57
- showWelcome
58
- };
@@ -1,129 +0,0 @@
1
- import {
2
- DEFAULT_EXTRACTION_CONFIG,
3
- addMemory,
4
- loadStore,
5
- markExtraction
6
- } from "./chunk-GFORWAMW.js";
7
- import "./chunk-I7WI3BMB.js";
8
-
9
- // src/memory/extractor.ts
10
- var EXTRACTION_SYSTEM = `You are a memory extraction assistant. Extract concise, durable facts from conversations.
11
- Output valid JSON only. No prose.`;
12
- function buildExtractionPrompt(messages, existingTopics) {
13
- const recent = messages.slice(-8).map(
14
- (m) => `[${m.role}]: ${m.content.slice(0, 300)}`
15
- ).join("\n\n");
16
- const knownStr = existingTopics.length > 0 ? `Already known (skip duplicates): ${existingTopics.join(", ")}` : "No existing memories yet.";
17
- return `Extract up to 5 memories from this conversation.
18
- Focus on: user preferences, named tools/projects, recurring patterns, key decisions.
19
- ${knownStr}
20
-
21
- Rules:
22
- - content: \u2264100 chars, specific and durable
23
- - category: preference|decision|entity|pattern|fact|convention
24
- - tags: 1-3 lowercase keywords
25
- - confidence: 0.0-1.0 (skip if < 0.6)
26
-
27
- Conversation:
28
- ${recent}
29
-
30
- Respond JSON only:
31
- {"memories": [{"content":"...","category":"...","tags":[...],"confidence":0.9}]}`;
32
- }
33
- async function extractMemories(history, client, config, layer, opts) {
34
- if (history.length < 4) return [];
35
- const store = await loadStore(layer, opts);
36
- const existingTopics = store.records.slice(-20).map((r) => r.content.slice(0, 40));
37
- const userPrompt = buildExtractionPrompt(history, existingTopics);
38
- let rawOutput;
39
- if (config.modelConfig.sdkType === "openai") {
40
- const { streamOpenAIChat } = await import("./openai-compat-R7EKWG6Z.js");
41
- const OpenAI = (await import("openai")).default;
42
- const openaiClient = client;
43
- const result = await streamOpenAIChat(openaiClient, [
44
- { role: "system", content: EXTRACTION_SYSTEM },
45
- { role: "user", content: userPrompt }
46
- ], {
47
- model: config.modelConfig.model,
48
- tools: [],
49
- onChunk: () => {
50
- },
51
- onToolCall: () => {
52
- }
53
- });
54
- rawOutput = result.content;
55
- } else {
56
- const { streamCallLLM } = await import("./claude-4BX3MJSK.js");
57
- const Anthropic = (await import("@anthropic-ai/sdk")).default;
58
- const anthropicClient = client;
59
- const result = await streamCallLLM(anthropicClient, {
60
- systemPrompt: EXTRACTION_SYSTEM,
61
- userPrompt,
62
- history: [],
63
- tools: [],
64
- model: config.modelConfig.model,
65
- onText: () => {
66
- },
67
- onToolCall: () => {
68
- }
69
- });
70
- rawOutput = result.output;
71
- }
72
- const extracted = parseExtractionResult(rawOutput);
73
- if (extracted.length === 0) return [];
74
- const saved = [];
75
- for (const mem of extracted) {
76
- if (mem.confidence < DEFAULT_EXTRACTION_CONFIG.minConfidence) continue;
77
- if (!mem.content || mem.content.length < 5) continue;
78
- const record = await addMemory(layer, {
79
- layer,
80
- category: mem.category,
81
- content: mem.content.slice(0, 500),
82
- tags: mem.tags.slice(0, 5),
83
- confidence: mem.confidence
84
- }, opts);
85
- saved.push(record);
86
- }
87
- await markExtraction(layer, opts);
88
- return saved;
89
- }
90
- function parseExtractionResult(output) {
91
- try {
92
- const jsonMatch = output.match(/\{[\s\S]*"memories"[\s\S]*\}/);
93
- if (!jsonMatch) return [];
94
- const parsed = JSON.parse(jsonMatch[0]);
95
- if (!Array.isArray(parsed.memories)) return [];
96
- const validCategories = /* @__PURE__ */ new Set([
97
- "preference",
98
- "decision",
99
- "entity",
100
- "pattern",
101
- "fact",
102
- "convention"
103
- ]);
104
- return parsed.memories.filter(
105
- (m) => typeof m.content === "string" && typeof m.confidence === "number" && validCategories.has(m.category)
106
- ).map((m) => ({
107
- content: String(m.content).slice(0, 500),
108
- category: m.category,
109
- tags: Array.isArray(m.tags) ? m.tags.map(String).slice(0, 5) : [],
110
- confidence: Math.min(1, Math.max(0, Number(m.confidence)))
111
- }));
112
- } catch {
113
- return [];
114
- }
115
- }
116
- function shouldExtract(roundCount, everyN = 3) {
117
- return roundCount > 0 && roundCount % everyN === 0;
118
- }
119
- function triggerAutoExtraction(history, client, config, layers) {
120
- for (const layer of layers) {
121
- extractMemories(history, client, config, layer).catch(() => {
122
- });
123
- }
124
- }
125
- export {
126
- extractMemories,
127
- shouldExtract,
128
- triggerAutoExtraction
129
- };
@@ -1,180 +0,0 @@
1
- import {
2
- estimateCost,
3
- formatCost,
4
- showError
5
- } from "./chunk-R3GPQC7I.js";
6
- import "./chunk-BE46C7JW.js";
7
- import "./chunk-RNG3K465.js";
8
- import {
9
- HYPERCORE_DIR,
10
- loadConfig
11
- } from "./chunk-I7WI3BMB.js";
12
-
13
- // src/commands/history.ts
14
- import { existsSync } from "fs";
15
- import { readdir, readFile } from "fs/promises";
16
- import { join } from "path";
17
- import chalk from "chalk";
18
- async function historyCommand() {
19
- if (!existsSync(HYPERCORE_DIR)) {
20
- showError("\u8BF7\u5148\u8FD0\u884C hypercore init \u521D\u59CB\u5316");
21
- process.exit(1);
22
- }
23
- let config;
24
- try {
25
- config = await loadConfig();
26
- } catch (err) {
27
- showError(err instanceof Error ? err.message : String(err));
28
- process.exit(1);
29
- }
30
- const outputDir = config.outputDir;
31
- if (!existsSync(outputDir)) {
32
- console.log(chalk.dim("\n \u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u8BD5\u8BD5 hyper run \u70ED\u70B9\u8FFD\u8E2A\n"));
33
- return;
34
- }
35
- let files;
36
- try {
37
- files = await readdir(outputDir);
38
- } catch {
39
- console.log(chalk.dim("\n \u65E0\u6CD5\u8BFB\u53D6\u8F93\u51FA\u76EE\u5F55\n"));
40
- return;
41
- }
42
- const jsonFiles = files.filter((f) => f.endsWith(".run.json")).sort().reverse().slice(0, 20);
43
- if (jsonFiles.length === 0) {
44
- console.log(chalk.dim("\n \u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u8BD5\u8BD5 hyper run \u70ED\u70B9\u8FFD\u8E2A\n"));
45
- return;
46
- }
47
- console.log(chalk.bold("\n \u{1F4CB} \u8FD0\u884C\u5386\u53F2\uFF08\u6700\u8FD1 20 \u6761\uFF09\n"));
48
- for (const file of jsonFiles) {
49
- try {
50
- const content = await readFile(join(outputDir, file), "utf-8");
51
- const meta = JSON.parse(content);
52
- const startDate = new Date(meta.startTime);
53
- const endDate = new Date(meta.endTime);
54
- const durationMs = endDate.getTime() - startDate.getTime();
55
- const durationStr = durationMs < 6e4 ? `${(durationMs / 1e3).toFixed(0)}s` : `${(durationMs / 6e4).toFixed(1)}min`;
56
- const totalTokens = (meta.totalTokens?.inputTokens || 0) + (meta.totalTokens?.outputTokens || 0);
57
- const cost = estimateCost(
58
- meta.model,
59
- meta.totalTokens?.inputTokens || 0,
60
- meta.totalTokens?.outputTokens || 0
61
- );
62
- const dateStr = startDate.toLocaleDateString("zh-CN", {
63
- month: "2-digit",
64
- day: "2-digit",
65
- hour: "2-digit",
66
- minute: "2-digit"
67
- });
68
- const costStr = cost ? formatCost(cost) : "";
69
- const stationCount = meta.stations?.length || 0;
70
- const fileId = file.replace(".run.json", "");
71
- console.log(
72
- ` ${chalk.dim(dateStr)} ${chalk.bold(meta.lineName)} ` + chalk.dim(`${stationCount}\u5DE5\u4F4D \xB7 ${durationStr} \xB7 ${totalTokens.toLocaleString()} tokens${costStr ? ` \xB7 ${costStr}` : ""}`)
73
- );
74
- if (meta.userInputs && Object.keys(meta.userInputs).length > 0) {
75
- const inputStr = Object.entries(meta.userInputs).map(([k, v]) => `${k}=${v}`).join(", ");
76
- console.log(chalk.dim(` ${inputStr}`));
77
- }
78
- } catch {
79
- }
80
- }
81
- console.log(chalk.dim(`
82
- \u{1F4A1} \u67E5\u770B\u8BE6\u60C5: hyper history view <\u65E5\u671F-\u7EBF\u540D>`));
83
- console.log(chalk.dim(` \u8F93\u51FA\u76EE\u5F55\uFF1A${outputDir}
84
- `));
85
- }
86
- async function historyViewCommand(fileId) {
87
- if (!existsSync(HYPERCORE_DIR)) {
88
- showError("\u8BF7\u5148\u8FD0\u884C hypercore init \u521D\u59CB\u5316");
89
- process.exit(1);
90
- }
91
- let config;
92
- try {
93
- config = await loadConfig();
94
- } catch (err) {
95
- showError(err instanceof Error ? err.message : String(err));
96
- process.exit(1);
97
- }
98
- const outputDir = config.outputDir;
99
- let jsonPath = join(outputDir, `${fileId}.run.json`);
100
- if (!existsSync(jsonPath)) {
101
- try {
102
- const files = await readdir(outputDir);
103
- const match = files.find((f) => f.includes(fileId) && f.endsWith(".run.json"));
104
- if (match) {
105
- jsonPath = join(outputDir, match);
106
- } else {
107
- showError(`\u672A\u627E\u5230\u8FD0\u884C\u8BB0\u5F55: ${fileId}`);
108
- console.log(chalk.dim(" \u4F7F\u7528 hyper history \u67E5\u770B\u53EF\u7528\u8BB0\u5F55\n"));
109
- return;
110
- }
111
- } catch {
112
- showError(`\u65E0\u6CD5\u8BFB\u53D6\u8F93\u51FA\u76EE\u5F55`);
113
- return;
114
- }
115
- }
116
- let content;
117
- try {
118
- content = await readFile(jsonPath, "utf-8");
119
- } catch {
120
- showError(`\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6: ${jsonPath}`);
121
- return;
122
- }
123
- const meta = JSON.parse(content);
124
- const startDate = new Date(meta.startTime);
125
- const endDate = new Date(meta.endTime);
126
- const durationMs = endDate.getTime() - startDate.getTime();
127
- const durationStr = durationMs < 6e4 ? `${(durationMs / 1e3).toFixed(0)}s` : `${(durationMs / 6e4).toFixed(1)}min`;
128
- const totalTokens = (meta.totalTokens?.inputTokens || 0) + (meta.totalTokens?.outputTokens || 0);
129
- const cost = estimateCost(
130
- meta.model,
131
- meta.totalTokens?.inputTokens || 0,
132
- meta.totalTokens?.outputTokens || 0
133
- );
134
- console.log(chalk.bold(`
135
- \u{1F4CB} \u8FD0\u884C\u8BE6\u60C5\uFF1A${meta.lineName}
136
- `));
137
- console.log(chalk.dim(` \u65F6\u95F4: ${startDate.toLocaleString("zh-CN")}`));
138
- console.log(chalk.dim(` \u8017\u65F6: ${durationStr}`));
139
- console.log(chalk.dim(` \u6A21\u578B: ${meta.model}`));
140
- console.log(chalk.dim(` Token: ${totalTokens.toLocaleString()} (\u8F93\u5165 ${(meta.totalTokens?.inputTokens || 0).toLocaleString()} + \u8F93\u51FA ${(meta.totalTokens?.outputTokens || 0).toLocaleString()})`));
141
- if (cost) {
142
- console.log(chalk.dim(` \u8D39\u7528: ${formatCost(cost)}`));
143
- }
144
- if (meta.userInputs && Object.keys(meta.userInputs).length > 0) {
145
- console.log(chalk.bold("\n \u8F93\u5165\u53C2\u6570\uFF1A"));
146
- for (const [key, val] of Object.entries(meta.userInputs)) {
147
- console.log(chalk.dim(` ${key}: ${val}`));
148
- }
149
- }
150
- if (meta.stations && meta.stations.length > 0) {
151
- console.log(chalk.bold(`
152
- \u5DE5\u4F4D\u6267\u884C\u8BB0\u5F55 (${meta.stations.length} \u4E2A)\uFF1A
153
- `));
154
- for (const station of meta.stations) {
155
- const stationTokens = (station.tokens?.inputTokens || 0) + (station.tokens?.outputTokens || 0);
156
- console.log(
157
- chalk.blue(` \u{1F4CD} \u5DE5\u4F4D ${station.index}\uFF1A${station.name}`) + chalk.dim(` [${station.agent}]`) + chalk.dim(` ${stationTokens.toLocaleString()} tokens`)
158
- );
159
- if (station.toolCalls && station.toolCalls.length > 0) {
160
- for (const tc of station.toolCalls) {
161
- console.log(chalk.dim(` \u{1F527} ${tc.toolName}`));
162
- }
163
- }
164
- if (station.output) {
165
- const preview = station.output.replace(/\n/g, " ").slice(0, 200);
166
- console.log(chalk.dim(` \u{1F4C4} ${preview}${station.output.length > 200 ? "\u2026" : ""}`));
167
- }
168
- console.log();
169
- }
170
- }
171
- const mdPath = jsonPath.replace(".run.json", ".md");
172
- if (existsSync(mdPath)) {
173
- console.log(chalk.dim(` \u{1F4C4} \u6210\u54C1\u6587\u4EF6\uFF1A${mdPath}`));
174
- }
175
- console.log();
176
- }
177
- export {
178
- historyCommand,
179
- historyViewCommand
180
- };
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
@@ -1,15 +0,0 @@
1
- import {
2
- getCanonicalDashboardPort,
3
- listInstances,
4
- registerInstance,
5
- unregisterInstance,
6
- updateInstanceRuntime
7
- } from "./chunk-LBVHDGZE.js";
8
- import "./chunk-I7WI3BMB.js";
9
- export {
10
- getCanonicalDashboardPort,
11
- listInstances,
12
- registerInstance,
13
- unregisterInstance,
14
- updateInstanceRuntime
15
- };
@@ -1,15 +0,0 @@
1
- import {
2
- getKeyBindings,
3
- keypressToCombo,
4
- listKeyBindings,
5
- loadKeyBindings,
6
- matchKeyBinding
7
- } from "./chunk-O6MG7TOH.js";
8
- import "./chunk-I7WI3BMB.js";
9
- export {
10
- getKeyBindings,
11
- keypressToCombo,
12
- listKeyBindings,
13
- loadKeyBindings,
14
- matchKeyBinding
15
- };