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.
- package/README.md +6 -6
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +37 -1
- package/skills/teamsmith/SKILL.md +32 -23
- package/skills/teamsmith/extension/team-bg.ts +12 -11
- package/skills/teamsmith/extension/team-inbox-watch.ts +149 -5
- package/skills/teamsmith/extension/team-notify.ts +20 -13
- package/skills/teamsmith/extension/team-remind.ts +189 -0
- package/skills/teamsmith/extension/team-reply.ts +4 -7
- package/skills/teamsmith/references/migration.md +101 -0
- package/skills/teamsmith/references/openspec.md +43 -27
- package/skills/teamsmith/references/protocol.md +28 -18
- package/skills/teamsmith/references/reminders.md +133 -98
- package/skills/teamsmith/references/troubleshooting.md +12 -7
- package/skills/teamsmith/references/workflows.md +85 -34
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +28 -5
- package/skills/teamsmith/scripts/lib/cmd-project.sh +100 -15
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +135 -10
- package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
- package/skills/teamsmith/scripts/lib/cmd-update.sh +90 -88
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +322 -159
- package/skills/teamsmith/scripts/lib/common.sh +156 -26
- package/skills/teamsmith/scripts/panel/panel.js +182 -182
- package/skills/teamsmith/scripts/panel/src/data.ts +113 -6
- package/skills/teamsmith/scripts/panel/src/layout.ts +26 -4
- package/skills/teamsmith/scripts/panel/src/main.tsx +103 -14
- package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
- package/skills/teamsmith/scripts/remind-store.mjs +404 -17
- package/skills/teamsmith/scripts/remind-tick.mjs +105 -0
- package/skills/teamsmith/scripts/reminder-delivery.mjs +76 -0
- package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
- package/skills/teamsmith/scripts/state-authority.mjs +334 -20
- 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 +4 -3
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +13 -11
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
- package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +36 -18
- package/skills/teamsmith/templates/report.md.tmpl +33 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
- package/skills/teamsmith/tests/bg-ledger.sh +24 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
- package/skills/teamsmith/tests/death-cause.sh +5 -0
- package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
- package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
- package/skills/teamsmith/tests/help-surface.sh +14 -151
- package/skills/teamsmith/tests/isolation-ledger.sh +89 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
- package/skills/teamsmith/tests/key-replies.sh +307 -106
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +17 -1
- package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
- package/skills/teamsmith/tests/live-capture-probe.sh +12 -2
- package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
- package/skills/teamsmith/tests/pulse-nudge-key.sh +5 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
- package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
- package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
- package/skills/teamsmith/tests/remind-cli.sh +108 -3
- package/skills/teamsmith/tests/remind-delivery-node.mjs +189 -0
- package/skills/teamsmith/tests/remind-delivery.sh +699 -0
- package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
- package/skills/teamsmith/tests/remind-pulse.sh +199 -0
- package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
- package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
- package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
- package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
- package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
- package/skills/teamsmith/tests/routes.sh +213 -293
- package/skills/teamsmith/tests/section-paths.tsv +14 -12
- package/skills/teamsmith/tests/smoke.sh +876 -130
- package/skills/teamsmith/tests/state-authority.sh +392 -28
- 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 +5 -5
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// reminder-delivery.mjs — the presentation and match half of the Reminder wake (P423 · agent-self-reminder
|
|
2
|
+
// 3.1/3.2). The delivery *decisions* (admission, the frozen batch, observation, unknown, resolve) live in
|
|
3
|
+
// remind-store.mjs inside the authority transaction; this file only answers two questions, both pure:
|
|
4
|
+
//
|
|
5
|
+
// reminderContent(batch) what exact text goes into the session (full text per Reminder, never clipped)
|
|
6
|
+
// matchesObservation(message, batch) is this the event that proves *our* message entered the run
|
|
7
|
+
//
|
|
8
|
+
// The caller (the PM's inbox watcher) writes the intent, then calls pi.sendMessage with this content and
|
|
9
|
+
// these details, then reports the matching `message_start` back to the transaction. A return value, a
|
|
10
|
+
// thrown error or a deferred action never becomes success on its own: only the correlated event does.
|
|
11
|
+
|
|
12
|
+
export const REMINDER_CUSTOM_TYPE = 'team-reminder';
|
|
13
|
+
|
|
14
|
+
const oneLine = (text, limit) => String(text).replace(/\s*\n\s*/g, ' ').slice(0, limit);
|
|
15
|
+
|
|
16
|
+
function attributes(member) {
|
|
17
|
+
const parts = [`source ${member.source ?? 'cli'}`];
|
|
18
|
+
if (member.task) parts.push(`task ${member.task}`);
|
|
19
|
+
if (member.key) parts.push(`key ${member.key}`);
|
|
20
|
+
return parts.join(' · ');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The complete batch as one message. Nothing is shortened; ids and times are the durable record's. */
|
|
24
|
+
export function reminderContent(batch) {
|
|
25
|
+
const attempted = batch.attemptedAt ?? batch.intentAt ?? new Date().toISOString();
|
|
26
|
+
const head = [
|
|
27
|
+
`[teamsmith reminder] ${batch.id} · ${batch.members.length} reminder${batch.members.length === 1 ? '' : 's'}`,
|
|
28
|
+
`Nonce: ${batch.nonce}`,
|
|
29
|
+
];
|
|
30
|
+
const bodies = batch.members.map(member => [
|
|
31
|
+
`ID: ${member.id}`,
|
|
32
|
+
`Due: ${member.dueAt}`,
|
|
33
|
+
`Enqueued: ${member.enqueuedAt ?? '-'}${member.overdue ? ' (overdue: the patrol queued it late)' : ''}`,
|
|
34
|
+
`Attempted: ${attempted}`,
|
|
35
|
+
`From: ${attributes(member)}`,
|
|
36
|
+
'',
|
|
37
|
+
member.message,
|
|
38
|
+
].join('\n'));
|
|
39
|
+
return `${head.join('\n')}\n\n${bodies.join('\n\n---\n\n')}\n\n---\n` +
|
|
40
|
+
'This message is a scheduled reminder this project\'s PM created earlier. The project and task state may have ' +
|
|
41
|
+
'changed since it was scheduled: check the current state before you continue.\n';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The machine-side identity of the same message: what the observation must match, never model-visible. */
|
|
45
|
+
export function reminderDetails(batch) {
|
|
46
|
+
return {
|
|
47
|
+
batchId: batch.id,
|
|
48
|
+
nonce: batch.nonce,
|
|
49
|
+
members: batch.members.map(member => member.id),
|
|
50
|
+
generation: batch.generation,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* True only for the public `message_start` of THIS batch's custom message: same custom type, same batch id,
|
|
56
|
+
* same nonce, same member set. A same-named message from another sender, an assistant/user message or a
|
|
57
|
+
* batch whose details are absent is not an observation.
|
|
58
|
+
*/
|
|
59
|
+
export function matchesObservation(message, batch) {
|
|
60
|
+
if (!message || typeof message !== 'object') return false;
|
|
61
|
+
if (message.role !== 'custom' || message.customType !== REMINDER_CUSTOM_TYPE) return false;
|
|
62
|
+
const details = message.details;
|
|
63
|
+
if (!details || typeof details !== 'object') return false;
|
|
64
|
+
if (details.batchId !== batch.id || details.nonce !== batch.nonce) return false;
|
|
65
|
+
if (!Array.isArray(details.members)) return false;
|
|
66
|
+
const expected = batch.members.map(member => (typeof member === 'string' ? member : member.id));
|
|
67
|
+
if (details.members.length !== expected.length) return false;
|
|
68
|
+
return expected.every((id, index) => details.members[index] === id);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** One bounded log line for the watcher's ledger: what was decided, never the reminder text. */
|
|
72
|
+
export function deliveryLogLine(batch, outcome) {
|
|
73
|
+
const ids = batch.members.map(member => (typeof member === 'string' ? member : member.id));
|
|
74
|
+
return `reminder ${outcome} batch=${batch.id} n=${ids.length} ids=${ids.join('|')} ` +
|
|
75
|
+
`generation=${batch.generation} attempted=${oneLine(batch.attemptedAt ?? batch.intentAt ?? '-', 40)}`;
|
|
76
|
+
}
|
|
@@ -520,12 +520,12 @@ function command(bin, args, cwd) {
|
|
|
520
520
|
if (result.error || result.status !== 0) throw new Error(`${basename(bin)} evidence unavailable`)
|
|
521
521
|
return result.stdout.trim()
|
|
522
522
|
}
|
|
523
|
-
function readRegular(path) {
|
|
523
|
+
export function readRegular(path) {
|
|
524
524
|
safeDirectory(dirname(path))
|
|
525
525
|
const fd = regular(path, C.O_RDONLY)
|
|
526
526
|
try { return readFileSync(fd, 'utf8') } finally { closeSync(fd) }
|
|
527
527
|
}
|
|
528
|
-
function ancestor(older, younger) {
|
|
528
|
+
export function ancestor(older, younger) {
|
|
529
529
|
const seen = new Set()
|
|
530
530
|
while (younger > 0 && !seen.has(younger)) {
|
|
531
531
|
if (older === younger) return true
|
|
@@ -534,7 +534,7 @@ function ancestor(older, younger) {
|
|
|
534
534
|
}
|
|
535
535
|
return false
|
|
536
536
|
}
|
|
537
|
-
function proofPid(path, pid, root) {
|
|
537
|
+
export function proofPid(path, pid, root) {
|
|
538
538
|
try {
|
|
539
539
|
const raw = readRegular(path).trim()
|
|
540
540
|
if (!/^\d+$/.test(raw) || !ancestor(Number(raw), pid)) return false
|
|
@@ -549,7 +549,7 @@ function proofPid(path, pid, root) {
|
|
|
549
549
|
throw e
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
function tmuxEvidence(socket, pane) {
|
|
552
|
+
export function tmuxEvidence(socket, pane) {
|
|
553
553
|
const fields = command('tmux', ['-S', socket, 'display-message', '-p', '-t', pane,
|
|
554
554
|
'#{socket_path}\t#{pid}\t#{pane_id}\t#{pane_pid}\t#{session_name}\t#{window_name}\t#{pane_current_path}']).split('\t')
|
|
555
555
|
if (fields.length !== 7) throw new Error('incomplete tmux evidence')
|
|
@@ -568,7 +568,7 @@ export function resolvePMIdentity(context, env = process.env) {
|
|
|
568
568
|
if (!env.TEAM_STATE_DIR || !env.TEAM_CONFIG_FILE || !env.TEAM_PM_WINDOW || !env.TEAM_SESSION) throw new Error('missing directed PM launch environment')
|
|
569
569
|
const state = safeDirectory(env.TEAM_STATE_DIR), config = resolve(env.TEAM_CONFIG_FILE)
|
|
570
570
|
if (config !== env.TEAM_CONFIG_FILE || realpathSync(config) !== config) throw new Error('noncanonical PM config')
|
|
571
|
-
|
|
571
|
+
readRegular(config) // The path, type and owner remain capture boundaries; its contents do not.
|
|
572
572
|
if (!context.sessionId || !context.sessionFile || !isAbsolute(context.sessionFile)) throw new Error('no persistent session identity')
|
|
573
573
|
const sessionFile = join(safeDirectory(dirname(context.sessionFile)), basename(context.sessionFile))
|
|
574
574
|
if (sessionFile !== context.sessionFile) throw new Error('noncanonical session path')
|
|
@@ -584,8 +584,7 @@ export function resolvePMIdentity(context, env = process.env) {
|
|
|
584
584
|
let proof = proofPid(join(state, 'pm.pid.spawn'), process.pid, root) ? 'spawn' : ''
|
|
585
585
|
if (!proof && proofPid(join(state, 'pm.pid'), process.pid, root) && /^(argv|spawn)$/.test(readRegular(join(state, 'pm.pid.proof')).trim())) proof = 'final'
|
|
586
586
|
if (!proof) throw new Error('no current PM launch proof')
|
|
587
|
-
return { root, state, config,
|
|
588
|
-
sessionId: context.sessionId, sessionFile, pid: process.pid, starttime: life.starttime, cwd, tmux }
|
|
587
|
+
return { root, state, config, sessionId: context.sessionId, sessionFile, pid: process.pid, starttime: life.starttime, cwd, tmux }
|
|
589
588
|
}
|
|
590
589
|
|
|
591
590
|
/** Registry is process evidence, not a second source index. Fixed lock and atomic replacement match journal discipline. */
|
|
@@ -637,8 +636,8 @@ export function inspectRuntime({ root, state, config, session, window, skill })
|
|
|
637
636
|
catch (e) { return { disk, state: 'unknown', reason: `registration:${e.code ?? e.name}` } }
|
|
638
637
|
const base = { disk, loaded: runtime.fingerprint, generation: runtime.generation, extension: runtime.extension, sessionId: runtime.sessionId }
|
|
639
638
|
try {
|
|
640
|
-
if (runtime.root !== realpathSync(root) || runtime.state !== realpathSync(state) || runtime.config !== realpathSync(config)
|
|
641
|
-
|
|
639
|
+
if (runtime.root !== realpathSync(root) || runtime.state !== realpathSync(state) || runtime.config !== realpathSync(config)) throw new Error('identity/config changed')
|
|
640
|
+
readRegular(config) // Keep the doctor's symlink and ownership checks without comparing configuration contents.
|
|
642
641
|
const life = processIdentity(runtime.pid)
|
|
643
642
|
if (life.dead || life.zombie || !life.starttime || life.starttime !== runtime.starttime || realpathSync(`/proc/${runtime.pid}/cwd`) !== runtime.cwd) throw new Error('dead/reused/foreign process')
|
|
644
643
|
const actual = tmuxEvidence(runtime.tmux.socket, runtime.tmux.pane)
|