@bolloon/bolloon-agent 0.2.12 → 0.2.13

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 (284) hide show
  1. package/README.md +495 -467
  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/bin/ipfs +0 -0
  6. package/dist/agents/agent-manifest-protocol.js +52 -0
  7. package/dist/agents/chat-segmenter.js +298 -0
  8. package/dist/agents/constraint-layer.js +19 -19
  9. package/dist/agents/judgment-protocol.js +479 -0
  10. package/dist/agents/parse-tool-call.js +304 -0
  11. package/dist/agents/peer-manifest-loader.js +210 -0
  12. package/dist/agents/pi-sdk-session-factory.js +110 -0
  13. package/dist/agents/pi-sdk-session-manager.js +297 -0
  14. package/dist/agents/pi-sdk-tools.js +1288 -0
  15. package/dist/agents/pi-sdk-types.js +13 -0
  16. package/dist/agents/pi-sdk.js +553 -1306
  17. package/dist/agents/react-loop.js +120 -0
  18. package/dist/agents/session-store.js +171 -0
  19. package/dist/agents/shell-guard.js +2 -2
  20. package/dist/agents/tool-registry.js +136 -0
  21. package/dist/agents/workflow-pivot-loop.js +200 -22
  22. package/dist/bollharness/src/scripts/context_router.js +7 -0
  23. package/dist/bollharness/src/scripts/deploy-guard.js +8 -8
  24. package/dist/bollharness-integration/context-router-judgment.js +4 -4
  25. package/dist/bollharness-integration/context-router.js +292 -292
  26. package/dist/bollharness-integration/gate-state-machine.js +26 -13
  27. package/dist/bollharness-integration/integration.js +71 -0
  28. package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
  29. package/dist/bollharness-integration/skill-adapter.js +57 -127
  30. package/dist/bootstrap/chat-archiver.js +276 -0
  31. package/dist/bootstrap/context-collector.js +6 -3
  32. package/dist/bootstrap/event-log.js +160 -0
  33. package/dist/bootstrap/lifecycle-hooks.js +15 -1
  34. package/dist/bootstrap/memory-compressor.js +170 -0
  35. package/dist/bootstrap/persona-loader.js +94 -0
  36. package/dist/bootstrap/project-state.js +159 -0
  37. package/dist/bootstrap/remote-mirror.js +97 -0
  38. package/dist/bootstrap/session-window.js +121 -0
  39. package/dist/bootstrap/vector-index.js +248 -0
  40. package/dist/cli/loading-tui.js +40 -0
  41. package/dist/cli-entry.js +41 -37
  42. package/dist/context-compaction/auto-compact.js +7 -7
  43. package/dist/electron/config.js +21 -0
  44. package/dist/electron/config.js.map +1 -0
  45. package/dist/electron/dialogs.js +108 -0
  46. package/dist/electron/dialogs.js.map +1 -0
  47. package/dist/electron/first-run.js +170 -0
  48. package/dist/electron/first-run.js.map +1 -0
  49. package/dist/electron/ipc.js +20 -0
  50. package/dist/electron/ipc.js.map +1 -0
  51. package/dist/electron/logger.js +114 -0
  52. package/dist/electron/logger.js.map +1 -0
  53. package/dist/electron/main.js +63 -0
  54. package/dist/electron/main.js.map +1 -0
  55. package/dist/electron/menu.js +145 -0
  56. package/dist/electron/menu.js.map +1 -0
  57. package/dist/electron/paths.js +75 -0
  58. package/dist/electron/paths.js.map +1 -0
  59. package/dist/electron/server.js +119 -0
  60. package/dist/electron/server.js.map +1 -0
  61. package/dist/electron/tray.js +111 -0
  62. package/dist/electron/tray.js.map +1 -0
  63. package/dist/electron/window.js +111 -0
  64. package/dist/electron/window.js.map +1 -0
  65. package/dist/electron-preload.js +26 -6
  66. package/dist/electron-preload.js.map +1 -1
  67. package/dist/electron.js +6 -168
  68. package/dist/electron.js.map +1 -1
  69. package/dist/index.js +323 -266
  70. package/dist/llm/config-store.js +24 -8
  71. package/dist/llm/llm-judgment-client.js +102 -102
  72. package/dist/llm/pi-ai.js +137 -85
  73. package/dist/llm/system-prompt/layers/channel/local.md +14 -14
  74. package/dist/llm/system-prompt/layers/channel/p2p-agent.md +18 -18
  75. package/dist/llm/system-prompt/layers/channel/p2p-visitor.md +19 -19
  76. package/dist/llm/system-prompt/layers/core/artifacts_storage.md +89 -89
  77. package/dist/llm/system-prompt/layers/core/evenhandedness.md +21 -21
  78. package/dist/llm/system-prompt/layers/core/hibs_reminders.md +15 -15
  79. package/dist/llm/system-prompt/layers/core/identity.md +37 -37
  80. package/dist/llm/system-prompt/layers/core/knowledge.md +17 -17
  81. package/dist/llm/system-prompt/layers/core/memory_system.md +12 -12
  82. package/dist/llm/system-prompt/layers/core/network_filesystem.md +28 -28
  83. package/dist/llm/system-prompt/layers/core/refusal.md +37 -37
  84. package/dist/llm/system-prompt/layers/core/tone.md +31 -31
  85. package/dist/llm/system-prompt/layers/core/tools.thin.md +13 -13
  86. package/dist/llm/system-prompt/layers/core/wellbeing.md +41 -41
  87. package/dist/llm/system-prompt/layers/role/architect.md +20 -20
  88. package/dist/llm/system-prompt/layers/role/expert.md +19 -19
  89. package/dist/llm/system-prompt/layers/role/implementer.md +15 -15
  90. package/dist/llm/system-prompt/layers/role/security.md +15 -15
  91. package/dist/llm/system-prompt/layers/tool/artifacts.md +72 -72
  92. package/dist/llm/system-prompt/layers/tool/bash.md +25 -25
  93. package/dist/llm/system-prompt/layers/tool/hibs_api.md +171 -171
  94. package/dist/llm/system-prompt/layers/tool/image_search.md +70 -70
  95. package/dist/llm/system-prompt/layers/tool/manifest.md +89 -89
  96. package/dist/llm/system-prompt/layers/tool/mcp_apps.md +53 -53
  97. package/dist/llm/system-prompt/layers/tool/web_search.md +83 -83
  98. package/dist/llm/tool-manifest/ask_user_input.js +1 -1
  99. package/dist/llm/tool-manifest/bash.js +3 -3
  100. package/dist/llm/tool-manifest/create_file.js +4 -4
  101. package/dist/llm/tool-manifest/fetch_sports_data.js +3 -3
  102. package/dist/llm/tool-manifest/image_search.js +2 -2
  103. package/dist/llm/tool-manifest/mcp.js +2 -2
  104. package/dist/llm/tool-manifest/message_compose.js +3 -3
  105. package/dist/llm/tool-manifest/places.js +2 -2
  106. package/dist/llm/tool-manifest/present_files.js +1 -1
  107. package/dist/llm/tool-manifest/recipe.js +2 -2
  108. package/dist/llm/tool-manifest/str_replace.js +5 -5
  109. package/dist/llm/tool-manifest/view.js +3 -3
  110. package/dist/llm/tool-manifest/weather.js +4 -4
  111. package/dist/llm/tool-manifest/web.js +4 -4
  112. package/dist/network/local-inbox-bus.js +73 -0
  113. package/dist/network/p2p-outbox.js +161 -0
  114. package/dist/network/peer-fs.js +420 -0
  115. package/dist/network/peer-resource-bridge.js +216 -0
  116. package/dist/pi-ecosystem-judgment/causal-judge.js +51 -51
  117. package/dist/pi-ecosystem-judgment/cleanup.js +126 -0
  118. package/dist/pi-ecosystem-judgment/distill-prompt.js +42 -42
  119. package/dist/pi-ecosystem-judgment/distillation.js +14 -14
  120. package/dist/pi-ecosystem-judgment/human-value-store.js +45 -11
  121. package/dist/pi-ecosystem-judgment/monitor-gate.js +28 -28
  122. package/dist/pi-ecosystem-judgment/value-injection.js +102 -102
  123. package/dist/security/context-router-tool.js +15 -15
  124. package/dist/security/tool-gate.js +11 -0
  125. package/dist/web/api-config.html +520 -520
  126. package/dist/web/client-loop-status.js +220 -0
  127. package/dist/web/client.js +22 -5
  128. package/dist/web/client.js.map +7 -0
  129. package/dist/web/components/wallet-viem.mjs +118 -118
  130. package/dist/web/index.html +375 -375
  131. package/dist/web/input-validator.js +103 -0
  132. package/dist/web/manifest.json +20 -20
  133. package/dist/web/routes-judgments.js +738 -0
  134. package/dist/web/routes-llm-config.js +279 -0
  135. package/dist/web/routes-tasks.js +222 -0
  136. package/dist/web/server-sse.js +121 -0
  137. package/dist/web/server-storage.js +154 -0
  138. package/dist/web/server-types.js +15 -0
  139. package/dist/web/server-v3-p2p.js +224 -0
  140. package/dist/web/server.js +1070 -1307
  141. package/dist/web/style.css +4742 -4742
  142. package/dist/web/util/safe-name.js +32 -0
  143. package/package.json +162 -160
  144. package/scripts/build-cli.js +215 -215
  145. package/scripts/build-web.ts +130 -130
  146. package/scripts/postinstall.js +152 -152
  147. package/bin/bolloon.js +0 -157
  148. package/dist/constraint-runtime/src/_archive_helper.js +0 -9
  149. package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
  150. package/dist/constraint-runtime/src/agent/index.js +0 -1
  151. package/dist/constraint-runtime/src/assistant/index.js +0 -12
  152. package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
  153. package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
  154. package/dist/constraint-runtime/src/bridge/index.js +0 -12
  155. package/dist/constraint-runtime/src/buddy/index.js +0 -12
  156. package/dist/constraint-runtime/src/cli/index.js +0 -12
  157. package/dist/constraint-runtime/src/command_graph.js +0 -10
  158. package/dist/constraint-runtime/src/commands.js +0 -60
  159. package/dist/constraint-runtime/src/components/index.js +0 -12
  160. package/dist/constraint-runtime/src/constants/index.js +0 -12
  161. package/dist/constraint-runtime/src/constraint/budget.js +0 -22
  162. package/dist/constraint-runtime/src/constraint/index.js +0 -2
  163. package/dist/constraint-runtime/src/constraint/permission.js +0 -20
  164. package/dist/constraint-runtime/src/context.js +0 -30
  165. package/dist/constraint-runtime/src/coordinator/index.js +0 -12
  166. package/dist/constraint-runtime/src/cost_hook.js +0 -4
  167. package/dist/constraint-runtime/src/cost_tracker.js +0 -8
  168. package/dist/constraint-runtime/src/deferred_init.js +0 -10
  169. package/dist/constraint-runtime/src/direct_modes.js +0 -6
  170. package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
  171. package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
  172. package/dist/constraint-runtime/src/execution_registry.js +0 -44
  173. package/dist/constraint-runtime/src/history.js +0 -9
  174. package/dist/constraint-runtime/src/hooks/index.js +0 -12
  175. package/dist/constraint-runtime/src/index.js +0 -26
  176. package/dist/constraint-runtime/src/ink.js +0 -4
  177. package/dist/constraint-runtime/src/keybindings/index.js +0 -12
  178. package/dist/constraint-runtime/src/memdir/index.js +0 -12
  179. package/dist/constraint-runtime/src/migrations/index.js +0 -12
  180. package/dist/constraint-runtime/src/models.js +0 -1
  181. package/dist/constraint-runtime/src/moreright/index.js +0 -12
  182. package/dist/constraint-runtime/src/native_ts/index.js +0 -12
  183. package/dist/constraint-runtime/src/output_styles/index.js +0 -12
  184. package/dist/constraint-runtime/src/parity_audit.js +0 -12
  185. package/dist/constraint-runtime/src/plugins/index.js +0 -12
  186. package/dist/constraint-runtime/src/port_manifest.js +0 -11
  187. package/dist/constraint-runtime/src/prefetch.js +0 -9
  188. package/dist/constraint-runtime/src/query.js +0 -1
  189. package/dist/constraint-runtime/src/remote/index.js +0 -12
  190. package/dist/constraint-runtime/src/remote_runtime.js +0 -9
  191. package/dist/constraint-runtime/src/runtime/index.js +0 -1
  192. package/dist/constraint-runtime/src/runtime/session.js +0 -35
  193. package/dist/constraint-runtime/src/schemas/index.js +0 -12
  194. package/dist/constraint-runtime/src/screens/index.js +0 -12
  195. package/dist/constraint-runtime/src/server/index.js +0 -12
  196. package/dist/constraint-runtime/src/services/index.js +0 -12
  197. package/dist/constraint-runtime/src/session_store.js +0 -22
  198. package/dist/constraint-runtime/src/setup.js +0 -30
  199. package/dist/constraint-runtime/src/skills/index.js +0 -1
  200. package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
  201. package/dist/constraint-runtime/src/state/index.js +0 -12
  202. package/dist/constraint-runtime/src/system_init.js +0 -20
  203. package/dist/constraint-runtime/src/thinking/engine.js +0 -42
  204. package/dist/constraint-runtime/src/thinking/index.js +0 -1
  205. package/dist/constraint-runtime/src/tool_pool.js +0 -8
  206. package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
  207. package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
  208. package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
  209. package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
  210. package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
  211. package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
  212. package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
  213. package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
  214. package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
  215. package/dist/constraint-runtime/src/tools.js +0 -80
  216. package/dist/constraint-runtime/src/transcript.js +0 -19
  217. package/dist/constraint-runtime/src/types/index.js +0 -12
  218. package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
  219. package/dist/constraint-runtime/src/utils/index.js +0 -12
  220. package/dist/constraint-runtime/src/vim/index.js +0 -12
  221. package/dist/constraint-runtime/src/voice/index.js +0 -12
  222. package/dist/constraint-runtime/tests/agent.test.js +0 -16
  223. package/dist/constraint-runtime/tests/constraint.test.js +0 -41
  224. package/dist/constraint-runtime/tests/skill.test.js +0 -19
  225. package/dist/constraint-runtime/tests/thinking.test.js +0 -22
  226. package/dist/pi-ecosystem-colony/index.js +0 -365
  227. package/dist/social/ant-colony/AdaptiveHeartbeat.js +0 -101
  228. package/dist/social/ant-colony/PheromoneEngine.js +0 -227
  229. package/dist/social/ant-colony/index.js +0 -6
  230. package/dist/social/ant-colony/types.js +0 -24
  231. package/dist/test/ai-judgment-test.js +0 -80
  232. package/dist/test/bollharness-integration.test.js +0 -318
  233. package/dist/test/channel-agent-multi-dialogue.js +0 -205
  234. package/dist/test/channel-heartbeat-agent-test.js +0 -201
  235. package/dist/test/constraint-layer.test.js +0 -164
  236. package/dist/test/diap-identity-test.js +0 -172
  237. package/dist/test/diap-quick-test.js +0 -62
  238. package/dist/test/global-shared-context.test.js +0 -315
  239. package/dist/test/harness-judgment-injection.test.js +0 -246
  240. package/dist/test/harness-workflow-integrator-test.js +0 -228
  241. package/dist/test/human-value-store.test.js +0 -243
  242. package/dist/test/hybrid-integration-test.js +0 -118
  243. package/dist/test/hybrid-messenger-verify.js +0 -55
  244. package/dist/test/iroh-bistream-debug.js +0 -38
  245. package/dist/test/iroh-communication.test.js +0 -66
  246. package/dist/test/iroh-debug-test.js +0 -57
  247. package/dist/test/iroh-diap-test.js +0 -71
  248. package/dist/test/iroh-direct-connect.js +0 -55
  249. package/dist/test/iroh-e2e-fixed.js +0 -89
  250. package/dist/test/iroh-e2e-same-process.js +0 -63
  251. package/dist/test/iroh-e2e.js +0 -66
  252. package/dist/test/iroh-final-e2e.js +0 -72
  253. package/dist/test/iroh-relay-test.js +0 -37
  254. package/dist/test/iroh-simple-test.js +0 -41
  255. package/dist/test/iroh-transport-verify.js +0 -54
  256. package/dist/test/iroh-transport.test.js +0 -37
  257. package/dist/test/iroh-two-nodes.js +0 -70
  258. package/dist/test/iroh-verify.js +0 -44
  259. package/dist/test/judgment-decision.test.js +0 -219
  260. package/dist/test/llm-judgment-integration.test.js +0 -220
  261. package/dist/test/p2p-agent-complex-dialogue.js +0 -385
  262. package/dist/test/p2p-agent-dialogue.js +0 -341
  263. package/dist/test/p2p-agent-full-bidirectional.js +0 -510
  264. package/dist/test/p2p-agent-harness-flow.js +0 -437
  265. package/dist/test/p2p-agent-harness-single.js +0 -143
  266. package/dist/test/p2p-ai-dialogue-test.js +0 -318
  267. package/dist/test/p2p-cid-connect-test.js +0 -195
  268. package/dist/test/p2p-connect-receiver.js +0 -69
  269. package/dist/test/p2p-doc-transfer.js +0 -110
  270. package/dist/test/p2p-identity-page-test.js +0 -77
  271. package/dist/test/p2p-iroh-test.js +0 -171
  272. package/dist/test/p2p-minimal-test.js +0 -241
  273. package/dist/test/p2p-node-1.js +0 -148
  274. package/dist/test/p2p-node-2.js +0 -148
  275. package/dist/test/p2p-server.js +0 -281
  276. package/dist/test/p2p-two-nodes-test.js +0 -438
  277. package/dist/test/pi-sdk.test.js +0 -44
  278. package/dist/test/set-persona.js +0 -40
  279. package/dist/test/simple.test.js +0 -9
  280. package/dist/test/storage-integration.test.js +0 -150
  281. package/dist/test/subagent-manager.test.js +0 -276
  282. package/dist/test/test-gate-flow.test.js +0 -81
  283. package/dist/test/workflow-engine.test.js +0 -87
  284. package/dist/test/workflow-pivot-loop.test.js +0 -246
@@ -11,6 +11,8 @@ import { GateStateMachine } from './gate-state-machine.js';
11
11
  import { GuardChecker, runGuards } from './guard-checker.js';
12
12
  import { ContextRouter } from './context-router.js';
13
13
  import { createSkillAdapter } from './skill-adapter.js';
14
+ import * as fs from 'fs';
15
+ import * as path from 'path';
14
16
  /**
15
17
  * Main integration class
16
18
  */
@@ -29,11 +31,76 @@ export class BollharnessIntegration {
29
31
  contextEnabled: config.contextEnabled ?? true,
30
32
  skillsEnabled: config.skillsEnabled ?? true,
31
33
  gatesEnabled: config.gatesEnabled ?? true,
34
+ persistencePath: config.persistencePath,
32
35
  };
33
36
  this.gateMachine = new GateStateMachine();
34
37
  this.guardChecker = new GuardChecker();
35
38
  this.contextRouter = new ContextRouter();
36
39
  this.skillAdapter = createSkillAdapter();
40
+ if (this.config.persistencePath) {
41
+ this.loadState();
42
+ }
43
+ }
44
+ saveState() {
45
+ if (!this.config.persistencePath)
46
+ return;
47
+ try {
48
+ const gateState = this.gateMachine.getState();
49
+ const data = JSON.stringify({
50
+ gateState: {
51
+ currentGate: gateState.currentGate,
52
+ entrySatisfied: gateState.entrySatisfied,
53
+ blockers: gateState.blockers,
54
+ requiredArtifact: gateState.requiredArtifact,
55
+ requiredNextSkill: gateState.requiredNextSkill,
56
+ valueInjection: gateState.valueInjection,
57
+ artifacts: Array.from(gateState.artifacts.entries()),
58
+ conversationHistory: gateState.conversationHistory,
59
+ },
60
+ sessionArchives: this.sessionArchives,
61
+ currentSessionId: this.currentSessionId,
62
+ }, null, 2);
63
+ const dir = path.dirname(this.config.persistencePath);
64
+ if (!fs.existsSync(dir)) {
65
+ fs.mkdirSync(dir, { recursive: true });
66
+ }
67
+ fs.writeFileSync(this.config.persistencePath, data, 'utf-8');
68
+ }
69
+ catch (err) {
70
+ console.warn(`[BollharnessIntegration] 持久化失败: ${err.message}`);
71
+ }
72
+ }
73
+ loadState() {
74
+ if (!this.config.persistencePath)
75
+ return;
76
+ try {
77
+ if (!fs.existsSync(this.config.persistencePath))
78
+ return;
79
+ const raw = fs.readFileSync(this.config.persistencePath, 'utf-8');
80
+ const data = JSON.parse(raw);
81
+ if (data.gateState) {
82
+ this.gateMachine.restore({
83
+ currentGate: data.gateState.currentGate,
84
+ entrySatisfied: data.gateState.entrySatisfied,
85
+ blockers: data.gateState.blockers,
86
+ requiredArtifact: data.gateState.requiredArtifact,
87
+ requiredNextSkill: data.gateState.requiredNextSkill,
88
+ requiredReviewSubstrate: undefined,
89
+ valueInjection: data.gateState.valueInjection || '',
90
+ artifacts: new Map(data.gateState.artifacts || []),
91
+ conversationHistory: data.gateState.conversationHistory || [],
92
+ });
93
+ }
94
+ if (data.sessionArchives) {
95
+ this.sessionArchives = data.sessionArchives;
96
+ }
97
+ if (data.currentSessionId) {
98
+ this.currentSessionId = data.currentSessionId;
99
+ }
100
+ }
101
+ catch (err) {
102
+ console.warn(`[BollharnessIntegration] 状态恢复失败: ${err.message}`);
103
+ }
37
104
  }
38
105
  /**
39
106
  * Process a file edit with all enabled checks
@@ -128,12 +195,14 @@ export class BollharnessIntegration {
128
195
  */
129
196
  submitGateArtifact(name, artifact) {
130
197
  this.gateMachine.submitArtifact(name, artifact);
198
+ this.saveState();
131
199
  }
132
200
  /**
133
201
  * Attempt gate transition
134
202
  */
135
203
  async transitionGate(reviewResult) {
136
204
  const transition = await this.gateMachine.transition(reviewResult);
205
+ this.saveState();
137
206
  return {
138
207
  success: transition.blockers.length === 0,
139
208
  transition,
@@ -246,6 +315,7 @@ export class BollharnessIntegration {
246
315
  };
247
316
  this.sessionArchives.push(archive);
248
317
  this.currentSessionId = id;
318
+ this.saveState();
249
319
  return archive;
250
320
  }
251
321
  /**
@@ -333,6 +403,7 @@ export class BollharnessIntegration {
333
403
  */
334
404
  startNewSession() {
335
405
  this.currentSessionId = `session_${Date.now()}`;
406
+ this.saveState();
336
407
  return this.currentSessionId;
337
408
  }
338
409
  /**
@@ -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
  }
@@ -88,6 +88,10 @@ function loadAllHarnessSkills() {
88
88
  * Base skill class for bollharness-compatible skills
89
89
  */
90
90
  export class BaseSkill {
91
+ static llm = null;
92
+ static setLlm(instance) {
93
+ BaseSkill.llm = instance;
94
+ }
91
95
  log(message, level = 'info') {
92
96
  const prefix = level === 'error' ? '❌' : level === 'warn' ? '⚠️' : 'ℹ️';
93
97
  console.log(`${prefix} [${this.name}] ${message}`);
@@ -95,6 +99,33 @@ export class BaseSkill {
95
99
  formatOutput(output) {
96
100
  return JSON.stringify(output, null, 2);
97
101
  }
102
+ async callLm(system, user) {
103
+ let llm = BaseSkill.llm;
104
+ if (!llm) {
105
+ try {
106
+ const { getMinimax } = await import('../llm/pi-ai.js');
107
+ const m = getMinimax();
108
+ if (m && typeof m.chat === 'function') {
109
+ BaseSkill.setLlm(m);
110
+ llm = m;
111
+ }
112
+ }
113
+ catch {
114
+ return this.formatOutput({ warning: 'LLM 未注入', name: this.name });
115
+ }
116
+ }
117
+ if (!llm) {
118
+ return this.formatOutput({ warning: 'LLM 未注入', name: this.name });
119
+ }
120
+ try {
121
+ const res = await llm.chat([{ role: 'user', content: user }], system);
122
+ return res.reply || '(空回复)';
123
+ }
124
+ catch (err) {
125
+ this.log(`LLM 调用失败: ${err.message}`, 'error');
126
+ return this.formatOutput({ error: `LLM 调用失败: ${err.message}` });
127
+ }
128
+ }
98
129
  }
99
130
  /**
100
131
  * Architecture Skill - Project architect for architecture decisions
@@ -103,58 +134,12 @@ export class ArchSkill extends BaseSkill {
103
134
  name = 'arch';
104
135
  description = 'Project architect. Responsible for architecture decisions, scheme comparison, and boundary freezing.';
105
136
  async execute(params) {
106
- const task = params.task || params.description;
137
+ const task = (params.task || params.description || params.action || '');
107
138
  this.log('Analyzing architecture task');
108
- // Extract essence
109
- const essence = this.extractEssence(task);
110
- // Find tensions
111
- const tensions = this.identifyTensions(task);
112
- // Compare alternatives
113
- const alternatives = this.compareAlternatives(task);
114
- // Identify boundaries to freeze
115
- const boundaries = this.identifyBoundaries(task);
116
- return this.formatOutput({
117
- essence,
118
- tensions,
119
- alternatives,
120
- boundaries,
121
- recommendation: this.makeRecommendation(task, alternatives),
122
- });
123
- }
124
- extractEssence(task) {
125
- // Simplified essence extraction
126
- return `The core challenge is: ${task}`;
127
- }
128
- identifyTensions(task) {
129
- return [
130
- 'Simplicity vs Flexibility',
131
- 'Performance vs Maintainability',
132
- 'Coupling vs Cohesion',
133
- ];
134
- }
135
- compareAlternatives(task) {
136
- return [
137
- {
138
- name: 'Option A: Direct Implementation',
139
- tradeoffs: ['Fast to implement', 'May not scale'],
140
- recommendation: 'Suitable for MVP',
141
- },
142
- {
143
- name: 'Option B: Abstraction Layer',
144
- tradeoffs: ['More upfront work', 'Better for extension'],
145
- recommendation: 'Suitable for long-term',
146
- },
147
- ];
148
- }
149
- identifyBoundaries(task) {
150
- return [
151
- 'API contract boundaries',
152
- 'Data format boundaries',
153
- 'Capability boundaries',
154
- ];
155
- }
156
- makeRecommendation(task, alternatives) {
157
- return alternatives[1]?.recommendation || 'Consider abstraction layer for long-term maintainability';
139
+ if (!task) {
140
+ return this.formatOutput({ warning: '未提供任务', usage: '--harness-skill arch "你的架构任务"' });
141
+ }
142
+ return this.callLm('You are a senior software architect. Analyze the task and output structured JSON with fields: essence, tensions, alternatives, boundaries, recommendation.', `Architecture task: ${task}`);
158
143
  }
159
144
  }
160
145
  /**
@@ -221,18 +206,9 @@ export class LeadSkill extends BaseSkill {
221
206
  gate_pack: this.getGatePack(),
222
207
  });
223
208
  }
224
- classifyChange(params) {
209
+ async classifyChange(params) {
225
210
  const description = params.description || '';
226
- // Simplified classification
227
- const isPolicy = description.includes('policy') || description.includes('boundary');
228
- const isContract = description.includes('API') || description.includes('contract') || description.includes('schema');
229
- const isImplementation = !isPolicy && !isContract;
230
- return this.formatOutput({
231
- classification: isPolicy ? 'policy' : isContract ? 'contract' : 'implementation',
232
- description,
233
- minimum_gate_path: isPolicy ? '0→8 (full)' : isContract ? '0→8 (full + consumers)' : '0→7 (fast track eligible)',
234
- fast_track_eligible: isImplementation,
235
- });
211
+ return this.callLm('You are a change classifier. Given a description, classify the change as policy, contract, or implementation. Output JSON: { classification, description, minimum_gate_path, fast_track_eligible }.', `Classify this change: ${description}`);
236
212
  }
237
213
  }
238
214
  /**
@@ -242,44 +218,12 @@ export class TaskArchSkill extends BaseSkill {
242
218
  name = 'task-arch';
243
219
  description = 'Task decomposition. Breaks down PLAN into parallelizable work packages (WP).';
244
220
  async execute(params) {
245
- const plan = params.plan;
221
+ const plan = (params.plan || params.task || params.description || params.action || '');
246
222
  this.log('Decomposing plan into work packages');
247
- // Extract work packages
248
- const workPackages = this.extractWorkPackages(plan);
249
- // Identify seams
250
- const seams = this.identifySeams(workPackages);
251
- // Identify integration points
252
- const integration = this.identifyIntegration(workPackages);
253
- return this.formatOutput({
254
- work_packages: workPackages,
255
- seams,
256
- integration,
257
- seam_owners: this.assignSeamOwners(seams),
258
- });
259
- }
260
- extractWorkPackages(plan) {
261
- // Simplified WP extraction
262
- return [
263
- { id: 'WP-1', description: 'Core implementation', files: ['src/agents/*.ts'] },
264
- { id: 'WP-2', description: 'Network layer', files: ['src/network/*.ts'] },
265
- { id: 'WP-3', description: 'Testing', files: ['src/test/*.ts'] },
266
- ];
267
- }
268
- identifySeams(packages) {
269
- return [
270
- { from: 'WP-1', to: 'WP-2', interface: 'P2PNetwork interface' },
271
- { from: 'WP-1', to: 'WP-3', interface: 'Test fixtures' },
272
- ];
273
- }
274
- identifyIntegration(packages) {
275
- return ['Integration test at WP-1/WP-2 boundary'];
276
- }
277
- assignSeamOwners(seams) {
278
- const owners = {};
279
- for (const seam of seams) {
280
- owners[`${seam.from}/${seam.to}`] = 'integration-owner';
223
+ if (!plan) {
224
+ return this.formatOutput({ warning: '未提供 plan', usage: '--harness-skill task-arch "你的开发计划"' });
281
225
  }
282
- return owners;
226
+ return this.callLm('You are a task decomposition specialist. Given a plan, break it down into work packages (WP) with seams and integration points. Output JSON: { work_packages, seams, integration }.', `Plan: ${plan}`);
283
227
  }
284
228
  }
285
229
  /**
@@ -398,35 +342,12 @@ export class CrystalLearnSkill extends BaseSkill {
398
342
  name = 'crystal-learn';
399
343
  description = 'Extracts failure patterns and maintains invariants.';
400
344
  async execute(params) {
401
- const task = params.task;
402
- this.log('Extracting failure patterns');
403
- // Identify failure modes
404
- const failures = this.identifyFailures(task);
405
- // Extract patterns
406
- const patterns = this.extractPatterns(failures);
407
- // Generate invariants
408
- const invariants = this.generateInvariants(patterns);
409
- return this.formatOutput({
410
- failure_modes: failures,
411
- patterns,
412
- invariants,
413
- });
414
- }
415
- identifyFailures(task) {
416
- return [
417
- 'Truth source split',
418
- 'Verification decay',
419
- 'Orphaned seams',
420
- ];
421
- }
422
- extractPatterns(failures) {
423
- return failures.map(f => ({
424
- pattern: f,
425
- prevention: `Implement guard to prevent ${f}`,
426
- }));
427
- }
428
- generateInvariants(patterns) {
429
- return patterns.map(p => `INV: ${p.pattern} must not occur`);
345
+ const task = (params.task || params.description || params.action || '');
346
+ this.log('Extracting failure patterns from: ' + (task || '(空)'));
347
+ if (!task) {
348
+ return this.formatOutput({ warning: '未提供任务', usage: '--harness-skill crystal-learn "你的任务描述"' });
349
+ }
350
+ return this.callLm('You are a failure pattern analyst. Extract failure modes, patterns, and invariants from the task description. Output structured JSON with failure_modes, patterns, invariants.', `Task: ${task}`);
430
351
  }
431
352
  }
432
353
  /**
@@ -482,6 +403,10 @@ export class SkillAdapter {
482
403
  getSkill(name) {
483
404
  return this.registry.get(name);
484
405
  }
406
+ injectLlm(llm) {
407
+ BaseSkill.setLlm(llm);
408
+ this.log('LLM 已注入到所有 BaseSkill');
409
+ }
485
410
  listSkills() {
486
411
  return this.registry.list();
487
412
  }
@@ -492,6 +417,11 @@ export class SkillAdapter {
492
417
  return this.registry.execute(name, params);
493
418
  }
494
419
  log(message, level = 'info') {
420
+ // 2026-07-06: info 默认静音 — 14 条 [SkillAdapter] Loaded/Registered 日志刷屏 web.log
421
+ // 调试时设 BOLLOON_VERBOSE=1 临时开起来. warn/error 仍正常打.
422
+ const VERBOSE = typeof process !== 'undefined' && process.env?.BOLLOON_VERBOSE === '1';
423
+ if (level === 'info' && !VERBOSE)
424
+ return;
495
425
  const prefix = level === 'error' ? '❌' : level === 'warn' ? '⚠️' : 'ℹ️';
496
426
  console.log(`${prefix} [SkillAdapter] ${message}`);
497
427
  }