teamsmith 0.4.5 → 0.4.7
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 +6 -6
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +37 -1
- package/skills/teamsmith/SKILL.md +32 -23
- package/skills/teamsmith/extension/team-bg.ts +12 -11
- package/skills/teamsmith/extension/team-inbox-watch.ts +149 -5
- package/skills/teamsmith/extension/team-notify.ts +20 -13
- package/skills/teamsmith/extension/team-remind.ts +189 -0
- package/skills/teamsmith/extension/team-reply.ts +4 -7
- package/skills/teamsmith/references/migration.md +101 -0
- package/skills/teamsmith/references/openspec.md +43 -27
- package/skills/teamsmith/references/protocol.md +28 -18
- package/skills/teamsmith/references/reminders.md +133 -98
- package/skills/teamsmith/references/troubleshooting.md +12 -7
- package/skills/teamsmith/references/workflows.md +85 -34
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +28 -5
- package/skills/teamsmith/scripts/lib/cmd-project.sh +100 -15
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +135 -10
- package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
- package/skills/teamsmith/scripts/lib/cmd-update.sh +90 -88
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +322 -159
- package/skills/teamsmith/scripts/lib/common.sh +156 -26
- package/skills/teamsmith/scripts/panel/panel.js +182 -182
- package/skills/teamsmith/scripts/panel/src/data.ts +113 -6
- package/skills/teamsmith/scripts/panel/src/layout.ts +26 -4
- package/skills/teamsmith/scripts/panel/src/main.tsx +103 -14
- package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
- package/skills/teamsmith/scripts/remind-store.mjs +404 -17
- package/skills/teamsmith/scripts/remind-tick.mjs +105 -0
- package/skills/teamsmith/scripts/reminder-delivery.mjs +76 -0
- package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
- package/skills/teamsmith/scripts/state-authority.mjs +334 -20
- package/skills/teamsmith/scripts/strings/commands.tsv +3 -3
- package/skills/teamsmith/scripts/strings/help.en.tsv +12 -12
- package/skills/teamsmith/scripts/strings/help.zh.tsv +12 -12
- package/skills/teamsmith/scripts/team +4 -3
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +13 -11
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
- package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +36 -18
- package/skills/teamsmith/templates/report.md.tmpl +33 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
- package/skills/teamsmith/tests/bg-ledger.sh +24 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
- package/skills/teamsmith/tests/death-cause.sh +5 -0
- package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
- package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
- package/skills/teamsmith/tests/help-surface.sh +14 -151
- package/skills/teamsmith/tests/isolation-ledger.sh +89 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
- package/skills/teamsmith/tests/key-replies.sh +307 -106
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +17 -1
- package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
- package/skills/teamsmith/tests/live-capture-probe.sh +12 -2
- package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
- package/skills/teamsmith/tests/pulse-nudge-key.sh +5 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
- package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
- package/skills/teamsmith/tests/remind-cli.sh +108 -3
- package/skills/teamsmith/tests/remind-delivery-node.mjs +189 -0
- package/skills/teamsmith/tests/remind-delivery.sh +699 -0
- package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
- package/skills/teamsmith/tests/remind-pulse.sh +199 -0
- package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
- package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
- package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
- package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
- package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
- package/skills/teamsmith/tests/routes.sh +213 -293
- package/skills/teamsmith/tests/section-paths.tsv +14 -12
- package/skills/teamsmith/tests/smoke.sh +876 -130
- package/skills/teamsmith/tests/state-authority.sh +392 -28
- package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +58 -8
- package/skills/teamsmith/tests/tmux-identity-leak.sh +12 -16
- package/skills/teamsmith-init/SKILL.md +5 -5
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
|
@@ -731,21 +731,69 @@ team_cmd_watch() {
|
|
|
731
731
|
|
|
732
732
|
team_require_cmd tmux "pulse 需要 tmux 来拉起 PM/agent"
|
|
733
733
|
team_watch_lock || return 1
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
734
|
+
local patrol_pid='' recovery_pid='' sleep_pid='' recovery_pending=0 recovery_seen=''
|
|
735
|
+
team_watch_loop_alive() { # <pid>:kill -0 对等待 wait 的僵尸仍为真,不能拿它当“还在跑”
|
|
736
|
+
local stat; stat="$(ps -o stat= -p "$1" 2>/dev/null | tr -d '[:space:]')"
|
|
737
|
+
[ -n "$stat" ] && [[ "$stat" != Z* ]]
|
|
738
|
+
}
|
|
739
|
+
team_watch_loop_cleanup() {
|
|
740
|
+
local pid child
|
|
741
|
+
for pid in "$patrol_pid" "$recovery_pid" "$sleep_pid"; do
|
|
742
|
+
[ -n "$pid" ] || continue
|
|
743
|
+
# The patrol/recovery is a shell child; stop its current external command too (for example a
|
|
744
|
+
# patrol sleep), then wait for the direct child. A process that already exited is expected here.
|
|
745
|
+
for child in $(ps -o pid= --ppid "$pid" 2>/dev/null); do
|
|
746
|
+
kill "$child" 2>/dev/null || true # 留:外部命令可能已先退出;仍须继续回收其余子进程
|
|
747
|
+
done
|
|
748
|
+
kill "$pid" 2>/dev/null || true # 留:登记的子进程可能已先退出;继续解锁
|
|
749
|
+
wait "$pid" 2>/dev/null || true # 留:被 TERM 的子进程 wait 返回 143(或已被回收),这不是清理失败
|
|
750
|
+
done
|
|
751
|
+
team_watch_unlock
|
|
752
|
+
}
|
|
753
|
+
trap 'team_watch_loop_cleanup' EXIT
|
|
754
|
+
# INT/TERM 必须立刻生效:sleep 放后台 + wait(被捕获的信号会立刻打断 wait),handler 里 exit 走 EXIT trap。
|
|
738
755
|
trap 'exit 130' INT
|
|
739
756
|
trap 'exit 143' TERM
|
|
740
757
|
fp0="$(team_watch_code_fp)"
|
|
741
758
|
team_hdr "teamsmith pulse · $TEAM_PROJECT(每 ${interval}s 一次;Ctrl-C 退出)"
|
|
742
759
|
team_dim " 只做两件事:记录容量趋势 | PM 没在跑就在它的窗口里把 $(team_pm_cli_name) 拉起来"
|
|
743
760
|
team_dim " 不管 tmux 布局,不管 agent(agent 归 PM 管:team resume)"
|
|
761
|
+
# agent-self-reminder 4.1:巡检节拍之外再加一个**轻量**的到期检查(默认 I10s)。它不是第二个后端、
|
|
762
|
+
# 不重扫项目、不调用模型:remind-tick.mjs 读一份有界快照,只在真到点时拿一次权威锁。完整巡检的
|
|
763
|
+
# 周期不变(下一个巡检点按 duration 从本次结束算,不会因为切片而变密)。
|
|
764
|
+
local slice="${TEAM_REMIND_TICK_SECS:-10}" next_patrol=0 now pulse_started
|
|
765
|
+
case "$slice" in ''|*[!0-9]*|0) slice=10 ;; esac
|
|
766
|
+
pulse_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
744
767
|
while :; do
|
|
745
|
-
#
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
768
|
+
# Reap first: a finished child must never look like an in-flight reason to skip the coalesced recheck.
|
|
769
|
+
if [ -n "$patrol_pid" ] && ! team_watch_loop_alive "$patrol_pid"; then
|
|
770
|
+
wait "$patrol_pid"; patrol_pid=''; next_patrol=$(( $(date +%s) + interval )); recovery_seen=''
|
|
771
|
+
fi
|
|
772
|
+
if [ -n "$recovery_pid" ] && ! team_watch_loop_alive "$recovery_pid"; then
|
|
773
|
+
wait "$recovery_pid"; recovery_pid=''
|
|
774
|
+
fi
|
|
775
|
+
|
|
776
|
+
# The lightweight child is synchronous and independent of the long patrol below. Queueing can
|
|
777
|
+
# therefore commit during that patrol; one bit coalesces every recovery need until it ends.
|
|
778
|
+
team_remind_due_tick "$pulse_started"
|
|
779
|
+
if [ "${TEAM_REMIND_RECOVERY_REQUIRED:-0}" = "1" ] && [ "${TEAM_REMIND_RECOVERY_SIGNATURE:-}" != "$recovery_seen" ]; then
|
|
780
|
+
recovery_pending=1
|
|
781
|
+
fi
|
|
782
|
+
|
|
783
|
+
# A due ordinary patrol goes first; recovery runs in the gap after it. Without this priority a
|
|
784
|
+
# permanently refused recovery would consume every free slot and starve the ordinary patrol.
|
|
785
|
+
now="$(date +%s)"
|
|
786
|
+
if [ "$now" -ge "$next_patrol" ] && [ -z "$patrol_pid" ] && [ -z "$recovery_pid" ]; then
|
|
787
|
+
# M9.8:判定必须用磁盘上的代码(漂移就重启本进程)—— 否则唤醒理由可能比 digest 旧
|
|
788
|
+
team_watch_reexec_if_stale "$fp0" watch ${argv[@]+"${argv[@]}"}
|
|
789
|
+
team_watch_once & patrol_pid=$!
|
|
790
|
+
fi
|
|
791
|
+
if [ -z "$patrol_pid" ] && [ -z "$recovery_pid" ] && [ "$recovery_pending" = "1" ]; then
|
|
792
|
+
recovery_pending=0; recovery_seen="${TEAM_REMIND_RECOVERY_SIGNATURE:-}"
|
|
793
|
+
team_remind_recovery "$pulse_started" & recovery_pid=$!
|
|
794
|
+
fi
|
|
795
|
+
sleep "$slice" & sleep_pid=$!
|
|
796
|
+
wait "$sleep_pid"; sleep_pid=''
|
|
749
797
|
done
|
|
750
798
|
}
|
|
751
799
|
|
|
@@ -975,8 +1023,9 @@ team_panel_pm_json() { # PM 状态用**闭集**词表:running|starting|absent|
|
|
|
975
1023
|
}
|
|
976
1024
|
|
|
977
1025
|
team_panel_standby_json() {
|
|
978
|
-
|
|
979
|
-
|
|
1026
|
+
# 全屏面板吞不下诊断(stderr 会弄花整帧):读不到权威时按 off 显示,诊断留给 `team standby status`。
|
|
1027
|
+
if team_in_standby 2>/dev/null; then
|
|
1028
|
+
printf '{"on": true, "reason": %s}' "$(team_panel_json_str "$(team_standby_reason 2>/dev/null || echo '-')")"
|
|
980
1029
|
else
|
|
981
1030
|
printf '{"on": false, "reason": ""}'
|
|
982
1031
|
fi
|
|
@@ -1252,9 +1301,10 @@ team_panel_change_tasks_json() { # <change id> → "tasks": [...], "tasks_more":
|
|
|
1252
1301
|
team_panel_changes_json() {
|
|
1253
1302
|
local spec_dir dir bin listed="" src="dir" out="[" first=1 id done total age phase n_changes=0
|
|
1254
1303
|
spec_dir="$(team_spec_dir_abs)"; dir="$spec_dir/changes"
|
|
1255
|
-
#
|
|
1256
|
-
#
|
|
1257
|
-
if
|
|
1304
|
+
# 软链按**落点**判(P424):`openspec` 或 `openspec/changes` 整体搬到项目内别处照常列;
|
|
1305
|
+
# 落点在项目根外才一条都不列 —— 列表跟详情走同一条判据,不把根外条目画成可 enter 的行。
|
|
1306
|
+
if ! team_panel_detail_container_ok "$spec_dir" "$spec_dir" \
|
|
1307
|
+
|| ! team_panel_detail_container_ok "$spec_dir" "$dir"; then
|
|
1258
1308
|
printf '{"available": false, "source": "none", "changes": [], "count": 0}'; return 0
|
|
1259
1309
|
fi
|
|
1260
1310
|
bin="$(team_openspec_bin_path 2>/dev/null || true)"
|
|
@@ -1296,8 +1346,9 @@ team_panel_changes_json() {
|
|
|
1296
1346
|
team_panel_specs_json() {
|
|
1297
1347
|
local spec_dir bin listed="" src="dir" out="[" first=1 name reqs count=0 total=0 line
|
|
1298
1348
|
spec_dir="$(team_spec_dir_abs)"
|
|
1299
|
-
#
|
|
1300
|
-
if
|
|
1349
|
+
# 同 changes:软链按落点判,项目内照常列,根外一条都不列。
|
|
1350
|
+
if ! team_panel_detail_container_ok "$spec_dir" "$spec_dir" \
|
|
1351
|
+
|| ! team_panel_detail_container_ok "$spec_dir" "$spec_dir/specs"; then
|
|
1301
1352
|
printf '{"available": false, "count": 0, "requirements": 0, "specs": []}'; return 0
|
|
1302
1353
|
fi
|
|
1303
1354
|
bin="$(team_openspec_bin_path 2>/dev/null || true)"
|
|
@@ -1334,8 +1385,10 @@ team_panel_specs_json() {
|
|
|
1334
1385
|
|
|
1335
1386
|
team_panel_decisions_json() { # DECISIONS.md:标题数 + 最新三条(新→旧)
|
|
1336
1387
|
local f="$TEAM_DOCS_ABS/DECISIONS.md" out="[" first=1 line count=0
|
|
1337
|
-
#
|
|
1338
|
-
|
|
1388
|
+
# 软链按落点判:账本搬到项目内别处(例如 `docs/team` 指到项目内另一棵树)照常列,
|
|
1389
|
+
# 落点在项目根外才不列(详情面会点名真实落点与项目根)。
|
|
1390
|
+
if ! team_panel_detail_container_ok "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS" \
|
|
1391
|
+
|| ! team_panel_detail_container_ok "$TEAM_DOCS_ABS" "$f"; then
|
|
1339
1392
|
printf '{"count": 0, "recent": []}'; return 0
|
|
1340
1393
|
fi
|
|
1341
1394
|
[ -f "$f" ] || { printf '{"count": 0, "recent": []}'; return 0; }
|
|
@@ -1437,35 +1490,104 @@ team_panel_settings_json() {
|
|
|
1437
1490
|
# `--file` 只服务**发现集里的**路径:任何别的路径都非 0 且不打印内容——面板不会变成任意文件读取器。
|
|
1438
1491
|
# 正文上限 128 KiB(超出截断并带 truncated 标记),UTF-8 边界用 iconv -c 收尾。
|
|
1439
1492
|
|
|
1440
|
-
# 发现记录:每行 `<相对路径>\t<tab 名>\t<字节数>\t
|
|
1493
|
+
# 发现记录:每行 `<相对路径>\t<tab 名>\t<字节数>\t<flag>\t<note>`,顺序 = 树上/账本上的呈现序。
|
|
1441
1494
|
# source 缺省 entry(既有语义逐字不变);spec/change/decision 三类见各自函数。
|
|
1442
|
-
#
|
|
1495
|
+
# P424:flag=0 = 可服务(note = 路径上经过的软链段,`|` 连接,可为空),flag=1 = 拒绝(note = 真实
|
|
1496
|
+
# 落点与边界)。被拒的路径排除出发现集(`--file` 选不到它)并在 reason 里点名两个路径。
|
|
1443
1497
|
team_panel_detail_rel() { # <绝对路径> → 相对 main root(不在 root 下时原样)
|
|
1444
1498
|
local f="$1"
|
|
1445
1499
|
case "$f" in "$TEAM_MAIN_ROOT"/*) printf '%s' "${f#"$TEAM_MAIN_ROOT"/}" ;; *) printf '%s' "$f" ;; esac
|
|
1446
1500
|
}
|
|
1447
1501
|
|
|
1448
|
-
#
|
|
1449
|
-
#
|
|
1450
|
-
#
|
|
1451
|
-
#
|
|
1452
|
-
#
|
|
1453
|
-
#
|
|
1454
|
-
#
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1502
|
+
# ---- 详情读路径的落点判据(P424)---------------------------------------------------------
|
|
1503
|
+
# 软链不再按「路径上任一段是软链」一律拒绝:项目内的软链是用户自己的账本摆放(例如
|
|
1504
|
+
# `docs/team → module/docs/team`),读它没有越界风险。越界的定义是**解析后的落点**:
|
|
1505
|
+
# * 落点在边界内(允许根在项目内时 = 项目根的物理路径)→ 可读,并把经过的软链段如实报给详情块;
|
|
1506
|
+
# * 落点在边界外 → 拒绝,点名「真实落点」与边界(不再只报「哪一段是软链」);
|
|
1507
|
+
# * 允许根**在项目外**(绝对路径的 TEAM_DOCS_DIR / TEAM_SPEC_DIR)时没有更外层的可信锚点 ——
|
|
1508
|
+
# 边界就是那个根自己(与改动前的锚点语义一致,不把根外布局读穿)。
|
|
1509
|
+
# 判据只有这一份:发现面(能不能进发现集)、读面(open 之后从 fd 量身份与落点)与列表块都用它。
|
|
1510
|
+
team_panel_detail_project_real() { # 项目根的物理路径(TEAM_MAIN_ROOT 自己是软链属本机布局)
|
|
1511
|
+
local real
|
|
1512
|
+
real="$(cd "$TEAM_MAIN_ROOT" 2>/dev/null && pwd -P)" || return 1
|
|
1513
|
+
printf '%s' "${real:-/}"
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
# 逐段解析到物理落点:先跟完叶节点的软链(环上限 40),再把父目录 `pwd -P`(中间段软链一起解析)。
|
|
1517
|
+
# 落点不存在 / 解析不出 → rc 1(调用方按「不可读」处理,不做更宽的猜)。
|
|
1518
|
+
team_panel_detail_landing() { # <abs> → 物理落点
|
|
1519
|
+
local p="$1" d b t hops=0
|
|
1520
|
+
case "$p" in /*) ;; *) return 1 ;; esac
|
|
1521
|
+
while [ -L "$p" ]; do
|
|
1522
|
+
hops=$((hops + 1))
|
|
1523
|
+
[ "$hops" -le 40 ] || return 1
|
|
1524
|
+
t="$(readlink -- "$p" 2>/dev/null)" || return 1
|
|
1525
|
+
[ -n "$t" ] || return 1
|
|
1526
|
+
case "$t" in
|
|
1527
|
+
/*) p="$t" ;;
|
|
1528
|
+
*) d="$(dirname -- "$p")"; p="$d/$t" ;;
|
|
1529
|
+
esac
|
|
1530
|
+
done
|
|
1531
|
+
[ -e "$p" ] || return 1
|
|
1532
|
+
d="$(cd "$(dirname -- "$p")" 2>/dev/null && pwd -P)" || return 1
|
|
1533
|
+
b="$(basename -- "$p")" || return 1
|
|
1534
|
+
case "$d" in /) printf '/%s' "$b" ;; *) printf '%s/%s' "${d%/}" "$b" ;; esac
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
# 落点边界:允许根在项目内(或允许根本身就是项目根)→ 项目根的物理路径;允许根在项目外 → 允许根自己。
|
|
1538
|
+
# 拿不到允许根的物理路径 → rc 1(fail-closed:拿不到边界就不放行)。
|
|
1539
|
+
team_panel_detail_boundary() { # <允许根|->
|
|
1540
|
+
local root="${1:-}" real
|
|
1541
|
+
case "$root" in
|
|
1542
|
+
-|'') root="$TEAM_MAIN_ROOT" ;;
|
|
1543
|
+
esac
|
|
1544
|
+
case "$root" in
|
|
1545
|
+
"$TEAM_MAIN_ROOT"|"$TEAM_MAIN_ROOT"/*) team_panel_detail_project_real ;;
|
|
1546
|
+
*)
|
|
1547
|
+
[ -d "$root" ] || return 1
|
|
1548
|
+
real="$(cd "$root" 2>/dev/null && pwd -P)" || return 1
|
|
1549
|
+
printf '%s' "${real%/}"
|
|
1550
|
+
;;
|
|
1551
|
+
esac
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
team_panel_detail_within() { # <边界 abs> <落点 abs>
|
|
1555
|
+
case "$2" in "$1"|"$1"/*) return 0 ;; esac
|
|
1556
|
+
return 1
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
# 落点判定:rc=0 在边界内;rc=1 越界(打印「<真实落点> 不在 <边界> 内」);rc=5 解析不出。
|
|
1560
|
+
# 调用方把 rc=1 的这段字串拼进「软链拒绝:」后面的原因里 —— 两个路径都点名,排错时不用猜。
|
|
1561
|
+
team_panel_detail_landing_reason() { # <允许根> <abs>
|
|
1562
|
+
local root="$1" abs="$2" real boundary
|
|
1563
|
+
real="$(team_panel_detail_landing "$abs")" || return 5
|
|
1564
|
+
boundary="$(team_panel_detail_boundary "$root")" || return 5
|
|
1565
|
+
team_panel_detail_within "$boundary" "$real" && return 0
|
|
1566
|
+
printf '%s 不在 %s 内' "$real" "$boundary"
|
|
1567
|
+
return 1
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
# 容器段(`openspec`、`docs`、`docs/team` 这类目录/文件):不存在的段不在这里判(缺目录由各块自己的
|
|
1571
|
+
# 缺省分支处理),存在就必须落在边界内 —— 列表块用它决定「照常列」还是「一条都不列」。
|
|
1572
|
+
team_panel_detail_container_ok() { # <允许根> <abs 目录/文件>
|
|
1573
|
+
[ -e "$2" ] || return 0
|
|
1574
|
+
team_panel_detail_landing_reason "$1" "$2" >/dev/null
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
# 路径上从项目根到候选的**软链段**(相对项目根,`|` 连接;没有软链 → 空)。详情块把它当排错线索
|
|
1578
|
+
# 如实报告(`links` 字段),不当错误:项目内软链是合法布局。
|
|
1579
|
+
team_panel_detail_link_segs() { # <abs>
|
|
1580
|
+
local abs="$1" rel cur c out=""
|
|
1581
|
+
rel="$(team_panel_detail_rel "$abs")"
|
|
1582
|
+
[ "$rel" != "$abs" ] || return 0
|
|
1461
1583
|
cur="$TEAM_MAIN_ROOT"
|
|
1462
1584
|
local IFS=/
|
|
1463
1585
|
for c in $rel; do
|
|
1464
1586
|
[ -n "$c" ] || continue
|
|
1465
1587
|
cur="$cur/$c"
|
|
1466
|
-
if [ -L "$cur" ]; then
|
|
1588
|
+
if [ -L "$cur" ]; then out="${out:+$out|}${cur#"$TEAM_MAIN_ROOT"/}"; fi
|
|
1467
1589
|
done
|
|
1468
|
-
|
|
1590
|
+
printf '%s' "$out"
|
|
1469
1591
|
}
|
|
1470
1592
|
|
|
1471
1593
|
team_panel_detail_source_root() { # <source> → 该 source 的允许根(entry/decision 不走软链目录判定)
|
|
@@ -1484,49 +1606,33 @@ team_panel_detail_stat_id() { # <follow|nofollow> <路径>
|
|
|
1484
1606
|
esac
|
|
1485
1607
|
}
|
|
1486
1608
|
|
|
1487
|
-
#
|
|
1488
|
-
#
|
|
1489
|
-
#
|
|
1490
|
-
#
|
|
1491
|
-
#
|
|
1492
|
-
#
|
|
1493
|
-
#
|
|
1494
|
-
#
|
|
1495
|
-
# rc=
|
|
1609
|
+
# 读面判据(P424):把「判」与「读」合成原子 —— 一次 open,之后只从**同一个 fd** 读。
|
|
1610
|
+
# * 落点 = fd 解析出的物理路径(`/proc/self/fd`,`/dev/fd` 兜底),必须在**边界**内:项目内的软链
|
|
1611
|
+
# (`docs/team` 指到项目内别处、`openspec` 整体搬家)照常读,越界(`/etc`、项目外的工作树…)仍然
|
|
1612
|
+
# 一个字节都不读。
|
|
1613
|
+
# * `stat -L` 的 fd 身份必须等于 `stat -L` 路径此刻的身份 —— open 前后被换成别的文件(含换成软链)
|
|
1614
|
+
# 仍然拒绝;正文只从 fd 读,所以「判据作用的对象」与「读出的内容」是同一个 inode。
|
|
1615
|
+
# * 非普通文件(FIFO、设备、目录、坏链)在 open **之前**就挡下:bash 没有 O_NONBLOCK 的 open,
|
|
1616
|
+
# FIFO 的 open 会一直等写者。发现面已按 `-f` 过滤过一次,这里是读前再判一次。
|
|
1617
|
+
# rc=0 读到(可能空正文 —— 与 `head -c` 打不开同形);rc=3 越界 / open 前后被换;rc=4 既没有
|
|
1618
|
+
# /proc/self/fd 也没有 /dev/fd(拿不到 fd 身份就不读,宁可拒也不拿可能被换过的路径去读)。
|
|
1496
1619
|
# `<cap>` 写 `-` = 读到 EOF(决策源要拿到整篇才能切片)。
|
|
1497
1620
|
team_panel_detail_read_nofollow() { # <允许根|-> <abs> <cap>
|
|
1498
|
-
local root="$1" abs="$2" cap="$3" id_fd="" id_path="" p
|
|
1621
|
+
local root="$1" abs="$2" cap="$3" id_fd="" id_path="" p boundary real
|
|
1622
|
+
[ -f "$abs" ] || return 0
|
|
1499
1623
|
{ exec 9<"$abs"; } 2>/dev/null || return 0
|
|
1500
1624
|
for p in /proc/self/fd/9 /dev/fd/9; do
|
|
1501
1625
|
id_fd="$(team_panel_detail_stat_id follow "$p")"
|
|
1502
1626
|
[ -n "$id_fd" ] && break
|
|
1503
1627
|
done
|
|
1504
1628
|
if [ -z "$id_fd" ]; then exec 9<&-; return 4; fi
|
|
1505
|
-
id_path="$(team_panel_detail_stat_id
|
|
1629
|
+
id_path="$(team_panel_detail_stat_id follow "$abs")"
|
|
1506
1630
|
if [ -z "$id_path" ] || [ "$id_fd" != "$id_path" ]; then exec 9<&-; return 3; fi
|
|
1507
|
-
#
|
|
1508
|
-
#
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
local fd_real root_real rel_real anchor="$TEAM_MAIN_ROOT"
|
|
1513
|
-
case "$root" in
|
|
1514
|
-
-|'') anchor="" ;;
|
|
1515
|
-
"$TEAM_MAIN_ROOT"|"$TEAM_MAIN_ROOT"/*) ;;
|
|
1516
|
-
*) anchor="$root" ;;
|
|
1517
|
-
esac
|
|
1518
|
-
# 判据无条件生效(没有「某条件不满足就跳过」的旁路):候选路径**必须**落在锚点之下,且句柄解析出的
|
|
1519
|
-
# 路径**必须逐字节等于**「锚点真实路径 + 字面相对路径」。现有调用图里 abs 全部由允许根与发现集拼出,
|
|
1520
|
-
# 前缀不匹配这条分支不可达;把它写成拒绝(而不是跳过)是为了让未来的调用方出错时也 fail-closed。
|
|
1521
|
-
if [ -n "$anchor" ]; then
|
|
1522
|
-
case "$abs" in "$anchor"/*) rel_real="${abs#"$anchor"/}" ;; *) exec 9<&-; return 3 ;; esac
|
|
1523
|
-
fd_real="$(readlink /proc/self/fd/9 2>/dev/null || readlink /dev/fd/9 2>/dev/null)"
|
|
1524
|
-
root_real="$(cd "$anchor" 2>/dev/null && pwd -P)"
|
|
1525
|
-
if [ -z "$fd_real" ] || [ -z "$root_real" ] || [ "$fd_real" != "$root_real/$rel_real" ]; then
|
|
1526
|
-
exec 9<&-; return 3
|
|
1527
|
-
fi
|
|
1528
|
-
fi
|
|
1529
|
-
if [ -n "$root" ] && [ "$root" != - ] && team_panel_detail_symlink_hit "$root" "$abs" >/dev/null; then
|
|
1631
|
+
# 判据作用于**读的那个对象**:句柄自己解析出的物理路径必须在边界内(项目根;允许根在项目外时是
|
|
1632
|
+
# 允许根自己)。拿不到句柄路径或边界 → 拒绝(fail-closed)。
|
|
1633
|
+
real="$(readlink /proc/self/fd/9 2>/dev/null || readlink /dev/fd/9 2>/dev/null)"
|
|
1634
|
+
boundary="$(team_panel_detail_boundary "$root")"
|
|
1635
|
+
if [ -z "$real" ] || [ -z "$boundary" ] || ! team_panel_detail_within "$boundary" "$real"; then
|
|
1530
1636
|
exec 9<&-; return 3
|
|
1531
1637
|
fi
|
|
1532
1638
|
if [ "$cap" = - ]; then
|
|
@@ -1538,85 +1644,117 @@ team_panel_detail_read_nofollow() { # <允许根|-> <abs> <cap>
|
|
|
1538
1644
|
return 0
|
|
1539
1645
|
}
|
|
1540
1646
|
|
|
1647
|
+
# 一条发现记录(P424):`<相对路径>\t<tab>\t<字节>\t<flag>\t<note>`。
|
|
1648
|
+
# flag=0 = 可服务(note = 路径上经过的软链段,`|` 连接,可为空);flag=1 = 拒绝(note = 真实落点与
|
|
1649
|
+
# 边界)。落点解析不出的文件不进发现集(与改动前的「坏链不可读」同形)。
|
|
1650
|
+
team_panel_detail_record_file() { # <允许根> <abs 文件> <tab> <字节>
|
|
1651
|
+
local root="$1" f="$2" tab="$3" size="${4:-0}" note rc
|
|
1652
|
+
rc=0
|
|
1653
|
+
note="$(team_panel_detail_landing_reason "$root" "$f")" || rc=$?
|
|
1654
|
+
case "$rc" in
|
|
1655
|
+
0) printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$tab" "$size" "0" "$(team_panel_detail_link_segs "$f")" ;;
|
|
1656
|
+
1) printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$tab" "$size" "1" "$note" ;;
|
|
1657
|
+
*) return 0 ;;
|
|
1658
|
+
esac
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
# 非普通文件的人话类型(FIFO / 设备 / 目录 / 套接字 / 坏链)——拒绝原因要说得清拒绝的是什么。
|
|
1662
|
+
team_panel_detail_type_name() { # <abs>
|
|
1663
|
+
if [ -p "$1" ]; then printf 'FIFO'; return 0; fi
|
|
1664
|
+
if [ -b "$1" ] || [ -c "$1" ]; then printf '设备文件'; return 0; fi
|
|
1665
|
+
if [ -d "$1" ]; then printf '目录'; return 0; fi
|
|
1666
|
+
if [ -S "$1" ]; then printf '套接字'; return 0; fi
|
|
1667
|
+
if [ -L "$1" ]; then printf '坏链'; return 0; fi
|
|
1668
|
+
printf '不是普通文件'
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
# 发现集的一条候选(P424):普通文件走落点判据;存在但不是普通文件的不服务、但要**点名**(FIFO 在
|
|
1672
|
+
# open 上会一直等写者,所以它连读面都进不去);不存在的候选静静跳过(各块自己的缺省分支会持)。
|
|
1673
|
+
team_panel_detail_record_path() { # <允许根> <abs> <tab>
|
|
1674
|
+
if [ -f "$2" ]; then
|
|
1675
|
+
# 读不到字节数(权限/IO)按 0 报:大小是展示值,不是判据(判据是落点与文件类型)。
|
|
1676
|
+
team_panel_detail_record_file "$1" "$2" "$3" "$(wc -c < "$2" 2>/dev/null | tr -d ' ' || true)"
|
|
1677
|
+
return 0
|
|
1678
|
+
fi
|
|
1679
|
+
if [ -e "$2" ] || [ -L "$2" ]; then
|
|
1680
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$2")" "$3" "0" "2" "$(team_panel_detail_type_name "$2")"
|
|
1681
|
+
fi
|
|
1682
|
+
return 0
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1541
1685
|
team_panel_detail_records_entry() { # <id>
|
|
1542
1686
|
local LC_ALL=C
|
|
1543
|
-
local id="$1" f name suffix tab size
|
|
1544
|
-
#
|
|
1545
|
-
if
|
|
1546
|
-
|
|
1547
|
-
|
|
1687
|
+
local id="$1" f name suffix tab size note rc first=1
|
|
1688
|
+
# 账本根(`docs` 或 `docs/team`)整体是软链时按落点判:项目内照常发现,项目外整条拒绝并点名。
|
|
1689
|
+
if [ -e "$TEAM_DOCS_ABS" ] || [ -L "$TEAM_DOCS_ABS" ]; then
|
|
1690
|
+
rc=0
|
|
1691
|
+
note="$(team_panel_detail_landing_reason "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS")" || rc=$?
|
|
1692
|
+
if [ "$rc" != 0 ]; then
|
|
1693
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1694
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$TEAM_DOCS_ABS")" "brief" "0" "1" "$note"
|
|
1695
|
+
return 0
|
|
1696
|
+
fi
|
|
1548
1697
|
fi
|
|
1549
1698
|
[ -d "$TEAM_DOCS_ABS" ] || return 0
|
|
1550
1699
|
for f in "$TEAM_DOCS_ABS/tasks/$id"-*.md; do
|
|
1551
|
-
[ -f "$f" ] || continue
|
|
1552
1700
|
name="${f##*/}"; suffix="${name#"$id"-}"; suffix="${suffix%.md}"
|
|
1553
|
-
tab="brief"; [ "$first" = 1 ] || tab="brief:$suffix"
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
refused=0; [ -L "$f" ] && refused=1
|
|
1557
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "$tab" "${size:-0}" "$refused"
|
|
1701
|
+
tab="brief"; [ "$first" = 1 ] || tab="brief:$suffix"
|
|
1702
|
+
[ -f "$f" ] && first=0
|
|
1703
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "$tab"
|
|
1558
1704
|
done
|
|
1559
1705
|
for f in "$TEAM_DOCS_ABS/reports/$id"-*.md; do
|
|
1560
|
-
[ -f "$f" ] || continue
|
|
1561
1706
|
name="${f##*/}"; suffix="${name#"$id"-}"; suffix="${suffix%.md}"
|
|
1562
|
-
|
|
1563
|
-
rel="$(team_panel_detail_rel "$f")"
|
|
1564
|
-
refused=0; [ -L "$f" ] && refused=1
|
|
1565
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "report:$suffix" "${size:-0}" "$refused"
|
|
1707
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "report:$suffix"
|
|
1566
1708
|
done
|
|
1567
1709
|
f="$TEAM_DOCS_ABS/reviews/$id.md"
|
|
1568
|
-
if [ -f "$f" ]; then
|
|
1569
|
-
|
|
1570
|
-
rel="$(team_panel_detail_rel "$f")"
|
|
1571
|
-
refused=0; [ -L "$f" ] && refused=1
|
|
1572
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "review" "${size:-0}" "$refused"
|
|
1710
|
+
if [ -f "$f" ] || [ -e "$f" ] || [ -L "$f" ]; then
|
|
1711
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "review"
|
|
1573
1712
|
fi
|
|
1574
1713
|
for f in "$TEAM_DOCS_ABS/reviews/$id"-*.md; do
|
|
1575
|
-
[ -f "$f" ] || continue
|
|
1576
1714
|
name="${f##*/}"; suffix="${name#"$id"-}"; suffix="${suffix%.md}"
|
|
1577
|
-
|
|
1578
|
-
rel="$(team_panel_detail_rel "$f")"
|
|
1579
|
-
refused=0; [ -L "$f" ] && refused=1
|
|
1580
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "review:$suffix" "${size:-0}" "$refused"
|
|
1715
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "review:$suffix"
|
|
1581
1716
|
done
|
|
1582
1717
|
return 0
|
|
1583
1718
|
}
|
|
1584
1719
|
|
|
1585
1720
|
# source spec:`<spec_dir>/specs/<capability>/spec.md`(唯一的那个文件,tab `spec`)。
|
|
1586
1721
|
team_panel_detail_records_spec() { # <capability>
|
|
1587
|
-
local id="$1" f size
|
|
1722
|
+
local id="$1" f size note rc root
|
|
1588
1723
|
root="$(team_spec_dir_abs)/specs"
|
|
1589
1724
|
f="$root/$id/spec.md"
|
|
1590
|
-
#
|
|
1591
|
-
if
|
|
1592
|
-
|
|
1593
|
-
|
|
1725
|
+
# 目录段(`specs/<cap>` 是软链)按落点判(`-f`/`-d` 都会跟随它):项目内照常读,根外整条拒绝并点名。
|
|
1726
|
+
if [ -e "$root/$id" ] || [ -L "$root/$id" ]; then
|
|
1727
|
+
rc=0
|
|
1728
|
+
note="$(team_panel_detail_landing_reason "$root" "$root/$id")" || rc=$?
|
|
1729
|
+
if [ "$rc" != 0 ]; then
|
|
1730
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1731
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$root/$id")" "spec" "0" "1" "$note"
|
|
1732
|
+
return 0
|
|
1733
|
+
fi
|
|
1594
1734
|
fi
|
|
1595
|
-
[ -f "$f" ]
|
|
1596
|
-
|
|
1597
|
-
rel="$(team_panel_detail_rel "$f")"
|
|
1598
|
-
[ -L "$f" ] && refused=1
|
|
1599
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "spec" "${size:-0}" "$refused"
|
|
1735
|
+
if [ ! -f "$f" ] && [ ! -e "$f" ] && [ ! -L "$f" ]; then return 0; fi
|
|
1736
|
+
team_panel_detail_record_path "$root" "$f" "spec"
|
|
1600
1737
|
}
|
|
1601
1738
|
|
|
1602
1739
|
# source change:该 change 自己的 proposal/design/tasks(按此序,缺的不补;archive 到不了)。
|
|
1603
1740
|
team_panel_detail_records_change() { # <change id>
|
|
1604
|
-
local id="$1" dir f name size
|
|
1741
|
+
local id="$1" dir f name size note rc root
|
|
1605
1742
|
root="$(team_spec_dir_abs)/changes"
|
|
1606
1743
|
dir="$root/$id"
|
|
1607
|
-
# 同上:`changes/<id>`
|
|
1608
|
-
if
|
|
1609
|
-
|
|
1610
|
-
|
|
1744
|
+
# 同上:`changes/<id>` 是软链时按落点判 —— 项目内(例如整棵 openspec 搬到项目里)照常读,根外拒绝。
|
|
1745
|
+
if [ -e "$dir" ] || [ -L "$dir" ]; then
|
|
1746
|
+
rc=0
|
|
1747
|
+
note="$(team_panel_detail_landing_reason "$root" "$dir")" || rc=$?
|
|
1748
|
+
if [ "$rc" != 0 ]; then
|
|
1749
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1750
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$dir")" "change" "0" "1" "$note"
|
|
1751
|
+
return 0
|
|
1752
|
+
fi
|
|
1611
1753
|
fi
|
|
1612
1754
|
[ -d "$dir" ] || return 0
|
|
1613
1755
|
for name in proposal design tasks; do
|
|
1614
1756
|
f="$dir/$name.md"
|
|
1615
|
-
|
|
1616
|
-
size="$(wc -c < "$f" 2>/dev/null | tr -d ' ')"
|
|
1617
|
-
rel="$(team_panel_detail_rel "$f")"
|
|
1618
|
-
refused=0; [ -L "$f" ] && refused=1
|
|
1619
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "$name" "${size:-0}" "$refused"
|
|
1757
|
+
team_panel_detail_record_path "$root" "$f" "$name"
|
|
1620
1758
|
done
|
|
1621
1759
|
}
|
|
1622
1760
|
|
|
@@ -1649,21 +1787,25 @@ team_panel_detail_decision_slice() { # <D编号> [文件](缺省账本;`-` =
|
|
|
1649
1787
|
|
|
1650
1788
|
# source decision:只服务所请求条目的切片(不提供整文件出口)。
|
|
1651
1789
|
team_panel_detail_records_decision() { # <D编号>
|
|
1652
|
-
local id="$1" f="$TEAM_DOCS_ABS/DECISIONS.md" slice size
|
|
1653
|
-
#
|
|
1654
|
-
if
|
|
1655
|
-
|
|
1656
|
-
|
|
1790
|
+
local id="$1" f="$TEAM_DOCS_ABS/DECISIONS.md" slice size note rc
|
|
1791
|
+
# 账本本身是软链时按落点判:项目内照常读,根外整条拒绝并点名(正文一个字节都不读)。
|
|
1792
|
+
if [ -e "$f" ] || [ -L "$f" ]; then
|
|
1793
|
+
rc=0
|
|
1794
|
+
note="$(team_panel_detail_landing_reason "$TEAM_DOCS_ABS" "$f")" || rc=$?
|
|
1795
|
+
if [ "$rc" != 0 ]; then
|
|
1796
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1797
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$id" "0" "1" "$note"
|
|
1798
|
+
return 0
|
|
1799
|
+
fi
|
|
1657
1800
|
fi
|
|
1658
1801
|
[ -f "$f" ] || return 0
|
|
1659
1802
|
slice="$(team_panel_detail_decision_slice "$id")"
|
|
1660
1803
|
[ -n "$slice" ] || return 0
|
|
1661
1804
|
size="$(printf '%s\n' "$slice" | wc -c | tr -d ' ')"
|
|
1662
|
-
|
|
1663
|
-
[ -L "$f" ] && refused=1
|
|
1664
|
-
printf '%s\t%s\t%s\t%s\n' "$rel" "$id" "${size:-0}" "$refused"
|
|
1805
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$id" "${size:-0}" "0" "$(team_panel_detail_link_segs "$f")"
|
|
1665
1806
|
}
|
|
1666
1807
|
|
|
1808
|
+
|
|
1667
1809
|
team_panel_detail_records() { # <id> [source]
|
|
1668
1810
|
case "${2:-entry}" in
|
|
1669
1811
|
entry) team_panel_detail_records_entry "$1" ;;
|
|
@@ -1699,12 +1841,21 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1699
1841
|
esac
|
|
1700
1842
|
fi
|
|
1701
1843
|
local -a paths=() tabs=() sizes=()
|
|
1702
|
-
local path tab size flag refused=""
|
|
1703
|
-
while IFS=$'\t' read -r path tab size flag; do
|
|
1844
|
+
local path tab size flag note refused="" refused_type="" links=""
|
|
1845
|
+
while IFS=$'\t' read -r path tab size flag note; do
|
|
1704
1846
|
[ -n "$path" ] || continue
|
|
1705
|
-
#
|
|
1706
|
-
if [ "${flag:-0}" = 1 ]; then
|
|
1847
|
+
# 被拒的路径不进发现集(`--file` 选不到、正文不读),原因里点名它 + 真实落点与边界。
|
|
1848
|
+
if [ "${flag:-0}" = 1 ]; then
|
|
1849
|
+
refused="${refused:+$refused · }$path${note:+($note)}"
|
|
1850
|
+
continue
|
|
1851
|
+
fi
|
|
1852
|
+
# 不是普通文件(FIFO / 设备 / 目录 / 坏链):同样不进发现集,但拒绝原因要说清它是什么。
|
|
1853
|
+
if [ "${flag:-0}" = 2 ]; then
|
|
1854
|
+
refused_type="${refused_type:+$refused_type · }$path${note:+($note)}"
|
|
1855
|
+
continue
|
|
1856
|
+
fi
|
|
1707
1857
|
paths+=("$path"); tabs+=("$tab"); sizes+=("${size:-0}")
|
|
1858
|
+
[ -z "${note:-}" ] || links="${links:+$links|}$note"
|
|
1708
1859
|
done < <(team_panel_detail_records "$id" "$source")
|
|
1709
1860
|
local n="${#paths[@]}" i pick=0
|
|
1710
1861
|
if [ -n "$want" ]; then
|
|
@@ -1726,27 +1877,27 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1726
1877
|
out="$out{\"tab\": $(team_panel_json_str "${tabs[$i]}"), \"name\": $(team_panel_json_str "${paths[$i]##*/}"), \"path\": $(team_panel_json_str "${paths[$i]}"), \"size\": $(team_panel_num "${sizes[$i]}"), \"truncated\": $t}"
|
|
1727
1878
|
done
|
|
1728
1879
|
out="$out]"
|
|
1729
|
-
local file="" text="" truncated=false abs read_hit="" read_unchecked="" read_root="-" read_rc=0 decision_rel="" decision_body=""
|
|
1880
|
+
local file="" text="" truncated=false abs read_hit="" read_unchecked="" read_root="-" read_rc=0 read_note="" decision_rel="" decision_body=""
|
|
1730
1881
|
if [ "$n" -gt 0 ]; then
|
|
1731
1882
|
file="${paths[$pick]}"
|
|
1732
1883
|
case "$file" in /*) abs="$file" ;; *) abs="$TEAM_MAIN_ROOT/$file" ;; esac
|
|
1733
|
-
# 路径级复判(发现与读取两处都判):发现之后、读之前路径被换成软链也不读 —— 这里顺手点名命中的那一段。
|
|
1734
|
-
# F3:entry/decision 两类也判(锚点是项目根:`docs` 本身是软链时点名 `docs`)。
|
|
1735
1884
|
case "$source" in
|
|
1736
|
-
spec|change)
|
|
1737
|
-
|
|
1738
|
-
file=""
|
|
1739
|
-
fi ;;
|
|
1740
|
-
entry|decision)
|
|
1741
|
-
if read_hit="$(team_panel_detail_symlink_hit "$TEAM_DOCS_ABS" "$abs")"; then
|
|
1742
|
-
file=""
|
|
1743
|
-
fi ;;
|
|
1885
|
+
spec|change) read_root="$(team_panel_detail_source_root "$source")" ;;
|
|
1886
|
+
entry|decision) read_root="$TEAM_DOCS_ABS" ;;
|
|
1744
1887
|
esac
|
|
1888
|
+
# 读前再判一次落点(发现之后、读之前路径被换成指向根外的软链):判据与发现面同源;
|
|
1889
|
+
# 原因里同时点名真实落点与边界,越界的路径一个字节都不读。
|
|
1890
|
+
read_rc=0
|
|
1891
|
+
read_note="$(team_panel_detail_landing_reason "$read_root" "$abs")" || read_rc=$?
|
|
1892
|
+
if [ "$read_rc" = 1 ]; then
|
|
1893
|
+
read_hit="$file($read_note)"; file=""
|
|
1894
|
+
fi
|
|
1745
1895
|
if [ -n "$read_hit" ]; then
|
|
1746
|
-
: #
|
|
1896
|
+
: # 越界:正文一个字节都不读(下面 reason 里点名)
|
|
1747
1897
|
elif [ "$source" = decision ]; then
|
|
1748
|
-
#
|
|
1749
|
-
#
|
|
1898
|
+
# 决策源也是「发现到的路径」:先原子读账本,再从**读到的那份正文**切片 —— 账本在发现之后被换掉,
|
|
1899
|
+
# 切出来的一样不是树外内容。
|
|
1900
|
+
read_rc=0
|
|
1750
1901
|
decision_rel="$(team_panel_detail_rel "$TEAM_DOCS_ABS/DECISIONS.md")"
|
|
1751
1902
|
decision_body="$(team_panel_detail_read_nofollow "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS/DECISIONS.md" -)" || read_rc=$?
|
|
1752
1903
|
case "$read_rc" in
|
|
@@ -1755,11 +1906,8 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1755
1906
|
*) text="$(printf '%s\n' "$decision_body" | team_panel_detail_decision_slice "$id" - | head -c "$cap" | iconv -c -f UTF-8 -t UTF-8 2>/dev/null || true)" ;;
|
|
1756
1907
|
esac
|
|
1757
1908
|
else
|
|
1758
|
-
#
|
|
1759
|
-
|
|
1760
|
-
spec|change) read_root="$(team_panel_detail_source_root "$source")" ;;
|
|
1761
|
-
entry) read_root="$TEAM_DOCS_ABS" ;;
|
|
1762
|
-
esac
|
|
1909
|
+
# 读面原子化:判据与读取作用于同一个 inode(open 一次 + fd 身份 + 落点现查)。
|
|
1910
|
+
read_rc=0
|
|
1763
1911
|
text="$(team_panel_detail_read_nofollow "$read_root" "$abs" "$cap")" || read_rc=$?
|
|
1764
1912
|
case "$read_rc" in
|
|
1765
1913
|
3) read_hit="$file"; file="" ;;
|
|
@@ -1768,14 +1916,17 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1768
1916
|
fi
|
|
1769
1917
|
[ "${sizes[$pick]}" -gt "$cap" ] && truncated=true
|
|
1770
1918
|
fi
|
|
1771
|
-
|
|
1919
|
+
|
|
1920
|
+
# 被拒的路径点名(越界软链 / 不是普通文件);目标根本不存在时给可读原因(不是错误帧,
|
|
1921
|
+
# 也不拿邻居的正文充数)。
|
|
1772
1922
|
local reason=""
|
|
1773
1923
|
if [ -n "$read_hit" ]; then
|
|
1774
1924
|
reason="软链拒绝:$read_hit"
|
|
1775
1925
|
elif [ -n "$read_unchecked" ]; then
|
|
1776
1926
|
reason="读取身份无法确认(没有 /proc/self/fd 也没有 /dev/fd):$read_unchecked"
|
|
1777
|
-
elif [ -n "$refused" ]; then
|
|
1778
|
-
reason="软链拒绝:$refused"
|
|
1927
|
+
elif [ -n "$refused" ] || [ -n "$refused_type" ]; then
|
|
1928
|
+
[ -z "$refused" ] || reason="软链拒绝:$refused"
|
|
1929
|
+
[ -z "$refused_type" ] || reason="${reason:+$reason · }不是普通文件,不打开:$refused_type"
|
|
1779
1930
|
elif [ "$n" -eq 0 ]; then
|
|
1780
1931
|
case "$source" in
|
|
1781
1932
|
spec) reason="${TEAM_SPEC_DIR:-openspec}/specs/$id/spec.md 不存在" ;;
|
|
@@ -1783,11 +1934,23 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1783
1934
|
decision) reason="DECISIONS.md 里没有 $id" ;;
|
|
1784
1935
|
esac
|
|
1785
1936
|
fi
|
|
1937
|
+
# P424:项目内的软链照常读,但把经过的软链段如实报出来(`links`,排错线索,不是错误、不再挡读)。
|
|
1938
|
+
local links_json="" seg seen=" "
|
|
1939
|
+
if [ -n "$links" ]; then
|
|
1940
|
+
while IFS= read -r seg; do
|
|
1941
|
+
[ -n "$seg" ] || continue
|
|
1942
|
+
case "$seen" in *" $seg "*) continue ;; esac
|
|
1943
|
+
seen="$seen$seg "
|
|
1944
|
+
links_json="$links_json${links_json:+, }$(team_panel_json_str "$seg")"
|
|
1945
|
+
done < <(printf '%s\n' "$links" | tr '|' '\n')
|
|
1946
|
+
fi
|
|
1947
|
+
local links_json_field=""
|
|
1948
|
+
[ -n "$links_json" ] && links_json_field=", \"links\": [$links_json]"
|
|
1786
1949
|
local reason_json=""
|
|
1787
1950
|
[ -n "$reason" ] && reason_json=", \"reason\": $(team_panel_json_str "$reason")"
|
|
1788
|
-
printf '{"id": %s, "count": %s, "file": %s, "text": %s, "truncated": %s, "files": %s%s}\n' \
|
|
1951
|
+
printf '{"id": %s, "count": %s, "file": %s, "text": %s, "truncated": %s, "files": %s%s%s}\n' \
|
|
1789
1952
|
"$(team_panel_json_str "$id")" "$(team_panel_num "$n")" "$(team_panel_json_str "$file")" \
|
|
1790
|
-
"$(team_panel_json_str_ml "$text")" "$truncated" "$out" "$reason_json"
|
|
1953
|
+
"$(team_panel_json_str_ml "$text")" "$truncated" "$out" "$links_json_field" "$reason_json"
|
|
1791
1954
|
}
|
|
1792
1955
|
|
|
1793
1956
|
# ---- 关键回复块(change: pulse-key-replies):三个 console-only 只读块,直接进 helper。
|
|
@@ -2238,7 +2401,7 @@ team_cmd_standby() {
|
|
|
2238
2401
|
local action="status" reason="-"
|
|
2239
2402
|
while [ $# -gt 0 ]; do
|
|
2240
2403
|
case "$1" in
|
|
2241
|
-
on|off|status) action="$1"; shift ;;
|
|
2404
|
+
on|off|status|migrate) action="$1"; shift ;;
|
|
2242
2405
|
--reason) reason="${2:?}"; shift 2 ;;
|
|
2243
2406
|
-*) team_usage_die "standby: 未知参数 $1" ;;
|
|
2244
2407
|
*) team_usage_die "standby: 多余参数 $1" ;;
|
|
@@ -2246,23 +2409,23 @@ team_cmd_standby() {
|
|
|
2246
2409
|
done
|
|
2247
2410
|
case "$action" in
|
|
2248
2411
|
on)
|
|
2249
|
-
|
|
2412
|
+
# 写失败就停住:一个报错的 `standby on` 之后团队到底是不是待命,不能靠猜。
|
|
2413
|
+
team_standby_on "$reason" || team_die "待命没有写进去(上面是权威层的原因);状态未变,修好后重跑"
|
|
2250
2414
|
team_wlog "standby on(原因:$reason)"
|
|
2251
2415
|
team_ok "已进入待命:pulse 不会再叫醒 PM(原因:$reason)"
|
|
2252
2416
|
team_dim " 待办不会丢:积压会记进 ${TEAM_STATE_DIR#"$TEAM_MAIN_ROOT"/}/watchdog.log;恢复用 $TEAM_CLI standby off"
|
|
2253
2417
|
;;
|
|
2254
2418
|
off)
|
|
2255
|
-
team_standby_off
|
|
2419
|
+
team_standby_off || team_die "待命没有关掉(上面是权威层的原因);状态未变,修好后重跑"
|
|
2256
2420
|
team_wlog "standby off"
|
|
2257
2421
|
team_ok "已退出待命:下个巡检周期起,有待办就会叫醒/拉起 PM"
|
|
2258
2422
|
;;
|
|
2423
|
+
migrate)
|
|
2424
|
+
# 旧 state/standby 一次性并入统一状态(保留原因/时间,不加代次);重复跑不变。
|
|
2425
|
+
team_standby_migrate || team_die "待命迁移失败(上面是权威层的原因);统一状态未有改动"
|
|
2426
|
+
;;
|
|
2259
2427
|
*)
|
|
2260
|
-
|
|
2261
|
-
local since; since="$(awk '{print $1}' "$(team_standby_file)" 2>/dev/null)"
|
|
2262
|
-
printf 'standby: on(自 %s,原因:%s)\n' "${since:--}" "$(team_standby_reason || echo -)"
|
|
2263
|
-
else
|
|
2264
|
-
printf 'standby: off\n'
|
|
2265
|
-
fi
|
|
2428
|
+
team_standby_status || team_die "读不到待命状态(上面是权威层的原因)"
|
|
2266
2429
|
local pend; pend="$(team_pending_text "$(team_panel_pending_counts_fast || true)")"
|
|
2267
2430
|
printf '待办:%s\n' "${pend:-无}"
|
|
2268
2431
|
;;
|