#!/usr/bin/env bash # 共用模块必须逐字节相同 —— 见 docs/PLUGIN-CONTRACT.md 第六节。 # # 一侧改了另一侧没改,几个平台的行为就会悄悄分叉:同一封邮件在 opencode 那边 # 标了已读、在 DSH 那边没标,而两处代码看起来都"对"。 # # 三方比对以 opencode 为基准逐个对比,而不是两两对比:后者在三方都不同时 # 会打出三条互相矛盾的差异,读的人无从判断谁是对的。 set -euo pipefail BASE=plugins/opencode-mail-bridge PEERS=(plugins/dsh-mail-bridge plugins/pi-mail-bridge) fail=0 for peer in "${PEERS[@]}"; do for f in relay-dedup relay-policy relay-key permission-mode bounded inbox-format session-snapshot workspace model-scope catchup addressing discovery rename-proposal permission-grants adopt sse-client user-question; do if [[ ! -f "$peer/lib/$f.js" ]]; then echo "共用模块缺失:$peer/lib/$f.js" >&2 fail=1 continue fi if ! diff -q "$BASE/lib/$f.js" "$peer/lib/$f.js" >/dev/null 2>&1; then echo "共用模块已分叉:lib/$f.js($BASE vs $peer)" >&2 diff "$BASE/lib/$f.js" "$peer/lib/$f.js" | head -20 >&2 fail=1 fi done # 测试同样要同源:共用模块的行为约定写在测试里, # 只同步实现不同步测试,等于允许一侧偷偷放宽约定。 for f in relay-policy relay-key permission-mode bounded inbox-format session-snapshot workspace model-scope catchup addressing discovery rename-proposal permission-grants adopt sse-client user-question; do if [[ ! -f "$peer/test/$f.test.mjs" ]]; then echo "共用测试缺失:$peer/test/$f.test.mjs" >&2 fail=1 continue fi if ! diff -q "$BASE/test/$f.test.mjs" "$peer/test/$f.test.mjs" >/dev/null 2>&1; then echo "共用测试已分叉:test/$f.test.mjs($BASE vs $peer)" >&2 fail=1 fi done done [[ $fail -eq 0 ]] && echo " 共用模块三方同源(opencode / dsh / pi)" || exit 1