@christang/keel 5.124.0 → 5.126.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 +4 -4
- 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 +92 -31
- package/src/core/patrol.js +41 -26
- package/src/core/shift.js +12 -3
package/README.md
CHANGED
|
@@ -808,10 +808,10 @@ nudge wakes a large session.
|
|
|
808
808
|
|
|
809
809
|
`keel patrol --nudge` goes further and nudges each idle role itself, with one direct message from
|
|
810
810
|
`keel-patrol` that wakes its session (#307): when records addressed to it have waited longer than
|
|
811
|
-
`--idle` (at most every two hours); when
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
was never resumed. A note filed without `--wake` — a coordinator parking a role — is left alone, and
|
|
811
|
+
`--idle` (at most every two hours); when a todo assigned to it is closed, telling it to change shift
|
|
812
|
+
at that task boundary — with `keel shift ready --wake` if another todo is still open for it, or plain
|
|
813
|
+
`ready` to wait for the coordinator — since a shift follows a finished task and the host compacts
|
|
814
|
+
within one (#313); and when a note it filed with `ready --wake` was never resumed. A note filed without `--wake` — a coordinator parking a role — is left alone, and
|
|
815
815
|
Keel's own messages never count as waiting.
|
|
816
816
|
|
|
817
817
|
With `--issues`, patrol also routes issue updates (#242): `issue_roles:` in `keel/config.yaml`
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.126.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.126.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.126.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.126.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.126.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.126.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
|
|
@@ -2828,11 +2828,12 @@ def validate_patrol_since_last_scenario() -> int:
|
|
|
2828
2828
|
|
|
2829
2829
|
|
|
2830
2830
|
def validate_patrol_nudge_scenario() -> int:
|
|
2831
|
-
"""
|
|
2831
|
+
"""Issues #307 part 1 and #313: the patrol nudges idle roles directly.
|
|
2832
2832
|
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2833
|
+
Addressed unread records nudge once per window; a closed todo nudges a
|
|
2834
|
+
shift change at that task boundary, naming `--wake` only while another
|
|
2835
|
+
todo is open; a self-initiated note nudges a resume; a parked note and
|
|
2836
|
+
the patrol's own messages never do; context is no longer an input.
|
|
2836
2837
|
"""
|
|
2837
2838
|
label = "patrol-nudge:"
|
|
2838
2839
|
with tempfile.TemporaryDirectory(prefix="keel-patrol-nudge-") as raw:
|
|
@@ -2842,6 +2843,12 @@ def validate_patrol_nudge_scenario() -> int:
|
|
|
2842
2843
|
lint = chat_worktree(rtl, base / "lint")
|
|
2843
2844
|
subprocess.run(["git", "push", "-q", "-u", "origin", "HEAD"], cwd=lint, check=True, capture_output=True)
|
|
2844
2845
|
run_keel(lint, "chat", "role", "--set", "lint", env=env)
|
|
2846
|
+
run_keel(rtl, "chat", "group", "add", "soc", "lint", env=env)
|
|
2847
|
+
todo_ids = []
|
|
2848
|
+
for text in ("R009 timing fix", "R010 lint cleanup"):
|
|
2849
|
+
made = run_keel(rtl, "chat", "todo", "soc", "--assignee", "lint", text, "--json", env=env)
|
|
2850
|
+
todo_ids.append(json.loads(made.stdout)["id"])
|
|
2851
|
+
run_keel(lint, "chat", "read", env=env)
|
|
2845
2852
|
run_keel(rtl, "chat", "post", "soc", "@verify please rerun R007", env=env)
|
|
2846
2853
|
time.sleep(1.2)
|
|
2847
2854
|
|
|
@@ -2851,45 +2858,60 @@ def validate_patrol_nudge_scenario() -> int:
|
|
|
2851
2858
|
def nudged(result: subprocess.CompletedProcess[str]) -> list[str]:
|
|
2852
2859
|
return [line for line in result.stdout.splitlines() if line.startswith("nudged ")]
|
|
2853
2860
|
|
|
2861
|
+
def told_lint(needle: str) -> str:
|
|
2862
|
+
return "\n".join(chat_records_with(rtl, "dm-keel-patrol--lint", needle))
|
|
2863
|
+
|
|
2854
2864
|
seen: list[str] = []
|
|
2855
|
-
first = nudge(
|
|
2865
|
+
first = nudge()
|
|
2856
2866
|
seen += nudged(first)
|
|
2857
2867
|
if "nudged verify: unread" not in nudged(first):
|
|
2858
2868
|
report(f"{label} verify was not nudged for unread: {first.stdout!r} {first.stderr!r}")
|
|
2859
2869
|
return 1
|
|
2860
2870
|
if any(line.startswith("nudged lint") for line in nudged(first)):
|
|
2861
|
-
report(f"{label} lint was nudged
|
|
2871
|
+
report(f"{label} lint was nudged before any task closed: {nudged(first)!r}")
|
|
2862
2872
|
return 1
|
|
2863
2873
|
if first.returncode != 2:
|
|
2864
2874
|
report(f"{label} a run that nudged exited {first.returncode}.")
|
|
2865
2875
|
return 1
|
|
2866
|
-
if not chat_records_with(rtl, "dm-keel-patrol--verify", "keel chat unread"):
|
|
2867
|
-
report(f"{label} no keel-patrol record reached verify.")
|
|
2868
|
-
return 1
|
|
2869
2876
|
if run_keel(verify, "chat", "notice", "--check", env=env).returncode != 0:
|
|
2870
2877
|
report(f"{label} the nudge does not wake verify.")
|
|
2871
2878
|
return 1
|
|
2872
|
-
|
|
2879
|
+
run_keel(lint, "chat", "done", todo_ids[0], env=env)
|
|
2880
|
+
time.sleep(1.2)
|
|
2881
|
+
second = nudge()
|
|
2873
2882
|
seen += nudged(second)
|
|
2874
2883
|
if nudged(second) != ["nudged lint: shift"]:
|
|
2875
|
-
report(f"{label}
|
|
2884
|
+
report(f"{label} closing a todo should nudge only lint's shift: {second.stdout!r} {second.stderr!r}")
|
|
2876
2885
|
return 1
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
report(f"{label} the shift nudge does not name keel shift ready --wake: {shift_text!r}")
|
|
2886
|
+
if "keel shift ready --wake" not in told_lint("R009"):
|
|
2887
|
+
report(f"{label} with a todo still open, the shift nudge does not name ready --wake: {told_lint('R009')!r}")
|
|
2880
2888
|
return 1
|
|
2881
|
-
if "Remote Control" not in
|
|
2882
|
-
report(f"{label} the shift nudge does not name Remote Control
|
|
2889
|
+
if "Remote Control" not in told_lint("R009"):
|
|
2890
|
+
report(f"{label} the shift nudge does not name Remote Control.")
|
|
2883
2891
|
return 1
|
|
2884
2892
|
time.sleep(1.2)
|
|
2885
|
-
third = nudge(
|
|
2893
|
+
third = nudge()
|
|
2886
2894
|
seen += nudged(third)
|
|
2887
2895
|
if nudged(third):
|
|
2888
|
-
report(f"{label} a run
|
|
2896
|
+
report(f"{label} a run with nothing new nudged: {nudged(third)!r}")
|
|
2889
2897
|
return 1
|
|
2890
2898
|
if third.returncode != 0:
|
|
2891
2899
|
report(f"{label} a run that nudged nobody exited {third.returncode}.")
|
|
2892
2900
|
return 1
|
|
2901
|
+
run_keel(lint, "chat", "done", todo_ids[1], env=env)
|
|
2902
|
+
time.sleep(1.2)
|
|
2903
|
+
fourth = nudge()
|
|
2904
|
+
seen += nudged(fourth)
|
|
2905
|
+
if "nudged lint: shift" not in nudged(fourth):
|
|
2906
|
+
report(f"{label} closing the last todo did not nudge lint: {fourth.stdout!r}")
|
|
2907
|
+
return 1
|
|
2908
|
+
last = told_lint("R010")
|
|
2909
|
+
if "wait for the coordinator" not in last:
|
|
2910
|
+
report(f"{label} with no todo left, the shift nudge does not say to wait for the coordinator: {last!r}")
|
|
2911
|
+
return 1
|
|
2912
|
+
if "--wake" in last:
|
|
2913
|
+
report(f"{label} with no todo left, the shift nudge still names --wake: {last!r}")
|
|
2914
|
+
return 1
|
|
2893
2915
|
armed = run_keel(lint, "shift", "ready", "--wake", "lint note", env=env)
|
|
2894
2916
|
if armed.returncode != 0:
|
|
2895
2917
|
report(f"{label} lint's ready --wake failed: {armed.stderr}")
|
|
@@ -2898,17 +2920,24 @@ def validate_patrol_nudge_scenario() -> int:
|
|
|
2898
2920
|
report(f"{label} verify's ready failed.")
|
|
2899
2921
|
return 1
|
|
2900
2922
|
time.sleep(1.2)
|
|
2901
|
-
|
|
2902
|
-
seen += nudged(
|
|
2903
|
-
if "nudged lint: resume" not in nudged(
|
|
2904
|
-
report(f"{label} lint's self-initiated note was not nudged to resume: {
|
|
2923
|
+
fifth = nudge()
|
|
2924
|
+
seen += nudged(fifth)
|
|
2925
|
+
if "nudged lint: resume" not in nudged(fifth):
|
|
2926
|
+
report(f"{label} lint's self-initiated note was not nudged to resume: {fifth.stdout!r}")
|
|
2905
2927
|
return 1
|
|
2906
|
-
if "nudged verify: resume" in nudged(
|
|
2928
|
+
if "nudged verify: resume" in nudged(fifth):
|
|
2907
2929
|
report(f"{label} verify's parked note was nudged to resume.")
|
|
2908
2930
|
return 1
|
|
2909
2931
|
if "nudged lint: unread" in seen:
|
|
2910
2932
|
report(f"{label} lint was nudged over the patrol's own message.")
|
|
2911
2933
|
return 1
|
|
2934
|
+
retired = nudge("--context", "lint=62")
|
|
2935
|
+
if retired.returncode != 1:
|
|
2936
|
+
report(f"{label} --context exited {retired.returncode}.")
|
|
2937
|
+
return 1
|
|
2938
|
+
if "retired" not in retired.stderr:
|
|
2939
|
+
report(f"{label} the --context refusal does not say it was retired: {retired.stderr!r}")
|
|
2940
|
+
return 1
|
|
2912
2941
|
report("patrol-nudge scenario passed.")
|
|
2913
2942
|
return 0
|
|
2914
2943
|
|
|
@@ -5934,7 +5963,7 @@ def validate_shift_role_elsewhere_scenario() -> int:
|
|
|
5934
5963
|
if started.returncode != 0:
|
|
5935
5964
|
report(f"{label} keel shift start verify was refused: {started.stderr}")
|
|
5936
5965
|
return 1
|
|
5937
|
-
lone = shift(loose2, "ready", "nothing requested here")
|
|
5966
|
+
lone = shift(loose2, "ready", "--force-reason", "the coordinator opens it", "nothing requested here")
|
|
5938
5967
|
if lone.returncode != 0:
|
|
5939
5968
|
report(f"{label} ready in an unbound worktree with no open request failed: {lone.stderr}")
|
|
5940
5969
|
return 1
|
|
@@ -6771,14 +6800,38 @@ def validate_shift_without_role_scenario() -> int:
|
|
|
6771
6800
|
return chat_json(run_keel(repo, "context", "--json", env=env))
|
|
6772
6801
|
|
|
6773
6802
|
before = context().get("status")
|
|
6774
|
-
|
|
6803
|
+
# Issue #317: nothing wakes the session after a clear here, so plain
|
|
6804
|
+
# `ready` is refused and points to a role and --wake.
|
|
6805
|
+
plain = run_keel(repo, "shift", "ready", "next: rerun R007", env=env)
|
|
6806
|
+
if plain.returncode != 1:
|
|
6807
|
+
report(f"{label} plain ready in a worktree without a chat role exited {plain.returncode}, not 1: {plain.stdout.strip()}")
|
|
6808
|
+
return 1
|
|
6809
|
+
if "keel chat role --set" not in plain.stderr:
|
|
6810
|
+
report(f"{label} the refusal does not name `keel chat role --set`: {plain.stderr.strip()}")
|
|
6811
|
+
return 1
|
|
6812
|
+
if "--wake" not in plain.stderr:
|
|
6813
|
+
report(f"{label} the refusal does not name --wake: {plain.stderr.strip()}")
|
|
6814
|
+
return 1
|
|
6815
|
+
if list((common / "shift" / "worktree").glob("*.md")):
|
|
6816
|
+
report(f"{label} the refused ready stored a worktree note.")
|
|
6817
|
+
return 1
|
|
6818
|
+
ready = run_keel(repo, "shift", "ready", "--force-reason", "the owner opens it", "next: rerun R007", env=env)
|
|
6775
6819
|
if ready.returncode != 0:
|
|
6776
|
-
report(f"{label} keel shift ready refused in a worktree without a chat role: {ready.stderr.strip()}")
|
|
6820
|
+
report(f"{label} keel shift ready --force-reason refused in a worktree without a chat role: {ready.stderr.strip()}")
|
|
6821
|
+
return 1
|
|
6822
|
+
if "the owner opens it" not in ready.stdout:
|
|
6823
|
+
report(f"{label} the clear hint does not name who starts the new session: {ready.stdout.strip()}")
|
|
6777
6824
|
return 1
|
|
6778
6825
|
notes = list((common / "shift" / "worktree").glob("*.md"))
|
|
6779
6826
|
if len(notes) != 1:
|
|
6780
6827
|
report(f"{label} ready kept {len(notes)} worktree notes under keel-chat/shift/worktree/, not one.")
|
|
6781
6828
|
return 1
|
|
6829
|
+
if "Started by hand: the owner opens it" not in notes[0].read_text(encoding="utf-8"):
|
|
6830
|
+
report(f"{label} the note does not record who starts the new session.")
|
|
6831
|
+
return 1
|
|
6832
|
+
if "Left as is" in notes[0].read_text(encoding="utf-8"):
|
|
6833
|
+
report(f"{label} the note lists loose ends left as is when the check found none.")
|
|
6834
|
+
return 1
|
|
6782
6835
|
text = run_keel(repo, "context", env=env).stdout
|
|
6783
6836
|
if "keel shift resume" not in text:
|
|
6784
6837
|
report(f"{label} keel context does not point to the waiting note: {text.strip()}")
|
|
@@ -6809,7 +6862,7 @@ def validate_shift_without_role_scenario() -> int:
|
|
|
6809
6862
|
|
|
6810
6863
|
# Issue #261: `--file -` is stdin, and an unreadable file is a named refusal.
|
|
6811
6864
|
missing = base / "missing-note.md"
|
|
6812
|
-
refused = run_keel(repo, "shift", "ready", "--file", str(missing), env=env)
|
|
6865
|
+
refused = run_keel(repo, "shift", "ready", "--force-reason", "the owner opens it", "--file", str(missing), env=env)
|
|
6813
6866
|
if re.search(r"^\s+at ", refused.stderr, re.M):
|
|
6814
6867
|
report(f"{label} an unreadable --file escaped as an uncaught exception: {refused.stderr.strip()}")
|
|
6815
6868
|
return 1
|
|
@@ -6823,7 +6876,7 @@ def validate_shift_without_role_scenario() -> int:
|
|
|
6823
6876
|
report(f"{label} the refusal of an unreadable --file does not name the path: {refused.stderr.strip()}")
|
|
6824
6877
|
return 1
|
|
6825
6878
|
piped = subprocess.run(
|
|
6826
|
-
["node", str(ROOT / "bin" / "keel.js"), "shift", "ready", "--file", "-"],
|
|
6879
|
+
["node", str(ROOT / "bin" / "keel.js"), "shift", "ready", "--force-reason", "the owner opens it", "--file", "-"],
|
|
6827
6880
|
cwd=repo, env=env, input="next: from stdin via --file -\n",
|
|
6828
6881
|
text=True, encoding="utf-8", errors="replace", capture_output=True, check=False,
|
|
6829
6882
|
)
|
|
@@ -6839,9 +6892,17 @@ def validate_shift_without_role_scenario() -> int:
|
|
|
6839
6892
|
return 1
|
|
6840
6893
|
|
|
6841
6894
|
for relative, needle in (("docs/shift-change.md", "no chat role"), ("docs/shift-change.zh-CN.md", "不绑定聊天角色")):
|
|
6842
|
-
|
|
6895
|
+
text = (ROOT / relative).read_text(encoding="utf-8")
|
|
6896
|
+
if needle not in text:
|
|
6843
6897
|
report(f"{label} {relative} does not say a chat role is optional ({needle!r}).")
|
|
6844
6898
|
return 1
|
|
6899
|
+
intro = text.split("## ", 1)[0]
|
|
6900
|
+
if "--wake" not in intro:
|
|
6901
|
+
report(f"{label} {relative} does not say an unbound self-shift needs --wake.")
|
|
6902
|
+
return 1
|
|
6903
|
+
if "--force-reason" not in intro:
|
|
6904
|
+
report(f"{label} {relative} does not say --force-reason files an unbound self-shift by hand.")
|
|
6905
|
+
return 1
|
|
6845
6906
|
if "shift-without-role" not in {name for name, _ in SCENARIOS}:
|
|
6846
6907
|
report(f"{label} scenario is not registered.")
|
|
6847
6908
|
return 1
|
package/src/core/patrol.js
CHANGED
|
@@ -12,7 +12,7 @@ const store = require("./chat/store");
|
|
|
12
12
|
const notice = require("./chat/notice");
|
|
13
13
|
const { parseSince } = require("./chat/view");
|
|
14
14
|
|
|
15
|
-
const USAGE = "keel patrol [--issues <file>] [--idle <90s|15m|2h|3d>] [--since-last [--notify]] [--nudge
|
|
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
17
|
const EXIT_QUIET = 0;
|
|
18
18
|
const EXIT_ERROR = 1;
|
|
@@ -204,19 +204,8 @@ function sinceLast(where, role, result, options) {
|
|
|
204
204
|
|
|
205
205
|
const KEEL_SENDERS = new Set([NOTIFY_SENDER, "keel-shift", "keel"]);
|
|
206
206
|
const UNREAD_EVERY_MS = Number(process.env.KEEL_PATROL_UNREAD_EVERY_MS) > 0 ? Number(process.env.KEEL_PATROL_UNREAD_EVERY_MS) : 2 * 60 * 60 * 1000;
|
|
207
|
-
const SHIFT_EVERY_MS = 6 * 60 * 60 * 1000;
|
|
208
207
|
const SELF_INITIATED = "Self-initiated: this shift armed `keel shift ready --wake`.";
|
|
209
208
|
|
|
210
|
-
function parseContexts(values) {
|
|
211
|
-
const contexts = new Map();
|
|
212
|
-
for (const value of values) {
|
|
213
|
-
const match = String(value).match(/^([a-z0-9][a-z0-9-]{0,31})=(\d{1,3}(?:\.\d+)?)%?$/);
|
|
214
|
-
if (!match) throw new PatrolError(`--context ${value} is not <role>=<percent>.`);
|
|
215
|
-
contexts.set(match[1], Number(match[2]));
|
|
216
|
-
}
|
|
217
|
-
return contexts;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
209
|
function sendNudge(where, role, kind, text) {
|
|
221
210
|
const group = store.directName(NOTIFY_SENDER, role);
|
|
222
211
|
if (!store.groupState(store.readLog(where, group)).exists) {
|
|
@@ -226,6 +215,24 @@ function sendNudge(where, role, kind, text) {
|
|
|
226
215
|
return { role, kind, text };
|
|
227
216
|
}
|
|
228
217
|
|
|
218
|
+
// Closed todos per assignee: each `done` record and the todo it closes.
|
|
219
|
+
function closedTodos(where) {
|
|
220
|
+
const byRole = new Map();
|
|
221
|
+
for (const name of store.listGroupNames(where)) {
|
|
222
|
+
const records = store.readLog(where, name);
|
|
223
|
+
const todos = new Map(records.filter((r) => r.kind === "todo").map((r) => [r.id, r]));
|
|
224
|
+
for (const record of records) {
|
|
225
|
+
if (record.kind !== "done" || !todos.has(record.target)) continue;
|
|
226
|
+
const todo = todos.get(record.target);
|
|
227
|
+
if (!todo.assignee) continue;
|
|
228
|
+
if (!byRole.has(todo.assignee)) byRole.set(todo.assignee, []);
|
|
229
|
+
byRole.get(todo.assignee).push({ done: record.id, todo: todo.id, title: String(todo.text || "").split("\n")[0].slice(0, 80) });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (const list of byRole.values()) list.sort((a, b) => (a.done < b.done ? -1 : 1));
|
|
233
|
+
return byRole;
|
|
234
|
+
}
|
|
235
|
+
|
|
229
236
|
function nudgeRoles(where, patroller, options) {
|
|
230
237
|
const stateFile = path.join(where.root, "patrol", "nudges.json");
|
|
231
238
|
const state = store.readJsonFile(stateFile);
|
|
@@ -235,7 +242,12 @@ function nudgeRoles(where, patroller, options) {
|
|
|
235
242
|
const escalations = [];
|
|
236
243
|
const roles = [...new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean))]
|
|
237
244
|
.filter((role) => role !== patroller).sort();
|
|
245
|
+
const closures = closedTodos(where);
|
|
238
246
|
for (const role of roles) {
|
|
247
|
+
// The first look only records the tasks already closed (#313 D1).
|
|
248
|
+
if (!state[role] || !Array.isArray(state[role].closedSeen)) {
|
|
249
|
+
state[role] = { ...(state[role] || {}), closedSeen: (closures.get(role) || []).map((entry) => entry.done) };
|
|
250
|
+
}
|
|
239
251
|
const last = Date.parse(notice.presenceOf(where, role).last_active || "");
|
|
240
252
|
if (!Number.isNaN(last) && last >= idleBefore) continue;
|
|
241
253
|
const mine = state[role] || {};
|
|
@@ -260,15 +272,19 @@ function nudgeRoles(where, patroller, options) {
|
|
|
260
272
|
} else {
|
|
261
273
|
mine.unanswered = 0;
|
|
262
274
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
// A finished task is the shift boundary (#313 D2); within a task the host compacts.
|
|
276
|
+
const fresh = (closures.get(role) || []).filter((entry) => !mine.closedSeen.includes(entry.done));
|
|
277
|
+
if (fresh.length && !noteText) {
|
|
278
|
+
const task = fresh[fresh.length - 1];
|
|
279
|
+
const open = store.openTodos(where, { assignee: role }).length;
|
|
280
|
+
const next = open
|
|
281
|
+
? `\`keel shift ready --wake "<note>"\` — you still hold ${open} open todo(s)`
|
|
282
|
+
: "`keel shift ready \"<note>\"`, and wait for the coordinator to start you with new work";
|
|
283
|
+
sent.push(sendNudge(where, role, "shift",
|
|
284
|
+
`${role}: your task ${task.todo} ("${task.title}") was closed. Change shift at this task boundary: `
|
|
285
|
+
+ `\`keel shift check\`, then ${next}, then clear this session (a session serving Remote Control cannot be `
|
|
286
|
+
+ "cleared: turn it off, clear, then turn it back on)."));
|
|
287
|
+
mine.closedSeen = [...mine.closedSeen, ...fresh.map((entry) => entry.done)];
|
|
272
288
|
}
|
|
273
289
|
if (noteText && noteText.includes(SELF_INITIATED)) {
|
|
274
290
|
const written = fs.statSync(note).mtime;
|
|
@@ -422,7 +438,7 @@ function runPatrol(argv) {
|
|
|
422
438
|
throw error;
|
|
423
439
|
}
|
|
424
440
|
}
|
|
425
|
-
const options = { repo: process.cwd(), issues: null, idle: "30m", json: false, sinceLast: false, notify: false, nudge: false,
|
|
441
|
+
const options = { repo: process.cwd(), issues: null, idle: "30m", json: false, sinceLast: false, notify: false, nudge: false, diskFreeGb: null, diskMinGb: 20, quota: null, quotaAlerts: [90, 95, 99], quotaQuietAt: 90 };
|
|
426
442
|
try {
|
|
427
443
|
for (let index = 0; index < argv.length; index += 1) {
|
|
428
444
|
const arg = argv[index];
|
|
@@ -430,8 +446,9 @@ function runPatrol(argv) {
|
|
|
430
446
|
else if (arg === "--since-last") options.sinceLast = true;
|
|
431
447
|
else if (arg === "--notify") options.notify = true;
|
|
432
448
|
else if (arg === "--nudge") options.nudge = true;
|
|
433
|
-
else if (arg === "--context"
|
|
434
|
-
|
|
449
|
+
else if (arg === "--context" || arg === "--shift-at") {
|
|
450
|
+
throw new PatrolError(`${arg}: --context and --shift-at were retired in 5.125.0 (#313): a shift follows a task's close, and compaction within a task stays the host's.`);
|
|
451
|
+
}
|
|
435
452
|
else if (arg === "--disk-free-gb") options.diskFreeGb = Number(argv[++index]);
|
|
436
453
|
else if (arg === "--disk-min-gb") options.diskMinGb = Number(argv[++index]);
|
|
437
454
|
else if (arg === "--quota") options.quota = Number(argv[++index]);
|
|
@@ -447,8 +464,6 @@ function runPatrol(argv) {
|
|
|
447
464
|
} else throw new PatrolError(`Unknown argument ${arg}. ${USAGE}`);
|
|
448
465
|
}
|
|
449
466
|
if (options.notify && !options.sinceLast) throw new PatrolError("--notify sends the risks found since the last run, so it needs --since-last.");
|
|
450
|
-
if (!(options.shiftAt > 0 && options.shiftAt <= 100)) throw new PatrolError("--shift-at needs a percentage from 1 to 100.");
|
|
451
|
-
options.contexts = parseContexts(options.context);
|
|
452
467
|
if (options.diskFreeGb !== null && !(options.diskFreeGb >= 0)) throw new PatrolError("--disk-free-gb needs a number of gigabytes.");
|
|
453
468
|
if (!(options.diskMinGb > 0)) throw new PatrolError("--disk-min-gb needs a positive number of gigabytes.");
|
|
454
469
|
const percent = (value) => Number.isFinite(value) && value >= 0 && value <= 100;
|
package/src/core/shift.js
CHANGED
|
@@ -371,6 +371,14 @@ function ready(where, options) {
|
|
|
371
371
|
if (options.wake && !role) {
|
|
372
372
|
throw new ShiftError("--wake wakes a chat role, and this worktree has none: bind one with `keel chat role --set <name>`, or name it with --role.");
|
|
373
373
|
}
|
|
374
|
+
// No request can name an unbound worktree, so its `ready` is a self-shift
|
|
375
|
+
// that nothing wakes after the clear (#317 D1).
|
|
376
|
+
if (!role && !options.forceReason) {
|
|
377
|
+
throw new ShiftError(
|
|
378
|
+
"This worktree has no chat role, so nothing will start the session that follows a clear: no request can name it, and --wake needs a role. "
|
|
379
|
+
+ "Bind one with `keel chat role --set <name>` and run `keel shift ready --wake`, or give --force-reason \"<who starts the new session>\"."
|
|
380
|
+
);
|
|
381
|
+
}
|
|
374
382
|
const since = Date.now();
|
|
375
383
|
const result = check(where, role);
|
|
376
384
|
if (!result.ready && !options.forceReason) {
|
|
@@ -385,7 +393,8 @@ function ready(where, options) {
|
|
|
385
393
|
`Written ${stamp} in ${result.worktree}.`,
|
|
386
394
|
// A shift the role started itself; the patrol may nudge it to resume (#307 D4).
|
|
387
395
|
options.wake ? "Self-initiated: this shift armed `keel shift ready --wake`." : "",
|
|
388
|
-
|
|
396
|
+
!role ? `Started by hand: ${options.forceReason}.` : "",
|
|
397
|
+
options.forceReason && result.items.length ? `\nLeft as is (${options.forceReason}):\n${result.items.map((item) => `- ${item.kind}: ${item.detail}`).join("\n")}` : "",
|
|
389
398
|
"",
|
|
390
399
|
].join("\n");
|
|
391
400
|
const note = ownNotePath(where, role);
|
|
@@ -404,7 +413,7 @@ function ready(where, options) {
|
|
|
404
413
|
}
|
|
405
414
|
}
|
|
406
415
|
const waiter = options.wake ? armWake(where, role, since) : null;
|
|
407
|
-
return { role: role || null, note, closed: open.map((todo) => todo.id), waiter };
|
|
416
|
+
return { role: role || null, note, closed: open.map((todo) => todo.id), waiter, startedBy: role ? null : options.forceReason };
|
|
408
417
|
}
|
|
409
418
|
|
|
410
419
|
// --- the one-shot wake (#293) -------------------------------------------------------
|
|
@@ -723,7 +732,7 @@ const CLEAR_HINT = [
|
|
|
723
732
|
// or — without a chat role — the person who opens it.
|
|
724
733
|
function clearHint(result) {
|
|
725
734
|
let last;
|
|
726
|
-
if (!result.role) last =
|
|
735
|
+
if (!result.role) last = `Without a chat role nothing wakes the new session; ${result.startedBy} — tell it to run \`keel shift resume\`.`;
|
|
727
736
|
else if (result.waiter) {
|
|
728
737
|
last = `The wake is armed: once ${result.role}'s next session starts (after a clear or a fresh start), it gets one message to run \`keel shift resume\`. The waiter gives up after two hours.`;
|
|
729
738
|
} else if (result.closed.length) last = "The coordinator's `keel shift start` then wakes the new shift.";
|