teamsmith 0.4.5 → 0.4.6
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 +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +13 -1
- package/skills/teamsmith/SKILL.md +1 -1
- package/skills/teamsmith/extension/team-bg.ts +7 -8
- package/skills/teamsmith/extension/team-inbox-watch.ts +136 -3
- package/skills/teamsmith/references/protocol.md +2 -3
- package/skills/teamsmith/references/reminders.md +55 -12
- package/skills/teamsmith/references/workflows.md +1 -3
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +18 -1
- package/skills/teamsmith/scripts/lib/cmd-project.sh +12 -9
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +49 -10
- package/skills/teamsmith/scripts/lib/cmd-update.sh +90 -88
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +281 -155
- package/skills/teamsmith/scripts/lib/common.sh +74 -14
- package/skills/teamsmith/scripts/panel/panel.js +134 -134
- package/skills/teamsmith/scripts/panel/src/data.ts +51 -0
- package/skills/teamsmith/scripts/panel/src/layout.ts +10 -0
- package/skills/teamsmith/scripts/panel/src/main.tsx +27 -0
- package/skills/teamsmith/scripts/remind-store.mjs +362 -6
- package/skills/teamsmith/scripts/remind-tick.mjs +102 -0
- package/skills/teamsmith/scripts/reminder-delivery.mjs +76 -0
- package/skills/teamsmith/scripts/state-authority.mjs +265 -17
- 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 +3 -3
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +2 -3
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +11 -5
- package/skills/teamsmith/tests/death-cause.sh +5 -0
- package/skills/teamsmith/tests/help-surface.sh +15 -150
- package/skills/teamsmith/tests/isolation-ledger.sh +85 -0
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +17 -1
- package/skills/teamsmith/tests/live-capture-probe.sh +12 -2
- package/skills/teamsmith/tests/pulse-nudge-key.sh +5 -0
- package/skills/teamsmith/tests/remind-delivery-node.mjs +176 -0
- package/skills/teamsmith/tests/remind-delivery.sh +611 -0
- package/skills/teamsmith/tests/section-paths.tsv +6 -6
- package/skills/teamsmith/tests/smoke.sh +397 -107
- package/skills/teamsmith/tests/state-authority.sh +246 -26
- 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 +1 -1
|
@@ -741,11 +741,22 @@ team_cmd_watch() {
|
|
|
741
741
|
team_hdr "teamsmith pulse · $TEAM_PROJECT(每 ${interval}s 一次;Ctrl-C 退出)"
|
|
742
742
|
team_dim " 只做两件事:记录容量趋势 | PM 没在跑就在它的窗口里把 $(team_pm_cli_name) 拉起来"
|
|
743
743
|
team_dim " 不管 tmux 布局,不管 agent(agent 归 PM 管:team resume)"
|
|
744
|
+
# agent-self-reminder 4.1:巡检节拍之外再加一个**轻量**的到期检查(默认 I10s)。它不是第二个后端、
|
|
745
|
+
# 不重扫项目、不调用模型:remind-tick.mjs 读一份有界快照,只在真到点时拿一次权威锁。完整巡检的
|
|
746
|
+
# 周期不变(下一个巡检点按 duration 从本次结束算,不会因为切片而变密)。
|
|
747
|
+
local slice="${TEAM_REMIND_TICK_SECS:-10}" next_patrol=0 now pulse_started
|
|
748
|
+
case "$slice" in ''|*[!0-9]*|0) slice=10 ;; esac
|
|
749
|
+
pulse_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
744
750
|
while :; do
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
751
|
+
now="$(date +%s)"
|
|
752
|
+
team_remind_due_tick "$pulse_started"
|
|
753
|
+
if [ "$now" -ge "$next_patrol" ]; then
|
|
754
|
+
# M9.8:判定必须用磁盘上的代码(漂移就重启本进程)—— 否则唤醒理由可能比 digest 旧
|
|
755
|
+
team_watch_reexec_if_stale "$fp0" watch ${argv[@]+"${argv[@]}"}
|
|
756
|
+
team_watch_once
|
|
757
|
+
next_patrol=$(( $(date +%s) + interval ))
|
|
758
|
+
fi
|
|
759
|
+
sleep "$slice" & wait $!
|
|
749
760
|
done
|
|
750
761
|
}
|
|
751
762
|
|
|
@@ -975,8 +986,9 @@ team_panel_pm_json() { # PM 状态用**闭集**词表:running|starting|absent|
|
|
|
975
986
|
}
|
|
976
987
|
|
|
977
988
|
team_panel_standby_json() {
|
|
978
|
-
|
|
979
|
-
|
|
989
|
+
# 全屏面板吞不下诊断(stderr 会弄花整帧):读不到权威时按 off 显示,诊断留给 `team standby status`。
|
|
990
|
+
if team_in_standby 2>/dev/null; then
|
|
991
|
+
printf '{"on": true, "reason": %s}' "$(team_panel_json_str "$(team_standby_reason 2>/dev/null || echo '-')")"
|
|
980
992
|
else
|
|
981
993
|
printf '{"on": false, "reason": ""}'
|
|
982
994
|
fi
|
|
@@ -1252,9 +1264,10 @@ team_panel_change_tasks_json() { # <change id> → "tasks": [...], "tasks_more":
|
|
|
1252
1264
|
team_panel_changes_json() {
|
|
1253
1265
|
local spec_dir dir bin listed="" src="dir" out="[" first=1 id done total age phase n_changes=0
|
|
1254
1266
|
spec_dir="$(team_spec_dir_abs)"; dir="$spec_dir/changes"
|
|
1255
|
-
#
|
|
1256
|
-
#
|
|
1257
|
-
if
|
|
1267
|
+
# 软链按**落点**判(P424):`openspec` 或 `openspec/changes` 整体搬到项目内别处照常列;
|
|
1268
|
+
# 落点在项目根外才一条都不列 —— 列表跟详情走同一条判据,不把根外条目画成可 enter 的行。
|
|
1269
|
+
if ! team_panel_detail_container_ok "$spec_dir" "$spec_dir" \
|
|
1270
|
+
|| ! team_panel_detail_container_ok "$spec_dir" "$dir"; then
|
|
1258
1271
|
printf '{"available": false, "source": "none", "changes": [], "count": 0}'; return 0
|
|
1259
1272
|
fi
|
|
1260
1273
|
bin="$(team_openspec_bin_path 2>/dev/null || true)"
|
|
@@ -1296,8 +1309,9 @@ team_panel_changes_json() {
|
|
|
1296
1309
|
team_panel_specs_json() {
|
|
1297
1310
|
local spec_dir bin listed="" src="dir" out="[" first=1 name reqs count=0 total=0 line
|
|
1298
1311
|
spec_dir="$(team_spec_dir_abs)"
|
|
1299
|
-
#
|
|
1300
|
-
if
|
|
1312
|
+
# 同 changes:软链按落点判,项目内照常列,根外一条都不列。
|
|
1313
|
+
if ! team_panel_detail_container_ok "$spec_dir" "$spec_dir" \
|
|
1314
|
+
|| ! team_panel_detail_container_ok "$spec_dir" "$spec_dir/specs"; then
|
|
1301
1315
|
printf '{"available": false, "count": 0, "requirements": 0, "specs": []}'; return 0
|
|
1302
1316
|
fi
|
|
1303
1317
|
bin="$(team_openspec_bin_path 2>/dev/null || true)"
|
|
@@ -1334,8 +1348,10 @@ team_panel_specs_json() {
|
|
|
1334
1348
|
|
|
1335
1349
|
team_panel_decisions_json() { # DECISIONS.md:标题数 + 最新三条(新→旧)
|
|
1336
1350
|
local f="$TEAM_DOCS_ABS/DECISIONS.md" out="[" first=1 line count=0
|
|
1337
|
-
#
|
|
1338
|
-
|
|
1351
|
+
# 软链按落点判:账本搬到项目内别处(例如 `docs/team` 指到项目内另一棵树)照常列,
|
|
1352
|
+
# 落点在项目根外才不列(详情面会点名真实落点与项目根)。
|
|
1353
|
+
if ! team_panel_detail_container_ok "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS" \
|
|
1354
|
+
|| ! team_panel_detail_container_ok "$TEAM_DOCS_ABS" "$f"; then
|
|
1339
1355
|
printf '{"count": 0, "recent": []}'; return 0
|
|
1340
1356
|
fi
|
|
1341
1357
|
[ -f "$f" ] || { printf '{"count": 0, "recent": []}'; return 0; }
|
|
@@ -1437,35 +1453,104 @@ team_panel_settings_json() {
|
|
|
1437
1453
|
# `--file` 只服务**发现集里的**路径:任何别的路径都非 0 且不打印内容——面板不会变成任意文件读取器。
|
|
1438
1454
|
# 正文上限 128 KiB(超出截断并带 truncated 标记),UTF-8 边界用 iconv -c 收尾。
|
|
1439
1455
|
|
|
1440
|
-
# 发现记录:每行 `<相对路径>\t<tab 名>\t<字节数>\t
|
|
1456
|
+
# 发现记录:每行 `<相对路径>\t<tab 名>\t<字节数>\t<flag>\t<note>`,顺序 = 树上/账本上的呈现序。
|
|
1441
1457
|
# source 缺省 entry(既有语义逐字不变);spec/change/decision 三类见各自函数。
|
|
1442
|
-
#
|
|
1458
|
+
# P424:flag=0 = 可服务(note = 路径上经过的软链段,`|` 连接,可为空),flag=1 = 拒绝(note = 真实
|
|
1459
|
+
# 落点与边界)。被拒的路径排除出发现集(`--file` 选不到它)并在 reason 里点名两个路径。
|
|
1443
1460
|
team_panel_detail_rel() { # <绝对路径> → 相对 main root(不在 root 下时原样)
|
|
1444
1461
|
local f="$1"
|
|
1445
1462
|
case "$f" in "$TEAM_MAIN_ROOT"/*) printf '%s' "${f#"$TEAM_MAIN_ROOT"/}" ;; *) printf '%s' "$f" ;; esac
|
|
1446
1463
|
}
|
|
1447
1464
|
|
|
1448
|
-
#
|
|
1449
|
-
#
|
|
1450
|
-
#
|
|
1451
|
-
#
|
|
1452
|
-
#
|
|
1453
|
-
#
|
|
1454
|
-
#
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1465
|
+
# ---- 详情读路径的落点判据(P424)---------------------------------------------------------
|
|
1466
|
+
# 软链不再按「路径上任一段是软链」一律拒绝:项目内的软链是用户自己的账本摆放(例如 ai_interview 的
|
|
1467
|
+
# `docs/team → ai-interview-algo/docs/team`),读它没有越界风险。越界的定义是**解析后的落点**:
|
|
1468
|
+
# * 落点在边界内(允许根在项目内时 = 项目根的物理路径)→ 可读,并把经过的软链段如实报给详情块;
|
|
1469
|
+
# * 落点在边界外 → 拒绝,点名「真实落点」与边界(不再只报「哪一段是软链」);
|
|
1470
|
+
# * 允许根**在项目外**(绝对路径的 TEAM_DOCS_DIR / TEAM_SPEC_DIR)时没有更外层的可信锚点 ——
|
|
1471
|
+
# 边界就是那个根自己(与改动前的锚点语义一致,不把根外布局读穿)。
|
|
1472
|
+
# 判据只有这一份:发现面(能不能进发现集)、读面(open 之后从 fd 量身份与落点)与列表块都用它。
|
|
1473
|
+
team_panel_detail_project_real() { # 项目根的物理路径(TEAM_MAIN_ROOT 自己是软链属本机布局)
|
|
1474
|
+
local real
|
|
1475
|
+
real="$(cd "$TEAM_MAIN_ROOT" 2>/dev/null && pwd -P)" || return 1
|
|
1476
|
+
printf '%s' "${real:-/}"
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
# 逐段解析到物理落点:先跟完叶节点的软链(环上限 40),再把父目录 `pwd -P`(中间段软链一起解析)。
|
|
1480
|
+
# 落点不存在 / 解析不出 → rc 1(调用方按「不可读」处理,不做更宽的猜)。
|
|
1481
|
+
team_panel_detail_landing() { # <abs> → 物理落点
|
|
1482
|
+
local p="$1" d b t hops=0
|
|
1483
|
+
case "$p" in /*) ;; *) return 1 ;; esac
|
|
1484
|
+
while [ -L "$p" ]; do
|
|
1485
|
+
hops=$((hops + 1))
|
|
1486
|
+
[ "$hops" -le 40 ] || return 1
|
|
1487
|
+
t="$(readlink -- "$p" 2>/dev/null)" || return 1
|
|
1488
|
+
[ -n "$t" ] || return 1
|
|
1489
|
+
case "$t" in
|
|
1490
|
+
/*) p="$t" ;;
|
|
1491
|
+
*) d="$(dirname -- "$p")"; p="$d/$t" ;;
|
|
1492
|
+
esac
|
|
1493
|
+
done
|
|
1494
|
+
[ -e "$p" ] || return 1
|
|
1495
|
+
d="$(cd "$(dirname -- "$p")" 2>/dev/null && pwd -P)" || return 1
|
|
1496
|
+
b="$(basename -- "$p")" || return 1
|
|
1497
|
+
case "$d" in /) printf '/%s' "$b" ;; *) printf '%s/%s' "${d%/}" "$b" ;; esac
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
# 落点边界:允许根在项目内(或允许根本身就是项目根)→ 项目根的物理路径;允许根在项目外 → 允许根自己。
|
|
1501
|
+
# 拿不到允许根的物理路径 → rc 1(fail-closed:拿不到边界就不放行)。
|
|
1502
|
+
team_panel_detail_boundary() { # <允许根|->
|
|
1503
|
+
local root="${1:-}" real
|
|
1504
|
+
case "$root" in
|
|
1505
|
+
-|'') root="$TEAM_MAIN_ROOT" ;;
|
|
1506
|
+
esac
|
|
1507
|
+
case "$root" in
|
|
1508
|
+
"$TEAM_MAIN_ROOT"|"$TEAM_MAIN_ROOT"/*) team_panel_detail_project_real ;;
|
|
1509
|
+
*)
|
|
1510
|
+
[ -d "$root" ] || return 1
|
|
1511
|
+
real="$(cd "$root" 2>/dev/null && pwd -P)" || return 1
|
|
1512
|
+
printf '%s' "${real%/}"
|
|
1513
|
+
;;
|
|
1514
|
+
esac
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
team_panel_detail_within() { # <边界 abs> <落点 abs>
|
|
1518
|
+
case "$2" in "$1"|"$1"/*) return 0 ;; esac
|
|
1519
|
+
return 1
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
# 落点判定:rc=0 在边界内;rc=1 越界(打印「<真实落点> 不在 <边界> 内」);rc=5 解析不出。
|
|
1523
|
+
# 调用方把 rc=1 的这段字串拼进「软链拒绝:」后面的原因里 —— 两个路径都点名,排错时不用猜。
|
|
1524
|
+
team_panel_detail_landing_reason() { # <允许根> <abs>
|
|
1525
|
+
local root="$1" abs="$2" real boundary
|
|
1526
|
+
real="$(team_panel_detail_landing "$abs")" || return 5
|
|
1527
|
+
boundary="$(team_panel_detail_boundary "$root")" || return 5
|
|
1528
|
+
team_panel_detail_within "$boundary" "$real" && return 0
|
|
1529
|
+
printf '%s 不在 %s 内' "$real" "$boundary"
|
|
1530
|
+
return 1
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
# 容器段(`openspec`、`docs`、`docs/team` 这类目录/文件):不存在的段不在这里判(缺目录由各块自己的
|
|
1534
|
+
# 缺省分支处理),存在就必须落在边界内 —— 列表块用它决定「照常列」还是「一条都不列」。
|
|
1535
|
+
team_panel_detail_container_ok() { # <允许根> <abs 目录/文件>
|
|
1536
|
+
[ -e "$2" ] || return 0
|
|
1537
|
+
team_panel_detail_landing_reason "$1" "$2" >/dev/null
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
# 路径上从项目根到候选的**软链段**(相对项目根,`|` 连接;没有软链 → 空)。详情块把它当排错线索
|
|
1541
|
+
# 如实报告(`links` 字段),不当错误:项目内软链是合法布局。
|
|
1542
|
+
team_panel_detail_link_segs() { # <abs>
|
|
1543
|
+
local abs="$1" rel cur c out=""
|
|
1544
|
+
rel="$(team_panel_detail_rel "$abs")"
|
|
1545
|
+
[ "$rel" != "$abs" ] || return 0
|
|
1461
1546
|
cur="$TEAM_MAIN_ROOT"
|
|
1462
1547
|
local IFS=/
|
|
1463
1548
|
for c in $rel; do
|
|
1464
1549
|
[ -n "$c" ] || continue
|
|
1465
1550
|
cur="$cur/$c"
|
|
1466
|
-
if [ -L "$cur" ]; then
|
|
1551
|
+
if [ -L "$cur" ]; then out="${out:+$out|}${cur#"$TEAM_MAIN_ROOT"/}"; fi
|
|
1467
1552
|
done
|
|
1468
|
-
|
|
1553
|
+
printf '%s' "$out"
|
|
1469
1554
|
}
|
|
1470
1555
|
|
|
1471
1556
|
team_panel_detail_source_root() { # <source> → 该 source 的允许根(entry/decision 不走软链目录判定)
|
|
@@ -1484,49 +1569,33 @@ team_panel_detail_stat_id() { # <follow|nofollow> <路径>
|
|
|
1484
1569
|
esac
|
|
1485
1570
|
}
|
|
1486
1571
|
|
|
1487
|
-
#
|
|
1488
|
-
#
|
|
1489
|
-
#
|
|
1490
|
-
#
|
|
1491
|
-
#
|
|
1492
|
-
#
|
|
1493
|
-
#
|
|
1494
|
-
#
|
|
1495
|
-
# rc=
|
|
1572
|
+
# 读面判据(P424):把「判」与「读」合成原子 —— 一次 open,之后只从**同一个 fd** 读。
|
|
1573
|
+
# * 落点 = fd 解析出的物理路径(`/proc/self/fd`,`/dev/fd` 兜底),必须在**边界**内:项目内的软链
|
|
1574
|
+
# (`docs/team` 指到项目内别处、`openspec` 整体搬家)照常读,越界(`/etc`、项目外的工作树…)仍然
|
|
1575
|
+
# 一个字节都不读。
|
|
1576
|
+
# * `stat -L` 的 fd 身份必须等于 `stat -L` 路径此刻的身份 —— open 前后被换成别的文件(含换成软链)
|
|
1577
|
+
# 仍然拒绝;正文只从 fd 读,所以「判据作用的对象」与「读出的内容」是同一个 inode。
|
|
1578
|
+
# * 非普通文件(FIFO、设备、目录、坏链)在 open **之前**就挡下:bash 没有 O_NONBLOCK 的 open,
|
|
1579
|
+
# FIFO 的 open 会一直等写者。发现面已按 `-f` 过滤过一次,这里是读前再判一次。
|
|
1580
|
+
# rc=0 读到(可能空正文 —— 与 `head -c` 打不开同形);rc=3 越界 / open 前后被换;rc=4 既没有
|
|
1581
|
+
# /proc/self/fd 也没有 /dev/fd(拿不到 fd 身份就不读,宁可拒也不拿可能被换过的路径去读)。
|
|
1496
1582
|
# `<cap>` 写 `-` = 读到 EOF(决策源要拿到整篇才能切片)。
|
|
1497
1583
|
team_panel_detail_read_nofollow() { # <允许根|-> <abs> <cap>
|
|
1498
|
-
local root="$1" abs="$2" cap="$3" id_fd="" id_path="" p
|
|
1584
|
+
local root="$1" abs="$2" cap="$3" id_fd="" id_path="" p boundary real
|
|
1585
|
+
[ -f "$abs" ] || return 0
|
|
1499
1586
|
{ exec 9<"$abs"; } 2>/dev/null || return 0
|
|
1500
1587
|
for p in /proc/self/fd/9 /dev/fd/9; do
|
|
1501
1588
|
id_fd="$(team_panel_detail_stat_id follow "$p")"
|
|
1502
1589
|
[ -n "$id_fd" ] && break
|
|
1503
1590
|
done
|
|
1504
1591
|
if [ -z "$id_fd" ]; then exec 9<&-; return 4; fi
|
|
1505
|
-
id_path="$(team_panel_detail_stat_id
|
|
1592
|
+
id_path="$(team_panel_detail_stat_id follow "$abs")"
|
|
1506
1593
|
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
|
|
1594
|
+
# 判据作用于**读的那个对象**:句柄自己解析出的物理路径必须在边界内(项目根;允许根在项目外时是
|
|
1595
|
+
# 允许根自己)。拿不到句柄路径或边界 → 拒绝(fail-closed)。
|
|
1596
|
+
real="$(readlink /proc/self/fd/9 2>/dev/null || readlink /dev/fd/9 2>/dev/null)"
|
|
1597
|
+
boundary="$(team_panel_detail_boundary "$root")"
|
|
1598
|
+
if [ -z "$real" ] || [ -z "$boundary" ] || ! team_panel_detail_within "$boundary" "$real"; then
|
|
1530
1599
|
exec 9<&-; return 3
|
|
1531
1600
|
fi
|
|
1532
1601
|
if [ "$cap" = - ]; then
|
|
@@ -1538,85 +1607,117 @@ team_panel_detail_read_nofollow() { # <允许根|-> <abs> <cap>
|
|
|
1538
1607
|
return 0
|
|
1539
1608
|
}
|
|
1540
1609
|
|
|
1610
|
+
# 一条发现记录(P424):`<相对路径>\t<tab>\t<字节>\t<flag>\t<note>`。
|
|
1611
|
+
# flag=0 = 可服务(note = 路径上经过的软链段,`|` 连接,可为空);flag=1 = 拒绝(note = 真实落点与
|
|
1612
|
+
# 边界)。落点解析不出的文件不进发现集(与改动前的「坏链不可读」同形)。
|
|
1613
|
+
team_panel_detail_record_file() { # <允许根> <abs 文件> <tab> <字节>
|
|
1614
|
+
local root="$1" f="$2" tab="$3" size="${4:-0}" note rc
|
|
1615
|
+
rc=0
|
|
1616
|
+
note="$(team_panel_detail_landing_reason "$root" "$f")" || rc=$?
|
|
1617
|
+
case "$rc" in
|
|
1618
|
+
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")" ;;
|
|
1619
|
+
1) printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$tab" "$size" "1" "$note" ;;
|
|
1620
|
+
*) return 0 ;;
|
|
1621
|
+
esac
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
# 非普通文件的人话类型(FIFO / 设备 / 目录 / 套接字 / 坏链)——拒绝原因要说得清拒绝的是什么。
|
|
1625
|
+
team_panel_detail_type_name() { # <abs>
|
|
1626
|
+
if [ -p "$1" ]; then printf 'FIFO'; return 0; fi
|
|
1627
|
+
if [ -b "$1" ] || [ -c "$1" ]; then printf '设备文件'; return 0; fi
|
|
1628
|
+
if [ -d "$1" ]; then printf '目录'; return 0; fi
|
|
1629
|
+
if [ -S "$1" ]; then printf '套接字'; return 0; fi
|
|
1630
|
+
if [ -L "$1" ]; then printf '坏链'; return 0; fi
|
|
1631
|
+
printf '不是普通文件'
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
# 发现集的一条候选(P424):普通文件走落点判据;存在但不是普通文件的不服务、但要**点名**(FIFO 在
|
|
1635
|
+
# open 上会一直等写者,所以它连读面都进不去);不存在的候选静静跳过(各块自己的缺省分支会持)。
|
|
1636
|
+
team_panel_detail_record_path() { # <允许根> <abs> <tab>
|
|
1637
|
+
if [ -f "$2" ]; then
|
|
1638
|
+
# 读不到字节数(权限/IO)按 0 报:大小是展示值,不是判据(判据是落点与文件类型)。
|
|
1639
|
+
team_panel_detail_record_file "$1" "$2" "$3" "$(wc -c < "$2" 2>/dev/null | tr -d ' ' || true)"
|
|
1640
|
+
return 0
|
|
1641
|
+
fi
|
|
1642
|
+
if [ -e "$2" ] || [ -L "$2" ]; then
|
|
1643
|
+
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")"
|
|
1644
|
+
fi
|
|
1645
|
+
return 0
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1541
1648
|
team_panel_detail_records_entry() { # <id>
|
|
1542
1649
|
local LC_ALL=C
|
|
1543
|
-
local id="$1" f name suffix tab size
|
|
1544
|
-
#
|
|
1545
|
-
if
|
|
1546
|
-
|
|
1547
|
-
|
|
1650
|
+
local id="$1" f name suffix tab size note rc first=1
|
|
1651
|
+
# 账本根(`docs` 或 `docs/team`)整体是软链时按落点判:项目内照常发现,项目外整条拒绝并点名。
|
|
1652
|
+
if [ -e "$TEAM_DOCS_ABS" ] || [ -L "$TEAM_DOCS_ABS" ]; then
|
|
1653
|
+
rc=0
|
|
1654
|
+
note="$(team_panel_detail_landing_reason "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS")" || rc=$?
|
|
1655
|
+
if [ "$rc" != 0 ]; then
|
|
1656
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1657
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$TEAM_DOCS_ABS")" "brief" "0" "1" "$note"
|
|
1658
|
+
return 0
|
|
1659
|
+
fi
|
|
1548
1660
|
fi
|
|
1549
1661
|
[ -d "$TEAM_DOCS_ABS" ] || return 0
|
|
1550
1662
|
for f in "$TEAM_DOCS_ABS/tasks/$id"-*.md; do
|
|
1551
|
-
[ -f "$f" ] || continue
|
|
1552
1663
|
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"
|
|
1664
|
+
tab="brief"; [ "$first" = 1 ] || tab="brief:$suffix"
|
|
1665
|
+
[ -f "$f" ] && first=0
|
|
1666
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "$tab"
|
|
1558
1667
|
done
|
|
1559
1668
|
for f in "$TEAM_DOCS_ABS/reports/$id"-*.md; do
|
|
1560
|
-
[ -f "$f" ] || continue
|
|
1561
1669
|
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"
|
|
1670
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "report:$suffix"
|
|
1566
1671
|
done
|
|
1567
1672
|
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"
|
|
1673
|
+
if [ -f "$f" ] || [ -e "$f" ] || [ -L "$f" ]; then
|
|
1674
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "review"
|
|
1573
1675
|
fi
|
|
1574
1676
|
for f in "$TEAM_DOCS_ABS/reviews/$id"-*.md; do
|
|
1575
|
-
[ -f "$f" ] || continue
|
|
1576
1677
|
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"
|
|
1678
|
+
team_panel_detail_record_path "$TEAM_DOCS_ABS" "$f" "review:$suffix"
|
|
1581
1679
|
done
|
|
1582
1680
|
return 0
|
|
1583
1681
|
}
|
|
1584
1682
|
|
|
1585
1683
|
# source spec:`<spec_dir>/specs/<capability>/spec.md`(唯一的那个文件,tab `spec`)。
|
|
1586
1684
|
team_panel_detail_records_spec() { # <capability>
|
|
1587
|
-
local id="$1" f size
|
|
1685
|
+
local id="$1" f size note rc root
|
|
1588
1686
|
root="$(team_spec_dir_abs)/specs"
|
|
1589
1687
|
f="$root/$id/spec.md"
|
|
1590
|
-
#
|
|
1591
|
-
if
|
|
1592
|
-
|
|
1593
|
-
|
|
1688
|
+
# 目录段(`specs/<cap>` 是软链)按落点判(`-f`/`-d` 都会跟随它):项目内照常读,根外整条拒绝并点名。
|
|
1689
|
+
if [ -e "$root/$id" ] || [ -L "$root/$id" ]; then
|
|
1690
|
+
rc=0
|
|
1691
|
+
note="$(team_panel_detail_landing_reason "$root" "$root/$id")" || 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 "$root/$id")" "spec" "0" "1" "$note"
|
|
1695
|
+
return 0
|
|
1696
|
+
fi
|
|
1594
1697
|
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"
|
|
1698
|
+
if [ ! -f "$f" ] && [ ! -e "$f" ] && [ ! -L "$f" ]; then return 0; fi
|
|
1699
|
+
team_panel_detail_record_path "$root" "$f" "spec"
|
|
1600
1700
|
}
|
|
1601
1701
|
|
|
1602
1702
|
# source change:该 change 自己的 proposal/design/tasks(按此序,缺的不补;archive 到不了)。
|
|
1603
1703
|
team_panel_detail_records_change() { # <change id>
|
|
1604
|
-
local id="$1" dir f name size
|
|
1704
|
+
local id="$1" dir f name size note rc root
|
|
1605
1705
|
root="$(team_spec_dir_abs)/changes"
|
|
1606
1706
|
dir="$root/$id"
|
|
1607
|
-
# 同上:`changes/<id>`
|
|
1608
|
-
if
|
|
1609
|
-
|
|
1610
|
-
|
|
1707
|
+
# 同上:`changes/<id>` 是软链时按落点判 —— 项目内(例如整棵 openspec 搬到项目里)照常读,根外拒绝。
|
|
1708
|
+
if [ -e "$dir" ] || [ -L "$dir" ]; then
|
|
1709
|
+
rc=0
|
|
1710
|
+
note="$(team_panel_detail_landing_reason "$root" "$dir")" || rc=$?
|
|
1711
|
+
if [ "$rc" != 0 ]; then
|
|
1712
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1713
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$dir")" "change" "0" "1" "$note"
|
|
1714
|
+
return 0
|
|
1715
|
+
fi
|
|
1611
1716
|
fi
|
|
1612
1717
|
[ -d "$dir" ] || return 0
|
|
1613
1718
|
for name in proposal design tasks; do
|
|
1614
1719
|
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"
|
|
1720
|
+
team_panel_detail_record_path "$root" "$f" "$name"
|
|
1620
1721
|
done
|
|
1621
1722
|
}
|
|
1622
1723
|
|
|
@@ -1649,21 +1750,25 @@ team_panel_detail_decision_slice() { # <D编号> [文件](缺省账本;`-` =
|
|
|
1649
1750
|
|
|
1650
1751
|
# source decision:只服务所请求条目的切片(不提供整文件出口)。
|
|
1651
1752
|
team_panel_detail_records_decision() { # <D编号>
|
|
1652
|
-
local id="$1" f="$TEAM_DOCS_ABS/DECISIONS.md" slice size
|
|
1653
|
-
#
|
|
1654
|
-
if
|
|
1655
|
-
|
|
1656
|
-
|
|
1753
|
+
local id="$1" f="$TEAM_DOCS_ABS/DECISIONS.md" slice size note rc
|
|
1754
|
+
# 账本本身是软链时按落点判:项目内照常读,根外整条拒绝并点名(正文一个字节都不读)。
|
|
1755
|
+
if [ -e "$f" ] || [ -L "$f" ]; then
|
|
1756
|
+
rc=0
|
|
1757
|
+
note="$(team_panel_detail_landing_reason "$TEAM_DOCS_ABS" "$f")" || rc=$?
|
|
1758
|
+
if [ "$rc" != 0 ]; then
|
|
1759
|
+
[ "$rc" = 5 ] && note="落点解析不出(目标不存在或链成环)"
|
|
1760
|
+
printf '%s\t%s\t%s\t%s\t%s\n' "$(team_panel_detail_rel "$f")" "$id" "0" "1" "$note"
|
|
1761
|
+
return 0
|
|
1762
|
+
fi
|
|
1657
1763
|
fi
|
|
1658
1764
|
[ -f "$f" ] || return 0
|
|
1659
1765
|
slice="$(team_panel_detail_decision_slice "$id")"
|
|
1660
1766
|
[ -n "$slice" ] || return 0
|
|
1661
1767
|
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"
|
|
1768
|
+
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
1769
|
}
|
|
1666
1770
|
|
|
1771
|
+
|
|
1667
1772
|
team_panel_detail_records() { # <id> [source]
|
|
1668
1773
|
case "${2:-entry}" in
|
|
1669
1774
|
entry) team_panel_detail_records_entry "$1" ;;
|
|
@@ -1699,12 +1804,21 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1699
1804
|
esac
|
|
1700
1805
|
fi
|
|
1701
1806
|
local -a paths=() tabs=() sizes=()
|
|
1702
|
-
local path tab size flag refused=""
|
|
1703
|
-
while IFS=$'\t' read -r path tab size flag; do
|
|
1807
|
+
local path tab size flag note refused="" refused_type="" links=""
|
|
1808
|
+
while IFS=$'\t' read -r path tab size flag note; do
|
|
1704
1809
|
[ -n "$path" ] || continue
|
|
1705
|
-
#
|
|
1706
|
-
if [ "${flag:-0}" = 1 ]; then
|
|
1810
|
+
# 被拒的路径不进发现集(`--file` 选不到、正文不读),原因里点名它 + 真实落点与边界。
|
|
1811
|
+
if [ "${flag:-0}" = 1 ]; then
|
|
1812
|
+
refused="${refused:+$refused · }$path${note:+($note)}"
|
|
1813
|
+
continue
|
|
1814
|
+
fi
|
|
1815
|
+
# 不是普通文件(FIFO / 设备 / 目录 / 坏链):同样不进发现集,但拒绝原因要说清它是什么。
|
|
1816
|
+
if [ "${flag:-0}" = 2 ]; then
|
|
1817
|
+
refused_type="${refused_type:+$refused_type · }$path${note:+($note)}"
|
|
1818
|
+
continue
|
|
1819
|
+
fi
|
|
1707
1820
|
paths+=("$path"); tabs+=("$tab"); sizes+=("${size:-0}")
|
|
1821
|
+
[ -z "${note:-}" ] || links="${links:+$links|}$note"
|
|
1708
1822
|
done < <(team_panel_detail_records "$id" "$source")
|
|
1709
1823
|
local n="${#paths[@]}" i pick=0
|
|
1710
1824
|
if [ -n "$want" ]; then
|
|
@@ -1726,27 +1840,27 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1726
1840
|
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
1841
|
done
|
|
1728
1842
|
out="$out]"
|
|
1729
|
-
local file="" text="" truncated=false abs read_hit="" read_unchecked="" read_root="-" read_rc=0 decision_rel="" decision_body=""
|
|
1843
|
+
local file="" text="" truncated=false abs read_hit="" read_unchecked="" read_root="-" read_rc=0 read_note="" decision_rel="" decision_body=""
|
|
1730
1844
|
if [ "$n" -gt 0 ]; then
|
|
1731
1845
|
file="${paths[$pick]}"
|
|
1732
1846
|
case "$file" in /*) abs="$file" ;; *) abs="$TEAM_MAIN_ROOT/$file" ;; esac
|
|
1733
|
-
# 路径级复判(发现与读取两处都判):发现之后、读之前路径被换成软链也不读 —— 这里顺手点名命中的那一段。
|
|
1734
|
-
# F3:entry/decision 两类也判(锚点是项目根:`docs` 本身是软链时点名 `docs`)。
|
|
1735
1847
|
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 ;;
|
|
1848
|
+
spec|change) read_root="$(team_panel_detail_source_root "$source")" ;;
|
|
1849
|
+
entry|decision) read_root="$TEAM_DOCS_ABS" ;;
|
|
1744
1850
|
esac
|
|
1851
|
+
# 读前再判一次落点(发现之后、读之前路径被换成指向根外的软链):判据与发现面同源;
|
|
1852
|
+
# 原因里同时点名真实落点与边界,越界的路径一个字节都不读。
|
|
1853
|
+
read_rc=0
|
|
1854
|
+
read_note="$(team_panel_detail_landing_reason "$read_root" "$abs")" || read_rc=$?
|
|
1855
|
+
if [ "$read_rc" = 1 ]; then
|
|
1856
|
+
read_hit="$file($read_note)"; file=""
|
|
1857
|
+
fi
|
|
1745
1858
|
if [ -n "$read_hit" ]; then
|
|
1746
|
-
: #
|
|
1859
|
+
: # 越界:正文一个字节都不读(下面 reason 里点名)
|
|
1747
1860
|
elif [ "$source" = decision ]; then
|
|
1748
|
-
#
|
|
1749
|
-
#
|
|
1861
|
+
# 决策源也是「发现到的路径」:先原子读账本,再从**读到的那份正文**切片 —— 账本在发现之后被换掉,
|
|
1862
|
+
# 切出来的一样不是树外内容。
|
|
1863
|
+
read_rc=0
|
|
1750
1864
|
decision_rel="$(team_panel_detail_rel "$TEAM_DOCS_ABS/DECISIONS.md")"
|
|
1751
1865
|
decision_body="$(team_panel_detail_read_nofollow "$TEAM_DOCS_ABS" "$TEAM_DOCS_ABS/DECISIONS.md" -)" || read_rc=$?
|
|
1752
1866
|
case "$read_rc" in
|
|
@@ -1755,11 +1869,8 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1755
1869
|
*) 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
1870
|
esac
|
|
1757
1871
|
else
|
|
1758
|
-
#
|
|
1759
|
-
|
|
1760
|
-
spec|change) read_root="$(team_panel_detail_source_root "$source")" ;;
|
|
1761
|
-
entry) read_root="$TEAM_DOCS_ABS" ;;
|
|
1762
|
-
esac
|
|
1872
|
+
# 读面原子化:判据与读取作用于同一个 inode(open 一次 + fd 身份 + 落点现查)。
|
|
1873
|
+
read_rc=0
|
|
1763
1874
|
text="$(team_panel_detail_read_nofollow "$read_root" "$abs" "$cap")" || read_rc=$?
|
|
1764
1875
|
case "$read_rc" in
|
|
1765
1876
|
3) read_hit="$file"; file="" ;;
|
|
@@ -1768,14 +1879,17 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1768
1879
|
fi
|
|
1769
1880
|
[ "${sizes[$pick]}" -gt "$cap" ] && truncated=true
|
|
1770
1881
|
fi
|
|
1771
|
-
|
|
1882
|
+
|
|
1883
|
+
# 被拒的路径点名(越界软链 / 不是普通文件);目标根本不存在时给可读原因(不是错误帧,
|
|
1884
|
+
# 也不拿邻居的正文充数)。
|
|
1772
1885
|
local reason=""
|
|
1773
1886
|
if [ -n "$read_hit" ]; then
|
|
1774
1887
|
reason="软链拒绝:$read_hit"
|
|
1775
1888
|
elif [ -n "$read_unchecked" ]; then
|
|
1776
1889
|
reason="读取身份无法确认(没有 /proc/self/fd 也没有 /dev/fd):$read_unchecked"
|
|
1777
|
-
elif [ -n "$refused" ]; then
|
|
1778
|
-
reason="软链拒绝:$refused"
|
|
1890
|
+
elif [ -n "$refused" ] || [ -n "$refused_type" ]; then
|
|
1891
|
+
[ -z "$refused" ] || reason="软链拒绝:$refused"
|
|
1892
|
+
[ -z "$refused_type" ] || reason="${reason:+$reason · }不是普通文件,不打开:$refused_type"
|
|
1779
1893
|
elif [ "$n" -eq 0 ]; then
|
|
1780
1894
|
case "$source" in
|
|
1781
1895
|
spec) reason="${TEAM_SPEC_DIR:-openspec}/specs/$id/spec.md 不存在" ;;
|
|
@@ -1783,11 +1897,23 @@ team_panel_detail_json() { # <id> [file] [source]
|
|
|
1783
1897
|
decision) reason="DECISIONS.md 里没有 $id" ;;
|
|
1784
1898
|
esac
|
|
1785
1899
|
fi
|
|
1900
|
+
# P424:项目内的软链照常读,但把经过的软链段如实报出来(`links`,排错线索,不是错误、不再挡读)。
|
|
1901
|
+
local links_json="" seg seen=" "
|
|
1902
|
+
if [ -n "$links" ]; then
|
|
1903
|
+
while IFS= read -r seg; do
|
|
1904
|
+
[ -n "$seg" ] || continue
|
|
1905
|
+
case "$seen" in *" $seg "*) continue ;; esac
|
|
1906
|
+
seen="$seen$seg "
|
|
1907
|
+
links_json="$links_json${links_json:+, }$(team_panel_json_str "$seg")"
|
|
1908
|
+
done < <(printf '%s\n' "$links" | tr '|' '\n')
|
|
1909
|
+
fi
|
|
1910
|
+
local links_json_field=""
|
|
1911
|
+
[ -n "$links_json" ] && links_json_field=", \"links\": [$links_json]"
|
|
1786
1912
|
local reason_json=""
|
|
1787
1913
|
[ -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' \
|
|
1914
|
+
printf '{"id": %s, "count": %s, "file": %s, "text": %s, "truncated": %s, "files": %s%s%s}\n' \
|
|
1789
1915
|
"$(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"
|
|
1916
|
+
"$(team_panel_json_str_ml "$text")" "$truncated" "$out" "$links_json_field" "$reason_json"
|
|
1791
1917
|
}
|
|
1792
1918
|
|
|
1793
1919
|
# ---- 关键回复块(change: pulse-key-replies):三个 console-only 只读块,直接进 helper。
|
|
@@ -2238,7 +2364,7 @@ team_cmd_standby() {
|
|
|
2238
2364
|
local action="status" reason="-"
|
|
2239
2365
|
while [ $# -gt 0 ]; do
|
|
2240
2366
|
case "$1" in
|
|
2241
|
-
on|off|status) action="$1"; shift ;;
|
|
2367
|
+
on|off|status|migrate) action="$1"; shift ;;
|
|
2242
2368
|
--reason) reason="${2:?}"; shift 2 ;;
|
|
2243
2369
|
-*) team_usage_die "standby: 未知参数 $1" ;;
|
|
2244
2370
|
*) team_usage_die "standby: 多余参数 $1" ;;
|
|
@@ -2246,23 +2372,23 @@ team_cmd_standby() {
|
|
|
2246
2372
|
done
|
|
2247
2373
|
case "$action" in
|
|
2248
2374
|
on)
|
|
2249
|
-
|
|
2375
|
+
# 写失败就停住:一个报错的 `standby on` 之后团队到底是不是待命,不能靠猜。
|
|
2376
|
+
team_standby_on "$reason" || team_die "待命没有写进去(上面是权威层的原因);状态未变,修好后重跑"
|
|
2250
2377
|
team_wlog "standby on(原因:$reason)"
|
|
2251
2378
|
team_ok "已进入待命:pulse 不会再叫醒 PM(原因:$reason)"
|
|
2252
2379
|
team_dim " 待办不会丢:积压会记进 ${TEAM_STATE_DIR#"$TEAM_MAIN_ROOT"/}/watchdog.log;恢复用 $TEAM_CLI standby off"
|
|
2253
2380
|
;;
|
|
2254
2381
|
off)
|
|
2255
|
-
team_standby_off
|
|
2382
|
+
team_standby_off || team_die "待命没有关掉(上面是权威层的原因);状态未变,修好后重跑"
|
|
2256
2383
|
team_wlog "standby off"
|
|
2257
2384
|
team_ok "已退出待命:下个巡检周期起,有待办就会叫醒/拉起 PM"
|
|
2258
2385
|
;;
|
|
2386
|
+
migrate)
|
|
2387
|
+
# 旧 state/standby 一次性并入统一状态(保留原因/时间,不加代次);重复跑不变。
|
|
2388
|
+
team_standby_migrate || team_die "待命迁移失败(上面是权威层的原因);统一状态未有改动"
|
|
2389
|
+
;;
|
|
2259
2390
|
*)
|
|
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
|
|
2391
|
+
team_standby_status || team_die "读不到待命状态(上面是权威层的原因)"
|
|
2266
2392
|
local pend; pend="$(team_pending_text "$(team_panel_pending_counts_fast || true)")"
|
|
2267
2393
|
printf '待办:%s\n' "${pend:-无}"
|
|
2268
2394
|
;;
|