teamsmith 0.3.4 → 0.4.1
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 +8 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +40 -0
- package/skills/teamsmith/SKILL.md +83 -163
- package/skills/teamsmith/extension/team-notify.ts +1 -1
- package/skills/teamsmith/extension/team-reply.ts +105 -0
- package/skills/teamsmith/references/agent-adapters.md +1 -1
- package/skills/teamsmith/references/config.md +20 -11
- package/skills/teamsmith/references/migration.md +47 -3
- package/skills/teamsmith/references/protocol.md +64 -31
- package/skills/teamsmith/references/reminders.md +131 -0
- package/skills/teamsmith/references/troubleshooting.md +19 -5
- package/skills/teamsmith/references/workflows.md +18 -16
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
- package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
- package/skills/teamsmith/scripts/lib/common.sh +44 -4
- package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
- package/skills/teamsmith/scripts/remind-store.mjs +529 -0
- package/skills/teamsmith/scripts/replies.mjs +9 -3
- package/skills/teamsmith/scripts/reply-capture.mjs +612 -0
- package/skills/teamsmith/scripts/state-authority.mjs +500 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
- package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
- package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
- package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
- package/skills/teamsmith/tests/delivery-truth.sh +82 -47
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
- package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
- package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
- package/skills/teamsmith/tests/frames/README.md +3 -1
- package/skills/teamsmith/tests/gate-guard.sh +20 -4
- package/skills/teamsmith/tests/help-surface.sh +60 -2
- package/skills/teamsmith/tests/install-shape.sh +312 -0
- package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
- package/skills/teamsmith/tests/key-replies.sh +187 -68
- package/skills/teamsmith/tests/ledger-claim.sh +8 -6
- package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
- package/skills/teamsmith/tests/lib/pm-window.sh +143 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
- package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
- package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
- package/skills/teamsmith/tests/meta-suite.sh +215 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
- package/skills/teamsmith/tests/panel-b3.sh +33 -4
- package/skills/teamsmith/tests/remind-cli.sh +574 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
- package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture.mjs +756 -0
- package/skills/teamsmith/tests/section-paths.tsv +40 -9
- package/skills/teamsmith/tests/section-select.sh +180 -26
- package/skills/teamsmith/tests/smoke.sh +1235 -238
- package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
- package/skills/teamsmith/tests/state-authority.sh +629 -0
- package/skills/teamsmith/tests/workflow-entry.sh +123 -3
- package/skills/teamsmith-init/SKILL.md +1 -1
|
@@ -88,12 +88,14 @@ team_build_prompt() { # <agent> <ID> <taskfile-abs> <worktree> <model> [<session
|
|
|
88
88
|
grep -qE '^[[:space:]]*issue:' "$taskfile" 2>/dev/null && \
|
|
89
89
|
issue="$(grep -E '^[[:space:]]*issue:' "$taskfile" | head -1 | grep -oE '[0-9]+' | head -1 || true)"
|
|
90
90
|
|
|
91
|
-
# 交付步骤与 forge 无关:skill 不假设任何 forge CLI(gh/glab/tea/curl 都行,由 PM
|
|
91
|
+
# 交付步骤与 forge 无关:skill 不假设任何 forge CLI(gh/glab/tea/curl 都行,由 PM 决定)。
|
|
92
|
+
# local 模式**没有远端**:不许写一条无条件的 push/PR 步骤(那是假指令,worker 会照做并失败);
|
|
93
|
+
# 远端模式的投递方式由 PM 指定,prompt 只说「按 PM 的方式」,不替 PM 承诺 PR。
|
|
92
94
|
local pr_step
|
|
93
95
|
case "$TEAM_VCS" in
|
|
94
|
-
local|"") pr_step="
|
|
95
|
-
*) pr_step="
|
|
96
|
-
(skill 不代做、也不假设 gh/glab
|
|
96
|
+
local|"") pr_step="**不向远端收尾**:本仓库是 local 模式(没有远端)-- 不要 push、不要开 PR/MR,把工作提交在你的任务分支上即可,PM 复验后本地合并" ;;
|
|
97
|
+
*) pr_step="按 PM 指定的投递方式:push 到 \`$TEAM_REMOTE\`(PM 另有指定的远端就按 PM 的),开不开 PR/MR、用哪个 forge 工具都由 PM 决定
|
|
98
|
+
(skill 不代做、也不假设 gh/glab;要你手动调 API 时按 PM 给的方式做,token 不要读进上下文)" ;;
|
|
97
99
|
esac
|
|
98
100
|
|
|
99
101
|
# 通知段(F1/F7/F8):worker 的摘要是**数据**,永远走文件通道 —— 提示词里不含任何 worker 文本,
|
|
@@ -141,8 +143,7 @@ Read these first, in order:
|
|
|
141
143
|
3. The task brief \`$taskfile\`$rel_note -- the single source of scope and acceptance commands
|
|
142
144
|
|
|
143
145
|
Scope discipline: do only what the brief says, and only change directories that OWNERSHIP assigns to you.
|
|
144
|
-
For cross-directory work, do not do it yourself: write \`BLOCKED:\`
|
|
145
|
-
then end the turn.
|
|
146
|
+
For cross-directory work, do not do it yourself: write \`BLOCKED:\` naming who should change what, then end the turn.
|
|
146
147
|
|
|
147
148
|
Red lines: never push $TEAM_PROTECTED_BRANCH, never force-push, never merge PR/MRs, never rebase or delete other
|
|
148
149
|
branches, never change repository settings. Never write tokens/secrets into code, logs or commit messages; never
|
|
@@ -156,27 +157,25 @@ needs to do what -- **cross-project communication is the PM's job via \`$cli mee
|
|
|
156
157
|
advice, problem reports); workers do not attend**. Only decisions that need the user's call go through the user.
|
|
157
158
|
|
|
158
159
|
**Never stop mid-task to ask for confirmation**: end the turn in exactly three situations --
|
|
159
|
-
(a) **delivered**: every acceptance command in the brief has been run + the report is written + the branch is
|
|
160
|
-
|
|
160
|
+
(a) **delivered**: every acceptance command in the brief has been run + the report is written + the branch is settled
|
|
161
|
+
(local: the commits stay on your task branch, nothing is pushed; remote: delivery as the PM directed, with any
|
|
162
|
+
PR/MR the PM asked for);
|
|
161
163
|
(b) **hard-blocked** (missing dependency, missing permission, someone else's bug): notify the PM with
|
|
162
164
|
\`$cli notify pm "<one line>"\`, state \`BLOCKED:\` clearly in the report, then end the turn;
|
|
163
165
|
(c) **suspended on background jobs**: jobs this session started are still running and every step that does not depend
|
|
164
|
-
on their results is done. A suspension is neither a delivery nor a blockage
|
|
165
|
-
verdict
|
|
166
|
-
|
|
166
|
+
on their results is done. A suspension is neither a delivery nor a blockage: do not write the report's final
|
|
167
|
+
verdict or notify \`BLOCKED:\`; end the turn with its **last line** naming every awaited job
|
|
168
|
+
(\`waiting on: <id>[, <id>…]\`), so the PM can see the ending was deliberate.
|
|
167
169
|
**Never work around a boundary on your own.**
|
|
168
170
|
|
|
169
171
|
Delivery process:
|
|
170
172
|
1. Actually run the acceptance commands from the brief. **Never claim something passed without running it** (the PM
|
|
171
173
|
re-verifies independently; a false report fails the task).
|
|
172
174
|
2. Commit every verifiable small step (\`git commit\`, Conventional Commits + task ID + trailer \`Agent: $agent\`${issue:+ + \`Refs #$issue\`}); never one big dump at the end.
|
|
173
|
-
3. Write the report \`$rel_report\` and commit it on your branch
|
|
174
|
-
real
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
(the PM checks this section with \`$cli review $id --strong\` and will send it back if missing).
|
|
178
|
-
4. \`git push -u $TEAM_REMOTE HEAD\`.
|
|
179
|
-
5. $pr_step.
|
|
175
|
+
3. Write the report \`$rel_report\` and commit it on your branch, following \`$TEAM_SKILL_DIR/templates/report.md.tmpl\`
|
|
176
|
+
(deliverables, the real command/output tails, the ledger-ban line, and flip evidence for a defect fix): the PM
|
|
177
|
+
reads it as evidence, not as intentions.
|
|
178
|
+
4. Settle the branch: $pr_step
|
|
180
179
|
|
|
181
180
|
Task: **$id**${issue:+ (issue #$issue)}. The brief \`$taskfile\` is the PM's read-only file -- do not modify it.${bg_block}${notify_block}
|
|
182
181
|
If this is a resumed run: start with \`git status\` / \`git log --oneline -5\` to see how far you got, and continue
|
|
@@ -1621,49 +1620,61 @@ team_require_recipient() { # <recipient> <是否 --any> <命令名>
|
|
|
1621
1620
|
return 1
|
|
1622
1621
|
}
|
|
1623
1622
|
|
|
1623
|
+
# P393:无可用监视通道时,默认 say 直投之前的**目标资格检查**(从 team_cmd_say 原样搬来)。
|
|
1624
|
+
# 位置很关键:它在「选中直投之后、按任何键之前」,所以已选中的监视通道不需要看 pane,而一个不合格的
|
|
1625
|
+
# 注册也不可能绕过它 —— 检查与按键之间不留一个「路由又消失」的空档。
|
|
1626
|
+
# 返回 0 = 目标可直投;2 = 已经离线处理完(收件箱已写、原因已打印),调用方不得再追加同一份兜底。
|
|
1627
|
+
# 收件人(--any 越权)与目标会话边界已在调用方校验/解析过,这里只做 pane 侧的三项判断。
|
|
1628
|
+
team_say_prepare_direct() { # <agent> <target> <msg>
|
|
1629
|
+
local agent="$1" target="$2" msg="$3" w
|
|
1630
|
+
w="${target#*:}"
|
|
1631
|
+
team_tmux_has_window "$TEAM_SESSION" "$w" \
|
|
1632
|
+
|| { team_say_offline "$agent" "$msg" "窗口 $TEAM_SESSION:$w 不在"; return 2; }
|
|
1633
|
+
# P55(投递换道):死 pane 不是投递目标 —— send-keys 返回 0 但文字落进虚空(探针 P5),
|
|
1634
|
+
# 「提示框非空确认送达」永远等不到(画面不再变)。消息走收件箱,输出点名座位已死与退出证据。
|
|
1635
|
+
if team_agent_pane_dead "$agent"; then
|
|
1636
|
+
local ev; ev="$(team_agent_pane_evidence "$agent" 2>/dev/null || echo '证据未知')"
|
|
1637
|
+
team_inbox_append "$agent" pm "(PM 消息,座位已死:$ev)$msg"
|
|
1638
|
+
team_warn "say: $agent 的 pane 已死($ev)—— 没有按任何键;消息已落 $TEAM_DOCS_DIR/inbox/$agent.md"
|
|
1639
|
+
team_dim " 现场:$TEAM_CLI status <ID>(或 tmux capture-pane -p -S - -t $target);恢复:$TEAM_CLI resume --agent $agent(会先抓现场再替换遗体)"
|
|
1640
|
+
return 2
|
|
1641
|
+
fi
|
|
1642
|
+
# 安全:空提示符时把消息 send-keys 进去会被 shell 当命令执行
|
|
1643
|
+
if team_is_shell_cmd "$(team_pane_cmd "$TEAM_SESSION:$w")" && ! team_pane_busy "$TEAM_SESSION:$w"; then
|
|
1644
|
+
team_say_offline "$agent" "$msg" "$(team_agent_cli_name) 已退出(空提示符)"
|
|
1645
|
+
return 2
|
|
1646
|
+
fi
|
|
1647
|
+
return 0
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1624
1650
|
team_cmd_say() {
|
|
1625
|
-
local agent="" msg="" verify=1 any=0
|
|
1651
|
+
local agent="" msg="" verify=1 any=0
|
|
1626
1652
|
while [ $# -gt 0 ]; do
|
|
1627
1653
|
case "$1" in
|
|
1628
1654
|
--no-verify) verify=0; shift ;;
|
|
1629
1655
|
--any) any=1; shift ;;
|
|
1630
|
-
--now
|
|
1656
|
+
# P393:公共 --now 已退休(say 默认就会在没有可用监视通道时直投)。走同一条未知参数路径:
|
|
1657
|
+
# 收件人校验、任何按键、任何队列/收件箱写入之前就以 rc=2 退出。
|
|
1631
1658
|
-*) team_usage_die "say: 未知参数 $1" ;;
|
|
1632
1659
|
*) if [ -z "$agent" ]; then agent="$1"; elif [ -z "$msg" ]; then msg="$1"; else msg="$msg $1"; fi; shift ;;
|
|
1633
1660
|
esac
|
|
1634
1661
|
done
|
|
1635
|
-
[ -n "$agent" ] && [ -n "$msg" ] || team_usage_die "say <agent> <单行消息> [--no-verify] [--any]
|
|
1662
|
+
[ -n "$agent" ] && [ -n "$msg" ] || team_usage_die "say <agent> <单行消息> [--no-verify] [--any]"
|
|
1636
1663
|
case "$msg" in *$'\n'*) team_die "say 只能发单行:多行请写进文件,然后让 agent 去读" ;; esac
|
|
1637
1664
|
team_require_recipient "$agent" "$any" say || return 1
|
|
1638
1665
|
local w; w="$(team_state_get "$agent" window "$agent")"
|
|
1639
1666
|
local target="$TEAM_SESSION:$w"
|
|
1640
|
-
# M30 · pi 通道不经过 tmux:有活的收件箱监视器(inbox-watch 扩展)时,窗口/pane 的检查都不必要
|
|
1641
|
-
# —— 「pi 通道零 tmux 调用」是 M30 的验收判据之一(消息写 durable 收件箱 + spool,由扩展唤醒)。
|
|
1642
|
-
if ! team_inbox_watch_route "$target" >/dev/null 2>&1; then
|
|
1643
|
-
team_tmux_has_window "$TEAM_SESSION" "$w" \
|
|
1644
|
-
|| { team_say_offline "$agent" "$msg" "窗口 $TEAM_SESSION:$w 不在"; return 0; }
|
|
1645
|
-
# P55(投递换道):死 pane 不是投递目标 —— send-keys 返回 0 但文字落进虚空(探针 P5),
|
|
1646
|
-
# 「提示框非空确认送达」永远等不到(画面不再变)。消息走收件箱,输出点名座位已死与退出证据。
|
|
1647
|
-
if team_agent_pane_dead "$agent"; then
|
|
1648
|
-
local ev; ev="$(team_agent_pane_evidence "$agent" 2>/dev/null || echo '证据未知')"
|
|
1649
|
-
team_inbox_append "$agent" pm "(PM 消息,座位已死:$ev)$msg"
|
|
1650
|
-
team_warn "say: $agent 的 pane 已死($ev)—— 没有按任何键;消息已落 $TEAM_DOCS_DIR/inbox/$agent.md"
|
|
1651
|
-
team_dim " 现场:$TEAM_CLI status <ID>(或 tmux capture-pane -p -S - -t $target);恢复:$TEAM_CLI resume --agent $agent(会先抓现场再替换遗体)"
|
|
1652
|
-
return 0
|
|
1653
|
-
fi
|
|
1654
|
-
# 安全:空提示符时把消息 send-keys 进去会被 shell 当命令执行
|
|
1655
|
-
if team_is_shell_cmd "$(team_pane_cmd "$TEAM_SESSION:$w")" && ! team_pane_busy "$TEAM_SESSION:$w"; then
|
|
1656
|
-
team_say_offline "$agent" "$msg" "$(team_agent_cli_name) 已退出(空提示符)"
|
|
1657
|
-
return 0
|
|
1658
|
-
fi
|
|
1659
|
-
fi
|
|
1660
1667
|
|
|
1661
|
-
#
|
|
1662
|
-
#
|
|
1668
|
+
# 投递一律走共享发送口(delivery-guard):它先判断有没有可用的监视通道,再决定直投或排队;
|
|
1669
|
+
# 直投前的窗口/死 pane/空提示符检查由 team_say_prepare_direct 在那一刻做(P393)。
|
|
1663
1670
|
local sargs=()
|
|
1664
1671
|
[ "$verify" = "1" ] || sargs+=(--no-verify)
|
|
1665
|
-
|
|
1666
|
-
team_send_guarded "$target" "$msg" say --from pm --inbox "$agent" ${sargs[@]+"${sargs[@]}"}
|
|
1672
|
+
local send_rc=0
|
|
1673
|
+
team_send_guarded "$target" "$msg" say --from pm --inbox "$agent" ${sargs[@]+"${sargs[@]}"} || send_rc=$?
|
|
1674
|
+
# 捕获返回值,才能在真实入口的 set -e 下报告持久化失败;其他非零结果仍原样失败,不能落进离线兜底。
|
|
1675
|
+
if [ "$send_rc" -ne 0 ] && [ "$TEAM_SEND_OUTCOME" != "persist-failed" ]; then
|
|
1676
|
+
return "$send_rc"
|
|
1677
|
+
fi
|
|
1667
1678
|
case "$TEAM_SEND_OUTCOME" in
|
|
1668
1679
|
delivered)
|
|
1669
1680
|
team_ok "said to $target: $msg(已确认送达)"
|
|
@@ -1673,9 +1684,17 @@ team_cmd_say() {
|
|
|
1673
1684
|
team_ok "said to $target: $msg(pi 监视通道:已写收件箱 $TEAM_DOCS_DIR/inbox/$agent.md + 唤醒指针;输入框零按键)"
|
|
1674
1685
|
return 0 ;;
|
|
1675
1686
|
queued)
|
|
1676
|
-
# 契约:排队 ≠ 送达 —— 输出里只许有 queued
|
|
1677
|
-
|
|
1678
|
-
|
|
1687
|
+
# 契约:排队 ≠ 送达 —— 输出里只许有 queued,绝不能写「已确认送达」。
|
|
1688
|
+
# P393:默认 say 不会再因为「目标有草稿」排队;这里排队只可能是**已选中的监视通道**没走完
|
|
1689
|
+
# (路由消失 / 收件箱或 spool 写不进去),条目留在 outbox 走原有排水。那种情况不许假称草稿、
|
|
1690
|
+
# 也不许承诺「清空草稿就送达」。
|
|
1691
|
+
if [ "$TEAM_SEND_REASON" = "watch-pending" ]; then
|
|
1692
|
+
team_ok "queued for $target: $msg(监视通道这次没走完:没有写任何键;条目已入 state/outbox/,后续排水仍走守卫)"
|
|
1693
|
+
team_dim " 条目:$TEAM_CLI outbox list | 这与目标输入框里的草稿无关,也不承诺清空草稿就会送达"
|
|
1694
|
+
else
|
|
1695
|
+
team_ok "queued for $target: $msg(没有写任何键;条目已入 state/outbox/,清空后自动投递)"
|
|
1696
|
+
team_dim " 原因/条目:$TEAM_CLI outbox list | 投递未确认的兜底:消息已在 $TEAM_DOCS_DIR/inbox/$agent.md"
|
|
1697
|
+
fi
|
|
1679
1698
|
return 0 ;;
|
|
1680
1699
|
held)
|
|
1681
1700
|
# delivery-truth D1/D2:geometry-untrusted / queue-stalled —— 一个键都没发,报 held + 原因 +
|
|
@@ -1684,7 +1703,8 @@ team_cmd_say() {
|
|
|
1684
1703
|
team_dim " 条目:$(basename "${TEAM_SEND_ENTRY:--}")|durable 全文:$(team_outbox_durable_path "${TEAM_SEND_ENTRY:--}" 2>/dev/null || printf '%s' -)(payload 与条目头未改)|原因:$TEAM_CLI outbox list |恢复:$(team_outbox_recovery_hint "${TEAM_SEND_REASON:--}")"
|
|
1685
1704
|
return 1 ;;
|
|
1686
1705
|
forced)
|
|
1687
|
-
|
|
1706
|
+
# P393:默认直投是**尝试**,不是回执 —— 不写「已确认送达」,也不承诺失败会自动入队。
|
|
1707
|
+
team_ok "attempted immediate send to $target: $msg(已尝试立即发送;未确认模型接收;跳过草稿守卫已记入 state/outbox/forced.log)"
|
|
1688
1708
|
return 0 ;;
|
|
1689
1709
|
unknown-sent)
|
|
1690
1710
|
team_ok "said to $target: $msg(输入框形状未知:按旧行为投递)"
|
|
@@ -1693,6 +1713,14 @@ team_cmd_say() {
|
|
|
1693
1713
|
team_inbox_append "$agent" pm "(PM 消息,投递未确认)$msg"
|
|
1694
1714
|
team_err "投递未确认:$target(输入框形状未知且 pane 无变化;消息已写入收件箱 $TEAM_DOCS_DIR/inbox/$agent.md)"
|
|
1695
1715
|
return 1 ;;
|
|
1716
|
+
offline-handled)
|
|
1717
|
+
# 发送口里的直投前检查已经处理完(收件箱已写、原因已打印):这里绝不再追加一份。
|
|
1718
|
+
return 0 ;;
|
|
1719
|
+
persist-failed)
|
|
1720
|
+
# 已选中监视通道,却连队列条目都没能落盘 = 真实持久化失败:不是离线,也不是「已排队」。
|
|
1721
|
+
team_err "say: 写不进 state/outbox/ 的队列条目(目标 $target)—— 没有按任何键,也没有离线/排队兜底"
|
|
1722
|
+
team_dim " 检查 $(team_state_dir)/outbox 的权限与磁盘后重发;已选中的监视通道不会退回直投"
|
|
1723
|
+
return 1 ;;
|
|
1696
1724
|
*)
|
|
1697
1725
|
team_say_offline "$agent" "$msg" "$(team_agent_cli_name) 已退出(空提示符)"
|
|
1698
1726
|
return 0 ;;
|
|
@@ -6,21 +6,153 @@ team_help() { # 兼容入口:`team help` 的三级路由在 scripts/lib/cmd-he
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
# ---------------------------------------------------------------- init
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
# ── 受管段扫描:这条规则的唯一实现(change instruction-context-slimming · decision 3b)─────
|
|
10
|
+
# 受管段 = 一对「围栏外、独占整行、逐字节等于标记」的行,两者之间的内容由 init 替换;文件里其它
|
|
11
|
+
# 每个字节都归项目自己。这里刻意不写第二个猜测式实现:写入器与 doctor 的迁移提示都读这一份结果。
|
|
12
|
+
#
|
|
13
|
+
# 扫描结果(全局,调用后立刻用):
|
|
14
|
+
# MS_LINES[i] 第 i 行的内容(只去掉行终止符;CRLF 的 CR 属于终止符,不在内容里)
|
|
15
|
+
# MS_TERM[i] 该行自己的终止符:$'\n' / $'\r\n' / ''(文件末行没有换行)
|
|
16
|
+
# 内容 + 自己的终止符 = 原字节,所以重写时逐字节还原,不做任何行尾归一化
|
|
17
|
+
# MS_IDX[] / MS_KIND[] 候选行:行下标 + curBegin|curEnd|legBegin|legEnd
|
|
18
|
+
# MS_FENCE_OPEN 1 = 文件结束在一个未闭合的代码围栏里(往那里追加会落进围栏、而且每次重跑都再追加一次)
|
|
19
|
+
#
|
|
20
|
+
# 围栏口径与已接受的 key-replies 解析器同一条窄词法规则(不是 Markdown 解析器):围栏行长 ≤3 个
|
|
21
|
+
# 前导空格 + 至少三个反引号或波浪号开启,只由同字符、长度不小于开启串、其后只有空白的行关闭;
|
|
22
|
+
# 反引号围栏的 info string 里再出现反引号则不算围栏。未闭合的围栏一直延续到文件末尾。
|
|
23
|
+
MS_FENCE_OPEN_RE='^ {0,3}(`{3,}|~{3,})(.*)$'
|
|
24
|
+
team_marker_scan() { # <file> <begin> <end> [<legacy-begin> <legacy-end>]
|
|
25
|
+
local f="$1" b="$2" e="$3" lb="${4:-}" le="${5:-}"
|
|
26
|
+
local -a raw=(); local c fc info op i n lastnl=1 tail_close_fence_re
|
|
27
|
+
MS_LINES=(); MS_TERM=(); MS_IDX=(); MS_KIND=(); MS_FENCE_OPEN=0
|
|
28
|
+
mapfile -t raw < "$f"
|
|
29
|
+
n=${#raw[@]}
|
|
30
|
+
[ "$n" -gt 0 ] || return 0
|
|
31
|
+
[ "$(tail -c 1 "$f" | wc -l)" -eq 1 ] || lastnl=0
|
|
32
|
+
fc=""
|
|
33
|
+
for ((i = 0; i < n; i++)); do
|
|
34
|
+
c="${raw[i]%$'\r'}"
|
|
35
|
+
MS_LINES[i]="$c"
|
|
36
|
+
if [ "$i" -eq $((n - 1)) ] && [ "$lastnl" = "0" ]; then
|
|
37
|
+
MS_TERM[i]=""
|
|
38
|
+
elif [ "${raw[i]}" != "$c" ]; then
|
|
39
|
+
MS_TERM[i]=$'\r\n'
|
|
40
|
+
else
|
|
41
|
+
MS_TERM[i]=$'\n'
|
|
42
|
+
fi
|
|
43
|
+
if [ -z "$fc" ]; then
|
|
44
|
+
if [[ $c =~ $MS_FENCE_OPEN_RE ]]; then
|
|
45
|
+
op="${BASH_REMATCH[1]}"; info="${BASH_REMATCH[2]}"
|
|
46
|
+
# 反引号围栏的 info string 里带反引号 → 不是围栏(CommonMark),按普通内容继续
|
|
47
|
+
if ! { [ "${op:0:1}" = '`' ] && [[ $info == *'`'* ]]; }; then
|
|
48
|
+
fc="${op:0:1}"; tail_close_fence_re="^ {0,3}${fc}{${#op},}[[:space:]]*$"
|
|
49
|
+
continue
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
case "$c" in
|
|
53
|
+
"$b") MS_IDX+=("$i"); MS_KIND+=(curBegin) ;;
|
|
54
|
+
"$e") MS_IDX+=("$i"); MS_KIND+=(curEnd) ;;
|
|
55
|
+
*)
|
|
56
|
+
if [ -n "$lb" ] && [ "$c" = "$lb" ]; then MS_IDX+=("$i"); MS_KIND+=(legBegin)
|
|
57
|
+
elif [ -n "$le" ] && [ "$c" = "$le" ]; then MS_IDX+=("$i"); MS_KIND+=(legEnd)
|
|
58
|
+
fi ;;
|
|
59
|
+
esac
|
|
60
|
+
elif [[ $c =~ $tail_close_fence_re ]]; then
|
|
61
|
+
fc=""
|
|
62
|
+
fi
|
|
63
|
+
done
|
|
64
|
+
# 只有「文件结束在围栏里」才影响决定:已闭合的围栏里那对示例行是普通内容
|
|
65
|
+
[ -n "$fc" ] && MS_FENCE_OPEN=1
|
|
66
|
+
return 0
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# 只回答一件事:文件里有没有「可迁移的旧标记候选行」(给 doctor 的迁移提示用)。
|
|
70
|
+
# 漂在正文、缩进、或被围栏圈起来的旧标记示例不是候选 —— 提示只该指向 init 真会改的那两行。
|
|
71
|
+
team_legacy_marker_candidates() { # <file> <legacy-begin> <legacy-end> → 候选行数
|
|
72
|
+
local f="$1"
|
|
73
|
+
[ -f "$f" ] && [ -s "$f" ] || { printf '0'; return 0; }
|
|
74
|
+
team_marker_scan "$f" '<!-- teamsmith:begin -->' '<!-- teamsmith:end -->' "$2" "$3"
|
|
75
|
+
local i cnt=0
|
|
76
|
+
for i in "${MS_KIND[@]}"; do
|
|
77
|
+
case "$i" in legBegin|legEnd) cnt=$((cnt + 1)) ;; esac
|
|
78
|
+
done
|
|
79
|
+
printf '%s' "$cnt"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
team_write_section() { # <file> <begin-marker> <end-marker> <content-file> [<legacy-begin> <legacy-end>]
|
|
83
|
+
local target="$1" begin="$2" end="$3" content="$4" lb="${5:-}" le="${6:-}"
|
|
84
|
+
local cb=0 ce=0 lbb=0 lee=0 bi=-1 ei=-1 lbi=-1 lei=-1 reason="" i
|
|
11
85
|
mkdir -p "$(dirname "$target")"
|
|
12
86
|
[ -f "$target" ] || : > "$target"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
87
|
+
team_marker_scan "$target" "$begin" "$end" "$lb" "$le"
|
|
88
|
+
for i in "${!MS_KIND[@]}"; do
|
|
89
|
+
case "${MS_KIND[i]}" in
|
|
90
|
+
curBegin) cb=$((cb + 1)); bi=${MS_IDX[i]} ;;
|
|
91
|
+
curEnd) ce=$((ce + 1)); ei=${MS_IDX[i]} ;;
|
|
92
|
+
legBegin) lbb=$((lbb + 1)); lbi=${MS_IDX[i]} ;;
|
|
93
|
+
legEnd) lee=$((lee + 1)); lei=${MS_IDX[i]} ;;
|
|
94
|
+
esac
|
|
95
|
+
done
|
|
96
|
+
if [ "$((cb + ce + lbb + lee))" -eq 0 ]; then
|
|
97
|
+
# 无候选:追加一块;但文件结束在未闭合围栏里时追加会落进围栏、而且每次重跑都再长一块 → 拒绝
|
|
98
|
+
if [ "$MS_FENCE_OPEN" = "1" ]; then
|
|
99
|
+
team_err "AGENTS 受管段:$target 的标记形状无法确定,文件未改动"
|
|
100
|
+
team_dim " 原因:文件结束在一个未闭合的代码围栏里(追加的协议段会落进围栏、且每次重跑都会再追加一块);先补上围栏的结束行" >&2
|
|
101
|
+
return 1
|
|
102
|
+
fi
|
|
21
103
|
{ [ -s "$target" ] && printf '\n'; printf '%s\n' "$begin"; grep -vFxf <(printf '%s\n%s\n' "$begin" "$end") "$content"; printf '%s\n' "$end"; } >> "$target"
|
|
22
104
|
team_ok "append $target(团队协议段落)"
|
|
105
|
+
return 0
|
|
106
|
+
fi
|
|
107
|
+
# 形状判定:先数完全部候选再决定,绝不「取第一对」
|
|
108
|
+
if { [ "$cb" -gt 0 ] || [ "$ce" -gt 0 ]; } && { [ "$lbb" -gt 0 ] || [ "$lee" -gt 0 ]; }; then
|
|
109
|
+
reason="新旧标记混用(当前 $((cb + ce)) 行、旧名 $((lbb + lee)) 行)——无法判断哪一对是受管段"
|
|
110
|
+
elif [ "$cb" -gt 1 ] || [ "$ce" -gt 1 ]; then
|
|
111
|
+
reason="有多对受管标记(开始 $cb 行、结束 $ce 行)"
|
|
112
|
+
elif [ "$cb" -eq 1 ] && [ "$ce" -eq 0 ]; then
|
|
113
|
+
reason="有开始标记没有结束标记(第 $((bi + 1)) 行)"
|
|
114
|
+
elif [ "$ce" -eq 1 ] && [ "$cb" -eq 0 ]; then
|
|
115
|
+
reason="有结束标记没有开始标记(第 $((ei + 1)) 行)"
|
|
116
|
+
elif [ "$cb" -eq 1 ] && [ "$ce" -eq 1 ] && [ "$bi" -ge "$ei" ]; then
|
|
117
|
+
reason="结束标记在开始标记之前(第 $((ei + 1)) 行 / 第 $((bi + 1)) 行)"
|
|
118
|
+
elif [ "$lbb" -gt 1 ] || [ "$lee" -gt 1 ]; then
|
|
119
|
+
reason="有多对旧名标记(开始 $lbb 行、结束 $lee 行)"
|
|
120
|
+
elif [ "$lbb" -eq 1 ] && [ "$lee" -eq 0 ]; then
|
|
121
|
+
reason="有旧名开始标记没有结束标记(第 $((lbi + 1)) 行)"
|
|
122
|
+
elif [ "$lee" -eq 1 ] && [ "$lbb" -eq 0 ]; then
|
|
123
|
+
reason="有旧名结束标记没有开始标记(第 $((lei + 1)) 行)"
|
|
124
|
+
elif [ "$((lbb + lee))" -gt 0 ] && [ "$lbi" -ge "$lei" ]; then
|
|
125
|
+
reason="旧名结束标记在开始标记之前(第 $((lei + 1)) 行 / 第 $((lbi + 1)) 行)"
|
|
126
|
+
fi
|
|
127
|
+
if [ -n "$reason" ]; then
|
|
128
|
+
team_err "AGENTS 受管段:$target 的标记形状无法确定,文件未改动"
|
|
129
|
+
team_dim " 原因:$reason;请手工改成恰好一对围栏外独占行的标记,再跑同一条命令" >&2
|
|
130
|
+
return 1
|
|
23
131
|
fi
|
|
132
|
+
# 到这里的形状:一对当前标记,或一对旧名标记
|
|
133
|
+
if [ "$cb" -eq 0 ]; then
|
|
134
|
+
bi="$lbi"; ei="$lei"
|
|
135
|
+
fi
|
|
136
|
+
local bodyterm=$'\n' legacy=0
|
|
137
|
+
[ "$cb" -eq 0 ] && legacy=1
|
|
138
|
+
# 正文的终止符只由 begin 行自己决定(混合行尾文件里它是唯一权威)
|
|
139
|
+
[ "${MS_TERM[bi]}" = $'\r\n' ] && bodyterm=$'\r\n'
|
|
140
|
+
local -a body=(); mapfile -t body < "$content"
|
|
141
|
+
local k m=${#MS_LINES[@]}
|
|
142
|
+
{
|
|
143
|
+
for ((k = 0; k < bi; k++)); do printf '%s%s' "${MS_LINES[k]}" "${MS_TERM[k]}"; done
|
|
144
|
+
# 旧名对:两行标记本身也换成当前标记(同一处范围编辑,围栏外的示例一个字节都不动)
|
|
145
|
+
if [ "$legacy" = "1" ]; then printf '%s%s' "$begin" "${MS_TERM[bi]}"; else printf '%s%s' "${MS_LINES[bi]}" "${MS_TERM[bi]}"; fi
|
|
146
|
+
for k in "${!body[@]}"; do
|
|
147
|
+
if [ "${body[k]}" = "$begin" ] || [ "${body[k]}" = "$end" ]; then continue; fi
|
|
148
|
+
printf '%s%s' "${body[k]}" "$bodyterm"
|
|
149
|
+
done
|
|
150
|
+
if [ "$legacy" = "1" ]; then printf '%s%s' "$end" "${MS_TERM[ei]}"; else printf '%s%s' "${MS_LINES[ei]}" "${MS_TERM[ei]}"; fi
|
|
151
|
+
for ((k = ei + 1; k < m; k++)); do printf '%s%s' "${MS_LINES[k]}" "${MS_TERM[k]}"; done
|
|
152
|
+
} > "$target.tmp" && mv "$target.tmp" "$target"
|
|
153
|
+
[ "$legacy" = "1" ] && team_dim " 旧名标记已迁移为 teamsmith 标记"
|
|
154
|
+
team_ok "update $target(协议段落已刷新)"
|
|
155
|
+
return 0
|
|
24
156
|
}
|
|
25
157
|
|
|
26
158
|
team_gitignore_add() { # <entry> ...
|
|
@@ -148,12 +280,27 @@ team_cmd_init() {
|
|
|
148
280
|
done
|
|
149
281
|
|
|
150
282
|
local project; project="$(basename "$TEAM_MAIN_ROOT")"
|
|
283
|
+
local cfg="$TEAM_MAIN_ROOT/.pi/team/config.sh" had_config=0; [ -f "$cfg" ] && had_config=1
|
|
284
|
+
local gates_from_config=0
|
|
285
|
+
# P402:既有契约(且不是 --force 重渲染)时,命令行上没给的渲染参数取**契约里的现值** —— 受管块是
|
|
286
|
+
# agent 读到的「PM 在哪、有谁」的权威说明,写目录名/硬编码默认就是文档撒谎(2026-11-03 现场:
|
|
287
|
+
# TEAM_SESSION=teamsmith、TEAM_AGENTS="dev verify dev2 dev3 dev-bob" 的项目被渲染成 `pm-skills:pm`
|
|
288
|
+
# 与 `dev verify`)。显式参数仍然优先;键缺失(老契约/手改)是预期分支,保持下面的默认。
|
|
289
|
+
if [ "$had_config" = "1" ] && [ "$force" != "1" ]; then
|
|
290
|
+
local _cfgv
|
|
291
|
+
if [ -z "$session" ] && _cfgv="$(team_config_file_value "$cfg" TEAM_SESSION)"; then session="$_cfgv"; fi
|
|
292
|
+
if [ -z "$agents" ] && _cfgv="$(team_config_file_value "$cfg" TEAM_AGENTS)"; then agents="$_cfgv"; fi
|
|
293
|
+
if [ -z "$docs" ] && _cfgv="$(team_config_file_value "$cfg" TEAM_DOCS_DIR)"; then docs="$_cfgv"; fi
|
|
294
|
+
if [ -z "$pmwin" ] && _cfgv="$(team_config_file_value "$cfg" TEAM_PM_WINDOW)"; then pmwin="$_cfgv"; fi
|
|
295
|
+
if [ -z "$gates" ] && _cfgv="$(team_config_file_value "$cfg" TEAM_GATES)"; then
|
|
296
|
+
gates="$_cfgv"; gates_from_config=1
|
|
297
|
+
fi
|
|
298
|
+
fi
|
|
151
299
|
session="${session:-$project}"
|
|
152
300
|
agents="${agents:-dev verify}"
|
|
153
301
|
vcs="${vcs:-$(team_detect_vcs)}"
|
|
154
302
|
docs="${docs:-docs/team}"
|
|
155
303
|
pmwin="${pmwin:-pm}"
|
|
156
|
-
local cfg="$TEAM_MAIN_ROOT/.pi/team/config.sh" had_config=0; [ -f "$cfg" ] && had_config=1
|
|
157
304
|
|
|
158
305
|
# 0) 模型策略闸门(P235):退休键 / 缺输入 / 非法值都在**任何写入之前**停住。
|
|
159
306
|
# 已有合法新策略允许不带输入重入(保留策略);退休键则连 --force 都不能当迁移捷径。
|
|
@@ -202,6 +349,8 @@ team_cmd_init() {
|
|
|
202
349
|
gates="$(team_detect_gates)"
|
|
203
350
|
TEAM_GATES="$_gates_keep"
|
|
204
351
|
fi
|
|
352
|
+
elif [ "$gates_from_config" = "1" ]; then
|
|
353
|
+
: # P402:契约现值(含空值)就是这次渲染的值,不再拿检测结果替换契约的「未配置」
|
|
205
354
|
else
|
|
206
355
|
gates="${gates:-$(team_detect_gates)}"
|
|
207
356
|
fi
|
|
@@ -272,16 +421,12 @@ team_cmd_init() {
|
|
|
272
421
|
"PROJECT=$project" "DOCS_DIR=$docs" "SESSION=$session" "PM_WINDOW=$pmwin" \
|
|
273
422
|
"SKILL_DIR=$TEAM_SKILL_DIR" "AGENTS=$agents" "GATES=${gates:-<未配置>}" \
|
|
274
423
|
"WORKTREES_DIR=${TEAM_WORKTREES_DIR:-.worktrees}" "PROTECTED_BRANCH=main" > "$section"
|
|
275
|
-
# 旧名标记迁移(<=1.12 的项目 AGENTS.md 里是 pi-team:begin/end
|
|
276
|
-
#
|
|
424
|
+
# 旧名标记迁移(<=1.12 的项目 AGENTS.md 里是 pi-team:begin/end):交给同一个写入器,按同一处
|
|
425
|
+
# 范围编辑把标记行的文字换掉(围栏外那对才动,示例里的旧标记逐字节保留)。
|
|
277
426
|
local _agents="$TEAM_MAIN_ROOT/AGENTS.md"
|
|
278
|
-
if [ -f "$_agents" ] \
|
|
279
|
-
&& grep -qF '<!-- pi-team:begin -->' "$_agents" \
|
|
280
|
-
&& ! grep -qF '<!-- teamsmith:begin -->' "$_agents"; then
|
|
281
|
-
sed -i 's|<!-- pi-team:begin -->|<!-- teamsmith:begin -->|; s|<!-- pi-team:end -->|<!-- teamsmith:end -->|' "$_agents"
|
|
282
|
-
fi
|
|
283
427
|
team_write_section "$TEAM_MAIN_ROOT/AGENTS.md" \
|
|
284
|
-
"<!-- teamsmith:begin -->" "<!-- teamsmith:end -->" "$section"
|
|
428
|
+
"<!-- teamsmith:begin -->" "<!-- teamsmith:end -->" "$section" \
|
|
429
|
+
"<!-- pi-team:begin -->" "<!-- pi-team:end -->" || { rm -f "$section"; return 1; }
|
|
285
430
|
rm -f "$section"
|
|
286
431
|
|
|
287
432
|
# 4) .gitignore
|
|
@@ -308,12 +453,15 @@ team_cmd_init() {
|
|
|
308
453
|
|
|
309
454
|
# ---------------------------------------------------------------- doctor
|
|
310
455
|
# M7.1:这个项目要不要读迁移指南?两个判据都来自可查的真实状态,不猜:
|
|
311
|
-
# ① AGENTS.md
|
|
456
|
+
# ① AGENTS.md 里还有围栏外的旧名标记 <!-- pi-team:begin -->(init 会就地改写;改写后不再触发)——
|
|
457
|
+
# 判据是「可迁移的候选行」,所以正文里引用、缩进或围栏里的旧名示例不会让这条提示永不消失。
|
|
312
458
|
# ② 本会话加载的 skill 比磁盘旧(mark-loaded 记的版本/指纹与磁盘不一致)—— 与 version --check 同口径
|
|
313
459
|
# 干净项目上保持静默(doctor 不该多刷一行);返回原因字符串,没有原因则返回空。
|
|
314
460
|
team_migration_reasons() {
|
|
315
461
|
local reasons="" f="$TEAM_MAIN_ROOT/AGENTS.md" loaded
|
|
316
|
-
|
|
462
|
+
# 只看「init 真会改的那两行」:围栏外、独占整行、逐字节等于旧名标记。正文引用、缩进
|
|
463
|
+
# 或围栏里的旧名示例都不会被 init 改写,所以它们也不该让这条提示永不消失。
|
|
464
|
+
if [ -f "$f" ] && [ "$(team_legacy_marker_candidates "$f" '<!-- pi-team:begin -->' '<!-- pi-team:end -->')" -gt 0 ]; then
|
|
317
465
|
reasons="AGENTS.md 还是旧名标记"
|
|
318
466
|
fi
|
|
319
467
|
loaded="$(team_loaded_version 2>/dev/null || true)"
|
|
@@ -620,6 +768,30 @@ team_cmd_doctor() {
|
|
|
620
768
|
fi
|
|
621
769
|
fi
|
|
622
770
|
|
|
771
|
+
# Disk, directed launch and actual process registration are separate evidence; mark-loaded is not runtime proof.
|
|
772
|
+
check "关键回复磁盘"
|
|
773
|
+
if [ -f "$TEAM_SKILL_DIR/extension/team-reply.ts" ] && [ -f "$TEAM_SKILL_DIR/scripts/reply-capture.mjs" ]; then
|
|
774
|
+
pass "捕获源码存在(不代表当前 PM 已加载)"
|
|
775
|
+
else warn "捕获源码缺失"; fi
|
|
776
|
+
check "关键回复启动"
|
|
777
|
+
if [ -z "$(team_trim "${TEAM_PM_CMD:-}")" ]; then
|
|
778
|
+
pass "内置 Pi 启动定向注入 team-reply;旧进程未带 -e 时 /reload 不会补入口,须获权重启"
|
|
779
|
+
else warn "自定义 PM 命令不注入捕获扩展,首版不承诺兼容"; fi
|
|
780
|
+
check "关键回复运行"
|
|
781
|
+
local reply_runner reply_runtime
|
|
782
|
+
reply_runner="$(team_js_runner)"
|
|
783
|
+
if [ -z "$reply_runner" ]; then
|
|
784
|
+
warn "unknown:无可用 JS 运行时,未核实 live 注册"
|
|
785
|
+
elif reply_runtime="$("$reply_runner" -e '
|
|
786
|
+
import(require("node:url").pathToFileURL(process.argv[1]).href).then(m => {
|
|
787
|
+
const [root,state,config,session,window,skill] = process.argv.slice(2);
|
|
788
|
+
const r = m.inspectRuntime({root,state,config,session,window,skill});
|
|
789
|
+
console.log(`${r.state} disk=${r.disk || "unknown"} loaded=${r.loaded || "unknown"} generation=${r.generation || "unknown"}; ${r.reason}`);
|
|
790
|
+
}).catch(e => { console.error(`runtime diagnostic unavailable: ${e.code || e.name}`); process.exitCode=1 })
|
|
791
|
+
' "$TEAM_SKILL_DIR/scripts/reply-capture.mjs" "$TEAM_MAIN_ROOT" "$TEAM_STATE_DIR" "${TEAM_CONFIG:-${TEAM_CONFIG_FILE:-}}" "$TEAM_SESSION" "$TEAM_PM_WINDOW" "$TEAM_SKILL_DIR")"; then
|
|
792
|
+
case "$reply_runtime" in ready\ *) pass "$reply_runtime" ;; *) warn "$reply_runtime" ;; esac
|
|
793
|
+
else warn "unknown:live 注册诊断执行失败(未当作启用)"; fi
|
|
794
|
+
|
|
623
795
|
check "巡检(pulse)"; local legacy_note; legacy_note="$(team_pulse_legacy_suffix)"
|
|
624
796
|
case "$(team_pulse_state)" in
|
|
625
797
|
off) warn "没在跑 → $TEAM_CLI pulse up(pulse 由 PM 配置)$legacy_note" ;;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# teamsmith · `team remind`:给 PM 自己的定时提醒(change: agent-self-reminder 2.1/2.3 · P409)
|
|
3
|
+
#
|
|
4
|
+
# team remind add --at <RFC3339>|--after <30s|5m|2h> (--message <text> | --message-file <file>)
|
|
5
|
+
# [--key <id>] [--task <ref>] [--json]
|
|
6
|
+
# team remind list [--all] [--json]
|
|
7
|
+
# team remind show <id> [--json]
|
|
8
|
+
# team remind cancel <id> [--json]
|
|
9
|
+
#
|
|
10
|
+
# 这里只做三件事:解析人敲的参数、把正文按**字节**送进 stdin、把助手的结论原样打印。
|
|
11
|
+
# 状态、锁、原子写与视图派生全在 scripts/state-authority.mjs 的事务里(common.sh 的
|
|
12
|
+
# team_authority_cli 是唯一入口)—— 没有第二份文件读写,也没有第二把锁。
|
|
13
|
+
#
|
|
14
|
+
# 正文走 stdin 而不是 argv:不经过 shell 引号/长度限制,也不重新编码;`--message-file` 直接把文件
|
|
15
|
+
# 接给 stdin(`$(cat …)` 会吃掉结尾换行,那是正文的一部分)。
|
|
16
|
+
#
|
|
17
|
+
# 本片只有 `scheduled` 与 `cancelled` 两个相位由这里产生;`queued/intent/observed/unknown/resolved`
|
|
18
|
+
# 由 3.x/4.x 的投递与 Pulse 写入,读侧已经按同一份快照派生并显示它们。
|
|
19
|
+
|
|
20
|
+
team_remind_usage() {
|
|
21
|
+
printf 'usage: team remind add|list|show|cancel …(team help remind)\n' >&2
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# team_remind_add — 参数面在这里拒绝;时间解析、正文字节与 key 幂等由事务里的同一份规则决定。
|
|
25
|
+
team_remind_add() {
|
|
26
|
+
local at="" after="" key="" task="" msg="" msgfile="" json="" has_msg=0 has_file=0
|
|
27
|
+
while [ $# -gt 0 ]; do
|
|
28
|
+
case "$1" in
|
|
29
|
+
--at) [ $# -ge 2 ] || team_usage_die "remind add: --at 需要时间"; at="$2"; shift 2 ;;
|
|
30
|
+
--after) [ $# -ge 2 ] || team_usage_die "remind add: --after 需要时长"; after="$2"; shift 2 ;;
|
|
31
|
+
--message) [ $# -ge 2 ] || team_usage_die "remind add: --message 需要正文"; msg="$2"; has_msg=1; shift 2 ;;
|
|
32
|
+
--message-file) [ $# -ge 2 ] || team_usage_die "remind add: --message-file 需要文件"; msgfile="$2"; has_file=1; shift 2 ;;
|
|
33
|
+
--key) [ $# -ge 2 ] || team_usage_die "remind add: --key 需要值"; key="$2"; shift 2 ;;
|
|
34
|
+
--task) [ $# -ge 2 ] || team_usage_die "remind add: --task 需要值"; task="$2"; shift 2 ;;
|
|
35
|
+
--json) json="--json"; shift ;;
|
|
36
|
+
-*) team_usage_die "remind add: 未知参数 $1" ;;
|
|
37
|
+
*) team_usage_die "remind add: 多余的参数 $1(正文用 --message 或 --message-file)" ;;
|
|
38
|
+
esac
|
|
39
|
+
done
|
|
40
|
+
if [ "$has_msg" = "1" ] && [ "$has_file" = "1" ]; then
|
|
41
|
+
team_usage_die "remind add: --message 与 --message-file 只能给一个"
|
|
42
|
+
fi
|
|
43
|
+
if [ "$has_msg" = "0" ] && [ "$has_file" = "0" ]; then
|
|
44
|
+
team_usage_die "remind add: 需要正文(--message <text> 或 --message-file <file>);正文不做截断,空正文会被拒绝"
|
|
45
|
+
fi
|
|
46
|
+
local args=(remind-add)
|
|
47
|
+
[ -n "$at" ] && args+=(--at "$at")
|
|
48
|
+
[ -n "$after" ] && args+=(--after "$after")
|
|
49
|
+
[ -n "$key" ] && args+=(--key "$key")
|
|
50
|
+
[ -n "$task" ] && args+=(--task "$task")
|
|
51
|
+
[ -n "$json" ] && args+=(--json)
|
|
52
|
+
if [ "$has_file" = "1" ]; then
|
|
53
|
+
[ -f "$msgfile" ] && [ -r "$msgfile" ] || team_die "remind add: 读不到正文文件 $msgfile"
|
|
54
|
+
team_authority_cli "${args[@]}" < "$msgfile"
|
|
55
|
+
else
|
|
56
|
+
printf '%s' "$msg" | team_authority_cli "${args[@]}"
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
team_remind_list() {
|
|
61
|
+
local args=(remind-list) json=""
|
|
62
|
+
while [ $# -gt 0 ]; do
|
|
63
|
+
case "$1" in
|
|
64
|
+
--all) args+=(--all); shift ;;
|
|
65
|
+
--json) json="--json"; shift ;;
|
|
66
|
+
-*) team_usage_die "remind list: 未知参数 $1" ;;
|
|
67
|
+
*) team_usage_die "remind list: 多余的参数 $1" ;;
|
|
68
|
+
esac
|
|
69
|
+
done
|
|
70
|
+
[ -n "$json" ] && args+=(--json)
|
|
71
|
+
team_authority_cli "${args[@]}" < /dev/null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# show / cancel 共用一个「恰好一个 id」的参数面。
|
|
75
|
+
team_remind_one_id() { # <子命令> <默认动词> [args…]
|
|
76
|
+
local sub="$1" op="$2"; shift 2
|
|
77
|
+
local id="" json=""
|
|
78
|
+
while [ $# -gt 0 ]; do
|
|
79
|
+
case "$1" in
|
|
80
|
+
--json) json="--json"; shift ;;
|
|
81
|
+
-*) team_usage_die "remind $sub: 未知参数 $1" ;;
|
|
82
|
+
*) [ -z "$id" ] || team_usage_die "remind $sub: 多余的参数 $1"; id="$1"; shift ;;
|
|
83
|
+
esac
|
|
84
|
+
done
|
|
85
|
+
[ -n "$id" ] || team_usage_die "remind $sub: 需要一个提醒 id(team remind list 看 id)"
|
|
86
|
+
local args=("$op" --id "$id")
|
|
87
|
+
[ -n "$json" ] && args+=(--json)
|
|
88
|
+
team_authority_cli "${args[@]}" < /dev/null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
team_cmd_remind() {
|
|
92
|
+
local sub="${1:-}"
|
|
93
|
+
[ $# -gt 0 ] && shift
|
|
94
|
+
case "$sub" in
|
|
95
|
+
add) team_remind_add "$@" ;;
|
|
96
|
+
list) team_remind_list "$@" ;;
|
|
97
|
+
show) team_remind_one_id show remind-show "$@" ;;
|
|
98
|
+
cancel) team_remind_one_id cancel remind-cancel "$@" ;;
|
|
99
|
+
"") team_remind_usage; return 2 ;;
|
|
100
|
+
-h|--help) team_remind_usage; return 0 ;;
|
|
101
|
+
*) team_usage_die "remind: 未知子命令 $sub(add|list|show|cancel)" ;;
|
|
102
|
+
esac
|
|
103
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
# teamsmith · 更新与版本自检:mark-loaded / version [--check] / changelog
|
|
3
3
|
#
|
|
4
4
|
# 三种更新粒度(实测自 Pi 的 reload 实现):
|
|
5
|
-
# scripts/**
|
|
5
|
+
# 普通 scripts/** 每次调用现读盘 → 零操作;reply-capture/replies 是扩展的已加载依赖,须 reload
|
|
6
6
|
# SKILL.md / references / templates → /reload(或 team reload)刷新描述与清单;正文本来就每次读盘
|
|
7
|
-
# extension/*.ts
|
|
7
|
+
# 已有 extension/*.ts 重新 import → /reload;PM 原启动未注入 reply 入口时须获权重启
|
|
8
8
|
#
|
|
9
9
|
# 本模块提供:把"本会话启动时的版本"记下来,之后任何时刻都能判断"我是不是旧的"。
|
|
10
10
|
|
|
@@ -13,7 +13,10 @@ team_skill_changelog() { printf '%s/CHANGELOG.md\n' "$TEAM_SKILL_DIR"; }
|
|
|
13
13
|
# M27:扩展面从一个变成两个(notify + bg);指纹必须覆盖**两个**,否则改了 team-bg.ts
|
|
14
14
|
# 而 `team version --check` 还说「没变」,PM 不会想起 /reload。team_skill_ext 保留
|
|
15
15
|
# 单数形态(老调用方要的是 notify 扩展那一个路径)。
|
|
16
|
-
team_skill_exts() {
|
|
16
|
+
team_skill_exts() {
|
|
17
|
+
printf '%s\n' "$TEAM_SKILL_DIR/extension/team-notify.ts" "$TEAM_SKILL_DIR/extension/team-bg.ts" \
|
|
18
|
+
"$TEAM_SKILL_DIR/extension/team-reply.ts" "$TEAM_SKILL_DIR/scripts/reply-capture.mjs" "$TEAM_SKILL_DIR/scripts/replies.mjs"
|
|
19
|
+
}
|
|
17
20
|
team_skill_ext() { printf '%s\n' "$TEAM_SKILL_DIR/extension/team-notify.ts"; }
|
|
18
21
|
|
|
19
22
|
team_skill_doc_version() { # SKILL.md frontmatter 里的 version
|
|
@@ -28,7 +31,7 @@ team_skill_changelog_version() { # CHANGELOG 顶部版本
|
|
|
28
31
|
sed -n 's/^##[[:space:]]*\[*v\?\([0-9][0-9.]*\)\]*.*/\1/p' "$f" | head -1
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
team_skill_hash() { # SKILL.md +
|
|
34
|
+
team_skill_hash() { # SKILL.md + 扩展入口/实际捕获依赖指纹(不代表 live runtime 已装载)
|
|
32
35
|
local a f
|
|
33
36
|
a="$(team_skill_file)"
|
|
34
37
|
{
|