@christang/keel 5.102.1 → 5.104.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 +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +193 -2
- package/src/core/chat/bridge.js +2 -0
- package/src/core/chat/cli.js +68 -8
- package/src/core/chat/notice.js +2 -1
- package/src/core/chat/store.js +125 -1
- package/src/core/chat/view.js +1 -0
package/README.md
CHANGED
|
@@ -709,7 +709,7 @@ Without a known default branch, no issue range is inferred.
|
|
|
709
709
|
|
|
710
710
|
## Group chat between sessions
|
|
711
711
|
|
|
712
|
-
Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
|
|
712
|
+
Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. A record posted with `--ack` asks the roles it addresses to acknowledge it, by `keel chat ack <id>` or a reply, and `keel chat show <id>` and `keel chat acks` list who has acknowledged, who only read it, and who has not read it. `keel chat summary --since <time>` digests what changed in the groups you can read — per sender, the message count, todos opened with whether they are still open, todos closed, superseded records folded into their successors, and acknowledgements still waiting — without a model and without marking anything read. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
|
|
713
713
|
|
|
714
714
|
## Commands
|
|
715
715
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.104.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.104.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.104.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.104.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.104.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.104.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
|
|
@@ -2521,6 +2521,185 @@ def validate_chat_supersedes_scenario() -> int:
|
|
|
2521
2521
|
return 0
|
|
2522
2522
|
|
|
2523
2523
|
|
|
2524
|
+
def validate_chat_ack_scenario() -> int:
|
|
2525
|
+
"""Issue #253: a record asks for an acknowledgement and the sender sees who gave it.
|
|
2526
|
+
|
|
2527
|
+
An acknowledgement is `keel chat ack <id>` or a reply from an addressed
|
|
2528
|
+
role; it marks the record read, wakes nobody, and is refused where it means
|
|
2529
|
+
nothing; `show` and `acks` split the addressed roles three ways.
|
|
2530
|
+
"""
|
|
2531
|
+
label = "chat-ack:"
|
|
2532
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-ack-") as raw:
|
|
2533
|
+
base = Path(raw)
|
|
2534
|
+
rtl, verify, env = chat_scratch_group(base)
|
|
2535
|
+
spec = chat_worktree(rtl, base / "spec")
|
|
2536
|
+
run_keel(spec, "chat", "role", "--set", "spec", env=env)
|
|
2537
|
+
run_keel(rtl, "chat", "group", "add", "soc", "spec", env=env)
|
|
2538
|
+
|
|
2539
|
+
def chat(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
2540
|
+
return run_keel(cwd, "chat", *args, env=env)
|
|
2541
|
+
|
|
2542
|
+
asked = chat_json(chat(rtl, "post", "soc", "@verify @spec rerun R007 on 1b64e8c", "--ack", "--json")).get("id", "")
|
|
2543
|
+
if not asked:
|
|
2544
|
+
report(f"{label} a post with --ack returned no id.")
|
|
2545
|
+
return 1
|
|
2546
|
+
acked = chat(verify, "ack", asked)
|
|
2547
|
+
if acked.returncode != 0:
|
|
2548
|
+
report(f"{label} verify could not acknowledge: {acked.stderr}")
|
|
2549
|
+
return 1
|
|
2550
|
+
view = chat(spec, "soc").stdout
|
|
2551
|
+
if "(ack requested)" not in view:
|
|
2552
|
+
report(f"{label} spec's group view does not mark the record (ack requested): {view!r}")
|
|
2553
|
+
return 1
|
|
2554
|
+
acks = chat_json(chat(rtl, "show", asked, "--json")).get("acks", {})
|
|
2555
|
+
if acks.get("acknowledged") != ["verify"]:
|
|
2556
|
+
report(f"{label} show lists acknowledged {acks.get('acknowledged')!r}, not ['verify'].")
|
|
2557
|
+
return 1
|
|
2558
|
+
if acks.get("readNotAcknowledged") != ["spec"]:
|
|
2559
|
+
report(f"{label} show lists read-not-acknowledged {acks.get('readNotAcknowledged')!r}, not ['spec'].")
|
|
2560
|
+
return 1
|
|
2561
|
+
if acks.get("unread") != []:
|
|
2562
|
+
report(f"{label} show lists unread {acks.get('unread')!r}, not [].")
|
|
2563
|
+
return 1
|
|
2564
|
+
waiting = chat_json(chat(rtl, "acks", "--mine", "--json")).get("records", [])
|
|
2565
|
+
if [r.get("id") for r in waiting] != [asked]:
|
|
2566
|
+
report(f"{label} acks --mine lists {[r.get('id') for r in waiting]!r}, not [{asked}].")
|
|
2567
|
+
return 1
|
|
2568
|
+
rtl_unread = chat_json(chat(rtl, "unread", "--json")).get("unread", [])
|
|
2569
|
+
if rtl_unread:
|
|
2570
|
+
report(f"{label} the acknowledgement left rtl something unread: {rtl_unread!r}")
|
|
2571
|
+
return 1
|
|
2572
|
+
|
|
2573
|
+
chat(spec, "post", "soc", "on it", "--reply-to", asked)
|
|
2574
|
+
acks = chat_json(chat(rtl, "show", asked, "--json")).get("acks", {})
|
|
2575
|
+
if acks.get("acknowledged") != ["spec", "verify"]:
|
|
2576
|
+
report(f"{label} a reply did not acknowledge: acknowledged {acks.get('acknowledged')!r}.")
|
|
2577
|
+
return 1
|
|
2578
|
+
if chat_json(chat(rtl, "acks", "--json")).get("records", []):
|
|
2579
|
+
report(f"{label} a fully acknowledged record is still listed by acks.")
|
|
2580
|
+
return 1
|
|
2581
|
+
|
|
2582
|
+
later = chat_json(chat(rtl, "post", "soc", "@spec check the clock", "--ack", "--json")).get("id", "")
|
|
2583
|
+
notice = chat_json(chat(spec, "notice", "--json")).get("notice", "")
|
|
2584
|
+
if "(ack requested)" not in notice:
|
|
2585
|
+
report(f"{label} spec's wake notice does not mark {later} (ack requested): {notice!r}")
|
|
2586
|
+
return 1
|
|
2587
|
+
plain = chat_json(chat(rtl, "post", "soc", "@spec fyi", "--json")).get("id", "")
|
|
2588
|
+
refusals = [
|
|
2589
|
+
("a record that does not ask", chat(spec, "ack", plain), "does not ask"),
|
|
2590
|
+
("a record that does not address the role", chat(verify, "ack", later), "does not address"),
|
|
2591
|
+
("a record already acknowledged", chat(verify, "ack", asked), "already acknowledged"),
|
|
2592
|
+
("--ack on a record addressing nobody", chat(rtl, "post", "soc", "note to self", "--ack"), "addresses no one"),
|
|
2593
|
+
]
|
|
2594
|
+
for what, result, needle in refusals:
|
|
2595
|
+
if result.returncode == 0:
|
|
2596
|
+
report(f"{label} {what} was accepted: {result.stdout}")
|
|
2597
|
+
return 1
|
|
2598
|
+
if needle not in result.stderr:
|
|
2599
|
+
report(f"{label} {what} was refused without saying {needle!r}: {result.stderr}")
|
|
2600
|
+
return 1
|
|
2601
|
+
|
|
2602
|
+
report("chat-ack scenario passed.")
|
|
2603
|
+
return 0
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
def validate_chat_summary_scenario() -> int:
|
|
2607
|
+
"""Issue #255: `keel chat summary --since` digests what changed, per group and sender.
|
|
2608
|
+
|
|
2609
|
+
Built from the records alone: a superseded record folds into its
|
|
2610
|
+
successor, todos carry open or done, waiting acknowledgements name who
|
|
2611
|
+
has not given one, and no read cursor moves.
|
|
2612
|
+
"""
|
|
2613
|
+
label = "chat-summary:"
|
|
2614
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-summary-") as raw:
|
|
2615
|
+
base = Path(raw)
|
|
2616
|
+
rtl, verify, env = chat_scratch_group(base)
|
|
2617
|
+
loose = chat_worktree(rtl, base / "loose")
|
|
2618
|
+
|
|
2619
|
+
def chat(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
2620
|
+
return run_keel(cwd, "chat", *args, env=env)
|
|
2621
|
+
|
|
2622
|
+
# A record's `created` is stamped to the second, so the time is too.
|
|
2623
|
+
before = datetime.now(timezone.utc).replace(microsecond=0).isoformat()
|
|
2624
|
+
rule = chat_json(chat(rtl, "post", "soc", "rule: rerun on every merge", "--json")).get("id", "")
|
|
2625
|
+
newer = chat_json(chat(rtl, "post", "soc", "rule: rerun nightly", "--supersedes", rule, "--json")).get("id", "")
|
|
2626
|
+
asked = chat_json(chat(rtl, "post", "soc", "@verify confirm R007", "--ack", "--json")).get("id", "")
|
|
2627
|
+
closed = chat_json(chat(rtl, "todo", "soc", "--assignee", "verify", "rerun R007", "--json")).get("id", "")
|
|
2628
|
+
chat(verify, "done", closed)
|
|
2629
|
+
chat(verify, "post", "soc", "R007 is green")
|
|
2630
|
+
still = chat_json(chat(verify, "todo", "soc", "--assignee", "rtl", "review the clock fix", "--json")).get("id", "")
|
|
2631
|
+
if not all((rule, newer, asked, closed, still)):
|
|
2632
|
+
report(f"{label} the fixture could not post every record: {[rule, newer, asked, closed, still]!r}")
|
|
2633
|
+
return 1
|
|
2634
|
+
|
|
2635
|
+
store = Path(chat_json(chat(rtl, "role", "--json")).get("store", ""))
|
|
2636
|
+
cursors = {path: path.read_bytes() for path in (store / "cursors").rglob("*") if path.is_file()}
|
|
2637
|
+
result = chat(rtl, "summary", "--since", before, "--json")
|
|
2638
|
+
if result.returncode != 0:
|
|
2639
|
+
report(f"{label} keel chat summary failed: {result.stdout} {result.stderr}")
|
|
2640
|
+
return 1
|
|
2641
|
+
payload = chat_json(result)
|
|
2642
|
+
after = {path: path.read_bytes() for path in (store / "cursors").rglob("*") if path.is_file()}
|
|
2643
|
+
if after != cursors:
|
|
2644
|
+
report(f"{label} the summary moved a read cursor.")
|
|
2645
|
+
return 1
|
|
2646
|
+
groups = {group.get("group"): group for group in payload.get("groups", [])}
|
|
2647
|
+
if list(groups) != ["soc"]:
|
|
2648
|
+
report(f"{label} the summary lists groups {list(groups)!r}, not ['soc'].")
|
|
2649
|
+
return 1
|
|
2650
|
+
senders = {sender.get("role"): sender for sender in groups["soc"].get("senders", [])}
|
|
2651
|
+
if list(senders) != ["rtl", "verify"]:
|
|
2652
|
+
report(f"{label} the senders are {list(senders)!r}, not ['rtl', 'verify'] in role order.")
|
|
2653
|
+
return 1
|
|
2654
|
+
r, v = senders["rtl"], senders["verify"]
|
|
2655
|
+
expected = [
|
|
2656
|
+
("rtl's message count, the superseded rule folded", r.get("messages"), 2),
|
|
2657
|
+
("rtl's todo, closed", [(t.get("id"), t.get("assignee"), t.get("state")) for t in r.get("todosOpened", [])], [(closed, "verify", "done")]),
|
|
2658
|
+
("rtl's superseding record", [(x.get("id"), x.get("supersedes")) for x in r.get("supersedes", [])], [(newer, rule)]),
|
|
2659
|
+
("verify's message count", v.get("messages"), 1),
|
|
2660
|
+
("verify's todo, open", [(t.get("id"), t.get("assignee"), t.get("state")) for t in v.get("todosOpened", [])], [(still, "rtl", "open")]),
|
|
2661
|
+
("verify's closed todo", [t.get("id") for t in v.get("todosClosed", [])], [closed]),
|
|
2662
|
+
("the waiting acknowledgement", [(a.get("id"), a.get("waiting")) for a in payload.get("waitingAcks", [])], [(asked, ["verify"])]),
|
|
2663
|
+
]
|
|
2664
|
+
for what, got, want in expected:
|
|
2665
|
+
if got != want:
|
|
2666
|
+
report(f"{label} {what} is {got!r}, not {want!r}.")
|
|
2667
|
+
return 1
|
|
2668
|
+
if rule in json.dumps(payload).replace(f'"supersedes": "{rule}"', ""):
|
|
2669
|
+
report(f"{label} the superseded rule {rule} is listed on its own.")
|
|
2670
|
+
return 1
|
|
2671
|
+
text = chat(rtl, "summary", "--since", before)
|
|
2672
|
+
if text.returncode != 0:
|
|
2673
|
+
report(f"{label} the text summary failed: {text.stderr!r}")
|
|
2674
|
+
return 1
|
|
2675
|
+
if f"{newer} superseded {rule}" not in text.stdout:
|
|
2676
|
+
report(f"{label} the text summary does not name the superseding record: {text.stdout!r}")
|
|
2677
|
+
return 1
|
|
2678
|
+
|
|
2679
|
+
quiet = chat(rtl, "summary", "--since", "2999-01-01")
|
|
2680
|
+
if quiet.returncode != 0:
|
|
2681
|
+
report(f"{label} a time after the last record exited {quiet.returncode}: {quiet.stderr!r}")
|
|
2682
|
+
return 1
|
|
2683
|
+
if "nothing changed" not in quiet.stdout:
|
|
2684
|
+
report(f"{label} a time after the last record did not say nothing changed: {quiet.stdout!r}")
|
|
2685
|
+
return 1
|
|
2686
|
+
refusals = [
|
|
2687
|
+
("a summary without --since", chat(rtl, "summary"), "--since"),
|
|
2688
|
+
("an unreadable --since", chat(rtl, "summary", "--since", "yesterdayish"), "--since"),
|
|
2689
|
+
("a worktree with no role", chat(loose, "summary", "--since", "1d"), "keel chat role --set"),
|
|
2690
|
+
]
|
|
2691
|
+
for what, refused, needle in refusals:
|
|
2692
|
+
if refused.returncode == 0:
|
|
2693
|
+
report(f"{label} {what} was accepted: {refused.stdout}")
|
|
2694
|
+
return 1
|
|
2695
|
+
if needle not in refused.stderr:
|
|
2696
|
+
report(f"{label} {what} was refused without naming {needle!r}: {refused.stderr}")
|
|
2697
|
+
return 1
|
|
2698
|
+
|
|
2699
|
+
report("chat-summary scenario passed.")
|
|
2700
|
+
return 0
|
|
2701
|
+
|
|
2702
|
+
|
|
2524
2703
|
def validate_chat_records_scenario() -> int:
|
|
2525
2704
|
"""Issue #187: todos, edits, retractions, search, and local-time display.
|
|
2526
2705
|
|
|
@@ -3191,6 +3370,8 @@ def validate_chat_bridge_outbound_scenario() -> int:
|
|
|
3191
3370
|
chat(rtl, "edit", root_id, "Clock fix is in (v2)")
|
|
3192
3371
|
gone_id = chat_json(chat(rtl, "post", "soc", "wrong group", "--json")).get("id", "")
|
|
3193
3372
|
chat(rtl, "retract", gone_id)
|
|
3373
|
+
asked_id = chat_json(chat(rtl, "post", "soc", "@verify confirm the clock", "--ack", "--json")).get("id", "")
|
|
3374
|
+
ack_id = chat_json(chat(verify, "ack", asked_id, "--json")).get("id", "")
|
|
3194
3375
|
old_rule_id = chat_json(chat(rtl, "post", "soc", "verify owns integration", "--json")).get("id", "")
|
|
3195
3376
|
new_rule_id = chat_json(chat(rtl, "post", "soc", "design owns integration", "--supersedes", old_rule_id, "--json")).get("id", "")
|
|
3196
3377
|
slack.rate_limit("chat.postMessage", 1)
|
|
@@ -3276,6 +3457,14 @@ def validate_chat_bridge_outbound_scenario() -> int:
|
|
|
3276
3457
|
if not any(c["params"].get("ts") == gone_ts for c in slack.calls_to("chat.delete")):
|
|
3277
3458
|
report(f"{label} the retraction did not call chat.delete.")
|
|
3278
3459
|
return 1
|
|
3460
|
+
# Issue #253: an acknowledgement stays local.
|
|
3461
|
+
if not ack_id:
|
|
3462
|
+
report(f"{label} the acknowledgement returned no id.")
|
|
3463
|
+
return 1
|
|
3464
|
+
carried = [c for c in slack.calls if ack_id in json.dumps(c.get("params", {}))]
|
|
3465
|
+
if carried:
|
|
3466
|
+
report(f"{label} the acknowledgement {ack_id} reached Slack: {carried!r}")
|
|
3467
|
+
return 1
|
|
3279
3468
|
# Issue #252: a superseded record's Slack copy says so.
|
|
3280
3469
|
if not new_rule_id:
|
|
3281
3470
|
report(f"{label} the superseding post returned no id.")
|
|
@@ -37991,6 +38180,8 @@ SCENARIOS: tuple = (
|
|
|
37991
38180
|
("shift-without-role", validate_shift_without_role_scenario),
|
|
37992
38181
|
("resource-lock", validate_resource_lock_scenario),
|
|
37993
38182
|
("chat-supersedes", validate_chat_supersedes_scenario),
|
|
38183
|
+
("chat-ack", validate_chat_ack_scenario),
|
|
38184
|
+
("chat-summary", validate_chat_summary_scenario),
|
|
37994
38185
|
("worktree-overview", validate_worktree_overview_scenario),
|
|
37995
38186
|
("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
|
|
37996
38187
|
("native-plugin-marketplaces", validate_native_plugin_marketplaces_scenario),
|
package/src/core/chat/bridge.js
CHANGED
|
@@ -311,6 +311,8 @@ function pendingOutbound(project) {
|
|
|
311
311
|
for (const [group, channel] of Object.entries(settings.channels)) {
|
|
312
312
|
for (const record of store.readLog(where, group)) {
|
|
313
313
|
if (!OUTBOUND_ORIGINS.has(record.origin || "local")) continue;
|
|
314
|
+
// An acknowledgement stays local (#253 D3): Slack shows the reply, if any.
|
|
315
|
+
if (record.kind === "ack") continue;
|
|
314
316
|
if (readPosted(where, record.id)) continue;
|
|
315
317
|
pending.push({ record, channel });
|
|
316
318
|
}
|
package/src/core/chat/cli.js
CHANGED
|
@@ -20,7 +20,10 @@ const USAGE = [
|
|
|
20
20
|
"keel chat group add|remove <group> <role>",
|
|
21
21
|
"keel chat group archive <group>",
|
|
22
22
|
"keel chat group list [--all] [--json] (also: keel chat list)",
|
|
23
|
-
"keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--json] (also: keel chat <group> <text...>)",
|
|
23
|
+
"keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--ack] [--json] (also: keel chat <group> <text...>)",
|
|
24
|
+
"keel chat ack <id> acknowledge a record that asks (a reply also counts)",
|
|
25
|
+
"keel chat acks [--mine] [--json] records still waiting on an acknowledgement",
|
|
26
|
+
"keel chat summary --since <90s|15m|2h|3d|date> [--group <group>] [--json] (what changed, per group and sender; reads without marking read)",
|
|
24
27
|
"keel chat dm <role> <text...> [--json]",
|
|
25
28
|
"keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
|
|
26
29
|
"keel chat unread [--json]",
|
|
@@ -66,10 +69,10 @@ const VALUED = {
|
|
|
66
69
|
"--compact-at": "compactAt",
|
|
67
70
|
};
|
|
68
71
|
const REPEATED = { "--member": "members" };
|
|
69
|
-
const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check" };
|
|
72
|
+
const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check", "--ack": "ack" };
|
|
70
73
|
|
|
71
74
|
function parseChatArgs(argv) {
|
|
72
|
-
const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false };
|
|
75
|
+
const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false, ack: false };
|
|
73
76
|
for (const key of Object.values(VALUED)) options[key] = null;
|
|
74
77
|
for (let index = 0; index < argv.length; index += 1) {
|
|
75
78
|
const arg = argv[index];
|
|
@@ -120,6 +123,35 @@ function readStdin() {
|
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
125
|
|
|
126
|
+
function ackLines(acks) {
|
|
127
|
+
const list = (roles) => roles.join(", ") || "none";
|
|
128
|
+
return [
|
|
129
|
+
`acknowledged: ${list(acks.acknowledged)}`,
|
|
130
|
+
`read, not acknowledged: ${list(acks.readNotAcknowledged)}`,
|
|
131
|
+
`not read: ${list(acks.unread)}`,
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function summaryLines({ groups, waitingAcks }, sinceText) {
|
|
136
|
+
if (!groups.length && !waitingAcks.length) return [`keel chat: nothing changed since ${sinceText}.`];
|
|
137
|
+
const first = (text) => String(text || "").split("\n")[0];
|
|
138
|
+
const lines = [`Since ${sinceText}:`];
|
|
139
|
+
for (const { group, senders } of groups) {
|
|
140
|
+
lines.push(`${group}:`);
|
|
141
|
+
for (const sender of senders) {
|
|
142
|
+
lines.push(` ${sender.role}: ${sender.messages} message${sender.messages === 1 ? "" : "s"}`);
|
|
143
|
+
for (const t of sender.todosOpened) lines.push(` todo for ${t.assignee} (${t.state}) ${t.id}: ${first(t.text)}`);
|
|
144
|
+
for (const t of sender.todosClosed) lines.push(` closed todo from ${t.from} ${t.id}: ${first(t.text)}`);
|
|
145
|
+
for (const x of sender.supersedes) lines.push(` ${x.id} superseded ${x.supersedes}: ${first(x.text)}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (waitingAcks.length) {
|
|
149
|
+
lines.push("Waiting on an acknowledgement:");
|
|
150
|
+
for (const a of waitingAcks) lines.push(` ${a.group} ${a.id} from ${a.from}, waiting on ${a.waiting.join(", ")}: ${first(a.text)}`);
|
|
151
|
+
}
|
|
152
|
+
return lines;
|
|
153
|
+
}
|
|
154
|
+
|
|
123
155
|
function publicRecord(record) {
|
|
124
156
|
const { refs, ...rest } = record;
|
|
125
157
|
return refs && refs.length ? record : rest;
|
|
@@ -260,7 +292,34 @@ function dispatch(where, options) {
|
|
|
260
292
|
case "post": {
|
|
261
293
|
const [group, ...words] = rest;
|
|
262
294
|
if (!group) throw new ChatError("keel chat post needs a group.");
|
|
263
|
-
postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
|
|
295
|
+
postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo, supersedes: options.supersedes, ack: options.ack }), options.json);
|
|
296
|
+
return 0;
|
|
297
|
+
}
|
|
298
|
+
case "ack": {
|
|
299
|
+
const id = rest[0];
|
|
300
|
+
if (!id) throw new ChatError("keel chat ack needs a record id.");
|
|
301
|
+
const record = store.ack(where, id);
|
|
302
|
+
out(options.json ? JSON.stringify({ id: record.id, target: id }) : `Acknowledged ${id}.`);
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
case "acks": {
|
|
306
|
+
const from = options.mine ? store.requireRole(where) : null;
|
|
307
|
+
const rows = store.openAcks(where, { from });
|
|
308
|
+
if (options.json) out(JSON.stringify({ records: rows.map(({ record, acks }) => ({ ...publicRecord(record), acks })) }));
|
|
309
|
+
else if (!rows.length) out("keel chat: no record is waiting on an acknowledgement.");
|
|
310
|
+
else out(rows.map(({ record, acks }) => [`${record.group} ${formatLine(record)}`, ...ackLines(acks).map((line) => ` ${line}`)].join("\n")).join("\n"));
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
case "summary": {
|
|
314
|
+
if (options.since === null) throw new ChatError("keel chat summary needs --since <90s|15m|2h|3d|date>.");
|
|
315
|
+
const threshold = parseSince(options.since);
|
|
316
|
+
if (threshold === null) throw new ChatError(`--since ${JSON.stringify(options.since)} is not a time; use 90s, 15m, 2h, 3d, or a date.`);
|
|
317
|
+
const role = store.requireRole(where);
|
|
318
|
+
if (options.group !== null) store.checkName(options.group, "Group");
|
|
319
|
+
const digest = store.summary(where, role, threshold, { group: options.group });
|
|
320
|
+
const sinceText = store.isoLocal(new Date(threshold));
|
|
321
|
+
if (options.json) out(JSON.stringify({ since: sinceText, ...digest }));
|
|
322
|
+
else out(summaryLines(digest, sinceText).join("\n"));
|
|
264
323
|
return 0;
|
|
265
324
|
}
|
|
266
325
|
case "dm": {
|
|
@@ -291,15 +350,16 @@ function dispatch(where, options) {
|
|
|
291
350
|
const record = store.findRecord(where, id);
|
|
292
351
|
if (!record) throw new ChatError(`No record ${id}.`);
|
|
293
352
|
const readers = store.readersOf(where, record);
|
|
294
|
-
|
|
295
|
-
|
|
353
|
+
const acks = record.ack === "requested" ? store.ackStatus(where, record) : null;
|
|
354
|
+
if (options.json) out(JSON.stringify({ record: publicRecord(record), readers, ...(acks ? { acks } : {}) }));
|
|
355
|
+
else out([`${record.group} ${formatLine(record)}`, `read by: ${readers.join(", ") || "nobody yet"}`, ...(acks ? ackLines(acks) : [])].join("\n"));
|
|
296
356
|
return 0;
|
|
297
357
|
}
|
|
298
358
|
case "todo": {
|
|
299
359
|
const [group, ...words] = rest;
|
|
300
360
|
if (!group) throw new ChatError("keel chat todo needs a group.");
|
|
301
361
|
if (options.assignee === null) throw new ChatError("keel chat todo needs --assignee <role>.");
|
|
302
|
-
postResult(where, store.todo(where, { group, assignee: options.assignee, issue: options.issue, text: textFrom(words), replyTo: options.replyTo }), options.json);
|
|
362
|
+
postResult(where, store.todo(where, { group, assignee: options.assignee, issue: options.issue, text: textFrom(words), replyTo: options.replyTo, ack: options.ack }), options.json);
|
|
303
363
|
return 0;
|
|
304
364
|
}
|
|
305
365
|
case "todos": {
|
|
@@ -365,7 +425,7 @@ function dispatch(where, options) {
|
|
|
365
425
|
default: {
|
|
366
426
|
// `keel chat <group>` views; `keel chat <group> <text...>` posts.
|
|
367
427
|
if (rest.length) {
|
|
368
|
-
postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
|
|
428
|
+
postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo, supersedes: options.supersedes, ack: options.ack }), options.json);
|
|
369
429
|
return 0;
|
|
370
430
|
}
|
|
371
431
|
return runView(where, command, options);
|
package/src/core/chat/notice.js
CHANGED
|
@@ -39,7 +39,8 @@ function noticeText(where, role, now = Date.now()) {
|
|
|
39
39
|
`keel chat: ${records.length} unread for role \`${role}\`, ${waking.length} addressed to you.`,
|
|
40
40
|
];
|
|
41
41
|
for (const record of waking.slice(0, NOTICE_LIMIT)) {
|
|
42
|
-
|
|
42
|
+
const asks = record.ack === "requested" ? " (ack requested)" : "";
|
|
43
|
+
lines.push(`- ${record.id} in ${record.group} from \`${record.from}\`${asks}, ${relativeAge(record.created, now)}: ${firstLine(record.text)}`);
|
|
43
44
|
}
|
|
44
45
|
if (waking.length > NOTICE_LIMIT) lines.push(`- and ${waking.length - NOTICE_LIMIT} more addressed to you.`);
|
|
45
46
|
if (others.size) {
|
package/src/core/chat/store.js
CHANGED
|
@@ -40,7 +40,7 @@ const DATA_NOTICE =
|
|
|
40
40
|
const READABLE_KINDS = new Set(["message", "todo", "system"]);
|
|
41
41
|
const LIST_FIELDS = new Set(["mentions", "refs"]);
|
|
42
42
|
const FIELD_ORDER = [
|
|
43
|
-
"id", "group", "kind", "from", "created", "mentions", "reply_to", "supersedes",
|
|
43
|
+
"id", "group", "kind", "from", "created", "mentions", "reply_to", "supersedes", "ack",
|
|
44
44
|
"assignee", "issue", "target", "refs", "origin", "slack_channel", "slack_ts",
|
|
45
45
|
];
|
|
46
46
|
|
|
@@ -560,6 +560,12 @@ function post(where, options) {
|
|
|
560
560
|
parent = findRecord(where, options.replyTo);
|
|
561
561
|
}
|
|
562
562
|
if (options.supersedes) checkSupersedes(where, from, group, records, options.supersedes);
|
|
563
|
+
if (options.ack) {
|
|
564
|
+
const draft = { kind: options.kind || "message", from, group, mentions, assignee: options.assignee || null };
|
|
565
|
+
if (!addressedRoles(state, draft).length) {
|
|
566
|
+
throw new ChatError("--ack asks the roles a record addresses, and this one addresses no one: mention a role, assign a todo, or post in a direct group.");
|
|
567
|
+
}
|
|
568
|
+
}
|
|
563
569
|
const record = writeRecord(where, {
|
|
564
570
|
group,
|
|
565
571
|
kind: options.kind || "message",
|
|
@@ -567,6 +573,7 @@ function post(where, options) {
|
|
|
567
573
|
mentions,
|
|
568
574
|
reply_to: options.replyTo || null,
|
|
569
575
|
supersedes: options.supersedes || null,
|
|
576
|
+
ack: options.ack ? ACK_REQUESTED : null,
|
|
570
577
|
assignee: options.assignee || null,
|
|
571
578
|
issue: options.issue || null,
|
|
572
579
|
refs: options.refs || [],
|
|
@@ -607,6 +614,66 @@ function checkSupersedes(where, from, group, records, id) {
|
|
|
607
614
|
}
|
|
608
615
|
}
|
|
609
616
|
|
|
617
|
+
const ACK_REQUESTED = "requested";
|
|
618
|
+
|
|
619
|
+
// The roles a record asks to acknowledge it (#253 D1): the group's other
|
|
620
|
+
// members it would wake, and every other member for `@all`.
|
|
621
|
+
function addressedRoles(state, record) {
|
|
622
|
+
const everyone = (record.mentions || []).includes(ALL);
|
|
623
|
+
return [...state.members]
|
|
624
|
+
.filter((role) => role !== record.from && (everyone || wakes(record, role)))
|
|
625
|
+
.sort();
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// Who of the addressed roles acknowledged — by `keel chat ack` or by replying —
|
|
629
|
+
// who only read the record, and who has not read it (#253 D4).
|
|
630
|
+
function ackStatus(where, record) {
|
|
631
|
+
const { records, state } = loadGroup(where, record.group);
|
|
632
|
+
const addressed = addressedRoles(state, record);
|
|
633
|
+
const given = new Set(records
|
|
634
|
+
.filter((r) => (r.kind === "ack" && r.target === record.id) || (READABLE_KINDS.has(r.kind) && r.reply_to === record.id))
|
|
635
|
+
.map((r) => r.from));
|
|
636
|
+
const readers = new Set(readersOf(where, record));
|
|
637
|
+
return {
|
|
638
|
+
acknowledged: addressed.filter((role) => given.has(role)),
|
|
639
|
+
readNotAcknowledged: addressed.filter((role) => !given.has(role) && readers.has(role)),
|
|
640
|
+
unread: addressed.filter((role) => !given.has(role) && !readers.has(role)),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function ack(where, id) {
|
|
645
|
+
const from = requireRole(where);
|
|
646
|
+
const target = targetFor(where, id, from, ["message", "todo"]);
|
|
647
|
+
if (target.ack !== ACK_REQUESTED) throw new ChatError(`Record ${id} does not ask for an acknowledgement.`);
|
|
648
|
+
const { state } = loadGroup(where, target.group);
|
|
649
|
+
const addressed = addressedRoles(state, target);
|
|
650
|
+
if (!addressed.includes(from)) {
|
|
651
|
+
throw new ChatError(`Record ${id} does not address ${from}; it asks ${addressed.join(", ")}.`);
|
|
652
|
+
}
|
|
653
|
+
if (ackStatus(where, target).acknowledged.includes(from)) {
|
|
654
|
+
throw new ChatError(`${from} already acknowledged ${id}.`);
|
|
655
|
+
}
|
|
656
|
+
const record = writeRecord(where, { group: target.group, kind: "ack", from, target: id });
|
|
657
|
+
advanceCursor(where, from, target.group, id);
|
|
658
|
+
return record;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Records in open groups that ask and still wait on an addressed role.
|
|
662
|
+
function openAcks(where, { from = null } = {}) {
|
|
663
|
+
const result = [];
|
|
664
|
+
for (const group of listGroupNames(where)) {
|
|
665
|
+
const records = readLog(where, group);
|
|
666
|
+
const state = groupState(records);
|
|
667
|
+
if (!state.exists || state.archived) continue;
|
|
668
|
+
for (const record of records) {
|
|
669
|
+
if (record.ack !== ACK_REQUESTED || (from && record.from !== from)) continue;
|
|
670
|
+
const status = ackStatus(where, record);
|
|
671
|
+
if (status.readNotAcknowledged.length || status.unread.length) result.push({ record, acks: status });
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return result;
|
|
675
|
+
}
|
|
676
|
+
|
|
610
677
|
// Ids a later record of the same author supersedes, in one group's log.
|
|
611
678
|
function supersededIds(records) {
|
|
612
679
|
const byId = new Map(records.map((record) => [record.id, record]));
|
|
@@ -722,6 +789,59 @@ function directPost(where, target, text, extra = {}) {
|
|
|
722
789
|
|
|
723
790
|
// --- cursors and receipts -----------------------------------------------------
|
|
724
791
|
|
|
792
|
+
// What changed since a time, per group and sender (#255): built from the
|
|
793
|
+
// records alone, and read without moving any cursor (D4). A superseded record
|
|
794
|
+
// folds into its successor and is not listed on its own (D2).
|
|
795
|
+
function summary(where, role, threshold, { group = null } = {}) {
|
|
796
|
+
const after = (record) => {
|
|
797
|
+
const time = Date.parse(record.created);
|
|
798
|
+
return !Number.isNaN(time) && time >= threshold;
|
|
799
|
+
};
|
|
800
|
+
const groups = [];
|
|
801
|
+
const waitingAcks = [];
|
|
802
|
+
for (const name of group ? [group] : listGroupNames(where)) {
|
|
803
|
+
const records = readLog(where, name);
|
|
804
|
+
const state = groupState(records);
|
|
805
|
+
if (!state.exists || state.archived || !canAct(state, role)) continue;
|
|
806
|
+
const superseded = supersededIds(records);
|
|
807
|
+
const closedBy = new Map(records.filter((r) => r.kind === "done").map((r) => [r.target, r]));
|
|
808
|
+
const byId = new Map(records.map((r) => [r.id, r]));
|
|
809
|
+
const senders = new Map();
|
|
810
|
+
const entry = (from) => {
|
|
811
|
+
if (!senders.has(from)) senders.set(from, { role: from, messages: 0, todosOpened: [], todosClosed: [], supersedes: [] });
|
|
812
|
+
return senders.get(from);
|
|
813
|
+
};
|
|
814
|
+
for (const record of records) {
|
|
815
|
+
if (!after(record) || superseded.has(record.id)) continue;
|
|
816
|
+
if (record.kind === "message") entry(record.from).messages += 1;
|
|
817
|
+
if (record.kind === "todo") {
|
|
818
|
+
entry(record.from).todosOpened.push({
|
|
819
|
+
id: record.id,
|
|
820
|
+
assignee: record.assignee,
|
|
821
|
+
state: closedBy.has(record.id) ? "done" : "open",
|
|
822
|
+
text: record.text,
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
if (record.kind === "done" && byId.get(record.target)?.kind === "todo") {
|
|
826
|
+
const todo = byId.get(record.target);
|
|
827
|
+
entry(record.from).todosClosed.push({ id: todo.id, from: todo.from, text: todo.text });
|
|
828
|
+
}
|
|
829
|
+
if (record.supersedes && READABLE_KINDS.has(record.kind)) {
|
|
830
|
+
entry(record.from).supersedes.push({ id: record.id, supersedes: record.supersedes, text: record.text });
|
|
831
|
+
}
|
|
832
|
+
if (record.ack === ACK_REQUESTED) {
|
|
833
|
+
const status = ackStatus(where, record);
|
|
834
|
+
const waiting = [...status.readNotAcknowledged, ...status.unread].sort();
|
|
835
|
+
if (waiting.length) waitingAcks.push({ id: record.id, group: name, from: record.from, text: record.text, waiting });
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (senders.size) {
|
|
839
|
+
groups.push({ group: name, senders: [...senders.values()].sort((a, b) => (a.role < b.role ? -1 : a.role > b.role ? 1 : 0)) });
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return { groups, waitingAcks };
|
|
843
|
+
}
|
|
844
|
+
|
|
725
845
|
function cursorFile(where, role, group) {
|
|
726
846
|
return path.join(where.root, "cursors", role, group);
|
|
727
847
|
}
|
|
@@ -791,6 +911,10 @@ function readGroups(where, role, group) {
|
|
|
791
911
|
}
|
|
792
912
|
|
|
793
913
|
module.exports = {
|
|
914
|
+
ack,
|
|
915
|
+
summary,
|
|
916
|
+
ackStatus,
|
|
917
|
+
openAcks,
|
|
794
918
|
checkName,
|
|
795
919
|
worktreeSignalPath,
|
|
796
920
|
ALL,
|
package/src/core/chat/view.js
CHANGED
|
@@ -85,6 +85,7 @@ function markers(record) {
|
|
|
85
85
|
if (record.reply_to) parts.push(`↳ ${record.reply_to}`);
|
|
86
86
|
if (record.superseded_by) parts.push(`(superseded by ${record.superseded_by})`);
|
|
87
87
|
if (record.supersedes) parts.push(`(supersedes ${record.supersedes})`);
|
|
88
|
+
if (record.ack === "requested") parts.push("(ack requested)");
|
|
88
89
|
// A mention the text already spells out is not repeated; one written as an
|
|
89
90
|
// alias (`@cb`) still shows the role it resolved to (#196).
|
|
90
91
|
const text = String(record.text || "").toLowerCase();
|