@christang/keel 5.126.0 → 5.127.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.
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.126.0 -->
1
+ <!-- keel:start version=5.127.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.126.0",
3
+ "version": "5.127.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.126.0",
9
+ "version": "5.127.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.126.0",
5
+ "version": "5.127.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.126.0",
3
+ "version": "5.127.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.126.0",
3
+ "version": "5.127.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.126.0"
51
- PROTOCOL_VERSION = "5.126.0"
50
+ PACKAGE_VERSION = "5.127.0"
51
+ PROTOCOL_VERSION = "5.127.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
@@ -2201,11 +2201,17 @@ def mailbox_common_dir(repo: Path) -> Path:
2201
2201
 
2202
2202
 
2203
2203
  CHAT_ROLE_VARIABLES = ("KEEL_CHAT_ROLE", "KEEL_MAIL_ROLE")
2204
+ # The desktop app's session markers (#319 D5): a run inside it must not change
2205
+ # what shift scenarios see.
2206
+ DESKTOP_HOST_VARIABLES = ("CLAUDE_CODE_ENTRYPOINT", "CLAUDE_CODE_HOST_SESSION_ID")
2204
2207
 
2205
2208
 
2206
2209
  def chat_environment(**extra: str) -> dict[str, str]:
2207
- """The test process's environment without any inherited chat role."""
2208
- env = {key: value for key, value in os.environ.items() if key not in CHAT_ROLE_VARIABLES}
2210
+ """The test process's environment without any inherited chat role or desktop host."""
2211
+ env = {
2212
+ key: value for key, value in os.environ.items()
2213
+ if key not in CHAT_ROLE_VARIABLES and key not in DESKTOP_HOST_VARIABLES
2214
+ }
2209
2215
  env.update(extra)
2210
2216
  return env
2211
2217
 
@@ -6782,6 +6788,76 @@ def validate_shift_change_scenario() -> int:
6782
6788
  return 0
6783
6789
 
6784
6790
 
6791
+ def validate_shift_desktop_wake_scenario() -> int:
6792
+ """Issue #319: on the desktop app a clear starts no session until a prompt.
6793
+
6794
+ `ready --wake` there records the session id and prints the partner recipe
6795
+ (a one-shot scheduled task that `send_message`s the session, which turns
6796
+ Remote Control back on first) instead of promising the waiter wakes it;
6797
+ `resume` there says to restore Remote Control. Elsewhere nothing changes.
6798
+ """
6799
+ label = "shift-desktop-wake:"
6800
+ with tempfile.TemporaryDirectory(prefix="keel-shift-desktop-") as raw:
6801
+ base = Path(raw)
6802
+ _rtl, verify, env, _ = shift_scratch(base)
6803
+ env = {**env, "KEEL_SHIFT_WAKE_TIMEOUT_MS": "2000"}
6804
+ desktop = {**env, "CLAUDE_CODE_ENTRYPOINT": "claude-desktop", "CLAUDE_CODE_HOST_SESSION_ID": "local_test-319"}
6805
+ note = mailbox_common_dir(verify) / "keel-chat" / "shift" / "verify.md"
6806
+
6807
+ armed = run_keel(verify, "shift", "ready", "--wake", "verify note: next is R011", env=desktop)
6808
+ if armed.returncode != 0:
6809
+ report(f"{label} ready --wake on the desktop app failed: {armed.stderr.strip()}")
6810
+ return 1
6811
+ if "Desktop session: local_test-319" not in note.read_text(encoding="utf-8"):
6812
+ report(f"{label} the note does not record the desktop session id.")
6813
+ return 1
6814
+ for needle in ("create_scheduled_task", "send_message", "local_test-319", "set_remote_control", "mcp__ccd_session_mgmt__set_remote_control"):
6815
+ if needle not in armed.stdout:
6816
+ report(f"{label} the desktop clear hint does not name {needle}: {armed.stdout.strip()}")
6817
+ return 1
6818
+ if "The wake is armed" in armed.stdout:
6819
+ report(f"{label} the desktop clear hint still says the waiter wakes the new session: {armed.stdout.strip()}")
6820
+ return 1
6821
+ resumed = run_keel(verify, "shift", "resume", env=desktop)
6822
+ if "next is R011" not in resumed.stdout:
6823
+ report(f"{label} resume on the desktop app did not print the note: {resumed.stdout.strip()} {resumed.stderr.strip()}")
6824
+ return 1
6825
+ if "set_remote_control" not in resumed.stdout:
6826
+ report(f"{label} resume on the desktop app does not say to turn Remote Control back on: {resumed.stdout.strip()}")
6827
+ return 1
6828
+
6829
+ plain = run_keel(verify, "shift", "ready", "--wake", "verify note: next is R012", env=env)
6830
+ if plain.returncode != 0:
6831
+ report(f"{label} ready --wake outside the desktop app failed: {plain.stderr.strip()}")
6832
+ return 1
6833
+ if "The wake is armed" not in plain.stdout:
6834
+ report(f"{label} outside the desktop app the clear hint no longer says the wake is armed: {plain.stdout.strip()}")
6835
+ return 1
6836
+ for needle in ("send_message", "create_scheduled_task"):
6837
+ if needle in plain.stdout:
6838
+ report(f"{label} outside the desktop app the clear hint names {needle}: {plain.stdout.strip()}")
6839
+ return 1
6840
+ if "Desktop session:" in note.read_text(encoding="utf-8"):
6841
+ report(f"{label} a note written outside the desktop app records a desktop session.")
6842
+ return 1
6843
+ 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()}")
6846
+ return 1
6847
+
6848
+ for relative in ("docs/shift-change.md", "docs/shift-change.zh-CN.md"):
6849
+ text = (ROOT / relative).read_text(encoding="utf-8")
6850
+ for needle in ("send_message", "set_remote_control"):
6851
+ if needle not in text:
6852
+ report(f"{label} {relative} does not name {needle} for the desktop app.")
6853
+ return 1
6854
+ if "shift-desktop-wake" not in {name for name, _ in SCENARIOS}:
6855
+ report(f"{label} scenario is not registered.")
6856
+ return 1
6857
+ report("shift-desktop-wake scenario passed.")
6858
+ return 0
6859
+
6860
+
6785
6861
  def validate_shift_without_role_scenario() -> int:
6786
6862
  """Owner's remark of 2026-10-05: a shift change needs no chat role.
6787
6863
 
@@ -40208,6 +40284,7 @@ SCENARIOS: tuple = (
40208
40284
  ("role-drift", validate_role_drift_scenario),
40209
40285
  ("host-run-session", validate_host_run_session_scenario),
40210
40286
  ("shift-without-role", validate_shift_without_role_scenario),
40287
+ ("shift-desktop-wake", validate_shift_desktop_wake_scenario),
40211
40288
  ("resource-lock", validate_resource_lock_scenario),
40212
40289
  ("chat-supersedes", validate_chat_supersedes_scenario),
40213
40290
  ("chat-ack", validate_chat_ack_scenario),
package/src/core/shift.js CHANGED
@@ -366,6 +366,13 @@ function readyRole(where, options) {
366
366
  return bound;
367
367
  }
368
368
 
369
+ // The Claude desktop app's session id, or null elsewhere (#319 D1). There a
370
+ // clear starts no session until a prompt arrives.
371
+ function desktopSession() {
372
+ const id = process.env.CLAUDE_CODE_HOST_SESSION_ID;
373
+ return process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop" && id ? id : null;
374
+ }
375
+
369
376
  function ready(where, options) {
370
377
  const role = readyRole(where, options);
371
378
  if (options.wake && !role) {
@@ -387,10 +394,12 @@ function ready(where, options) {
387
394
  const text = readNoteText(options).replace(/\s+$/, "");
388
395
  if (!text.trim()) throw new ShiftError("keel shift ready needs the shift note: give it as text, with --file, or on stdin.");
389
396
  const stamp = store.isoLocal(new Date());
397
+ const desktop = desktopSession();
390
398
  const head = [
391
399
  `# Shift note: ${role || path.basename(where.worktree)}`,
392
400
  "",
393
401
  `Written ${stamp} in ${result.worktree}.`,
402
+ desktop ? `Desktop session: ${desktop}.` : "",
394
403
  // A shift the role started itself; the patrol may nudge it to resume (#307 D4).
395
404
  options.wake ? "Self-initiated: this shift armed `keel shift ready --wake`." : "",
396
405
  !role ? `Started by hand: ${options.forceReason}.` : "",
@@ -413,7 +422,7 @@ function ready(where, options) {
413
422
  }
414
423
  }
415
424
  const waiter = options.wake ? armWake(where, role, since) : null;
416
- return { role: role || null, note, closed: open.map((todo) => todo.id), waiter, startedBy: role ? null : options.forceReason };
425
+ return { role: role || null, note, closed: open.map((todo) => todo.id), waiter, startedBy: role ? null : options.forceReason, desktop };
417
426
  }
418
427
 
419
428
  // --- the one-shot wake (#293) -------------------------------------------------------
@@ -733,7 +742,14 @@ const CLEAR_HINT = [
733
742
  function clearHint(result) {
734
743
  let last;
735
744
  if (!result.role) last = `Without a chat role nothing wakes the new session; ${result.startedBy} — tell it to run \`keel shift resume\`.`;
736
- else if (result.waiter) {
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`.";
752
+ } else if (result.waiter) {
737
753
  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.`;
738
754
  } else if (result.closed.length) last = "The coordinator's `keel shift start` then wakes the new shift.";
739
755
  else {
@@ -813,7 +829,11 @@ function runShift(argv) {
813
829
  // A new coordinator learns whom its previous shift left unstarted (#289 D2).
814
830
  const waiting = (result.waiting || []).map((w) => w.role);
815
831
  const still = waiting.length ? `\n\nStill waiting for \`keel shift start\`: ${waiting.join(", ")}.` : "";
816
- out(result, `${result.text.replace(/\s+$/, "")}\n\n(The note moved to ${result.note}.)${still}${remind ? `\n\n${patrolReminder(patrol)}` : ""}`);
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)`."
835
+ : "";
836
+ out(result, `${result.text.replace(/\s+$/, "")}\n\n(The note moved to ${result.note}.)${still}${remind ? `\n\n${patrolReminder(patrol)}` : ""}${remote}`);
817
837
  return 0;
818
838
  }
819
839
  case "history": {