@christang/keel 5.150.0 → 5.152.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/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 +144 -3
- package/src/core/chat/cli.js +16 -7
- package/src/core/chat/store.js +2 -1
- package/src/core/shift.js +66 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.152.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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.152.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.152.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.152.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.152.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.152.0"
|
|
53
|
+
PROTOCOL_VERSION = "5.152.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
|
|
|
@@ -6035,6 +6110,70 @@ def shift_scratch(base: Path) -> tuple[Path, Path, dict, Path]:
|
|
|
6035
6110
|
return rtl, verify, env, remote
|
|
6036
6111
|
|
|
6037
6112
|
|
|
6113
|
+
def validate_shift_resume_checks_commits_scenario() -> int:
|
|
6114
|
+
"""Issue #347: a shift note's commit ids go stale before the next shift reads it.
|
|
6115
|
+
|
|
6116
|
+
`keel shift resume` lists each commit id and `<branch> @ <sha>` the note
|
|
6117
|
+
names, checked against the remote-tracking refs as of the last fetch:
|
|
6118
|
+
already in the default branch, branch moved, branch gone, or not found.
|
|
6119
|
+
It fetches nothing.
|
|
6120
|
+
"""
|
|
6121
|
+
label = "shift-resume-checks-commits:"
|
|
6122
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-347-") as raw:
|
|
6123
|
+
base = Path(raw)
|
|
6124
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
6125
|
+
|
|
6126
|
+
def git(*args: str) -> str:
|
|
6127
|
+
return subprocess.run(["git", *args], cwd=rtl, text=True, capture_output=True, check=True).stdout.strip()
|
|
6128
|
+
|
|
6129
|
+
git("commit", "-q", "--allow-empty", "-m", "landed")
|
|
6130
|
+
git("push", "-q", "origin", "HEAD")
|
|
6131
|
+
landed = git("rev-parse", "HEAD")
|
|
6132
|
+
default = git("rev-parse", "--abbrev-ref", "HEAD")
|
|
6133
|
+
tree = git("rev-parse", "HEAD^{tree}")
|
|
6134
|
+
old = git("commit-tree", tree, "-p", landed, "-m", "feat one")
|
|
6135
|
+
git("push", "-q", "origin", f"{old}:refs/heads/feat")
|
|
6136
|
+
new = git("commit-tree", tree, "-p", old, "-m", "feat two")
|
|
6137
|
+
git("push", "-q", "origin", f"{new}:refs/heads/feat")
|
|
6138
|
+
note = (f"A84 {landed[:8]} is waiting to be merged. feat @ {old[:8]} waits for the push window. "
|
|
6139
|
+
f"gone-branch @ {landed[:8]} too. deadbee1 was the old base. Dated 20261018.")
|
|
6140
|
+
readied = run_keel(verify, "shift", "ready", note, env=env)
|
|
6141
|
+
if readied.returncode != 0:
|
|
6142
|
+
report(f"{label} ready failed: {readied.stderr}")
|
|
6143
|
+
return 1
|
|
6144
|
+
resumed = run_keel(verify, "shift", "resume", env=env)
|
|
6145
|
+
if resumed.returncode != 0:
|
|
6146
|
+
report(f"{label} resume failed: {resumed.stderr}")
|
|
6147
|
+
return 1
|
|
6148
|
+
lines = resumed.stdout.splitlines()
|
|
6149
|
+
|
|
6150
|
+
def line_for(token: str) -> str:
|
|
6151
|
+
return next((l for l in lines if l.lstrip().startswith(("- " + token, token))), "")
|
|
6152
|
+
|
|
6153
|
+
checks = (
|
|
6154
|
+
(landed[:8], f"already in origin/{default}"),
|
|
6155
|
+
(f"feat @ {old[:8]}", f"branch moved: now {new[:8]}"),
|
|
6156
|
+
(f"gone-branch @ {landed[:8]}", "branch gone"),
|
|
6157
|
+
("deadbee1", "not found"),
|
|
6158
|
+
)
|
|
6159
|
+
for token, want in checks:
|
|
6160
|
+
found = line_for(token)
|
|
6161
|
+
if want not in found:
|
|
6162
|
+
report(f"{label} {token!r} is not marked {want!r}: {found!r} in {resumed.stdout!r}")
|
|
6163
|
+
return 1
|
|
6164
|
+
if line_for("20261018"):
|
|
6165
|
+
report(f"{label} a date was read as a commit id: {resumed.stdout!r}")
|
|
6166
|
+
return 1
|
|
6167
|
+
if "not fetched" not in resumed.stdout:
|
|
6168
|
+
report(f"{label} the check does not say it did not fetch: {resumed.stdout!r}")
|
|
6169
|
+
return 1
|
|
6170
|
+
if "shift-resume-checks-commits" not in {name for name, _ in SCENARIOS}:
|
|
6171
|
+
report(f"{label} scenario is not registered.")
|
|
6172
|
+
return 1
|
|
6173
|
+
report("shift-resume-checks-commits scenario passed.")
|
|
6174
|
+
return 0
|
|
6175
|
+
|
|
6176
|
+
|
|
6038
6177
|
def validate_shift_role_elsewhere_scenario() -> int:
|
|
6039
6178
|
"""Issues #290, #291: a note filed under the role from another worktree.
|
|
6040
6179
|
|
|
@@ -41551,6 +41690,7 @@ SCENARIOS: tuple = (
|
|
|
41551
41690
|
"chat-stamp-help",
|
|
41552
41691
|
validate_chat_stamp_help_scenario,
|
|
41553
41692
|
),
|
|
41693
|
+
("chat-stamp-default", validate_chat_stamp_default_scenario),
|
|
41554
41694
|
(
|
|
41555
41695
|
"chat-human-view",
|
|
41556
41696
|
validate_chat_human_view_scenario,
|
|
@@ -41885,6 +42025,7 @@ SCENARIOS: tuple = (
|
|
|
41885
42025
|
("owner-language", validate_owner_language_scenario),
|
|
41886
42026
|
("owner-language-after-tools", validate_owner_language_after_tools_scenario),
|
|
41887
42027
|
("shift-history", validate_shift_history_scenario),
|
|
42028
|
+
("shift-resume-checks-commits", validate_shift_resume_checks_commits_scenario),
|
|
41888
42029
|
("shift-keeps-transcripts", validate_shift_keeps_transcripts_scenario),
|
|
41889
42030
|
("shift-keeps-found-transcripts", validate_shift_keeps_found_transcripts_scenario),
|
|
41890
42031
|
("role-drift", validate_role_drift_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/shift.js
CHANGED
|
@@ -575,6 +575,65 @@ function resumeRole(where, named) {
|
|
|
575
575
|
return named;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
// Notes cite `<branch> @ <sha>` and bare commit ids, which go stale between
|
|
579
|
+
// `ready` and `resume` (#347). Each is marked against the remote-tracking refs
|
|
580
|
+
// as they are: Keel fetches nothing, and says when they were last fetched.
|
|
581
|
+
const NOTE_PAIR = /([A-Za-z0-9][\w./-]*)\s*@\s*([0-9a-f]{7,40})\b/g;
|
|
582
|
+
const NOTE_SHA = /(?<![\w@/-])([0-9a-f]{7,40})\b/g;
|
|
583
|
+
const looksLikeSha = (token) => /[a-f]/.test(token) && /\d/.test(token);
|
|
584
|
+
|
|
585
|
+
function remoteDefault(cwd) {
|
|
586
|
+
const head = git(cwd, ["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"]);
|
|
587
|
+
if (head.ok && head.out) return head.out;
|
|
588
|
+
for (const name of ["origin/main", "origin/master"]) {
|
|
589
|
+
if (git(cwd, ["rev-parse", "--verify", "--quiet", `refs/remotes/${name}`]).ok) return name;
|
|
590
|
+
}
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function noteCommits(cwd, text) {
|
|
595
|
+
const seen = new Set();
|
|
596
|
+
const named = [];
|
|
597
|
+
for (const match of String(text).matchAll(NOTE_PAIR)) {
|
|
598
|
+
if (!looksLikeSha(match[2])) continue;
|
|
599
|
+
named.push({ index: match.index, branch: match[1], sha: match[2], token: `${match[1]} @ ${match[2]}` });
|
|
600
|
+
seen.add(match.index + match[0].length - match[2].length);
|
|
601
|
+
}
|
|
602
|
+
for (const match of String(text).matchAll(NOTE_SHA)) {
|
|
603
|
+
if (!looksLikeSha(match[1]) || seen.has(match.index)) continue;
|
|
604
|
+
named.push({ index: match.index, branch: null, sha: match[1], token: match[1] });
|
|
605
|
+
}
|
|
606
|
+
named.sort((a, b) => a.index - b.index);
|
|
607
|
+
const listed = new Set();
|
|
608
|
+
const base = remoteDefault(cwd);
|
|
609
|
+
const commits = [];
|
|
610
|
+
for (const item of named) {
|
|
611
|
+
if (listed.has(item.token)) continue;
|
|
612
|
+
listed.add(item.token);
|
|
613
|
+
const marks = [];
|
|
614
|
+
const full = git(cwd, ["rev-parse", "--verify", "--quiet", `${item.sha}^{commit}`]);
|
|
615
|
+
if (!full.ok) marks.push("not found");
|
|
616
|
+
else if (base && git(cwd, ["merge-base", "--is-ancestor", full.out, base]).ok) marks.push(`already in ${base}`);
|
|
617
|
+
if (item.branch) {
|
|
618
|
+
const tip = git(cwd, ["rev-parse", "--verify", "--quiet", `refs/remotes/origin/${item.branch}`]);
|
|
619
|
+
if (!tip.ok) marks.push("branch gone");
|
|
620
|
+
else if (!full.ok || tip.out !== full.out) marks.push(`branch moved: now ${tip.out.slice(0, 8)}`);
|
|
621
|
+
}
|
|
622
|
+
commits.push({ token: item.token, marks: marks.length ? marks : ["current"] });
|
|
623
|
+
}
|
|
624
|
+
return commits;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function lastFetch(cwd) {
|
|
628
|
+
const file = git(cwd, ["rev-parse", "--git-path", "FETCH_HEAD"]);
|
|
629
|
+
if (!file.ok) return null;
|
|
630
|
+
try {
|
|
631
|
+
return store.isoLocal(fs.statSync(path.resolve(cwd, file.out)).mtime);
|
|
632
|
+
} catch {
|
|
633
|
+
return null;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
578
637
|
function resume(where, named = null) {
|
|
579
638
|
const role = resumeRole(where, named);
|
|
580
639
|
const note = waitingNote(where, role);
|
|
@@ -584,7 +643,7 @@ function resume(where, named = null) {
|
|
|
584
643
|
const history = path.join(shiftDir(where), "history", `${role || path.basename(note, ".md")}-${stamp}.md`);
|
|
585
644
|
fs.mkdirSync(path.dirname(history), { recursive: true });
|
|
586
645
|
fs.renameSync(note, history);
|
|
587
|
-
if (!role) return { role: null, note: history, text, told: null };
|
|
646
|
+
if (!role) return { role: null, note: history, text, told: null, commits: noteCommits(where.worktree, text), fetched: lastFetch(where.worktree) };
|
|
588
647
|
// The cold-start message has done its work once the note is read.
|
|
589
648
|
for (const record of store.unread(where, role)) {
|
|
590
649
|
if (isShift(record)) store.advanceCursor(where, role, record.group, record.id);
|
|
@@ -598,7 +657,7 @@ function resume(where, named = null) {
|
|
|
598
657
|
? store.post(where, { group, text, refs: [REF] })
|
|
599
658
|
: store.writeRecord(where, { group, kind: "message", from: role, refs: [REF], text })).id;
|
|
600
659
|
}
|
|
601
|
-
return { role, note: history, text, told, waiting: role ? unstarted(where, role) : [] };
|
|
660
|
+
return { role, note: history, text, told, waiting: role ? unstarted(where, role) : [], commits: noteCommits(where.worktree, text), fetched: lastFetch(where.worktree) };
|
|
602
661
|
}
|
|
603
662
|
|
|
604
663
|
function status(where) {
|
|
@@ -986,7 +1045,11 @@ function runShift(argv) {
|
|
|
986
1045
|
+ "`set_remote_control(\"self\", true)`, and rename the session back with `set_session_title`. "
|
|
987
1046
|
+ "Declaring `shift-restore` under authorize: in keel/config.yaml lets a woken session do this without asking."
|
|
988
1047
|
: "";
|
|
989
|
-
|
|
1048
|
+
const commits = (result.commits || []).length
|
|
1049
|
+
? `\n\nCommits the note names, against the remote-tracking refs (not fetched; last fetch ${result.fetched || "never"}):\n`
|
|
1050
|
+
+ result.commits.map((c) => `- ${c.token}: ${c.marks.join("; ")}`).join("\n")
|
|
1051
|
+
: "";
|
|
1052
|
+
out(result, `${result.text.replace(/\s+$/, "")}${commits}\n\n(The note moved to ${result.note}.)${still}${remind ? `\n\n${patrolReminder(patrol)}` : ""}${remote}`);
|
|
990
1053
|
return 0;
|
|
991
1054
|
}
|
|
992
1055
|
case "history": {
|