@christang/keel 5.127.0 → 5.129.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
@@ -182,7 +182,7 @@ because a permission granted in conversation does not survive a context reset. D
182
182
  `keel/config.yaml` instead:
183
183
 
184
184
  ```yaml
185
- authorize: # accepted names: commit, push, push:<branch glob>, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>]
185
+ authorize: # accepted names: commit, push, push:<branch glob>, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>], shift-restore
186
186
  - commit
187
187
  - push
188
188
  ```
@@ -231,6 +231,13 @@ refused. A permission mode that cannot be relied on to ask, `bypassPermissions`
231
231
  refused too. Declaring it turns the push check on by itself, and a bare `push` beside it is
232
232
  refused.
233
233
 
234
+ `shift-restore` (#319) covers the two things a session started by a shift change on the Claude
235
+ desktop app must do right after `keel shift resume`: turn its own Remote Control back on, and rename
236
+ itself back to its working title. A clear there keeps neither. Without the declaration, the woken
237
+ session reads that restore as another session's request and stops to ask you. It reaches only that
238
+ session, so it takes no scope, and it covers no other session, no clear or archive, and no repository
239
+ action.
240
+
234
241
  `cleanup:scratch` covers removing temporary worktrees and run output under the session's own
235
242
  scratchpad, after checking that they are merged and that no process is using them. It never covers
236
243
  a branch or another session's files, and like the tracker scopes it is carried, not enforced.
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.127.0 -->
1
+ <!-- keel:start version=5.129.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.127.0",
3
+ "version": "5.129.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.127.0",
9
+ "version": "5.129.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.127.0",
5
+ "version": "5.129.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.127.0",
3
+ "version": "5.129.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.127.0",
3
+ "version": "5.129.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.127.0"
51
- PROTOCOL_VERSION = "5.127.0"
50
+ PACKAGE_VERSION = "5.129.0"
51
+ PROTOCOL_VERSION = "5.129.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
@@ -6788,6 +6788,65 @@ def validate_shift_change_scenario() -> int:
6788
6788
  return 0
6789
6789
 
6790
6790
 
6791
+ def validate_shift_restore_authorization_scenario() -> int:
6792
+ """Issue #319: `shift-restore` lets a woken desktop shift restore itself.
6793
+
6794
+ The name is read and listed by `--doctor`, a scoped form is refused, and
6795
+ a desktop `keel shift resume` says the restore is standing-authorized only
6796
+ when the repository declares it.
6797
+ """
6798
+ label = "shift-restore-authorization:"
6799
+ with tempfile.TemporaryDirectory(prefix="keel-shift-restore-") as raw:
6800
+ base = Path(raw)
6801
+ _rtl, verify, env, _ = shift_scratch(base)
6802
+ env = {**env, "KEEL_SHIFT_WAKE_TIMEOUT_MS": "2000"}
6803
+ desktop = {**env, "CLAUDE_CODE_ENTRYPOINT": "claude-desktop", "CLAUDE_CODE_HOST_SESSION_ID": "local_test-319"}
6804
+ config = verify / "keel" / "config.yaml"
6805
+
6806
+ def declare(*entries: str) -> None:
6807
+ write_text(config, "authorize:\n" + "".join(f" - {entry}\n" for entry in entries))
6808
+
6809
+ declare("commit", "shift-restore")
6810
+ doctor = run_keel(verify, "--doctor", env=env)
6811
+ if "shift-restore" not in doctor.stdout:
6812
+ report(f"{label} keel --doctor does not list shift-restore: {doctor.stdout.strip()} {doctor.stderr.strip()}")
6813
+ return 1
6814
+ if "unrecognized" in (doctor.stdout + doctor.stderr).lower():
6815
+ report(f"{label} shift-restore was not read as a standing authorization: {doctor.stdout.strip()} {doctor.stderr.strip()}")
6816
+ return 1
6817
+ run_keel(verify, "shift", "ready", "--wake", "--force-reason", "the fixture config is uncommitted", "verify note: R013", env=desktop)
6818
+ granted = run_keel(verify, "shift", "resume", env=desktop)
6819
+ if "Standing-authorized by `shift-restore`" not in granted.stdout:
6820
+ report(f"{label} a desktop resume with shift-restore declared does not say it is standing-authorized: {granted.stdout.strip()}")
6821
+ return 1
6822
+
6823
+ declare("commit")
6824
+ run_keel(verify, "shift", "ready", "--wake", "--force-reason", "the fixture config is uncommitted", "verify note: R014", env=desktop)
6825
+ asked = run_keel(verify, "shift", "resume", env=desktop)
6826
+ if "Standing-authorized" in asked.stdout:
6827
+ report(f"{label} a desktop resume without shift-restore says the restore is standing-authorized: {asked.stdout.strip()}")
6828
+ return 1
6829
+ if "shift-restore" not in asked.stdout:
6830
+ report(f"{label} a desktop resume without shift-restore does not name the declaration that would allow it: {asked.stdout.strip()}")
6831
+ return 1
6832
+
6833
+ declare("commit", "shift-restore:anything")
6834
+ scoped = run_keel(verify, "--doctor", env=env)
6835
+ combined = scoped.stdout + scoped.stderr
6836
+ if "shift-restore:anything" not in combined or "commit: authorized" in combined:
6837
+ report(f"{label} a scoped shift-restore was not refused by name: {combined.strip()}")
6838
+ return 1
6839
+
6840
+ if "shift-restore" not in (ROOT / "README.md").read_text(encoding="utf-8"):
6841
+ report(f"{label} README.md does not document shift-restore.")
6842
+ return 1
6843
+ if "shift-restore-authorization" not in {name for name, _ in SCENARIOS}:
6844
+ report(f"{label} scenario is not registered.")
6845
+ return 1
6846
+ report("shift-restore-authorization scenario passed.")
6847
+ return 0
6848
+
6849
+
6791
6850
  def validate_shift_desktop_wake_scenario() -> int:
6792
6851
  """Issue #319: on the desktop app a clear starts no session until a prompt.
6793
6852
 
@@ -6811,10 +6870,20 @@ def validate_shift_desktop_wake_scenario() -> int:
6811
6870
  if "Desktop session: local_test-319" not in note.read_text(encoding="utf-8"):
6812
6871
  report(f"{label} the note does not record the desktop session id.")
6813
6872
  return 1
6814
- for needle in ("create_scheduled_task", "send_message", "local_test-319", "set_remote_control", "mcp__ccd_session_mgmt__set_remote_control"):
6873
+ # Remote Control off, then the task, so the wake cannot fire before the
6874
+ # clear; then rename and clear (#319 comments 6143435530, 6144856601).
6875
+ for needle in ("create_scheduled_task", "send_message", "local_test-319", "set_session_title",
6876
+ "mcp__ccd_session_mgmt__set_remote_control", "shift-restore"):
6815
6877
  if needle not in armed.stdout:
6816
6878
  report(f"{label} the desktop clear hint does not name {needle}: {armed.stdout.strip()}")
6817
6879
  return 1
6880
+ off = armed.stdout.find('set_remote_control("self", false)')
6881
+ if off == -1 or off > armed.stdout.find("create_scheduled_task"):
6882
+ report(f"{label} the desktop clear hint does not turn Remote Control off before create_scheduled_task: {armed.stdout.strip()}")
6883
+ return 1
6884
+ if "mcp__ccd_session_mgmt__clear_session" in armed.stdout:
6885
+ report(f"{label} the desktop clear hint still blames approval of clear_session: {armed.stdout.strip()}")
6886
+ return 1
6818
6887
  if "The wake is armed" in armed.stdout:
6819
6888
  report(f"{label} the desktop clear hint still says the waiter wakes the new session: {armed.stdout.strip()}")
6820
6889
  return 1
@@ -6825,6 +6894,9 @@ def validate_shift_desktop_wake_scenario() -> int:
6825
6894
  if "set_remote_control" not in resumed.stdout:
6826
6895
  report(f"{label} resume on the desktop app does not say to turn Remote Control back on: {resumed.stdout.strip()}")
6827
6896
  return 1
6897
+ if "set_session_title" not in resumed.stdout:
6898
+ report(f"{label} resume on the desktop app does not say to rename the session back: {resumed.stdout.strip()}")
6899
+ return 1
6828
6900
 
6829
6901
  plain = run_keel(verify, "shift", "ready", "--wake", "verify note: next is R012", env=env)
6830
6902
  if plain.returncode != 0:
@@ -6833,7 +6905,7 @@ def validate_shift_desktop_wake_scenario() -> int:
6833
6905
  if "The wake is armed" not in plain.stdout:
6834
6906
  report(f"{label} outside the desktop app the clear hint no longer says the wake is armed: {plain.stdout.strip()}")
6835
6907
  return 1
6836
- for needle in ("send_message", "create_scheduled_task"):
6908
+ for needle in ("send_message", "create_scheduled_task", "set_session_title", "shift-restore"):
6837
6909
  if needle in plain.stdout:
6838
6910
  report(f"{label} outside the desktop app the clear hint names {needle}: {plain.stdout.strip()}")
6839
6911
  return 1
@@ -6841,13 +6913,13 @@ def validate_shift_desktop_wake_scenario() -> int:
6841
6913
  report(f"{label} a note written outside the desktop app records a desktop session.")
6842
6914
  return 1
6843
6915
  again = run_keel(verify, "shift", "resume", env=env)
6844
- if "set_remote_control" in again.stdout:
6845
- report(f"{label} resume outside the desktop app names set_remote_control: {again.stdout.strip()}")
6916
+ if "set_remote_control" in again.stdout or "set_session_title" in again.stdout:
6917
+ report(f"{label} resume outside the desktop app names the desktop restore: {again.stdout.strip()}")
6846
6918
  return 1
6847
6919
 
6848
6920
  for relative in ("docs/shift-change.md", "docs/shift-change.zh-CN.md"):
6849
6921
  text = (ROOT / relative).read_text(encoding="utf-8")
6850
- for needle in ("send_message", "set_remote_control"):
6922
+ for needle in ("send_message", "set_remote_control", "set_session_title", "shift-restore"):
6851
6923
  if needle not in text:
6852
6924
  report(f"{label} {relative} does not name {needle} for the desktop app.")
6853
6925
  return 1
@@ -28909,7 +28981,7 @@ def validate_continuation_authorization_scenario() -> int:
28909
28981
  ACCEPTED_AUTHORIZE_NAMES = (
28910
28982
  "commit, push, push:<branch glob>, release, archive, continuation, "
28911
28983
  "issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, "
28912
- "issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>]"
28984
+ "issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>], shift-restore"
28913
28985
  )
28914
28986
 
28915
28987
 
@@ -28971,7 +29043,7 @@ def validate_continuation_docs_scenario() -> int:
28971
29043
  return 1
28972
29044
 
28973
29045
  config_text = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
28974
- if "commit, push, push:<branch glob>,\n# release, archive, continuation, issue:<owner>/<repo>, protocol-refresh,\n# chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch,\n# push-protected:<branch glob>[@<role>]" not in config_text:
29046
+ if "commit, push, push:<branch glob>,\n# release, archive, continuation, issue:<owner>/<repo>, protocol-refresh,\n# chat-reply:<group>, issue-close:<owner>/<repo>, cleanup:scratch,\n# push-protected:<branch glob>[@<role>], shift-restore" not in config_text:
28975
29047
  report(
28976
29048
  f"{label}: keel/config.yaml's comment lacks: protocol-refresh in the "
28977
29049
  "seven-name vocabulary."
@@ -40285,6 +40357,7 @@ SCENARIOS: tuple = (
40285
40357
  ("host-run-session", validate_host_run_session_scenario),
40286
40358
  ("shift-without-role", validate_shift_without_role_scenario),
40287
40359
  ("shift-desktop-wake", validate_shift_desktop_wake_scenario),
40360
+ ("shift-restore-authorization", validate_shift_restore_authorization_scenario),
40288
40361
  ("resource-lock", validate_resource_lock_scenario),
40289
40362
  ("chat-supersedes", validate_chat_supersedes_scenario),
40290
40363
  ("chat-ack", validate_chat_ack_scenario),
@@ -31,6 +31,10 @@ const STANDING_AUTHORIZATION_ACTIONS = [
31
31
  // A branch the Claude write guard asks the user about, one push at a time,
32
32
  // instead of refusing (#280); `@<role>` limits who may be asked.
33
33
  "push-protected",
34
+ // Restoring the session a desktop shift change started: turning its Remote
35
+ // Control back on and renaming it back, right after `keel shift resume`
36
+ // (#319). It reaches that one session, so it takes no scope.
37
+ "shift-restore",
34
38
  ];
35
39
 
36
40
  // The actions whose credential reaches further than the checkout the
package/src/core/shift.js CHANGED
@@ -743,12 +743,22 @@ function clearHint(result) {
743
743
  let last;
744
744
  if (!result.role) last = `Without a chat role nothing wakes the new session; ${result.startedBy} — tell it to run \`keel shift resume\`.`;
745
745
  else if (result.waiter && result.desktop) {
746
- // Nothing starts a cleared desktop session but a prompt (#319 D3).
747
- last = "On the Claude desktop app a clear starts no session until a prompt arrives, so the waiter alone wakes nothing (#319). "
748
- + "Before you clear, create a one-shot scheduled task with the host's `create_scheduled_task`, firing a few minutes after the clear, "
749
- + `whose prompt calls \`send_message\` to session \`${result.desktop}\` with: "${result.role}: your new shift starts now. `
750
- + 'First turn Remote Control back on with set_remote_control("self", true), then run `keel context` and `keel shift resume`." '
751
- + "Keel creates no task. Turning Remote Control back on unattended needs `mcp__ccd_session_mgmt__set_remote_control` in `permissions.allow`.";
746
+ // Nothing starts a cleared desktop session but a prompt (#319 D3). The task
747
+ // comes after Remote Control is off, which can block for hours while the
748
+ // session is followed remotely; a wake that fires first is queued, and the
749
+ // app then refuses the clear to keep it (#319 D1 of shift-desktop-wake-order).
750
+ last = [
751
+ "On the Claude desktop app a clear starts no session until a prompt arrives, so the waiter alone wakes nothing (#319). Do these in order:",
752
+ '1. Turn Remote Control off with set_remote_control("self", false), and wait for that call to return; it can take long while someone follows this session remotely.',
753
+ "2. Only then create a one-shot scheduled task with the host's `create_scheduled_task`, firing about three minutes later, "
754
+ + `whose prompt calls \`send_message\` to session \`${result.desktop}\` with: "${result.role}: your new shift starts now. `
755
+ + "Run `keel context` and `keel shift resume`, then restore Remote Control and this session's title as `keel shift resume` says.\" "
756
+ + "A task created earlier can fire first, and the app then refuses the clear to keep its message.",
757
+ `3. Rename this session with \`set_session_title\` (for example "${result.role} · shifted ${store.isoLocal(new Date()).slice(0, 16)}"), so its archived copy can be told apart.`,
758
+ '4. Call clear_session("self").',
759
+ "Keel creates no task. Restoring unattended needs `mcp__ccd_session_mgmt__set_remote_control` in `permissions.allow`, "
760
+ + "and `shift-restore` under `authorize:` in keel/config.yaml so the woken session does not stop to ask.",
761
+ ].join("\n");
752
762
  } else if (result.waiter) {
753
763
  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.`;
754
764
  } else if (result.closed.length) last = "The coordinator's `keel shift start` then wakes the new shift.";
@@ -829,9 +839,16 @@ function runShift(argv) {
829
839
  // A new coordinator learns whom its previous shift left unstarted (#289 D2).
830
840
  const waiting = (result.waiting || []).map((w) => w.role);
831
841
  const still = waiting.length ? `\n\nStill waiting for \`keel shift start\`: ${waiting.join(", ")}.` : "";
832
- // A clear on the desktop app does not keep Remote Control (#319 D4).
833
- const remote = desktopSession()
834
- ? "\n\nOn the Claude desktop app Remote Control does not survive a clear: turn it back on with `set_remote_control(\"self\", true)`."
842
+ // A clear on the desktop app keeps neither Remote Control nor the title (#319).
843
+ const { readStandingAuthorization } = require("./config");
844
+ const restore = readStandingAuthorization(where.worktree).scopes.has("shift-restore");
845
+ const remote = desktopSession() && restore
846
+ ? "\n\nStanding-authorized by `shift-restore` in keel/config.yaml: turn Remote Control back on with "
847
+ + "`set_remote_control(\"self\", true)` and rename this session back to its working title with `set_session_title`, now, without asking."
848
+ : desktopSession()
849
+ ? "\n\nOn the Claude desktop app a clear keeps neither Remote Control nor this session's title: turn Remote Control back on with "
850
+ + "`set_remote_control(\"self\", true)` and rename the session back with `set_session_title`. "
851
+ + "Declaring `shift-restore` under authorize: in keel/config.yaml lets a woken session do this without asking."
835
852
  : "";
836
853
  out(result, `${result.text.replace(/\s+$/, "")}\n\n(The note moved to ${result.note}.)${still}${remind ? `\n\n${patrolReminder(patrol)}` : ""}${remote}`);
837
854
  return 0;