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,5 @@
1
+ #!/usr/bin/env bash
2
+ # P442: private real Pi/tmux and controlled loopback model only; never the live team or credentials.
3
+ set -euo pipefail
4
+ TESTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ exec node "$TESTS/remind-tool-real.mjs" "$@"
@@ -2,13 +2,13 @@
2
2
  import assert from 'node:assert/strict'
3
3
  import { createServer } from 'node:http'
4
4
  import { spawnSync } from 'node:child_process'
5
- import { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
5
+ import { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs'
6
6
  import { dirname, join, resolve } from 'node:path'
7
7
  import { fileURLToPath } from 'node:url'
8
8
  import { setTimeout as delay } from 'node:timers/promises'
9
9
  import { CaptureJournal, captureDiskFingerprint, inspectRuntime } from '../scripts/reply-capture.mjs'
10
10
  const tests = dirname(fileURLToPath(import.meta.url)), skill = dirname(tests)
11
- const selection = (process.argv.find(a => a.startsWith('--select='))?.slice(9) ?? (process.argv.includes('--select') ? process.argv[process.argv.indexOf('--select') + 1] : undefined) ?? 'print,tui,terminal,identity,lifecycle,owner-mutations').split(',')
11
+ const selection = (process.argv.find(a => a.startsWith('--select='))?.slice(9) ?? (process.argv.includes('--select') ? process.argv[process.argv.indexOf('--select') + 1] : undefined) ?? 'print,tui,terminal,identity,lifecycle,owner-mutations,diagnostic-mutations,config-mutations').split(',')
12
12
  const evidence = resolve(process.env.P396_EVIDENCE ?? `${process.env.HOME}/.cache/P396/pi-${Date.now()}`)
13
13
  mkdirSync(evidence, { recursive: true, mode: 0o700 })
14
14
  const temporary = mkdtempSync('/var/tmp/p396-real-'), socket = join(temporary, 'socket')
@@ -62,6 +62,7 @@ server = createServer(async (req, res) => {
62
62
  })
63
63
  await new Promise(resolve => server.listen(0, '127.0.0.1', resolve))
64
64
  const port = server.address().port
65
+ const invalidateIdentity = info => tmux('rename-window', '-t', info.pane, 'not-pm')
65
66
  async function run(name, kind = 'print', opts = {}) {
66
67
  const dir = join(evidence, name), root = join(temporary, name), home = join(root, 'home'), state = join(root, '.pi/team/state'), config = join(root, '.pi/team/config.sh')
67
68
  for (const path of [dir, home, state, join(root, 'docs/team/tasks'), join(root, 'docs/team/inbox'), join(root, 'docs/team/outbox'), join(home, '.pi/agent')]) mkdirSync(path, { recursive: true })
@@ -71,6 +72,23 @@ async function run(name, kind = 'print', opts = {}) {
71
72
  const path = join(runSkill, 'extension/team-reply.ts'), bytes = readFileSync(path, 'utf8'), anchor = 'if (owners.has(key)) return'
72
73
  assert.equal(bytes.split(anchor).length, 2); writeFileSync(path, bytes.replace(anchor, 'if (false) return'))
73
74
  }
75
+ if (opts.diagnosticFlip) {
76
+ const path = join(runSkill, 'extension/team-reply.ts'), bytes = readFileSync(path, 'utf8')
77
+ const anchor = ' const line = `[team-reply] ${d.reason}; source=${d.entryId || \'unbound\'}; evidence=${d.path}\\n`\n'
78
+ assert.equal(bytes.split(anchor).length, 2)
79
+ writeFileSync(path, bytes.replace(anchor, `${anchor} process.stderr.write(line)\n`))
80
+ }
81
+ if (opts.configFlip) {
82
+ const path = join(runSkill, 'scripts/reply-capture.mjs'); let bytes = readFileSync(path, 'utf8')
83
+ const read = ' readRegular(config) // The path, type and owner remain capture boundaries; its contents do not.\n'
84
+ const identify = ' return { root, state, config, sessionId: context.sessionId, sessionFile, pid: process.pid, starttime: life.starttime, cwd, tmux }\n'
85
+ const inspect = " readRegular(config) // Keep the doctor's symlink and ownership checks without comparing configuration contents.\n"
86
+ for (const anchor of [read, identify, inspect]) assert.equal(bytes.split(anchor).length, 2, `config flip anchor: ${anchor.trim()}`)
87
+ bytes = bytes.replace(read, ' const configBytes = readRegular(config), configStat = lstatSync(config)\n')
88
+ bytes = bytes.replace(identify, ' return { root, state, config, configHash: digest(configBytes), configIno: configStat.ino, sessionId: context.sessionId, sessionFile, pid: process.pid, starttime: life.starttime, cwd, tmux }\n')
89
+ bytes = bytes.replace(inspect, " if (runtime.configHash !== digest(readRegular(config))) throw new Error('identity/config changed')\n")
90
+ writeFileSync(path, bytes)
91
+ }
74
92
  writeFileSync(join(home, '.pi/agent/settings.json'), JSON.stringify({ retry: { enabled: kind === 'retry', maxRetries: 1, baseDelayMs: 1 }, compaction: { enabled: false } }))
75
93
  writeFileSync(join(root, 'docs/team/BOARD.md'), '# untouched\n')
76
94
  command('git', ['init', '-q', '-b', 'main'], { cwd: root })
@@ -192,6 +210,10 @@ async function run(name, kind = 'print', opts = {}) {
192
210
  assert(!JSON.stringify(history).includes('[[team-reply'), 'next provider history is clean')
193
211
  }
194
212
  if (kind === 'print') assert.equal(readFileSync(join(dir, 'stdout'), 'utf8'), text(ends.at(-1).message) + '\n', 'exact final print stdout')
213
+ for (const file of ['stdout', 'stderr']) {
214
+ const path = join(dir, file)
215
+ if (existsSync(path)) assert(!readFileSync(path, 'utf8').includes('[team-reply]'), `terminal ${file} must not contain internal diagnostics`)
216
+ }
195
217
  if (kind === 'tui') {
196
218
  await delay(100)
197
219
  const raw = readFileSync(join(dir, 'raw.pty'), 'utf8')
@@ -200,6 +222,8 @@ async function run(name, kind = 'print', opts = {}) {
200
222
  writeFileSync(join(dir, 'final-screen.txt'), screen)
201
223
  assert(screen.includes(`决定 ${name} 保留。`), 'final frame matching body positive')
202
224
  assert(!screen.includes('[[team-reply'), 'final frame has no complete control')
225
+ assert(!screen.includes('[team-reply]'), 'final frame must not contain internal diagnostics')
226
+ assert(!raw.includes('[team-reply]'), 'raw PTY must not contain internal diagnostics')
203
227
  // Scrollback may retain transient frames: validate finalized authoritative message separately, never claim zero flash.
204
228
  assert(raw.includes(`决定 ${name} 保留。`), 'raw PTY actual body positive')
205
229
  }
@@ -239,6 +263,38 @@ async function test(name, body) {
239
263
  try { await body(); console.log(`PASS real Pi ${name}`); passed++ }
240
264
  catch (e) { failed++; console.error(`FAIL real Pi ${name}: ${e.stack}`) }
241
265
  }
266
+ async function configChange(name) {
267
+ const flip = process.env.P438_CONFIG_FLIP === '1'
268
+ await run(name, 'print', {
269
+ skillCopy: flip, configFlip: flip,
270
+ onReady: async info => {
271
+ const runtimePath = join(info.state, 'reply-capture/runtime.json')
272
+ await until(() => existsSync(runtimePath) && json(runtimePath).status === 'ready', 'capture ready before config edit')
273
+ const before = readFileSync(info.config, 'utf8'), beforeIno = statSync(info.config).ino
274
+ const output = command('bash', [join(info.skill, 'scripts/team'), '--root', info.root, 'config', 'set-task-model', 'routine', 'p396/after-config', '--yes'], { cwd: info.root, env: info.env })
275
+ writeFileSync(join(info.dir, 'config-change.txt'), output)
276
+ assert.notEqual(readFileSync(info.config, 'utf8'), before, 'the product CLI really changed task-model configuration')
277
+ assert.notEqual(statSync(info.config).ino, beforeIno, 'the atomic CLI write really changed the config inode')
278
+ assert.match(readFileSync(info.config, 'utf8'), /routine=p396\/after-config/)
279
+ const { inspectRuntime: inspect } = await import(join(info.skill, 'scripts/reply-capture.mjs'))
280
+ assert.equal(inspect({ ...info, window: 'pm' }).state, 'ready', 'task-model edit leaves runtime ready')
281
+ },
282
+ interactive: async info => {
283
+ await until(() => storeCount(info.state) === 1 && confirmedCount(info.state) === 1, 'marked reply saved after task-model edit')
284
+ const runtime = json(join(info.state, 'reply-capture/runtime.json'))
285
+ assert.equal(runtime.status, 'ready', 'capture does not degrade after the changed configuration is re-proved')
286
+ const { inspectRuntime: inspect } = await import(join(info.skill, 'scripts/reply-capture.mjs'))
287
+ assert.equal(inspect({ ...info, window: 'pm' }).state, 'ready', 'doctor runtime remains ready after capture')
288
+ const doctor = spawnSync('bash', [join(info.skill, 'scripts/team'), '--root', info.root, 'doctor'], { cwd: info.root, env: info.env, encoding: 'utf8' })
289
+ writeFileSync(join(info.dir, 'doctor.txt'), doctor.stdout + doctor.stderr)
290
+ assert.match(doctor.stdout, /关键回复运行/)
291
+ assert.match(doctor.stdout, /ready disk=/)
292
+ const events = jsonl(join(info.dir, 'events.jsonl'))
293
+ assert(events.filter(e => e.type === 'message_end').every(e => !text(e.message).includes('[[team-reply')), 'the post-edit reply is cleaned')
294
+ await control(info, 'stop')
295
+ },
296
+ })
297
+ }
242
298
  try {
243
299
  if (selection.includes('print')) await test('builtin print/end/append/entry/settled/raw store/transcript', () => run('print'))
244
300
  if (selection.includes('tui')) await test('interactive actual-marker raw PTY and authoritative final cleanup', () => run('tui', 'tui'))
@@ -253,6 +309,41 @@ try {
253
309
  },
254
310
  }))
255
311
  }
312
+ if (selection.includes('config-change')) await test('task-model CLI edit keeps live capture and doctor ready', () => configChange('config-change'))
313
+ if (selection.includes('config-mutations')) await test('restoring config hash/inode identity makes the real edit red; restoration is green', async () => {
314
+ for (const [group, code] of [['config-flip', 1], ['config-control', 0]]) {
315
+ const result = spawnSync(process.execPath, [fileURLToPath(import.meta.url), '--select=config-change'], {
316
+ env: { ...process.env, P396_EVIDENCE: join(evidence, group), P438_CONFIG_FLIP: code ? '1' : '0' }, encoding: 'utf8',
317
+ })
318
+ const output = result.stdout + result.stderr
319
+ writeFileSync(join(evidence, `${group}.log`), output)
320
+ assert.equal(result.status, code, output)
321
+ assert(output.includes(code ? 'task-model edit leaves runtime ready' : 'passed=1 failed=0'), output)
322
+ }
323
+ })
324
+ if (selection.includes('diagnostics')) await test('recover-skip:ineligible is file-only and never appears in the Pi terminal', async () => {
325
+ const info = await run('diagnostics', 'tui', {
326
+ noPublish: true, onReady: invalidateIdentity,
327
+ skillCopy: process.env.P437_DIAGNOSTIC_FLIP === '1', diagnosticFlip: process.env.P437_DIAGNOSTIC_FLIP === '1',
328
+ })
329
+ const path = join(info.state, 'reply-capture/diagnostics.log')
330
+ assert(existsSync(path), 'recover refusal leaves a local diagnostic file')
331
+ const diagnostic = readFileSync(path, 'utf8')
332
+ assert(diagnostic.includes('[team-reply] recover-skip:ineligible; source=unbound; evidence='), diagnostic)
333
+ assert(diagnostic.includes(join(info.state, 'reply-capture')), 'diagnostic retains its evidence path')
334
+ })
335
+ if (selection.includes('diagnostic-mutations')) await test('restoring diagnostic stderr makes the real Pi terminal assertion red; restoration is green', async () => {
336
+ for (const [group, code] of [['diagnostics-flip', 1], ['diagnostics-control', 0]]) {
337
+ const result = spawnSync(process.execPath, [fileURLToPath(import.meta.url), '--select=diagnostics'], {
338
+ env: { ...process.env, P396_EVIDENCE: join(evidence, group), P437_DIAGNOSTIC_FLIP: code ? '1' : '0' }, encoding: 'utf8',
339
+ })
340
+ const output = result.stdout + result.stderr
341
+ writeFileSync(join(evidence, `${group}.log`), output)
342
+ assert.equal(result.status, code, output)
343
+ if (code) assert(output.includes('raw PTY must not contain internal diagnostics'), output)
344
+ else assert(output.includes('passed=1 failed=0'), output)
345
+ }
346
+ })
256
347
  if (selection.includes('owner-flip')) await test('first path keeps owner/runtime', () => run('owner-flip', 'print', { skillCopy: true, duplicate: true, ownerFlip: true }))
257
348
  if (selection.includes('owner-control')) await test('first path keeps owner/runtime', () => run('owner-control', 'print', { skillCopy: true, duplicate: true }))
258
349
  if (selection.includes('owner-mutations')) await test('owner mutation named red and restoration green in private Pi', async () => {