@bolloon/bolloon-agent 0.3.44 → 0.3.46

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 (217) hide show
  1. package/README.md +135 -135
  2. package/bin/bolloon-cli.cjs +183 -183
  3. package/bin/bolloon-daemon.sh +207 -0
  4. package/bin/bolloon.cjs +0 -0
  5. package/dist/agents/agent-identity.js +17 -0
  6. package/dist/agents/constraint-layer.js +19 -19
  7. package/dist/agents/judgment-protocol.js +14 -14
  8. package/dist/agents/loop-review.js +21 -5
  9. package/dist/agents/pi-sdk-types.js +12 -12
  10. package/dist/agents/pi-sdk.js +197 -102
  11. package/dist/agents/skill-writer.js +19 -0
  12. package/dist/agents/workflow-pivot-loop.js +3 -3
  13. package/dist/bollharness/src/scripts/deploy-guard.js +8 -8
  14. package/dist/bollharness-integration/context-router-judgment.js +4 -4
  15. package/dist/bollharness-integration/context-router.js +292 -292
  16. package/dist/bollharness-integration/gate-state-machine.js +13 -13
  17. package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
  18. package/dist/bollharness-integration/skill-adapter.js +21 -21
  19. package/dist/bootstrap/chat-archiver.js +14 -14
  20. package/dist/bootstrap/context-os.js +21 -21
  21. package/dist/bootstrap/memory-compressor.js +29 -13
  22. package/dist/cli-entry.js +47 -37
  23. package/dist/constraint-runtime/reference_data/archive_surface_snapshot.json +63 -0
  24. package/dist/constraint-runtime/reference_data/commands_snapshot.json +1037 -0
  25. package/dist/constraint-runtime/reference_data/subsystems/assistant.json +8 -0
  26. package/dist/constraint-runtime/reference_data/subsystems/bootstrap.json +8 -0
  27. package/dist/constraint-runtime/reference_data/subsystems/bridge.json +32 -0
  28. package/dist/constraint-runtime/reference_data/subsystems/buddy.json +13 -0
  29. package/dist/constraint-runtime/reference_data/subsystems/cli.json +26 -0
  30. package/dist/constraint-runtime/reference_data/subsystems/components.json +32 -0
  31. package/dist/constraint-runtime/reference_data/subsystems/constants.json +28 -0
  32. package/dist/constraint-runtime/reference_data/subsystems/coordinator.json +8 -0
  33. package/dist/constraint-runtime/reference_data/subsystems/entrypoints.json +15 -0
  34. package/dist/constraint-runtime/reference_data/subsystems/hooks.json +32 -0
  35. package/dist/constraint-runtime/reference_data/subsystems/keybindings.json +21 -0
  36. package/dist/constraint-runtime/reference_data/subsystems/memdir.json +15 -0
  37. package/dist/constraint-runtime/reference_data/subsystems/migrations.json +18 -0
  38. package/dist/constraint-runtime/reference_data/subsystems/moreright.json +8 -0
  39. package/dist/constraint-runtime/reference_data/subsystems/native_ts.json +11 -0
  40. package/dist/constraint-runtime/reference_data/subsystems/outputStyles.json +8 -0
  41. package/dist/constraint-runtime/reference_data/subsystems/plugins.json +9 -0
  42. package/dist/constraint-runtime/reference_data/subsystems/remote.json +11 -0
  43. package/dist/constraint-runtime/reference_data/subsystems/schemas.json +8 -0
  44. package/dist/constraint-runtime/reference_data/subsystems/screens.json +10 -0
  45. package/dist/constraint-runtime/reference_data/subsystems/server.json +10 -0
  46. package/dist/constraint-runtime/reference_data/subsystems/services.json +32 -0
  47. package/dist/constraint-runtime/reference_data/subsystems/skills.json +27 -0
  48. package/dist/constraint-runtime/reference_data/subsystems/state.json +13 -0
  49. package/dist/constraint-runtime/reference_data/subsystems/types.json +18 -0
  50. package/dist/constraint-runtime/reference_data/subsystems/upstreamproxy.json +9 -0
  51. package/dist/constraint-runtime/reference_data/subsystems/utils.json +32 -0
  52. package/dist/constraint-runtime/reference_data/subsystems/vim.json +12 -0
  53. package/dist/constraint-runtime/reference_data/subsystems/voice.json +8 -0
  54. package/dist/constraint-runtime/reference_data/tools_snapshot.json +922 -0
  55. package/dist/constraint-runtime/setup.js +1 -1
  56. package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.d.ts +13 -3
  57. package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.js +16 -4
  58. package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.d.ts +50 -0
  59. package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.js +78 -0
  60. package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.d.ts +24 -3
  61. package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.js +31 -4
  62. package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.d.ts +1 -0
  63. package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.js +14 -3
  64. package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.d.ts +11 -2
  65. package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.js +23 -4
  66. package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.d.ts +4 -0
  67. package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.js +22 -2
  68. package/dist/context-compaction/auto-compact.js +7 -7
  69. package/dist/electron/config.js.map +1 -0
  70. package/dist/electron/dialogs.js.map +1 -0
  71. package/dist/electron/first-run.js +54 -54
  72. package/dist/electron/first-run.js.map +1 -0
  73. package/dist/electron/ipc.js.map +1 -0
  74. package/dist/electron/logger.js.map +1 -0
  75. package/dist/electron/main.js.map +1 -0
  76. package/dist/electron/menu.js.map +1 -0
  77. package/dist/electron/paths.js.map +1 -0
  78. package/dist/electron/server.js.map +1 -0
  79. package/dist/electron/tray.js.map +1 -0
  80. package/dist/electron/window.js.map +1 -0
  81. package/dist/electron-build/electron/first-run.js +54 -54
  82. package/dist/electron-preload.js.map +1 -1
  83. package/dist/electron.js.map +1 -1
  84. package/dist/index.js +113 -113
  85. package/dist/llm/llm-judgment-client.js +102 -102
  86. package/dist/llm/pi-ai.js +48 -48
  87. package/dist/llm/system-prompt/layers/channel/human-async.md +41 -41
  88. package/dist/llm/system-prompt/layers/channel/local.md +14 -14
  89. package/dist/llm/system-prompt/layers/channel/p2p-agent.md +18 -18
  90. package/dist/llm/system-prompt/layers/channel/p2p-peer-sync.md +51 -51
  91. package/dist/llm/system-prompt/layers/channel/p2p-proactive.md +43 -43
  92. package/dist/llm/system-prompt/layers/channel/p2p-visitor.md +19 -19
  93. package/dist/llm/system-prompt/layers/channel/session-handoff.md +61 -61
  94. package/dist/llm/system-prompt/layers/core/artifacts_storage.md +89 -89
  95. package/dist/llm/system-prompt/layers/core/evenhandedness.md +21 -21
  96. package/dist/llm/system-prompt/layers/core/external-engagement.md +73 -73
  97. package/dist/llm/system-prompt/layers/core/hibs_reminders.md +15 -15
  98. package/dist/llm/system-prompt/layers/core/identity.md +48 -48
  99. package/dist/llm/system-prompt/layers/core/knowledge.md +17 -17
  100. package/dist/llm/system-prompt/layers/core/memory_system.md +12 -12
  101. package/dist/llm/system-prompt/layers/core/network_filesystem.md +28 -28
  102. package/dist/llm/system-prompt/layers/core/refusal.md +37 -37
  103. package/dist/llm/system-prompt/layers/core/tone.md +31 -31
  104. package/dist/llm/system-prompt/layers/core/tools.thin.md +13 -13
  105. package/dist/llm/system-prompt/layers/core/wellbeing.md +41 -41
  106. package/dist/llm/system-prompt/layers/role/architect.md +20 -20
  107. package/dist/llm/system-prompt/layers/role/expert.md +19 -19
  108. package/dist/llm/system-prompt/layers/role/implementer.md +15 -15
  109. package/dist/llm/system-prompt/layers/role/security.md +15 -15
  110. package/dist/llm/system-prompt/layers/tool/artifacts.md +72 -72
  111. package/dist/llm/system-prompt/layers/tool/bash.md +25 -25
  112. package/dist/llm/system-prompt/layers/tool/goal_handoff.md +77 -77
  113. package/dist/llm/system-prompt/layers/tool/hibs_api.md +171 -171
  114. package/dist/llm/system-prompt/layers/tool/image_search.md +70 -70
  115. package/dist/llm/system-prompt/layers/tool/manifest.md +89 -89
  116. package/dist/llm/system-prompt/layers/tool/mcp_apps.md +53 -53
  117. package/dist/llm/system-prompt/layers/tool/p2p_request.md +61 -61
  118. package/dist/llm/system-prompt/layers/tool/web_search.md +83 -83
  119. package/dist/llm/tool-manifest/ask_user_input.js +1 -1
  120. package/dist/llm/tool-manifest/bash.js +3 -3
  121. package/dist/llm/tool-manifest/create_file.js +4 -4
  122. package/dist/llm/tool-manifest/fetch_sports_data.js +3 -3
  123. package/dist/llm/tool-manifest/image_search.js +2 -2
  124. package/dist/llm/tool-manifest/index.js +59 -0
  125. package/dist/llm/tool-manifest/mcp.js +2 -2
  126. package/dist/llm/tool-manifest/message_compose.js +3 -3
  127. package/dist/llm/tool-manifest/places.js +2 -2
  128. package/dist/llm/tool-manifest/present_files.js +1 -1
  129. package/dist/llm/tool-manifest/recipe.js +2 -2
  130. package/dist/llm/tool-manifest/str_replace.js +5 -5
  131. package/dist/llm/tool-manifest/view.js +3 -3
  132. package/dist/llm/tool-manifest/weather.js +4 -4
  133. package/dist/llm/tool-manifest/web.js +4 -4
  134. package/dist/orbitdb/cid-database.js +41 -0
  135. package/dist/orbitdb/did-catalog-replication.js +199 -0
  136. package/dist/orbitdb/trajectory-store.js +150 -0
  137. package/dist/pi-ecosystem-judgment/causal-judge.js +51 -51
  138. package/dist/pi-ecosystem-judgment/distill-prompt.js +42 -42
  139. package/dist/pi-ecosystem-judgment/distillation.js +14 -14
  140. package/dist/pi-ecosystem-judgment/monitor-gate.js +28 -28
  141. package/dist/pi-ecosystem-judgment/value-injection.js +102 -102
  142. package/dist/security/context-router-tool.js +15 -15
  143. package/dist/storage/did-catalog-bridge.js +271 -0
  144. package/dist/utils/auto-update.js.map +1 -0
  145. package/dist/web/api-config.html +779 -779
  146. package/dist/web/client-hearth.js +10 -10
  147. package/dist/web/client.js +141 -0
  148. package/dist/web/client.js.map +7 -0
  149. package/dist/web/components/wallet-viem.mjs +118 -118
  150. package/dist/web/index.html +472 -424
  151. package/dist/web/manifest.json +20 -20
  152. package/dist/web/server.js +290 -13
  153. package/dist/web/style.css +4946 -4914
  154. package/package.json +193 -193
  155. package/scripts/build-cli.js +215 -215
  156. package/scripts/build-web.ts +130 -130
  157. package/scripts/postinstall.js +152 -152
  158. package/bin/bolloon.js +0 -157
  159. package/dist/pi-ecosystem-colony/index.js +0 -365
  160. package/dist/social/ant-colony/AdaptiveHeartbeat.js +0 -101
  161. package/dist/social/ant-colony/PheromoneEngine.js +0 -227
  162. package/dist/social/ant-colony/index.js +0 -6
  163. package/dist/social/ant-colony/types.js +0 -24
  164. package/dist/test/ai-judgment-test.js +0 -80
  165. package/dist/test/bollharness-integration.test.js +0 -318
  166. package/dist/test/channel-agent-multi-dialogue.js +0 -205
  167. package/dist/test/channel-heartbeat-agent-test.js +0 -201
  168. package/dist/test/constraint-layer.test.js +0 -164
  169. package/dist/test/diap-identity-test.js +0 -172
  170. package/dist/test/diap-quick-test.js +0 -62
  171. package/dist/test/global-shared-context.test.js +0 -315
  172. package/dist/test/harness-judgment-injection.test.js +0 -246
  173. package/dist/test/harness-workflow-integrator-test.js +0 -228
  174. package/dist/test/human-value-store.test.js +0 -243
  175. package/dist/test/hybrid-integration-test.js +0 -118
  176. package/dist/test/hybrid-messenger-verify.js +0 -55
  177. package/dist/test/iroh-bistream-debug.js +0 -38
  178. package/dist/test/iroh-communication.test.js +0 -66
  179. package/dist/test/iroh-debug-test.js +0 -57
  180. package/dist/test/iroh-diap-test.js +0 -71
  181. package/dist/test/iroh-direct-connect.js +0 -55
  182. package/dist/test/iroh-e2e-fixed.js +0 -89
  183. package/dist/test/iroh-e2e-same-process.js +0 -63
  184. package/dist/test/iroh-e2e.js +0 -66
  185. package/dist/test/iroh-final-e2e.js +0 -72
  186. package/dist/test/iroh-relay-test.js +0 -37
  187. package/dist/test/iroh-simple-test.js +0 -41
  188. package/dist/test/iroh-transport-verify.js +0 -54
  189. package/dist/test/iroh-transport.test.js +0 -37
  190. package/dist/test/iroh-two-nodes.js +0 -70
  191. package/dist/test/iroh-verify.js +0 -44
  192. package/dist/test/judgment-decision.test.js +0 -219
  193. package/dist/test/llm-judgment-integration.test.js +0 -220
  194. package/dist/test/p2p-agent-complex-dialogue.js +0 -385
  195. package/dist/test/p2p-agent-dialogue.js +0 -341
  196. package/dist/test/p2p-agent-full-bidirectional.js +0 -510
  197. package/dist/test/p2p-agent-harness-flow.js +0 -437
  198. package/dist/test/p2p-agent-harness-single.js +0 -143
  199. package/dist/test/p2p-ai-dialogue-test.js +0 -318
  200. package/dist/test/p2p-cid-connect-test.js +0 -195
  201. package/dist/test/p2p-connect-receiver.js +0 -69
  202. package/dist/test/p2p-doc-transfer.js +0 -110
  203. package/dist/test/p2p-identity-page-test.js +0 -77
  204. package/dist/test/p2p-iroh-test.js +0 -171
  205. package/dist/test/p2p-minimal-test.js +0 -241
  206. package/dist/test/p2p-node-1.js +0 -148
  207. package/dist/test/p2p-node-2.js +0 -148
  208. package/dist/test/p2p-server.js +0 -281
  209. package/dist/test/p2p-two-nodes-test.js +0 -438
  210. package/dist/test/pi-sdk.test.js +0 -44
  211. package/dist/test/set-persona.js +0 -40
  212. package/dist/test/simple.test.js +0 -9
  213. package/dist/test/storage-integration.test.js +0 -150
  214. package/dist/test/subagent-manager.test.js +0 -276
  215. package/dist/test/test-gate-flow.test.js +0 -81
  216. package/dist/test/workflow-engine.test.js +0 -87
  217. package/dist/test/workflow-pivot-loop.test.js +0 -246
@@ -19,101 +19,101 @@ import { getPiSDKConfig } from '../llm/config-store.js';
19
19
  /**
20
20
  * 判断用的 Prompt 模板(可以从 YAML 加载)
21
21
  */
22
- export const JUDGMENT_PROMPT_TEMPLATE = `你是一个专业的 AI 任务分析专家。你的职责是深入理解用户的问题,并给出精准的判断。
23
-
24
- 【输入】
25
- {user_input}
26
-
27
- 【历史上下文】
28
- {history_context}
29
-
30
- 请分析以上输入,回答以下问题:
31
-
32
- ## 1. 问题理解
33
-
34
- **问题本质**:用户真正想要什么?这是什么类型的问题?
35
- - how-to: 寻求操作指导
36
- - why: 寻求解释
37
- - what: 寻求定义
38
- - should: 寻求建议
39
- - feasibility: 寻求可行性评估
40
-
41
- **核心需求**:用户最想要的结果是什么?
42
-
43
- **隐含信息**:有什么用户没有明确说但需要考虑的因素?
44
- - 时间压力?
45
- - 质量要求?
46
- - 风险限制?
47
- - 团队协作?
48
-
49
- ## 2. 复杂性评估
50
-
51
- **复杂性等级**:这个问题有多复杂?
52
- - simple: 简单任务,直接可答
53
- - moderate: 中等复杂,需要一定思考
54
- - complex: 复杂问题,需要深入分析
55
- - profound: 深刻问题,需要本质性思考
56
-
57
- **评估理由**:为什么认为这是这个复杂性等级?
58
-
59
- **深度**:需要多深的理解?
60
- - surface: 表面理解即可
61
- - deeper: 需要分析
62
- - fundamental: 需要本质性思考
63
-
64
- ## 3. 处理决策
65
-
66
- **推荐方式**:
67
- - answer: 直接回答
68
- - analyze: 深入分析
69
- - design: 设计方案
70
- - implement: 实现代码
71
- - coordinate: 协调多智能体
72
-
73
- **决策理由**:为什么推荐这个处理方式?
74
-
75
- ## 4. 路由决策
76
-
77
- **应该调用的 Skills**(可选多个):
78
- - arch: 架构设计
79
- - harness-dev: 开发实现
80
- - guardian-fixer: 代码审查
81
- - harness-eng: 工程协调
82
- - harness-eng-test: 测试工程
83
- - task-arch: 任务分解
84
- - crystal-learn: 反思学习
85
-
86
- **参与智能体**(可选):
87
- - architect: 架构师
88
- - developer: 开发者
89
- - reviewer: 审查员
90
- - coordinator: 协调者
91
-
92
- **协作模式**:
93
- - solo: 单独处理
94
- - pair: 配对协作
95
- - team: 团队协作
96
-
97
- ## 5. 产出要求
98
-
99
- **需要的产物**:
100
- - 问题分析
101
- - 方案设计
102
- - 代码实现
103
- - 测试用例
104
- - 其他
105
-
106
- **Gate 建议**(如果有):
107
- - Gate 0: 问题锁定
108
- - Gate 1: 架构设计
109
- - Gate 2: 架构审查
110
- - Gate 3: 计划制定
111
- - Gate 4: 计划审查
112
- - Gate 5: 任务分解
113
- - Gate 6: 任务审查
114
- - Gate 7: 代码实现
115
- - Gate 8: 测试验证
116
-
22
+ export const JUDGMENT_PROMPT_TEMPLATE = `你是一个专业的 AI 任务分析专家。你的职责是深入理解用户的问题,并给出精准的判断。
23
+
24
+ 【输入】
25
+ {user_input}
26
+
27
+ 【历史上下文】
28
+ {history_context}
29
+
30
+ 请分析以上输入,回答以下问题:
31
+
32
+ ## 1. 问题理解
33
+
34
+ **问题本质**:用户真正想要什么?这是什么类型的问题?
35
+ - how-to: 寻求操作指导
36
+ - why: 寻求解释
37
+ - what: 寻求定义
38
+ - should: 寻求建议
39
+ - feasibility: 寻求可行性评估
40
+
41
+ **核心需求**:用户最想要的结果是什么?
42
+
43
+ **隐含信息**:有什么用户没有明确说但需要考虑的因素?
44
+ - 时间压力?
45
+ - 质量要求?
46
+ - 风险限制?
47
+ - 团队协作?
48
+
49
+ ## 2. 复杂性评估
50
+
51
+ **复杂性等级**:这个问题有多复杂?
52
+ - simple: 简单任务,直接可答
53
+ - moderate: 中等复杂,需要一定思考
54
+ - complex: 复杂问题,需要深入分析
55
+ - profound: 深刻问题,需要本质性思考
56
+
57
+ **评估理由**:为什么认为这是这个复杂性等级?
58
+
59
+ **深度**:需要多深的理解?
60
+ - surface: 表面理解即可
61
+ - deeper: 需要分析
62
+ - fundamental: 需要本质性思考
63
+
64
+ ## 3. 处理决策
65
+
66
+ **推荐方式**:
67
+ - answer: 直接回答
68
+ - analyze: 深入分析
69
+ - design: 设计方案
70
+ - implement: 实现代码
71
+ - coordinate: 协调多智能体
72
+
73
+ **决策理由**:为什么推荐这个处理方式?
74
+
75
+ ## 4. 路由决策
76
+
77
+ **应该调用的 Skills**(可选多个):
78
+ - arch: 架构设计
79
+ - harness-dev: 开发实现
80
+ - guardian-fixer: 代码审查
81
+ - harness-eng: 工程协调
82
+ - harness-eng-test: 测试工程
83
+ - task-arch: 任务分解
84
+ - crystal-learn: 反思学习
85
+
86
+ **参与智能体**(可选):
87
+ - architect: 架构师
88
+ - developer: 开发者
89
+ - reviewer: 审查员
90
+ - coordinator: 协调者
91
+
92
+ **协作模式**:
93
+ - solo: 单独处理
94
+ - pair: 配对协作
95
+ - team: 团队协作
96
+
97
+ ## 5. 产出要求
98
+
99
+ **需要的产物**:
100
+ - 问题分析
101
+ - 方案设计
102
+ - 代码实现
103
+ - 测试用例
104
+ - 其他
105
+
106
+ **Gate 建议**(如果有):
107
+ - Gate 0: 问题锁定
108
+ - Gate 1: 架构设计
109
+ - Gate 2: 架构审查
110
+ - Gate 3: 计划制定
111
+ - Gate 4: 计划审查
112
+ - Gate 5: 任务分解
113
+ - Gate 6: 任务审查
114
+ - Gate 7: 代码实现
115
+ - Gate 8: 测试验证
116
+
117
117
  请用 JSON 格式输出分析结果。`;
118
118
  /**
119
119
  * LLM-native Judgment Engine
@@ -434,20 +434,20 @@ export const SKILL_PROMPTS = {
434
434
  arch: {
435
435
  name: 'arch',
436
436
  description: '架构设计专家',
437
- systemPrompt: `你是一个经验丰富的系统架构师。你擅长:
438
- - 从需求中提取本质问题
439
- - 设计可扩展的系统架构
440
- - 权衡技术方案
441
- - 识别架构风险
442
-
443
- 你相信:
444
- - 本质和实现必须分离
445
- - 好的架构从简单规则中生长
437
+ systemPrompt: `你是一个经验丰富的系统架构师。你擅长:
438
+ - 从需求中提取本质问题
439
+ - 设计可扩展的系统架构
440
+ - 权衡技术方案
441
+ - 识别架构风险
442
+
443
+ 你相信:
444
+ - 本质和实现必须分离
445
+ - 好的架构从简单规则中生长
446
446
  - 复杂性应该被控制而非消除`,
447
- userPromptTemplate: `用户需求:{user_input}
448
-
449
- {context}
450
-
447
+ userPromptTemplate: `用户需求:{user_input}
448
+
449
+ {context}
450
+
451
451
  请进行架构分析:`,
452
452
  examples: [
453
453
  {
@@ -460,40 +460,40 @@ export const SKILL_PROMPTS = {
460
460
  'harness-dev': {
461
461
  name: 'harness-dev',
462
462
  description: '开发实现专家',
463
- systemPrompt: `你是一个高效的代码实现专家。你擅长:
464
- - 快速理解和实现需求
465
- - 编写清晰、可维护的代码
466
- - 遵循最佳实践
467
- - 处理边界情况
468
-
469
- 你相信:
470
- - 代码即文档
471
- - 测试是代码的一部分
463
+ systemPrompt: `你是一个高效的代码实现专家。你擅长:
464
+ - 快速理解和实现需求
465
+ - 编写清晰、可维护的代码
466
+ - 遵循最佳实践
467
+ - 处理边界情况
468
+
469
+ 你相信:
470
+ - 代码即文档
471
+ - 测试是代码的一部分
472
472
  - 简单优于复杂`,
473
- userPromptTemplate: `任务:{user_input}
474
-
475
- 技术栈:{tech_stack}
476
-
473
+ userPromptTemplate: `任务:{user_input}
474
+
475
+ 技术栈:{tech_stack}
476
+
477
477
  请实现代码:`,
478
478
  outputFormat: 'code'
479
479
  },
480
480
  'guardian-fixer': {
481
481
  name: 'guardian-fixer',
482
482
  description: '代码审查专家',
483
- systemPrompt: `你是一个严格的代码审查专家。你擅长:
484
- - 发现潜在问题
485
- - 提出改进建议
486
- - 确保代码质量
487
- - 平衡效率和安全性
488
-
489
- 你相信:
490
- - 细节决定成败
491
- - 代码审查是质量保障的最后防线
483
+ systemPrompt: `你是一个严格的代码审查专家。你擅长:
484
+ - 发现潜在问题
485
+ - 提出改进建议
486
+ - 确保代码质量
487
+ - 平衡效率和安全性
488
+
489
+ 你相信:
490
+ - 细节决定成败
491
+ - 代码审查是质量保障的最后防线
492
492
  - 建设性批评比否定更有价值`,
493
- userPromptTemplate: `代码:\n{code}
494
-
495
- 审查范围:{scope}
496
-
493
+ userPromptTemplate: `代码:\n{code}
494
+
495
+ 审查范围:{scope}
496
+
497
497
  请进行审查:`,
498
498
  outputFormat: 'structured'
499
499
  }
@@ -377,16 +377,16 @@ export class PeerSyncSkill extends BaseSkill {
377
377
  }
378
378
  this.log(`peer-sync 启动: target_id=${targetId}`);
379
379
  // 选 peer 的策略由 LLM 决定 (根据 list_peers 输出 + expertise tag)
380
- return this.callLm(`You are a peer-selection specialist for the bolloon P2P network.
381
- Given a target_id and task description, output structured JSON with:
382
- - selectedPeer: DID of the best peer (or null if none suitable)
383
- - channelName: human-readable name for the new channel
384
- - initialMessage: first message to send (≤ 200 chars, brief + asks for acceptance)
385
- - estimatedRounds: expected back-and-forth count (1-10)
386
-
387
- Rules:
388
- - Prefer peers with matching expertise tag
389
- - If no peer matches, return selectedPeer: null
380
+ return this.callLm(`You are a peer-selection specialist for the bolloon P2P network.
381
+ Given a target_id and task description, output structured JSON with:
382
+ - selectedPeer: DID of the best peer (or null if none suitable)
383
+ - channelName: human-readable name for the new channel
384
+ - initialMessage: first message to send (≤ 200 chars, brief + asks for acceptance)
385
+ - estimatedRounds: expected back-and-forth count (1-10)
386
+
387
+ Rules:
388
+ - Prefer peers with matching expertise tag
389
+ - If no peer matches, return selectedPeer: null
390
390
  - Don't over-explain — peer agent has same identity layer as you`, `target_id: ${targetId}\ntask: ${task}`);
391
391
  }
392
392
  }
@@ -412,17 +412,17 @@ export class HabitDistillSkill extends BaseSkill {
412
412
  }
413
413
  this.log(`habit-distill 启动: session=${sessionKey}`);
414
414
  // 抽取习性的 prompt — 让 LLM 输出结构化 JSON
415
- return this.callLm(`You are a habit-extraction specialist.
416
- Given a summary of user-assistant interaction, output JSON with:
417
- - habits: [{ content: string, tags: string[], weight: 'low'|'medium'|'high' }]
418
- - content: 一个用户偏好/习性的简短描述 (≤ 100 字)
419
- - tags: 标签如 ['input-style', 'terminology', 'recurring-topic', 'correction']
420
- - weight: 影响判断力注入门时的优先级
421
- - skipReason: 若不该蒸馏 (用户拒绝/任务太简单/judgment 库饱和), 填理由
422
-
423
- Rules:
424
- - 习性必须是"用户可观察到的稳定模式", 不是单次偏好
425
- - 隐私相关打 tags 含 'private', 注入门自动过滤
415
+ return this.callLm(`You are a habit-extraction specialist.
416
+ Given a summary of user-assistant interaction, output JSON with:
417
+ - habits: [{ content: string, tags: string[], weight: 'low'|'medium'|'high' }]
418
+ - content: 一个用户偏好/习性的简短描述 (≤ 100 字)
419
+ - tags: 标签如 ['input-style', 'terminology', 'recurring-topic', 'correction']
420
+ - weight: 影响判断力注入门时的优先级
421
+ - skipReason: 若不该蒸馏 (用户拒绝/任务太简单/judgment 库饱和), 填理由
422
+
423
+ Rules:
424
+ - 习性必须是"用户可观察到的稳定模式", 不是单次偏好
425
+ - 隐私相关打 tags 含 'private', 注入门自动过滤
426
426
  - 不要重复已有 judgment (调用方负责查重)`, `Session: ${sessionKey}\nMessages summary: ${recentMessagesSummary || '(caller should pass loadMessages output)'}`);
427
427
  }
428
428
  }
@@ -117,20 +117,20 @@ function templateMonthlySummary(opts) {
117
117
  const channelSet = new Set(opts.entries.map(e => e.channelName).filter(Boolean));
118
118
  const sampleUser = user.slice(0, 5).map(e => ` - [${e.ts}] ${e.text.slice(0, 80)}`).join('\n');
119
119
  const sampleAi = ai.slice(0, 5).map(e => ` - [${e.ts}] ${e.text.slice(0, 80)}`).join('\n');
120
- return `# 月度对话摘要 — ${opts.yearMonth} (peer ${opts.publicKey.slice(0, 12)}…)
121
-
122
- 时间: ${opts.timestamp}
123
- 对话轮次: ${opts.entries.length} (user=${user.length}, ai=${ai.length})
124
- 涉及 channel: ${Array.from(channelSet).slice(0, 10).join(', ') || '(无)'}
125
-
126
- ## 用户关键提问
127
- ${sampleUser || ' (无)'}
128
-
129
- ## AI 关键回答
130
- ${sampleAi || ' (无)'}
131
-
132
- ## 备注
133
- - 此摘要由模板生成 (LLM 调用失败 fallback)
120
+ return `# 月度对话摘要 — ${opts.yearMonth} (peer ${opts.publicKey.slice(0, 12)}…)
121
+
122
+ 时间: ${opts.timestamp}
123
+ 对话轮次: ${opts.entries.length} (user=${user.length}, ai=${ai.length})
124
+ 涉及 channel: ${Array.from(channelSet).slice(0, 10).join(', ') || '(无)'}
125
+
126
+ ## 用户关键提问
127
+ ${sampleUser || ' (无)'}
128
+
129
+ ## AI 关键回答
130
+ ${sampleAi || ' (无)'}
131
+
132
+ ## 备注
133
+ - 此摘要由模板生成 (LLM 调用失败 fallback)
134
134
  `;
135
135
  }
136
136
  /**
@@ -63,27 +63,27 @@ function slugify(s) {
63
63
  // 初始化: 建目录 + 每层 README (幂等)
64
64
  // ============================================================
65
65
  function layerReadme(l) {
66
- return `# ${l.key} — ${l.name}
67
-
68
- ## 这一层回答的问题
69
- ${l.name}
70
-
71
- ## 存什么
72
- ${l.store}
73
-
74
- ## 不该存什么
75
- ${l.notStore}
76
-
77
- ## 典型用途
78
- ${l.usage}
79
-
80
- ## 价值判断标准 (Context OS §5)
81
- 写入前先回答: **未来哪个具体场景会用到它?**
82
- 回答不出 = 噪音, 留在 tmp/, 不进正式层.
83
-
84
- ## 价值生命周期
85
- 阶段0 临时价值点 (对话中刚出现, 未验证) → 阶段1 验证 (被使用/确认)
86
- → 阶段2 固化 (本层唯一位置) → 阶段3 索引化 (高频引用) → 阶段4 归档/删除.
66
+ return `# ${l.key} — ${l.name}
67
+
68
+ ## 这一层回答的问题
69
+ ${l.name}
70
+
71
+ ## 存什么
72
+ ${l.store}
73
+
74
+ ## 不该存什么
75
+ ${l.notStore}
76
+
77
+ ## 典型用途
78
+ ${l.usage}
79
+
80
+ ## 价值判断标准 (Context OS §5)
81
+ 写入前先回答: **未来哪个具体场景会用到它?**
82
+ 回答不出 = 噪音, 留在 tmp/, 不进正式层.
83
+
84
+ ## 价值生命周期
85
+ 阶段0 临时价值点 (对话中刚出现, 未验证) → 阶段1 验证 (被使用/确认)
86
+ → 阶段2 固化 (本层唯一位置) → 阶段3 索引化 (高频引用) → 阶段4 归档/删除.
87
87
  `;
88
88
  }
89
89
  export async function ensureContextOsDirs(home) {
@@ -94,19 +94,19 @@ function templateSummary(opts) {
94
94
  const aiMsgs = opts.newMessages.filter(m => m.type === 'ai');
95
95
  const userSnippet = userMsgs.slice(0, 3).map(m => ` - ${m.content.slice(0, 80)}`).join('\n');
96
96
  const aiSnippet = aiMsgs.slice(0, 3).map(m => ` - ${m.content.slice(0, 80)}`).join('\n');
97
- return `# Session 摘要 — ${opts.channelId} / ${opts.sessionId}
98
-
99
- 时间: ${opts.timestamp}
100
- 新增消息数: ${opts.newMessages.length} (user=${userMsgs.length}, ai=${aiMsgs.length})
101
-
102
- ## 用户关键提问
103
- ${userSnippet || ' (无)'}
104
-
105
- ## AI 关键回答
106
- ${aiSnippet || ' (无)'}
107
-
108
- ## 备注
109
- - 此摘要由模板生成 (LLM 调用失败 fallback)
97
+ return `# Session 摘要 — ${opts.channelId} / ${opts.sessionId}
98
+
99
+ 时间: ${opts.timestamp}
100
+ 新增消息数: ${opts.newMessages.length} (user=${userMsgs.length}, ai=${aiMsgs.length})
101
+
102
+ ## 用户关键提问
103
+ ${userSnippet || ' (无)'}
104
+
105
+ ## AI 关键回答
106
+ ${aiSnippet || ' (无)'}
107
+
108
+ ## 备注
109
+ - 此摘要由模板生成 (LLM 调用失败 fallback)
110
110
  `;
111
111
  }
112
112
  /**
@@ -172,6 +172,22 @@ export async function compressSessionToMemory(opts) {
172
172
  await fs.mkdir(path.dirname(summaryPath), { recursive: true });
173
173
  await fs.appendFile(summaryPath, block, 'utf-8');
174
174
  await writeCursor(cursorPath, allMessages.length);
175
+ // 2026-08-08 (DID 目录写穿): 摘要同步进 DID 目录 memory 表 — WAL 事件 → 多设备同步/OrbitDB 复制.
176
+ // 失败静默: 目录不可用不影响原磁盘写入.
177
+ try {
178
+ const { catalogUpsertQuiet } = await import('../storage/did-catalog-bridge.js');
179
+ await catalogUpsertQuiet('memory', `sessions/${agentId}/${path.basename(summaryPath)}`, {
180
+ agentId,
181
+ channelId: opts.channelId,
182
+ sessionId: opts.sessionId,
183
+ kind: 'summary',
184
+ file: path.basename(summaryPath),
185
+ summary: summaryBody.slice(0, 4000),
186
+ size: summaryBody.length,
187
+ updatedAt: Date.now(),
188
+ }, { home: opts.home });
189
+ }
190
+ catch { /* 静默 */ }
175
191
  // 2026-08-03 (Context OS P4): 价值点分类路由 — 把摘要里的 decision/lesson/knowledge/insight
176
192
  // 自动写入 human-values + judgeness (Context OS §6 对话收尾: 价值不流失).
177
193
  // 失败静默, 不阻塞主对话. 幂等: 相同 decision 文本跳过.
package/dist/cli-entry.js CHANGED
@@ -50,42 +50,42 @@ function printBannerCli() {
50
50
  printBanner(VERSION);
51
51
  }
52
52
  function printHelp() {
53
- console.log(`
54
- ${BOLD}用法:${RESET}
55
- bolloon [选项] [命令] [参数]
56
-
57
- ${BOLD}选项:${RESET}
58
- --gui, -g 启动图形界面 (Electron)
59
- --web, -w 启动 Web UI (浏览器)
60
- --cli, -c 启动命令行界面
61
- --version, -v 显示版本信息
62
- --help, -h 显示帮助信息
63
-
64
- ${BOLD}命令:${RESET}
65
- bolloon update [--now] 检查更新 / 立即更新 (bolloon update --now)
66
- bolloon model [name] [model] 列出 / 切换模型供应商 (如: bolloon model deepseek deepseek-v4-flash)
67
- bolloon read <file> 读取文档
68
- bolloon summarize <file> 总结文档
69
- bolloon improve <file> <req> 改进文档
70
- bolloon engine list 列出外部编码智能体
71
- bolloon engine run <prompt> 委派任务给智能体
72
- bolloon x402 fetch <url> x402 自动支付 HTTP 请求
73
- bolloon x402 balance <address> 查询 x402 钱包余额
74
-
75
- ${BOLD}示例:${RESET}
76
- bolloon # 启动图形界面
77
- bolloon --web # 启动 Web UI
78
- bolloon --cli # 命令行模式
79
- bolloon model # 查看当前模型供应商
80
- bolloon model minimax # 切换到 MiniMax
81
- bolloon update # 检查更新
82
- bolloon update --now # 立即更新
83
-
84
- ${BOLD}环境变量:${RESET}
85
- MINIMAX_API_KEY MiniMax API 密钥
86
- OPENAI_API_KEY OpenAI API 密钥
87
- ANTHROPIC_API_KEY Anthropic API 密钥
88
- PORT Web 服务端口 (默认 54188)
53
+ console.log(`
54
+ ${BOLD}用法:${RESET}
55
+ bolloon [选项] [命令] [参数]
56
+
57
+ ${BOLD}选项:${RESET}
58
+ --gui, -g 启动图形界面 (Electron)
59
+ --web, -w 启动 Web UI (浏览器)
60
+ --cli, -c 启动命令行界面
61
+ --version, -v 显示版本信息
62
+ --help, -h 显示帮助信息
63
+
64
+ ${BOLD}命令:${RESET}
65
+ bolloon update [--now] 检查更新 / 立即更新 (bolloon update --now)
66
+ bolloon model [name] [model] 列出 / 切换模型供应商 (如: bolloon model deepseek deepseek-v4-flash)
67
+ bolloon read <file> 读取文档
68
+ bolloon summarize <file> 总结文档
69
+ bolloon improve <file> <req> 改进文档
70
+ bolloon engine list 列出外部编码智能体
71
+ bolloon engine run <prompt> 委派任务给智能体
72
+ bolloon x402 fetch <url> x402 自动支付 HTTP 请求
73
+ bolloon x402 balance <address> 查询 x402 钱包余额
74
+
75
+ ${BOLD}示例:${RESET}
76
+ bolloon # 启动图形界面
77
+ bolloon --web # 启动 Web UI
78
+ bolloon --cli # 命令行模式
79
+ bolloon model # 查看当前模型供应商
80
+ bolloon model minimax # 切换到 MiniMax
81
+ bolloon update # 检查更新
82
+ bolloon update --now # 立即更新
83
+
84
+ ${BOLD}环境变量:${RESET}
85
+ MINIMAX_API_KEY MiniMax API 密钥
86
+ OPENAI_API_KEY OpenAI API 密钥
87
+ ANTHROPIC_API_KEY Anthropic API 密钥
88
+ PORT Web 服务端口 (默认 54188)
89
89
  `);
90
90
  }
91
91
  function getDistDir() {
@@ -111,11 +111,13 @@ function getMainScript() {
111
111
  }
112
112
  function getElectronPath() {
113
113
  // ESM 兼容: use _require (createRequire) instead of raw require
114
+ // 2026-08-09: electron 在 devDependencies, 全局安装不装 → require 失败返回 null
115
+ // (上层 startElectron 收到 null 后降级为 Web 模式, 不再返回裸字符串 'electron' 导致 ENOENT)
114
116
  try {
115
117
  return _require('electron');
116
118
  }
117
119
  catch {
118
- return 'electron';
120
+ return null;
119
121
  }
120
122
  }
121
123
  // 解析命令行参数
@@ -466,6 +468,14 @@ async function runNodeScript(scriptPath, additionalArgs) {
466
468
  // 启动 Electron
467
469
  async function startElectron(additionalArgs) {
468
470
  const electronPath = getElectronPath();
471
+ // 2026-08-09: electron 是 devDependency, 全局安装不包含 → 降级为 Web 模式
472
+ // (浏览器打开 Web UI, 功能等价, 避免 spawn electron ENOENT 直接退出)
473
+ if (!electronPath) {
474
+ log('未检测到 Electron 桌面运行时 (全局安装不含 devDependencies)', YELLOW);
475
+ log('自动降级为 Web 模式 — 浏览器打开 Web UI...', CYAN);
476
+ await startWebServer(additionalArgs);
477
+ return;
478
+ }
469
479
  const distDir = getDistDir();
470
480
  // 确定主进程入口
471
481
  let mainPath = path.join(distDir, 'electron.js');
@@ -0,0 +1,63 @@
1
+ {
2
+ "archive_root": "archive/claude_code_ts_snapshot/src",
3
+ "root_files": [
4
+ "QueryEngine.ts",
5
+ "Task.ts",
6
+ "Tool.ts",
7
+ "commands.ts",
8
+ "context.ts",
9
+ "cost-tracker.ts",
10
+ "costHook.ts",
11
+ "dialogLaunchers.tsx",
12
+ "history.ts",
13
+ "ink.ts",
14
+ "interactiveHelpers.tsx",
15
+ "main.tsx",
16
+ "projectOnboardingState.ts",
17
+ "query.ts",
18
+ "replLauncher.tsx",
19
+ "setup.ts",
20
+ "tasks.ts",
21
+ "tools.ts"
22
+ ],
23
+ "root_dirs": [
24
+ "assistant",
25
+ "bootstrap",
26
+ "bridge",
27
+ "buddy",
28
+ "cli",
29
+ "commands",
30
+ "components",
31
+ "constants",
32
+ "context",
33
+ "coordinator",
34
+ "entrypoints",
35
+ "hooks",
36
+ "ink",
37
+ "keybindings",
38
+ "memdir",
39
+ "migrations",
40
+ "moreright",
41
+ "native-ts",
42
+ "outputStyles",
43
+ "plugins",
44
+ "query",
45
+ "remote",
46
+ "schemas",
47
+ "screens",
48
+ "server",
49
+ "services",
50
+ "skills",
51
+ "state",
52
+ "tasks",
53
+ "tools",
54
+ "types",
55
+ "upstreamproxy",
56
+ "utils",
57
+ "vim",
58
+ "voice"
59
+ ],
60
+ "total_ts_like_files": 1902,
61
+ "command_entry_count": 207,
62
+ "tool_entry_count": 184
63
+ }