@bolloon/bolloon-agent 0.1.36 → 0.1.38
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/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/lefthook.yml +0 -33
- package/scripts/auto-evolve-loop.ts +0 -481
- package/scripts/build-web.ts +0 -116
- package/scripts/diff-reviewer.ts +0 -159
- 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
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); });
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/**
|
|
3
|
-
* validate-system-prompt.ts — 护栏: system-prompt 改动验证
|
|
4
|
-
*
|
|
5
|
-
* 跑在 pre-commit + reviewer 后:
|
|
6
|
-
* 1. 每个 layer .md 不超 maxChars
|
|
7
|
-
* 2. version 字段 (HTML 注释 <!-- id@version -->) 存在
|
|
8
|
-
* 3. hibsml 标签没漏 (如果出现 → 警告)
|
|
9
|
-
*
|
|
10
|
-
* 用法:
|
|
11
|
-
* tsx scripts/validate-system-prompt.ts
|
|
12
|
-
* tsx scripts/validate-system-prompt.ts --layer core/refusal.md
|
|
13
|
-
*/
|
|
14
|
-
import * as fs from 'fs/promises';
|
|
15
|
-
import * as path from 'path';
|
|
16
|
-
|
|
17
|
-
const REPO = process.cwd();
|
|
18
|
-
const LAYERS_DIR = path.join(REPO, 'src/llm/system-prompt/layers');
|
|
19
|
-
|
|
20
|
-
// 跟 registry 保持一致 (手维护同步; 后续可让 registry 暴露)
|
|
21
|
-
// P-Action 4 (2026-06-15): 跟 registry.ts STATIC_LAYERS maxChars 同步, 停用 layer 设 0
|
|
22
|
-
const MAX_CHARS: Record<string, number> = {
|
|
23
|
-
'core/identity': 800,
|
|
24
|
-
'core/knowledge': 600,
|
|
25
|
-
'core/tools.thin': 400,
|
|
26
|
-
'core/hibs_reminders': 0, // 停用 (was 800)
|
|
27
|
-
'core/refusal': 800,
|
|
28
|
-
'core/tone': 500,
|
|
29
|
-
'core/wellbeing': 600,
|
|
30
|
-
'core/evenhandedness': 300,
|
|
31
|
-
'core/memory_system': 200,
|
|
32
|
-
'core/artifacts_storage': 0, // 停用 (was 2500)
|
|
33
|
-
'core/network_filesystem': 0, // 停用 (was 900)
|
|
34
|
-
'role/expert': 500,
|
|
35
|
-
'role/architect': 0, // 停用 (was 500)
|
|
36
|
-
'role/implementer': 0, // 停用 (was 500)
|
|
37
|
-
'role/security': 0, // 停用 (was 500)
|
|
38
|
-
'channel/local': 500,
|
|
39
|
-
'channel/p2p-visitor': 700,
|
|
40
|
-
'channel/p2p-agent': 700,
|
|
41
|
-
'tool/bash': 600,
|
|
42
|
-
'tool/web_search': 600,
|
|
43
|
-
'tool/mcp_apps': 0, // 停用 (was 1800)
|
|
44
|
-
'tool/hibs_api': 0, // 停用 (was 4500)
|
|
45
|
-
'tool/image_search': 0, // 停用 (was 2500)
|
|
46
|
-
'tool/artifacts': 0, // 停用 (was 2500)
|
|
47
|
-
'tool/manifest': 500,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type IssueType = 'oversize' | 'no-version' | 'leftover-hibsml';
|
|
51
|
-
type IssueSeverity = 'error' | 'warning';
|
|
52
|
-
|
|
53
|
-
interface Issue {
|
|
54
|
-
layer: string;
|
|
55
|
-
type: IssueType;
|
|
56
|
-
severity: IssueSeverity;
|
|
57
|
-
detail: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* P-Action 4 (2026-06-15): oversize 降级为 warning.
|
|
62
|
-
* 原因: P-Action 4 收紧 registry maxChars 后, 多个历史 layer .md 实际长度超过新上限.
|
|
63
|
-
* 这些 .md 是"原样"对齐 Claude.ai 完整版的, 内容不动 (用户约束: 不改 prompt).
|
|
64
|
-
* runtime 时 assembleSystemPrompt 会按 maxChars 截断, 行为已受控.
|
|
65
|
-
* 因此 validate 阶段不再 fail build, 只 log warning.
|
|
66
|
-
* 保留为 error 的: no-version (可追溯性), leftover-hibsml (安全).
|
|
67
|
-
*/
|
|
68
|
-
const SEVERITY: Record<IssueType, IssueSeverity> = {
|
|
69
|
-
oversize: 'warning',
|
|
70
|
-
'no-version': 'error',
|
|
71
|
-
'leftover-hibsml': 'error',
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
async function check(file: string): Promise<Issue[]> {
|
|
75
|
-
const issues: Issue[] = [];
|
|
76
|
-
const rel = path.relative(LAYERS_DIR, file);
|
|
77
|
-
const max = MAX_CHARS[rel.replace(/\.md$/, '')];
|
|
78
|
-
const content = await fs.readFile(file, 'utf-8');
|
|
79
|
-
if (max && content.length > max) {
|
|
80
|
-
issues.push({ layer: rel, type: 'oversize', severity: SEVERITY.oversize, detail: `${content.length} > ${max}` });
|
|
81
|
-
}
|
|
82
|
-
if (!/<!--\s*[\w.-]+@[\d.]+\s*-->/.test(content)) {
|
|
83
|
-
issues.push({ layer: rel, type: 'no-version', severity: SEVERITY['no-version'], detail: '缺 <!-- id@version --> 标记' });
|
|
84
|
-
}
|
|
85
|
-
if (/\{hibsml:(?!thinking_mode)[\w_]+\}/.test(content) || /\{\/hibsml:/.test(content)) {
|
|
86
|
-
issues.push({ layer: rel, type: 'leftover-hibsml', severity: SEVERITY['leftover-hibsml'], detail: '检测到未脱除的 hibsml 标签' });
|
|
87
|
-
}
|
|
88
|
-
return issues;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function walk(dir: string): Promise<string[]> {
|
|
92
|
-
const out: string[] = [];
|
|
93
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
94
|
-
for (const e of entries) {
|
|
95
|
-
const full = path.join(dir, e.name);
|
|
96
|
-
if (e.isDirectory()) out.push(...await walk(full));
|
|
97
|
-
else if (e.name.endsWith('.md')) out.push(full);
|
|
98
|
-
}
|
|
99
|
-
return out;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function main() {
|
|
103
|
-
const args = process.argv.slice(2);
|
|
104
|
-
let files: string[];
|
|
105
|
-
if (args.includes('--layer')) {
|
|
106
|
-
const idx = args.indexOf('--layer');
|
|
107
|
-
const target = path.join(LAYERS_DIR, args[idx + 1]);
|
|
108
|
-
files = [target];
|
|
109
|
-
} else {
|
|
110
|
-
files = await walk(LAYERS_DIR);
|
|
111
|
-
}
|
|
112
|
-
const allIssues: Issue[] = [];
|
|
113
|
-
for (const f of files) {
|
|
114
|
-
const issues = await check(f);
|
|
115
|
-
allIssues.push(...issues);
|
|
116
|
-
}
|
|
117
|
-
if (allIssues.length === 0) {
|
|
118
|
-
console.log(`✅ ${files.length} 个 layer 全部通过 (字符上限, 版本标记, hibsml 脱除)`);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const errors = allIssues.filter((i) => i.severity === 'error');
|
|
122
|
-
const warnings = allIssues.filter((i) => i.severity === 'warning');
|
|
123
|
-
|
|
124
|
-
if (warnings.length > 0) {
|
|
125
|
-
console.warn(`⚠️ ${warnings.length} 个 warning (P-Action 4 后 oversize 不再 fail build):`);
|
|
126
|
-
for (const i of warnings) {
|
|
127
|
-
console.warn(` [${i.type}] ${i.layer}: ${i.detail}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (errors.length === 0) {
|
|
132
|
-
console.log(`✅ ${files.length} 个 layer 通过 (${warnings.length} 个 warning, 0 个 error)`);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
console.error(`❌ ${errors.length} 个 error:`);
|
|
136
|
-
for (const i of errors) {
|
|
137
|
-
console.error(` [${i.type}] ${i.layer}: ${i.detail}`);
|
|
138
|
-
}
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
main().catch((e) => { console.error(e); process.exit(1); });
|
package/scripts/weekly-report.ts
DELETED
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/**
|
|
3
|
-
* weekly-report.ts — Bolloon 每周表现报告 (阶段 B)
|
|
4
|
-
*
|
|
5
|
-
* 输入:
|
|
6
|
-
* ~/.bolloon/human-values/evolution.jsonl (接受/拒绝/回滚事件)
|
|
7
|
-
* ~/.bolloon/human-values/usage.jsonl (judgment 使用记录)
|
|
8
|
-
* ~/.bolloon/human-values/counterfactual-audit.jsonl (反事实审计)
|
|
9
|
-
* ~/.bolloon/human-values/judgments.json (当前 judgment 库)
|
|
10
|
-
* ~/.bolloon/self-improve-audit.log (改源码尝试的审计, 即使被拒)
|
|
11
|
-
*
|
|
12
|
-
* 输出:
|
|
13
|
-
* ~/.bolloon/reports/2026-W24.md (markdown 报告)
|
|
14
|
-
*
|
|
15
|
-
* 设计原则:
|
|
16
|
-
* - 纯本地计算 + 纯函数式分析 (不调 LLM, 避免幻觉)
|
|
17
|
-
* - 周范围默认 ISO 周(周一为起点), 可 --week 2026-W24 指定
|
|
18
|
-
* - 不写 judgments.json, 不动 persona, 仅追加 reports/*.md
|
|
19
|
-
* - 失败静默 + 退出码 != 0 让 cron 知道坏了
|
|
20
|
-
*
|
|
21
|
-
* 用法:
|
|
22
|
-
* tsx scripts/weekly-report.ts # 生成上周
|
|
23
|
-
* tsx scripts/weekly-report.ts --week 2026-W24 # 指定周
|
|
24
|
-
* tsx scripts/weekly-report.ts --week 2026-W24 --dry-run
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import * as fs from 'fs/promises';
|
|
28
|
-
import * as os from 'os';
|
|
29
|
-
import * as path from 'path';
|
|
30
|
-
|
|
31
|
-
const HOME = () => os.homedir() || process.env.HOME || '/tmp';
|
|
32
|
-
const ROOT = () => HOME() + '/.bolloon';
|
|
33
|
-
const REPORTS_DIR = () => ROOT() + '/reports';
|
|
34
|
-
|
|
35
|
-
const FILES = {
|
|
36
|
-
evolution: () => ROOT() + '/human-values/evolution.jsonl',
|
|
37
|
-
usage: () => ROOT() + '/human-values/usage.jsonl',
|
|
38
|
-
counterfactual: () => ROOT() + '/human-values/counterfactual-audit.jsonl',
|
|
39
|
-
judgments: () => ROOT() + '/human-values/judgments.json',
|
|
40
|
-
selfImproveAudit: () => ROOT() + '/self-improve-audit.log',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
interface EvolutionEntry {
|
|
44
|
-
ts: string;
|
|
45
|
-
action: 'accept' | 'reject' | 'revert';
|
|
46
|
-
suggestion: { kind: string; judgmentId: string; action: string };
|
|
47
|
-
appliedPatch?: Record<string, unknown>;
|
|
48
|
-
}
|
|
49
|
-
interface UsageEntry {
|
|
50
|
-
ts: string;
|
|
51
|
-
channelId: string | null;
|
|
52
|
-
userInputPreview: string;
|
|
53
|
-
usedIds: string[];
|
|
54
|
-
}
|
|
55
|
-
interface CounterfactualEntry {
|
|
56
|
-
ts: string;
|
|
57
|
-
trigger: { userInput: string; aiReply: string; violatedPrinciples: unknown[] };
|
|
58
|
-
verdict: string;
|
|
59
|
-
recomendaciones?: string[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function readJsonl<T>(p: string): Promise<T[]> {
|
|
63
|
-
try {
|
|
64
|
-
const content = await fs.readFile(p, 'utf-8');
|
|
65
|
-
return content
|
|
66
|
-
.trim()
|
|
67
|
-
.split('\n')
|
|
68
|
-
.filter(Boolean)
|
|
69
|
-
.map((l) => {
|
|
70
|
-
try {
|
|
71
|
-
return JSON.parse(l) as T;
|
|
72
|
-
} catch {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
.filter((e): e is T => Boolean(e));
|
|
77
|
-
} catch {
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function readJson<T>(p: string): Promise<T | null> {
|
|
83
|
-
try {
|
|
84
|
-
return JSON.parse(await fs.readFile(p, 'utf-8')) as T;
|
|
85
|
-
} catch {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function isoWeekString(d: Date): string {
|
|
91
|
-
// ISO week: 1 = 包含 1 月 4 日的那周
|
|
92
|
-
const target = new Date(d.valueOf());
|
|
93
|
-
const dayNr = (d.getUTCDay() + 6) % 7; // 周一=0
|
|
94
|
-
target.setUTCDate(target.getUTCDate() - dayNr + 3);
|
|
95
|
-
const firstThursday = new Date(Date.UTC(target.getUTCFullYear(), 0, 4));
|
|
96
|
-
const week =
|
|
97
|
-
1 +
|
|
98
|
-
Math.round(
|
|
99
|
-
((target.valueOf() - firstThursday.valueOf()) / 86400000 - 3 + ((firstThursday.getUTCDay() + 6) % 7)) / 7
|
|
100
|
-
);
|
|
101
|
-
return `${target.getUTCFullYear()}-W${String(week).padStart(2, '0')}`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function weekRange(iso: string): { start: Date; end: Date } {
|
|
105
|
-
const m = /^(\d{4})-W(\d{1,2})$/.exec(iso);
|
|
106
|
-
if (!m) throw new Error(`bad ISO week: ${iso}`);
|
|
107
|
-
const year = Number(m[1]);
|
|
108
|
-
const week = Number(m[2]);
|
|
109
|
-
// ISO 周 1 是包含 1 月 4 日的那周
|
|
110
|
-
const jan4 = new Date(Date.UTC(year, 0, 4));
|
|
111
|
-
const jan4Day = (jan4.getUTCDay() + 6) % 7; // 周一=0
|
|
112
|
-
const week1Mon = new Date(jan4);
|
|
113
|
-
week1Mon.setUTCDate(jan4.getUTCDate() - jan4Day);
|
|
114
|
-
const start = new Date(week1Mon);
|
|
115
|
-
start.setUTCDate(week1Mon.getUTCDate() + (week - 1) * 7);
|
|
116
|
-
const end = new Date(start);
|
|
117
|
-
end.setUTCDate(start.getUTCDate() + 7);
|
|
118
|
-
return { start, end };
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function inWeek(ts: string, start: Date, end: Date): boolean {
|
|
122
|
-
const t = new Date(ts).getTime();
|
|
123
|
-
return t >= start.getTime() && t < end.getTime();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function pct(n: number, d: number): string {
|
|
127
|
-
if (d === 0) return 'n/a';
|
|
128
|
-
return `${((n / d) * 100).toFixed(1)}%`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function topN<T>(arr: T[], key: (x: T) => string, n: number): Array<[string, number]> {
|
|
132
|
-
const m = new Map<string, number>();
|
|
133
|
-
for (const x of arr) {
|
|
134
|
-
const k = key(x);
|
|
135
|
-
m.set(k, (m.get(k) || 0) + 1);
|
|
136
|
-
}
|
|
137
|
-
return Array.from(m.entries())
|
|
138
|
-
.sort((a, b) => b[1] - a[1])
|
|
139
|
-
.slice(0, n);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
interface Report {
|
|
143
|
-
week: string;
|
|
144
|
-
range: { start: string; end: string };
|
|
145
|
-
generatedAt: string;
|
|
146
|
-
summary: {
|
|
147
|
-
totalUsage: number;
|
|
148
|
-
uniqueChannels: number;
|
|
149
|
-
uniqueJudgments: number;
|
|
150
|
-
evolutionEvents: number;
|
|
151
|
-
acceptRate: number;
|
|
152
|
-
rejected: number;
|
|
153
|
-
reverted: number;
|
|
154
|
-
counterfactualScans: number;
|
|
155
|
-
};
|
|
156
|
-
topJudgments: Array<[string, number]>;
|
|
157
|
-
topKinds: Array<[string, number]>;
|
|
158
|
-
policyAudit: {
|
|
159
|
-
selfImproveAttempts: number;
|
|
160
|
-
blockedByPolicy: number;
|
|
161
|
-
note: string;
|
|
162
|
-
};
|
|
163
|
-
openQuestions: string[];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async function buildReport(weekIso: string): Promise<Report> {
|
|
167
|
-
const { start, end } = weekRange(weekIso);
|
|
168
|
-
|
|
169
|
-
const [evolution, usage, counterfactual, judgments, audit] = await Promise.all([
|
|
170
|
-
readJsonl<EvolutionEntry>(FILES.evolution()),
|
|
171
|
-
readJsonl<UsageEntry>(FILES.usage()),
|
|
172
|
-
readJsonl<CounterfactualEntry>(FILES.counterfactual()),
|
|
173
|
-
readJson<unknown[]>(FILES.judgments()),
|
|
174
|
-
(async () => {
|
|
175
|
-
try {
|
|
176
|
-
const txt = await fs.readFile(FILES.selfImproveAudit(), 'utf-8');
|
|
177
|
-
return txt.split('\n').filter(Boolean);
|
|
178
|
-
} catch {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
})(),
|
|
182
|
-
]);
|
|
183
|
-
|
|
184
|
-
const evoInWeek = evolution.filter((e) => inWeek(e.ts, start, end));
|
|
185
|
-
const useInWeek = usage.filter((u) => inWeek(u.ts, start, end));
|
|
186
|
-
const cfInWeek = counterfactual.filter((c) => inWeek(c.ts, start, end));
|
|
187
|
-
const auditInWeek = audit.filter((line) => {
|
|
188
|
-
// audit 是日志行, 格式不一定, 简单按日期前缀过滤
|
|
189
|
-
const d = line.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
190
|
-
if (!d) return false;
|
|
191
|
-
const ts = new Date(d[1] + 'T00:00:00Z').getTime();
|
|
192
|
-
return ts >= start.getTime() && ts < end.getTime();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const totalUsage = useInWeek.length;
|
|
196
|
-
const channels = new Set(useInWeek.map((u) => u.channelId || 'null'));
|
|
197
|
-
const ids = new Set<string>();
|
|
198
|
-
for (const u of useInWeek) for (const id of u.usedIds) ids.add(id);
|
|
199
|
-
|
|
200
|
-
const accepts = evoInWeek.filter((e) => e.action === 'accept').length;
|
|
201
|
-
const rejects = evoInWeek.filter((e) => e.action === 'reject').length;
|
|
202
|
-
const reverts = evoInWeek.filter((e) => e.action === 'revert').length;
|
|
203
|
-
const acceptRate = accepts + rejects === 0 ? 0 : accepts / (accepts + rejects);
|
|
204
|
-
|
|
205
|
-
// 自改审计 (路径白/黑名单拦截)
|
|
206
|
-
const selfImproveAttempts = auditInWeek.filter((l) => /attempt|尝试/i.test(l)).length;
|
|
207
|
-
const blockedByPolicy = auditInWeek.filter((l) => /block|deny|拒绝|denylist/i.test(l)).length;
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
week: weekIso,
|
|
211
|
-
range: { start: start.toISOString().slice(0, 10), end: end.toISOString().slice(0, 10) },
|
|
212
|
-
generatedAt: new Date().toISOString(),
|
|
213
|
-
summary: {
|
|
214
|
-
totalUsage,
|
|
215
|
-
uniqueChannels: channels.size,
|
|
216
|
-
uniqueJudgments: ids.size,
|
|
217
|
-
evolutionEvents: evoInWeek.length,
|
|
218
|
-
acceptRate,
|
|
219
|
-
rejected: rejects,
|
|
220
|
-
reverted: reverts,
|
|
221
|
-
counterfactualScans: cfInWeek.length,
|
|
222
|
-
},
|
|
223
|
-
topJudgments: topN(useInWeek.flatMap((u) => u.usedIds.map((id) => ({ id }))), (x) => x.id, 10),
|
|
224
|
-
topKinds: topN(evoInWeek, (e) => e.suggestion.kind, 5),
|
|
225
|
-
policyAudit: {
|
|
226
|
-
selfImproveAttempts,
|
|
227
|
-
blockedByPolicy,
|
|
228
|
-
note: selfImproveAttempts === 0 ? '本周无源码自改尝试(护栏未触发)' : '见 self-improve-audit.log',
|
|
229
|
-
},
|
|
230
|
-
openQuestions: openQuestions(evoInWeek, cfInWeek, useInWeek),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function openQuestions(evo: EvolutionEntry[], cf: CounterfactualEntry[], use: UsageEntry[]): string[] {
|
|
235
|
-
const out: string[] = [];
|
|
236
|
-
if (evo.length === 0 && use.length > 0) {
|
|
237
|
-
out.push('本周有使用但无自适应建议 → 可能 judgment 库太稳定, 或扫描器未触发');
|
|
238
|
-
}
|
|
239
|
-
if (use.length === 0) {
|
|
240
|
-
out.push('本周无 judgment 使用记录 → 检查 usage.jsonl 是否在写, 或渠道是否活跃');
|
|
241
|
-
}
|
|
242
|
-
if (cf.length > 0) {
|
|
243
|
-
const conflictCount = cf.filter((c) => /冲突|conflict|不合理/i.test(c.verdict)).length;
|
|
244
|
-
if (conflictCount > 0) {
|
|
245
|
-
out.push(`反事实审计发现 ${conflictCount} 条潜在冲突 → 看 counterfactual-audit.jsonl`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
const reverts = evo.filter((e) => e.action === 'revert').length;
|
|
249
|
-
if (reverts >= 2) {
|
|
250
|
-
out.push(`本周回滚 ${reverts} 次 → 类 B 建议可能过激, 考虑收紧阈值`);
|
|
251
|
-
}
|
|
252
|
-
return out;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function toMarkdown(r: Report, totalJudgments: number): string {
|
|
256
|
-
const lines: string[] = [];
|
|
257
|
-
lines.push(`# 📊 Bolloon 周报 — ${r.week}`);
|
|
258
|
-
lines.push('');
|
|
259
|
-
lines.push(`> 范围: ${r.range.start} → ${r.range.end} · 生成于 ${r.generatedAt}`);
|
|
260
|
-
lines.push('');
|
|
261
|
-
lines.push('## 核心数字');
|
|
262
|
-
lines.push('');
|
|
263
|
-
lines.push('| 指标 | 本周 |');
|
|
264
|
-
lines.push('|------|------|');
|
|
265
|
-
lines.push(`| judgment 调用次数 | ${r.summary.totalUsage} |`);
|
|
266
|
-
lines.push(`| 触达渠道数 | ${r.summary.uniqueChannels} |`);
|
|
267
|
-
lines.push(`| 用到的不同 judgment 数 | ${r.summary.uniqueJudgments} |`);
|
|
268
|
-
lines.push(`| 自适应事件数 | ${r.summary.evolutionEvents} |`);
|
|
269
|
-
lines.push(`| 接受率 | ${pct(r.summary.acceptRate * 100, 100)} (${Math.round(r.summary.acceptRate * 100)}%) |`);
|
|
270
|
-
lines.push(`| 拒绝数 | ${r.summary.rejected} |`);
|
|
271
|
-
lines.push(`| 回滚数 | ${r.summary.reverted} |`);
|
|
272
|
-
lines.push(`| 反事实审计次数 | ${r.summary.counterfactualScans} |`);
|
|
273
|
-
lines.push(`| 当前 judgment 库总条数 | ${totalJudgments} |`);
|
|
274
|
-
lines.push('');
|
|
275
|
-
lines.push('## 最常被引用的 judgment');
|
|
276
|
-
lines.push('');
|
|
277
|
-
if (r.topJudgments.length === 0) {
|
|
278
|
-
lines.push('_(本周无引用)_');
|
|
279
|
-
} else {
|
|
280
|
-
for (const [id, n] of r.topJudgments) {
|
|
281
|
-
lines.push(`- \`${id}\` × ${n}`);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
lines.push('');
|
|
285
|
-
lines.push('## 自适应建议类型分布');
|
|
286
|
-
lines.push('');
|
|
287
|
-
if (r.topKinds.length === 0) {
|
|
288
|
-
lines.push('_(本周无自适应事件)_');
|
|
289
|
-
} else {
|
|
290
|
-
for (const [kind, n] of r.topKinds) {
|
|
291
|
-
lines.push(`- **${kind}** × ${n}`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
lines.push('');
|
|
295
|
-
lines.push('## 护栏审计');
|
|
296
|
-
lines.push('');
|
|
297
|
-
lines.push(`- 源码自改尝试: **${r.policyAudit.selfImproveAttempts}**`);
|
|
298
|
-
lines.push(`- 被策略拦截: **${r.policyAudit.blockedByPolicy}**`);
|
|
299
|
-
lines.push(`- ${r.policyAudit.note}`);
|
|
300
|
-
lines.push('');
|
|
301
|
-
lines.push('## 关注事项');
|
|
302
|
-
lines.push('');
|
|
303
|
-
if (r.openQuestions.length === 0) {
|
|
304
|
-
lines.push('_(本周一切正常, 无特别关注)_');
|
|
305
|
-
} else {
|
|
306
|
-
for (const q of r.openQuestions) {
|
|
307
|
-
lines.push(`- ${q}`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
lines.push('');
|
|
311
|
-
lines.push('---');
|
|
312
|
-
lines.push('');
|
|
313
|
-
lines.push('> 本报告由 `scripts/weekly-report.ts` 纯本地生成, 不调 LLM. 数据源见 ~/.bolloon/human-values/');
|
|
314
|
-
lines.push('');
|
|
315
|
-
return lines.join('\n');
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function parseArgs(argv: string[]): { week?: string; dryRun: boolean } {
|
|
319
|
-
const out: { week?: string; dryRun: boolean } = { dryRun: false };
|
|
320
|
-
for (let i = 0; i < argv.length; i++) {
|
|
321
|
-
if (argv[i] === '--week' && argv[i + 1]) {
|
|
322
|
-
out.week = argv[++i];
|
|
323
|
-
} else if (argv[i] === '--dry-run') {
|
|
324
|
-
out.dryRun = true;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return out;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
async function main() {
|
|
331
|
-
const args = parseArgs(process.argv.slice(2));
|
|
332
|
-
// 默认: 上周(更合理 — 周末才回顾)
|
|
333
|
-
const now = new Date();
|
|
334
|
-
const lastWeek = new Date(now);
|
|
335
|
-
lastWeek.setUTCDate(now.getUTCDate() - 7);
|
|
336
|
-
const week = args.week || isoWeekString(lastWeek);
|
|
337
|
-
const { start, end } = weekRange(week);
|
|
338
|
-
|
|
339
|
-
console.log(`[weekly-report] 生成 ${week} (${start.toISOString().slice(0, 10)} → ${end.toISOString().slice(0, 10)})`);
|
|
340
|
-
|
|
341
|
-
const r = await buildReport(week);
|
|
342
|
-
const judgments = (await readJson<unknown[]>(FILES.judgments())) || [];
|
|
343
|
-
const md = toMarkdown(r, judgments.length);
|
|
344
|
-
|
|
345
|
-
const outDir = REPORTS_DIR();
|
|
346
|
-
const outPath = path.join(outDir, `${week}.md`);
|
|
347
|
-
|
|
348
|
-
if (args.dryRun) {
|
|
349
|
-
console.log(`[weekly-report] DRY-RUN, 不会写盘. 输出预览:`);
|
|
350
|
-
console.log('---');
|
|
351
|
-
console.log(md);
|
|
352
|
-
console.log('---');
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
await fs.mkdir(outDir, { recursive: true });
|
|
357
|
-
await fs.writeFile(outPath, md, 'utf-8');
|
|
358
|
-
console.log(`[weekly-report] ✅ 写入 ${outPath} (${md.length} bytes)`);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
main().catch((err) => {
|
|
362
|
-
console.error('[weekly-report] ❌ 失败:', err);
|
|
363
|
-
process.exit(1);
|
|
364
|
-
});
|