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
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// remind-delivery-node.mjs — the Node half of tests/remind-delivery.sh (P423 · agent-self-reminder 3.1/3.2).
|
|
3
|
+
//
|
|
4
|
+
// Three groups, each printing `RD PASS|FAIL <name> [:: detail]` lines (the bash fixture owns the
|
|
5
|
+
// authority-level lifecycle; this file owns the presentation/match contract and the watcher itself):
|
|
6
|
+
//
|
|
7
|
+
// content reminderContent(): every Reminder's text byte for byte, ids, due/enqueued/attempt times,
|
|
8
|
+
// source/task/overdue, no truncation; reminderDetails() carries the correlation identity.
|
|
9
|
+
// match matchesObservation(): only our custom message with the frozen batch id, nonce and member
|
|
10
|
+
// set matches; role, type, nonce, batch and members each fail it on their own.
|
|
11
|
+
// watcher the real extension with a fake Pi host: one frozen batch → exactly one sendMessage
|
|
12
|
+
// (followUp, triggerTurn), durable intent before the call, the correlated message_start
|
|
13
|
+
// commits observed + one automatic Standby exit, a duplicate event changes nothing.
|
|
14
|
+
//
|
|
15
|
+
// Isolation: the caller (the fixture) prepares a repository, HOME/TMPDIR and strips the inherited team
|
|
16
|
+
// identity; this file only touches the repository path it is given and never the real project.
|
|
17
|
+
import { readFileSync } from 'node:fs'
|
|
18
|
+
import { join, resolve } from 'node:path'
|
|
19
|
+
import { pathToFileURL } from 'node:url'
|
|
20
|
+
|
|
21
|
+
const [skillArg, repoArg, group] = process.argv.slice(2)
|
|
22
|
+
if (!skillArg || !repoArg || !group) {
|
|
23
|
+
console.error('usage: remind-delivery-node.mjs <skill-dir> <fixture-repo> <content|match|watcher>')
|
|
24
|
+
process.exit(2)
|
|
25
|
+
}
|
|
26
|
+
const SKILL = resolve(skillArg)
|
|
27
|
+
const REPO = resolve(repoArg)
|
|
28
|
+
const MOD = await import(pathToFileURL(join(SKILL, 'scripts/reminder-delivery.mjs')).href)
|
|
29
|
+
|
|
30
|
+
let pass = 0
|
|
31
|
+
let fail = 0
|
|
32
|
+
const ok = (name, detail = '') => { pass++; process.stdout.write(`RD PASS ${name}${detail ? ` :: ${detail}` : ''}\n`) }
|
|
33
|
+
const bad = (name, detail = '') => { fail++; process.stdout.write(`RD FAIL ${name}${detail ? ` :: ${detail}` : ''}\n`) }
|
|
34
|
+
const check = (name, condition, detail = '') => (condition ? ok(name, detail) : bad(name, detail))
|
|
35
|
+
const snapshot = () => JSON.parse(readFileSync(join(REPO, '.pi/team/state/reminders/state.json'), 'utf8'))
|
|
36
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
37
|
+
async function waitFor(fn, timeoutMs, name) {
|
|
38
|
+
const deadline = Date.now() + timeoutMs
|
|
39
|
+
while (Date.now() < deadline) {
|
|
40
|
+
try { const value = fn(); if (value) return value } catch { /* the file may not exist yet */ }
|
|
41
|
+
await sleep(100)
|
|
42
|
+
}
|
|
43
|
+
bad(`${name}(等待超时 ${timeoutMs}ms)`)
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const MESSAGE = '第一行 hello 100%\nsecond line\n\n' // trailing blank line: the bytes are part of the text
|
|
48
|
+
|
|
49
|
+
function batchFixture(overrides = {}) {
|
|
50
|
+
return {
|
|
51
|
+
id: 'bat-00000000-0000-0000-0000-000000000000-3',
|
|
52
|
+
nonce: 'nonce-abc',
|
|
53
|
+
generation: 'off',
|
|
54
|
+
intentAt: '2026-11-05T10:00:00.000Z',
|
|
55
|
+
session: 'sess-1',
|
|
56
|
+
members: [
|
|
57
|
+
{ id: 'rem-x-1', dueAt: '2026-11-05T10:00:00.000Z', enqueuedAt: '2026-11-05T10:00:09.000Z', overdue: false,
|
|
58
|
+
source: 'cli', task: null, key: null, message: MESSAGE },
|
|
59
|
+
{ id: 'rem-x-2', dueAt: '2026-11-05T09:59:00.000Z', enqueuedAt: '2026-11-05T10:00:09.000Z', overdue: true,
|
|
60
|
+
source: 'cli', task: 'P423', key: 'check', message: 'second reminder' },
|
|
61
|
+
],
|
|
62
|
+
...overrides,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (group === 'content') {
|
|
67
|
+
const batch = batchFixture()
|
|
68
|
+
const text = MOD.reminderContent(batch)
|
|
69
|
+
check('content 每条正文逐字节出现(含结尾空行)', text.includes(MESSAGE) && text.includes('second reminder'))
|
|
70
|
+
check('content 点名批次与 nonce', text.includes(batch.id) && text.includes('Nonce: nonce-abc'))
|
|
71
|
+
check('content 点名每条 id / due / enqueued / attempted', ['rem-x-1', 'rem-x-2'].every(id => text.includes(id)) &&
|
|
72
|
+
text.includes('Due: 2026-11-05T09:59:00.000Z') && text.includes('Enqueued: 2026-11-05T10:00:09.000Z') &&
|
|
73
|
+
text.includes('Attempted: 2026-11-05T10:00:00.000Z'))
|
|
74
|
+
check('content 标出补发与来源/任务/key', text.includes('overdue: the patrol queued it late') &&
|
|
75
|
+
text.includes('source cli') && text.includes('task P423') && text.includes('key check'))
|
|
76
|
+
check('content 不截断:整条正文长度原样留在消息里', (text.match(new RegExp(MESSAGE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) ?? []).length === 1)
|
|
77
|
+
const details = MOD.reminderDetails(batch)
|
|
78
|
+
check('details 带批次身份与成员(模型看不见的那一半)', details.batchId === batch.id && details.nonce === 'nonce-abc' &&
|
|
79
|
+
details.members.join(',') === 'rem-x-1,rem-x-2')
|
|
80
|
+
const line = MOD.deliveryLogLine(batch, 'intent-sent')
|
|
81
|
+
check('账本行点名批次/条数/来源,且不含提醒正文', line.includes(batch.id) && line.includes('n=2') && !line.includes('hello'))
|
|
82
|
+
process.stdout.write(`== remind-delivery-node content 结果 == ✓${pass} ✗${fail}\n`)
|
|
83
|
+
process.exit(fail ? 1 : 0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (group === 'match') {
|
|
87
|
+
const batch = batchFixture()
|
|
88
|
+
const good = { role: 'custom', customType: 'team-reminder', details: MOD.reminderDetails(batch), content: 'x' }
|
|
89
|
+
check('match 我们那条消息 + 冻结的身份 → 真', MOD.matchesObservation(good, batch) === true)
|
|
90
|
+
check('match 别的 customType → 假', MOD.matchesObservation({ ...good, customType: 'team-inbox' }, batch) === false)
|
|
91
|
+
check('match 非 custom 角色(助手/用户)→ 假', MOD.matchesObservation({ ...good, role: 'assistant' }, batch) === false)
|
|
92
|
+
check('match 没有 details → 假(身份无从证明)', MOD.matchesObservation({ ...good, details: undefined }, batch) === false)
|
|
93
|
+
check('match 别的 nonce → 假', MOD.matchesObservation({ ...good, details: { ...good.details, nonce: 'other' } }, batch) === false)
|
|
94
|
+
check('match 别的批次 → 假', MOD.matchesObservation({ ...good, details: { ...good.details, batchId: 'bat-other' } }, batch) === false)
|
|
95
|
+
check('match 成员集不同 → 假', MOD.matchesObservation({ ...good, details: { ...good.details, members: ['rem-x-1'] } }, batch) === false)
|
|
96
|
+
process.stdout.write(`== remind-delivery-node match 结果 == ✓${pass} ✗${fail}\n`)
|
|
97
|
+
process.exit(fail ? 1 : 0)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (group !== 'watcher') {
|
|
101
|
+
console.error(`remind-delivery-node: unknown group ${group}`)
|
|
102
|
+
process.exit(2)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ---------------------------------------------------------------- watcher (fake Pi host)
|
|
106
|
+
process.env.TEAM_REMIND_POLL_MS = '200'
|
|
107
|
+
const EXT = join(SKILL, 'extension/team-inbox-watch.ts')
|
|
108
|
+
const sent = []
|
|
109
|
+
const handlers = {}
|
|
110
|
+
let factory
|
|
111
|
+
try {
|
|
112
|
+
factory = (await import(pathToFileURL(EXT).href)).default
|
|
113
|
+
} catch (e) {
|
|
114
|
+
bad(`watcher 扩展导入失败(需要 bun/tsx 这类能直接跑 .ts 的运行时):${e.message}`)
|
|
115
|
+
process.stdout.write(`== remind-delivery-node watcher 结果 == ✓${pass} ✗${fail}\n`)
|
|
116
|
+
process.exit(1)
|
|
117
|
+
}
|
|
118
|
+
factory({
|
|
119
|
+
on: (name, fn) => { (handlers[name] ||= []).push(fn) },
|
|
120
|
+
registerTool() {},
|
|
121
|
+
registerCommand() {},
|
|
122
|
+
sendMessage: (message, options) => { sent.push({ message, options }) },
|
|
123
|
+
})
|
|
124
|
+
if (!handlers.session_start?.length || !handlers.message_start?.length) {
|
|
125
|
+
bad('watcher 没有注册 session_start / message_start')
|
|
126
|
+
process.stdout.write(`== remind-delivery-node watcher 结果 == ✓${pass} ✗${fail}\n`)
|
|
127
|
+
process.exit(1)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let sessionId = 'sess-live'
|
|
131
|
+
const ctx = { cwd: REPO, sessionManager: { getSessionId: () => sessionId } }
|
|
132
|
+
await handlers.session_start[0]({ reason: 'startup' }, ctx)
|
|
133
|
+
const frozen = await waitFor(() => snapshot().batches.some(b => b.phase === 'intent') || null, 8000, 'watcher 把到点提醒冻结成一批')
|
|
134
|
+
check('watcher 冻结后不再有 queued 记录(同一批,不会重复入队)',
|
|
135
|
+
Boolean(frozen) && snapshot().reminders.every(r => r.phase !== 'queued'))
|
|
136
|
+
const waiting = await waitFor(() => (sent.length ? sent : null), 8000, 'watcher 在一批冻结后发出消息')
|
|
137
|
+
const first = sent[0]
|
|
138
|
+
check('watcher 只发一条完整消息(一批一条)', sent.length === 1, `sent=${sent.length}`)
|
|
139
|
+
check('watcher 用 followUp + triggerTurn(不打断当前回合)', first?.options?.triggerTurn === true && first?.options?.deliverAs === 'followUp')
|
|
140
|
+
check('watcher 的 customType 是我们自己的', first?.message?.customType === 'team-reminder')
|
|
141
|
+
const body = String(first?.message?.content ?? '')
|
|
142
|
+
check('watcher 的正文带完整提醒文本(不截断)', body.includes('watcher reminder text'))
|
|
143
|
+
check('watcher 先写 intent 再发(快照里已有该批次)', (() => {
|
|
144
|
+
const snap = snapshot()
|
|
145
|
+
const batch = snap.batches.find(b => b.id === first?.message?.details?.batchId)
|
|
146
|
+
return Boolean(batch) && batch.phase === 'intent' && batch.right === 'unspent'
|
|
147
|
+
})(), 'snapshot has no matching intent')
|
|
148
|
+
const intentBatch = snapshot().batches.find(b => b.id === first?.message?.details?.batchId)
|
|
149
|
+
check('watcher 的意图绑定了当前待命代次', intentBatch?.generation === 1, `generation=${intentBatch?.generation}`)
|
|
150
|
+
|
|
151
|
+
// the observation: Pi's own message_start for that very message
|
|
152
|
+
await handlers.message_start[0]({ message: { role: 'custom', customType: first.message.customType, details: first.message.details } })
|
|
153
|
+
const after = snapshot()
|
|
154
|
+
const observed = after.batches.find(b => b.id === first.message.details.batchId)
|
|
155
|
+
check('watcher 观察到匹配事件 → 批次 observed、right 花掉', observed?.phase === 'observed' && observed?.right === 'spent', `${observed?.phase}/${observed?.right}`)
|
|
156
|
+
check('watcher 的观察原子地退出待命(auto-off)', after.standby.on === false && observed?.outcome?.standby === 'auto-off',
|
|
157
|
+
`standby=${after.standby.on}/${observed?.outcome?.standby}`)
|
|
158
|
+
const observedAudit = after.audit.filter(a => a.op === 'remind-observed')
|
|
159
|
+
check('watcher 的审计点名批次与每个提醒(含来源)', observedAudit.length === 1 &&
|
|
160
|
+
observedAudit[0].batch === observed.id && observedAudit[0].ids.length === 1 && observedAudit[0].sources.length === 1)
|
|
161
|
+
|
|
162
|
+
// a duplicate/late event must change nothing and must not exit a newer generation
|
|
163
|
+
await handlers.message_start[0]({ message: { role: 'custom', customType: first.message.customType, details: first.message.details } })
|
|
164
|
+
await sleep(400)
|
|
165
|
+
const again = snapshot()
|
|
166
|
+
check('watcher 重复事件不产生第二次自动退待命', again.audit.filter(a => a.op === 'remind-observed').length === 1 &&
|
|
167
|
+
again.batches.find(b => b.id === observed.id)?.rightSpentBy === 'wake')
|
|
168
|
+
|
|
169
|
+
// shutdown clears the timer: nothing is sent afterwards
|
|
170
|
+
await handlers.session_shutdown[0]({}, ctx)
|
|
171
|
+
const sentAtShutdown = sent.length
|
|
172
|
+
await sleep(700)
|
|
173
|
+
check('watcher shutdown 后不再发送', sent.length === sentAtShutdown, `sent=${sent.length}`)
|
|
174
|
+
|
|
175
|
+
process.stdout.write(`== remind-delivery-node watcher 结果 == ✓${pass} ✗${fail}\n`)
|
|
176
|
+
process.exit(fail ? 1 : 0)
|