hypercore-cli 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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-D4PUN5BN.js +0 -162
  92. package/dist/auth-UTR4I6QY.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-77FRUHTU.js +0 -271
  98. package/dist/chunk-7ZYMJFCA.js +0 -251
  99. package/dist/chunk-BE46C7JW.js +0 -46
  100. package/dist/chunk-CM423E2U.js +0 -133
  101. package/dist/chunk-E4NKO2KI.js +0 -263
  102. package/dist/chunk-GH7E2OJE.js +0 -223
  103. package/dist/chunk-GMLQ7GZ5.js +0 -134
  104. package/dist/chunk-GU2FZQ6A.js +0 -69
  105. package/dist/chunk-IOPKN5GD.js +0 -190
  106. package/dist/chunk-LWDNLX6B.js +0 -2025
  107. package/dist/chunk-MGLJ53QN.js +0 -219
  108. package/dist/chunk-NHPDLYEW.js +0 -139
  109. package/dist/chunk-OGQGKMDX.js +0 -173
  110. package/dist/chunk-OPZYEVYR.js +0 -150
  111. package/dist/chunk-OWAOKDIN.js +0 -1505
  112. package/dist/chunk-R3GPQC7I.js +0 -393
  113. package/dist/chunk-RKB2JOV2.js +0 -43
  114. package/dist/chunk-RNG3K465.js +0 -80
  115. package/dist/chunk-SHJQMIJL.js +0 -288
  116. package/dist/chunk-SVF2VWOZ.js +0 -145
  117. package/dist/chunk-TGTYKBGC.js +0 -86
  118. package/dist/chunk-V2EBSFPU.js +0 -575
  119. package/dist/chunk-VJDQNNSO.js +0 -681
  120. package/dist/chunk-VQ35XX7B.js +0 -167
  121. package/dist/chunk-WHLVZCQY.js +0 -245
  122. package/dist/chunk-XMGHVNH2.js +0 -66
  123. package/dist/chunk-YWOSOTUO.js +0 -58
  124. package/dist/chunk-ZQRNV2US.js +0 -166
  125. package/dist/chunk-ZSBHUGWR.js +0 -262
  126. package/dist/claude-O5FSOXZC.js +0 -12
  127. package/dist/commands-43PLOWRU.js +0 -128
  128. package/dist/commands-5YVUSUMP.js +0 -232
  129. package/dist/commands-VZMZJFZF.js +0 -1044
  130. package/dist/config-WXXEEEVW.js +0 -8
  131. package/dist/config-loader-SXO674TF.js +0 -24
  132. package/dist/diagnose-BX45APUZ.js +0 -12
  133. package/dist/display-IIUBEYWN.js +0 -58
  134. package/dist/extractor-R5ABXNTJ.js +0 -129
  135. package/dist/history-JPXZEOT3.js +0 -180
  136. package/dist/index.d.ts +0 -1
  137. package/dist/instance-registry-6NJTCAE4.js +0 -15
  138. package/dist/keybindings-ADWNOX5M.js +0 -15
  139. package/dist/loader-AXDDCB2G.js +0 -58
  140. package/dist/network-V3O4UZYZ.js +0 -279
  141. package/dist/notify-HPTALZDC.js +0 -14
  142. package/dist/openai-compat-UFDV2SCK.js +0 -12
  143. package/dist/permissions-JUKXMNDH.js +0 -10
  144. package/dist/prompt-5CZ34WGA.js +0 -166
  145. package/dist/quality-ST7PPNFR.js +0 -16
  146. package/dist/repl-EOWP6AAB.js +0 -3374
  147. package/dist/roadmap-5OBEKROY.js +0 -17
  148. package/dist/server-BB5AENWU.js +0 -57
  149. package/dist/session-5NDKKFLN.js +0 -21
  150. package/dist/skills-JVLIQVJN.js +0 -175
  151. package/dist/store-G7KRD4PN.js +0 -25
  152. package/dist/team-FVNNVDBY.js +0 -385
  153. package/dist/telemetry-6R4EIE6O.js +0 -30
  154. package/dist/test-runner-REKSVPPY.js +0 -619
  155. package/dist/theme-3SYJ3UQA.js +0 -14
  156. package/dist/upgrade-YSXCO63I.js +0 -83
  157. package/dist/verify-JUDKTPKZ.js +0 -14
  158. package/dist/web-H2BJXUBZ.js +0 -39
@@ -1,8 +0,0 @@
1
- import {
2
- HYPERCORE_DIR,
3
- loadConfig
4
- } from "./chunk-SVF2VWOZ.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-SHJQMIJL.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-7ZYMJFCA.js";
7
- import "./chunk-SVF2VWOZ.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-UFDV2SCK.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-O5FSOXZC.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-SVF2VWOZ.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-CM423E2U.js";
8
- import "./chunk-SVF2VWOZ.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-YWOSOTUO.js";
8
- import "./chunk-SVF2VWOZ.js";
9
- export {
10
- getKeyBindings,
11
- keypressToCombo,
12
- listKeyBindings,
13
- loadKeyBindings,
14
- matchKeyBinding
15
- };
@@ -1,58 +0,0 @@
1
- import {
2
- CATEGORY_LABELS,
3
- DEFAULT_EXTRACTION_CONFIG,
4
- loadStore
5
- } from "./chunk-7ZYMJFCA.js";
6
- import "./chunk-SVF2VWOZ.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
- };