@bolloon/bolloon-agent 0.2.1 → 0.2.3
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/bin/ipfs +0 -0
- package/dist/agents/judgment-protocol.js +479 -0
- package/dist/agents/parse-tool-call.js +304 -0
- package/dist/agents/pi-sdk.js +190 -267
- package/dist/agents/react-loop.js +86 -0
- package/dist/agents/session-store.js +157 -0
- package/dist/agents/tool-registry.js +136 -0
- package/dist/agents/workflow-pivot-loop.js +40 -0
- package/dist/bollharness/src/index.js +5 -0
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_api_types.js +45 -0
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +146 -0
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +135 -0
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +31 -0
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +34 -0
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +63 -0
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +41 -0
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_security.js +48 -0
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +6 -0
- package/dist/bollharness/src/scripts/checks/check_versions.js +6 -0
- package/dist/bollharness/src/scripts/checks/finding.js +13 -0
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +20 -0
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +6 -0
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +8 -0
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +8 -0
- package/dist/bollharness/src/scripts/context_router.js +67 -0
- package/dist/bollharness/src/scripts/deploy-guard.js +157 -0
- package/dist/bollharness/src/scripts/guard-feedback.js +192 -0
- package/dist/bollharness/src/scripts/guard_router.js +158 -0
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +6 -0
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +6 -0
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +6 -0
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +6 -0
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +92 -0
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +63 -0
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +6 -0
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +6 -0
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +6 -0
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +73 -0
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +6 -0
- package/dist/bollharness/src/scripts/hooks/precompact.js +6 -0
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +6 -0
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +108 -0
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +6 -0
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +7 -0
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +7 -0
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +157 -0
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +6 -0
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +10 -0
- package/dist/bollharness/src/scripts/install/install-trust-token.js +7 -0
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +9 -0
- package/dist/bollharness/src/scripts/install/phase2_auto.js +21 -0
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +6 -0
- package/dist/bollharness/src/scripts/install/tier_selector.js +7 -0
- package/dist/bollharness/src/scripts/install/transcript_miner.js +7 -0
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +10 -0
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +12 -0
- package/dist/bollharness/src/scripts/sanitize.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +5 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +6 -0
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +4 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +6 -0
- package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +29 -0
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +10 -0
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +13 -0
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +22 -0
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +25 -0
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +10 -0
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +25 -0
- package/dist/electron/config.js.map +1 -0
- package/dist/electron/dialogs.js.map +1 -0
- package/dist/electron/first-run.js.map +1 -0
- package/dist/electron/ipc.js.map +1 -0
- package/dist/electron/logger.js.map +1 -0
- package/dist/electron/main.js.map +1 -0
- package/dist/electron/menu.js.map +1 -0
- package/dist/electron/paths.js.map +1 -0
- package/dist/electron/server.js +2 -1
- package/dist/electron/server.js.map +1 -0
- package/dist/electron/tray.js.map +1 -0
- package/dist/electron/window.js.map +1 -0
- package/dist/electron-preload.js +29 -0
- package/dist/electron-preload.js.map +1 -0
- package/dist/electron.js +5 -0
- package/dist/electron.js.map +1 -0
- package/dist/llm/config-store.js +24 -8
- package/dist/llm/pi-ai.js +33 -19
- package/dist/workflows/collaboration.js +374 -0
- package/dist/workflows/index.js +54 -0
- package/package.json +18 -4
- package/.comm/README.md +0 -21
- package/.comm/default/2026-06-17T08-23-00-017Z-8a735de8.md +0 -7
- package/CLAUDE.md +0 -3
- package/build/icon.icns +0 -0
- package/build/icon.ico +0 -0
- package/build/icon.png +0 -0
- package/build/tray.png +0 -0
- package/build/trayTemplate.png +0 -0
- 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/detect-schema-changes.sh +0 -48
- package/scripts/lefthook-helper.sh +0 -69
- package/scripts/postinstall.js +0 -153
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# auto-evolve-snapshot.sh — 阶段 C 护栏 2 + 3
|
|
3
|
-
#
|
|
4
|
-
# 用法 (LLM 改源码前必调):
|
|
5
|
-
# bash scripts/auto-evolve-snapshot.sh # 打 baseline tag + 记当前 HEAD
|
|
6
|
-
# bash scripts/auto-evolve-snapshot.sh apply <patch-id> # 人类批准后合并 staging → main
|
|
7
|
-
# bash scripts/auto-evolve-snapshot.sh list # 列所有 baseline
|
|
8
|
-
# bash scripts/auto-evolve-snapshot.sh rollback <tag> # 回滚到指定 baseline
|
|
9
|
-
#
|
|
10
|
-
# 流程:
|
|
11
|
-
# 1. LLM 改之前调 snapshot: 当前 HEAD 打 auto-evolve-baseline-<ts> tag
|
|
12
|
-
# 2. LLM 改 staging/auto-evolve/<patch-id>/ (不进 src/)
|
|
13
|
-
# 3. 护栏 1 (lefthook) 跑 vitest + tsc, 坏就 abort
|
|
14
|
-
# 4. 护栏 4 (reviewer hook) 审 diff, 通过才准 apply
|
|
15
|
-
# 5. 人类调 apply: git apply staging/auto-evolve/<patch-id>/*.patch → src/
|
|
16
|
-
# 6. 出问题: 调 rollback → git reset --hard <tag>
|
|
17
|
-
|
|
18
|
-
set -euo pipefail
|
|
19
|
-
|
|
20
|
-
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
21
|
-
cd "$REPO_ROOT"
|
|
22
|
-
|
|
23
|
-
STAGING_DIR="staging/auto-evolve"
|
|
24
|
-
TAG_PREFIX="auto-evolve-baseline-"
|
|
25
|
-
|
|
26
|
-
cmd="${1:-snapshot}"
|
|
27
|
-
patch_id="${2:-}"
|
|
28
|
-
|
|
29
|
-
case "$cmd" in
|
|
30
|
-
snapshot)
|
|
31
|
-
# 护栏 2: 打 baseline tag
|
|
32
|
-
if ! git diff --quiet HEAD 2>/dev/null; then
|
|
33
|
-
echo "❌ 有未提交改动. 先 git commit 或 git stash"
|
|
34
|
-
exit 1
|
|
35
|
-
fi
|
|
36
|
-
ts="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
37
|
-
tag="${TAG_PREFIX}${ts}"
|
|
38
|
-
git tag -a "$tag" -m "auto-evolve baseline @ ${ts}" HEAD
|
|
39
|
-
echo "✅ baseline tag: $tag"
|
|
40
|
-
echo "$tag" > .last-auto-evolve-baseline
|
|
41
|
-
echo " 回滚命令: bash $0 rollback $tag"
|
|
42
|
-
;;
|
|
43
|
-
|
|
44
|
-
prepare)
|
|
45
|
-
# LLM 改之前调: 创建 staging 目录
|
|
46
|
-
if [ -z "$patch_id" ]; then
|
|
47
|
-
echo "用法: $0 prepare <patch-id>"
|
|
48
|
-
exit 1
|
|
49
|
-
fi
|
|
50
|
-
mkdir -p "$STAGING_DIR/$patch_id"
|
|
51
|
-
echo "$patch_id" > "$STAGING_DIR/$patch_id/.patch-id"
|
|
52
|
-
echo "✅ staging 创建: $STAGING_DIR/$patch_id/"
|
|
53
|
-
echo " LLM 改完后把 patch 放这里: $STAGING_DIR/$patch_id/*.patch"
|
|
54
|
-
;;
|
|
55
|
-
|
|
56
|
-
apply)
|
|
57
|
-
# 人类批准: 把 staging 的 patch 合并到 src/
|
|
58
|
-
if [ -z "$patch_id" ]; then
|
|
59
|
-
echo "用法: $0 apply <patch-id>"
|
|
60
|
-
exit 1
|
|
61
|
-
fi
|
|
62
|
-
patch_dir="$STAGING_DIR/$patch_id"
|
|
63
|
-
if [ ! -d "$patch_dir" ]; then
|
|
64
|
-
echo "❌ staging 不存在: $patch_dir"
|
|
65
|
-
exit 1
|
|
66
|
-
fi
|
|
67
|
-
# 必须先 snapshot
|
|
68
|
-
if [ ! -f .last-auto-evolve-baseline ]; then
|
|
69
|
-
echo "❌ 没有 baseline. 先跑: $0 snapshot"
|
|
70
|
-
exit 1
|
|
71
|
-
fi
|
|
72
|
-
baseline="$(cat .last-auto-evolve-baseline)"
|
|
73
|
-
|
|
74
|
-
# 应用所有 patch
|
|
75
|
-
applied=0
|
|
76
|
-
for p in "$patch_dir"/*.patch; do
|
|
77
|
-
[ -e "$p" ] || continue
|
|
78
|
-
echo " applying: $p"
|
|
79
|
-
if ! git apply --check "$p"; then
|
|
80
|
-
echo "❌ patch 不可用: $p (可能已应用过)"
|
|
81
|
-
exit 1
|
|
82
|
-
fi
|
|
83
|
-
git apply "$p"
|
|
84
|
-
applied=$((applied + 1))
|
|
85
|
-
done
|
|
86
|
-
|
|
87
|
-
if [ $applied -eq 0 ]; then
|
|
88
|
-
echo "❌ staging 里没有 .patch 文件"
|
|
89
|
-
exit 1
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
echo "✅ 应用 $applied 个 patch"
|
|
93
|
-
echo " 建议现在跑: npm test + git commit -m 'auto-evolve: $patch_id'"
|
|
94
|
-
echo " 出问题回滚: $0 rollback $baseline"
|
|
95
|
-
;;
|
|
96
|
-
|
|
97
|
-
rollback)
|
|
98
|
-
# 回滚到指定 baseline
|
|
99
|
-
if [ -z "$patch_id" ]; then
|
|
100
|
-
echo "用法: $0 rollback <tag>"
|
|
101
|
-
echo "可用的 baseline:"
|
|
102
|
-
git tag -l "${TAG_PREFIX}*" | sort -r | head -10
|
|
103
|
-
exit 1
|
|
104
|
-
fi
|
|
105
|
-
if ! git tag -l | grep -qx "$patch_id"; then
|
|
106
|
-
echo "❌ tag 不存在: $patch_id"
|
|
107
|
-
exit 1
|
|
108
|
-
fi
|
|
109
|
-
echo "⚠️ 将回滚到 $patch_id (hard reset, 丢弃之后所有改动)"
|
|
110
|
-
read -p "确认? [y/N] " -n 1 -r
|
|
111
|
-
echo
|
|
112
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
113
|
-
git reset --hard "$patch_id"
|
|
114
|
-
echo "✅ 回滚到 $patch_id"
|
|
115
|
-
else
|
|
116
|
-
echo "取消"
|
|
117
|
-
fi
|
|
118
|
-
;;
|
|
119
|
-
|
|
120
|
-
list)
|
|
121
|
-
echo "auto-evolve baselines (最近 10):"
|
|
122
|
-
git tag -l "${TAG_PREFIX}*" | sort -r | head -10 | while read tag; do
|
|
123
|
-
msg="$(git tag -l --format='%(contents)' "$tag" | head -1)"
|
|
124
|
-
echo " $tag — $msg"
|
|
125
|
-
done
|
|
126
|
-
if [ -f .last-auto-evolve-baseline ]; then
|
|
127
|
-
echo ""
|
|
128
|
-
echo "当前 baseline: $(cat .last-auto-evolve-baseline)"
|
|
129
|
-
fi
|
|
130
|
-
;;
|
|
131
|
-
|
|
132
|
-
*)
|
|
133
|
-
echo "用法: $0 {snapshot|prepare <id>|apply <id>|rollback <tag>|list}"
|
|
134
|
-
exit 1
|
|
135
|
-
;;
|
|
136
|
-
esac
|
package/scripts/build-cli.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI 构建脚本
|
|
3
|
-
*
|
|
4
|
-
* 生成 bin/bolloon.js 和 bin/bolloon.cmd 入口文件
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as fs from 'fs';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
13
|
-
const rootDir = path.join(__dirname, '..');
|
|
14
|
-
|
|
15
|
-
const binDir = path.join(rootDir, 'bin');
|
|
16
|
-
if (!fs.existsSync(binDir)) {
|
|
17
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Windows 批处理入口
|
|
21
|
-
const winContent = `@echo off
|
|
22
|
-
set "BOLLOON_ROOT=%~dp0"
|
|
23
|
-
set "BOLLOON_ROOT=%BOLLOON_ROOT:~0,-1%"
|
|
24
|
-
|
|
25
|
-
REM 确定入口文件
|
|
26
|
-
set "ENTRY=%BOLLOON_ROOT%\\dist\\index.js"
|
|
27
|
-
if not exist "%ENTRY%" (
|
|
28
|
-
set "ENTRY=%BOLLOON_ROOT%\\src\\index.ts"
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
node "%ENTRY%" %*
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
fs.writeFileSync(path.join(binDir, 'bolloon.cmd'), winContent);
|
|
35
|
-
|
|
36
|
-
// Unix/Linux/Mac 入口脚本
|
|
37
|
-
const unixContent = `#!/usr/bin/env node
|
|
38
|
-
const path = require("path");
|
|
39
|
-
const { spawn } = require("child_process");
|
|
40
|
-
const fs = require("fs");
|
|
41
|
-
|
|
42
|
-
const RESET = "\\x1b[0m";
|
|
43
|
-
const BOLD = "\\x1b[1m";
|
|
44
|
-
const CYAN = "\\x1b[36m";
|
|
45
|
-
const GREEN = "\\x1b[32m";
|
|
46
|
-
const MAGENTA = "\\x1b[35m";
|
|
47
|
-
|
|
48
|
-
function log(msg, color) {
|
|
49
|
-
console.log((color || RESET) + msg + RESET);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function printBanner() {
|
|
53
|
-
console.log("\\n" + CYAN + BOLD + [
|
|
54
|
-
" ╔═══════════════════════════════════════════╗",
|
|
55
|
-
" ║ 🤖 Bolloon Agent ║",
|
|
56
|
-
" ║ P2P AI Document Processor ║",
|
|
57
|
-
" ╚═══════════════════════════════════════════╝"
|
|
58
|
-
].join("\\n") + RESET + "\\n");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getMainEntry() {
|
|
62
|
-
const distDir = path.dirname(require.main.filename);
|
|
63
|
-
const distIndex = path.join(distDir, "index.js");
|
|
64
|
-
if (fs.existsSync(distIndex)) {
|
|
65
|
-
return distIndex;
|
|
66
|
-
}
|
|
67
|
-
return path.join(process.cwd(), "src", "index.ts");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function parseArgs() {
|
|
71
|
-
const args = process.argv.slice(2);
|
|
72
|
-
if (args.length === 0) {
|
|
73
|
-
return { mode: "gui", args: [] };
|
|
74
|
-
}
|
|
75
|
-
const first = args[0];
|
|
76
|
-
switch (first) {
|
|
77
|
-
case "-v":
|
|
78
|
-
case "--version":
|
|
79
|
-
return { mode: "version", args: [] };
|
|
80
|
-
case "-h":
|
|
81
|
-
case "--help":
|
|
82
|
-
return { mode: "help", args: [] };
|
|
83
|
-
case "-g":
|
|
84
|
-
case "--gui":
|
|
85
|
-
return { mode: "gui", args: args.slice(1) };
|
|
86
|
-
case "-w":
|
|
87
|
-
case "--web":
|
|
88
|
-
return { mode: "web", args: args.slice(1) };
|
|
89
|
-
case "-c":
|
|
90
|
-
case "--cli":
|
|
91
|
-
return { mode: "cli", args: args.slice(1) };
|
|
92
|
-
default:
|
|
93
|
-
return { mode: "passthrough", args };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function startElectron(additionalArgs) {
|
|
98
|
-
try {
|
|
99
|
-
const electron = require("electron");
|
|
100
|
-
const distDir = path.dirname(require.main.filename);
|
|
101
|
-
let mainPath = path.join(distDir, "electron.js");
|
|
102
|
-
if (!fs.existsSync(mainPath)) {
|
|
103
|
-
mainPath = path.join(process.cwd(), "src", "electron.ts");
|
|
104
|
-
}
|
|
105
|
-
log("启动 Electron...", CYAN);
|
|
106
|
-
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
107
|
-
stdio: "inherit",
|
|
108
|
-
env: { ...process.env, NODE_ENV: "development" }
|
|
109
|
-
});
|
|
110
|
-
child.on("error", (err) => {
|
|
111
|
-
log("Electron 启动失败: " + err.message, MAGENTA);
|
|
112
|
-
process.exit(1);
|
|
113
|
-
});
|
|
114
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
115
|
-
} catch (err) {
|
|
116
|
-
log("Electron 不可用,切换到 Web 模式...", CYAN);
|
|
117
|
-
await startWebServer(additionalArgs);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function startWebServer(additionalArgs) {
|
|
122
|
-
const mainPath = getMainEntry();
|
|
123
|
-
const webArgs = ["--web", ...additionalArgs];
|
|
124
|
-
log("启动 Web 服务...", CYAN);
|
|
125
|
-
const child = spawn(process.execPath, [mainPath, ...webArgs], { stdio: "inherit" });
|
|
126
|
-
child.on("error", (err) => {
|
|
127
|
-
log("Web 服务启动失败: " + err.message, MAGENTA);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
});
|
|
130
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function startCLI(additionalArgs) {
|
|
134
|
-
const mainPath = getMainEntry();
|
|
135
|
-
log("启动命令行界面...", CYAN);
|
|
136
|
-
const child = spawn(process.execPath, [mainPath, ...additionalArgs], { stdio: "inherit" });
|
|
137
|
-
child.on("error", (err) => {
|
|
138
|
-
log("CLI 启动失败: " + err.message, MAGENTA);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
});
|
|
141
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function main() {
|
|
145
|
-
const { mode, args } = parseArgs();
|
|
146
|
-
switch (mode) {
|
|
147
|
-
case "version":
|
|
148
|
-
console.log("Bolloon Agent v0.1.1");
|
|
149
|
-
break;
|
|
150
|
-
case "help":
|
|
151
|
-
printBanner();
|
|
152
|
-
console.log(BOLD + "用法:" + RESET + " bolloon [选项] [命令] [参数]");
|
|
153
|
-
console.log(BOLD + "选项:" + RESET + " --gui, -g 启动图形界面");
|
|
154
|
-
console.log(" --web, -w 启动 Web UI");
|
|
155
|
-
console.log(" --cli, -c 启动命令行界面");
|
|
156
|
-
console.log(" --version, -v 显示版本");
|
|
157
|
-
console.log(" --help, -h 显示帮助");
|
|
158
|
-
console.log(BOLD + "示例:" + RESET + " bolloon # 启动图形界面");
|
|
159
|
-
console.log(" bolloon --web # 启动 Web UI");
|
|
160
|
-
console.log(" bolloon --read file # 读取文档");
|
|
161
|
-
break;
|
|
162
|
-
case "gui":
|
|
163
|
-
printBanner();
|
|
164
|
-
await startElectron(args);
|
|
165
|
-
break;
|
|
166
|
-
case "web":
|
|
167
|
-
printBanner();
|
|
168
|
-
await startWebServer(args);
|
|
169
|
-
break;
|
|
170
|
-
case "cli":
|
|
171
|
-
await startCLI(args);
|
|
172
|
-
break;
|
|
173
|
-
case "passthrough":
|
|
174
|
-
const mainPath = getMainEntry();
|
|
175
|
-
const child = spawn(process.execPath, [mainPath, ...args], { stdio: "inherit" });
|
|
176
|
-
child.on("error", (err) => {
|
|
177
|
-
log("执行失败: " + err.message, MAGENTA);
|
|
178
|
-
process.exit(1);
|
|
179
|
-
});
|
|
180
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
181
|
-
break;
|
|
182
|
-
default:
|
|
183
|
-
log("未知模式: " + mode, MAGENTA);
|
|
184
|
-
printBanner();
|
|
185
|
-
console.log("输入 --help 查看帮助");
|
|
186
|
-
process.exit(1);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
main().catch((err) => {
|
|
191
|
-
console.error("Fatal error:", err);
|
|
192
|
-
process.exit(1);
|
|
193
|
-
});
|
|
194
|
-
`;
|
|
195
|
-
|
|
196
|
-
fs.writeFileSync(path.join(binDir, 'bolloon.cjs'), unixContent);
|
|
197
|
-
|
|
198
|
-
// 确保 bin/bolloon.js 存在(npm link 需要)
|
|
199
|
-
// 优先用符号链接(POSIX),Windows 上若权限不足则退化为复制文件
|
|
200
|
-
const jsSymlink = path.join(binDir, 'bolloon.js');
|
|
201
|
-
if (fs.existsSync(jsSymlink)) fs.unlinkSync(jsSymlink);
|
|
202
|
-
try {
|
|
203
|
-
fs.symlinkSync('bolloon.cjs', jsSymlink);
|
|
204
|
-
} catch (err) {
|
|
205
|
-
if (err && err.code === 'EPERM') {
|
|
206
|
-
fs.copyFileSync(path.join(binDir, 'bolloon.cjs'), jsSymlink);
|
|
207
|
-
console.warn(' ⚠ symlink 不支持(Windows),已退化为文件复制');
|
|
208
|
-
} else {
|
|
209
|
-
throw err;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
console.log("✓ CLI 构建完成");
|
|
214
|
-
console.log(" bin/bolloon.cjs - CommonJS 入口");
|
|
215
|
-
console.log(" bin/bolloon.js - 符号链接 -> bolloon.cjs");
|
|
216
|
-
console.log(" bin/bolloon.cmd - Windows 入口");
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# detect-schema-changes.sh — 阶段 C 护栏 6
|
|
3
|
-
#
|
|
4
|
-
# 检查 LLM 改的文件里有没有动 schema (interface / type / enum 声明)
|
|
5
|
-
# 有则强制要求 reviewer 双签 (在 .auto-evolve-review-required 文件)
|
|
6
|
-
#
|
|
7
|
-
# 用法 (在 staging 准备好 patch 后, apply 前):
|
|
8
|
-
# bash scripts/detect-schema-changes.sh <patch-id>
|
|
9
|
-
|
|
10
|
-
set -euo pipefail
|
|
11
|
-
|
|
12
|
-
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
13
|
-
cd "$REPO_ROOT"
|
|
14
|
-
|
|
15
|
-
patch_id="${1:-}"
|
|
16
|
-
if [ -z "$patch_id" ]; then
|
|
17
|
-
echo "用法: $0 <patch-id>"
|
|
18
|
-
exit 1
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
staging_dir="staging/auto-evolve/$patch_id"
|
|
22
|
-
if [ ! -d "$staging_dir" ]; then
|
|
23
|
-
echo "❌ staging 不存在: $staging_dir"
|
|
24
|
-
exit 1
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
flag="$staging_dir/.schema-changed"
|
|
28
|
-
rm -f "$flag"
|
|
29
|
-
|
|
30
|
-
found=0
|
|
31
|
-
for patch in "$staging_dir"/*.patch; do
|
|
32
|
-
[ -e "$patch" ] || continue
|
|
33
|
-
# 检查 patch 里有没有新增/修改 interface、type、enum 声明
|
|
34
|
-
if grep -E '^\+.*(interface |type [A-Z][a-zA-Z0-9_]* =|enum [A-Z][a-zA-Z0-9_]*)' "$patch" > /dev/null 2>&1; then
|
|
35
|
-
found=1
|
|
36
|
-
echo "⚠️ schema 改动检测到: $patch"
|
|
37
|
-
grep -E '^\+.*(interface |type [A-Z][a-zA-Z0-9_]* =|enum [A-Z][a-zA-Z0-9_]*)' "$patch" | head -3
|
|
38
|
-
fi
|
|
39
|
-
done
|
|
40
|
-
|
|
41
|
-
if [ $found -eq 1 ]; then
|
|
42
|
-
touch "$flag"
|
|
43
|
-
echo ""
|
|
44
|
-
echo "🚨 schema 改动标记: $flag"
|
|
45
|
-
echo " 护栏 6 触发: apply 时会强制要求双签 reviewer"
|
|
46
|
-
else
|
|
47
|
-
echo "✅ 无 schema 改动, 走单签"
|
|
48
|
-
fi
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# 2026-06-17: lefthook helper — agent auto-evolve branch detection
|
|
3
|
-
# 写在独立文件里避免 lefthook 嵌套引号 + Windows bash 解析问题
|
|
4
|
-
# 用法: lefthook.yml 里 run: sh scripts/lefthook-helper.sh <command>
|
|
5
|
-
# <command> = commit | vitest-full | build-check | tag-baseline
|
|
6
|
-
|
|
7
|
-
CMD="$1"
|
|
8
|
-
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo none)
|
|
9
|
-
AUTO_EVOLVE_MSG=$(git log -1 --pretty=%B 2>/dev/null | head -1 | grep -c ^auto-evolve: || echo 0)
|
|
10
|
-
|
|
11
|
-
is_master_main() {
|
|
12
|
-
[ "$BRANCH" = "master" ] || [ "$BRANCH" = "main" ]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
is_auto_evolve() {
|
|
16
|
-
if [ "$BOLLOON_AUTO_EVOLVE" = "1" ]; then return 0; fi
|
|
17
|
-
if [ "$AUTO_EVOLVE_MSG" -gt 0 ] 2>/dev/null; then return 0; fi
|
|
18
|
-
return 1
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
case "$CMD" in
|
|
22
|
-
commit-vitest-bail)
|
|
23
|
-
if is_auto_evolve; then
|
|
24
|
-
echo "[skip] vitest-bail (auto-evolve mode, branch=$BRANCH)"
|
|
25
|
-
exit 0
|
|
26
|
-
fi
|
|
27
|
-
npx vitest run --bail=1 --reporter=dot
|
|
28
|
-
;;
|
|
29
|
-
commit-tsc-check)
|
|
30
|
-
if is_auto_evolve; then
|
|
31
|
-
echo "[skip] tsc-check (auto-evolve mode, branch=$BRANCH)"
|
|
32
|
-
exit 0
|
|
33
|
-
fi
|
|
34
|
-
npx tsc --noEmit
|
|
35
|
-
;;
|
|
36
|
-
push-vitest-full)
|
|
37
|
-
if is_master_main; then
|
|
38
|
-
npx vitest run --reporter=dot
|
|
39
|
-
else
|
|
40
|
-
echo "[skip] vitest-full (branch=$BRANCH, not master/main)"
|
|
41
|
-
exit 0
|
|
42
|
-
fi
|
|
43
|
-
;;
|
|
44
|
-
push-build-check)
|
|
45
|
-
if is_master_main; then
|
|
46
|
-
npm run build:main
|
|
47
|
-
else
|
|
48
|
-
echo "[skip] build-check (branch=$BRANCH, not master/main)"
|
|
49
|
-
exit 0
|
|
50
|
-
fi
|
|
51
|
-
;;
|
|
52
|
-
push-tag-baseline)
|
|
53
|
-
if is_master_main; then
|
|
54
|
-
if git tag -l 'auto-evolve-baseline-*' | grep -q .; then
|
|
55
|
-
exit 0
|
|
56
|
-
else
|
|
57
|
-
echo "[ERROR] push to master/main requires auto-evolve-baseline-* tag. Run: bash scripts/auto-evolve-snapshot.sh"
|
|
58
|
-
exit 1
|
|
59
|
-
fi
|
|
60
|
-
else
|
|
61
|
-
echo "[skip] tag-baseline (branch=$BRANCH, not master/main)"
|
|
62
|
-
exit 0
|
|
63
|
-
fi
|
|
64
|
-
;;
|
|
65
|
-
*)
|
|
66
|
-
echo "Unknown command: $CMD"
|
|
67
|
-
exit 1
|
|
68
|
-
;;
|
|
69
|
-
esac
|
package/scripts/postinstall.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Postinstall 脚本
|
|
3
|
-
* npm 安装后自动执行
|
|
4
|
-
*
|
|
5
|
-
* 主要任务:
|
|
6
|
-
* 1. 确保 bin 目录存在且可执行
|
|
7
|
-
* 2. 初始化本地配置
|
|
8
|
-
* 3. 检查依赖完整性
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import * as fs from 'fs';
|
|
12
|
-
import * as path from 'path';
|
|
13
|
-
import { fileURLToPath } from 'url';
|
|
14
|
-
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = path.dirname(__filename);
|
|
17
|
-
const rootDir = path.join(__dirname, '..');
|
|
18
|
-
|
|
19
|
-
const RESET = '\x1b[0m';
|
|
20
|
-
const GREEN = '\x1b[32m';
|
|
21
|
-
const YELLOW = '\x1b[33m';
|
|
22
|
-
const CYAN = '\x1b[36m';
|
|
23
|
-
|
|
24
|
-
function log(msg, color = RESET) {
|
|
25
|
-
console.log(color + msg + RESET);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function initUserDirs() {
|
|
29
|
-
// 创建用户数据目录
|
|
30
|
-
const home = process.env.HOME || process.env.USERPROFILE || '/tmp';
|
|
31
|
-
const bolloonDir = path.join(home, '.bolloon');
|
|
32
|
-
|
|
33
|
-
const dirs = [
|
|
34
|
-
bolloonDir,
|
|
35
|
-
path.join(bolloonDir, 'sessions'),
|
|
36
|
-
path.join(bolloonDir, 'peer-store'),
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
for (const dir of dirs) {
|
|
40
|
-
if (!fs.existsSync(dir)) {
|
|
41
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
42
|
-
log(` ✓ 创建目录: ${dir}`, GREEN);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 初始化配置文件
|
|
47
|
-
const configPath = path.join(bolloonDir, 'config.json');
|
|
48
|
-
if (!fs.existsSync(configPath)) {
|
|
49
|
-
const defaultConfig = {
|
|
50
|
-
version: '0.1.12',
|
|
51
|
-
initializedAt: new Date().toISOString(),
|
|
52
|
-
defaults: {
|
|
53
|
-
port: 54188,
|
|
54
|
-
theme: 'dark',
|
|
55
|
-
autoConnect: true,
|
|
56
|
-
},
|
|
57
|
-
providers: {
|
|
58
|
-
minimax: { enabled: false },
|
|
59
|
-
openai: { enabled: false },
|
|
60
|
-
anthropic: { enabled: false },
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
64
|
-
log(` ✓ 创建配置: ${configPath}`, GREEN);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return bolloonDir;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function checkNativeDeps() {
|
|
71
|
-
// 检查必要的原生依赖
|
|
72
|
-
const nativeDeps = [
|
|
73
|
-
'libp2p',
|
|
74
|
-
'@diap/sdk',
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
let allOk = true;
|
|
78
|
-
|
|
79
|
-
for (const dep of nativeDeps) {
|
|
80
|
-
const depPath = path.join(rootDir, 'node_modules', dep);
|
|
81
|
-
if (!fs.existsSync(depPath)) {
|
|
82
|
-
log(` ⚠ 缺少依赖: ${dep}`, YELLOW);
|
|
83
|
-
allOk = false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return allOk;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function setupPlatform() {
|
|
91
|
-
const platform = process.platform;
|
|
92
|
-
|
|
93
|
-
log(`\n 平台: ${platform}`, CYAN);
|
|
94
|
-
|
|
95
|
-
if (platform === 'win32') {
|
|
96
|
-
// Windows: 确保 .cmd 文件存在
|
|
97
|
-
const binDir = path.join(rootDir, 'bin');
|
|
98
|
-
const cmdPath = path.join(binDir, 'bolloon.cmd');
|
|
99
|
-
|
|
100
|
-
if (fs.existsSync(binDir) && !fs.existsSync(cmdPath)) {
|
|
101
|
-
const cmdContent = `@echo off
|
|
102
|
-
node "%~dp0..\\dist\\cli.js" %*
|
|
103
|
-
`;
|
|
104
|
-
fs.writeFileSync(cmdPath, cmdContent);
|
|
105
|
-
log(' ✓ Windows 入口已创建', GREEN);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
// Unix/Linux/Mac: 确保 bin 文件可执行
|
|
109
|
-
const binDir = path.join(rootDir, 'bin');
|
|
110
|
-
const binPath = path.join(binDir, 'bolloon.js');
|
|
111
|
-
|
|
112
|
-
if (fs.existsSync(binPath)) {
|
|
113
|
-
try {
|
|
114
|
-
fs.chmodSync(binPath, 0o755);
|
|
115
|
-
log(' ✓ bin/bolloon.js 已设为可执行', GREEN);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
log(` ⚠ 无法设置执行权限: ${err.message}`, YELLOW);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function main() {
|
|
124
|
-
console.log('\n📦 Bolloon 安装后处理...\n');
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
// 1. 初始化用户目录
|
|
128
|
-
const bolloonDir = initUserDirs();
|
|
129
|
-
log(` ✓ 用户数据目录: ${bolloonDir}`, GREEN);
|
|
130
|
-
|
|
131
|
-
// 2. 检查依赖
|
|
132
|
-
const depsOk = checkNativeDeps();
|
|
133
|
-
if (!depsOk) {
|
|
134
|
-
log('\n ⚠ 部分依赖缺失,建议运行: npm install', YELLOW);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// 3. 平台特定设置
|
|
138
|
-
setupPlatform();
|
|
139
|
-
|
|
140
|
-
console.log('\n✅ 安装完成!\n');
|
|
141
|
-
console.log(' 使用方式:');
|
|
142
|
-
console.log(' bolloon # 启动 GUI');
|
|
143
|
-
console.log(' bolloon --web # 启动 Web UI');
|
|
144
|
-
console.log(' bolloon --cli # 命令行模式');
|
|
145
|
-
console.log(' bolloon --help # 显示帮助\n');
|
|
146
|
-
console.log(` 配置文件: ${path.join(bolloonDir, 'config.json')}\n`);
|
|
147
|
-
} catch (err) {
|
|
148
|
-
console.error('\n❌ 安装后处理失败:', err.message);
|
|
149
|
-
console.error(' 这通常不影响基本功能,继续安装...\n');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
main();
|