@christang/keel 5.149.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +4 -3
- 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 +150 -14
- package/src/core/chat/cli.js +16 -7
- package/src/core/chat/store.js +2 -1
- package/src/core/patrol.js +11 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
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",
|
package/README.md
CHANGED
|
@@ -842,15 +842,16 @@ keel patrol --issues /tmp/issues.json # as the coordinator's role
|
|
|
842
842
|
as met and sends the waiting role one direct message, which wakes it. It lists every role's
|
|
843
843
|
presence, last activity, and open todos, marking those idle beyond `--idle` (default `30m`). It
|
|
844
844
|
fetches nothing, schedules nothing, calls no model, and writes nothing when nothing is new; it exits
|
|
845
|
-
0 then, 2 when
|
|
846
|
-
|
|
845
|
+
0 then, 2 when the coordinator has something to act on — a risk, or its own wait met — 3 when it only
|
|
846
|
+
recorded something or told other roles, and 1 on an error, so a cheap scheduler — cron, `/loop`, CI —
|
|
847
|
+
can wake the model only on 2 (#350). `keel chat waits` lists what is still awaited.
|
|
847
848
|
|
|
848
849
|
A patrol on an hourly schedule should report change, not state, or it wakes the coordinator every
|
|
849
850
|
hour for a note deliberately left parked (#295). `keel patrol --since-last` keeps a snapshot per role
|
|
850
851
|
— shift status, the remote default branch tip, the main checkout's uncommitted paths, each role's
|
|
851
852
|
idleness and open todos, and the coordinator's addressed records unread beyond `--idle` — and prints
|
|
852
853
|
only `changed:` lines for what differs from the previous run; the first run records a baseline. It
|
|
853
|
-
writes that snapshot on every run, and exits 2 only when
|
|
854
|
+
writes that snapshot on every run, and exits 3 when something changed and 2 only when a risk did. Add `--notify` and the
|
|
854
855
|
coordinator gets one direct message from `keel-patrol`, which wakes its session, carrying only risks
|
|
855
856
|
(#307): the shared checkout gaining uncommitted paths after a clean run, free disk the host reports with
|
|
856
857
|
`--disk-free-gb` dropping below `--disk-min-gb` (default 20), and a role that left two nudges in a row
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
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.
|
|
9
|
+
"version": "5.151.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.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.
|
|
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.
|
|
53
|
-
PROTOCOL_VERSION = "5.
|
|
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
|
-
|
|
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
|
|
|
@@ -2858,7 +2933,7 @@ def validate_patrol_since_last_scenario() -> int:
|
|
|
2858
2933
|
for args in (["commit", "-q", "--allow-empty", "-m", "landed"], ["push", "-q", "origin", "HEAD"]):
|
|
2859
2934
|
subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
|
|
2860
2935
|
second = patrol("--since-last", "--notify")
|
|
2861
|
-
if second.returncode !=
|
|
2936
|
+
if second.returncode != 3:
|
|
2862
2937
|
report(f"{label} the run after a change exited {second.returncode}: {second.stdout!r} {second.stderr!r}")
|
|
2863
2938
|
return 1
|
|
2864
2939
|
changed = [line for line in second.stdout.splitlines() if line.startswith("changed:")]
|
|
@@ -2886,6 +2961,65 @@ def validate_patrol_since_last_scenario() -> int:
|
|
|
2886
2961
|
return 0
|
|
2887
2962
|
|
|
2888
2963
|
|
|
2964
|
+
def validate_patrol_exit_says_who_acts_scenario() -> int:
|
|
2965
|
+
"""Issue #350: `keel patrol` exited 2 on pure state changes too.
|
|
2966
|
+
|
|
2967
|
+
A coordinator's schedule wakes its model on exit 2, so a run that only
|
|
2968
|
+
moved state or told other roles cost a model turn for nothing. Exit 2 now
|
|
2969
|
+
means the coordinator has something to act on — a risk, or its own wait
|
|
2970
|
+
met — and exit 3 means patrol recorded or delivered something for others.
|
|
2971
|
+
"""
|
|
2972
|
+
label = "patrol-exit-says-who-acts:"
|
|
2973
|
+
with tempfile.TemporaryDirectory(prefix="keel-patrol-350-") as raw:
|
|
2974
|
+
base = Path(raw)
|
|
2975
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
2976
|
+
|
|
2977
|
+
def patrol(*args: str) -> subprocess.CompletedProcess[str]:
|
|
2978
|
+
return run_keel(rtl, "patrol", *args, env=env)
|
|
2979
|
+
|
|
2980
|
+
def push() -> str:
|
|
2981
|
+
for args in (["commit", "-q", "--allow-empty", "-m", "landed"], ["push", "-q", "origin", "HEAD"]):
|
|
2982
|
+
subprocess.run(["git", *args], cwd=rtl, check=True, capture_output=True)
|
|
2983
|
+
return subprocess.run(["git", "rev-parse", "HEAD"], cwd=rtl, text=True, capture_output=True, check=True).stdout.strip()
|
|
2984
|
+
|
|
2985
|
+
if patrol("--since-last", "--notify").returncode != 0:
|
|
2986
|
+
report(f"{label} the baseline run did not exit 0.")
|
|
2987
|
+
return 1
|
|
2988
|
+
push()
|
|
2989
|
+
moved = patrol("--since-last", "--notify")
|
|
2990
|
+
if moved.returncode != 3:
|
|
2991
|
+
report(f"{label} a run whose only news is the remote tip exited {moved.returncode}, not 3: {moved.stdout!r}")
|
|
2992
|
+
return 1
|
|
2993
|
+
(rtl / "stray.txt").write_text("x\n")
|
|
2994
|
+
risky = patrol("--since-last", "--notify")
|
|
2995
|
+
if risky.returncode != 2:
|
|
2996
|
+
report(f"{label} a run that found a risk exited {risky.returncode}, not 2: {risky.stdout!r}")
|
|
2997
|
+
return 1
|
|
2998
|
+
(rtl / "stray.txt").unlink()
|
|
2999
|
+
|
|
3000
|
+
sha = push()
|
|
3001
|
+
run_keel(verify, "chat", "wait", "soc", "--commit", sha, "rerun when it lands", env=env)
|
|
3002
|
+
theirs = patrol()
|
|
3003
|
+
if theirs.returncode != 3:
|
|
3004
|
+
report(f"{label} a run that met another role's wait exited {theirs.returncode}, not 3: {theirs.stdout!r}")
|
|
3005
|
+
return 1
|
|
3006
|
+
sha = push()
|
|
3007
|
+
run_keel(rtl, "chat", "wait", "soc", "--commit", sha, "merge the next slice", env=env)
|
|
3008
|
+
mine = patrol()
|
|
3009
|
+
if mine.returncode != 2:
|
|
3010
|
+
report(f"{label} a run that met the coordinator's own wait exited {mine.returncode}, not 2: {mine.stdout!r}")
|
|
3011
|
+
return 1
|
|
3012
|
+
helped = run_keel(rtl, "patrol", "--help", env=env)
|
|
3013
|
+
if "3:" not in helped.stdout:
|
|
3014
|
+
report(f"{label} --help does not document exit 3: {helped.stdout!r}")
|
|
3015
|
+
return 1
|
|
3016
|
+
if "patrol-exit-says-who-acts" not in {name for name, _ in SCENARIOS}:
|
|
3017
|
+
report(f"{label} scenario is not registered.")
|
|
3018
|
+
return 1
|
|
3019
|
+
report("patrol-exit-says-who-acts scenario passed.")
|
|
3020
|
+
return 0
|
|
3021
|
+
|
|
3022
|
+
|
|
2889
3023
|
def validate_patrol_nudge_scenario() -> int:
|
|
2890
3024
|
"""Issues #307 part 1 and #313: the patrol nudges idle roles directly.
|
|
2891
3025
|
|
|
@@ -2929,8 +3063,8 @@ def validate_patrol_nudge_scenario() -> int:
|
|
|
2929
3063
|
if any(line.startswith("nudged lint") for line in nudged(first)):
|
|
2930
3064
|
report(f"{label} lint was nudged before any task closed: {nudged(first)!r}")
|
|
2931
3065
|
return 1
|
|
2932
|
-
if first.returncode !=
|
|
2933
|
-
report(f"{label} a run that nudged exited {first.returncode}.")
|
|
3066
|
+
if first.returncode != 3:
|
|
3067
|
+
report(f"{label} a run that nudged exited {first.returncode}, not 3.")
|
|
2934
3068
|
return 1
|
|
2935
3069
|
if run_keel(verify, "chat", "notice", "--check", env=env).returncode != 0:
|
|
2936
3070
|
report(f"{label} the nudge does not wake verify.")
|
|
@@ -3168,8 +3302,8 @@ def validate_coordinator_patrol_scenario() -> int:
|
|
|
3168
3302
|
|
|
3169
3303
|
subprocess.run(["git", "push", "-q", "origin", "feature"], cwd=rtl, check=True, capture_output=True)
|
|
3170
3304
|
landed = patrol()
|
|
3171
|
-
if landed.returncode !=
|
|
3172
|
-
report(f"{label} patrol after the push exited {landed.returncode}, not
|
|
3305
|
+
if landed.returncode != 3:
|
|
3306
|
+
report(f"{label} patrol after the push exited {landed.returncode}, not 3: {landed.stdout} {landed.stderr}")
|
|
3173
3307
|
return 1
|
|
3174
3308
|
if chat_json(chat(rtl, "waits", "--json")).get("waits"):
|
|
3175
3309
|
report(f"{label} the met wait is still listed.")
|
|
@@ -3198,8 +3332,8 @@ def validate_coordinator_patrol_scenario() -> int:
|
|
|
3198
3332
|
issues = base / "issues.json"
|
|
3199
3333
|
issues.write_text(json.dumps([{"number": 42, "title": "clock fix", "state": "CLOSED", "labels": [], "updatedAt": "2026-10-11T00:00:00Z"}]), encoding="utf-8")
|
|
3200
3334
|
closed = patrol("--issues", str(issues))
|
|
3201
|
-
if closed.returncode !=
|
|
3202
|
-
report(f"{label} patrol with issue 42 closed exited {closed.returncode}, not
|
|
3335
|
+
if closed.returncode != 3:
|
|
3336
|
+
report(f"{label} patrol with issue 42 closed exited {closed.returncode}, not 3: {closed.stdout} {closed.stderr}")
|
|
3203
3337
|
return 1
|
|
3204
3338
|
report("coordinator-patrol scenario passed.")
|
|
3205
3339
|
return 0
|
|
@@ -3229,8 +3363,8 @@ def validate_patrol_issue_routing_scenario() -> int:
|
|
|
3229
3363
|
return [r.get("text", "") for r in chat_json(run_keel(verify, "chat", "unread", "--json", env=env)).get("unread", []) if "#157" in r.get("text", "")]
|
|
3230
3364
|
|
|
3231
3365
|
first = patrol("2026-10-11T01:00:00Z")
|
|
3232
|
-
if first.returncode !=
|
|
3233
|
-
report(f"{label} the first patrol exited {first.returncode}, not
|
|
3366
|
+
if first.returncode != 3:
|
|
3367
|
+
report(f"{label} the first patrol exited {first.returncode}, not 3: {first.stdout} {first.stderr}")
|
|
3234
3368
|
return 1
|
|
3235
3369
|
if len(notices()) != 1:
|
|
3236
3370
|
report(f"{label} verify has {len(notices())} notices about #157, not 1.")
|
|
@@ -3247,8 +3381,8 @@ def validate_patrol_issue_routing_scenario() -> int:
|
|
|
3247
3381
|
report(f"{label} the same update was sent again.")
|
|
3248
3382
|
return 1
|
|
3249
3383
|
later = patrol("2026-10-11T02:00:00Z")
|
|
3250
|
-
if later.returncode !=
|
|
3251
|
-
report(f"{label} a later update exited {later.returncode}, not
|
|
3384
|
+
if later.returncode != 3:
|
|
3385
|
+
report(f"{label} a later update exited {later.returncode}, not 3.")
|
|
3252
3386
|
return 1
|
|
3253
3387
|
if len(notices()) != 2:
|
|
3254
3388
|
report(f"{label} a later update left {len(notices())} notices, not 2.")
|
|
@@ -41492,6 +41626,7 @@ SCENARIOS: tuple = (
|
|
|
41492
41626
|
"chat-stamp-help",
|
|
41493
41627
|
validate_chat_stamp_help_scenario,
|
|
41494
41628
|
),
|
|
41629
|
+
("chat-stamp-default", validate_chat_stamp_default_scenario),
|
|
41495
41630
|
(
|
|
41496
41631
|
"chat-human-view",
|
|
41497
41632
|
validate_chat_human_view_scenario,
|
|
@@ -41845,6 +41980,7 @@ SCENARIOS: tuple = (
|
|
|
41845
41980
|
("chat-ack", validate_chat_ack_scenario),
|
|
41846
41981
|
("coordinator-patrol", validate_coordinator_patrol_scenario),
|
|
41847
41982
|
("patrol-since-last", validate_patrol_since_last_scenario),
|
|
41983
|
+
("patrol-exit-says-who-acts", validate_patrol_exit_says_who_acts_scenario),
|
|
41848
41984
|
("patrol-nudge", validate_patrol_nudge_scenario),
|
|
41849
41985
|
("patrol-escalate", validate_patrol_escalate_scenario),
|
|
41850
41986
|
("patrol-quota", validate_patrol_quota_scenario),
|
package/src/core/chat/cli.js
CHANGED
|
@@ -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
|
-
//
|
|
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 (
|
|
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
|
-
|
|
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) {
|
package/src/core/chat/store.js
CHANGED
|
@@ -624,7 +624,8 @@ function post(where, options) {
|
|
|
624
624
|
return record;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
|
|
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.
|
package/src/core/patrol.js
CHANGED
|
@@ -14,9 +14,14 @@ const { parseSince } = require("./chat/view");
|
|
|
14
14
|
|
|
15
15
|
const USAGE = "keel patrol [--issues <file>] [--idle <90s|15m|2h|3d>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>]\n keel patrol task [--json] [--repo <path>] print the host scheduled task for `patrol:`";
|
|
16
16
|
const NOTIFY_SENDER = "keel-patrol";
|
|
17
|
+
// 2 asks the coordinator to act — a risk, or a wait of its own now met — and
|
|
18
|
+
// 3 says patrol recorded or delivered something only other roles need: a
|
|
19
|
+
// coordinator's schedule wakes its model on 2, so a run that merely moved
|
|
20
|
+
// state no longer costs a turn (#350).
|
|
17
21
|
const EXIT_QUIET = 0;
|
|
18
22
|
const EXIT_ERROR = 1;
|
|
19
|
-
const
|
|
23
|
+
const EXIT_ACT = 2;
|
|
24
|
+
const EXIT_RECORDED = 3;
|
|
20
25
|
|
|
21
26
|
class PatrolError extends Error {}
|
|
22
27
|
|
|
@@ -402,7 +407,7 @@ function hostTask(where) {
|
|
|
402
407
|
"",
|
|
403
408
|
`1. Run \`git -C ${at} fetch -q origin\`. If it fails, keep its error and continue.`,
|
|
404
409
|
`2. Run \`keel patrol --repo ${at} --since-last --notify\`.`,
|
|
405
|
-
`3. Exit 0: nothing changed. Exit 2: keel has already told ${role}. In
|
|
410
|
+
`3. Exit 0: nothing changed. Exit 2: keel has already told ${role} what to act on. Exit 3: keel recorded or told other roles only. In these cases end without output. `
|
|
406
411
|
+ "Exit 1: end with one line, `keel patrol failed: <its error output>`, adding the fetch error from step 1 if there was one.",
|
|
407
412
|
].join("\n");
|
|
408
413
|
return {
|
|
@@ -465,7 +470,7 @@ function runPatrol(argv) {
|
|
|
465
470
|
else if (arg === "--quota-alerts") options.quotaAlerts = String(argv[++index] || "").split(",").map(Number);
|
|
466
471
|
else if (arg === "--quota-quiet-at") options.quotaQuietAt = Number(argv[++index]);
|
|
467
472
|
else if (arg === "--help" || arg === "-h") {
|
|
468
|
-
process.stdout.write(`${USAGE}\nExit 0: wrote nothing. 2:
|
|
473
|
+
process.stdout.write(`${USAGE}\nExit 0: wrote nothing. 2: something for you to act on (a risk, or your own wait met). 3: recorded or told other roles only. 1: error.\n`);
|
|
469
474
|
return EXIT_QUIET;
|
|
470
475
|
} else if (["--repo", "--issues", "--idle"].includes(arg)) {
|
|
471
476
|
const value = argv[++index];
|
|
@@ -504,7 +509,9 @@ function runPatrol(argv) {
|
|
|
504
509
|
}
|
|
505
510
|
process.stdout.write(`${options.json ? JSON.stringify(result, null, 2) : render(result)}\n`);
|
|
506
511
|
const changed = result.sinceLast && result.sinceLast.changes.length;
|
|
507
|
-
const
|
|
512
|
+
const own = result.held.some((held) => held.from === role);
|
|
513
|
+
const recorded = result.notices.length || result.held.length || changed || (result.nudges || []).length;
|
|
514
|
+
const code = result.risks.length || own ? EXIT_ACT : recorded ? EXIT_RECORDED : EXIT_QUIET;
|
|
508
515
|
appendRunLog(where, role, code, result);
|
|
509
516
|
return code;
|
|
510
517
|
} catch (error) {
|