@bolloon/bolloon-agent 0.1.36 → 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/dist/web/client.js +2861 -3746
- package/dist/web/components/p2p/index.js +226 -264
- package/dist/web/ui/message-renderer.js +323 -434
- package/dist/web/ui/step-timeline.js +255 -351
- package/package.json +2 -2
- package/.auto-evolve-calls +0 -1
- package/.last-auto-evolve-baseline +0 -1
- package/.playwright-mcp/page-2026-06-16T07-51-45-706Z.yml +0 -130
- package/.playwright-mcp/page-2026-06-16T07-56-44-116Z.yml +0 -131
- package/Bolloon.md +0 -144
- package/Dive-into/CITATION.cff +0 -17
- package/Dive-into/LICENSE +0 -25
- package/Dive-into/README.md +0 -598
- package/Dive-into/README_zh.md +0 -599
- package/Dive-into/assets/context.png +0 -0
- package/Dive-into/assets/extensibility.png +0 -0
- package/Dive-into/assets/iteration.png +0 -0
- package/Dive-into/assets/layered_architecture.png +0 -0
- package/Dive-into/assets/main_structure.png +0 -0
- package/Dive-into/assets/permission.png +0 -0
- package/Dive-into/assets/session_compact.png +0 -0
- package/Dive-into/assets/subagent.png +0 -0
- package/Dive-into/paper/Dive_into_Claude_Code.pdf +0 -0
- 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/dist/web/components/p2p/P2PModal.js +0 -188
- package/dist/web/components/p2p/p2p-modal.js +0 -657
- package/dist/web/components/p2p/p2p-tools.js +0 -248
- package/lefthook.yml +0 -33
- package/scripts/auto-evolve-loop.ts +0 -481
- 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 -116
- package/scripts/detect-schema-changes.sh +0 -48
- package/scripts/diff-reviewer.ts +0 -159
- package/scripts/postinstall.js +0 -153
- package/scripts/validate-system-prompt.ts +0 -142
- 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/permission-mode.ts +0 -127
- package/src/agents/pi-sdk.ts +0 -2895
- package/src/agents/pre-tool-validator.ts +0 -213
- 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 -766
- 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 -135
- package/src/bootstrap/context-collector.ts +0 -371
- package/src/bootstrap/context-hierarchy.ts +0 -283
- package/src/bootstrap/lifecycle-hooks.ts +0 -289
- package/src/bootstrap/project-context.ts +0 -171
- package/src/cli/interface.ts +0 -211
- package/src/cli-entry.ts +0 -304
- package/src/constraints/index.ts +0 -6
- package/src/context-compaction/auto-compact.ts +0 -153
- package/src/context-compaction/budget-gate.ts +0 -32
- package/src/context-compaction/budget-reduce.ts +0 -37
- package/src/context-compaction/context-collapse.ts +0 -72
- package/src/context-compaction/index.ts +0 -24
- package/src/context-compaction/microcompact.ts +0 -54
- package/src/context-compaction/pipeline.ts +0 -133
- package/src/context-compaction/snip.ts +0 -51
- package/src/context-compaction/token-estimator.ts +0 -36
- package/src/context-compaction/types.ts +0 -99
- 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 -317
- 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 -1724
- 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 -471
- package/src/llm/pi-ai.ts +0 -653
- package/src/llm/system-prompt/health.ts +0 -159
- package/src/llm/system-prompt/layers/channel/local.md +0 -14
- package/src/llm/system-prompt/layers/channel/p2p-agent.md +0 -18
- package/src/llm/system-prompt/layers/channel/p2p-visitor.md +0 -19
- package/src/llm/system-prompt/layers/core/artifacts_storage.md +0 -89
- package/src/llm/system-prompt/layers/core/evenhandedness.md +0 -21
- package/src/llm/system-prompt/layers/core/hibs_reminders.md +0 -15
- package/src/llm/system-prompt/layers/core/identity.md +0 -37
- package/src/llm/system-prompt/layers/core/knowledge.md +0 -17
- package/src/llm/system-prompt/layers/core/memory_system.md +0 -12
- package/src/llm/system-prompt/layers/core/network_filesystem.md +0 -28
- package/src/llm/system-prompt/layers/core/refusal.md +0 -37
- package/src/llm/system-prompt/layers/core/tone.md +0 -31
- package/src/llm/system-prompt/layers/core/tools.thin.md +0 -13
- package/src/llm/system-prompt/layers/core/wellbeing.md +0 -41
- package/src/llm/system-prompt/layers/role/architect.md +0 -20
- package/src/llm/system-prompt/layers/role/expert.md +0 -19
- package/src/llm/system-prompt/layers/role/implementer.md +0 -15
- package/src/llm/system-prompt/layers/role/security.md +0 -15
- package/src/llm/system-prompt/layers/tool/artifacts.md +0 -72
- package/src/llm/system-prompt/layers/tool/bash.md +0 -25
- package/src/llm/system-prompt/layers/tool/hibs_api.md +0 -171
- package/src/llm/system-prompt/layers/tool/image_search.md +0 -70
- package/src/llm/system-prompt/layers/tool/manifest.md +0 -89
- package/src/llm/system-prompt/layers/tool/mcp_apps.md +0 -53
- package/src/llm/system-prompt/layers/tool/web_search.md +0 -83
- package/src/llm/system-prompt/registry.ts +0 -325
- package/src/llm/system-prompt/strip-hibsml.ts +0 -52
- package/src/llm/tool-manifest/ask_user_input.ts +0 -37
- package/src/llm/tool-manifest/bash.ts +0 -25
- package/src/llm/tool-manifest/create_file.ts +0 -26
- package/src/llm/tool-manifest/fetch_sports_data.ts +0 -28
- package/src/llm/tool-manifest/image_search.ts +0 -26
- package/src/llm/tool-manifest/index.ts +0 -88
- package/src/llm/tool-manifest/mcp.ts +0 -46
- package/src/llm/tool-manifest/message_compose.ts +0 -33
- package/src/llm/tool-manifest/places.ts +0 -86
- package/src/llm/tool-manifest/present_files.ts +0 -23
- package/src/llm/tool-manifest/recipe.ts +0 -42
- package/src/llm/tool-manifest/recommend_apps.ts +0 -25
- package/src/llm/tool-manifest/str_replace.ts +0 -29
- package/src/llm/tool-manifest/types.ts +0 -52
- package/src/llm/tool-manifest/view.ts +0 -26
- package/src/llm/tool-manifest/weather.ts +0 -29
- package/src/llm/tool-manifest/web.ts +0 -54
- 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 -262
- package/src/network/p2p-secret.ts +0 -153
- package/src/network/p2p.ts +0 -964
- package/src/network/source-intent-broadcaster.ts +0 -242
- package/src/network/source-intent.ts +0 -167
- 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/input-scanner.ts +0 -287
- 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 -2352
- package/src/web/client.ts +0 -4326
- 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 -373
- package/src/web/iroh-delegate-transport.ts +0 -139
- package/src/web/manifest.json +0 -21
- package/src/web/server.ts +0 -5731
- package/src/web/style.css +0 -4737
- package/src/web/ui/message-renderer.ts +0 -540
- package/src/web/ui/step-timeline.ts +0 -394
- 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/test-results/.last-run.json +0 -6
- package/test-results/src-test-web-loop-status-b-5734c-atus-bar-/346/230/276/347/244/272-spinner-/344/270/215/346/230/276/347/244/272/345/276/252/347/216/257/350/256/241/346/225/260/error-context.md +0 -285
- package/tsconfig.cli.json +0 -16
- package/tsconfig.electron.json +0 -20
- package/tsconfig.json +0 -18
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# auto-evolve-snapshot.sh — 阶段 C 护栏 2 + 3
|
|
3
|
-
#
|
|
4
|
-
# 用法 (LLM 改源码前必调):
|
|
5
|
-
# bash scripts/auto-evolve-snapshot.sh # 打 baseline tag + 记当前 HEAD
|
|
6
|
-
# bash scripts/auto-evolve-snapshot.sh apply <patch-id> # 人类批准后合并 staging → main
|
|
7
|
-
# bash scripts/auto-evolve-snapshot.sh list # 列所有 baseline
|
|
8
|
-
# bash scripts/auto-evolve-snapshot.sh rollback <tag> # 回滚到指定 baseline
|
|
9
|
-
#
|
|
10
|
-
# 流程:
|
|
11
|
-
# 1. LLM 改之前调 snapshot: 当前 HEAD 打 auto-evolve-baseline-<ts> tag
|
|
12
|
-
# 2. LLM 改 staging/auto-evolve/<patch-id>/ (不进 src/)
|
|
13
|
-
# 3. 护栏 1 (lefthook) 跑 vitest + tsc, 坏就 abort
|
|
14
|
-
# 4. 护栏 4 (reviewer hook) 审 diff, 通过才准 apply
|
|
15
|
-
# 5. 人类调 apply: git apply staging/auto-evolve/<patch-id>/*.patch → src/
|
|
16
|
-
# 6. 出问题: 调 rollback → git reset --hard <tag>
|
|
17
|
-
|
|
18
|
-
set -euo pipefail
|
|
19
|
-
|
|
20
|
-
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
21
|
-
cd "$REPO_ROOT"
|
|
22
|
-
|
|
23
|
-
STAGING_DIR="staging/auto-evolve"
|
|
24
|
-
TAG_PREFIX="auto-evolve-baseline-"
|
|
25
|
-
|
|
26
|
-
cmd="${1:-snapshot}"
|
|
27
|
-
patch_id="${2:-}"
|
|
28
|
-
|
|
29
|
-
case "$cmd" in
|
|
30
|
-
snapshot)
|
|
31
|
-
# 护栏 2: 打 baseline tag
|
|
32
|
-
if ! git diff --quiet HEAD 2>/dev/null; then
|
|
33
|
-
echo "❌ 有未提交改动. 先 git commit 或 git stash"
|
|
34
|
-
exit 1
|
|
35
|
-
fi
|
|
36
|
-
ts="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
37
|
-
tag="${TAG_PREFIX}${ts}"
|
|
38
|
-
git tag -a "$tag" -m "auto-evolve baseline @ ${ts}" HEAD
|
|
39
|
-
echo "✅ baseline tag: $tag"
|
|
40
|
-
echo "$tag" > .last-auto-evolve-baseline
|
|
41
|
-
echo " 回滚命令: bash $0 rollback $tag"
|
|
42
|
-
;;
|
|
43
|
-
|
|
44
|
-
prepare)
|
|
45
|
-
# LLM 改之前调: 创建 staging 目录
|
|
46
|
-
if [ -z "$patch_id" ]; then
|
|
47
|
-
echo "用法: $0 prepare <patch-id>"
|
|
48
|
-
exit 1
|
|
49
|
-
fi
|
|
50
|
-
mkdir -p "$STAGING_DIR/$patch_id"
|
|
51
|
-
echo "$patch_id" > "$STAGING_DIR/$patch_id/.patch-id"
|
|
52
|
-
echo "✅ staging 创建: $STAGING_DIR/$patch_id/"
|
|
53
|
-
echo " LLM 改完后把 patch 放这里: $STAGING_DIR/$patch_id/*.patch"
|
|
54
|
-
;;
|
|
55
|
-
|
|
56
|
-
apply)
|
|
57
|
-
# 人类批准: 把 staging 的 patch 合并到 src/
|
|
58
|
-
if [ -z "$patch_id" ]; then
|
|
59
|
-
echo "用法: $0 apply <patch-id>"
|
|
60
|
-
exit 1
|
|
61
|
-
fi
|
|
62
|
-
patch_dir="$STAGING_DIR/$patch_id"
|
|
63
|
-
if [ ! -d "$patch_dir" ]; then
|
|
64
|
-
echo "❌ staging 不存在: $patch_dir"
|
|
65
|
-
exit 1
|
|
66
|
-
fi
|
|
67
|
-
# 必须先 snapshot
|
|
68
|
-
if [ ! -f .last-auto-evolve-baseline ]; then
|
|
69
|
-
echo "❌ 没有 baseline. 先跑: $0 snapshot"
|
|
70
|
-
exit 1
|
|
71
|
-
fi
|
|
72
|
-
baseline="$(cat .last-auto-evolve-baseline)"
|
|
73
|
-
|
|
74
|
-
# 应用所有 patch
|
|
75
|
-
applied=0
|
|
76
|
-
for p in "$patch_dir"/*.patch; do
|
|
77
|
-
[ -e "$p" ] || continue
|
|
78
|
-
echo " applying: $p"
|
|
79
|
-
if ! git apply --check "$p"; then
|
|
80
|
-
echo "❌ patch 不可用: $p (可能已应用过)"
|
|
81
|
-
exit 1
|
|
82
|
-
fi
|
|
83
|
-
git apply "$p"
|
|
84
|
-
applied=$((applied + 1))
|
|
85
|
-
done
|
|
86
|
-
|
|
87
|
-
if [ $applied -eq 0 ]; then
|
|
88
|
-
echo "❌ staging 里没有 .patch 文件"
|
|
89
|
-
exit 1
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
echo "✅ 应用 $applied 个 patch"
|
|
93
|
-
echo " 建议现在跑: npm test + git commit -m 'auto-evolve: $patch_id'"
|
|
94
|
-
echo " 出问题回滚: $0 rollback $baseline"
|
|
95
|
-
;;
|
|
96
|
-
|
|
97
|
-
rollback)
|
|
98
|
-
# 回滚到指定 baseline
|
|
99
|
-
if [ -z "$patch_id" ]; then
|
|
100
|
-
echo "用法: $0 rollback <tag>"
|
|
101
|
-
echo "可用的 baseline:"
|
|
102
|
-
git tag -l "${TAG_PREFIX}*" | sort -r | head -10
|
|
103
|
-
exit 1
|
|
104
|
-
fi
|
|
105
|
-
if ! git tag -l | grep -qx "$patch_id"; then
|
|
106
|
-
echo "❌ tag 不存在: $patch_id"
|
|
107
|
-
exit 1
|
|
108
|
-
fi
|
|
109
|
-
echo "⚠️ 将回滚到 $patch_id (hard reset, 丢弃之后所有改动)"
|
|
110
|
-
read -p "确认? [y/N] " -n 1 -r
|
|
111
|
-
echo
|
|
112
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
113
|
-
git reset --hard "$patch_id"
|
|
114
|
-
echo "✅ 回滚到 $patch_id"
|
|
115
|
-
else
|
|
116
|
-
echo "取消"
|
|
117
|
-
fi
|
|
118
|
-
;;
|
|
119
|
-
|
|
120
|
-
list)
|
|
121
|
-
echo "auto-evolve baselines (最近 10):"
|
|
122
|
-
git tag -l "${TAG_PREFIX}*" | sort -r | head -10 | while read tag; do
|
|
123
|
-
msg="$(git tag -l --format='%(contents)' "$tag" | head -1)"
|
|
124
|
-
echo " $tag — $msg"
|
|
125
|
-
done
|
|
126
|
-
if [ -f .last-auto-evolve-baseline ]; then
|
|
127
|
-
echo ""
|
|
128
|
-
echo "当前 baseline: $(cat .last-auto-evolve-baseline)"
|
|
129
|
-
fi
|
|
130
|
-
;;
|
|
131
|
-
|
|
132
|
-
*)
|
|
133
|
-
echo "用法: $0 {snapshot|prepare <id>|apply <id>|rollback <tag>|list}"
|
|
134
|
-
exit 1
|
|
135
|
-
;;
|
|
136
|
-
esac
|
package/scripts/build-cli.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI 构建脚本
|
|
3
|
-
*
|
|
4
|
-
* 生成 bin/bolloon.js 和 bin/bolloon.cmd 入口文件
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as fs from 'fs';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
13
|
-
const rootDir = path.join(__dirname, '..');
|
|
14
|
-
|
|
15
|
-
const binDir = path.join(rootDir, 'bin');
|
|
16
|
-
if (!fs.existsSync(binDir)) {
|
|
17
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Windows 批处理入口
|
|
21
|
-
const winContent = `@echo off
|
|
22
|
-
set "BOLLOON_ROOT=%~dp0"
|
|
23
|
-
set "BOLLOON_ROOT=%BOLLOON_ROOT:~0,-1%"
|
|
24
|
-
|
|
25
|
-
REM 确定入口文件
|
|
26
|
-
set "ENTRY=%BOLLOON_ROOT%\\dist\\index.js"
|
|
27
|
-
if not exist "%ENTRY%" (
|
|
28
|
-
set "ENTRY=%BOLLOON_ROOT%\\src\\index.ts"
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
node "%ENTRY%" %*
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
fs.writeFileSync(path.join(binDir, 'bolloon.cmd'), winContent);
|
|
35
|
-
|
|
36
|
-
// Unix/Linux/Mac 入口脚本
|
|
37
|
-
const unixContent = `#!/usr/bin/env node
|
|
38
|
-
const path = require("path");
|
|
39
|
-
const { spawn } = require("child_process");
|
|
40
|
-
const fs = require("fs");
|
|
41
|
-
|
|
42
|
-
const RESET = "\\x1b[0m";
|
|
43
|
-
const BOLD = "\\x1b[1m";
|
|
44
|
-
const CYAN = "\\x1b[36m";
|
|
45
|
-
const GREEN = "\\x1b[32m";
|
|
46
|
-
const MAGENTA = "\\x1b[35m";
|
|
47
|
-
|
|
48
|
-
function log(msg, color) {
|
|
49
|
-
console.log((color || RESET) + msg + RESET);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function printBanner() {
|
|
53
|
-
console.log("\\n" + CYAN + BOLD + [
|
|
54
|
-
" ╔═══════════════════════════════════════════╗",
|
|
55
|
-
" ║ 🤖 Bolloon Agent ║",
|
|
56
|
-
" ║ P2P AI Document Processor ║",
|
|
57
|
-
" ╚═══════════════════════════════════════════╝"
|
|
58
|
-
].join("\\n") + RESET + "\\n");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getMainEntry() {
|
|
62
|
-
const distDir = path.dirname(require.main.filename);
|
|
63
|
-
const distIndex = path.join(distDir, "index.js");
|
|
64
|
-
if (fs.existsSync(distIndex)) {
|
|
65
|
-
return distIndex;
|
|
66
|
-
}
|
|
67
|
-
return path.join(process.cwd(), "src", "index.ts");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function parseArgs() {
|
|
71
|
-
const args = process.argv.slice(2);
|
|
72
|
-
if (args.length === 0) {
|
|
73
|
-
return { mode: "gui", args: [] };
|
|
74
|
-
}
|
|
75
|
-
const first = args[0];
|
|
76
|
-
switch (first) {
|
|
77
|
-
case "-v":
|
|
78
|
-
case "--version":
|
|
79
|
-
return { mode: "version", args: [] };
|
|
80
|
-
case "-h":
|
|
81
|
-
case "--help":
|
|
82
|
-
return { mode: "help", args: [] };
|
|
83
|
-
case "-g":
|
|
84
|
-
case "--gui":
|
|
85
|
-
return { mode: "gui", args: args.slice(1) };
|
|
86
|
-
case "-w":
|
|
87
|
-
case "--web":
|
|
88
|
-
return { mode: "web", args: args.slice(1) };
|
|
89
|
-
case "-c":
|
|
90
|
-
case "--cli":
|
|
91
|
-
return { mode: "cli", args: args.slice(1) };
|
|
92
|
-
default:
|
|
93
|
-
return { mode: "passthrough", args };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function startElectron(additionalArgs) {
|
|
98
|
-
try {
|
|
99
|
-
const electron = require("electron");
|
|
100
|
-
const distDir = path.dirname(require.main.filename);
|
|
101
|
-
let mainPath = path.join(distDir, "electron.js");
|
|
102
|
-
if (!fs.existsSync(mainPath)) {
|
|
103
|
-
mainPath = path.join(process.cwd(), "src", "electron.ts");
|
|
104
|
-
}
|
|
105
|
-
log("启动 Electron...", CYAN);
|
|
106
|
-
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
107
|
-
stdio: "inherit",
|
|
108
|
-
env: { ...process.env, NODE_ENV: "development" }
|
|
109
|
-
});
|
|
110
|
-
child.on("error", (err) => {
|
|
111
|
-
log("Electron 启动失败: " + err.message, MAGENTA);
|
|
112
|
-
process.exit(1);
|
|
113
|
-
});
|
|
114
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
115
|
-
} catch (err) {
|
|
116
|
-
log("Electron 不可用,切换到 Web 模式...", CYAN);
|
|
117
|
-
await startWebServer(additionalArgs);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function startWebServer(additionalArgs) {
|
|
122
|
-
const mainPath = getMainEntry();
|
|
123
|
-
const webArgs = ["--web", ...additionalArgs];
|
|
124
|
-
log("启动 Web 服务...", CYAN);
|
|
125
|
-
const child = spawn(process.execPath, [mainPath, ...webArgs], { stdio: "inherit" });
|
|
126
|
-
child.on("error", (err) => {
|
|
127
|
-
log("Web 服务启动失败: " + err.message, MAGENTA);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
});
|
|
130
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function startCLI(additionalArgs) {
|
|
134
|
-
const mainPath = getMainEntry();
|
|
135
|
-
log("启动命令行界面...", CYAN);
|
|
136
|
-
const child = spawn(process.execPath, [mainPath, ...additionalArgs], { stdio: "inherit" });
|
|
137
|
-
child.on("error", (err) => {
|
|
138
|
-
log("CLI 启动失败: " + err.message, MAGENTA);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
});
|
|
141
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function main() {
|
|
145
|
-
const { mode, args } = parseArgs();
|
|
146
|
-
switch (mode) {
|
|
147
|
-
case "version":
|
|
148
|
-
console.log("Bolloon Agent v0.1.1");
|
|
149
|
-
break;
|
|
150
|
-
case "help":
|
|
151
|
-
printBanner();
|
|
152
|
-
console.log(BOLD + "用法:" + RESET + " bolloon [选项] [命令] [参数]");
|
|
153
|
-
console.log(BOLD + "选项:" + RESET + " --gui, -g 启动图形界面");
|
|
154
|
-
console.log(" --web, -w 启动 Web UI");
|
|
155
|
-
console.log(" --cli, -c 启动命令行界面");
|
|
156
|
-
console.log(" --version, -v 显示版本");
|
|
157
|
-
console.log(" --help, -h 显示帮助");
|
|
158
|
-
console.log(BOLD + "示例:" + RESET + " bolloon # 启动图形界面");
|
|
159
|
-
console.log(" bolloon --web # 启动 Web UI");
|
|
160
|
-
console.log(" bolloon --read file # 读取文档");
|
|
161
|
-
break;
|
|
162
|
-
case "gui":
|
|
163
|
-
printBanner();
|
|
164
|
-
await startElectron(args);
|
|
165
|
-
break;
|
|
166
|
-
case "web":
|
|
167
|
-
printBanner();
|
|
168
|
-
await startWebServer(args);
|
|
169
|
-
break;
|
|
170
|
-
case "cli":
|
|
171
|
-
await startCLI(args);
|
|
172
|
-
break;
|
|
173
|
-
case "passthrough":
|
|
174
|
-
const mainPath = getMainEntry();
|
|
175
|
-
const child = spawn(process.execPath, [mainPath, ...args], { stdio: "inherit" });
|
|
176
|
-
child.on("error", (err) => {
|
|
177
|
-
log("执行失败: " + err.message, MAGENTA);
|
|
178
|
-
process.exit(1);
|
|
179
|
-
});
|
|
180
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
181
|
-
break;
|
|
182
|
-
default:
|
|
183
|
-
log("未知模式: " + mode, MAGENTA);
|
|
184
|
-
printBanner();
|
|
185
|
-
console.log("输入 --help 查看帮助");
|
|
186
|
-
process.exit(1);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
main().catch((err) => {
|
|
191
|
-
console.error("Fatal error:", err);
|
|
192
|
-
process.exit(1);
|
|
193
|
-
});
|
|
194
|
-
`;
|
|
195
|
-
|
|
196
|
-
fs.writeFileSync(path.join(binDir, 'bolloon.cjs'), unixContent);
|
|
197
|
-
|
|
198
|
-
// 确保 bin/bolloon.js 存在(npm link 需要)
|
|
199
|
-
// 优先用符号链接(POSIX),Windows 上若权限不足则退化为复制文件
|
|
200
|
-
const jsSymlink = path.join(binDir, 'bolloon.js');
|
|
201
|
-
if (fs.existsSync(jsSymlink)) fs.unlinkSync(jsSymlink);
|
|
202
|
-
try {
|
|
203
|
-
fs.symlinkSync('bolloon.cjs', jsSymlink);
|
|
204
|
-
} catch (err) {
|
|
205
|
-
if (err && err.code === 'EPERM') {
|
|
206
|
-
fs.copyFileSync(path.join(binDir, 'bolloon.cjs'), jsSymlink);
|
|
207
|
-
console.warn(' ⚠ symlink 不支持(Windows),已退化为文件复制');
|
|
208
|
-
} else {
|
|
209
|
-
throw err;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
console.log("✓ CLI 构建完成");
|
|
214
|
-
console.log(" bin/bolloon.cjs - CommonJS 入口");
|
|
215
|
-
console.log(" bin/bolloon.js - 符号链接 -> bolloon.cjs");
|
|
216
|
-
console.log(" bin/bolloon.cmd - Windows 入口");
|
package/scripts/build-web.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web 构建脚本
|
|
3
|
-
*/
|
|
4
|
-
import * as fs from 'fs/promises';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
|
-
import * as esbuild from 'esbuild';
|
|
8
|
-
|
|
9
|
-
const ROOT = path.resolve(import.meta.dirname, '..');
|
|
10
|
-
const DIST_WEB = path.join(ROOT, 'dist', 'web');
|
|
11
|
-
|
|
12
|
-
async function main() {
|
|
13
|
-
console.log('[build-web] 开始构建...');
|
|
14
|
-
|
|
15
|
-
// 重要: 不能 rm -rf 整个 dist/web/, 否则会删掉 build:main 编译出来的
|
|
16
|
-
// dist/web/server.js. 只清理 web 静态资源, 保留 server.js.
|
|
17
|
-
for (const f of ['index.html', 'api-config.html', 'style.css', 'client.js', 'components']) {
|
|
18
|
-
await fs.rm(path.join(DIST_WEB, f), { recursive: true, force: true });
|
|
19
|
-
}
|
|
20
|
-
await fs.mkdir(DIST_WEB, { recursive: true });
|
|
21
|
-
await fs.mkdir(path.join(DIST_WEB, 'components', 'p2p'), { recursive: true });
|
|
22
|
-
|
|
23
|
-
// 编译 TypeScript 模块
|
|
24
|
-
console.log('[build-web] 编译 TypeScript 模块...');
|
|
25
|
-
const moduleFiles = [
|
|
26
|
-
'src/web/components/p2p/types.ts',
|
|
27
|
-
'src/web/components/p2p/p2p-store-memory.ts',
|
|
28
|
-
'src/web/components/p2p/p2p-identity.ts',
|
|
29
|
-
'src/web/components/p2p/p2p-connection.ts',
|
|
30
|
-
'src/web/components/p2p/p2p-messages.ts',
|
|
31
|
-
'src/web/components/p2p/p2p-manager.ts',
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
execSync(`npx tsc --outDir dist/web/components/p2p --declaration false --skipLibCheck --target ES2022 --module ESNext --moduleResolution bundler ${moduleFiles.join(' ')}`, {
|
|
36
|
-
cwd: ROOT,
|
|
37
|
-
stdio: 'inherit'
|
|
38
|
-
});
|
|
39
|
-
} catch {
|
|
40
|
-
console.log('[build-web] TypeScript 编译有警告,继续...');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 编译 P2P Modal UI(esbuild)
|
|
44
|
-
console.log('[build-web] 编译 P2P Modal UI...');
|
|
45
|
-
await esbuild.build({
|
|
46
|
-
entryPoints: [path.join(ROOT, 'src/web/components/p2p/index.ts')],
|
|
47
|
-
outfile: path.join(DIST_WEB, 'components/p2p/index.js'),
|
|
48
|
-
format: 'esm',
|
|
49
|
-
target: 'es2022',
|
|
50
|
-
platform: 'browser',
|
|
51
|
-
minify: false,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// 2026-06-15: 编译 message-renderer.ts (对话显示 UI 模块)
|
|
55
|
-
// esbuild 编译 .ts → dist/web/ui/message-renderer.js (ESM, 浏览器侧 <script type="module"> 加载)
|
|
56
|
-
console.log('[build-web] 编译 message-renderer.ts...');
|
|
57
|
-
await fs.mkdir(path.join(DIST_WEB, 'ui'), { recursive: true });
|
|
58
|
-
await esbuild.build({
|
|
59
|
-
entryPoints: [path.join(ROOT, 'src/web/ui/message-renderer.ts')],
|
|
60
|
-
outfile: path.join(DIST_WEB, 'ui/message-renderer.js'),
|
|
61
|
-
format: 'esm',
|
|
62
|
-
target: 'es2022',
|
|
63
|
-
platform: 'browser',
|
|
64
|
-
minify: false,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// 2026-06-15: 编译 step-timeline.ts (气泡内 4 状态步骤条)
|
|
68
|
-
console.log('[build-web] 编译 step-timeline.ts...');
|
|
69
|
-
await esbuild.build({
|
|
70
|
-
entryPoints: [path.join(ROOT, 'src/web/ui/step-timeline.ts')],
|
|
71
|
-
outfile: path.join(DIST_WEB, 'ui/step-timeline.js'),
|
|
72
|
-
format: 'esm',
|
|
73
|
-
target: 'es2022',
|
|
74
|
-
platform: 'browser',
|
|
75
|
-
minify: false,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// 编译主客户端入口 (classic script, 非 module; 由 index.html 以 /client.js 加载)
|
|
79
|
-
console.log('[build-web] 编译 client.ts...');
|
|
80
|
-
await esbuild.build({
|
|
81
|
-
entryPoints: [path.join(ROOT, 'src/web/client.ts')],
|
|
82
|
-
outfile: path.join(DIST_WEB, 'client.js'),
|
|
83
|
-
format: 'iife',
|
|
84
|
-
target: 'es2022',
|
|
85
|
-
platform: 'browser',
|
|
86
|
-
minify: false,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// 复制静态文件
|
|
90
|
-
console.log('[build-web] 复制静态文件...');
|
|
91
|
-
await fs.copyFile(path.join(ROOT, 'src/web/index.html'), path.join(DIST_WEB, 'index.html'));
|
|
92
|
-
await fs.copyFile(path.join(ROOT, 'src/web/api-config.html'), path.join(DIST_WEB, 'api-config.html'));
|
|
93
|
-
await fs.copyFile(path.join(ROOT, 'src/web/style.css'), path.join(DIST_WEB, 'style.css'));
|
|
94
|
-
// 复制 PWA manifest (index.html 里有 <link rel="manifest">, 否则浏览器会 404)
|
|
95
|
-
await fs.copyFile(path.join(ROOT, 'src/web/manifest.json'), path.join(DIST_WEB, 'manifest.json'));
|
|
96
|
-
// 复制 icons 目录 (manifest.json 里引用了 favicon 等)
|
|
97
|
-
await fs.cp(path.join(ROOT, 'src/web/icons'), path.join(DIST_WEB, 'icons'), { recursive: true });
|
|
98
|
-
|
|
99
|
-
// 复制 components/ 下的独立 ESM 模块 (非 p2p 那些, 已被 esbuild 单独编译)
|
|
100
|
-
// 例如 wallet-viem.mjs: 浏览器侧 viem 封装, 被 index.html 引用
|
|
101
|
-
const extraComponentsDir = path.join(ROOT, 'src/web/components');
|
|
102
|
-
for (const entry of await fs.readdir(extraComponentsDir)) {
|
|
103
|
-
if (entry === 'p2p') continue;
|
|
104
|
-
const src = path.join(extraComponentsDir, entry);
|
|
105
|
-
const dest = path.join(DIST_WEB, 'components', entry);
|
|
106
|
-
const stat = await fs.stat(src);
|
|
107
|
-
if (stat.isFile()) {
|
|
108
|
-
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
109
|
-
await fs.copyFile(src, dest);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
console.log('[build-web] 完成!');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
main().catch(console.error);
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# detect-schema-changes.sh — 阶段 C 护栏 6
|
|
3
|
-
#
|
|
4
|
-
# 检查 LLM 改的文件里有没有动 schema (interface / type / enum 声明)
|
|
5
|
-
# 有则强制要求 reviewer 双签 (在 .auto-evolve-review-required 文件)
|
|
6
|
-
#
|
|
7
|
-
# 用法 (在 staging 准备好 patch 后, apply 前):
|
|
8
|
-
# bash scripts/detect-schema-changes.sh <patch-id>
|
|
9
|
-
|
|
10
|
-
set -euo pipefail
|
|
11
|
-
|
|
12
|
-
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
13
|
-
cd "$REPO_ROOT"
|
|
14
|
-
|
|
15
|
-
patch_id="${1:-}"
|
|
16
|
-
if [ -z "$patch_id" ]; then
|
|
17
|
-
echo "用法: $0 <patch-id>"
|
|
18
|
-
exit 1
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
staging_dir="staging/auto-evolve/$patch_id"
|
|
22
|
-
if [ ! -d "$staging_dir" ]; then
|
|
23
|
-
echo "❌ staging 不存在: $staging_dir"
|
|
24
|
-
exit 1
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
flag="$staging_dir/.schema-changed"
|
|
28
|
-
rm -f "$flag"
|
|
29
|
-
|
|
30
|
-
found=0
|
|
31
|
-
for patch in "$staging_dir"/*.patch; do
|
|
32
|
-
[ -e "$patch" ] || continue
|
|
33
|
-
# 检查 patch 里有没有新增/修改 interface、type、enum 声明
|
|
34
|
-
if grep -E '^\+.*(interface |type [A-Z][a-zA-Z0-9_]* =|enum [A-Z][a-zA-Z0-9_]*)' "$patch" > /dev/null 2>&1; then
|
|
35
|
-
found=1
|
|
36
|
-
echo "⚠️ schema 改动检测到: $patch"
|
|
37
|
-
grep -E '^\+.*(interface |type [A-Z][a-zA-Z0-9_]* =|enum [A-Z][a-zA-Z0-9_]*)' "$patch" | head -3
|
|
38
|
-
fi
|
|
39
|
-
done
|
|
40
|
-
|
|
41
|
-
if [ $found -eq 1 ]; then
|
|
42
|
-
touch "$flag"
|
|
43
|
-
echo ""
|
|
44
|
-
echo "🚨 schema 改动标记: $flag"
|
|
45
|
-
echo " 护栏 6 触发: apply 时会强制要求双签 reviewer"
|
|
46
|
-
else
|
|
47
|
-
echo "✅ 无 schema 改动, 走单签"
|
|
48
|
-
fi
|
package/scripts/diff-reviewer.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/**
|
|
3
|
-
* diff-reviewer.ts — 阶段 C 护栏 4
|
|
4
|
-
*
|
|
5
|
-
* 2nd LLM call 审第 1 个的 diff:
|
|
6
|
-
* - 默认用 Haiku (便宜, ~$0.001/diff)
|
|
7
|
-
* - schema 改动升级 Sonnet (护栏 6 双签)
|
|
8
|
-
*
|
|
9
|
-
* 输入: patch 文件 (git format-patch 风格)
|
|
10
|
-
* 输出: .review-verdict 写到 staging/<patch-id>/, 含 PASS/FAIL + 原因
|
|
11
|
-
*
|
|
12
|
-
* 用法:
|
|
13
|
-
* tsx scripts/diff-reviewer.ts <patch-id> [--model sonnet]
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import * as fs from 'fs/promises';
|
|
17
|
-
import * as path from 'path';
|
|
18
|
-
// Anthropic SDK 在 review() 里 lazy import — 无 API key 或没装 SDK 都不应炸
|
|
19
|
-
|
|
20
|
-
const STAGING_DIR = 'staging/auto-evolve';
|
|
21
|
-
const ENV_KEY_MODEL = 'AUTO_EVOLVE_REVIEW_MODEL';
|
|
22
|
-
|
|
23
|
-
const REVIEW_PROMPT = `你是一个严格的代码审查员. 审查以下 git diff (LLM 自动生成的源码改动).
|
|
24
|
-
|
|
25
|
-
只回答 JSON, 字段:
|
|
26
|
-
{
|
|
27
|
-
"verdict": "PASS" | "FAIL",
|
|
28
|
-
"concerns": ["concern 1", "concern 2", ...],
|
|
29
|
-
"suggestions": ["suggestion 1", ...]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
PASS 条件 (全部满足才 PASS):
|
|
33
|
-
1. 改动能解决它声称要解决的问题
|
|
34
|
-
2. 没引入明显 bug (空指针, 内存泄漏, 死循环, race condition)
|
|
35
|
-
3. 没引入安全漏洞 (injection, XSS, 越权)
|
|
36
|
-
4. 边界条件考虑 (空数组, undefined, 极值, 并发)
|
|
37
|
-
5. 改动局限在它声称的范围, 不夹带私货
|
|
38
|
-
6. 跟现有代码风格一致
|
|
39
|
-
|
|
40
|
-
FAIL 条件 (任一即 FAIL):
|
|
41
|
-
- 满足上面任一 PASS 条件的反例
|
|
42
|
-
- 引入了新依赖 (必须在 concerns 里说)
|
|
43
|
-
- 删除了测试 / 注释掉失败用例
|
|
44
|
-
- 用了 any / unknown / @ts-ignore 偷懒
|
|
45
|
-
|
|
46
|
-
DIFF:
|
|
47
|
-
{{DIFF}}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
function degradedGrepReview(patchContent: string): { verdict: string; concerns: string[]; suggestions: string[]; raw: string } {
|
|
51
|
-
console.warn('[diff-reviewer] ⚠️ 降级 grep 检查 (无 API key 或无 SDK)');
|
|
52
|
-
const concerns: string[] = [];
|
|
53
|
-
if (/\+.*\bany\b/.test(patchContent)) concerns.push('使用了 any');
|
|
54
|
-
if (/\+.*\b@ts-ignore\b/.test(patchContent)) concerns.push('使用了 @ts-ignore');
|
|
55
|
-
if (/\+.*\bconsole\.log\b/.test(patchContent)) concerns.push('留了 console.log');
|
|
56
|
-
if (/\-.*test\(/.test(patchContent)) concerns.push('删除了测试');
|
|
57
|
-
return {
|
|
58
|
-
verdict: concerns.length > 0 ? 'FAIL' : 'PASS',
|
|
59
|
-
concerns,
|
|
60
|
-
suggestions: [],
|
|
61
|
-
raw: '(degraded grep mode)',
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async function review(patchContent: string, model: string): Promise<{ verdict: string; concerns: string[]; suggestions: string[]; raw: string }> {
|
|
66
|
-
// 无 API key → 直接降级, 不 import SDK (避免 no-ANTHROPIC 环境下也炸)
|
|
67
|
-
if (!process.env.ANTHROPIC_API_KEY) {
|
|
68
|
-
return degradedGrepReview(patchContent);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 有 API key → 尝试 lazy import SDK
|
|
72
|
-
let Anthropic: any;
|
|
73
|
-
try {
|
|
74
|
-
({ Anthropic } = await import('@anthropic-ai/sdk'));
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.warn('[diff-reviewer] ⚠️ @anthropic-ai/sdk 未装, 降级 grep');
|
|
77
|
-
return degradedGrepReview(patchContent);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const client = new Anthropic();
|
|
81
|
-
const prompt = REVIEW_PROMPT.replace('{{DIFF}}', patchContent.slice(0, 20000)); // 限长
|
|
82
|
-
const resp = await client.messages.create({
|
|
83
|
-
model,
|
|
84
|
-
max_tokens: 1024,
|
|
85
|
-
messages: [{ role: 'user', content: prompt }],
|
|
86
|
-
});
|
|
87
|
-
const text = resp.content[0].type === 'text' ? resp.content[0].text : '';
|
|
88
|
-
// 解析 JSON
|
|
89
|
-
const m = /\{[\s\S]*\}/.exec(text);
|
|
90
|
-
if (!m) {
|
|
91
|
-
return { verdict: 'FAIL', concerns: ['LLM 没返回 JSON'], suggestions: [], raw: text };
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const parsed = JSON.parse(m[0]);
|
|
95
|
-
return {
|
|
96
|
-
verdict: parsed.verdict === 'PASS' ? 'PASS' : 'FAIL',
|
|
97
|
-
concerns: parsed.concerns || [],
|
|
98
|
-
suggestions: parsed.suggestions || [],
|
|
99
|
-
raw: text,
|
|
100
|
-
};
|
|
101
|
-
} catch {
|
|
102
|
-
return { verdict: 'FAIL', concerns: ['JSON 解析失败'], suggestions: [], raw: text };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function main() {
|
|
107
|
-
const args = process.argv.slice(2);
|
|
108
|
-
const patchId = args[0];
|
|
109
|
-
if (!patchId) {
|
|
110
|
-
console.error('用法: tsx diff-reviewer.ts <patch-id> [--model sonnet]');
|
|
111
|
-
process.exit(1);
|
|
112
|
-
}
|
|
113
|
-
const forceModel = args.includes('--model') ? args[args.indexOf('--model') + 1] : null;
|
|
114
|
-
|
|
115
|
-
const stagingDir = path.join(STAGING_DIR, patchId);
|
|
116
|
-
const schemaFlag = path.join(stagingDir, '.schema-changed');
|
|
117
|
-
const isSchemaChange = await fs.access(schemaFlag).then(() => true).catch(() => false);
|
|
118
|
-
|
|
119
|
-
const defaultModel = isSchemaChange ? 'claude-sonnet-4-6' : 'claude-haiku-4-5';
|
|
120
|
-
const model = forceModel || process.env[ENV_KEY_MODEL] || defaultModel;
|
|
121
|
-
|
|
122
|
-
console.log(`[diff-reviewer] patch=${patchId} schema=${isSchemaChange} model=${model}`);
|
|
123
|
-
|
|
124
|
-
// 合并所有 patch
|
|
125
|
-
const files = await fs.readdir(stagingDir);
|
|
126
|
-
const patches = files.filter((f) => f.endsWith('.patch'));
|
|
127
|
-
if (patches.length === 0) {
|
|
128
|
-
console.error('❌ staging 里没有 .patch 文件');
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let combined = '';
|
|
133
|
-
for (const p of patches) {
|
|
134
|
-
combined += `\n=== ${p} ===\n` + (await fs.readFile(path.join(stagingDir, p), 'utf-8'));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const r = await review(combined, model);
|
|
138
|
-
|
|
139
|
-
const verdict = {
|
|
140
|
-
patchId,
|
|
141
|
-
model,
|
|
142
|
-
schemaChange: isSchemaChange,
|
|
143
|
-
verdict: r.verdict,
|
|
144
|
-
concerns: r.concerns,
|
|
145
|
-
suggestions: r.suggestions,
|
|
146
|
-
reviewedAt: new Date().toISOString(),
|
|
147
|
-
};
|
|
148
|
-
await fs.writeFile(path.join(stagingDir, '.review-verdict'), JSON.stringify(verdict, null, 2));
|
|
149
|
-
|
|
150
|
-
console.log(`[diff-reviewer] verdict=${r.verdict} concerns=${r.concerns.length}`);
|
|
151
|
-
if (r.verdict === 'FAIL') {
|
|
152
|
-
for (const c of r.concerns) console.log(` - ${c}`);
|
|
153
|
-
process.exit(2);
|
|
154
|
-
} else {
|
|
155
|
-
for (const s of r.suggestions) console.log(` 💡 ${s}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
main().catch((e) => { console.error(e); process.exit(1); });
|