teamsmith 0.4.6 → 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.
Files changed (70) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +24 -0
  4. package/skills/teamsmith/SKILL.md +32 -23
  5. package/skills/teamsmith/extension/team-bg.ts +5 -3
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
  7. package/skills/teamsmith/extension/team-notify.ts +20 -13
  8. package/skills/teamsmith/extension/team-remind.ts +189 -0
  9. package/skills/teamsmith/extension/team-reply.ts +4 -7
  10. package/skills/teamsmith/references/migration.md +101 -0
  11. package/skills/teamsmith/references/openspec.md +43 -27
  12. package/skills/teamsmith/references/protocol.md +26 -15
  13. package/skills/teamsmith/references/reminders.md +153 -161
  14. package/skills/teamsmith/references/troubleshooting.md +12 -7
  15. package/skills/teamsmith/references/workflows.md +84 -31
  16. package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
  17. package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
  18. package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
  19. package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
  20. package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
  21. package/skills/teamsmith/scripts/lib/common.sh +83 -13
  22. package/skills/teamsmith/scripts/panel/panel.js +179 -179
  23. package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
  24. package/skills/teamsmith/scripts/panel/src/layout.ts +20 -8
  25. package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
  26. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  27. package/skills/teamsmith/scripts/remind-store.mjs +55 -24
  28. package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
  29. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  30. package/skills/teamsmith/scripts/state-authority.mjs +72 -6
  31. package/skills/teamsmith/scripts/team +1 -0
  32. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +11 -8
  33. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  34. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  35. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  36. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  37. package/skills/teamsmith/templates/pm-prompt.md.tmpl +31 -19
  38. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  39. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  40. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  41. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  42. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  43. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  44. package/skills/teamsmith/tests/help-surface.sh +3 -5
  45. package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
  46. package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
  47. package/skills/teamsmith/tests/key-replies.sh +307 -106
  48. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  49. package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
  50. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  51. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
  52. package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
  53. package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
  54. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  55. package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
  56. package/skills/teamsmith/tests/remind-delivery.sh +123 -35
  57. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  58. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  59. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  60. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  61. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  62. package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
  63. package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
  64. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  65. package/skills/teamsmith/tests/routes.sh +213 -293
  66. package/skills/teamsmith/tests/section-paths.tsv +10 -8
  67. package/skills/teamsmith/tests/smoke.sh +484 -28
  68. package/skills/teamsmith/tests/state-authority.sh +152 -8
  69. package/skills/teamsmith-init/SKILL.md +5 -5
  70. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -0,0 +1,27 @@
1
+ /** Test-only earlier message_start handler for P444. Loaded before team-inbox-watch in private Pi. */
2
+ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent'
3
+ import { appendFileSync, existsSync, writeFileSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+ import { setTimeout as delay } from 'node:timers/promises'
6
+
7
+ export default function (pi: ExtensionAPI) {
8
+ pi.on('message_start', async (event, ctx) => {
9
+ const message: any = event.message
10
+ if (message?.role !== 'custom' || message.customType !== 'team-reminder') return
11
+ const dir = process.env.P442_EVIDENCE!
12
+ const record = {
13
+ type: 'delay_enter', pid: process.pid, sessionId: ctx.sessionManager.getSessionId(),
14
+ message: { role: message.role, customType: message.customType, content: message.content,
15
+ details: message.details, display: true },
16
+ }
17
+ appendFileSync(join(dir, 'events.jsonl'), JSON.stringify(record) + '\n')
18
+ writeFileSync(join(dir, 'delay-entered'), String(process.pid))
19
+ if (process.env.P444_KILL_AT === 'event') process.kill(process.pid, 'SIGKILL')
20
+ if (process.env.P444_DELAY === '1') {
21
+ const release = join(dir, 'release-event')
22
+ while (!existsSync(release)) await delay(25)
23
+ }
24
+ appendFileSync(join(dir, 'events.jsonl'), JSON.stringify({ type: 'delay_exit', pid: process.pid,
25
+ sessionId: ctx.sessionManager.getSessionId(), details: message.details }) + '\n')
26
+ })
27
+ }
@@ -0,0 +1,65 @@
1
+ /** Test-only controlled provider and lifecycle recorder for P442. Never injected by product defaults. */
2
+ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent'
3
+ import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+
6
+ export default function (pi: ExtensionAPI) {
7
+ const dir = process.env.P442_EVIDENCE!
8
+ const log = (value: object) => appendFileSync(join(dir, 'events.jsonl'), JSON.stringify(value) + '\n')
9
+ pi.registerProvider('p442', {
10
+ baseUrl: process.env.P442_ENDPOINT!, apiKey: 'local-fixture-not-a-credential', api: 'openai-completions',
11
+ models: [{ id: 'controlled', name: 'Controlled loopback fixture', reasoning: false, input: ['text'],
12
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 262144, maxTokens: 8192,
13
+ compat: { supportsDeveloperRole: false, supportsStore: false } }],
14
+ })
15
+ pi.registerCommand('p442-control', {
16
+ description: 'Private P442 lifecycle driver',
17
+ handler: async (action, ctx) => {
18
+ await ctx.waitForIdle()
19
+ if (action === 'reload') await ctx.reload()
20
+ else if (action === 'new') await ctx.newSession()
21
+ else if (action === 'fork') {
22
+ const entry = ctx.sessionManager.getBranch().find((e: any) => e.type === 'message' && e.message.role === 'assistant')!
23
+ await ctx.fork(entry.id, { position: 'at' })
24
+ } else if (action.startsWith('send ')) {
25
+ // Re-submit a recorded message through Pi itself. The resulting message_start is a real Pi
26
+ // event in the current (possibly replaced) session, not a direct call to a product handler.
27
+ const message = JSON.parse(readFileSync(action.slice(5), 'utf8'))
28
+ pi.sendMessage(message, { triggerTurn: true, deliverAs: 'followUp' })
29
+ log({ type: 'fixture_send', customType: message.customType, details: message.details,
30
+ sessionId: ctx.sessionManager.getSessionId() })
31
+ } else if (action === 'busy') {
32
+ pi.sendMessage({ customType: 'p442-busy', content: 'P444 unrelated busy turn', display: true },
33
+ { triggerTurn: true, deliverAs: 'followUp' })
34
+ log({ type: 'fixture_send', customType: 'p442-busy', sessionId: ctx.sessionManager.getSessionId() })
35
+ } else if (action === 'stop') ctx.shutdown()
36
+ else throw new Error(`unknown fixture action ${action}`)
37
+ log({ type: 'command_done', action })
38
+ },
39
+ })
40
+ const state = (ctx: any) => ({
41
+ sessionId: ctx.sessionManager.getSessionId(), sessionFile: ctx.sessionManager.getSessionFile(),
42
+ reminderTools: pi.getAllTools().filter((tool: any) => tool.name === 'team_remind')
43
+ .map((tool: any) => ({ name: tool.name, exposure: tool.exposure })),
44
+ activeTools: pi.getActiveTools().filter((name: string) => name === 'team_remind'),
45
+ })
46
+ pi.on('session_start', (_event, ctx) => {
47
+ log({ type: 'session_start', pid: process.pid, ...state(ctx) })
48
+ writeFileSync(join(dir, 'session-start'), String(process.pid))
49
+ })
50
+ pi.on('before_agent_start', (_event, ctx) => { log({ type: 'before_agent_start', ...state(ctx) }) })
51
+ pi.on('message_start', (event, ctx) => {
52
+ if (event.message.role === 'custom') log({ type: 'custom_start', customType: event.message.customType,
53
+ details: event.message.details, ...state(ctx) })
54
+ })
55
+ pi.on('tool_execution_end', event => {
56
+ if (event.toolName === 'team_remind') log({ type: 'tool_end', isError: event.isError, result: event.result })
57
+ })
58
+ pi.on('agent_settled', (_event, ctx) => { log({ type: 'agent_settled', ...state(ctx) }) })
59
+ pi.on('session_shutdown', () => {
60
+ log({ type: 'shutdown' })
61
+ const file = join(process.env.TEAM_STATE_DIR ?? '', 'remind-tool/current.json')
62
+ try { log({ type: 'capability', value: JSON.parse(readFileSync(file, 'utf8')) }) }
63
+ catch (e: any) { log({ type: 'capability_missing', reason: e.code, exists: existsSync(file) }) }
64
+ })
65
+ }
@@ -759,7 +759,7 @@ check_coverage() {
759
759
  [ "$aw" = "0" ] && ok "每个别名都打印主命令的页并点名该别名"
760
760
 
761
761
  # O2 · the dispatcher's internal entries are a closed set, declared in one place (here)
762
- local internal="__inbox-write __notify-settle __panel-data"
762
+ local internal="__inbox-write __notify-settle __panel-data __remind-recover"
763
763
  local found want nm extra="" miss="" n
764
764
  found="$(team_internal_labels)"
765
765
  want="$(printf '%s\n' $internal | sort -u)"
@@ -1512,11 +1512,9 @@ if [ "$_TEAM_HELP_REQ" = "1" ]; then""", 1)' \
1512
1512
  coverage "__probe-x"
1513
1513
 
1514
1514
  # O2b: the declared internal set names one entry that is no longer a dispatcher label
1515
- # P417: 这里的字面量以前跟丢了声明本身(声明是三个名字 `__inbox-write __notify-settle __panel-data`,
1516
- # 而变异找的是中间没有 `__notify-settle` 的两词子串)——替换静默空转,⑪ 于是长期「没有红」:
1517
- # 一条自己什么都没测的红侧。字面量改成声明的原三词串;改完这条翻转必须变红。
1515
+ # P417: 变异必须点名声明的完整当前值;替换静默空转会让这条红侧什么都没测。
1518
1516
  flip_case "internal-list-short" "⑪声明清单里删一个内部名" "tests/help-surface.sh" \
1519
- 's = s.replace("__inbox-write __notify-settle __panel-data", "__notify-settle __panel-data", 1)' \
1517
+ 's = s.replace("__inbox-write __notify-settle __panel-data __remind-recover", "__notify-settle __panel-data __remind-recover", 1)' \
1520
1518
  coverage "__inbox-write"
1521
1519
 
1522
1520
  # O6a: a declared group disappears from the manifest while its commands still name it
@@ -7,8 +7,12 @@ ROOT="$(cd "$SELF_DIR/../../.." && pwd)"
7
7
  REF=""
8
8
  if [ "${1:-}" = --ref ] && [ "$#" = 2 ]; then REF="$2"
9
9
  elif [ "$#" != 0 ]; then printf 'usage: isolation-ledger.sh [--ref <commit>]\n' >&2; exit 2; fi
10
- TMP="$(mktemp -d -p /var/tmp p426-isolation.XXXXXX)"
11
- trap 'rm -rf "$TMP"' EXIT
10
+ # P427:临时根走夹具的**唯一创建者**(tests/lib/tmp-root.sh:owned 家族 + 项目 ns + 落盘台账 + 退出回收)。
11
+ # 不自己算基准、也不写死 /var/tmp —— section 40 的临时根 lint 对这两件事都会点名(旧写法是
12
+ # `mktemp -d -p /var/tmp p426-isolation.XXXXXX`)。
13
+ . "$SELF_DIR/lib/tmp-root.sh"
14
+ TMP="$(tmp_root_create isolation)" || { printf 'isolation-ledger: 建不了临时根\n' >&2; exit 2; }
15
+ trap 'tmp_root_reap_all' EXIT
12
16
  for file in smoke.sh tmux-identity-leak.sh; do
13
17
  if [ -n "$REF" ]; then git -C "$ROOT" show "$REF:skills/teamsmith/tests/$file" > "$TMP/$file"
14
18
  else cp "$SELF_DIR/$file" "$TMP/$file"; fi
@@ -47,6 +47,13 @@ kr_panel_snapshot() { # <页> <额外参数…> → stdout
47
47
  | sed -e 's/\x1b\[[0-9;]*m//g'
48
48
  }
49
49
 
50
+ kr_reply_time_snapshot() { # <输出> <TZ> <at|-> <省略 0|1> <页> <额外参数…>
51
+ local out="$1" tz="$2" at="$3" omit="$4" page="$5"; shift 5
52
+ "${clean_env[@]}" TZ="$tz" B3_STUB_REPLY=ok B3_STUB_REPLY_AT="$at" B3_STUB_REPLY_AT_OMIT="$omit" \
53
+ node "$panel" --root "$ROOT" --team-cli "$SELF_DIR/panel-b3-stub.sh" --snapshot --page "$page" \
54
+ --width 160 --height 30 --lang zh "$@" 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$out"
55
+ }
56
+
50
57
  # ---------------------------------------------------------------- 组:blocks
51
58
  kr_group_blocks() {
52
59
  section "blocks · 三个需求块的装配契约(3.3)"
@@ -73,6 +80,52 @@ kr_group_blocks() {
73
80
  assert_match "$(kr_argv)" 'reply_body.*--no 1' "blocks:视窗形态出现在 argv(--no 1)"
74
81
  assert_eq "blocks:打开视窗时不调度 list(视窗取代列表)" "$(block_calls reply_list)" "0"
75
82
  assert_has "$tmp/bl-body.txt" "块夹具正文" "blocks:正文块渲染出原文"
83
+
84
+ # P436:同一 UTC 输入在两个阅读者时区下,列表/摘要保持紧凑本地时间,详情带实际偏移。
85
+ # 用固定 stub 而非真实发布时间,避免测试依赖运行时钟;KR_PANEL 可指向变异 bundle 做红侧。
86
+ local time_at='2026-09-16T09:59:00Z' zone tz compact full surface page f
87
+ for zone in shanghai new-york; do
88
+ if [ "$zone" = shanghai ]; then
89
+ tz='Asia/Shanghai'; compact='09-16 17:59'; full='2026-09-16 17:59 +08:00'
90
+ else
91
+ tz='America/New_York'; compact='09-16 05:59'; full='2026-09-16 05:59 -04:00'
92
+ fi
93
+ for surface in summary list body; do
94
+ f="$tmp/bl-time-$zone-$surface.txt"
95
+ page=5
96
+ [ "$surface" = summary ] && page=1
97
+ if [ "$surface" = body ]; then
98
+ kr_reply_time_snapshot "$f" "$tz" "$time_at" 0 "$page" --reply-no 1
99
+ else
100
+ kr_reply_time_snapshot "$f" "$tz" "$time_at" 0 "$page"
101
+ fi
102
+ assert_has "$f" "$compact" "blocks:$zone 的 $surface 与列表使用同一紧凑本地时刻"
103
+ assert_not "$f" "$time_at" "blocks:$zone 的 $surface 不直接显示原始 UTC"
104
+ assert_not "$f" 'Invalid Date' "blocks:$zone 的 $surface 没有 Invalid Date"
105
+ if [ "$surface" = body ]; then
106
+ assert_has "$f" "$full" "blocks:$zone 的详情显示完整本地时间与实际偏移"
107
+ fi
108
+ done
109
+ done
110
+ # 非法/缺失时间沿用无时间的降级:保留回复与发布者,不显示原始坏值或 Invalid Date。
111
+ local mode omit shown_at
112
+ for mode in invalid missing; do
113
+ if [ "$mode" = invalid ]; then shown_at='not-a-time'; omit=0; else shown_at='-'; omit=1; fi
114
+ for surface in summary list body; do
115
+ f="$tmp/bl-time-$mode-$surface.txt"
116
+ page=5
117
+ [ "$surface" = summary ] && page=1
118
+ if [ "$surface" = body ]; then
119
+ kr_reply_time_snapshot "$f" 'Asia/Shanghai' "$shown_at" "$omit" "$page" --reply-no 1
120
+ else
121
+ kr_reply_time_snapshot "$f" 'Asia/Shanghai' "$shown_at" "$omit" "$page"
122
+ fi
123
+ assert_not "$f" 'Invalid Date' "blocks:$mode 的 $surface 不显示 Invalid Date"
124
+ assert_not "$f" 'not-a-time' "blocks:$mode 的 $surface 不显示非法原始时间"
125
+ assert_has "$f" 'dev2' "blocks:$mode 的 $surface 仍保留回复与发布者"
126
+ done
127
+ done
128
+
76
129
  # ⑤ 慢块:子进程超时被杀(timeoutMs 10s)→ 只降级本块,其余块照常
77
130
  kr_shim_set_slow reply_list 30
78
131
  reset_argv