teamsmith 0.4.5 → 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 (81) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +37 -1
  4. package/skills/teamsmith/SKILL.md +32 -23
  5. package/skills/teamsmith/extension/team-bg.ts +12 -11
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +149 -5
  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 +28 -18
  13. package/skills/teamsmith/references/reminders.md +133 -98
  14. package/skills/teamsmith/references/troubleshooting.md +12 -7
  15. package/skills/teamsmith/references/workflows.md +85 -34
  16. package/skills/teamsmith/scripts/lib/cmd-agents.sh +28 -5
  17. package/skills/teamsmith/scripts/lib/cmd-project.sh +100 -15
  18. package/skills/teamsmith/scripts/lib/cmd-remind.sh +135 -10
  19. package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
  20. package/skills/teamsmith/scripts/lib/cmd-update.sh +90 -88
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +322 -159
  22. package/skills/teamsmith/scripts/lib/common.sh +156 -26
  23. package/skills/teamsmith/scripts/panel/panel.js +182 -182
  24. package/skills/teamsmith/scripts/panel/src/data.ts +113 -6
  25. package/skills/teamsmith/scripts/panel/src/layout.ts +26 -4
  26. package/skills/teamsmith/scripts/panel/src/main.tsx +103 -14
  27. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  28. package/skills/teamsmith/scripts/remind-store.mjs +404 -17
  29. package/skills/teamsmith/scripts/remind-tick.mjs +105 -0
  30. package/skills/teamsmith/scripts/reminder-delivery.mjs +76 -0
  31. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  32. package/skills/teamsmith/scripts/state-authority.mjs +334 -20
  33. package/skills/teamsmith/scripts/strings/commands.tsv +3 -3
  34. package/skills/teamsmith/scripts/strings/help.en.tsv +12 -12
  35. package/skills/teamsmith/scripts/strings/help.zh.tsv +12 -12
  36. package/skills/teamsmith/scripts/team +4 -3
  37. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +13 -11
  38. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  39. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  40. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  41. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  42. package/skills/teamsmith/templates/pm-prompt.md.tmpl +36 -18
  43. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  44. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  45. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  46. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  47. package/skills/teamsmith/tests/death-cause.sh +5 -0
  48. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  49. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  50. package/skills/teamsmith/tests/help-surface.sh +14 -151
  51. package/skills/teamsmith/tests/isolation-ledger.sh +89 -0
  52. package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
  53. package/skills/teamsmith/tests/key-replies.sh +307 -106
  54. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +17 -1
  55. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  56. package/skills/teamsmith/tests/live-capture-probe.sh +12 -2
  57. package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
  58. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  59. package/skills/teamsmith/tests/pulse-nudge-key.sh +5 -0
  60. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
  61. package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
  62. package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
  63. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  64. package/skills/teamsmith/tests/remind-delivery-node.mjs +189 -0
  65. package/skills/teamsmith/tests/remind-delivery.sh +699 -0
  66. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  67. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  68. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  69. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  70. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  71. package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
  72. package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
  73. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  74. package/skills/teamsmith/tests/routes.sh +213 -293
  75. package/skills/teamsmith/tests/section-paths.tsv +14 -12
  76. package/skills/teamsmith/tests/smoke.sh +876 -130
  77. package/skills/teamsmith/tests/state-authority.sh +392 -28
  78. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +58 -8
  79. package/skills/teamsmith/tests/tmux-identity-leak.sh +12 -16
  80. package/skills/teamsmith-init/SKILL.md +5 -5
  81. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ // P442: invalid PM contexts stop before Reminder state; full authority input survives unchanged.
3
+ // Real Pi/tmux evidence lives in remind-tool-real.mjs. This file supplies the fast zero-I/O and flip arms.
4
+ import assert from 'node:assert/strict'
5
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
6
+ import { dirname, join, resolve } from 'node:path'
7
+ import { fileURLToPath, pathToFileURL } from 'node:url'
8
+ import { spawnSync } from 'node:child_process'
9
+
10
+ const tests = dirname(fileURLToPath(import.meta.url)), skill = dirname(tests)
11
+ const root = mkdtempSync('/var/tmp/p442-tool-node-')
12
+ const repo = join(root, 'repo'), state = join(repo, '.pi/team/state'), config = join(repo, '.pi/team/config.sh')
13
+ const snapshot = join(state, 'reminders/state.json')
14
+ const env = { ...process.env, HOME: join(root, 'home'), TMPDIR: root,
15
+ TEAM_ROOT: repo, TEAM_MAIN_ROOT: repo, TEAM_STATE_DIR: state, TEAM_CONFIG_FILE: config,
16
+ TEAM_PM_WINDOW: 'pm', TEAM_SESSION: 'p442-node' }
17
+ let passed = 0
18
+ const pass = name => { passed++; console.log(`PASS ${name}`) }
19
+ const command = (bin, args, cwd = repo) => {
20
+ const result = spawnSync(bin, args, { cwd, env, encoding: 'utf8' })
21
+ assert.equal(result.status, 0, `${bin} ${args.join(' ')}: ${result.stderr}`)
22
+ }
23
+ const context = cwd => ({ cwd, sessionManager: { getSessionId: () => 'ordinary-session', getSessionFile: () => join(root, 'ordinary.jsonl') } })
24
+ async function loadExtension(base) {
25
+ const tools = [], handlers = {}
26
+ let activeTools = ['read', 'team_remind']
27
+ const pi = {
28
+ registerTool: definition => { tools.push(definition); if (definition.exposure === 'direct' && !activeTools.includes(definition.name)) activeTools.push(definition.name) },
29
+ getActiveTools: () => activeTools.slice(),
30
+ setActiveTools: names => { activeTools = names.slice() },
31
+ on: (name, fn) => { (handlers[name] ||= []).push(fn) },
32
+ }
33
+ const factory = (await import(pathToFileURL(join(base, 'extension/team-remind.ts')).href)).default
34
+ await factory(pi)
35
+ return { tools, handlers, active: () => activeTools.slice() }
36
+ }
37
+ const actionInput = action => action === 'add' ? { action, after: '1h', message: 'must not be written' }
38
+ : action === 'list' ? { action } : { action, id: 'rem-00000000-0000-0000-0000-000000000000-1' }
39
+
40
+ try {
41
+ for (const path of [state, dirname(config), join(root, 'home')]) mkdirSync(path, { recursive: true })
42
+ writeFileSync(config, "TEAM_PROJECT='p442-node'\nTEAM_SESSION='p442-node'\nTEAM_PM_WINDOW='pm'\nTEAM_PM_MODEL='p442/controlled'\nTEAM_TASK_MODELS='code=p442/controlled'\n")
43
+ command('git', ['init', '-q', '-b', 'main'])
44
+ const worker = join(root, 'worker')
45
+ writeFileSync(join(repo, 'README'), 'fixture')
46
+ command('git', ['add', 'README'])
47
+ command('git', ['-c', 'user.name=fixture', '-c', 'user.email=fixture@example.invalid', 'commit', '-qm', 'fixture'])
48
+ command('git', ['worktree', 'add', '-q', '--detach', worker, 'HEAD'])
49
+
50
+ const host = await loadExtension(skill)
51
+ assert.equal(host.tools.at(-1).exposure, 'hidden')
52
+ for (const [name, cwd, reason] of [['ordinary', repo, 'startup'], ['worker', worker, 'startup'], ['forged', repo, 'reload']]) {
53
+ if (reason === 'reload') await host.handlers.session_start[0]({ reason: 'reload' }, context(cwd))
54
+ else await host.handlers.session_start[0]({ reason: 'startup' }, context(cwd))
55
+ assert.equal(host.tools.at(-1).exposure, 'hidden', `${name}: tool must be hidden`)
56
+ assert(!host.active().includes('team_remind'), `${name}: active tool list withdrew team_remind`)
57
+ for (const action of ['add', 'list', 'show', 'cancel']) {
58
+ await assert.rejects(host.tools.at(-1).execute('call', actionInput(action), undefined, undefined, context(cwd)), /refused|not a verified/, `${name}/${action}`)
59
+ assert(!existsSync(snapshot), `${name}/${action}: no Reminder snapshot may be read or created`)
60
+ }
61
+ pass(`${name}: hidden and all four actions refuse with zero Reminder state`)
62
+ }
63
+ const schema = host.tools.at(-1).parameters
64
+ for (const forbidden of ['project', 'owner', 'state', 'statePath', 'recipient', 'source']) assert(!Object.hasOwn(schema.properties, forbidden))
65
+ pass('tool schema has no caller-selected project/owner/state/recipient/source')
66
+
67
+ // Deliberate defect: bypass only execute's PM check. The same invalid context now writes, proving the
68
+ // zero-state assertions above have teeth. The scratch copy contains only the modules this extension loads.
69
+ const flipped = join(root, 'flipped-skill')
70
+ for (const relative of ['extension/team-remind.ts', 'scripts/remind-capability.mjs', 'scripts/reply-capture.mjs',
71
+ 'scripts/replies.mjs', 'scripts/state-authority.mjs', 'scripts/remind-store.mjs']) {
72
+ mkdirSync(dirname(join(flipped, relative)), { recursive: true }); cpSync(join(skill, relative), join(flipped, relative))
73
+ }
74
+ const extensionPath = join(flipped, 'extension/team-remind.ts')
75
+ const original = readFileSync(extensionPath, 'utf8'), anchor = 'const identity = verify(ctx)'
76
+ assert.equal(original.split(anchor).length, 2)
77
+ writeFileSync(extensionPath, original.replace(anchor,
78
+ "const identity = { root: ctx.cwd, state: join(ctx.cwd, '.pi/team/state'), config: join(ctx.cwd, '.pi/team/config.sh') }"))
79
+ const badHost = await loadExtension(flipped)
80
+ await badHost.handlers.session_start[0]({ reason: 'startup' }, context(repo))
81
+ const badResult = await badHost.tools.at(-1).execute('call', actionInput('add'), undefined, undefined, context(repo))
82
+ assert.equal(badResult.details.ok, true)
83
+ assert(existsSync(snapshot), 'the identity-check mutation must really write in the invalid context')
84
+ pass('flip: removing execute identity proof turns the same invalid add into a write')
85
+
86
+ // Direct authority presentation: no key means independent IDs; a 64 KiB body and its final newline survive.
87
+ rmSync(snapshot, { force: true })
88
+ const capability = await import(pathToFileURL(join(skill, 'scripts/remind-capability.mjs')).href)
89
+ const assertConfigValues = module => {
90
+ const parse = (value, key = 'TEAM_SESSION') => module.configValue(`${key}=${value}\n`, key)
91
+ assert.equal(parse('"p442-node" # tmux session name'), 'p442-node', 'default generated quoted value with trailing comment')
92
+ assert.equal(parse('"p442#node" # hash inside quotes'), 'p442#node', 'quoted # belongs to the value')
93
+ assert.equal(parse("'p442#node'\t# hash inside quotes"), 'p442#node', 'single-quoted # belongs to the value')
94
+ assert.equal(parse('p442-node # tmux session name'), 'p442-node', 'unquoted value loses its whitespace-delimited comment')
95
+ assert.equal(parse('p442#node'), 'p442#node', 'unquoted # without preceding whitespace belongs to the value')
96
+ }
97
+ assertConfigValues(capability)
98
+ pass('config: default comments, quoted hashes and unquoted values parse by behavior')
99
+
100
+ const legacyParser = `export function configValue(text, key) {
101
+ const match = new RegExp(\`^\\\\s*(?:export\\\\s+)?\${key}=(.*)\\\\s*$\`, 'm').exec(text)
102
+ if (!match) return null
103
+ const raw = match[1].trim()
104
+ if ((raw.startsWith("'") && raw.endsWith("'")) || (raw.startsWith('"') && raw.endsWith('"'))) return raw.slice(1, -1)
105
+ return raw
106
+ }`
107
+ const currentParser = readFileSync(join(skill, 'scripts/remind-capability.mjs'), 'utf8').match(/export function configValue\(text, key\) \{[\s\S]*?\n\}/)?.[0]
108
+ assert(currentParser, 'locate the current configValue for the legacy flip')
109
+ const legacyPath = join(root, 'legacy-config.mjs')
110
+ writeFileSync(legacyPath, readFileSync(join(skill, 'scripts/remind-capability.mjs'), 'utf8')
111
+ .replace(currentParser, () => legacyParser)
112
+ .replace("'./reply-capture.mjs'", JSON.stringify(pathToFileURL(join(skill, 'scripts/reply-capture.mjs')).href)))
113
+ const legacy = await import(pathToFileURL(legacyPath).href)
114
+ let legacyFailure
115
+ try { assertConfigValues(legacy) } catch (e) { legacyFailure = e }
116
+ assert.match(legacyFailure?.message ?? '', /default generated quoted value with trailing comment/,
117
+ 'restoring the old parser must turn the named default-config assertion red')
118
+ console.log(`EXPECTED RED configValue: ${legacyFailure.message.split('\n')[0]}`)
119
+ pass('flip: restoring old configValue turns the named default-config assertion red')
120
+
121
+ const identity = { root: repo, state, config }
122
+ const capabilityRecord = generation => ({ generation, extensionVersion: 'fixture', status: 'registered', exposure: 'direct' })
123
+ capability.publishRemindCapability(identity, capabilityRecord('before-remove'))
124
+ capability.removeRemindCapability(identity, 'before-remove')
125
+ assert(!existsSync(join(state, 'remind-tool/current.json')), 'matching shutdown removes capability evidence')
126
+ capability.publishRemindCapability(identity, capabilityRecord('after-remove'))
127
+ assert.equal(JSON.parse(readFileSync(join(state, 'remind-tool/current.json'), 'utf8')).generation, 'after-remove',
128
+ 'a new session can immediately publish after removal without inheriting a held lock')
129
+ const large = `${'x'.repeat(64 * 1024)}\n`
130
+ const first = await capability.runReminderAuthority({ identity, skill, action: 'add', params: { after: '1h', message: large } })
131
+ const second = await capability.runReminderAuthority({ identity, skill, action: 'add', params: { after: '1h', message: large } })
132
+ assert(first.reminder.id !== second.reminder.id)
133
+ assert.equal(first.reminder.source, 'pm-tool')
134
+ assert.equal(first.reminder.message, large)
135
+ const listed = await capability.runReminderAuthority({ identity, skill, action: 'list', params: {} })
136
+ assert.equal(listed.active.find(item => item.id === first.reminder.id).message, large)
137
+ const shown = await capability.runReminderAuthority({ identity, skill, action: 'show', params: { id: first.reminder.id } })
138
+ assert.equal(shown.reminder.message, large)
139
+ const cancelled = await capability.runReminderAuthority({ identity, skill, action: 'cancel', params: { id: first.reminder.id } })
140
+ assert.equal(cancelled.outcome, 'cancelled')
141
+ pass('authority: full text and capability removal followed immediately by a new registration')
142
+
143
+ const truncating = join(root, 'truncating.mjs')
144
+ const capabilitySource = readFileSync(join(skill, 'scripts/remind-capability.mjs'), 'utf8')
145
+ .replace("'./reply-capture.mjs'", JSON.stringify(pathToFileURL(join(skill, 'scripts/reply-capture.mjs')).href))
146
+ const truncateAnchor = "input = Buffer.from(params.message, 'utf8')"
147
+ assert.equal(capabilitySource.split(truncateAnchor).length, 2)
148
+ writeFileSync(truncating, capabilitySource.replace(truncateAnchor,
149
+ "params = { ...params, message: params.message.slice(0, 65536) };\n input = Buffer.from(params.message, 'utf8')"))
150
+ const badCapability = await import(pathToFileURL(truncating).href)
151
+ const truncated = await badCapability.runReminderAuthority({ identity, skill, action: 'add', params: { after: '1h', message: large } })
152
+ assert.equal(truncated.reminder.message.length, 65536)
153
+ assert(!truncated.reminder.message.endsWith('\n'))
154
+ pass('flip: truncating the tool input loses the final newline and is caught by the full-text assertions')
155
+
156
+ console.log(`remind-tool-node: passed=${passed} failed=0`)
157
+ } finally {
158
+ rmSync(root, { recursive: true, force: true })
159
+ }