@christang/keel 5.129.0 → 5.131.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>], shift-restore
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, self-shift
186
186
  - commit
187
187
  - push
188
188
  ```
@@ -238,6 +238,12 @@ session reads that restore as another session's request and stops to ask you. It
238
238
  session, so it takes no scope, and it covers no other session, no clear or archive, and no repository
239
239
  action.
240
240
 
241
+ `self-shift` (#319) is its outgoing counterpart: the five steps `keel shift ready --wake` prints on
242
+ the desktop app once the note is stored — turn the session's own Remote Control off and wait, dismiss
243
+ the PRs bound to it (#326), create the one-shot wake task, rename the session, clear it. It does not
244
+ decide that a shift happens; that stays with the task-boundary rule and the coordinator. It takes no
245
+ scope.
246
+
241
247
  `cleanup:scratch` covers removing temporary worktrees and run output under the session's own
242
248
  scratchpad, after checking that they are merged and that no process is using them. It never covers
243
249
  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.129.0 -->
1
+ <!-- keel:start version=5.131.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.129.0",
3
+ "version": "5.131.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.129.0",
9
+ "version": "5.131.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.129.0",
5
+ "version": "5.131.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.129.0",
3
+ "version": "5.131.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.129.0",
3
+ "version": "5.131.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.129.0"
51
- PROTOCOL_VERSION = "5.129.0"
50
+ PACKAGE_VERSION = "5.131.0"
51
+ PROTOCOL_VERSION = "5.131.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,68 @@ def validate_shift_change_scenario() -> int:
6788
6788
  return 0
6789
6789
 
6790
6790
 
6791
+ def validate_self_shift_authorization_scenario() -> int:
6792
+ """Issue #319: `self-shift` lets a desktop session take its own five steps.
6793
+
6794
+ The name is read and listed by `--doctor`, a scoped form is refused, and a
6795
+ desktop `keel shift ready --wake` says the steps are standing-authorized
6796
+ only when the repository declares it.
6797
+ """
6798
+ label = "self-shift-authorization:"
6799
+ with tempfile.TemporaryDirectory(prefix="keel-self-shift-") 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
+ reason = ("--force-reason", "the fixture config is uncommitted")
6806
+
6807
+ def declare(*entries: str) -> None:
6808
+ write_text(config, "authorize:\n" + "".join(f" - {entry}\n" for entry in entries))
6809
+
6810
+ declare("commit", "self-shift")
6811
+ doctor = run_keel(verify, "--doctor", env=env)
6812
+ if "self-shift" not in doctor.stdout or "unrecognized" in (doctor.stdout + doctor.stderr).lower():
6813
+ report(f"{label} self-shift was not read and listed as a standing authorization: {doctor.stdout.strip()} {doctor.stderr.strip()}")
6814
+ return 1
6815
+ granted = run_keel(verify, "shift", "ready", "--wake", *reason, "verify note: R015", env=desktop)
6816
+ if "Standing-authorized by `self-shift`" not in granted.stdout:
6817
+ report(f"{label} a desktop ready --wake with self-shift declared does not say the steps are standing-authorized: {granted.stdout.strip()} {granted.stderr.strip()}")
6818
+ return 1
6819
+ # The PR-dismiss step makes five (#326).
6820
+ if "take these five steps now" not in granted.stdout:
6821
+ report(f"{label} a desktop ready --wake with self-shift declared does not cover five steps: {granted.stdout.strip()}")
6822
+ return 1
6823
+ run_keel(verify, "shift", "resume", env=desktop)
6824
+
6825
+ declare("commit")
6826
+ asked = run_keel(verify, "shift", "ready", "--wake", *reason, "verify note: R016", env=desktop)
6827
+ if "Standing-authorized by `self-shift`" in asked.stdout:
6828
+ report(f"{label} a desktop ready --wake without self-shift says the steps are standing-authorized: {asked.stdout.strip()}")
6829
+ return 1
6830
+ if "self-shift" not in asked.stdout:
6831
+ report(f"{label} a desktop ready --wake without self-shift does not name the declaration that would allow it: {asked.stdout.strip()}")
6832
+ return 1
6833
+ run_keel(verify, "shift", "resume", env=desktop)
6834
+
6835
+ declare("commit", "self-shift:anything")
6836
+ scoped = run_keel(verify, "--doctor", env=env)
6837
+ combined = scoped.stdout + scoped.stderr
6838
+ if "self-shift:anything" not in combined or "commit: authorized" in combined:
6839
+ report(f"{label} a scoped self-shift was not refused by name: {combined.strip()}")
6840
+ return 1
6841
+
6842
+ for relative in ("README.md", "docs/shift-change.md", "docs/shift-change.zh-CN.md"):
6843
+ if "self-shift" not in (ROOT / relative).read_text(encoding="utf-8"):
6844
+ report(f"{label} {relative} does not name self-shift.")
6845
+ return 1
6846
+ if "self-shift-authorization" not in {name for name, _ in SCENARIOS}:
6847
+ report(f"{label} scenario is not registered.")
6848
+ return 1
6849
+ report("self-shift-authorization scenario passed.")
6850
+ return 0
6851
+
6852
+
6791
6853
  def validate_shift_restore_authorization_scenario() -> int:
6792
6854
  """Issue #319: `shift-restore` lets a woken desktop shift restore itself.
6793
6855
 
@@ -6881,6 +6943,20 @@ def validate_shift_desktop_wake_scenario() -> int:
6881
6943
  if off == -1 or off > armed.stdout.find("create_scheduled_task"):
6882
6944
  report(f"{label} the desktop clear hint does not turn Remote Control off before create_scheduled_task: {armed.stdout.strip()}")
6883
6945
  return 1
6946
+ # Dismiss the bound PRs after Remote Control is off and before the
6947
+ # task, or the app's auto-archive takes the idle cleared session (#326).
6948
+ for needle in ("unbind_pr", "get_status", "unarchive_session", "mcp__ccd_pr__unbind_pr",
6949
+ "mcp__ccd_session_mgmt__unarchive_session"):
6950
+ if needle not in armed.stdout:
6951
+ report(f"{label} the desktop clear hint does not name {needle}: {armed.stdout.strip()}")
6952
+ return 1
6953
+ unbind = armed.stdout.find("unbind_pr")
6954
+ if not off < unbind < armed.stdout.find("create_scheduled_task"):
6955
+ report(f"{label} the desktop clear hint does not dismiss bound PRs between Remote Control off and create_scheduled_task: {armed.stdout.strip()}")
6956
+ return 1
6957
+ if "archived copy" in armed.stdout:
6958
+ report(f"{label} the desktop clear hint still says the rename tells an archived copy apart: {armed.stdout.strip()}")
6959
+ return 1
6884
6960
  if "mcp__ccd_session_mgmt__clear_session" in armed.stdout:
6885
6961
  report(f"{label} the desktop clear hint still blames approval of clear_session: {armed.stdout.strip()}")
6886
6962
  return 1
@@ -6905,7 +6981,8 @@ def validate_shift_desktop_wake_scenario() -> int:
6905
6981
  if "The wake is armed" not in plain.stdout:
6906
6982
  report(f"{label} outside the desktop app the clear hint no longer says the wake is armed: {plain.stdout.strip()}")
6907
6983
  return 1
6908
- for needle in ("send_message", "create_scheduled_task", "set_session_title", "shift-restore"):
6984
+ for needle in ("send_message", "create_scheduled_task", "set_session_title", "shift-restore",
6985
+ "unbind_pr", "unarchive_session"):
6909
6986
  if needle in plain.stdout:
6910
6987
  report(f"{label} outside the desktop app the clear hint names {needle}: {plain.stdout.strip()}")
6911
6988
  return 1
@@ -6919,7 +6996,8 @@ def validate_shift_desktop_wake_scenario() -> int:
6919
6996
 
6920
6997
  for relative in ("docs/shift-change.md", "docs/shift-change.zh-CN.md"):
6921
6998
  text = (ROOT / relative).read_text(encoding="utf-8")
6922
- for needle in ("send_message", "set_remote_control", "set_session_title", "shift-restore"):
6999
+ for needle in ("send_message", "set_remote_control", "set_session_title", "shift-restore",
7000
+ "unbind_pr", "unarchive_session"):
6923
7001
  if needle not in text:
6924
7002
  report(f"{label} {relative} does not name {needle} for the desktop app.")
6925
7003
  return 1
@@ -28981,7 +29059,7 @@ def validate_continuation_authorization_scenario() -> int:
28981
29059
  ACCEPTED_AUTHORIZE_NAMES = (
28982
29060
  "commit, push, push:<branch glob>, release, archive, continuation, "
28983
29061
  "issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>, "
28984
- "issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>], shift-restore"
29062
+ "issue-close:<owner>/<repo>, cleanup:scratch, push-protected:<branch glob>[@<role>], shift-restore, self-shift"
28985
29063
  )
28986
29064
 
28987
29065
 
@@ -29043,7 +29121,7 @@ def validate_continuation_docs_scenario() -> int:
29043
29121
  return 1
29044
29122
 
29045
29123
  config_text = (ROOT / "keel/config.yaml").read_text(encoding="utf-8")
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:
29124
+ 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, self-shift" not in config_text:
29047
29125
  report(
29048
29126
  f"{label}: keel/config.yaml's comment lacks: protocol-refresh in the "
29049
29127
  "seven-name vocabulary."
@@ -40358,6 +40436,7 @@ SCENARIOS: tuple = (
40358
40436
  ("shift-without-role", validate_shift_without_role_scenario),
40359
40437
  ("shift-desktop-wake", validate_shift_desktop_wake_scenario),
40360
40438
  ("shift-restore-authorization", validate_shift_restore_authorization_scenario),
40439
+ ("self-shift-authorization", validate_self_shift_authorization_scenario),
40361
40440
  ("resource-lock", validate_resource_lock_scenario),
40362
40441
  ("chat-supersedes", validate_chat_supersedes_scenario),
40363
40442
  ("chat-ack", validate_chat_ack_scenario),
@@ -35,6 +35,10 @@ const STANDING_AUTHORIZATION_ACTIONS = [
35
35
  // Control back on and renaming it back, right after `keel shift resume`
36
36
  // (#319). It reaches that one session, so it takes no scope.
37
37
  "shift-restore",
38
+ // A session's own four outgoing steps on the desktop app, after `keel shift
39
+ // ready --wake` stored its note: Remote Control off, the wake task, the
40
+ // rename, and the clear (#319). Never the decision to change shift.
41
+ "self-shift",
38
42
  ];
39
43
 
40
44
  // The actions whose credential reaches further than the checkout the
package/src/core/shift.js CHANGED
@@ -422,7 +422,7 @@ function ready(where, options) {
422
422
  }
423
423
  }
424
424
  const waiter = options.wake ? armWake(where, role, since) : null;
425
- return { role: role || null, note, closed: open.map((todo) => todo.id), waiter, startedBy: role ? null : options.forceReason, desktop };
425
+ return { role: role || null, note, closed: open.map((todo) => todo.id), waiter, startedBy: role ? null : options.forceReason, desktop, worktree: where.worktree };
426
426
  }
427
427
 
428
428
  // --- the one-shot wake (#293) -------------------------------------------------------
@@ -750,14 +750,26 @@ function clearHint(result) {
750
750
  last = [
751
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
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, "
753
+ // The app's auto-archive takes an idle session whose bound PRs are all
754
+ // merged, and releases its worktree; a cleared session waiting for its
755
+ // wake is exactly that (#326 D1 of shift-desktop-unbind-merged-prs).
756
+ "2. Dismiss every PR bound to this session: call `get_status`, and while it reports a bound PR, dismiss it with `unbind_pr` and call `get_status` again. "
757
+ + "Otherwise the app's auto-archive archives the cleared, idle session before the wake and releases its worktree (#326). "
758
+ + "The new shift can bind an open one again with `bind_pr`.",
759
+ "3. Only then create a one-shot scheduled task with the host's `create_scheduled_task`, firing about three minutes later, "
754
760
  + `whose prompt calls \`send_message\` to session \`${result.desktop}\` with: "${result.role}: your new shift starts now. `
755
761
  + "Run `keel context` and `keel shift resume`, then restore Remote Control and this session's title as `keel shift resume` says.\" "
762
+ + "and, if the send is refused because the session is archived, calls `unarchive_session` on it, sends again, and says which path it took. "
756
763
  + "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`, "
764
+ `4. Rename this session with \`set_session_title\` (for example "${result.role} · shifted ${store.isoLocal(new Date()).slice(0, 16)}"), so it reads as between shifts until the woken session renames it back.`,
765
+ '5. Call clear_session("self").',
766
+ "Keel creates no task. Running unattended needs `mcp__ccd_session_mgmt__set_remote_control`, `mcp__ccd_pr__unbind_pr` "
767
+ + "and `mcp__ccd_session_mgmt__unarchive_session` in `permissions.allow`, "
760
768
  + "and `shift-restore` under `authorize:` in keel/config.yaml so the woken session does not stop to ask.",
769
+ // The outgoing side's confirmation is the repository's to waive (#319).
770
+ require("./config").readStandingAuthorization(result.worktree).scopes.has("self-shift")
771
+ ? "Standing-authorized by `self-shift` in keel/config.yaml: take these five steps now, without asking."
772
+ : "Declaring `self-shift` under authorize: in keel/config.yaml lets a session take these five steps without asking.",
761
773
  ].join("\n");
762
774
  } else if (result.waiter) {
763
775
  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.`;