@christang/keel 5.103.0 → 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 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. 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. 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
 
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.103.0 -->
1
+ <!-- keel:start version=5.104.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.103.0",
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.103.0",
9
+ "version": "5.104.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.103.0",
5
+ "version": "5.104.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.103.0",
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.103.0",
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.103.0"
51
- PROTOCOL_VERSION = "5.103.0"
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
@@ -2603,6 +2603,103 @@ def validate_chat_ack_scenario() -> int:
2603
2603
  return 0
2604
2604
 
2605
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
+
2606
2703
  def validate_chat_records_scenario() -> int:
2607
2704
  """Issue #187: todos, edits, retractions, search, and local-time display.
2608
2705
 
@@ -38084,6 +38181,7 @@ SCENARIOS: tuple = (
38084
38181
  ("resource-lock", validate_resource_lock_scenario),
38085
38182
  ("chat-supersedes", validate_chat_supersedes_scenario),
38086
38183
  ("chat-ack", validate_chat_ack_scenario),
38184
+ ("chat-summary", validate_chat_summary_scenario),
38087
38185
  ("worktree-overview", validate_worktree_overview_scenario),
38088
38186
  ("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
38089
38187
  ("native-plugin-marketplaces", validate_native_plugin_marketplaces_scenario),
@@ -23,6 +23,7 @@ const USAGE = [
23
23
  "keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--ack] [--json] (also: keel chat <group> <text...>)",
24
24
  "keel chat ack <id> acknowledge a record that asks (a reply also counts)",
25
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)",
26
27
  "keel chat dm <role> <text...> [--json]",
27
28
  "keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
28
29
  "keel chat unread [--json]",
@@ -131,6 +132,26 @@ function ackLines(acks) {
131
132
  ];
132
133
  }
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
+
134
155
  function publicRecord(record) {
135
156
  const { refs, ...rest } = record;
136
157
  return refs && refs.length ? record : rest;
@@ -289,6 +310,18 @@ function dispatch(where, options) {
289
310
  else out(rows.map(({ record, acks }) => [`${record.group} ${formatLine(record)}`, ...ackLines(acks).map((line) => ` ${line}`)].join("\n")).join("\n"));
290
311
  return 0;
291
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"));
323
+ return 0;
324
+ }
292
325
  case "dm": {
293
326
  const [target, ...words] = rest;
294
327
  if (!target) throw new ChatError("keel chat dm needs a role.");
@@ -789,6 +789,59 @@ function directPost(where, target, text, extra = {}) {
789
789
 
790
790
  // --- cursors and receipts -----------------------------------------------------
791
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
+
792
845
  function cursorFile(where, role, group) {
793
846
  return path.join(where.root, "cursors", role, group);
794
847
  }
@@ -859,6 +912,7 @@ function readGroups(where, role, group) {
859
912
 
860
913
  module.exports = {
861
914
  ack,
915
+ summary,
862
916
  ackStatus,
863
917
  openAcks,
864
918
  checkName,