@bolloon/bolloon-agent 0.1.35 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agents/p2p-chat-tools.js +6 -6
- package/dist/agents/permission-mode.js +115 -0
- package/dist/agents/pi-sdk.js +435 -25
- package/dist/agents/pre-tool-validator.js +194 -0
- package/dist/agents/workflow-pivot-loop.js +113 -12
- package/dist/bollharness-integration/context-router.js +2 -2
- package/dist/bollharness-integration/guard-checker.js +1 -1
- package/dist/bootstrap/bootstrap.js +3 -0
- package/dist/bootstrap/context-collector.js +17 -1
- package/dist/bootstrap/context-hierarchy.js +218 -0
- package/dist/bootstrap/lifecycle-hooks.js +86 -24
- package/dist/bootstrap/project-context.js +10 -3
- package/dist/context-compaction/auto-compact.js +144 -0
- package/dist/context-compaction/budget-gate.js +28 -0
- package/dist/context-compaction/budget-reduce.js +35 -0
- package/dist/context-compaction/context-collapse.js +66 -0
- package/dist/context-compaction/index.js +21 -0
- package/dist/context-compaction/microcompact.js +51 -0
- package/dist/context-compaction/pipeline.js +123 -0
- package/dist/context-compaction/snip.js +45 -0
- package/dist/context-compaction/token-estimator.js +35 -0
- package/dist/context-compaction/types.js +19 -0
- package/dist/heartbeat/HealthMonitor.js +3 -2
- package/dist/index.js +38 -2
- package/dist/llm/llm-judgment-client.js +32 -30
- package/dist/llm/pi-ai.js +103 -16
- package/dist/llm/system-prompt/health.js +129 -0
- package/dist/llm/system-prompt/registry.js +246 -0
- package/dist/llm/system-prompt/strip-hibsml.js +51 -0
- package/dist/llm/tool-manifest/ask_user_input.js +35 -0
- package/dist/llm/tool-manifest/bash.js +23 -0
- package/dist/llm/tool-manifest/create_file.js +24 -0
- package/dist/llm/tool-manifest/fetch_sports_data.js +26 -0
- package/dist/llm/tool-manifest/image_search.js +24 -0
- package/dist/llm/tool-manifest/index.js +69 -0
- package/dist/llm/tool-manifest/mcp.js +43 -0
- package/dist/llm/tool-manifest/message_compose.js +31 -0
- package/dist/llm/tool-manifest/places.js +83 -0
- package/dist/llm/tool-manifest/present_files.js +21 -0
- package/dist/llm/tool-manifest/recipe.js +40 -0
- package/dist/llm/tool-manifest/recommend_apps.js +23 -0
- package/dist/llm/tool-manifest/str_replace.js +27 -0
- package/dist/llm/tool-manifest/types.js +7 -0
- package/dist/llm/tool-manifest/view.js +24 -0
- package/dist/llm/tool-manifest/weather.js +27 -0
- package/dist/llm/tool-manifest/web.js +51 -0
- package/dist/network/p2p-direct.js +23 -0
- package/dist/network/source-intent-broadcaster.js +203 -0
- package/dist/network/source-intent.js +100 -0
- package/dist/pi-ecosystem-judgment/adaptive-scan.js +48 -0
- package/dist/pi-ecosystem-judgment/injection-gate.js +54 -12
- package/dist/pi-ecosystem-judgment/value-injection.js +8 -2
- package/dist/security/context-router-tool.js +1 -1
- package/dist/security/input-scanner.js +223 -0
- package/dist/web/client.js +3089 -4458
- package/dist/web/index.html +58 -67
- package/dist/web/server.js +299 -117
- package/dist/web/style.css +531 -249
- package/dist/web/ui/message-renderer.js +352 -0
- package/dist/web/ui/step-timeline.js +279 -0
- package/package.json +2 -2
- package/.auto-evolve-calls +0 -1
- package/.last-auto-evolve-baseline +0 -1
- package/Bolloon.md +0 -103
- package/dist/agents/constraint-layer.js.map +0 -1
- package/dist/agents/pi-sdk.js.map +0 -1
- package/dist/agents/workflow-engine.js.map +0 -1
- package/dist/bollharness/src/index.js +0 -5
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_api_types.js +0 -45
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +0 -146
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +0 -135
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +0 -31
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +0 -34
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +0 -63
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +0 -41
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_security.js +0 -48
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_versions.js +0 -6
- package/dist/bollharness/src/scripts/checks/finding.js +0 -13
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +0 -20
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +0 -6
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +0 -8
- package/dist/bollharness/src/scripts/context_router.js +0 -67
- package/dist/bollharness/src/scripts/deploy-guard.js +0 -157
- package/dist/bollharness/src/scripts/guard-feedback.js +0 -192
- package/dist/bollharness/src/scripts/guard_router.js +0 -158
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +0 -6
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +0 -6
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +0 -6
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +0 -6
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +0 -92
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +0 -63
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +0 -6
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +0 -6
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +0 -73
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +0 -6
- package/dist/bollharness/src/scripts/hooks/precompact.js +0 -6
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +0 -6
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +0 -108
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +0 -6
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +0 -7
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +0 -157
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +0 -6
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +0 -10
- package/dist/bollharness/src/scripts/install/install-trust-token.js +0 -7
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +0 -9
- package/dist/bollharness/src/scripts/install/phase2_auto.js +0 -21
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +0 -6
- package/dist/bollharness/src/scripts/install/tier_selector.js +0 -7
- package/dist/bollharness/src/scripts/install/transcript_miner.js +0 -7
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +0 -10
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +0 -12
- package/dist/bollharness/src/scripts/sanitize.js +0 -6
- package/dist/bollharness-integration/context-router-judgment.js.map +0 -1
- package/dist/bollharness-integration/context-router.js.map +0 -1
- package/dist/bollharness-integration/gate-state-machine.js.map +0 -1
- package/dist/bollharness-integration/gate-transition-hooks.js.map +0 -1
- package/dist/bollharness-integration/guard-checker.js.map +0 -1
- package/dist/bollharness-integration/index.js.map +0 -1
- package/dist/bollharness-integration/integration.js.map +0 -1
- package/dist/bollharness-integration/llm/pi-ai.d.ts +0 -60
- package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +0 -153
- package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +0 -136
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +0 -117
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +0 -78
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +0 -139
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +0 -127
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +0 -95
- package/dist/bollharness-integration/skill-adapter.js.map +0 -1
- package/dist/constraint-runtime/src/_archive_helper.js +0 -9
- package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
- package/dist/constraint-runtime/src/agent/index.js +0 -1
- package/dist/constraint-runtime/src/assistant/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
- package/dist/constraint-runtime/src/bridge/index.js +0 -12
- package/dist/constraint-runtime/src/buddy/index.js +0 -12
- package/dist/constraint-runtime/src/cli/index.js +0 -12
- package/dist/constraint-runtime/src/command_graph.js +0 -10
- package/dist/constraint-runtime/src/commands.js +0 -60
- package/dist/constraint-runtime/src/components/index.js +0 -12
- package/dist/constraint-runtime/src/constants/index.js +0 -12
- package/dist/constraint-runtime/src/constraint/budget.js +0 -22
- package/dist/constraint-runtime/src/constraint/budget.js.map +0 -1
- package/dist/constraint-runtime/src/constraint/index.js +0 -2
- package/dist/constraint-runtime/src/constraint/permission.js +0 -20
- package/dist/constraint-runtime/src/constraint/permission.js.map +0 -1
- package/dist/constraint-runtime/src/context.js +0 -30
- package/dist/constraint-runtime/src/coordinator/index.js +0 -12
- package/dist/constraint-runtime/src/cost_hook.js +0 -4
- package/dist/constraint-runtime/src/cost_tracker.js +0 -8
- package/dist/constraint-runtime/src/deferred_init.js +0 -10
- package/dist/constraint-runtime/src/direct_modes.js +0 -6
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
- package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
- package/dist/constraint-runtime/src/execution_registry.js +0 -44
- package/dist/constraint-runtime/src/history.js +0 -9
- package/dist/constraint-runtime/src/hooks/index.js +0 -12
- package/dist/constraint-runtime/src/index.js +0 -26
- package/dist/constraint-runtime/src/ink.js +0 -4
- package/dist/constraint-runtime/src/keybindings/index.js +0 -12
- package/dist/constraint-runtime/src/memdir/index.js +0 -12
- package/dist/constraint-runtime/src/migrations/index.js +0 -12
- package/dist/constraint-runtime/src/models.js +0 -1
- package/dist/constraint-runtime/src/models.js.map +0 -1
- package/dist/constraint-runtime/src/moreright/index.js +0 -12
- package/dist/constraint-runtime/src/native_ts/index.js +0 -12
- package/dist/constraint-runtime/src/output_styles/index.js +0 -12
- package/dist/constraint-runtime/src/parity_audit.js +0 -12
- package/dist/constraint-runtime/src/plugins/index.js +0 -12
- package/dist/constraint-runtime/src/port_manifest.js +0 -11
- package/dist/constraint-runtime/src/prefetch.js +0 -9
- package/dist/constraint-runtime/src/query.js +0 -1
- package/dist/constraint-runtime/src/remote/index.js +0 -12
- package/dist/constraint-runtime/src/remote_runtime.js +0 -9
- package/dist/constraint-runtime/src/runtime/index.js +0 -1
- package/dist/constraint-runtime/src/runtime/session.js +0 -35
- package/dist/constraint-runtime/src/schemas/index.js +0 -12
- package/dist/constraint-runtime/src/screens/index.js +0 -12
- package/dist/constraint-runtime/src/server/index.js +0 -12
- package/dist/constraint-runtime/src/services/index.js +0 -12
- package/dist/constraint-runtime/src/session_store.js +0 -22
- package/dist/constraint-runtime/src/setup.js +0 -30
- package/dist/constraint-runtime/src/skills/index.js +0 -1
- package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
- package/dist/constraint-runtime/src/state/index.js +0 -12
- package/dist/constraint-runtime/src/system_init.js +0 -20
- package/dist/constraint-runtime/src/thinking/engine.js +0 -42
- package/dist/constraint-runtime/src/thinking/index.js +0 -1
- package/dist/constraint-runtime/src/tool_pool.js +0 -8
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
- package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
- package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +0 -29
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +0 -13
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +0 -22
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +0 -25
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +0 -25
- package/dist/constraint-runtime/src/tools.js +0 -80
- package/dist/constraint-runtime/src/transcript.js +0 -19
- package/dist/constraint-runtime/src/types/index.js +0 -12
- package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
- package/dist/constraint-runtime/src/utils/index.js +0 -12
- package/dist/constraint-runtime/src/vim/index.js +0 -12
- package/dist/constraint-runtime/src/voice/index.js +0 -12
- package/dist/constraints/index.js.map +0 -1
- package/dist/documents/reader.js.map +0 -1
- package/dist/llm/config-store.js.map +0 -1
- package/dist/llm/pi-ai.js.map +0 -1
- package/dist/network/agent-network.js.map +0 -1
- package/dist/network/iroh-integration.js.map +0 -1
- package/dist/network/iroh-transport.js.map +0 -1
- package/dist/network/p2p.js.map +0 -1
- package/dist/network/storage/adapters/json-adapter.js.map +0 -1
- package/dist/pi-ecosystem-colony/index.js.map +0 -1
- package/dist/pi-ecosystem-goals/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/decision.js.map +0 -1
- package/dist/pi-ecosystem-judgment/distillation.js.map +0 -1
- package/dist/pi-ecosystem-judgment/human-value-store.js.map +0 -1
- package/dist/pi-ecosystem-judgment/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/value-injection.js.map +0 -1
- package/dist/pi-ecosystem-mcp/index.js.map +0 -1
- package/dist/pi-ecosystem-subagents/index.js.map +0 -1
- package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +0 -1
- package/dist/social/ant-colony/PheromoneEngine.js.map +0 -1
- package/dist/social/ant-colony/types.js.map +0 -1
- package/dist/social/channels/ChannelManager.js.map +0 -1
- package/dist/social/channels/DiapChannelBridge.js.map +0 -1
- package/dist/social/channels/InterestMatcher.js.map +0 -1
- package/dist/social/channels/types.js.map +0 -1
- package/dist/social/global-shared-context.js.map +0 -1
- package/dist/social/heartbeat.js.map +0 -1
- package/lefthook.yml +0 -29
- package/scripts/auto-evolve-loop.ts +0 -376
- package/scripts/auto-evolve-oneshot.sh +0 -155
- package/scripts/auto-evolve-snapshot.sh +0 -136
- package/scripts/build-cli.js +0 -216
- package/scripts/build-web.ts +0 -82
- package/scripts/detect-schema-changes.sh +0 -48
- package/scripts/diff-reviewer.ts +0 -159
- package/scripts/postinstall.js +0 -153
- package/scripts/weekly-report.ts +0 -364
- package/src/agents/agent-manifest-protocol.ts +0 -117
- package/src/agents/constraint-layer.ts +0 -309
- package/src/agents/iroh-secret.ts +0 -32
- package/src/agents/p2p-chat-tools.ts +0 -383
- package/src/agents/p2p-document-tools.ts +0 -347
- package/src/agents/pi-sdk.ts +0 -2462
- package/src/agents/protocol.ts +0 -398
- package/src/agents/shell-guard.ts +0 -417
- package/src/agents/shell-tool.ts +0 -103
- package/src/agents/skill-loader.ts +0 -202
- package/src/agents/subagent-manager.ts +0 -553
- package/src/agents/workflow-engine.ts +0 -332
- package/src/agents/workflow-pivot-loop.ts +0 -675
- package/src/bollharness/.sanitize-report.json +0 -13
- package/src/bollharness/CLAUDE.md +0 -73
- package/src/bollharness/LICENSE +0 -21
- package/src/bollharness/README.md +0 -143
- package/src/bollharness/README.zh-CN.md +0 -131
- package/src/bollharness/package.json +0 -20
- package/src/bollharness/reference/SOURCE-COMMIT.txt +0 -3
- package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +0 -12
- package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +0 -27
- package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +0 -57
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
- package/src/bollharness/schemas/metrics-jsonl-allowlist.json +0 -67
- package/src/bollharness/scripts/checks/next_decision_number.sh +0 -48
- package/src/bollharness/scripts/ci/count-components.sh +0 -65
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
- package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -108
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
- package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
- package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
- package/src/bollharness/scripts/hooks/find-project-root.sh +0 -47
- package/src/bollharness/scripts/hooks/inbox-poll.sh +0 -78
- package/src/bollharness/scripts/hooks/precompact.sh +0 -56
- package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
- package/src/bollharness/scripts/sync-from-upstream.sh +0 -281
- package/src/bollharness/src/index.ts +0 -5
- package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_api_types.ts +0 -52
- package/src/bollharness/src/scripts/checks/check_artifact_link.ts +0 -156
- package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +0 -141
- package/src/bollharness/src/scripts/checks/check_doc_links.ts +0 -36
- package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +0 -40
- package/src/bollharness/src/scripts/checks/check_hook_installed.ts +0 -70
- package/src/bollharness/src/scripts/checks/check_issue_closure.ts +0 -51
- package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_security.ts +0 -54
- package/src/bollharness/src/scripts/checks/check_skill_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_versions.ts +0 -11
- package/src/bollharness/src/scripts/checks/finding.ts +0 -35
- package/src/bollharness/src/scripts/checks/next_decision_number.ts +0 -24
- package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +0 -11
- package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +0 -14
- package/src/bollharness/src/scripts/context_router.ts +0 -76
- package/src/bollharness/src/scripts/deploy-guard.ts +0 -182
- package/src/bollharness/src/scripts/guard-feedback.ts +0 -215
- package/src/bollharness/src/scripts/guard_router.ts +0 -194
- package/src/bollharness/src/scripts/hooks/_hook_output.js +0 -3
- package/src/bollharness/src/scripts/hooks/_hook_output.ts +0 -11
- package/src/bollharness/src/scripts/hooks/auto-python3.ts +0 -10
- package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +0 -10
- package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +0 -10
- package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +0 -111
- package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +0 -74
- package/src/bollharness/src/scripts/hooks/inbox-ack.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-validate.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +0 -10
- package/src/bollharness/src/scripts/hooks/initializer-agent.ts +0 -10
- package/src/bollharness/src/scripts/hooks/loop-detection.ts +0 -83
- package/src/bollharness/src/scripts/hooks/owner-guard.ts +0 -10
- package/src/bollharness/src/scripts/hooks/precompact.ts +0 -10
- package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +0 -10
- package/src/bollharness/src/scripts/hooks/risk-tracker.ts +0 -121
- package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +0 -10
- package/src/bollharness/src/scripts/hooks/session-reflection.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +0 -12
- package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +0 -164
- package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +0 -10
- package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +0 -14
- package/src/bollharness/src/scripts/install/install-trust-token.ts +0 -13
- package/src/bollharness/src/scripts/install/multi_project_registry.ts +0 -13
- package/src/bollharness/src/scripts/install/phase2_auto.ts +0 -28
- package/src/bollharness/src/scripts/install/pre_commit_installer.ts +0 -10
- package/src/bollharness/src/scripts/install/tier_selector.ts +0 -10
- package/src/bollharness/src/scripts/install/transcript_miner.ts +0 -13
- package/src/bollharness/src/scripts/lib/claim_patterns.ts +0 -11
- package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +0 -13
- package/src/bollharness/src/scripts/sanitize.ts +0 -9
- package/src/bollharness/templates/persona/default.json +0 -19
- package/src/bollharness/templates/scaffold/.gitignore.append +0 -16
- package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
- package/src/bollharness-integration/channel-judgment-engine.ts +0 -634
- package/src/bollharness-integration/context-chain-router.ts +0 -474
- package/src/bollharness-integration/context-router-judgment.ts +0 -339
- package/src/bollharness-integration/context-router.ts +0 -583
- package/src/bollharness-integration/gate-state-machine.ts +0 -444
- package/src/bollharness-integration/gate-transition-hooks.ts +0 -137
- package/src/bollharness-integration/guard-checker.ts +0 -451
- package/src/bollharness-integration/index.ts +0 -195
- package/src/bollharness-integration/integration.ts +0 -538
- package/src/bollharness-integration/judgment-prompts.yaml +0 -535
- package/src/bollharness-integration/llm-judgment-engine.ts +0 -712
- package/src/bollharness-integration/skill-adapter.ts +0 -646
- package/src/bootstrap/bootstrap.ts +0 -132
- package/src/bootstrap/context-collector.ts +0 -342
- package/src/bootstrap/lifecycle-hooks.ts +0 -176
- package/src/bootstrap/project-context.ts +0 -163
- package/src/cli/interface.ts +0 -211
- package/src/cli-entry.ts +0 -304
- package/src/constraints/index.ts +0 -6
- package/src/documents/reader.ts +0 -85
- package/src/documents/store.ts +0 -252
- package/src/electron-preload.ts +0 -25
- package/src/electron.ts +0 -200
- package/src/heartbeat/DaemonManager.ts +0 -283
- package/src/heartbeat/HealthMonitor.ts +0 -316
- package/src/heartbeat/StartupVerifier.ts +0 -223
- package/src/heartbeat/Watchdog.ts +0 -208
- package/src/heartbeat/index.ts +0 -109
- package/src/heartbeat/self-improve-bus.ts +0 -110
- package/src/heartbeat/types.ts +0 -82
- package/src/index.ts +0 -1690
- package/src/llm/audio-config-store.ts +0 -246
- package/src/llm/config-store.ts +0 -400
- package/src/llm/llm-judgment-client.ts +0 -470
- package/src/llm/pi-ai.ts +0 -558
- package/src/llm/video-config-store.ts +0 -257
- package/src/network/agent-network.ts +0 -800
- package/src/network/hybrid-messenger.ts +0 -199
- package/src/network/iroh-bootstrap.ts +0 -57
- package/src/network/iroh-discovery.ts +0 -208
- package/src/network/iroh-integration.ts +0 -158
- package/src/network/iroh-transport.ts +0 -637
- package/src/network/known-peers.ts +0 -102
- package/src/network/p2p-direct.ts +0 -240
- package/src/network/p2p-secret.ts +0 -153
- package/src/network/p2p.ts +0 -964
- package/src/network/storage/adapters/json-adapter.ts +0 -454
- package/src/network/storage/index.ts +0 -203
- package/src/network/storage/types.ts +0 -166
- package/src/security/builtin-guards.ts +0 -162
- package/src/security/context-router-tool.ts +0 -122
- package/src/security/react-harness.ts +0 -177
- package/src/security/tool-gate.ts +0 -294
- package/src/social/ant-colony/index.js +0 -19
- package/src/social/channels/ChannelManager.ts +0 -485
- package/src/social/channels/DiapChannelBridge.ts +0 -501
- package/src/social/channels/InterestMatcher.ts +0 -189
- package/src/social/channels/agent-workflow-config.json +0 -214
- package/src/social/channels/agent-workflow-config.yaml +0 -334
- package/src/social/channels/channel-agent-session.ts +0 -407
- package/src/social/channels/channel-heartbeat-agent.ts +0 -622
- package/src/social/channels/diap-doc-parser.ts +0 -282
- package/src/social/channels/harness-workflow-integrator.ts +0 -594
- package/src/social/channels/index.ts +0 -22
- package/src/social/channels/types.ts +0 -115
- package/src/social/global-shared-context.ts +0 -506
- package/src/social/heartbeat.ts +0 -1057
- package/src/social/persona/enhanced-persona.ts +0 -359
- package/src/types.d.ts +0 -12
- package/src/utils/auto-evolve-policy.ts +0 -138
- package/src/utils/auto-update.ts +0 -482
- package/src/utils/clamp.ts +0 -5
- package/src/web/agent-delegate-server.ts +0 -148
- package/src/web/api-config.html +0 -520
- package/src/web/client.js +0 -4898
- package/src/web/components/p2p/P2PModal.tsx +0 -416
- package/src/web/components/p2p/index.ts +0 -566
- package/src/web/components/p2p/index.tsx +0 -297
- package/src/web/components/p2p/p2p-connection.ts +0 -338
- package/src/web/components/p2p/p2p-identity.ts +0 -92
- package/src/web/components/p2p/p2p-manager.ts +0 -147
- package/src/web/components/p2p/p2p-messages.ts +0 -219
- package/src/web/components/p2p/p2p-modal.ts +0 -685
- package/src/web/components/p2p/p2p-store-memory.ts +0 -162
- package/src/web/components/p2p/p2p-tools.ts +0 -315
- package/src/web/components/p2p/types.ts +0 -170
- package/src/web/components/wallet-viem.mjs +0 -118
- package/src/web/design.md +0 -99
- package/src/web/icons/apple-touch-icon.png +0 -0
- package/src/web/icons/favicon-16x16.png +0 -0
- package/src/web/icons/favicon-192x192.png +0 -0
- package/src/web/icons/favicon-32x32.png +0 -0
- package/src/web/icons/favicon-48x48.png +0 -0
- package/src/web/icons/favicon-512x512.png +0 -0
- package/src/web/icons/favicon.icns +0 -0
- package/src/web/icons/favicon.ico +0 -0
- package/src/web/icons/icon.png +0 -0
- package/src/web/icons/image.png +0 -0
- package/src/web/index.html +0 -382
- package/src/web/iroh-delegate-transport.ts +0 -139
- package/src/web/manifest.json +0 -21
- package/src/web/server.ts +0 -5571
- package/src/web/style.css +0 -4455
- package/staging/auto-evolve/clean-001/.review-verdict +0 -9
- package/staging/auto-evolve/clean-001/clean-001.patch +0 -14
- package/staging/auto-evolve/e2e-001/.patch-id +0 -1
- package/staging/auto-evolve/e2e-001/.review-verdict +0 -12
- package/staging/auto-evolve/e2e-001/e2e-001.patch +0 -11
- package/staging/auto-evolve/test-bad/.review-verdict +0 -12
- package/staging/auto-evolve/test-bad/test-bad.patch +0 -11
- package/tsconfig.cli.json +0 -16
- package/tsconfig.electron.json +0 -20
- package/tsconfig.json +0 -18
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
|
|
4
|
-
const PROD_IP = "47.118.31.230";
|
|
5
|
-
const BRIDGE_VPS_HOSTS = ["46.250.229.84"];
|
|
6
|
-
const GUARDED_HOSTS = [PROD_IP, ...BRIDGE_VPS_HOSTS];
|
|
7
|
-
|
|
8
|
-
const DEPLOY_SH_PATTERN = /^bash\s+scripts\/deploy\.sh(\s+--(dry-run|yes))*\s*$/;
|
|
9
|
-
|
|
10
|
-
const SSH_READONLY_CMDS = new Set([
|
|
11
|
-
"journalctl", "cat", "ls", "head", "tail", "grep",
|
|
12
|
-
"ss", "curl", "dig", "status", "git", "file", "stat",
|
|
13
|
-
]);
|
|
14
|
-
|
|
15
|
-
const SYSTEMCTL_WRITE_OPS = new Set(["restart", "stop", "start"]);
|
|
16
|
-
|
|
17
|
-
interface GuardInput {
|
|
18
|
-
tool_name: string;
|
|
19
|
-
tool_input: {
|
|
20
|
-
command?: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getCommand(): string | null {
|
|
25
|
-
try {
|
|
26
|
-
const input: GuardInput = JSON.parse(fs.readFileSync(0, "utf-8"));
|
|
27
|
-
return input.tool_input?.command ?? null;
|
|
28
|
-
} catch {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isDeploySh(cmd: string): boolean {
|
|
34
|
-
return DEPLOY_SH_PATTERN.test(cmd.trim());
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function hasGuardedHost(cmd: string): boolean {
|
|
38
|
-
return GUARDED_HOSTS.some(host => cmd.includes(host));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function whichGuardedHost(cmd: string): string | null {
|
|
42
|
-
for (const host of GUARDED_HOSTS) {
|
|
43
|
-
if (cmd.includes(host)) return host;
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isCompoundCommand(cmd: string): boolean {
|
|
49
|
-
let stripped = cmd.replace(/"[^"]*"/g, "");
|
|
50
|
-
stripped = stripped.replace(/'[^']*'/g, "");
|
|
51
|
-
return /[;&|]{1,2}/.test(stripped);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function checkScpDirection(cmd: string): "upload" | "download" | "none" {
|
|
55
|
-
const parts = cmd.split(/\s+/);
|
|
56
|
-
if (!parts.length || parts[0] !== "scp") return "none";
|
|
57
|
-
|
|
58
|
-
const args = parts.slice(1).filter(p => !p.startsWith("-"));
|
|
59
|
-
if (args.length < 2) return "none";
|
|
60
|
-
|
|
61
|
-
const lastArg = args[args.length - 1];
|
|
62
|
-
if (GUARDED_HOSTS.some(host => lastArg.includes(host))) {
|
|
63
|
-
return "upload";
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (const arg of args.slice(0, -1)) {
|
|
67
|
-
if (GUARDED_HOSTS.some(host => arg.includes(host))) {
|
|
68
|
-
return "download";
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return "none";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function checkSshCommand(cmd: string): "write" | "readonly" | "none" {
|
|
75
|
-
if (!cmd.includes("ssh") || !hasGuardedHost(cmd)) return "none";
|
|
76
|
-
|
|
77
|
-
const quoted = cmd.match(/"([^"]*)"/)?.[1] ?? cmd.match(/'([^']*)'/)?.[1];
|
|
78
|
-
if (!quoted) return "none";
|
|
79
|
-
|
|
80
|
-
const remoteCmd = quoted.trim();
|
|
81
|
-
const parts = remoteCmd.split(/\s+/);
|
|
82
|
-
if (!parts.length) return "none";
|
|
83
|
-
|
|
84
|
-
let idx = 0;
|
|
85
|
-
if (parts[0] === "sudo") {
|
|
86
|
-
idx = 1;
|
|
87
|
-
while (idx < parts.length && parts[idx].startsWith("-")) {
|
|
88
|
-
if (parts[idx] === "-u" && idx + 1 < parts.length) {
|
|
89
|
-
idx += 2;
|
|
90
|
-
} else {
|
|
91
|
-
idx += 1;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const firstWord = parts[idx] ?? "";
|
|
97
|
-
|
|
98
|
-
if (firstWord === "systemctl") {
|
|
99
|
-
if (idx + 1 < parts.length && SYSTEMCTL_WRITE_OPS.has(parts[idx + 1])) {
|
|
100
|
-
return "write";
|
|
101
|
-
}
|
|
102
|
-
return "readonly";
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (SSH_READONLY_CMDS.has(firstWord)) {
|
|
106
|
-
return "readonly";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return "write";
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function checkRsync(cmd: string): "write" | "dryrun" | "none" {
|
|
113
|
-
if (!cmd.includes("rsync") || !hasGuardedHost(cmd)) return "none";
|
|
114
|
-
|
|
115
|
-
const parts = cmd.split(/\s+/);
|
|
116
|
-
if (parts.includes("-n") || cmd.includes("--dry-run")) {
|
|
117
|
-
return "dryrun";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
for (const p of parts) {
|
|
121
|
-
if (p.startsWith("-") && !p.startsWith("--") && p.includes("n")) {
|
|
122
|
-
return "dryrun";
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return "write";
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function block(reason: string, host: string | null = null): void {
|
|
130
|
-
let guidance: string;
|
|
131
|
-
if (host === PROD_IP) {
|
|
132
|
-
guidance = `请使用标准部署流程:
|
|
133
|
-
后端: bash scripts/deploy.sh --yes
|
|
134
|
-
Demo 正式: bash scripts/deploy-demo.sh <name> --channel prod --yes
|
|
135
|
-
Demo 内测: bash scripts/deploy-demo.sh <name> --channel preview --yes
|
|
136
|
-
Edge/Nginx: bash scripts/deploy-edge.sh --yes
|
|
137
|
-
详见 CLAUDE.md Development Commands。`;
|
|
138
|
-
} else if (BRIDGE_VPS_HOSTS.includes(host ?? "")) {
|
|
139
|
-
guidance = `Bridge VPS 必须走 git pull 更新路径:
|
|
140
|
-
ssh root@${host} 'sudo -u boll git -C /opt/boll pull --ff-only'
|
|
141
|
-
scp/rsync 直传会重新制造 orphan worktree。
|
|
142
|
-
详见 docs/issues/guard-20260408-0445-bridge-vps-orphan-worktree.md。`;
|
|
143
|
-
} else {
|
|
144
|
-
guidance = "未识别的受保护服务器目标,请确认 deploy 路径。";
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
process.stderr.write(`BLOCKED: ${reason}\n${guidance}\n`);
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function main(): void {
|
|
152
|
-
const cmd = getCommand();
|
|
153
|
-
if (!cmd) process.exit(0);
|
|
154
|
-
|
|
155
|
-
if (!hasGuardedHost(cmd)) process.exit(0);
|
|
156
|
-
|
|
157
|
-
const host = whichGuardedHost(cmd);
|
|
158
|
-
|
|
159
|
-
if (isCompoundCommand(cmd)) {
|
|
160
|
-
block("检测到复合命令中包含受保护服务器操作,禁止绕过标准部署路径", host);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (isDeploySh(cmd)) process.exit(0);
|
|
164
|
-
|
|
165
|
-
const scpDir = checkScpDirection(cmd);
|
|
166
|
-
if (scpDir === "upload") block("禁止手动 scp 上传到受保护服务器", host);
|
|
167
|
-
if (scpDir === "download") process.exit(0);
|
|
168
|
-
|
|
169
|
-
const sshType = checkSshCommand(cmd);
|
|
170
|
-
if (sshType === "write") block("禁止手动对受保护服务器执行写操作", host);
|
|
171
|
-
if (sshType === "readonly") process.exit(0);
|
|
172
|
-
|
|
173
|
-
const rsyncType = checkRsync(cmd);
|
|
174
|
-
if (rsyncType === "write") block("禁止手动 rsync 写入受保护服务器", host);
|
|
175
|
-
if (rsyncType === "dryrun") process.exit(0);
|
|
176
|
-
|
|
177
|
-
block("检测到未识别的受保护服务器操作", host);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (require.main === module) {
|
|
181
|
-
main();
|
|
182
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { match, loadFragment, FALLBACK_FRAGMENTS } from "./context_router";
|
|
4
|
-
import { readAllSignals, runGuards, writeSessionSignal } from "./guard_router";
|
|
5
|
-
import { Finding } from "./checks/finding";
|
|
6
|
-
|
|
7
|
-
const INJECTED_TTL = 3600;
|
|
8
|
-
const INJECTED_FILE = path.join(process.cwd(), ".boll", "guard", "injected.json");
|
|
9
|
-
const METRICS_DIR = path.join(process.cwd(), ".boll", "metrics");
|
|
10
|
-
const METRICS_FILE = path.join(METRICS_DIR, "guard-events.jsonl");
|
|
11
|
-
|
|
12
|
-
function emitMetric(event: string, data: Record<string, unknown> = {}): void {
|
|
13
|
-
try {
|
|
14
|
-
if (!fs.existsSync(METRICS_DIR)) {
|
|
15
|
-
fs.mkdirSync(METRICS_DIR, { recursive: true });
|
|
16
|
-
}
|
|
17
|
-
const record = {
|
|
18
|
-
ts: new Date().toISOString(),
|
|
19
|
-
session_pid: process.ppid,
|
|
20
|
-
event,
|
|
21
|
-
...data,
|
|
22
|
-
};
|
|
23
|
-
fs.appendFileSync(METRICS_FILE, JSON.stringify(record) + "\n", "utf-8");
|
|
24
|
-
} catch {}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function readInjected(): Set<string> {
|
|
28
|
-
if (!fs.existsSync(INJECTED_FILE)) return new Set();
|
|
29
|
-
try {
|
|
30
|
-
const data = JSON.parse(fs.readFileSync(INJECTED_FILE, "utf-8"));
|
|
31
|
-
if (Date.now() / 1000 - data.timestamp > INJECTED_TTL) return new Set();
|
|
32
|
-
return new Set(data.fragments || []);
|
|
33
|
-
} catch {
|
|
34
|
-
return new Set();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function writeInjected(fragments: Set<string>): void {
|
|
39
|
-
const guardDir = path.join(process.cwd(), ".boll", "guard");
|
|
40
|
-
if (!fs.existsSync(guardDir)) {
|
|
41
|
-
fs.mkdirSync(guardDir, { recursive: true });
|
|
42
|
-
}
|
|
43
|
-
const data = { timestamp: Date.now() / 1000, fragments: Array.from(fragments).sort() };
|
|
44
|
-
fs.writeFileSync(INJECTED_FILE, JSON.stringify(data, null, 2), "utf-8");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getFilePath(): string | null {
|
|
48
|
-
if (process.argv.includes("--dry-run")) {
|
|
49
|
-
const idx = process.argv.indexOf("--dry-run");
|
|
50
|
-
if (idx + 1 < process.argv.length) {
|
|
51
|
-
return process.argv[idx + 1];
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const input = JSON.parse(fs.readFileSync(0, "utf-8"));
|
|
58
|
-
return input.tool_input?.file_path ?? input.tool_input?.path ?? null;
|
|
59
|
-
} catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function makeRelative(filePath: string, repoRoot: string): string | null {
|
|
65
|
-
try {
|
|
66
|
-
const resolved = path.resolve(filePath);
|
|
67
|
-
return path.relative(repoRoot, resolved);
|
|
68
|
-
} catch {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function appendFindings(outputParts: string[], findings: Finding[]): void {
|
|
74
|
-
outputParts.push("\n\n## Guard Findings\n");
|
|
75
|
-
for (const raw of findings) {
|
|
76
|
-
const f = raw;
|
|
77
|
-
const blockingTag = f.blocking ? " [blocking]" : "";
|
|
78
|
-
const skills = f.required_skills.join(", ");
|
|
79
|
-
const skillsLine = skills ? `\n required_skills: ${skills}` : "";
|
|
80
|
-
outputParts.push(
|
|
81
|
-
`- ${f.severity}${blockingTag} ${f.category}: ${f.message}${skillsLine}`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const REPO_ROOT = process.cwd();
|
|
87
|
-
const checksDir = path.join(REPO_ROOT, "src", "scripts", "checks");
|
|
88
|
-
|
|
89
|
-
export async function main(): Promise<void> {
|
|
90
|
-
const startMs = Date.now();
|
|
91
|
-
const checkOnly = process.argv.includes("--check-only");
|
|
92
|
-
const once = process.argv.includes("--once");
|
|
93
|
-
const dryRun = process.argv.includes("--dry-run");
|
|
94
|
-
|
|
95
|
-
emitMetric("hook_trigger", {
|
|
96
|
-
mode: checkOnly ? "check_only" : "post_tool_use",
|
|
97
|
-
once,
|
|
98
|
-
dry_run: dryRun,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (once) {
|
|
102
|
-
const guardDir = path.join(process.cwd(), ".boll", "guard");
|
|
103
|
-
const sessionFile = path.join(guardDir, `once-${process.pid}.flag`);
|
|
104
|
-
if (fs.existsSync(sessionFile)) {
|
|
105
|
-
try {
|
|
106
|
-
const ts = parseFloat(fs.readFileSync(sessionFile, "utf-8").trim());
|
|
107
|
-
if (Date.now() / 1000 - ts < 3600) {
|
|
108
|
-
process.exit(0);
|
|
109
|
-
}
|
|
110
|
-
} catch {}
|
|
111
|
-
}
|
|
112
|
-
if (!fs.existsSync(guardDir)) {
|
|
113
|
-
fs.mkdirSync(guardDir, { recursive: true });
|
|
114
|
-
}
|
|
115
|
-
fs.writeFileSync(sessionFile, String(Date.now() / 1000), "utf-8");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const outputParts: string[] = [];
|
|
119
|
-
|
|
120
|
-
if (checkOnly) {
|
|
121
|
-
const signal = readAllSignals(process.pid);
|
|
122
|
-
const findings = signal.findings;
|
|
123
|
-
if (findings.length) {
|
|
124
|
-
appendFindings(outputParts, findings);
|
|
125
|
-
process.stderr.write(outputParts.join("\n") + "\n");
|
|
126
|
-
emitMetric("check_only_findings", {
|
|
127
|
-
findings_count: findings.length,
|
|
128
|
-
elapsed_ms: Date.now() - startMs,
|
|
129
|
-
});
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
process.exit(0);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
let filePath = getFilePath();
|
|
136
|
-
if (!filePath) process.exit(0);
|
|
137
|
-
|
|
138
|
-
filePath = makeRelative(filePath, REPO_ROOT);
|
|
139
|
-
if (!filePath) {
|
|
140
|
-
emitMetric("path_rejected", { reason: "outside_repo_or_unresolvable" });
|
|
141
|
-
process.exit(0);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const alreadyInjected = readInjected();
|
|
145
|
-
|
|
146
|
-
let fragments = match(filePath);
|
|
147
|
-
if (!fragments.length) {
|
|
148
|
-
fragments = Array.isArray(FALLBACK_FRAGMENTS) ? FALLBACK_FRAGMENTS : [FALLBACK_FRAGMENTS];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const newFragments = fragments.filter(f => !alreadyInjected.has(f));
|
|
152
|
-
|
|
153
|
-
const contentParts: string[] = [];
|
|
154
|
-
for (const name of newFragments) {
|
|
155
|
-
const text = loadFragment(name);
|
|
156
|
-
if (text) contentParts.push(text);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (newFragments.length) {
|
|
160
|
-
const totalBytes = contentParts.reduce((sum, p) => sum + Buffer.byteLength(p, "utf-8"), 0);
|
|
161
|
-
emitMetric("fragment_inject", {
|
|
162
|
-
file_path: filePath,
|
|
163
|
-
fragments: newFragments,
|
|
164
|
-
count: newFragments.length,
|
|
165
|
-
bytes: totalBytes,
|
|
166
|
-
est_tokens: Math.ceil(totalBytes / 4),
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (contentParts.length) {
|
|
171
|
-
outputParts.push("## Context\n");
|
|
172
|
-
outputParts.push(contentParts.join("\n\n---\n\n"));
|
|
173
|
-
newFragments.forEach(f => alreadyInjected.add(f));
|
|
174
|
-
writeInjected(alreadyInjected);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const findings = await runGuards(filePath, checksDir);
|
|
178
|
-
|
|
179
|
-
if (findings.length) {
|
|
180
|
-
const blockingCount = findings.filter(f => f.blocking).length;
|
|
181
|
-
const categories: Record<string, number> = {};
|
|
182
|
-
const severities: Record<string, number> = {};
|
|
183
|
-
for (const f of findings) {
|
|
184
|
-
categories[f.category] = (categories[f.category] || 0) + 1;
|
|
185
|
-
severities[f.severity] = (severities[f.severity] || 0) + 1;
|
|
186
|
-
}
|
|
187
|
-
emitMetric("guard_findings", {
|
|
188
|
-
file_path: filePath,
|
|
189
|
-
findings_count: findings.length,
|
|
190
|
-
blocking_count: blockingCount,
|
|
191
|
-
categories,
|
|
192
|
-
severities,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
writeSessionSignal(findings);
|
|
196
|
-
appendFindings(outputParts, findings);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
emitMetric("hook_done", {
|
|
200
|
-
file_path: filePath,
|
|
201
|
-
had_output: outputParts.length > 0,
|
|
202
|
-
elapsed_ms: Date.now() - startMs,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (outputParts.length) {
|
|
206
|
-
process.stderr.write(outputParts.join("\n") + "\n");
|
|
207
|
-
process.exit(2);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
process.exit(0);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (require.main === module) {
|
|
214
|
-
main();
|
|
215
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { Finding } from "./checks/finding";
|
|
4
|
-
|
|
5
|
-
export const GUARD_MAP: Record<string, string[]> = {
|
|
6
|
-
"bridge_agent/": ["check_bridge_deps"],
|
|
7
|
-
"backend/product/bridge/": ["check_bridge_deps"],
|
|
8
|
-
"mcp-server/": ["check_mcp_parity"],
|
|
9
|
-
"mcp-server-node/": ["check_mcp_parity"],
|
|
10
|
-
"docs/issues/": ["check_issue_closure"],
|
|
11
|
-
"backend/product/routes/": ["check_doc_freshness"],
|
|
12
|
-
"docs/ROADMAP.md": ["check_doc_freshness"],
|
|
13
|
-
"CLAUDE.md": ["check_doc_freshness"],
|
|
14
|
-
"docs/magic/": ["check_doc_freshness"],
|
|
15
|
-
".boll/rules/backend-routes.md": ["check_doc_freshness"],
|
|
16
|
-
".boll/settings.json": ["check_hook_installed"],
|
|
17
|
-
".githooks/": ["check_hook_installed"],
|
|
18
|
-
"scripts/context_router.ts": ["check_fragment_integrity"],
|
|
19
|
-
"scripts/context-fragments/": ["check_fragment_integrity"],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const DEFAULT_GUARDS: string[] = [];
|
|
23
|
-
|
|
24
|
-
export const CATEGORY_TO_SKILLS: Record<string, string[]> = {
|
|
25
|
-
closure_semantics: ["lead", "boll-ops"],
|
|
26
|
-
contract_drift: ["boll-dev", "boll-eng-test"],
|
|
27
|
-
bridge_boundary: ["boll-bridge", "boll-ops"],
|
|
28
|
-
policy_freeze: ["lead", "arch", "plan-lock"],
|
|
29
|
-
doc_integrity: ["boll-ops"],
|
|
30
|
-
version_drift: ["boll-ops"],
|
|
31
|
-
artifact_linkage: ["lead"],
|
|
32
|
-
governance_bootstrap: ["boll-ops"],
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const SESSION_TTL_SECONDS = 3600;
|
|
36
|
-
|
|
37
|
-
export function route(filePath: string): string[] {
|
|
38
|
-
const matched: string[] = [];
|
|
39
|
-
const sortedPatterns = Object.keys(GUARD_MAP).sort((a, b) => b.length - a.length);
|
|
40
|
-
|
|
41
|
-
for (const pattern of sortedPatterns) {
|
|
42
|
-
if (filePath.startsWith(pattern) || filePath === pattern.replace(/\/$/, "")) {
|
|
43
|
-
matched.push(...GUARD_MAP[pattern]);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (matched.length === 0) {
|
|
48
|
-
return [...DEFAULT_GUARDS];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return [...new Set(matched)];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function runGuards(
|
|
55
|
-
filePath: string,
|
|
56
|
-
checksDir: string
|
|
57
|
-
): Promise<Finding[]> {
|
|
58
|
-
const guardNames = route(filePath);
|
|
59
|
-
const findings: Finding[] = [];
|
|
60
|
-
|
|
61
|
-
for (const name of guardNames) {
|
|
62
|
-
try {
|
|
63
|
-
const checkModule = await import(path.join(checksDir, `${name}.js`));
|
|
64
|
-
if (!checkModule.run) {
|
|
65
|
-
findings.push({
|
|
66
|
-
severity: "P1",
|
|
67
|
-
message: `${name} has no run() function`,
|
|
68
|
-
file: `scripts/checks/${name}.ts`,
|
|
69
|
-
blocking: false,
|
|
70
|
-
category: "governance_bootstrap",
|
|
71
|
-
problem_class: "unknown",
|
|
72
|
-
required_skills: [],
|
|
73
|
-
required_reads: [],
|
|
74
|
-
});
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const result = checkModule.run(checksDir, { mode: "full" });
|
|
79
|
-
if (Array.isArray(result)) {
|
|
80
|
-
findings.push(...result);
|
|
81
|
-
} else {
|
|
82
|
-
findings.push(result);
|
|
83
|
-
}
|
|
84
|
-
} catch (exc) {
|
|
85
|
-
findings.push({
|
|
86
|
-
severity: "P0",
|
|
87
|
-
message: `Failed to import guard ${name}: ${exc}`,
|
|
88
|
-
file: `scripts/checks/${name}.ts`,
|
|
89
|
-
blocking: true,
|
|
90
|
-
category: "governance_bootstrap",
|
|
91
|
-
problem_class: "unknown",
|
|
92
|
-
required_skills: [],
|
|
93
|
-
required_reads: [],
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return findings;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getGuardDir(): string {
|
|
102
|
-
return path.join(process.cwd(), ".boll", "guard");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface SessionSignal {
|
|
106
|
-
pid: number;
|
|
107
|
-
timestamp: number;
|
|
108
|
-
findings: Finding[];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function writeSessionSignal(findings: Finding[]): string {
|
|
112
|
-
const guardDir = getGuardDir();
|
|
113
|
-
if (!fs.existsSync(guardDir)) {
|
|
114
|
-
fs.mkdirSync(guardDir, { recursive: true });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const pid = process.pid;
|
|
118
|
-
const target = path.join(guardDir, `session-${pid}.json`);
|
|
119
|
-
const tmp = path.join(guardDir, `session-${pid}.tmp`);
|
|
120
|
-
|
|
121
|
-
const data: SessionSignal = {
|
|
122
|
-
pid,
|
|
123
|
-
timestamp: Date.now() / 1000,
|
|
124
|
-
findings,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
fs.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf-8");
|
|
128
|
-
fs.renameSync(tmp, target);
|
|
129
|
-
return target;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface ReadSignalsResult {
|
|
133
|
-
severity: string | null;
|
|
134
|
-
blocking: boolean;
|
|
135
|
-
required_skills: string[];
|
|
136
|
-
findings: Finding[];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function readAllSignals(pid?: number): ReadSignalsResult {
|
|
140
|
-
const guardDir = getGuardDir();
|
|
141
|
-
if (!fs.existsSync(guardDir)) {
|
|
142
|
-
return { severity: null, blocking: false, required_skills: [], findings: [] };
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const severityOrder: Record<string, number> = { P0: 0, P1: 1, P2: 2 };
|
|
146
|
-
const now = Date.now() / 1000;
|
|
147
|
-
|
|
148
|
-
const allFindings: Finding[] = [];
|
|
149
|
-
let maxSeverity: string | null = null;
|
|
150
|
-
let blocking = false;
|
|
151
|
-
const skills = new Set<string>();
|
|
152
|
-
|
|
153
|
-
let paths: string[];
|
|
154
|
-
if (pid !== undefined) {
|
|
155
|
-
paths = [path.join(guardDir, `session-${pid}.json`)];
|
|
156
|
-
} else {
|
|
157
|
-
paths = fs.readdirSync(guardDir)
|
|
158
|
-
.filter(f => f.startsWith("session-") && f.endsWith(".json"))
|
|
159
|
-
.map(f => path.join(guardDir, f));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
for (const p of paths) {
|
|
163
|
-
if (!fs.existsSync(p)) continue;
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
const data: SessionSignal = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
167
|
-
|
|
168
|
-
const ts = data.timestamp;
|
|
169
|
-
if (now - ts > SESSION_TTL_SECONDS) {
|
|
170
|
-
try {
|
|
171
|
-
fs.unlinkSync(p);
|
|
172
|
-
} catch {}
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
for (const f of data.findings) {
|
|
177
|
-
allFindings.push(f);
|
|
178
|
-
const sev = f.severity;
|
|
179
|
-
if (maxSeverity === null || severityOrder[sev] < severityOrder[maxSeverity]) {
|
|
180
|
-
maxSeverity = sev;
|
|
181
|
-
}
|
|
182
|
-
if (f.blocking) blocking = true;
|
|
183
|
-
f.required_skills.forEach(s => skills.add(s));
|
|
184
|
-
}
|
|
185
|
-
} catch {}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
severity: maxSeverity,
|
|
190
|
-
blocking,
|
|
191
|
-
required_skills: Array.from(skills).sort(),
|
|
192
|
-
findings: allFindings,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
|
|
5
|
-
process.stdout.write(
|
|
6
|
-
`\n\n## Bollharness Context\n\n` +
|
|
7
|
-
`bollharness is an AI Agent Session Governance Framework.\n\n` +
|
|
8
|
-
`For more information, see CLAUDE.md in the project root.\n`
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
process.exit(0);
|