@bolloon/bolloon-agent 0.1.35 → 0.1.37
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.
- package/README.md +1 -1
- package/dist/agents/p2p-chat-tools.js +6 -6
- package/dist/agents/permission-mode.js +115 -0
- package/dist/agents/pi-sdk.js +435 -25
- package/dist/agents/pre-tool-validator.js +194 -0
- package/dist/agents/workflow-pivot-loop.js +113 -12
- package/dist/bollharness-integration/context-router.js +2 -2
- package/dist/bollharness-integration/guard-checker.js +1 -1
- package/dist/bootstrap/bootstrap.js +3 -0
- package/dist/bootstrap/context-collector.js +17 -1
- package/dist/bootstrap/context-hierarchy.js +218 -0
- package/dist/bootstrap/lifecycle-hooks.js +86 -24
- package/dist/bootstrap/project-context.js +10 -3
- package/dist/context-compaction/auto-compact.js +144 -0
- package/dist/context-compaction/budget-gate.js +28 -0
- package/dist/context-compaction/budget-reduce.js +35 -0
- package/dist/context-compaction/context-collapse.js +66 -0
- package/dist/context-compaction/index.js +21 -0
- package/dist/context-compaction/microcompact.js +51 -0
- package/dist/context-compaction/pipeline.js +123 -0
- package/dist/context-compaction/snip.js +45 -0
- package/dist/context-compaction/token-estimator.js +35 -0
- package/dist/context-compaction/types.js +19 -0
- package/dist/heartbeat/HealthMonitor.js +3 -2
- package/dist/index.js +38 -2
- package/dist/llm/llm-judgment-client.js +32 -30
- package/dist/llm/pi-ai.js +103 -16
- package/dist/llm/system-prompt/health.js +129 -0
- package/dist/llm/system-prompt/registry.js +246 -0
- package/dist/llm/system-prompt/strip-hibsml.js +51 -0
- package/dist/llm/tool-manifest/ask_user_input.js +35 -0
- package/dist/llm/tool-manifest/bash.js +23 -0
- package/dist/llm/tool-manifest/create_file.js +24 -0
- package/dist/llm/tool-manifest/fetch_sports_data.js +26 -0
- package/dist/llm/tool-manifest/image_search.js +24 -0
- package/dist/llm/tool-manifest/index.js +69 -0
- package/dist/llm/tool-manifest/mcp.js +43 -0
- package/dist/llm/tool-manifest/message_compose.js +31 -0
- package/dist/llm/tool-manifest/places.js +83 -0
- package/dist/llm/tool-manifest/present_files.js +21 -0
- package/dist/llm/tool-manifest/recipe.js +40 -0
- package/dist/llm/tool-manifest/recommend_apps.js +23 -0
- package/dist/llm/tool-manifest/str_replace.js +27 -0
- package/dist/llm/tool-manifest/types.js +7 -0
- package/dist/llm/tool-manifest/view.js +24 -0
- package/dist/llm/tool-manifest/weather.js +27 -0
- package/dist/llm/tool-manifest/web.js +51 -0
- package/dist/network/p2p-direct.js +23 -0
- package/dist/network/source-intent-broadcaster.js +203 -0
- package/dist/network/source-intent.js +100 -0
- package/dist/pi-ecosystem-judgment/adaptive-scan.js +48 -0
- package/dist/pi-ecosystem-judgment/injection-gate.js +54 -12
- package/dist/pi-ecosystem-judgment/value-injection.js +8 -2
- package/dist/security/context-router-tool.js +1 -1
- package/dist/security/input-scanner.js +223 -0
- package/dist/web/client.js +3089 -4458
- package/dist/web/index.html +58 -67
- package/dist/web/server.js +299 -117
- package/dist/web/style.css +531 -249
- package/dist/web/ui/message-renderer.js +352 -0
- package/dist/web/ui/step-timeline.js +279 -0
- package/package.json +2 -2
- package/.auto-evolve-calls +0 -1
- package/.last-auto-evolve-baseline +0 -1
- package/Bolloon.md +0 -103
- package/dist/agents/constraint-layer.js.map +0 -1
- package/dist/agents/pi-sdk.js.map +0 -1
- package/dist/agents/workflow-engine.js.map +0 -1
- package/dist/bollharness/src/index.js +0 -5
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_api_types.js +0 -45
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +0 -146
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +0 -135
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +0 -31
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +0 -34
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +0 -63
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +0 -41
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_security.js +0 -48
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_versions.js +0 -6
- package/dist/bollharness/src/scripts/checks/finding.js +0 -13
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +0 -20
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +0 -6
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +0 -8
- package/dist/bollharness/src/scripts/context_router.js +0 -67
- package/dist/bollharness/src/scripts/deploy-guard.js +0 -157
- package/dist/bollharness/src/scripts/guard-feedback.js +0 -192
- package/dist/bollharness/src/scripts/guard_router.js +0 -158
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +0 -6
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +0 -6
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +0 -6
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +0 -6
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +0 -92
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +0 -63
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +0 -6
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +0 -6
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +0 -73
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +0 -6
- package/dist/bollharness/src/scripts/hooks/precompact.js +0 -6
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +0 -6
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +0 -108
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +0 -6
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +0 -7
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +0 -157
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +0 -6
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +0 -10
- package/dist/bollharness/src/scripts/install/install-trust-token.js +0 -7
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +0 -9
- package/dist/bollharness/src/scripts/install/phase2_auto.js +0 -21
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +0 -6
- package/dist/bollharness/src/scripts/install/tier_selector.js +0 -7
- package/dist/bollharness/src/scripts/install/transcript_miner.js +0 -7
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +0 -10
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +0 -12
- package/dist/bollharness/src/scripts/sanitize.js +0 -6
- package/dist/bollharness-integration/context-router-judgment.js.map +0 -1
- package/dist/bollharness-integration/context-router.js.map +0 -1
- package/dist/bollharness-integration/gate-state-machine.js.map +0 -1
- package/dist/bollharness-integration/gate-transition-hooks.js.map +0 -1
- package/dist/bollharness-integration/guard-checker.js.map +0 -1
- package/dist/bollharness-integration/index.js.map +0 -1
- package/dist/bollharness-integration/integration.js.map +0 -1
- package/dist/bollharness-integration/llm/pi-ai.d.ts +0 -60
- package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +0 -153
- package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +0 -136
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +0 -117
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +0 -78
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +0 -139
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +0 -127
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +0 -95
- package/dist/bollharness-integration/skill-adapter.js.map +0 -1
- package/dist/constraint-runtime/src/_archive_helper.js +0 -9
- package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
- package/dist/constraint-runtime/src/agent/index.js +0 -1
- package/dist/constraint-runtime/src/assistant/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
- package/dist/constraint-runtime/src/bridge/index.js +0 -12
- package/dist/constraint-runtime/src/buddy/index.js +0 -12
- package/dist/constraint-runtime/src/cli/index.js +0 -12
- package/dist/constraint-runtime/src/command_graph.js +0 -10
- package/dist/constraint-runtime/src/commands.js +0 -60
- package/dist/constraint-runtime/src/components/index.js +0 -12
- package/dist/constraint-runtime/src/constants/index.js +0 -12
- package/dist/constraint-runtime/src/constraint/budget.js +0 -22
- package/dist/constraint-runtime/src/constraint/budget.js.map +0 -1
- package/dist/constraint-runtime/src/constraint/index.js +0 -2
- package/dist/constraint-runtime/src/constraint/permission.js +0 -20
- package/dist/constraint-runtime/src/constraint/permission.js.map +0 -1
- package/dist/constraint-runtime/src/context.js +0 -30
- package/dist/constraint-runtime/src/coordinator/index.js +0 -12
- package/dist/constraint-runtime/src/cost_hook.js +0 -4
- package/dist/constraint-runtime/src/cost_tracker.js +0 -8
- package/dist/constraint-runtime/src/deferred_init.js +0 -10
- package/dist/constraint-runtime/src/direct_modes.js +0 -6
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
- package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
- package/dist/constraint-runtime/src/execution_registry.js +0 -44
- package/dist/constraint-runtime/src/history.js +0 -9
- package/dist/constraint-runtime/src/hooks/index.js +0 -12
- package/dist/constraint-runtime/src/index.js +0 -26
- package/dist/constraint-runtime/src/ink.js +0 -4
- package/dist/constraint-runtime/src/keybindings/index.js +0 -12
- package/dist/constraint-runtime/src/memdir/index.js +0 -12
- package/dist/constraint-runtime/src/migrations/index.js +0 -12
- package/dist/constraint-runtime/src/models.js +0 -1
- package/dist/constraint-runtime/src/models.js.map +0 -1
- package/dist/constraint-runtime/src/moreright/index.js +0 -12
- package/dist/constraint-runtime/src/native_ts/index.js +0 -12
- package/dist/constraint-runtime/src/output_styles/index.js +0 -12
- package/dist/constraint-runtime/src/parity_audit.js +0 -12
- package/dist/constraint-runtime/src/plugins/index.js +0 -12
- package/dist/constraint-runtime/src/port_manifest.js +0 -11
- package/dist/constraint-runtime/src/prefetch.js +0 -9
- package/dist/constraint-runtime/src/query.js +0 -1
- package/dist/constraint-runtime/src/remote/index.js +0 -12
- package/dist/constraint-runtime/src/remote_runtime.js +0 -9
- package/dist/constraint-runtime/src/runtime/index.js +0 -1
- package/dist/constraint-runtime/src/runtime/session.js +0 -35
- package/dist/constraint-runtime/src/schemas/index.js +0 -12
- package/dist/constraint-runtime/src/screens/index.js +0 -12
- package/dist/constraint-runtime/src/server/index.js +0 -12
- package/dist/constraint-runtime/src/services/index.js +0 -12
- package/dist/constraint-runtime/src/session_store.js +0 -22
- package/dist/constraint-runtime/src/setup.js +0 -30
- package/dist/constraint-runtime/src/skills/index.js +0 -1
- package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
- package/dist/constraint-runtime/src/state/index.js +0 -12
- package/dist/constraint-runtime/src/system_init.js +0 -20
- package/dist/constraint-runtime/src/thinking/engine.js +0 -42
- package/dist/constraint-runtime/src/thinking/index.js +0 -1
- package/dist/constraint-runtime/src/tool_pool.js +0 -8
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
- package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
- package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +0 -29
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +0 -13
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +0 -22
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +0 -25
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +0 -25
- package/dist/constraint-runtime/src/tools.js +0 -80
- package/dist/constraint-runtime/src/transcript.js +0 -19
- package/dist/constraint-runtime/src/types/index.js +0 -12
- package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
- package/dist/constraint-runtime/src/utils/index.js +0 -12
- package/dist/constraint-runtime/src/vim/index.js +0 -12
- package/dist/constraint-runtime/src/voice/index.js +0 -12
- package/dist/constraints/index.js.map +0 -1
- package/dist/documents/reader.js.map +0 -1
- package/dist/llm/config-store.js.map +0 -1
- package/dist/llm/pi-ai.js.map +0 -1
- package/dist/network/agent-network.js.map +0 -1
- package/dist/network/iroh-integration.js.map +0 -1
- package/dist/network/iroh-transport.js.map +0 -1
- package/dist/network/p2p.js.map +0 -1
- package/dist/network/storage/adapters/json-adapter.js.map +0 -1
- package/dist/pi-ecosystem-colony/index.js.map +0 -1
- package/dist/pi-ecosystem-goals/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/decision.js.map +0 -1
- package/dist/pi-ecosystem-judgment/distillation.js.map +0 -1
- package/dist/pi-ecosystem-judgment/human-value-store.js.map +0 -1
- package/dist/pi-ecosystem-judgment/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/value-injection.js.map +0 -1
- package/dist/pi-ecosystem-mcp/index.js.map +0 -1
- package/dist/pi-ecosystem-subagents/index.js.map +0 -1
- package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +0 -1
- package/dist/social/ant-colony/PheromoneEngine.js.map +0 -1
- package/dist/social/ant-colony/types.js.map +0 -1
- package/dist/social/channels/ChannelManager.js.map +0 -1
- package/dist/social/channels/DiapChannelBridge.js.map +0 -1
- package/dist/social/channels/InterestMatcher.js.map +0 -1
- package/dist/social/channels/types.js.map +0 -1
- package/dist/social/global-shared-context.js.map +0 -1
- package/dist/social/heartbeat.js.map +0 -1
- package/lefthook.yml +0 -29
- package/scripts/auto-evolve-loop.ts +0 -376
- package/scripts/auto-evolve-oneshot.sh +0 -155
- package/scripts/auto-evolve-snapshot.sh +0 -136
- package/scripts/build-cli.js +0 -216
- package/scripts/build-web.ts +0 -82
- package/scripts/detect-schema-changes.sh +0 -48
- package/scripts/diff-reviewer.ts +0 -159
- package/scripts/postinstall.js +0 -153
- package/scripts/weekly-report.ts +0 -364
- package/src/agents/agent-manifest-protocol.ts +0 -117
- package/src/agents/constraint-layer.ts +0 -309
- package/src/agents/iroh-secret.ts +0 -32
- package/src/agents/p2p-chat-tools.ts +0 -383
- package/src/agents/p2p-document-tools.ts +0 -347
- package/src/agents/pi-sdk.ts +0 -2462
- package/src/agents/protocol.ts +0 -398
- package/src/agents/shell-guard.ts +0 -417
- package/src/agents/shell-tool.ts +0 -103
- package/src/agents/skill-loader.ts +0 -202
- package/src/agents/subagent-manager.ts +0 -553
- package/src/agents/workflow-engine.ts +0 -332
- package/src/agents/workflow-pivot-loop.ts +0 -675
- package/src/bollharness/.sanitize-report.json +0 -13
- package/src/bollharness/CLAUDE.md +0 -73
- package/src/bollharness/LICENSE +0 -21
- package/src/bollharness/README.md +0 -143
- package/src/bollharness/README.zh-CN.md +0 -131
- package/src/bollharness/package.json +0 -20
- package/src/bollharness/reference/SOURCE-COMMIT.txt +0 -3
- package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +0 -12
- package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +0 -27
- package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +0 -57
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
- package/src/bollharness/schemas/metrics-jsonl-allowlist.json +0 -67
- package/src/bollharness/scripts/checks/next_decision_number.sh +0 -48
- package/src/bollharness/scripts/ci/count-components.sh +0 -65
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
- package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -108
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
- package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
- package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
- package/src/bollharness/scripts/hooks/find-project-root.sh +0 -47
- package/src/bollharness/scripts/hooks/inbox-poll.sh +0 -78
- package/src/bollharness/scripts/hooks/precompact.sh +0 -56
- package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
- package/src/bollharness/scripts/sync-from-upstream.sh +0 -281
- package/src/bollharness/src/index.ts +0 -5
- package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_api_types.ts +0 -52
- package/src/bollharness/src/scripts/checks/check_artifact_link.ts +0 -156
- package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +0 -141
- package/src/bollharness/src/scripts/checks/check_doc_links.ts +0 -36
- package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +0 -40
- package/src/bollharness/src/scripts/checks/check_hook_installed.ts +0 -70
- package/src/bollharness/src/scripts/checks/check_issue_closure.ts +0 -51
- package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_security.ts +0 -54
- package/src/bollharness/src/scripts/checks/check_skill_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_versions.ts +0 -11
- package/src/bollharness/src/scripts/checks/finding.ts +0 -35
- package/src/bollharness/src/scripts/checks/next_decision_number.ts +0 -24
- package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +0 -11
- package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +0 -14
- package/src/bollharness/src/scripts/context_router.ts +0 -76
- package/src/bollharness/src/scripts/deploy-guard.ts +0 -182
- package/src/bollharness/src/scripts/guard-feedback.ts +0 -215
- package/src/bollharness/src/scripts/guard_router.ts +0 -194
- package/src/bollharness/src/scripts/hooks/_hook_output.js +0 -3
- package/src/bollharness/src/scripts/hooks/_hook_output.ts +0 -11
- package/src/bollharness/src/scripts/hooks/auto-python3.ts +0 -10
- package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +0 -10
- package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +0 -10
- package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +0 -111
- package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +0 -74
- package/src/bollharness/src/scripts/hooks/inbox-ack.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-validate.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +0 -10
- package/src/bollharness/src/scripts/hooks/initializer-agent.ts +0 -10
- package/src/bollharness/src/scripts/hooks/loop-detection.ts +0 -83
- package/src/bollharness/src/scripts/hooks/owner-guard.ts +0 -10
- package/src/bollharness/src/scripts/hooks/precompact.ts +0 -10
- package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +0 -10
- package/src/bollharness/src/scripts/hooks/risk-tracker.ts +0 -121
- package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +0 -10
- package/src/bollharness/src/scripts/hooks/session-reflection.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +0 -12
- package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +0 -164
- package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +0 -10
- package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +0 -14
- package/src/bollharness/src/scripts/install/install-trust-token.ts +0 -13
- package/src/bollharness/src/scripts/install/multi_project_registry.ts +0 -13
- package/src/bollharness/src/scripts/install/phase2_auto.ts +0 -28
- package/src/bollharness/src/scripts/install/pre_commit_installer.ts +0 -10
- package/src/bollharness/src/scripts/install/tier_selector.ts +0 -10
- package/src/bollharness/src/scripts/install/transcript_miner.ts +0 -13
- package/src/bollharness/src/scripts/lib/claim_patterns.ts +0 -11
- package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +0 -13
- package/src/bollharness/src/scripts/sanitize.ts +0 -9
- package/src/bollharness/templates/persona/default.json +0 -19
- package/src/bollharness/templates/scaffold/.gitignore.append +0 -16
- package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
- package/src/bollharness-integration/channel-judgment-engine.ts +0 -634
- package/src/bollharness-integration/context-chain-router.ts +0 -474
- package/src/bollharness-integration/context-router-judgment.ts +0 -339
- package/src/bollharness-integration/context-router.ts +0 -583
- package/src/bollharness-integration/gate-state-machine.ts +0 -444
- package/src/bollharness-integration/gate-transition-hooks.ts +0 -137
- package/src/bollharness-integration/guard-checker.ts +0 -451
- package/src/bollharness-integration/index.ts +0 -195
- package/src/bollharness-integration/integration.ts +0 -538
- package/src/bollharness-integration/judgment-prompts.yaml +0 -535
- package/src/bollharness-integration/llm-judgment-engine.ts +0 -712
- package/src/bollharness-integration/skill-adapter.ts +0 -646
- package/src/bootstrap/bootstrap.ts +0 -132
- package/src/bootstrap/context-collector.ts +0 -342
- package/src/bootstrap/lifecycle-hooks.ts +0 -176
- package/src/bootstrap/project-context.ts +0 -163
- package/src/cli/interface.ts +0 -211
- package/src/cli-entry.ts +0 -304
- package/src/constraints/index.ts +0 -6
- package/src/documents/reader.ts +0 -85
- package/src/documents/store.ts +0 -252
- package/src/electron-preload.ts +0 -25
- package/src/electron.ts +0 -200
- package/src/heartbeat/DaemonManager.ts +0 -283
- package/src/heartbeat/HealthMonitor.ts +0 -316
- package/src/heartbeat/StartupVerifier.ts +0 -223
- package/src/heartbeat/Watchdog.ts +0 -208
- package/src/heartbeat/index.ts +0 -109
- package/src/heartbeat/self-improve-bus.ts +0 -110
- package/src/heartbeat/types.ts +0 -82
- package/src/index.ts +0 -1690
- package/src/llm/audio-config-store.ts +0 -246
- package/src/llm/config-store.ts +0 -400
- package/src/llm/llm-judgment-client.ts +0 -470
- package/src/llm/pi-ai.ts +0 -558
- package/src/llm/video-config-store.ts +0 -257
- package/src/network/agent-network.ts +0 -800
- package/src/network/hybrid-messenger.ts +0 -199
- package/src/network/iroh-bootstrap.ts +0 -57
- package/src/network/iroh-discovery.ts +0 -208
- package/src/network/iroh-integration.ts +0 -158
- package/src/network/iroh-transport.ts +0 -637
- package/src/network/known-peers.ts +0 -102
- package/src/network/p2p-direct.ts +0 -240
- package/src/network/p2p-secret.ts +0 -153
- package/src/network/p2p.ts +0 -964
- package/src/network/storage/adapters/json-adapter.ts +0 -454
- package/src/network/storage/index.ts +0 -203
- package/src/network/storage/types.ts +0 -166
- package/src/security/builtin-guards.ts +0 -162
- package/src/security/context-router-tool.ts +0 -122
- package/src/security/react-harness.ts +0 -177
- package/src/security/tool-gate.ts +0 -294
- package/src/social/ant-colony/index.js +0 -19
- package/src/social/channels/ChannelManager.ts +0 -485
- package/src/social/channels/DiapChannelBridge.ts +0 -501
- package/src/social/channels/InterestMatcher.ts +0 -189
- package/src/social/channels/agent-workflow-config.json +0 -214
- package/src/social/channels/agent-workflow-config.yaml +0 -334
- package/src/social/channels/channel-agent-session.ts +0 -407
- package/src/social/channels/channel-heartbeat-agent.ts +0 -622
- package/src/social/channels/diap-doc-parser.ts +0 -282
- package/src/social/channels/harness-workflow-integrator.ts +0 -594
- package/src/social/channels/index.ts +0 -22
- package/src/social/channels/types.ts +0 -115
- package/src/social/global-shared-context.ts +0 -506
- package/src/social/heartbeat.ts +0 -1057
- package/src/social/persona/enhanced-persona.ts +0 -359
- package/src/types.d.ts +0 -12
- package/src/utils/auto-evolve-policy.ts +0 -138
- package/src/utils/auto-update.ts +0 -482
- package/src/utils/clamp.ts +0 -5
- package/src/web/agent-delegate-server.ts +0 -148
- package/src/web/api-config.html +0 -520
- package/src/web/client.js +0 -4898
- package/src/web/components/p2p/P2PModal.tsx +0 -416
- package/src/web/components/p2p/index.ts +0 -566
- package/src/web/components/p2p/index.tsx +0 -297
- package/src/web/components/p2p/p2p-connection.ts +0 -338
- package/src/web/components/p2p/p2p-identity.ts +0 -92
- package/src/web/components/p2p/p2p-manager.ts +0 -147
- package/src/web/components/p2p/p2p-messages.ts +0 -219
- package/src/web/components/p2p/p2p-modal.ts +0 -685
- package/src/web/components/p2p/p2p-store-memory.ts +0 -162
- package/src/web/components/p2p/p2p-tools.ts +0 -315
- package/src/web/components/p2p/types.ts +0 -170
- package/src/web/components/wallet-viem.mjs +0 -118
- package/src/web/design.md +0 -99
- package/src/web/icons/apple-touch-icon.png +0 -0
- package/src/web/icons/favicon-16x16.png +0 -0
- package/src/web/icons/favicon-192x192.png +0 -0
- package/src/web/icons/favicon-32x32.png +0 -0
- package/src/web/icons/favicon-48x48.png +0 -0
- package/src/web/icons/favicon-512x512.png +0 -0
- package/src/web/icons/favicon.icns +0 -0
- package/src/web/icons/favicon.ico +0 -0
- package/src/web/icons/icon.png +0 -0
- package/src/web/icons/image.png +0 -0
- package/src/web/index.html +0 -382
- package/src/web/iroh-delegate-transport.ts +0 -139
- package/src/web/manifest.json +0 -21
- package/src/web/server.ts +0 -5571
- package/src/web/style.css +0 -4455
- package/staging/auto-evolve/clean-001/.review-verdict +0 -9
- package/staging/auto-evolve/clean-001/clean-001.patch +0 -14
- package/staging/auto-evolve/e2e-001/.patch-id +0 -1
- package/staging/auto-evolve/e2e-001/.review-verdict +0 -12
- package/staging/auto-evolve/e2e-001/e2e-001.patch +0 -11
- package/staging/auto-evolve/test-bad/.review-verdict +0 -12
- package/staging/auto-evolve/test-bad/test-bad.patch +0 -11
- package/tsconfig.cli.json +0 -16
- package/tsconfig.electron.json +0 -20
- package/tsconfig.json +0 -18
|
@@ -1,712 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM-native Judgment Engine
|
|
3
|
-
*
|
|
4
|
-
* 核心理念:
|
|
5
|
-
* - 不使用关键词匹配,而是让 LLM 理解用户意图
|
|
6
|
-
* - 价值观注入:学习人类判断价值观,注入到 Prompt 中
|
|
7
|
-
* - Skills 可以被动态调用
|
|
8
|
-
*
|
|
9
|
-
* 架构:
|
|
10
|
-
* 1. LLM-as-Judge: 使用 LLM 执行真正的理解
|
|
11
|
-
* 2. Value Injection: 从 human-value-store 获取价值观注入
|
|
12
|
-
* 3. Dynamic-Skill-Routing: 根据判断结果动态调用 Skills
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { createBollharnessIntegration } from './integration.js';
|
|
16
|
-
import {
|
|
17
|
-
generateJudgmentPromptWithValues,
|
|
18
|
-
type ValueInjectionConfig
|
|
19
|
-
} from '../pi-ecosystem-judgment/value-injection.js';
|
|
20
|
-
import {
|
|
21
|
-
learnFromFeedback,
|
|
22
|
-
learnFromCorrection
|
|
23
|
-
} from '../pi-ecosystem-judgment/human-value-store.js';
|
|
24
|
-
import { initPiAI, getModel, isModelAvailable } from '../llm/pi-ai.js';
|
|
25
|
-
import { getPiSDKConfig } from '../llm/config-store.js';
|
|
26
|
-
|
|
27
|
-
export interface LLMJudgmentResult {
|
|
28
|
-
// 理解结果
|
|
29
|
-
understanding: {
|
|
30
|
-
essence: string; // 问题本质
|
|
31
|
-
coreNeed: string; // 核心需求
|
|
32
|
-
implicit: string[]; // 隐含信息
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// 评估结果
|
|
36
|
-
assessment: {
|
|
37
|
-
complexity: 'simple' | 'moderate' | 'complex' | 'profound';
|
|
38
|
-
complexityReason: string; // 为什么是这个复杂性
|
|
39
|
-
depth: 'surface' | 'deeper' | 'fundamental';
|
|
40
|
-
urgency: 'low' | 'medium' | 'high' | 'critical';
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// 决策
|
|
44
|
-
decision: {
|
|
45
|
-
approach: 'answer' | 'analyze' | 'design' | 'implement' | 'coordinate';
|
|
46
|
-
reasoning: string; // 决策理由
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// 路由
|
|
50
|
-
routing: {
|
|
51
|
-
skills: string[]; // 应该调用的 Skills
|
|
52
|
-
agents: string[]; // 应该参与的智能体
|
|
53
|
-
collaboration: 'solo' | 'pair' | 'team';
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// 产物
|
|
57
|
-
artifacts: {
|
|
58
|
-
required: string[]; // 需要什么产物
|
|
59
|
-
gate?: number; // 如果需要 gate
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// 原始 LLM 输出
|
|
63
|
-
raw?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 判断用的 Prompt 模板(可以从 YAML 加载)
|
|
68
|
-
*/
|
|
69
|
-
export const JUDGMENT_PROMPT_TEMPLATE = `你是一个专业的 AI 任务分析专家。你的职责是深入理解用户的问题,并给出精准的判断。
|
|
70
|
-
|
|
71
|
-
【输入】
|
|
72
|
-
{user_input}
|
|
73
|
-
|
|
74
|
-
【历史上下文】
|
|
75
|
-
{history_context}
|
|
76
|
-
|
|
77
|
-
请分析以上输入,回答以下问题:
|
|
78
|
-
|
|
79
|
-
## 1. 问题理解
|
|
80
|
-
|
|
81
|
-
**问题本质**:用户真正想要什么?这是什么类型的问题?
|
|
82
|
-
- how-to: 寻求操作指导
|
|
83
|
-
- why: 寻求解释
|
|
84
|
-
- what: 寻求定义
|
|
85
|
-
- should: 寻求建议
|
|
86
|
-
- feasibility: 寻求可行性评估
|
|
87
|
-
|
|
88
|
-
**核心需求**:用户最想要的结果是什么?
|
|
89
|
-
|
|
90
|
-
**隐含信息**:有什么用户没有明确说但需要考虑的因素?
|
|
91
|
-
- 时间压力?
|
|
92
|
-
- 质量要求?
|
|
93
|
-
- 风险限制?
|
|
94
|
-
- 团队协作?
|
|
95
|
-
|
|
96
|
-
## 2. 复杂性评估
|
|
97
|
-
|
|
98
|
-
**复杂性等级**:这个问题有多复杂?
|
|
99
|
-
- simple: 简单任务,直接可答
|
|
100
|
-
- moderate: 中等复杂,需要一定思考
|
|
101
|
-
- complex: 复杂问题,需要深入分析
|
|
102
|
-
- profound: 深刻问题,需要本质性思考
|
|
103
|
-
|
|
104
|
-
**评估理由**:为什么认为这是这个复杂性等级?
|
|
105
|
-
|
|
106
|
-
**深度**:需要多深的理解?
|
|
107
|
-
- surface: 表面理解即可
|
|
108
|
-
- deeper: 需要分析
|
|
109
|
-
- fundamental: 需要本质性思考
|
|
110
|
-
|
|
111
|
-
## 3. 处理决策
|
|
112
|
-
|
|
113
|
-
**推荐方式**:
|
|
114
|
-
- answer: 直接回答
|
|
115
|
-
- analyze: 深入分析
|
|
116
|
-
- design: 设计方案
|
|
117
|
-
- implement: 实现代码
|
|
118
|
-
- coordinate: 协调多智能体
|
|
119
|
-
|
|
120
|
-
**决策理由**:为什么推荐这个处理方式?
|
|
121
|
-
|
|
122
|
-
## 4. 路由决策
|
|
123
|
-
|
|
124
|
-
**应该调用的 Skills**(可选多个):
|
|
125
|
-
- arch: 架构设计
|
|
126
|
-
- harness-dev: 开发实现
|
|
127
|
-
- guardian-fixer: 代码审查
|
|
128
|
-
- harness-eng: 工程协调
|
|
129
|
-
- harness-eng-test: 测试工程
|
|
130
|
-
- task-arch: 任务分解
|
|
131
|
-
- crystal-learn: 反思学习
|
|
132
|
-
|
|
133
|
-
**参与智能体**(可选):
|
|
134
|
-
- architect: 架构师
|
|
135
|
-
- developer: 开发者
|
|
136
|
-
- reviewer: 审查员
|
|
137
|
-
- coordinator: 协调者
|
|
138
|
-
|
|
139
|
-
**协作模式**:
|
|
140
|
-
- solo: 单独处理
|
|
141
|
-
- pair: 配对协作
|
|
142
|
-
- team: 团队协作
|
|
143
|
-
|
|
144
|
-
## 5. 产出要求
|
|
145
|
-
|
|
146
|
-
**需要的产物**:
|
|
147
|
-
- 问题分析
|
|
148
|
-
- 方案设计
|
|
149
|
-
- 代码实现
|
|
150
|
-
- 测试用例
|
|
151
|
-
- 其他
|
|
152
|
-
|
|
153
|
-
**Gate 建议**(如果有):
|
|
154
|
-
- Gate 0: 问题锁定
|
|
155
|
-
- Gate 1: 架构设计
|
|
156
|
-
- Gate 2: 架构审查
|
|
157
|
-
- Gate 3: 计划制定
|
|
158
|
-
- Gate 4: 计划审查
|
|
159
|
-
- Gate 5: 任务分解
|
|
160
|
-
- Gate 6: 任务审查
|
|
161
|
-
- Gate 7: 代码实现
|
|
162
|
-
- Gate 8: 测试验证
|
|
163
|
-
|
|
164
|
-
请用 JSON 格式输出分析结果。`;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 简化的判断结果(用于快速场景)
|
|
168
|
-
*/
|
|
169
|
-
export interface QuickJudgment {
|
|
170
|
-
complexity: 'simple' | 'moderate' | 'complex' | 'profound';
|
|
171
|
-
approach: 'answer' | 'analyze' | 'design' | 'implement' | 'coordinate';
|
|
172
|
-
skills: string[];
|
|
173
|
-
collaboration: 'solo' | 'pair' | 'team';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* LLM-native Judgment Engine
|
|
178
|
-
*/
|
|
179
|
-
export class LLMJudgmentEngine {
|
|
180
|
-
private harness: ReturnType<typeof createBollharnessIntegration>;
|
|
181
|
-
private promptTemplate: string;
|
|
182
|
-
private useLLM: boolean;
|
|
183
|
-
private valueInjectionConfig: Partial<ValueInjectionConfig>;
|
|
184
|
-
private recentJudgments: Array<{
|
|
185
|
-
input: string;
|
|
186
|
-
result: LLMJudgmentResult;
|
|
187
|
-
timestamp: number;
|
|
188
|
-
}> = [];
|
|
189
|
-
|
|
190
|
-
constructor(options?: {
|
|
191
|
-
useLLM?: boolean;
|
|
192
|
-
promptTemplate?: string;
|
|
193
|
-
valueInjectionConfig?: Partial<ValueInjectionConfig>;
|
|
194
|
-
}) {
|
|
195
|
-
this.harness = createBollharnessIntegration();
|
|
196
|
-
this.promptTemplate = options?.promptTemplate || JUDGMENT_PROMPT_TEMPLATE;
|
|
197
|
-
this.useLLM = options?.useLLM ?? true;
|
|
198
|
-
this.valueInjectionConfig = options?.valueInjectionConfig || {};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* 设置判断用的 Prompt 模板
|
|
203
|
-
*/
|
|
204
|
-
setPromptTemplate(template: string): void {
|
|
205
|
-
this.promptTemplate = template;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* 设置价值观注入配置
|
|
210
|
-
*/
|
|
211
|
-
setValueInjectionConfig(config: Partial<ValueInjectionConfig>): void {
|
|
212
|
-
this.valueInjectionConfig = config;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 从配置文件加载 Prompt
|
|
217
|
-
*/
|
|
218
|
-
async loadPromptFromConfig(configPath: string): Promise<void> {
|
|
219
|
-
// TODO: 从 YAML/JSON 加载 prompt 模板
|
|
220
|
-
// 这个配置可以包含更复杂的 prompt 变体
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* 执行 LLM 判断(集成价值观注入)
|
|
225
|
-
*/
|
|
226
|
-
async judge(
|
|
227
|
-
userInput: string,
|
|
228
|
-
options?: {
|
|
229
|
-
history?: string[];
|
|
230
|
-
forceLLM?: boolean;
|
|
231
|
-
context?: string;
|
|
232
|
-
}
|
|
233
|
-
): Promise<LLMJudgmentResult> {
|
|
234
|
-
// 如果强制不使用 LLM 或未配置,使用简化判断
|
|
235
|
-
if (!this.useLLM && !options?.forceLLM) {
|
|
236
|
-
return this.quickJudge(userInput);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// 构建 prompt(带价值观注入)
|
|
240
|
-
const historyContext = options?.history
|
|
241
|
-
? options.history.slice(-5).join('\n')
|
|
242
|
-
: '无历史上下文';
|
|
243
|
-
|
|
244
|
-
const context = options?.context || userInput;
|
|
245
|
-
|
|
246
|
-
// 生成带价值观的 prompt
|
|
247
|
-
let prompt: string;
|
|
248
|
-
try {
|
|
249
|
-
prompt = await generateJudgmentPromptWithValues(
|
|
250
|
-
userInput,
|
|
251
|
-
context,
|
|
252
|
-
options?.history || [],
|
|
253
|
-
this.valueInjectionConfig
|
|
254
|
-
);
|
|
255
|
-
} catch (error) {
|
|
256
|
-
// 价值观注入失败,使用基础 prompt
|
|
257
|
-
console.warn('[LLMJudgment] Value injection failed, using base prompt:', error);
|
|
258
|
-
prompt = this.promptTemplate
|
|
259
|
-
.replace('{user_input}', userInput)
|
|
260
|
-
.replace('{history_context}', historyContext);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
try {
|
|
264
|
-
// 调用 LLM(这里需要集成 LLMConfigStore)
|
|
265
|
-
const result = await this.callLLM(prompt);
|
|
266
|
-
|
|
267
|
-
// 解析 LLM 输出
|
|
268
|
-
const judgmentResult = this.parseLLMOutput(result, userInput);
|
|
269
|
-
|
|
270
|
-
// 记录判断结果(用于学习)
|
|
271
|
-
this.recordJudgment(userInput, judgmentResult);
|
|
272
|
-
|
|
273
|
-
return judgmentResult;
|
|
274
|
-
} catch (error) {
|
|
275
|
-
console.warn('[LLMJudgment] LLM call failed, falling back to quick judgment:', error);
|
|
276
|
-
return this.quickJudge(userInput);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* 记录判断结果(支持后续学习)
|
|
282
|
-
*/
|
|
283
|
-
private recordJudgment(input: string, result: LLMJudgmentResult): void {
|
|
284
|
-
this.recentJudgments.push({
|
|
285
|
-
input,
|
|
286
|
-
result,
|
|
287
|
-
timestamp: Date.now()
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
// 保留最近 50 条判断
|
|
291
|
-
if (this.recentJudgments.length > 50) {
|
|
292
|
-
this.recentJudgments.shift();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* 学习人类反馈(集成到判断引擎)
|
|
298
|
-
*/
|
|
299
|
-
async learnFromHumanFeedback(
|
|
300
|
-
originalInput: string,
|
|
301
|
-
approved: boolean,
|
|
302
|
-
reason?: string
|
|
303
|
-
): Promise<void> {
|
|
304
|
-
// 从反馈中学习
|
|
305
|
-
await learnFromFeedback(originalInput, approved, reason);
|
|
306
|
-
|
|
307
|
-
// 重新评估相关判断的置信度
|
|
308
|
-
const relatedJudgment = this.recentJudgments.find(
|
|
309
|
-
j => j.input.includes(originalInput.substring(0, 20))
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
if (relatedJudgment && !approved) {
|
|
313
|
-
// 如果被拒绝,降低置信度
|
|
314
|
-
console.log('[LLMJudgment] Learning from rejection, will adjust future judgments');
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* 学习修正(从错误中学习)
|
|
320
|
-
*/
|
|
321
|
-
async learnFromCorrection(original: string, corrected: string, reason: string): Promise<void> {
|
|
322
|
-
await learnFromCorrection(original, corrected, reason);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* 调用 LLM
|
|
327
|
-
*/
|
|
328
|
-
private async callLLM(prompt: string): Promise<string> {
|
|
329
|
-
if (!isModelAvailable()) {
|
|
330
|
-
const config = getPiSDKConfig();
|
|
331
|
-
initPiAI(config);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const model = getModel();
|
|
335
|
-
const result = await model.chat(prompt, process.cwd());
|
|
336
|
-
return result.reply;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* 解析 LLM 输出
|
|
341
|
-
*/
|
|
342
|
-
private parseLLMOutput(output: string, originalInput: string): LLMJudgmentResult {
|
|
343
|
-
try {
|
|
344
|
-
// 尝试解析 JSON
|
|
345
|
-
const parsed = JSON.parse(output);
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
understanding: {
|
|
349
|
-
essence: parsed.essence || parsed.问题本质 || 'unknown',
|
|
350
|
-
coreNeed: parsed.coreNeed || parsed.核心需求 || 'unknown',
|
|
351
|
-
implicit: parsed.implicit || parsed.隐含信息 || []
|
|
352
|
-
},
|
|
353
|
-
assessment: {
|
|
354
|
-
complexity: this.normalizeComplexity(parsed.complexity || parsed.复杂性等级),
|
|
355
|
-
complexityReason: parsed.complexityReason || parsed.评估理由 || '',
|
|
356
|
-
depth: this.normalizeDepth(parsed.depth || parsed.深度),
|
|
357
|
-
urgency: this.normalizeUrgency(parsed.urgency || 'medium')
|
|
358
|
-
},
|
|
359
|
-
decision: {
|
|
360
|
-
approach: this.normalizeApproach(parsed.approach || parsed.推荐方式),
|
|
361
|
-
reasoning: parsed.reasoning || parsed.决策理由 || ''
|
|
362
|
-
},
|
|
363
|
-
routing: {
|
|
364
|
-
skills: parsed.skills || parsed.应该调用的Skills || [],
|
|
365
|
-
agents: parsed.agents || parsed.参与智能体 || [],
|
|
366
|
-
collaboration: this.normalizeCollaboration(parsed.collaboration || parsed.协作模式)
|
|
367
|
-
},
|
|
368
|
-
artifacts: {
|
|
369
|
-
required: parsed.artifacts || parsed.需要的产物 || [],
|
|
370
|
-
gate: parsed.gate || parsed.Gate建议
|
|
371
|
-
},
|
|
372
|
-
raw: output
|
|
373
|
-
};
|
|
374
|
-
} catch {
|
|
375
|
-
// JSON 解析失败,返回默认结果
|
|
376
|
-
return this.quickJudge(originalInput);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* 快速判断(不调用 LLM)
|
|
382
|
-
*/
|
|
383
|
-
private quickJudge(userInput: string): LLMJudgmentResult {
|
|
384
|
-
const input = userInput.toLowerCase();
|
|
385
|
-
const words = userInput.length;
|
|
386
|
-
|
|
387
|
-
// 复杂性评估
|
|
388
|
-
let complexity: 'simple' | 'moderate' | 'complex' | 'profound' = 'moderate';
|
|
389
|
-
let complexityReason = '';
|
|
390
|
-
|
|
391
|
-
const hasDesignKeywords = input.includes('设计') || input.includes('架构');
|
|
392
|
-
const hasReviewKeywords = input.includes('review') || input.includes('审查');
|
|
393
|
-
const hasMultiSystem = input.includes('和') || input.includes('以及');
|
|
394
|
-
const hasFundamental = input.includes('为什么') || input.includes('本质') || input.includes('根本');
|
|
395
|
-
|
|
396
|
-
if (hasDesignKeywords || hasMultiSystem || words > 200) {
|
|
397
|
-
complexity = 'complex';
|
|
398
|
-
complexityReason = '涉及设计或多系统';
|
|
399
|
-
}
|
|
400
|
-
if (hasFundamental || (words > 500 && hasDesignKeywords)) {
|
|
401
|
-
complexity = 'profound';
|
|
402
|
-
complexityReason = '需要本质性思考';
|
|
403
|
-
}
|
|
404
|
-
if (words < 50 && !hasDesignKeywords) {
|
|
405
|
-
complexity = 'simple';
|
|
406
|
-
complexityReason = '简短输入,意图明确';
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// 处理方式
|
|
410
|
-
let approach: LLMJudgmentResult['decision']['approach'] = 'answer';
|
|
411
|
-
if (hasDesignKeywords) approach = 'design';
|
|
412
|
-
else if (hasReviewKeywords || input.includes('分析')) approach = 'analyze';
|
|
413
|
-
else if (input.includes('实现') || input.includes('写')) approach = 'implement';
|
|
414
|
-
|
|
415
|
-
// Skills
|
|
416
|
-
const skills: string[] = [];
|
|
417
|
-
if (hasDesignKeywords) skills.push('arch');
|
|
418
|
-
if (hasReviewKeywords) skills.push('guardian-fixer');
|
|
419
|
-
if (approach === 'implement') skills.push('harness-dev');
|
|
420
|
-
if (complexity === 'complex' || complexity === 'profound') {
|
|
421
|
-
skills.push('harness-eng');
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// 协作模式
|
|
425
|
-
const collaboration: LLMJudgmentResult['routing']['collaboration'] =
|
|
426
|
-
complexity === 'profound' ? 'team' :
|
|
427
|
-
complexity === 'complex' ? 'pair' : 'solo';
|
|
428
|
-
|
|
429
|
-
return {
|
|
430
|
-
understanding: {
|
|
431
|
-
essence: this.extractEssence(input),
|
|
432
|
-
coreNeed: this.extractCoreNeed(input),
|
|
433
|
-
implicit: []
|
|
434
|
-
},
|
|
435
|
-
assessment: {
|
|
436
|
-
complexity,
|
|
437
|
-
complexityReason,
|
|
438
|
-
depth: hasFundamental ? 'fundamental' : 'surface',
|
|
439
|
-
urgency: input.includes('紧急') ? 'high' : 'medium'
|
|
440
|
-
},
|
|
441
|
-
decision: {
|
|
442
|
-
approach,
|
|
443
|
-
reasoning: '基于快速模式判断'
|
|
444
|
-
},
|
|
445
|
-
routing: {
|
|
446
|
-
skills,
|
|
447
|
-
agents: [],
|
|
448
|
-
collaboration
|
|
449
|
-
},
|
|
450
|
-
artifacts: {
|
|
451
|
-
required: approach === 'design' ? ['架构文档'] : ['回答']
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
private normalizeComplexity(c: string): LLMJudgmentResult['assessment']['complexity'] {
|
|
457
|
-
const lower = c.toLowerCase();
|
|
458
|
-
if (lower.includes('simple') || lower.includes('简单')) return 'simple';
|
|
459
|
-
if (lower.includes('moderate') || lower.includes('中等')) return 'moderate';
|
|
460
|
-
if (lower.includes('complex') || lower.includes('复杂')) return 'complex';
|
|
461
|
-
return 'profound';
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
private normalizeDepth(d: string): LLMJudgmentResult['assessment']['depth'] {
|
|
465
|
-
const lower = d.toLowerCase();
|
|
466
|
-
if (lower.includes('surface') || lower.includes('表面')) return 'surface';
|
|
467
|
-
if (lower.includes('deeper') || lower.includes('深入')) return 'deeper';
|
|
468
|
-
return 'fundamental';
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
private normalizeUrgency(u: string): LLMJudgmentResult['assessment']['urgency'] {
|
|
472
|
-
const lower = u.toLowerCase();
|
|
473
|
-
if (lower.includes('low') || lower.includes('低')) return 'low';
|
|
474
|
-
if (lower.includes('high') || lower.includes('高') || lower.includes('紧急')) return 'high';
|
|
475
|
-
if (lower.includes('critical') || lower.includes('关键')) return 'critical';
|
|
476
|
-
return 'medium';
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
private normalizeApproach(a: string): LLMJudgmentResult['decision']['approach'] {
|
|
480
|
-
const lower = a.toLowerCase();
|
|
481
|
-
if (lower.includes('answer') || lower.includes('回答')) return 'answer';
|
|
482
|
-
if (lower.includes('analyze') || lower.includes('分析')) return 'analyze';
|
|
483
|
-
if (lower.includes('design') || lower.includes('设计')) return 'design';
|
|
484
|
-
if (lower.includes('implement') || lower.includes('实现')) return 'implement';
|
|
485
|
-
return 'coordinate';
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
private normalizeCollaboration(c: string): LLMJudgmentResult['routing']['collaboration'] {
|
|
489
|
-
const lower = c.toLowerCase();
|
|
490
|
-
if (lower.includes('solo') || lower.includes('单独')) return 'solo';
|
|
491
|
-
if (lower.includes('pair') || lower.includes('配对')) return 'pair';
|
|
492
|
-
return 'team';
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
private extractEssence(input: string): string {
|
|
496
|
-
if (input.includes('为什么')) return 'why: 寻求解释';
|
|
497
|
-
if (input.includes('怎么') || input.includes('如何')) return 'how-to: 寻求指导';
|
|
498
|
-
if (input.includes('应该')) return 'should: 寻求建议';
|
|
499
|
-
return 'general: 一般性讨论';
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
private extractCoreNeed(input: string): string {
|
|
503
|
-
const lower = input.toLowerCase();
|
|
504
|
-
if (lower.includes('设计') || lower.includes('架构')) return '设计方案';
|
|
505
|
-
if (lower.includes('实现') || lower.includes('写')) return '实现代码';
|
|
506
|
-
if (lower.includes('修复') || lower.includes('解决')) return '修复问题';
|
|
507
|
-
if (lower.includes('review') || lower.includes('审查')) return '审查代码';
|
|
508
|
-
return '获得帮助';
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// 单例
|
|
513
|
-
let engineInstance: LLMJudgmentEngine | null = null;
|
|
514
|
-
|
|
515
|
-
export function createLLMJudgmentEngine(options?: {
|
|
516
|
-
useLLM?: boolean;
|
|
517
|
-
promptTemplate?: string;
|
|
518
|
-
}): LLMJudgmentEngine {
|
|
519
|
-
return new LLMJudgmentEngine(options);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export function getLLMJudgmentEngine(): LLMJudgmentEngine {
|
|
523
|
-
if (!engineInstance) {
|
|
524
|
-
engineInstance = new LLMJudgmentEngine();
|
|
525
|
-
}
|
|
526
|
-
return engineInstance;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Skill Prompt 配置(可以从 YAML 加载)
|
|
531
|
-
*/
|
|
532
|
-
export interface SkillPromptConfig {
|
|
533
|
-
name: string;
|
|
534
|
-
description: string;
|
|
535
|
-
systemPrompt: string; // 系统级 prompt
|
|
536
|
-
userPromptTemplate: string; // 用户输入的 prompt 模板
|
|
537
|
-
examples?: Array<{
|
|
538
|
-
input: string;
|
|
539
|
-
output: string;
|
|
540
|
-
}>;
|
|
541
|
-
constraints?: string[];
|
|
542
|
-
outputFormat?: string;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Skills 的 Prompt 配置
|
|
547
|
-
*/
|
|
548
|
-
export const SKILL_PROMPTS: Record<string, SkillPromptConfig> = {
|
|
549
|
-
arch: {
|
|
550
|
-
name: 'arch',
|
|
551
|
-
description: '架构设计专家',
|
|
552
|
-
systemPrompt: `你是一个经验丰富的系统架构师。你擅长:
|
|
553
|
-
- 从需求中提取本质问题
|
|
554
|
-
- 设计可扩展的系统架构
|
|
555
|
-
- 权衡技术方案
|
|
556
|
-
- 识别架构风险
|
|
557
|
-
|
|
558
|
-
你相信:
|
|
559
|
-
- 本质和实现必须分离
|
|
560
|
-
- 好的架构从简单规则中生长
|
|
561
|
-
- 复杂性应该被控制而非消除`,
|
|
562
|
-
userPromptTemplate: `用户需求:{user_input}
|
|
563
|
-
|
|
564
|
-
{context}
|
|
565
|
-
|
|
566
|
-
请进行架构分析:`,
|
|
567
|
-
examples: [
|
|
568
|
-
{
|
|
569
|
-
input: '设计一个电商系统',
|
|
570
|
-
output: '我将首先分析电商系统的核心本质:交易撮合...'
|
|
571
|
-
}
|
|
572
|
-
],
|
|
573
|
-
outputFormat: 'markdown'
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
'harness-dev': {
|
|
577
|
-
name: 'harness-dev',
|
|
578
|
-
description: '开发实现专家',
|
|
579
|
-
systemPrompt: `你是一个高效的代码实现专家。你擅长:
|
|
580
|
-
- 快速理解和实现需求
|
|
581
|
-
- 编写清晰、可维护的代码
|
|
582
|
-
- 遵循最佳实践
|
|
583
|
-
- 处理边界情况
|
|
584
|
-
|
|
585
|
-
你相信:
|
|
586
|
-
- 代码即文档
|
|
587
|
-
- 测试是代码的一部分
|
|
588
|
-
- 简单优于复杂`,
|
|
589
|
-
userPromptTemplate: `任务:{user_input}
|
|
590
|
-
|
|
591
|
-
技术栈:{tech_stack}
|
|
592
|
-
|
|
593
|
-
请实现代码:`,
|
|
594
|
-
outputFormat: 'code'
|
|
595
|
-
},
|
|
596
|
-
|
|
597
|
-
'guardian-fixer': {
|
|
598
|
-
name: 'guardian-fixer',
|
|
599
|
-
description: '代码审查专家',
|
|
600
|
-
systemPrompt: `你是一个严格的代码审查专家。你擅长:
|
|
601
|
-
- 发现潜在问题
|
|
602
|
-
- 提出改进建议
|
|
603
|
-
- 确保代码质量
|
|
604
|
-
- 平衡效率和安全性
|
|
605
|
-
|
|
606
|
-
你相信:
|
|
607
|
-
- 细节决定成败
|
|
608
|
-
- 代码审查是质量保障的最后防线
|
|
609
|
-
- 建设性批评比否定更有价值`,
|
|
610
|
-
userPromptTemplate: `代码:\n{code}
|
|
611
|
-
|
|
612
|
-
审查范围:{scope}
|
|
613
|
-
|
|
614
|
-
请进行审查:`,
|
|
615
|
-
outputFormat: 'structured'
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* 动态 Skill 调用器
|
|
621
|
-
*/
|
|
622
|
-
export class DynamicSkillRouter {
|
|
623
|
-
private skillPrompts: Record<string, SkillPromptConfig>;
|
|
624
|
-
private judgmentEngine: LLMJudgmentEngine;
|
|
625
|
-
|
|
626
|
-
constructor(options?: { useLLM?: boolean }) {
|
|
627
|
-
this.skillPrompts = SKILL_PROMPTS;
|
|
628
|
-
this.judgmentEngine = createLLMJudgmentEngine({ useLLM: options?.useLLM ?? true });
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* 根据判断结果动态调用 Skills
|
|
633
|
-
*/
|
|
634
|
-
async routeAndExecute(
|
|
635
|
-
userInput: string,
|
|
636
|
-
judgment: LLMJudgmentResult,
|
|
637
|
-
context?: Record<string, unknown>
|
|
638
|
-
): Promise<Record<string, unknown>> {
|
|
639
|
-
const results: Record<string, unknown> = {};
|
|
640
|
-
|
|
641
|
-
// 并行执行多个 Skills
|
|
642
|
-
const skillPromises = judgment.routing.skills.map(async (skillName) => {
|
|
643
|
-
const skillConfig = this.skillPrompts[skillName];
|
|
644
|
-
if (!skillConfig) {
|
|
645
|
-
console.warn(`[SkillRouter] Unknown skill: ${skillName}`);
|
|
646
|
-
return { skill: skillName, result: null };
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
try {
|
|
650
|
-
const result = await this.executeSkill(
|
|
651
|
-
skillConfig,
|
|
652
|
-
userInput,
|
|
653
|
-
context
|
|
654
|
-
);
|
|
655
|
-
return { skill: skillName, result };
|
|
656
|
-
} catch (error) {
|
|
657
|
-
console.error(`[SkillRouter] Skill ${skillName} failed:`, error);
|
|
658
|
-
return { skill: skillName, result: null, error };
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
const skillResults = await Promise.all(skillPromises);
|
|
663
|
-
|
|
664
|
-
for (const { skill, result, error } of skillResults) {
|
|
665
|
-
results[skill] = result || { error: String(error) };
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return results;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* 执行单个 Skill
|
|
673
|
-
*/
|
|
674
|
-
private async executeSkill(
|
|
675
|
-
skillConfig: SkillPromptConfig,
|
|
676
|
-
userInput: string,
|
|
677
|
-
context?: Record<string, unknown>
|
|
678
|
-
): Promise<string> {
|
|
679
|
-
// 构建 prompt
|
|
680
|
-
let prompt = skillConfig.userPromptTemplate.replace('{user_input}', userInput);
|
|
681
|
-
|
|
682
|
-
if (context) {
|
|
683
|
-
for (const [key, value] of Object.entries(context)) {
|
|
684
|
-
prompt = prompt.replace(`{${key}}`, String(value));
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// TODO: 调用 LLM 执行 Skill
|
|
689
|
-
// 这里需要集成实际的 LLM 调用
|
|
690
|
-
|
|
691
|
-
return `Skill ${skillConfig.name} executed with prompt:\n${prompt}`;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* 添加自定义 Skill
|
|
696
|
-
*/
|
|
697
|
-
registerSkill(name: string, config: SkillPromptConfig): void {
|
|
698
|
-
this.skillPrompts[name] = config;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* 获取可用的 Skills
|
|
703
|
-
*/
|
|
704
|
-
listSkills(): string[] {
|
|
705
|
-
return Object.keys(this.skillPrompts);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// 导出工厂函数
|
|
710
|
-
export function createDynamicSkillRouter(options?: { useLLM?: boolean }): DynamicSkillRouter {
|
|
711
|
-
return new DynamicSkillRouter(options);
|
|
712
|
-
}
|