@christang/keel 5.112.1 → 5.113.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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.113.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.113.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.113.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.113.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.113.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.113.0"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -5439,6 +5439,138 @@ def validate_resource_lock_scenario() -> int:
|
|
|
5439
5439
|
return 0
|
|
5440
5440
|
|
|
5441
5441
|
|
|
5442
|
+
def shift_scratch(base: Path) -> tuple[Path, Path, dict, Path]:
|
|
5443
|
+
"""`rtl` and `verify` worktrees pushed to a bare remote, for shift scenarios."""
|
|
5444
|
+
rtl, verify, env = chat_scratch_group(base)
|
|
5445
|
+
remote = base / "remote.git"
|
|
5446
|
+
subprocess.run(["git", "init", "-q", "--bare", str(remote)], check=True, capture_output=True)
|
|
5447
|
+
subprocess.run(["git", "remote", "add", "origin", str(remote)], cwd=rtl, check=True, capture_output=True)
|
|
5448
|
+
for tree in (rtl, verify):
|
|
5449
|
+
subprocess.run(["git", "push", "-q", "-u", "origin", "HEAD"], cwd=tree, check=True, capture_output=True)
|
|
5450
|
+
return rtl, verify, env, remote
|
|
5451
|
+
|
|
5452
|
+
|
|
5453
|
+
def validate_shift_role_elsewhere_scenario() -> int:
|
|
5454
|
+
"""Issues #290, #291: a note filed under the role from another worktree.
|
|
5455
|
+
|
|
5456
|
+
`ready --role` files it under the role; an unbound worktree refuses to
|
|
5457
|
+
misfile while role requests are open; status names what works for a
|
|
5458
|
+
worktree note.
|
|
5459
|
+
"""
|
|
5460
|
+
label = "shift-role-elsewhere:"
|
|
5461
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-elsewhere-") as raw:
|
|
5462
|
+
base = Path(raw)
|
|
5463
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
5464
|
+
loose = chat_worktree(rtl, base / "loose")
|
|
5465
|
+
loose2 = chat_worktree(rtl, base / "loose2")
|
|
5466
|
+
for tree in (loose, loose2):
|
|
5467
|
+
subprocess.run(["git", "push", "-q", "-u", "origin", "HEAD"], cwd=tree, check=True, capture_output=True)
|
|
5468
|
+
|
|
5469
|
+
def shift(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
5470
|
+
return run_keel(cwd, "shift", *args, env=env)
|
|
5471
|
+
|
|
5472
|
+
shift(rtl, "request", "verify")
|
|
5473
|
+
common = mailbox_common_dir(rtl) / "keel-chat" / "shift"
|
|
5474
|
+
misfiled = shift(loose, "ready", "worked on R008 here")
|
|
5475
|
+
if misfiled.returncode == 0:
|
|
5476
|
+
report(f"{label} ready in an unbound worktree with verify's request open was accepted.")
|
|
5477
|
+
return 1
|
|
5478
|
+
if "--role verify" not in misfiled.stderr:
|
|
5479
|
+
report(f"{label} the refusal does not name --role verify: {misfiled.stderr}")
|
|
5480
|
+
return 1
|
|
5481
|
+
if list((common / "worktree").glob("*.md")) if (common / "worktree").exists() else []:
|
|
5482
|
+
report(f"{label} a refused ready still wrote a worktree note.")
|
|
5483
|
+
return 1
|
|
5484
|
+
wrong = shift(loose, "ready", "--role", "rtl", "x")
|
|
5485
|
+
if wrong.returncode == 0:
|
|
5486
|
+
report(f"{label} ready --role rtl, which has no open request, was accepted.")
|
|
5487
|
+
return 1
|
|
5488
|
+
filed = shift(loose, "ready", "--role", "verify", "worked on R008 in loose")
|
|
5489
|
+
if filed.returncode != 0:
|
|
5490
|
+
report(f"{label} ready --role verify failed: {filed.stdout} {filed.stderr}")
|
|
5491
|
+
return 1
|
|
5492
|
+
if not (common / "verify.md").exists():
|
|
5493
|
+
report(f"{label} ready --role verify did not file the note under verify.")
|
|
5494
|
+
return 1
|
|
5495
|
+
started = shift(rtl, "start", "verify")
|
|
5496
|
+
if started.returncode != 0:
|
|
5497
|
+
report(f"{label} keel shift start verify was refused: {started.stderr}")
|
|
5498
|
+
return 1
|
|
5499
|
+
lone = shift(loose2, "ready", "nothing requested here")
|
|
5500
|
+
if lone.returncode != 0:
|
|
5501
|
+
report(f"{label} ready in an unbound worktree with no open request failed: {lone.stderr}")
|
|
5502
|
+
return 1
|
|
5503
|
+
status = shift(rtl, "status").stdout
|
|
5504
|
+
line = next((l for l in status.splitlines() if "loose2" in l), "")
|
|
5505
|
+
if str(loose2.resolve()) not in line or "keel shift resume" not in line:
|
|
5506
|
+
report(f"{label} the worktree note's status line does not name its path and keel shift resume: {line!r}")
|
|
5507
|
+
return 1
|
|
5508
|
+
if "keel shift start worktree" in status:
|
|
5509
|
+
report(f"{label} status still suggests keel shift start for a worktree note: {status!r}")
|
|
5510
|
+
return 1
|
|
5511
|
+
report("shift-role-elsewhere scenario passed.")
|
|
5512
|
+
return 0
|
|
5513
|
+
|
|
5514
|
+
|
|
5515
|
+
def validate_shift_coordinator_last_scenario() -> int:
|
|
5516
|
+
"""Issue #289: the coordinator starts the others before its own shift ends.
|
|
5517
|
+
|
|
5518
|
+
Its check reports a waiting, unstarted note and its ready is refused until
|
|
5519
|
+
it starts that role; a successor's resume lists who still waits; the
|
|
5520
|
+
request and ready name session state a clear destroys.
|
|
5521
|
+
"""
|
|
5522
|
+
label = "shift-coordinator-last:"
|
|
5523
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-coordinator-") as raw:
|
|
5524
|
+
base = Path(raw)
|
|
5525
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
5526
|
+
|
|
5527
|
+
def shift(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
5528
|
+
return run_keel(cwd, "shift", *args, env=env)
|
|
5529
|
+
|
|
5530
|
+
shift(rtl, "request", "verify")
|
|
5531
|
+
request_text = "\n".join(chat_records_with(rtl, "dm-rtl--verify", "Shift change requested"))
|
|
5532
|
+
if "scheduled jobs" not in request_text:
|
|
5533
|
+
report(f"{label} the request does not name scheduled jobs: {request_text!r}")
|
|
5534
|
+
return 1
|
|
5535
|
+
readied = shift(verify, "ready", "verify note")
|
|
5536
|
+
if readied.returncode != 0:
|
|
5537
|
+
report(f"{label} verify's ready failed: {readied.stderr}")
|
|
5538
|
+
return 1
|
|
5539
|
+
if "scheduled jobs" not in readied.stdout:
|
|
5540
|
+
report(f"{label} ready's output does not name scheduled jobs: {readied.stdout!r}")
|
|
5541
|
+
return 1
|
|
5542
|
+
checked = shift(rtl, "check", "--json")
|
|
5543
|
+
items = json.loads(checked.stdout).get("items", [])
|
|
5544
|
+
if checked.returncode != 1:
|
|
5545
|
+
report(f"{label} rtl's check exited {checked.returncode} with verify unstarted, not 1.")
|
|
5546
|
+
return 1
|
|
5547
|
+
if not any(i.get("kind") == "unstarted" and "verify" in i.get("detail", "") for i in items):
|
|
5548
|
+
report(f"{label} rtl's check has no unstarted item for verify: {items!r}")
|
|
5549
|
+
return 1
|
|
5550
|
+
if shift(rtl, "ready", "rtl note").returncode == 0:
|
|
5551
|
+
report(f"{label} rtl's ready was accepted with verify unstarted.")
|
|
5552
|
+
return 1
|
|
5553
|
+
shift(rtl, "start", "verify")
|
|
5554
|
+
after = json.loads(shift(rtl, "check", "--json").stdout).get("items", [])
|
|
5555
|
+
if any(i.get("kind") == "unstarted" for i in after):
|
|
5556
|
+
report(f"{label} rtl's check still reports unstarted after start: {after!r}")
|
|
5557
|
+
return 1
|
|
5558
|
+
|
|
5559
|
+
shift(verify, "resume")
|
|
5560
|
+
shift(rtl, "request", "verify")
|
|
5561
|
+
shift(verify, "ready", "verify note, second round")
|
|
5562
|
+
forced = shift(rtl, "ready", "--force-reason", "user is away", "rtl note")
|
|
5563
|
+
if forced.returncode != 0:
|
|
5564
|
+
report(f"{label} rtl's ready --force-reason failed: {forced.stderr}")
|
|
5565
|
+
return 1
|
|
5566
|
+
resumed = shift(rtl, "resume")
|
|
5567
|
+
if "verify" not in resumed.stdout or "keel shift start" not in resumed.stdout:
|
|
5568
|
+
report(f"{label} rtl's resume does not list verify as waiting for keel shift start: {resumed.stdout!r}")
|
|
5569
|
+
return 1
|
|
5570
|
+
report("shift-coordinator-last scenario passed.")
|
|
5571
|
+
return 0
|
|
5572
|
+
|
|
5573
|
+
|
|
5442
5574
|
def validate_shift_change_scenario() -> int:
|
|
5443
5575
|
"""Owner's decision of 2026-10-05: a role's session changes shift through Keel.
|
|
5444
5576
|
|
|
@@ -39051,6 +39183,8 @@ SCENARIOS: tuple = (
|
|
|
39051
39183
|
("context-names-the-protocol-refresh", validate_context_names_the_protocol_refresh_scenario),
|
|
39052
39184
|
("collected-feedback-is-recorded", validate_collected_feedback_is_recorded_scenario),
|
|
39053
39185
|
("shift-change", validate_shift_change_scenario),
|
|
39186
|
+
("shift-role-elsewhere", validate_shift_role_elsewhere_scenario),
|
|
39187
|
+
("shift-coordinator-last", validate_shift_coordinator_last_scenario),
|
|
39054
39188
|
("shift-without-role", validate_shift_without_role_scenario),
|
|
39055
39189
|
("resource-lock", validate_resource_lock_scenario),
|
|
39056
39190
|
("chat-supersedes", validate_chat_supersedes_scenario),
|
package/src/core/shift.js
CHANGED
|
@@ -23,6 +23,7 @@ const USAGE = [
|
|
|
23
23
|
"keel shift request <role> [text] ask a role to change shift (wakes it)",
|
|
24
24
|
"keel shift check [--json] readiness check of this worktree; exit 1 if anything is loose",
|
|
25
25
|
"keel shift ready [text | --file f] store the shift note, close the request (refused while loose)",
|
|
26
|
+
" [--role r] ...under role r, from a worktree bound to no role (#290)",
|
|
26
27
|
" [--force-reason r] ...or state why the loose ends may stay",
|
|
27
28
|
"keel shift start <role> [text] wake the cleared role to resume (once its note waits)",
|
|
28
29
|
"keel shift resume [--json] print and consume this role's note",
|
|
@@ -201,6 +202,14 @@ function check(where, role) {
|
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
if (role) {
|
|
205
|
+
// A coordinator does not leave notes waiting unstarted (#289 D1): once it
|
|
206
|
+
// clears, nobody is left to start them.
|
|
207
|
+
for (const waiting of unstarted(where, role)) {
|
|
208
|
+
items.push({
|
|
209
|
+
kind: "unstarted",
|
|
210
|
+
detail: `${waiting.role}: note waiting since ${waiting.since}; run \`keel shift start ${waiting.role}\` before your own shift ends`,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
204
213
|
for (const todo of store.openTodos(where, { assignee: role })) {
|
|
205
214
|
if (isShift(todo)) continue;
|
|
206
215
|
items.push({ kind: "open-todo", detail: `${todo.id} in ${todo.group}: ${firstLine(todo.text)}` });
|
|
@@ -216,6 +225,36 @@ function check(where, role) {
|
|
|
216
225
|
return { ready: items.length === 0, worktree: where.worktree, role: role || null, items, notes };
|
|
217
226
|
}
|
|
218
227
|
|
|
228
|
+
// The UTC millisecond a chat record id was written at (`20261012T093944609Z-…`).
|
|
229
|
+
function idTime(id) {
|
|
230
|
+
const m = String(id || "").match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z/);
|
|
231
|
+
return m ? Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +m[6], +m[7]) : 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Roles whose note waits, whose latest shift request came from `coordinator`,
|
|
235
|
+
// and that `coordinator` has not started since the note was written.
|
|
236
|
+
function unstarted(where, coordinator) {
|
|
237
|
+
const result = [];
|
|
238
|
+
for (const file of safeList(shiftDir(where))) {
|
|
239
|
+
if (!file.endsWith(".md")) continue;
|
|
240
|
+
const role = file.slice(0, -3);
|
|
241
|
+
if (role === coordinator || !/^[a-z0-9][a-z0-9-]{0,31}$/.test(role)) continue;
|
|
242
|
+
const requests = shiftRequests(where, role);
|
|
243
|
+
const latest = requests[requests.length - 1];
|
|
244
|
+
if (!latest || latest.from !== coordinator) continue;
|
|
245
|
+
const written = fs.statSync(path.join(shiftDir(where), file)).mtime;
|
|
246
|
+
// A record's id carries its UTC time to the millisecond; `created` only to
|
|
247
|
+
// the second, which lets a start from the previous round read as later
|
|
248
|
+
// than a note written in the same second.
|
|
249
|
+
const started = store.readLog(where, store.directName(coordinator, role)).some(
|
|
250
|
+
(record) => record.from === coordinator && record.kind === "message" && isShift(record)
|
|
251
|
+
&& /your new shift starts now/.test(record.text || "") && idTime(record.id) > written.getTime()
|
|
252
|
+
);
|
|
253
|
+
if (!started) result.push({ role, since: store.isoLocal(written) });
|
|
254
|
+
}
|
|
255
|
+
return result.sort((a, b) => (a.role < b.role ? -1 : 1));
|
|
256
|
+
}
|
|
257
|
+
|
|
219
258
|
function firstLine(text) {
|
|
220
259
|
const line = String(text || "").split("\n")[0];
|
|
221
260
|
return line.length > 100 ? `${line.slice(0, 100)}…` : line;
|
|
@@ -265,8 +304,9 @@ function request(where, role, text) {
|
|
|
265
304
|
`Shift change requested by ${from}. Wrap up, then hand over:`,
|
|
266
305
|
"1. `keel shift check` until it reports ready (or decide what may stay).",
|
|
267
306
|
"2. Put follow-ups where the project tracks them, and update long-lived memory you own.",
|
|
268
|
-
"3.
|
|
269
|
-
"4.
|
|
307
|
+
"3. Note in the shift note any session state a clear destroys and Keel cannot see — scheduled jobs, Remote Control — so the next shift can re-create it.",
|
|
308
|
+
"4. `keel shift ready \"<what you were doing, next step, what you wait on, where>\"`.",
|
|
309
|
+
"5. Clear this session as `keel shift ready` says.",
|
|
270
310
|
text ? `\n${text}` : "",
|
|
271
311
|
].join("\n").trim();
|
|
272
312
|
return store.todo(where, { group, assignee: role, text: body, refs: [REF] });
|
|
@@ -292,8 +332,37 @@ function readNoteText(options) {
|
|
|
292
332
|
return "";
|
|
293
333
|
}
|
|
294
334
|
|
|
335
|
+
// The role a note is filed under (#290 D4, D5): the worktree's, or `--role`
|
|
336
|
+
// when this worktree has none and that role has an open request. An unbound
|
|
337
|
+
// worktree refuses to file under itself while role requests are open, since
|
|
338
|
+
// such a note would answer none of them.
|
|
339
|
+
function readyRole(where, options) {
|
|
340
|
+
const bound = store.currentRole(where);
|
|
341
|
+
if (options.role) {
|
|
342
|
+
store.checkName(options.role, "Role");
|
|
343
|
+
if (bound && bound !== options.role) {
|
|
344
|
+
throw new ShiftError(`This worktree is bound to role ${bound}; --role ${options.role} names another role.`);
|
|
345
|
+
}
|
|
346
|
+
if (!shiftRequests(where, options.role).some((r) => r.open)) {
|
|
347
|
+
throw new ShiftError(`--role ${options.role}: no shift change is requested of ${options.role}, so there is no request for this note to answer.`);
|
|
348
|
+
}
|
|
349
|
+
return options.role;
|
|
350
|
+
}
|
|
351
|
+
if (!bound) {
|
|
352
|
+
const open = [...new Set(shiftRequests(where).filter((r) => r.open).map((r) => r.assignee))].sort();
|
|
353
|
+
if (open.length) {
|
|
354
|
+
throw new ShiftError(
|
|
355
|
+
`This worktree has no chat role, and shift changes are requested of ${open.join(", ")}. `
|
|
356
|
+
+ `If this session is one of them, run ${open.map((r) => `\`keel shift ready --role ${r} …\``).join(" or ")}; `
|
|
357
|
+
+ "a note filed under this worktree would answer none of the requests."
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return bound;
|
|
362
|
+
}
|
|
363
|
+
|
|
295
364
|
function ready(where, options) {
|
|
296
|
-
const role =
|
|
365
|
+
const role = readyRole(where, options);
|
|
297
366
|
const result = check(where, role);
|
|
298
367
|
if (!result.ready && !options.forceReason) {
|
|
299
368
|
throw new ShiftError(`${renderCheck(result)}\nResolve these, or give --force-reason "<why they may stay>".`);
|
|
@@ -312,13 +381,16 @@ function ready(where, options) {
|
|
|
312
381
|
writeFileAtomic(note, `${head}\n${text}\n`);
|
|
313
382
|
// Requests are chat records; without a role there is none to close (D2).
|
|
314
383
|
const open = role ? shiftRequests(where, role).filter((r) => r.open) : [];
|
|
384
|
+
const doneText = (todo) => `done — ${role} is ready for the shift change; the note waits for \`keel shift resume\`.${options.forceReason ? ` Left as is: ${options.forceReason}.` : ""}`;
|
|
315
385
|
for (const todo of open) {
|
|
316
|
-
store.
|
|
317
|
-
group: todo.group,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
386
|
+
if (store.currentRole(where) === role) {
|
|
387
|
+
store.post(where, { group: todo.group, replyTo: todo.id, refs: [REF], text: doneText(todo) });
|
|
388
|
+
} else {
|
|
389
|
+
// Filed with --role from a worktree bound to no role (#290 D4): the
|
|
390
|
+
// reply and the closing record are the role's own.
|
|
391
|
+
store.writeRecord(where, { group: todo.group, kind: "message", from: role, reply_to: todo.id, refs: [REF], text: doneText(todo) });
|
|
392
|
+
store.writeRecord(where, { group: todo.group, kind: "done", from: role, target: todo.id });
|
|
393
|
+
}
|
|
322
394
|
}
|
|
323
395
|
return { role: role || null, note, closed: open.map((todo) => todo.id) };
|
|
324
396
|
}
|
|
@@ -357,7 +429,7 @@ function resume(where) {
|
|
|
357
429
|
const group = directGroup(where, role, latest.from);
|
|
358
430
|
told = store.post(where, { group, text: `${role} is on shift, resumed from its shift note.`, refs: [REF] }).id;
|
|
359
431
|
}
|
|
360
|
-
return { role, note: history, text, told };
|
|
432
|
+
return { role, note: history, text, told, waiting: role ? unstarted(where, role) : [] };
|
|
361
433
|
}
|
|
362
434
|
|
|
363
435
|
function status(where) {
|
|
@@ -370,13 +442,28 @@ function status(where) {
|
|
|
370
442
|
entry(todo.assignee).request = { id: todo.id, from: todo.from, created: todo.created, open: todo.open };
|
|
371
443
|
}
|
|
372
444
|
const dir = shiftDir(where);
|
|
445
|
+
const worktreeNotes = [];
|
|
373
446
|
for (const [folder, prefix] of [[dir, ""], [path.join(dir, "worktree"), "worktree "]]) {
|
|
374
447
|
for (const file of safeList(folder)) {
|
|
375
448
|
if (!file.endsWith(".md")) continue;
|
|
376
449
|
const stat = fs.statSync(path.join(folder, file));
|
|
377
|
-
entry(`${prefix}${file.slice(0, -3)}`)
|
|
450
|
+
const row = entry(`${prefix}${file.slice(0, -3)}`);
|
|
451
|
+
row.note = store.isoLocal(stat.mtime);
|
|
452
|
+
if (prefix) {
|
|
453
|
+
// The note's header names the worktree it was written in (#291 D6).
|
|
454
|
+
const header = fs.readFileSync(path.join(folder, file), "utf8").match(/^Written \S+ in (.+)\.$/m);
|
|
455
|
+
row.path = header ? header[1] : null;
|
|
456
|
+
worktreeNotes.push({ name: file.slice(0, -3), written: stat.mtime.getTime() });
|
|
457
|
+
}
|
|
378
458
|
}
|
|
379
459
|
}
|
|
460
|
+
// A role still requested may have handed over from another worktree (#290 D6).
|
|
461
|
+
for (const row of roles.values()) {
|
|
462
|
+
if (row.note || !row.request || !row.request.open) continue;
|
|
463
|
+
const since = Date.parse(row.request.created);
|
|
464
|
+
const later = worktreeNotes.filter((n) => !Number.isNaN(since) && n.written >= since).map((n) => n.name);
|
|
465
|
+
if (later.length) row.worktreeNotesSince = later;
|
|
466
|
+
}
|
|
380
467
|
for (const file of safeList(path.join(dir, "history"))) {
|
|
381
468
|
const match = file.match(/^(.+)-(\d{4}-\d{2}-\d{2}T\d+)\.md$/);
|
|
382
469
|
if (!match) continue;
|
|
@@ -395,8 +482,16 @@ function safeList(dir) {
|
|
|
395
482
|
}
|
|
396
483
|
|
|
397
484
|
function describe(row) {
|
|
485
|
+
if (row.note && row.role.startsWith("worktree ")) {
|
|
486
|
+
return `${row.role}: note waiting since ${row.note}; no chat role there, so tell the session in ${row.path || "that worktree"} to run \`keel shift resume\``;
|
|
487
|
+
}
|
|
398
488
|
if (row.note) return `${row.role}: note waiting since ${row.note}; \`keel shift start ${row.role}\` wakes it to resume`;
|
|
399
|
-
if (row.request && row.request.open)
|
|
489
|
+
if (row.request && row.request.open) {
|
|
490
|
+
const elsewhere = row.worktreeNotesSince
|
|
491
|
+
? `; a worktree note was written since (${row.worktreeNotesSince.join(", ")}) — if it is ${row.role}'s, file it with \`keel shift ready --role ${row.role}\``
|
|
492
|
+
: "";
|
|
493
|
+
return `${row.role}: change requested by ${row.request.from} at ${row.request.created}; not ready yet${elsewhere}`;
|
|
494
|
+
}
|
|
400
495
|
if (row.resumed) return `${row.role}: on shift, resumed ${row.resumed}`;
|
|
401
496
|
return `${row.role}: ready was recorded without a note`;
|
|
402
497
|
}
|
|
@@ -404,6 +499,7 @@ function describe(row) {
|
|
|
404
499
|
// --- the command line --------------------------------------------------------------
|
|
405
500
|
|
|
406
501
|
const CLEAR_HINT = [
|
|
502
|
+
"Session state a clear destroys — scheduled jobs, Remote Control — is not in Keel; if the note does not say how to re-create it, add that first.",
|
|
407
503
|
"Now clear this session:",
|
|
408
504
|
"- Claude desktop app: call `clear_session(\"self\")` (the owner approves it), or type /clear;",
|
|
409
505
|
"- Claude Code CLI: /clear;",
|
|
@@ -412,13 +508,14 @@ const CLEAR_HINT = [
|
|
|
412
508
|
].join("\n");
|
|
413
509
|
|
|
414
510
|
function runShift(argv) {
|
|
415
|
-
const options = { json: false, repo: process.cwd(), positionals: [], file: null, forceReason: null };
|
|
511
|
+
const options = { json: false, repo: process.cwd(), positionals: [], file: null, forceReason: null, role: null };
|
|
416
512
|
for (let index = 0; index < argv.length; index += 1) {
|
|
417
513
|
const arg = argv[index];
|
|
418
514
|
if (arg === "--json") options.json = true;
|
|
419
515
|
else if (arg === "--repo") options.repo = argv[++index] || "";
|
|
420
516
|
else if (arg === "--file") options.file = argv[++index] || "";
|
|
421
517
|
else if (arg === "--force-reason") options.forceReason = argv[++index] || "";
|
|
518
|
+
else if (arg === "--role") options.role = argv[++index] || "";
|
|
422
519
|
else if (arg === "--help" || arg === "-h") {
|
|
423
520
|
process.stdout.write(`${USAGE}\n`);
|
|
424
521
|
return 0;
|
|
@@ -463,7 +560,10 @@ function runShift(argv) {
|
|
|
463
560
|
const patrol = readPatrolDeclaration(where.worktree);
|
|
464
561
|
const remind = patrol.role && result.role === patrol.role;
|
|
465
562
|
if (remind) result.patrol = { role: patrol.role, every: patrol.every };
|
|
466
|
-
|
|
563
|
+
// A new coordinator learns whom its previous shift left unstarted (#289 D2).
|
|
564
|
+
const waiting = (result.waiting || []).map((w) => w.role);
|
|
565
|
+
const still = waiting.length ? `\n\nStill waiting for \`keel shift start\`: ${waiting.join(", ")}.` : "";
|
|
566
|
+
out(result, `${result.text.replace(/\s+$/, "")}\n\n(The note moved to ${result.note}.)${still}${remind ? `\n\n${patrolReminder(patrol)}` : ""}`);
|
|
467
567
|
return 0;
|
|
468
568
|
}
|
|
469
569
|
case "status": {
|