@christang/keel 5.150.0 → 5.151.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.150.0",
3
+ "version": "5.151.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,4 +1,4 @@
1
- <!-- keel:start version=5.150.0 -->
1
+ <!-- keel:start version=5.151.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.150.0",
3
+ "version": "5.151.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.150.0",
9
+ "version": "5.151.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.150.0",
5
+ "version": "5.151.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.150.0",
3
+ "version": "5.151.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.150.0",
3
+ "version": "5.151.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",
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
49
49
  "scripts/validate_plugin.py",
50
50
  ]
51
51
 
52
- PACKAGE_VERSION = "5.150.0"
53
- PROTOCOL_VERSION = "5.150.0"
52
+ PACKAGE_VERSION = "5.151.0"
53
+ PROTOCOL_VERSION = "5.151.0"
54
54
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
55
55
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
56
56
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -2311,7 +2311,8 @@ def validate_chat_core_scenario() -> int:
2311
2311
  report(f"{label} post did not report an id: {first.stdout.strip()} {first.stderr.strip()}")
2312
2312
  return 1
2313
2313
  peek = chat(verify, "soc", "--peek", "--json")
2314
- texts = [(r.get("from"), r.get("text")) for r in chat_json(peek).get("records", [])]
2314
+ # Keel stamps the time by default (#349); the stamp is not the author's text.
2315
+ texts = [(r.get("from"), re.sub(r"^\[\d{2}-\d{2} \d{2}:\d{2}\] ", "", r.get("text") or "")) for r in chat_json(peek).get("records", [])]
2315
2316
  if ("rtl", "Stimulus misreads the spec.") not in texts:
2316
2317
  report(f"{label} the verify worktree did not see rtl's message: {peek.stdout.strip()} {peek.stderr.strip()}")
2317
2318
  return 1
@@ -2681,6 +2682,80 @@ def validate_chat_stamp_help_scenario() -> int:
2681
2682
  return 0
2682
2683
 
2683
2684
 
2685
+ def validate_chat_stamp_default_scenario() -> int:
2686
+ """Issue #349: `post` and `dm` stamp Keel's time by default.
2687
+
2688
+ `--stamp` was opt-in, so replies written without it carried hand-typed
2689
+ times — one said "12:0x" at 12:50. The stamp is now the default, `--no-stamp`
2690
+ opts out, and a text that already opens with a stamp is not stamped twice.
2691
+ """
2692
+ label = "chat-stamp-default:"
2693
+ with tempfile.TemporaryDirectory(prefix="keel-chat-349-") as raw:
2694
+ base = Path(raw)
2695
+ rtl, _verify, env = chat_scratch_group(base)
2696
+
2697
+ def last(group: str) -> tuple[str, str]:
2698
+ record = sorted(chat_log(rtl, group).glob("*.md"))[-1].read_text(encoding="utf-8")
2699
+ created = re.search(r"^created: \d{4}-(\d{2})-(\d{2})T(\d{2}):(\d{2})", record, re.M)
2700
+ month, day, hour, minute = created.groups()
2701
+ return f"[{month}-{day} {hour}:{minute}] ", record.split("\n---\n", 1)[1].strip()
2702
+
2703
+ def chat(*args: str) -> subprocess.CompletedProcess[str]:
2704
+ return run_keel(rtl, "chat", *args, env=env)
2705
+
2706
+ first = chat_json(chat("post", "soc", "R009 done", "--json"))
2707
+ for group, args, text in (
2708
+ ("soc", ("post", "soc", "plain post"), "plain post"),
2709
+ ("soc", ("post", "soc", "--reply-to", first.get("id", ""), "a reply"), "a reply"),
2710
+ ("dm-rtl--verify", ("dm", "verify", "a direct message"), "a direct message"),
2711
+ ):
2712
+ done = chat(*args)
2713
+ if done.returncode != 0:
2714
+ report(f"{label} {' '.join(args)} failed: {done.stderr.strip()}")
2715
+ return 1
2716
+ want, body = last(group)
2717
+ if body != want + text:
2718
+ report(f"{label} {' '.join(args)} without --stamp stored {body!r}, not {want + text!r}")
2719
+ return 1
2720
+ chat("post", "soc", "--no-stamp", "no stamp here")
2721
+ _, body = last("soc")
2722
+ if body != "no stamp here":
2723
+ report(f"{label} --no-stamp stored {body!r}")
2724
+ return 1
2725
+ chat("post", "soc", "[10-19 11:00] already stamped")
2726
+ _, body = last("soc")
2727
+ if body != "[10-19 11:00] already stamped":
2728
+ report(f"{label} a text that opens with a stamp was stamped again: {body!r}")
2729
+ return 1
2730
+ both = chat("post", "soc", "--stamp", "--no-stamp", "x")
2731
+ if both.returncode == 0:
2732
+ report(f"{label} --stamp with --no-stamp was accepted.")
2733
+ return 1
2734
+ # A stamp must not change what the text means (D3).
2735
+ todo = chat_json(chat("todo", "soc", "--assignee", "verify", "rerun R009", "--json")).get("id", "")
2736
+ if not todo:
2737
+ report(f"{label} the todo was not created.")
2738
+ return 1
2739
+ if not any(t.get("id") == todo for t in chat_json(chat("todos", "soc", "--json")).get("todos", [])):
2740
+ report(f"{label} the new todo is not listed open.")
2741
+ return 1
2742
+ chat("post", "soc", "--reply-to", todo, "✅ rerun clean")
2743
+ listed = chat_json(chat("todos", "soc", "--json"))
2744
+ if any(t.get("id") == todo for t in listed.get("todos", [])):
2745
+ report(f"{label} a stamped ✅ reply did not close its todo: {listed!r}")
2746
+ return 1
2747
+ chat("post", "soc", "# Plan\n- one\n- two")
2748
+ want, body = last("soc")
2749
+ if body != want.rstrip() + "\n# Plan\n- one\n- two":
2750
+ report(f"{label} a post opening with a heading was not stamped on its own line: {body!r}")
2751
+ return 1
2752
+ if "chat-stamp-default" not in {name for name, _ in SCENARIOS}:
2753
+ report(f"{label} scenario is not registered.")
2754
+ return 1
2755
+ report("chat-stamp-default scenario passed.")
2756
+ return 0
2757
+
2758
+
2684
2759
  def validate_patrol_rearm_scenario() -> int:
2685
2760
  """Issue #260: the patrolling role is reminded to re-arm its schedule.
2686
2761
 
@@ -41551,6 +41626,7 @@ SCENARIOS: tuple = (
41551
41626
  "chat-stamp-help",
41552
41627
  validate_chat_stamp_help_scenario,
41553
41628
  ),
41629
+ ("chat-stamp-default", validate_chat_stamp_default_scenario),
41554
41630
  (
41555
41631
  "chat-human-view",
41556
41632
  validate_chat_human_view_scenario,
@@ -21,13 +21,13 @@ const USAGE = [
21
21
  "keel chat group add|remove <group> <role> [--listen] (--listen: receives the group, may ack and close its todos, does not post)",
22
22
  "keel chat group archive <group>",
23
23
  "keel chat group list [--all] [--json] (also: keel chat list)",
24
- "keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--ack] [--stamp] [--not-a-loop <why>] [--json] (also: keel chat <group> <text...>)",
24
+ "keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--ack] [--no-stamp] [--not-a-loop <why>] [--json] (also: keel chat <group> <text...>; Keel stamps the time unless --no-stamp)",
25
25
  "keel chat ack <id> acknowledge a record that asks (a reply also counts)",
26
26
  "keel chat acks [--mine] [--json] records still waiting on an acknowledgement",
27
27
  "keel chat summary --since <90s|15m|2h|3d|date> [--group <group>] [--json] (what changed, per group and sender; reads without marking read)",
28
28
  "keel chat wait <group> --commit <sha> [--remote <name>] [note...] (or --issue <n> --closed: what this role waits for; keel patrol tells it when it holds)",
29
29
  "keel chat waits [--json] waits not yet met",
30
- "keel chat dm <role> <text...> [--stamp] [--not-a-loop <why>] [--json]",
30
+ "keel chat dm <role> <text...> [--no-stamp] [--not-a-loop <why>] [--json]",
31
31
  "keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
32
32
  "keel chat unread [--json]",
33
33
  "keel chat read [<group>] [--json]",
@@ -78,10 +78,10 @@ const VALUED = {
78
78
  "--compact-at": "compactAt",
79
79
  };
80
80
  const REPEATED = { "--member": "members" };
81
- const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check", "--ack": "ack", "--listen": "listen", "--closed": "closed", "--stamp": "stamp", "--help": "help", "-h": "help", "--prune": "prune" };
81
+ const SWITCHES = { "--json": "json", "--peek": "peek", "--all": "all", "--mine": "mine", "--follow": "follow", "--once": "once", "--mail": "mail", "--check": "check", "--ack": "ack", "--listen": "listen", "--closed": "closed", "--stamp": "stamp", "--no-stamp": "noStamp", "--help": "help", "-h": "help", "--prune": "prune" };
82
82
 
83
83
  function parseChatArgs(argv) {
84
- const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false, ack: false, listen: false, closed: false, stamp: false, help: false, prune: false };
84
+ const options = { positionals: [], members: [], json: false, peek: false, all: false, mine: false, follow: false, once: false, mail: false, check: false, ack: false, listen: false, closed: false, stamp: false, noStamp: false, help: false, prune: false };
85
85
  for (const key of Object.values(VALUED)) options[key] = null;
86
86
  for (let index = 0; index < argv.length; index += 1) {
87
87
  const arg = argv[index];
@@ -119,11 +119,20 @@ function parseChatArgs(argv) {
119
119
  return options;
120
120
  }
121
121
 
122
- // `--stamp` (#298 D3): the time comes from Keel's clock, never the author's estimate.
122
+ // The time comes from Keel's clock, never the author's estimate (#298 D3).
123
+ // It is the default since replies without `--stamp` carried hand-typed times
124
+ // (#349); `--no-stamp` opts out, and a text that already opens with a stamp
125
+ // is left as it is.
126
+ const OPENING_STAMP = /^\[\d{2}-\d{2} \d{2}:\d{2}\]/;
127
+ const MARKDOWN_BLOCK = /^(?:#{1,6}\s|[-*+]\s|>|```|\d+[.)]\s|\|)/;
128
+
123
129
  function stamped(text, options) {
124
- if (!options.stamp || !String(text || "").trim()) return text;
130
+ if (options.stamp && options.noStamp) throw new ChatError("--stamp and --no-stamp cannot both be given.");
131
+ if (options.noStamp || !String(text || "").trim() || OPENING_STAMP.test(String(text).trimStart())) return text;
125
132
  const now = store.isoLocal(new Date());
126
- return `[${now.slice(5, 10)} ${now.slice(11, 16)}] ${text}`;
133
+ const stamp = `[${now.slice(5, 10)} ${now.slice(11, 16)}]`;
134
+ // A first line that opens a Markdown block keeps its line start (#349 D3).
135
+ return MARKDOWN_BLOCK.test(String(text).trimStart()) ? `${stamp}\n${String(text).trimStart()}` : `${stamp} ${text}`;
127
136
  }
128
137
 
129
138
  function out(text) {
@@ -624,7 +624,8 @@ function post(where, options) {
624
624
  return record;
625
625
  }
626
626
 
627
- const DONE_REPLY = /^\s*(done\b|✅)/i;
627
+ // A Keel stamp may open the reply (#349): `[10-19 11:00] ✅` still closes.
628
+ const DONE_REPLY = /^\s*(?:\[\d{2}-\d{2} \d{2}:\d{2}\]\s*)?(done\b|✅)/i;
628
629
 
629
630
  // A record supersedes only its author's current version of a message or todo
630
631
  // in the same group (#252 D1), so the chain stays linear and readable.