teamsmith 0.3.4 → 0.4.0
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 +8 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +30 -0
- package/skills/teamsmith/SKILL.md +83 -163
- package/skills/teamsmith/extension/team-notify.ts +1 -1
- package/skills/teamsmith/extension/team-reply.ts +105 -0
- package/skills/teamsmith/references/agent-adapters.md +1 -1
- package/skills/teamsmith/references/config.md +20 -11
- package/skills/teamsmith/references/migration.md +47 -3
- package/skills/teamsmith/references/protocol.md +64 -31
- package/skills/teamsmith/references/reminders.md +131 -0
- package/skills/teamsmith/references/troubleshooting.md +19 -5
- package/skills/teamsmith/references/workflows.md +18 -16
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
- package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
- package/skills/teamsmith/scripts/lib/common.sh +44 -4
- package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
- package/skills/teamsmith/scripts/remind-store.mjs +529 -0
- package/skills/teamsmith/scripts/replies.mjs +9 -3
- package/skills/teamsmith/scripts/reply-capture.mjs +596 -0
- package/skills/teamsmith/scripts/state-authority.mjs +500 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
- package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
- package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
- package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
- package/skills/teamsmith/tests/delivery-truth.sh +82 -47
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
- package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
- package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
- package/skills/teamsmith/tests/frames/README.md +3 -1
- package/skills/teamsmith/tests/gate-guard.sh +20 -4
- package/skills/teamsmith/tests/help-surface.sh +60 -2
- package/skills/teamsmith/tests/install-shape.sh +312 -0
- package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
- package/skills/teamsmith/tests/key-replies.sh +187 -68
- package/skills/teamsmith/tests/ledger-claim.sh +8 -6
- package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
- package/skills/teamsmith/tests/lib/pm-window.sh +127 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
- package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
- package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
- package/skills/teamsmith/tests/meta-suite.sh +215 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
- package/skills/teamsmith/tests/panel-b3.sh +33 -4
- package/skills/teamsmith/tests/remind-cli.sh +574 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
- package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture.mjs +622 -0
- package/skills/teamsmith/tests/section-paths.tsv +40 -9
- package/skills/teamsmith/tests/section-select.sh +180 -26
- package/skills/teamsmith/tests/smoke.sh +1235 -238
- package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
- package/skills/teamsmith/tests/state-authority.sh +629 -0
- package/skills/teamsmith/tests/workflow-entry.sh +123 -3
- package/skills/teamsmith-init/SKILL.md +1 -1
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// state-authority.mjs — one durable project-state authority (P406 · change: agent-self-reminder 1.1/1.2).
|
|
3
|
+
//
|
|
4
|
+
// Every cooperating process (CLI, Pulse, Pi) enters through request(): Bash by running this file with
|
|
5
|
+
// --cli, Node by importing { request }. Both spawn the same OS `flock` with this same file as the
|
|
6
|
+
// transaction helper, so there is exactly one implementation of the locator, the snapshot and the lock:
|
|
7
|
+
//
|
|
8
|
+
// <main>/.pi/team/reminder-locator.json pinned state root + persistent project identity
|
|
9
|
+
// <main>/.pi/team/reminder-locator.lock serializes locator establishment (never removed)
|
|
10
|
+
// <state>/reminders/state.json the versioned snapshot (authority)
|
|
11
|
+
// <state>/reminders/authority.lock serializes every state transaction (never removed)
|
|
12
|
+
//
|
|
13
|
+
// Lock order is always locator, then authority. Neither path depends on TMPDIR. A transaction reads and
|
|
14
|
+
// validates the snapshot, mutates it, writes a unique same-directory temporary file, fsyncs it, renames
|
|
15
|
+
// it over the snapshot and fsyncs the directory before reporting success.
|
|
16
|
+
//
|
|
17
|
+
// A missing flock, a lock timeout, a corrupt/unsupported snapshot, a torn file or an identity mismatch
|
|
18
|
+
// is a visible error. There is no unlocked fallback and an unreadable snapshot is never replaced by an
|
|
19
|
+
// empty store. This slice (1.1/1.2) deliberately does NOT import or touch the legacy `standby` marker:
|
|
20
|
+
// migration is task 1.3. `init` therefore only ever writes a fresh snapshot with Standby generation 0.
|
|
21
|
+
|
|
22
|
+
import * as fs from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { randomUUID } from 'node:crypto';
|
|
25
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
26
|
+
import { fileURLToPath } from 'node:url';
|
|
27
|
+
import { REMIND_OPS, applyReminder, renderRemind, validateReminders } from './remind-store.mjs';
|
|
28
|
+
|
|
29
|
+
const SELF = fileURLToPath(import.meta.url);
|
|
30
|
+
const SNAPSHOT_VERSION = 1;
|
|
31
|
+
const LOCK_WAIT_SECONDS = 5;
|
|
32
|
+
// `flock -E` reports a lock conflict with this code, so "waited the whole window" and "the helper died"
|
|
33
|
+
// stop looking alike. A helper of ours never exits 75.
|
|
34
|
+
const LOCK_CONFLICT_EXIT = 75;
|
|
35
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
36
|
+
const SEQUENCE_KINDS = new Set(['reminder', 'batch', 'queue']);
|
|
37
|
+
|
|
38
|
+
const fail = message => { throw new Error(message); };
|
|
39
|
+
|
|
40
|
+
// The project a working directory belongs to -- the same git rule as common.sh's team_dir_roots, so a
|
|
41
|
+
// Node caller (Pulse, Pi) cannot be talked out of its own project by an inherited variable.
|
|
42
|
+
function projectOf(cwd) {
|
|
43
|
+
const out = spawnSync('git', ['-C', cwd, 'rev-parse', '--path-format=absolute', '--show-toplevel', '--git-common-dir'],
|
|
44
|
+
{ encoding: 'utf8' });
|
|
45
|
+
if (out.error) fail(`cannot resolve the project identity from ${cwd}: ${out.error.message}`);
|
|
46
|
+
if (out.status !== 0) fail(`cannot resolve the project identity from ${cwd}: not a git work tree (${String(out.stderr || '').trim()})`);
|
|
47
|
+
const [top, common] = String(out.stdout).trim().split('\n');
|
|
48
|
+
if (!top || !common) fail(`cannot resolve the project identity from ${cwd}: unexpected git output`);
|
|
49
|
+
return { main: fs.realpathSync(path.dirname(common)) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Every entry point pins identity the same way: derive the project from the working directory, then
|
|
53
|
+
// refuse an inherited root that names a different project (a second authority must never be created).
|
|
54
|
+
// The git lookup is cached per working directory (a long-lived Pulse/Pi process must not fork git for
|
|
55
|
+
// every transaction); the comparison against the caller's root runs on every call.
|
|
56
|
+
const identityByCwd = new Map();
|
|
57
|
+
function authorityIdentity(context) {
|
|
58
|
+
const cwd = realDir(context.cwd ?? process.cwd(), 'working directory');
|
|
59
|
+
let derived = identityByCwd.get(cwd);
|
|
60
|
+
if (!derived) { derived = projectOf(cwd); identityByCwd.set(cwd, derived); }
|
|
61
|
+
const main = context.mainRoot ? realDir(context.mainRoot, 'project root') : derived.main;
|
|
62
|
+
if (main !== derived.main) {
|
|
63
|
+
fail(`inherited project root ${main} does not belong to the working directory's project (${derived.main}); ` +
|
|
64
|
+
'refusing to create or use a second authority -- clear the inherited TEAM_* identity or run from the project');
|
|
65
|
+
}
|
|
66
|
+
return main;
|
|
67
|
+
}
|
|
68
|
+
const exists = file => { try { fs.lstatSync(file); return true; } catch (e) { if (e.code === 'ENOENT') return false; throw e; } };
|
|
69
|
+
const regular = file => {
|
|
70
|
+
if (!fs.lstatSync(file).isFile()) fail(`not a regular file: ${file}`);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function realDir(dir, what) {
|
|
74
|
+
let real;
|
|
75
|
+
try { real = fs.realpathSync(dir); } catch (e) { fail(`${what} does not exist or is unreadable: ${dir} (${e.code ?? e.message})`); }
|
|
76
|
+
if (!fs.statSync(real).isDirectory()) fail(`${what} is not a directory: ${dir}`);
|
|
77
|
+
return real;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Physical path of a possibly-not-yet-created path: realpath of the deepest existing ancestor plus the
|
|
81
|
+
// remaining segments. This is what two processes must agree on before anything is created.
|
|
82
|
+
function canonical(pathLike) {
|
|
83
|
+
let current = path.resolve(pathLike);
|
|
84
|
+
const rest = [];
|
|
85
|
+
for (;;) {
|
|
86
|
+
try { return path.join(fs.realpathSync(current), ...rest); }
|
|
87
|
+
catch (e) {
|
|
88
|
+
if (e.code !== 'ENOENT') throw e;
|
|
89
|
+
const parent = path.dirname(current);
|
|
90
|
+
if (parent === current) throw e;
|
|
91
|
+
rest.unshift(path.basename(current));
|
|
92
|
+
current = parent;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function fsyncDir(dir) {
|
|
98
|
+
const fd = fs.openSync(dir, 'r');
|
|
99
|
+
try { fs.fsyncSync(fd); } finally { fs.closeSync(fd); }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function readJSON(file) {
|
|
103
|
+
regular(file);
|
|
104
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
105
|
+
try { return JSON.parse(text); } catch (e) { fail(`unreadable JSON in ${file}: ${e.message}`); }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// fsync the file, rename it into place, fsync the directory. A failed write leaves the old snapshot.
|
|
109
|
+
function writeAtomic(file, value) {
|
|
110
|
+
const dir = path.dirname(file);
|
|
111
|
+
const tmp = path.join(dir, `.${path.basename(file)}.${process.pid}.${randomUUID()}.tmp`);
|
|
112
|
+
let fd;
|
|
113
|
+
try {
|
|
114
|
+
fd = fs.openSync(tmp, 'wx', 0o600);
|
|
115
|
+
fs.writeFileSync(fd, JSON.stringify(value) + '\n', 'utf8');
|
|
116
|
+
fs.fsyncSync(fd);
|
|
117
|
+
fs.closeSync(fd);
|
|
118
|
+
fd = undefined;
|
|
119
|
+
fs.renameSync(tmp, file);
|
|
120
|
+
fsyncDir(dir);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
if (fd !== undefined) { try { fs.closeSync(fd); } catch { /* the original error is the one to report */ } }
|
|
123
|
+
try { if (exists(tmp)) fs.unlinkSync(tmp); } catch { /* a leftover temp file is inert; keep the real error */ }
|
|
124
|
+
throw e;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const locatorFile = main => path.join(main, '.pi/team/reminder-locator.json');
|
|
129
|
+
const locatorLock = main => path.join(main, '.pi/team/reminder-locator.lock');
|
|
130
|
+
const remindersDir = state => path.join(state, 'reminders');
|
|
131
|
+
const snapshotFile = state => path.join(remindersDir(state), 'state.json');
|
|
132
|
+
const authorityLock = state => path.join(remindersDir(state), 'authority.lock');
|
|
133
|
+
|
|
134
|
+
// The lock files are permanent regular files. Refuse a symlink or special file instead of locking it.
|
|
135
|
+
function verifyLockFile(lock) {
|
|
136
|
+
let fd;
|
|
137
|
+
try { fd = fs.openSync(lock, fs.constants.O_CREAT | fs.constants.O_RDWR | fs.constants.O_NOFOLLOW, 0o600); }
|
|
138
|
+
catch (e) { fail(`cannot use lock file ${lock}: ${e.code ?? e.message}`); }
|
|
139
|
+
try { if (!fs.fstatSync(fd).isFile()) fail(`lock path is not a regular file: ${lock}`); }
|
|
140
|
+
finally { fs.closeSync(fd); }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function readLocator(main) {
|
|
144
|
+
const file = locatorFile(main);
|
|
145
|
+
if (!regular_exists(file)) return null;
|
|
146
|
+
const locator = readJSON(file);
|
|
147
|
+
if (locator.version !== SNAPSHOT_VERSION) fail(`unsupported state-root locator version: ${locator.version} (${file})`);
|
|
148
|
+
if (typeof locator.projectId !== 'string' || !UUID_RE.test(locator.projectId)) fail(`state-root locator ${file} has no persistent project identity`);
|
|
149
|
+
if (locator.mainRoot !== main) fail(`state-root locator ${file} belongs to another project (${locator.mainRoot})`);
|
|
150
|
+
if (typeof locator.stateRoot !== 'string' || !path.isAbsolute(locator.stateRoot)) fail(`state-root locator ${file} has an invalid state root`);
|
|
151
|
+
return locator;
|
|
152
|
+
}
|
|
153
|
+
function regular_exists(file) {
|
|
154
|
+
try { return fs.lstatSync(file).isFile(); } catch (e) { if (e.code === 'ENOENT') return false; throw e; }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Absent means never initialized. Present but not a regular file (a symlink, fifo, directory) is a
|
|
158
|
+
// corrupt authority: refuse it instead of treating it as absent and renaming a new snapshot over it.
|
|
159
|
+
function snapshotPresence(file) {
|
|
160
|
+
let stat;
|
|
161
|
+
try { stat = fs.lstatSync(file); } catch (e) { if (e.code === 'ENOENT') return false; throw e; }
|
|
162
|
+
if (!stat.isFile()) fail(`state snapshot is not a regular file: ${file}`);
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// A pinned locator must name this project and the canonical state root the caller asked for.
|
|
167
|
+
function agree(locator, main, want) {
|
|
168
|
+
if (locator.stateRoot !== want) {
|
|
169
|
+
fail(`canonical state-root mismatch: pinned ${locator.stateRoot}, requested ${want}; ` +
|
|
170
|
+
'quiesce the writers and migrate the locator explicitly (never pick a second authority)');
|
|
171
|
+
}
|
|
172
|
+
return { created: false, projectId: locator.projectId, mainRoot: main, stateRoot: locator.stateRoot };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Runs under the locator lock and only ever establishes the first locator: a process that lost the race
|
|
176
|
+
// re-reads here and agrees with the winner instead of pinning a second authority.
|
|
177
|
+
function locate(main, requested) {
|
|
178
|
+
const want = canonical(requested);
|
|
179
|
+
const pinned = readLocator(main);
|
|
180
|
+
if (pinned) return agree(pinned, main, want);
|
|
181
|
+
// First pin: refuse a state root that lives in another project's .pi/team before creating anything.
|
|
182
|
+
const inside = /^(.*)\/\.pi\/team(?:\/|$)/.exec(want);
|
|
183
|
+
if (inside && inside[1] !== main) {
|
|
184
|
+
fail(`state root ${want} is inside another project's .pi/team (${inside[1]}); pass this project's own state root`);
|
|
185
|
+
}
|
|
186
|
+
fs.mkdirSync(want, { recursive: true });
|
|
187
|
+
const stateRoot = fs.realpathSync(want);
|
|
188
|
+
if (stateRoot !== want) fail(`state root ${want} resolves to ${stateRoot} after creation; refusing a moving authority`);
|
|
189
|
+
const locator = { version: SNAPSHOT_VERSION, projectId: randomUUID(), mainRoot: main, stateRoot };
|
|
190
|
+
writeAtomic(locatorFile(main), locator);
|
|
191
|
+
return { created: true, projectId: locator.projectId, mainRoot: main, stateRoot: locator.stateRoot };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function integer(value) {
|
|
195
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function initial(locator) {
|
|
199
|
+
return {
|
|
200
|
+
version: SNAPSHOT_VERSION,
|
|
201
|
+
project: { id: locator.projectId, mainRoot: locator.mainRoot, stateRoot: locator.stateRoot },
|
|
202
|
+
sequences: { reminder: 1, batch: 1, queue: 1 },
|
|
203
|
+
pruned: 0,
|
|
204
|
+
// Present from version 1 so task 1.3 can migrate into the same snapshot. This slice never reads or
|
|
205
|
+
// writes the legacy marker: generation 0 means "no authority-observed Standby yet", not "off".
|
|
206
|
+
standby: { on: false, generation: 0, reason: null, since: null },
|
|
207
|
+
reminders: [],
|
|
208
|
+
batches: [],
|
|
209
|
+
audit: [],
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function validate(snapshot, main, state) {
|
|
214
|
+
const where = snapshotFile(state);
|
|
215
|
+
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) fail(`invalid state snapshot ${where}: not an object`);
|
|
216
|
+
if (snapshot.version !== SNAPSHOT_VERSION) fail(`unsupported state version: ${snapshot.version} (${where}; expected ${SNAPSHOT_VERSION})`);
|
|
217
|
+
const project = snapshot.project;
|
|
218
|
+
if (!project || typeof project !== 'object') fail(`invalid state snapshot ${where}: missing project identity`);
|
|
219
|
+
if (typeof project.id !== 'string' || !UUID_RE.test(project.id)) fail(`invalid state snapshot ${where}: missing project id`);
|
|
220
|
+
if (project.mainRoot !== main) fail(`state project identity mismatch: snapshot main root ${project.mainRoot}, this project ${main}`);
|
|
221
|
+
if (project.stateRoot !== state) fail(`state project identity mismatch: snapshot state root ${project.stateRoot}, this authority ${state}`);
|
|
222
|
+
if (!snapshot.sequences || typeof snapshot.sequences !== 'object') fail(`invalid state snapshot ${where}: missing sequence identities`);
|
|
223
|
+
for (const kind of SEQUENCE_KINDS) {
|
|
224
|
+
if (!Number.isSafeInteger(snapshot.sequences[kind]) || snapshot.sequences[kind] < 1) fail(`invalid state snapshot ${where}: invalid ${kind} sequence`);
|
|
225
|
+
}
|
|
226
|
+
if (!integer(snapshot.pruned)) fail(`invalid state snapshot ${where}: invalid pruned high-water`);
|
|
227
|
+
const standby = snapshot.standby;
|
|
228
|
+
if (!standby || typeof standby !== 'object' || typeof standby.on !== 'boolean' || !integer(standby.generation)) {
|
|
229
|
+
fail(`invalid state snapshot ${where}: invalid Standby slot`);
|
|
230
|
+
}
|
|
231
|
+
if (standby.reason !== null && typeof standby.reason !== 'string') fail(`invalid state snapshot ${where}: invalid Standby reason`);
|
|
232
|
+
if (standby.since !== null && typeof standby.since !== 'string') fail(`invalid state snapshot ${where}: invalid Standby timestamp`);
|
|
233
|
+
for (const key of ['reminders', 'batches', 'audit']) {
|
|
234
|
+
if (!Array.isArray(snapshot[key])) fail(`invalid state snapshot ${where}: ${key} is not an array`);
|
|
235
|
+
}
|
|
236
|
+
if (!snapshot.reminders.every(record => record && typeof record === 'object' && typeof record.id === 'string')) {
|
|
237
|
+
fail(`invalid state snapshot ${where}: a Reminder record has no id`);
|
|
238
|
+
}
|
|
239
|
+
if (!snapshot.batches.every(record => record && typeof record === 'object' && typeof record.id === 'string')) {
|
|
240
|
+
fail(`invalid state snapshot ${where}: a batch record has no id`);
|
|
241
|
+
}
|
|
242
|
+
// The reminder records carry the delivery truth, so their shape is validated with the same care as the
|
|
243
|
+
// envelope: a record whose id, phase or high-water contradicts the snapshot is refused, never "repaired".
|
|
244
|
+
validateReminders(snapshot, fail);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function summary(snapshot, created) {
|
|
248
|
+
return {
|
|
249
|
+
version: snapshot.version,
|
|
250
|
+
created,
|
|
251
|
+
projectId: snapshot.project.id,
|
|
252
|
+
mainRoot: snapshot.project.mainRoot,
|
|
253
|
+
stateRoot: snapshot.project.stateRoot,
|
|
254
|
+
sequences: { ...snapshot.sequences },
|
|
255
|
+
pruned: snapshot.pruned,
|
|
256
|
+
standby: { ...snapshot.standby },
|
|
257
|
+
counts: { reminders: snapshot.reminders.length, batches: snapshot.batches.length, audit: snapshot.audit.length },
|
|
258
|
+
snapshot: snapshotFile(snapshot.project.stateRoot),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function apply(snapshot, request, nowMs) {
|
|
263
|
+
if (REMIND_OPS.has(request.op)) return applyReminder(snapshot, request, nowMs);
|
|
264
|
+
switch (request.op) {
|
|
265
|
+
case 'init':
|
|
266
|
+
return summary(snapshot, true);
|
|
267
|
+
case 'read':
|
|
268
|
+
return summary(snapshot, false);
|
|
269
|
+
case 'allocate': {
|
|
270
|
+
const kind = request.kind;
|
|
271
|
+
if (!SEQUENCE_KINDS.has(kind)) fail(`unknown state sequence kind: ${kind}`);
|
|
272
|
+
const value = snapshot.sequences[kind];
|
|
273
|
+
snapshot.sequences[kind] = value + 1;
|
|
274
|
+
return { kind, value, highWater: snapshot.sequences[kind], projectId: snapshot.project.id, stateRoot: snapshot.project.stateRoot };
|
|
275
|
+
}
|
|
276
|
+
default:
|
|
277
|
+
fail(`unknown state operation: ${request.op}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Runs under the authority lock. The locator is re-read here so a snapshot and a locator that were
|
|
282
|
+
// swapped between projects cannot both pass validation.
|
|
283
|
+
function transaction(main, state, request) {
|
|
284
|
+
const locator = readLocator(main);
|
|
285
|
+
if (!locator) fail(`state-root locator disappeared for ${main}; refusing an unpinned authority`);
|
|
286
|
+
if (locator.stateRoot !== state) fail(`state root ${state} is not the pinned authority (${locator.stateRoot})`);
|
|
287
|
+
verifyLockFile(authorityLock(state));
|
|
288
|
+
const file = snapshotFile(state);
|
|
289
|
+
const hasSnapshot = snapshotPresence(file);
|
|
290
|
+
let snapshot;
|
|
291
|
+
if (hasSnapshot) {
|
|
292
|
+
snapshot = readJSON(file);
|
|
293
|
+
validate(snapshot, main, state);
|
|
294
|
+
if (snapshot.project.id !== locator.projectId) fail(`project identity mismatch: snapshot ${snapshot.project.id}, locator ${locator.projectId}`);
|
|
295
|
+
} else {
|
|
296
|
+
// Absent => never initialized. Corrupt/unsupported is handled above and never becomes an empty store.
|
|
297
|
+
if (request.op === 'read') fail(`state authority is not initialized: ${file}`);
|
|
298
|
+
snapshot = initial(locator);
|
|
299
|
+
validate(snapshot, main, state);
|
|
300
|
+
}
|
|
301
|
+
const before = JSON.stringify(snapshot);
|
|
302
|
+
const result = apply(snapshot, request, Date.now());
|
|
303
|
+
// A reminder result reports its own `created` (an idempotent key hit is created:false); every other
|
|
304
|
+
// operation keeps the authority-level meaning: was this the first snapshot?
|
|
305
|
+
if (!REMIND_OPS.has(request.op)) result.created = !hasSnapshot;
|
|
306
|
+
const changed = JSON.stringify(snapshot) !== before;
|
|
307
|
+
// A first `init` does not mutate the object, but the fresh snapshot must still be published. A read
|
|
308
|
+
// (list/show, a refused cancel) never publishes one: reading an empty authority stays a read.
|
|
309
|
+
if (changed || (!hasSnapshot && request.op === 'init')) writeAtomic(file, snapshot);
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function flock(lock, args, input) {
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
const startedAt = Date.now();
|
|
316
|
+
const child = spawn('flock', ['-x', '-w', String(LOCK_WAIT_SECONDS), '-E', String(LOCK_CONFLICT_EXIT), lock,
|
|
317
|
+
process.execPath, SELF, ...args],
|
|
318
|
+
{ stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'] });
|
|
319
|
+
const out = [];
|
|
320
|
+
const err = [];
|
|
321
|
+
child.stdout.on('data', chunk => out.push(chunk));
|
|
322
|
+
child.stderr.on('data', chunk => err.push(chunk));
|
|
323
|
+
child.on('error', e => reject(new Error(`flock unavailable: ${e.message}; install a usable OS flock utility (no unlocked fallback)`)));
|
|
324
|
+
if (input !== undefined) child.stdin.on('error', () => { /* the helper may exit before reading; its exit status carries the error */ });
|
|
325
|
+
child.on('close', (code, signal) => {
|
|
326
|
+
const stderr = Buffer.concat(err).toString().trim();
|
|
327
|
+
if (code !== 0) {
|
|
328
|
+
if (stderr) return reject(new Error(stderr));
|
|
329
|
+
// Only a conflict exit that actually used up the window is a timeout. Anything else (a helper
|
|
330
|
+
// killed or crashed mid-transaction) is reported as what it is, with its status.
|
|
331
|
+
const waitedOut = code === LOCK_CONFLICT_EXIT && Date.now() - startedAt >= LOCK_WAIT_SECONDS * 1000 - 500;
|
|
332
|
+
if (waitedOut) return reject(new Error(`lock wait timed out after ${LOCK_WAIT_SECONDS}s at ${lock}; no state was written`));
|
|
333
|
+
return reject(new Error(`transaction helper exited with status ${code}${signal ? ` (${signal})` : ''} at ${lock}; no state was written`));
|
|
334
|
+
}
|
|
335
|
+
try { resolve(JSON.parse(Buffer.concat(out).toString())); }
|
|
336
|
+
catch (e) { reject(new Error(`invalid transaction result from ${lock}: ${e.message}`)); }
|
|
337
|
+
});
|
|
338
|
+
if (input !== undefined) child.stdin.end(input);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function resolveAuthority(context) {
|
|
343
|
+
const main = authorityIdentity(context);
|
|
344
|
+
const want = canonical(context.stateRoot);
|
|
345
|
+
// A pinned locator is replaced by rename, so an unlocked read always sees a whole one. That keeps the
|
|
346
|
+
// common path at zero child processes; the locator lock is taken only to establish the first one.
|
|
347
|
+
const pinned = readLocator(main);
|
|
348
|
+
if (pinned) return agree(pinned, main, want);
|
|
349
|
+
try { fs.mkdirSync(path.join(main, '.pi/team'), { recursive: true }); }
|
|
350
|
+
catch (e) { fail(`cannot create the project-local locator directory under ${main}: ${e.code ?? e.message}`); }
|
|
351
|
+
return flock(locatorLock(main), ['--locator', main, want]);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// The single Node-facing entry point (the CLI below is a thin wrapper around it).
|
|
355
|
+
export async function request(context, requestData) {
|
|
356
|
+
const located = await resolveAuthority(context);
|
|
357
|
+
const state = located.stateRoot;
|
|
358
|
+
try { fs.mkdirSync(remindersDir(state), { recursive: true, mode: 0o700 }); }
|
|
359
|
+
catch (e) { fail(`cannot create the authority directory under ${state}: ${e.code ?? e.message}`); }
|
|
360
|
+
return flock(authorityLock(state), ['--transaction', located.mainRoot, state], JSON.stringify(requestData));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export async function resolve(context) {
|
|
364
|
+
return resolveAuthority(context);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function parseCli(argv) {
|
|
368
|
+
const [main, state, op, ...rest] = argv;
|
|
369
|
+
if (!main || !state || !op) {
|
|
370
|
+
fail('usage: state-authority.mjs --cli <project-root> <state-root> ' +
|
|
371
|
+
'<resolve|init|read|allocate <kind>|remind-add|remind-list|remind-show|remind-cancel> ' +
|
|
372
|
+
'[--print <field>] [--json]');
|
|
373
|
+
}
|
|
374
|
+
let print = null;
|
|
375
|
+
let json = false;
|
|
376
|
+
const args = [];
|
|
377
|
+
const flags = {};
|
|
378
|
+
while (rest.length) {
|
|
379
|
+
const token = rest.shift();
|
|
380
|
+
if (token === '--print') {
|
|
381
|
+
print = rest.shift();
|
|
382
|
+
if (!print) fail('--print needs a field name');
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
// Reminder flags are parsed here and handed to the transaction as data; the helper never reads them
|
|
386
|
+
// from the environment or from a shell-quoted string.
|
|
387
|
+
if (REMIND_OPS.has(op) && token.startsWith('--')) {
|
|
388
|
+
const name = token.slice(2);
|
|
389
|
+
if (name === 'json') { json = true; continue; }
|
|
390
|
+
if ((REMIND_BOOL_FLAGS[op] ?? new Set()).has(name)) { flags[name] = true; continue; }
|
|
391
|
+
const value = rest.shift();
|
|
392
|
+
if (value === undefined) fail(`${token} needs a value`);
|
|
393
|
+
flags[name] = value;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
args.push(token);
|
|
397
|
+
}
|
|
398
|
+
const requestData = REMIND_OPS.has(op) ? parseRemindFlags(op, flags) : { op };
|
|
399
|
+
if (op === 'allocate') {
|
|
400
|
+
requestData.kind = args.shift();
|
|
401
|
+
if (!requestData.kind) fail('allocate needs a sequence kind (reminder|batch|queue)');
|
|
402
|
+
}
|
|
403
|
+
if (args.length) fail(`unexpected arguments: ${args.join(' ')}`);
|
|
404
|
+
return { context: { mainRoot: main, stateRoot: state }, requestData, print, json };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Boolean reminder flags (everything else takes a value).
|
|
408
|
+
const REMIND_BOOL_FLAGS = { 'remind-list': new Set(['all']) };
|
|
409
|
+
|
|
410
|
+
// Exactly the flags each reminder operation accepts: an unknown flag is refused here rather than silently
|
|
411
|
+
// ignored, so a typo cannot look like a successful create.
|
|
412
|
+
const REMIND_FLAGS = {
|
|
413
|
+
'remind-add': new Set(['at', 'after', 'key', 'task', 'source']),
|
|
414
|
+
'remind-list': new Set(['all']),
|
|
415
|
+
'remind-show': new Set(['id']),
|
|
416
|
+
'remind-cancel': new Set(['id']),
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
function parseRemindFlags(op, flags) {
|
|
420
|
+
const allowed = REMIND_FLAGS[op];
|
|
421
|
+
const request = { op };
|
|
422
|
+
for (const name of Object.keys(flags)) {
|
|
423
|
+
if (!allowed.has(name)) fail(`${op} does not accept --${name}`);
|
|
424
|
+
request[name] = flags[name];
|
|
425
|
+
}
|
|
426
|
+
if ((op === 'remind-show' || op === 'remind-cancel') && !request.id) fail(`${op} needs --id <reminder-id>`);
|
|
427
|
+
return request;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// The message is read from stdin so its bytes never travel through argv: no shell quoting, no length
|
|
431
|
+
// limit, no re-encoding. Invalid UTF-8 is refused before a lock is taken.
|
|
432
|
+
async function readMessageFromStdin() {
|
|
433
|
+
const chunks = [];
|
|
434
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
435
|
+
const buffer = Buffer.concat(chunks);
|
|
436
|
+
let text;
|
|
437
|
+
try { text = new TextDecoder('utf-8', { fatal: true }).decode(buffer); }
|
|
438
|
+
catch { return { error: 'message is not valid UTF-8; write the text as UTF-8 and try again' }; }
|
|
439
|
+
if (text.indexOf('\u0000') !== -1) return { error: 'message contains a NUL byte' };
|
|
440
|
+
return { message: text };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async function main(argv) {
|
|
444
|
+
const [mode, ...rest] = argv;
|
|
445
|
+
if (mode === '--locator') {
|
|
446
|
+
const [main, requested] = rest;
|
|
447
|
+
verifyLockFile(locatorLock(main));
|
|
448
|
+
process.stdout.write(JSON.stringify(locate(main, requested)) + '\n');
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (mode === '--transaction') {
|
|
452
|
+
const [main, state] = rest;
|
|
453
|
+
const chunks = [];
|
|
454
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
455
|
+
let requestData;
|
|
456
|
+
try { requestData = JSON.parse(Buffer.concat(chunks).toString()); }
|
|
457
|
+
catch (e) { fail(`invalid transaction request on stdin: ${e.message}`); }
|
|
458
|
+
process.stdout.write(JSON.stringify(transaction(main, state, requestData)) + '\n');
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (mode === '--cli') {
|
|
462
|
+
const { context, requestData, print, json } = parseCli(rest);
|
|
463
|
+
if (REMIND_OPS.has(requestData.op)) {
|
|
464
|
+
if (requestData.op === 'remind-add') {
|
|
465
|
+
const message = await readMessageFromStdin();
|
|
466
|
+
if (message.error) {
|
|
467
|
+
process.stdout.write(renderRemind(requestData.op, { ok: false, refusal: 'bad-message', reason: message.error }));
|
|
468
|
+
process.exitCode = 1;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
requestData.message = message.message;
|
|
472
|
+
}
|
|
473
|
+
const result = await request(context, requestData);
|
|
474
|
+
const text = json ? JSON.stringify(result, null, 2) + '\n' : renderRemind(requestData.op, result);
|
|
475
|
+
process.stdout.write(text.endsWith('\n') ? text : text + '\n');
|
|
476
|
+
// A refusal is not a crash: the reason was printed, and the exit status says nothing was written.
|
|
477
|
+
if (!result.ok) process.exitCode = 1;
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
const result = requestData.op === 'resolve' ? await resolve(context) : await request(context, requestData);
|
|
481
|
+
if (print !== null) {
|
|
482
|
+
if (!Object.hasOwn(result, print)) fail(`unknown output field: ${print}`);
|
|
483
|
+
if (result[print] === null || typeof result[print] === 'object') fail(`output field ${print} is not scalar`);
|
|
484
|
+
process.stdout.write(String(result[print]) + '\n');
|
|
485
|
+
} else {
|
|
486
|
+
process.stdout.write(JSON.stringify(result, null, 2) + '\n');
|
|
487
|
+
}
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
fail('usage: state-authority.mjs --cli <project-root> <state-root> ' +
|
|
491
|
+
'<resolve|init|read|allocate <kind>|remind-add|remind-list|remind-show|remind-cancel> [--print <field>] [--json]');
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === SELF) {
|
|
495
|
+
main(process.argv.slice(2)).catch(e => {
|
|
496
|
+
const message = String((e && e.message) || e);
|
|
497
|
+
process.stderr.write(/^state-authority:/.test(message) ? `${message}\n` : `state-authority: ${message}\n`);
|
|
498
|
+
process.exitCode = 1;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
@@ -59,7 +59,7 @@ cmd thread ledger thread <agent> [<message>] [--from <sender>] [--re <n>] --from
|
|
|
59
59
|
cmd report ledger report <ID> <agent> [--force] --force - - ledger gate docs writes-docs none not-reversible:the report file stays - report team report P1 dev
|
|
60
60
|
cmd add-agent seats add-agent <a> [--register] [--create] [--no-install] [--print] --register --create --no-install --print - - seat worktree worktree writes-worktree none not-reversible:the branch and the worktree stay until you remove them - add-agent team add-agent dev
|
|
61
61
|
cmd dispatch seats dispatch <a> <ID> <task-file> [--model <model>] [--branch <name>] [--fresh] [--allow-overflow] [--print] --model --branch --fresh --allow-overflow --print - - seat brief worktree task-branch gate docs state starts-process none not-reversible:the seat's session and its branch are its own history - dispatch team dispatch dev P1 docs/team/tasks/P1-first-task.md --branch task/P1-first-task
|
|
62
|
-
cmd say seats say <a> <message>
|
|
62
|
+
cmd say seats say <a> <message> - - - seat knock docs state writes-docs none not-reversible:the queue keeps what was already delivered - say team say dev "the gate is green, please open the PR"
|
|
63
63
|
cmd notify seats notify <a> <message> [--from <sender>] --from - - seat pulse docs state writes-docs none not-reversible:the inbox line stays - notify team notify pm "P1 delivered, please review"
|
|
64
64
|
cmd draft seats draft [pm] ;; draft send <file> [--now] --now send - seat state writes-state none not-reversible:the delivered text is in the queue - draft team draft send /tmp/note.md
|
|
65
65
|
cmd outbox seats outbox [list] ;; outbox flush [--now] ;; outbox drop <n|all> --now list flush drop - knock state writes-state none idempotent - outbox team outbox list
|
|
@@ -68,6 +68,7 @@ cmd pulse patrol pulse up|down|restart|status|logs [--print] --print up down res
|
|
|
68
68
|
cmd monitor patrol monitor [--once] [--print|--json] [--width <N>] [--height <N>] [--interval <N>] [--events <K>] [--no-pulse] --once --print --json --width --height --interval --events --no-pulse - - pulse state writes-state none not-reversible:every run appends its own bookkeeping line - monitor team monitor --print --once
|
|
69
69
|
cmd watch patrol watch [--once] [--interval <N>] [--ui] --once --interval --ui - - pulse state writes-state none not-reversible:every tick appends to the patrol log - watch team watch --once
|
|
70
70
|
cmd standby patrol standby on [--reason <text>] ;; standby off ;; standby status --reason on off status - pm pulse state writes-state none not-reversible:the state it writes is a record of when it was set - standby team standby on --reason "waiting for the user"
|
|
71
|
+
cmd remind patrol remind add --after <duration> --message <text> [--key <id>] [--task <ref>] [--json] ;; remind add --at <date-time> --message-file <file> [--key <id>] [--task <ref>] [--json] ;; remind list [--all] [--json] ;; remind show <id> [--json] ;; remind cancel <id> [--json] --after --at --message --message-file --key --task --all --json add list show cancel - pm pulse state writes-state none not-reversible:a reminder is a record: cancel marks it cancelled and the history stays - remind team remind add --after 20m --message "check the build"
|
|
71
72
|
cmd up patrol up [--agents] [--fresh-pm] [--print] --agents --fresh-pm --print - - pm seat state starts-process none not-reversible:the PM session it starts keeps its own history - up team up
|
|
72
73
|
cmd resume patrol resume [--agent <a>] [--all] [--dry-run] --agent --all --dry-run - - seat pm state starts-process none not-reversible:a resumed seat continues in its own session - resume team resume --all
|
|
73
74
|
cmd meeting peers meeting open <slug> --with <peer> --topic <text> [--ttl <hours>] [--yes] ;; meeting say <slug> --intent <intent> <message> [--knock] ;; meeting read <slug> [--since <n>] [--peek] ;; meeting list [--all] ;; meeting inbox ;; meeting agree <slug> <option> [--note <text>] ;; meeting close <slug> --with --topic --ttl --yes --intent --knock --since --peek --all --note open say read list inbox agree close propose peer knock help - pm meetings writes-meetings needs-yes:TEAM_CONFIRM_WRITES not-reversible:the shared transcript is the record of what was said - meeting team meeting open rename --with other:pm --topic "rename the interface"
|
|
@@ -275,13 +275,12 @@ cmd.dispatch.arg.--fresh start a new session instead of reopening the recorded o
|
|
|
275
275
|
cmd.dispatch.arg.--allow-overflow dispatch even when the model's concurrency limit is already reached.
|
|
276
276
|
cmd.dispatch.arg.--print print the launch command without starting anything.
|
|
277
277
|
cmd.say.title send a seat one line
|
|
278
|
-
cmd.say.what Puts one line in front of a seat.
|
|
278
|
+
cmd.say.what Puts one line in front of a seat. A live inbox watcher gets the line in its durable inbox and wake spool with no keystrokes; with no usable watcher the line is typed straight into the seat's window as one immediate attempt, even over a draft, and the skip is recorded. Neither path proves the model received it.
|
|
279
279
|
cmd.say.when Use it for a short instruction or a status note. For a decision the seat's next session must still find, write it in the thread as well.
|
|
280
280
|
cmd.say.example team say dev "the gate is green, please open the pull request"
|
|
281
281
|
cmd.say.read the seat's window and the outbox
|
|
282
282
|
cmd.say.write the seat's inbox and the outbox
|
|
283
283
|
cmd.say.see `team notify`, `team outbox`, `team thread`
|
|
284
|
-
cmd.say.arg.--now deliver immediately, skipping the draft guard; the skip is recorded.
|
|
285
284
|
cmd.notify.title one line from a seat to the PM
|
|
286
285
|
cmd.notify.what Writes one line into the PM's inbox and knocks on the PM's window. The sender is resolved from the directory the command runs in, so a seat cannot claim to be the PM by typing a name.
|
|
287
286
|
cmd.notify.when Use it at the end of a turn to say that something is ready or that something is blocked.
|
|
@@ -357,6 +356,21 @@ cmd.standby.read the state directory and the patrol log
|
|
|
357
356
|
cmd.standby.write the state directory
|
|
358
357
|
cmd.standby.see `team pulse`, `team digest`
|
|
359
358
|
cmd.standby.arg.--reason why the PM is standing down; it is written down so the next session knows.
|
|
359
|
+
cmd.remind.title record a one-shot reminder for this project
|
|
360
|
+
cmd.remind.what Records a reminder for the project PM in the same versioned project state as the rest of teamsmith: its full text, when it is due and who created it. `list` prints what is waiting and when it is due, `show` prints one record in full, `cancel` stops a reminder that has not been frozen for delivery. Every status you see is derived from that one record on each read, never a second copy. This build records, lists and cancels them: a due reminder shows as derived-due, and nothing wakes the PM yet.
|
|
361
|
+
cmd.remind.when Use it to park something for a later time instead of holding a session open or retrying from memory.
|
|
362
|
+
cmd.remind.example team remind add --after 20m --message "check the build"
|
|
363
|
+
cmd.remind.read the project state snapshot and the state-root locator
|
|
364
|
+
cmd.remind.write the project state snapshot
|
|
365
|
+
cmd.remind.see `team pulse`, `team standby`
|
|
366
|
+
cmd.remind.arg.--after how long from now until it is due: a whole number and `s`, `m` or `h` (for example `90s`, `20m`, `2h`).
|
|
367
|
+
cmd.remind.arg.--at the instant it is due, as an RFC 3339 date-time with an explicit offset (`2026-10-28T09:00:00+08:00`) or `Z`. A time without an offset, an impossible date or a past instant is refused.
|
|
368
|
+
cmd.remind.arg.--message the text the future agent should read, taken exactly as written. Empty text is refused and nothing is shortened.
|
|
369
|
+
cmd.remind.arg.--message-file read the text from a file, byte for byte; a trailing newline is part of the text.
|
|
370
|
+
cmd.remind.arg.--key a name for this logical reminder. While a live reminder holds the key, the identical request returns that reminder and its original due time, and a different request under the same key is refused; once the reminder ends, the key can be used again.
|
|
371
|
+
cmd.remind.arg.--task the task or brief this reminder belongs to, so the record says what it is about.
|
|
372
|
+
cmd.remind.arg.--all also print the reminders that already ended (the retained history), newest first.
|
|
373
|
+
cmd.remind.arg.--json print the record(s) as JSON instead of the table.
|
|
360
374
|
cmd.up.title build the stage and start the PM
|
|
361
375
|
cmd.up.what Creates the project's session and windows if they are missing and starts the PM in its own window, continuing the project's previous conversation unless a fresh one is asked for. It starts the PM only; the seats are not touched.
|
|
362
376
|
cmd.up.when Use it after a restart, or when the session was lost and the team should keep working in the same project.
|
|
@@ -261,13 +261,12 @@ cmd.dispatch.arg.--fresh 新开一个会话,而不是复用记录里的那个
|
|
|
261
261
|
cmd.dispatch.arg.--allow-overflow 即使该模型的并发限额已经满了也照派。
|
|
262
262
|
cmd.dispatch.arg.--print 只打印启动命令,不启动任何东西。
|
|
263
263
|
cmd.say.title 给一个席位发一句话
|
|
264
|
-
cmd.say.what
|
|
264
|
+
cmd.say.what 把一句话放到席位眼前。席位的收件箱监视器活着时,这句话落进它的 durable 收件箱与唤醒 spool、一个键都不打;没有可用监视器时,直接把这句话打进席位窗口(即使输入框里有草稿),这次跳过会留痕。两条路都不等于模型已经收到。
|
|
265
265
|
cmd.say.when 一句短指令或一句状态说明时用它。席位下一个会话还要找得到的决定,另外写进往来记录。
|
|
266
266
|
cmd.say.example team say dev "门禁绿了,请开 PR"
|
|
267
267
|
cmd.say.read 席位的窗口与延后队列
|
|
268
268
|
cmd.say.write 席位的收件箱与延后队列
|
|
269
269
|
cmd.say.see `team notify`、`team outbox`、`team thread`
|
|
270
|
-
cmd.say.arg.--now 立刻投递,跳过草稿守卫;这次跳过会留痕。
|
|
271
270
|
cmd.notify.title 席位发给 PM 的一句话
|
|
272
271
|
cmd.notify.what 把一句话写进 PM 的收件箱,并敲一下 PM 的窗口。发送者按命令运行时所在的目录解析,所以席位不能靠自称来冒充 PM。
|
|
273
272
|
cmd.notify.when 回合结束时用它,说某件事成了、或者某件事卡住了。
|
|
@@ -343,6 +342,21 @@ cmd.standby.read 状态目录与巡检日志
|
|
|
343
342
|
cmd.standby.write 状态目录
|
|
344
343
|
cmd.standby.see `team pulse`、`team digest`
|
|
345
344
|
cmd.standby.arg.--reason PM 为什么停工;写下来,下一个会话才知道。
|
|
345
|
+
cmd.remind.title 给本项目记一条定时提醒
|
|
346
|
+
cmd.remind.what 把一条提醒记进 teamsmith 的项目状态:完整正文、什么时候到期、谁创建的。`list` 打印还在等的提醒和它们的到期时间,`show` 打印一条的全部内容,`cancel` 取消一条还没被送去投递的提醒。你看到的状态都是每次读取时从那条记录派生出来的,不另存一份。这一版只负责记录、查看和取消:到期的提醒显示为 derived-due,但还不会叫醒 PM。
|
|
347
|
+
cmd.remind.when 要把一件事留到以后再处理、又不想一直挂着会话或靠记性重来时用它。
|
|
348
|
+
cmd.remind.example team remind add --after 20m --message "看一下构建"
|
|
349
|
+
cmd.remind.read 项目状态快照与状态根定位器
|
|
350
|
+
cmd.remind.write 项目状态快照
|
|
351
|
+
cmd.remind.see `team pulse`、`team standby`
|
|
352
|
+
cmd.remind.arg.--after 从现在起多久到期:整数加 `s`、`m` 或 `h`(例如 `90s`、`20m`、`2h`)。
|
|
353
|
+
cmd.remind.arg.--at 到期的时刻,写成带明确时区的 RFC 3339 时间(`2026-10-28T09:00:00+08:00`)或以 `Z` 结尾。没有时区、不存在的日期、已经过去的时间都会被拒绝。
|
|
354
|
+
cmd.remind.arg.--message 将来那个 agent 要读的正文,按原样记录。空正文会被拒绝,也不会被缩短。
|
|
355
|
+
cmd.remind.arg.--message-file 从文件读正文,逐字节照录;文件末尾的换行也是正文的一部分。
|
|
356
|
+
cmd.remind.arg.--key 这条逻辑提醒的名字。只要还有一条未结束的提醒占着这个 key:同样的请求会返回那条提醒和它原来的到期时间,同一个 key 下的不同请求会被拒绝;提醒结束后 key 可以再用。
|
|
357
|
+
cmd.remind.arg.--task 这条提醒属于哪个任务或任务书,记录里因此能看出它是关于什么的。
|
|
358
|
+
cmd.remind.arg.--all 连已经结束的提醒(保留的历史)一起打印,最新的在前。
|
|
359
|
+
cmd.remind.arg.--json 把记录按 JSON 打印,不打印表格。
|
|
346
360
|
cmd.up.title 搭好台子并把 PM 拉起来
|
|
347
361
|
cmd.up.what 缺什么就建什么:项目的 session 与窗口,然后在它自己的窗口里启动 PM,默认接着这个项目上一场会话,除非你要一场新的。它只负责 PM,不动席位。
|
|
348
362
|
cmd.up.when 重启之后用它,或者在 session 丢了、团队该在同一个项目里继续干活时用它。
|
|
@@ -130,6 +130,7 @@ case "$CMD" in
|
|
|
130
130
|
watchdog) team_cmd_watchdog "$@" ;; # 同上
|
|
131
131
|
watchdog-status) team_cmd_watchdog_status "$@" ;; # 同上
|
|
132
132
|
standby) team_cmd_standby "$@" ;;
|
|
133
|
+
remind) team_cmd_remind "$@" ;;
|
|
133
134
|
meeting) team_cmd_meeting "$@" ;;
|
|
134
135
|
version) if [ "${1:-}" = "--check" ] || [ "${1:-}" = "check" ]; then team_cmd_version_check "$@"; else team_cmd_version_brief "$@"; fi ;;
|
|
135
136
|
mark-loaded) team_cmd_mark_loaded "$@" ;;
|