@christang/keel 5.141.0 → 5.142.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,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.141.0",
3
+ "version": "5.142.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,4 +1,4 @@
1
- <!-- keel:start version=5.141.0 -->
1
+ <!-- keel:start version=5.142.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.
package/bin/keel.js CHANGED
@@ -1013,13 +1013,34 @@ function hostRun(executable, args) {
1013
1013
  });
1014
1014
  }
1015
1015
 
1016
- function hostJson(executable, args) {
1017
- const result = hostRun(executable, args);
1018
- if (result.error || result.status !== 0) return null;
1016
+ // A read-only `plugin list --json` normally answers in 1–3 s, and once hung
1017
+ // for minutes through a proxy (#354). It gets its own short limit, and a query
1018
+ // that fails is reported as one, never as a host with no Keel.
1019
+ function hostQuery(executable, args) {
1020
+ const limit = Number(process.env.KEEL_UPDATE_QUERY_TIMEOUT_MS) || 30 * 1000;
1021
+ const result = spawnSync(executable, args, {
1022
+ encoding: "utf8",
1023
+ shell: process.platform === "win32",
1024
+ timeout: limit,
1025
+ });
1026
+ if (result.error && result.error.code === "ENOENT") return { absent: true };
1027
+ if (result.error && result.error.code === "ETIMEDOUT") {
1028
+ return { failed: `timed out after ${limit / 1000} s` };
1029
+ }
1030
+ if (result.error) return { failed: result.error.message };
1031
+ // On Windows the call goes through cmd.exe, which reports a missing command
1032
+ // as a nonzero exit rather than ENOENT.
1033
+ if (
1034
+ result.status !== 0 && process.platform === "win32"
1035
+ && /is not recognized as an internal or external command/i.test(result.stderr || "")
1036
+ ) {
1037
+ return { absent: true };
1038
+ }
1039
+ if (result.status !== 0) return { failed: `exited ${result.status}` };
1019
1040
  try {
1020
- return JSON.parse(result.stdout);
1041
+ return { json: JSON.parse(result.stdout) };
1021
1042
  } catch {
1022
- return null;
1043
+ return { failed: "printed no JSON" };
1023
1044
  }
1024
1045
  }
1025
1046
 
@@ -1027,8 +1048,12 @@ function hostJson(executable, args) {
1027
1048
  // host is absent or has none. Both hosts answer `plugin list --json`, in
1028
1049
  // different shapes (2026-10-03: Claude a list of {id, version, installPath},
1029
1050
  // Codex {installed: [{pluginId, version, marketplaceSource, source}]}).
1051
+ // Each returns the Keel entry, null for a host with none, or { failed } when
1052
+ // the query itself failed.
1030
1053
  function claudeKeel(executable) {
1031
- const listed = hostJson(executable, ["plugin", "list", "--json"]);
1054
+ const queried = hostQuery(executable, ["plugin", "list", "--json"]);
1055
+ if (queried.failed) return { failed: `\`claude plugin list --json\` ${queried.failed}` };
1056
+ const listed = queried.json;
1032
1057
  const entry = (Array.isArray(listed) ? listed : [])
1033
1058
  .find((item) => item && typeof item.id === "string" && item.id.startsWith("keel@"));
1034
1059
  if (!entry) return null;
@@ -1042,7 +1067,9 @@ const CODEX_SPARSE_PATHS = [".agents/plugins", "plugins/keel"];
1042
1067
  const CODEX_SPARSE_FLAGS = CODEX_SPARSE_PATHS.map((entry) => `--sparse ${entry}`).join(" ");
1043
1068
 
1044
1069
  function codexKeel(executable) {
1045
- const listed = hostJson(executable, ["plugin", "list", "--json"]);
1070
+ const queried = hostQuery(executable, ["plugin", "list", "--json"]);
1071
+ if (queried.failed) return { failed: `\`codex plugin list --json\` ${queried.failed}` };
1072
+ const listed = queried.json;
1046
1073
  const items = listed && Array.isArray(listed.installed) ? listed.installed : [];
1047
1074
  const entry = items.find((item) => item && item.name === "keel" && item.installed !== false);
1048
1075
  if (!entry) return null;
@@ -1089,7 +1116,8 @@ function versionChange(before, after) {
1089
1116
  function updateClaudePlugin(options) {
1090
1117
  const component = "claude plugin";
1091
1118
  const executable = process.env.KEEL_UPDATE_CLAUDE || "claude";
1092
- const installed = claudeKeel(executable);
1119
+ const queried = claudeKeel(executable);
1120
+ const installed = queried && !queried.failed ? queried : null;
1093
1121
  const id = installed ? installed.id : "keel@keel-marketplace";
1094
1122
  const market = installed ? installed.market : "keel-marketplace";
1095
1123
  const steps = [["plugin", "marketplace", "update", market], ["plugin", "update", id]];
@@ -1097,12 +1125,20 @@ function updateClaudePlugin(options) {
1097
1125
  for (const args of steps) process.stdout.write(`keel: would run claude ${args.join(" ")}\n`);
1098
1126
  return true;
1099
1127
  }
1128
+ if (queried && queried.failed) {
1129
+ updateLine(component, "failed", queried.failed);
1130
+ return false;
1131
+ }
1100
1132
  if (!installed) {
1101
1133
  updateLine(component, "absent", "Claude Code is not installed here or has no Keel plugin");
1102
1134
  return true;
1103
1135
  }
1104
1136
  if (!runHostSteps(component, "claude", executable, steps)) return false;
1105
1137
  const after = claudeKeel(executable);
1138
+ if (after && after.failed) {
1139
+ updateLine(component, "failed", `${after.failed} after the update, so its result is unverified`);
1140
+ return false;
1141
+ }
1106
1142
  updateLine(
1107
1143
  component,
1108
1144
  versionChange(installed.version, after && after.version),
@@ -1114,7 +1150,8 @@ function updateClaudePlugin(options) {
1114
1150
  function updateCodexPlugin(options) {
1115
1151
  const component = "codex plugin";
1116
1152
  const executable = process.env.KEEL_UPDATE_CODEX || "codex";
1117
- const installed = codexKeel(executable);
1153
+ const queried = codexKeel(executable);
1154
+ const installed = queried && !queried.failed ? queried : null;
1118
1155
  const id = installed ? installed.id : "keel@keel-marketplace";
1119
1156
  const market = installed ? installed.market : "keel-marketplace";
1120
1157
  const steps = [["plugin", "marketplace", "upgrade", market], ["plugin", "add", id]];
@@ -1122,6 +1159,10 @@ function updateCodexPlugin(options) {
1122
1159
  for (const args of steps) process.stdout.write(`keel: would run codex ${args.join(" ")}\n`);
1123
1160
  return true;
1124
1161
  }
1162
+ if (queried && queried.failed) {
1163
+ updateLine(component, "failed", queried.failed);
1164
+ return false;
1165
+ }
1125
1166
  if (!installed) {
1126
1167
  updateLine(component, "absent", "Codex is not installed here or has no Keel plugin");
1127
1168
  return true;
@@ -1159,10 +1200,18 @@ function updateCodexPlugin(options) {
1159
1200
  ? readOrNull(path.join(codexHome, "plugins", "cache", market, "keel", installed.version, "hooks", "codex.json"))
1160
1201
  : null;
1161
1202
  const upgraded = codexKeel(executable);
1203
+ if (upgraded && upgraded.failed) {
1204
+ updateLine(component, "failed", `${upgraded.failed} after the marketplace refresh`);
1205
+ return false;
1206
+ }
1162
1207
  const newHooks = upgraded && upgraded.path ? readOrNull(path.join(upgraded.path, "hooks", "codex.json")) : null;
1163
1208
  const hooksChanged = oldHooks && newHooks && !oldHooks.equals(newHooks);
1164
1209
  if (!runHostSteps(component, "codex", executable, [steps[1]])) return false;
1165
1210
  const after = codexKeel(executable);
1211
+ if (after && after.failed) {
1212
+ updateLine(component, "failed", `${after.failed} after the update, so its result is unverified`);
1213
+ return false;
1214
+ }
1166
1215
  updateLine(
1167
1216
  component,
1168
1217
  versionChange(installed.version, after && after.version),
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.141.0",
3
+ "version": "5.142.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.141.0",
9
+ "version": "5.142.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.141.0",
5
+ "version": "5.142.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.141.0",
3
+ "version": "5.142.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.141.0",
3
+ "version": "5.142.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",
@@ -48,8 +48,8 @@ REQUIRED_SCRIPTS = [
48
48
  "scripts/validate_plugin.py",
49
49
  ]
50
50
 
51
- PACKAGE_VERSION = "5.141.0"
52
- PROTOCOL_VERSION = "5.141.0"
51
+ PACKAGE_VERSION = "5.142.0"
52
+ PROTOCOL_VERSION = "5.142.0"
53
53
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
54
54
  OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
55
55
  # Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
@@ -23638,6 +23638,14 @@ const path = require("path");
23638
23638
  const host = process.env.FAKE_HOST;
23639
23639
  const args = process.argv.slice(2);
23640
23640
  fs.appendFileSync(process.env.FAKE_LOG, JSON.stringify([host, ...args]) + "\n");
23641
+ // FAKE_LIST_SLEEP_<HOST> holds `plugin list --json` for N seconds, and
23642
+ // FAKE_LIST_EXIT_<HOST> makes it exit with that status (#354).
23643
+ if (args.join(" ") === "plugin list --json") {
23644
+ const hold = Number(process.env[`FAKE_LIST_SLEEP_${host.toUpperCase()}`] || "0");
23645
+ if (hold > 0) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, hold * 1000);
23646
+ const code = process.env[`FAKE_LIST_EXIT_${host.toUpperCase()}`];
23647
+ if (code) process.exit(Number(code));
23648
+ }
23641
23649
  const stateFile = process.env.FAKE_STATE;
23642
23650
  const state = fs.existsSync(stateFile) ? JSON.parse(fs.readFileSync(stateFile, "utf8")) : {};
23643
23651
  const save = () => fs.writeFileSync(stateFile, JSON.stringify(state));
@@ -23834,6 +23842,98 @@ OVERLAY_BLOCK_RE = re.compile(
23834
23842
  )
23835
23843
 
23836
23844
 
23845
+ def validate_update_host_query_timeout_scenario() -> int:
23846
+ """Issue #354: a hung or failed host query is `failed`, never `absent`.
23847
+
23848
+ `plugin list --json` once hung for minutes through a proxy; every host call
23849
+ had five minutes, and a query that failed read as a host with no Keel.
23850
+ """
23851
+ label = "update-host-query-timeout:"
23852
+ with tempfile.TemporaryDirectory(prefix="keel-update-354-", ignore_cleanup_errors=True) as raw:
23853
+ tmp = Path(raw)
23854
+ fake = tmp / "fake.js"
23855
+ write_text(fake, UPDATE_FAKE)
23856
+ launchers = {}
23857
+ for host in ("npm", "claude", "codex"):
23858
+ launcher = tmp / f"fake-{host}"
23859
+ write_text(launcher, f'#!/bin/sh\nFAKE_HOST={host} exec node "{fake}" "$@"\n')
23860
+ launcher.chmod(0o755)
23861
+ launchers[host] = launcher
23862
+ source = tmp / "codex-source"
23863
+ write_text(source / "hooks/codex.json", "{}\n")
23864
+
23865
+ def update(*extra: str, env_extra: dict[str, str]):
23866
+ log = tmp / "log.jsonl"
23867
+ state = tmp / "state.json"
23868
+ for stale in (log, state):
23869
+ if stale.exists():
23870
+ stale.unlink()
23871
+ log.write_text("")
23872
+ env = dict(os.environ)
23873
+ env.update({
23874
+ "KEEL_UPDATE_NPM": str(launchers["npm"]),
23875
+ "KEEL_UPDATE_CLAUDE": str(launchers["claude"]),
23876
+ "KEEL_UPDATE_CODEX": str(launchers["codex"]),
23877
+ "KEEL_UPDATE_QUERY_TIMEOUT_MS": "1500",
23878
+ "CODEX_HOME": str(tmp / "codex-home"),
23879
+ "FAKE_LOG": str(log), "FAKE_STATE": str(state),
23880
+ "FAKE_CODEX_SOURCE": str(source),
23881
+ })
23882
+ env.pop("KEEL_UPDATE_SOURCE", None)
23883
+ env.update(env_extra)
23884
+ started = time.monotonic()
23885
+ result = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--update", *extra], cwd=tmp, env=env,
23886
+ text=True, capture_output=True, check=False, timeout=120)
23887
+ calls = [json.loads(line) for line in log.read_text().splitlines() if line.strip()]
23888
+ return result, calls, time.monotonic() - started
23889
+
23890
+ def line(output: str, component: str) -> str:
23891
+ return next((l for l in output.splitlines() if l.startswith(f"keel update: {component}:")), "")
23892
+
23893
+ result, _, _ = update(env_extra={"FAKE_LIST_EXIT_CLAUDE": "3"})
23894
+ claude = line(result.stdout, "claude plugin")
23895
+ if "absent" in claude:
23896
+ report(f"{label} a claude plugin list --json that exited 3 was reported absent: {claude!r}")
23897
+ return 1
23898
+ if "failed" not in claude or "exited 3" not in claude:
23899
+ report(f"{label} a claude plugin list --json that exited 3 does not read failed with exited 3: {claude!r}")
23900
+ return 1
23901
+
23902
+ result, calls, took = update(env_extra={"FAKE_LIST_SLEEP_CODEX": "10"})
23903
+ codex = line(result.stdout, "codex plugin")
23904
+ if "absent" in codex:
23905
+ report(f"{label} a hung codex plugin list --json was reported absent: {codex!r}")
23906
+ return 1
23907
+ for needle in ("failed", "codex plugin list --json", "timed out after 1.5 s"):
23908
+ if needle not in codex:
23909
+ report(f"{label} the hung-query line does not name {needle!r}: {codex!r}")
23910
+ return 1
23911
+ if any(c[:4] == ["codex", "plugin", "marketplace", "upgrade"] for c in calls):
23912
+ report(f"{label} a Codex update command ran after its query failed: {calls!r}")
23913
+ return 1
23914
+ if "updated" not in line(result.stdout, "claude plugin"):
23915
+ report(f"{label} the Claude line did not still report its update: {result.stdout!r}")
23916
+ return 1
23917
+ if result.returncode == 0:
23918
+ report(f"{label} a failed query left keel --update exiting 0.")
23919
+ return 1
23920
+ if took > 9:
23921
+ report(f"{label} the hung query held keel --update for {took:.1f} s, past its 1.5 s limit.")
23922
+ return 1
23923
+
23924
+ result, _, _ = update(env_extra={"KEEL_UPDATE_CODEX": str(tmp / "no-such-codex")})
23925
+ if "absent" not in line(result.stdout, "codex plugin"):
23926
+ report(f"{label} a missing codex executable no longer reads absent: {result.stdout!r}")
23927
+ return 1
23928
+
23929
+ result, _, _ = update("--dry-run", env_extra={"FAKE_LIST_SLEEP_CODEX": "10"})
23930
+ if result.returncode != 0:
23931
+ report(f"{label} --dry-run with a hung query exited {result.returncode}: {result.stdout!r}")
23932
+ return 1
23933
+ report("update-host-query-timeout scenario passed.")
23934
+ return 0
23935
+
23936
+
23837
23937
  def validate_update_codex_refresh_retry_scenario() -> int:
23838
23938
  """Issue #329: a slow link can cut Codex's whole-repository marketplace clone.
23839
23939
 
@@ -41122,6 +41222,7 @@ SCENARIOS: tuple = (
41122
41222
  ("adopted-update-is-silent-unless-reload", validate_adopted_update_is_silent_unless_reload_scenario),
41123
41223
  ("update-covers-installed-hosts", validate_update_covers_installed_hosts_scenario),
41124
41224
  ("update-codex-refresh-retry", validate_update_codex_refresh_retry_scenario),
41225
+ ("update-host-query-timeout", validate_update_host_query_timeout_scenario),
41125
41226
  ("refresh-covers-every-target", validate_refresh_covers_every_target_scenario),
41126
41227
  ("directory-branch-advances", validate_directory_branch_advances_scenario),
41127
41228
  ("release-notes-name-the-directory-branch", validate_release_notes_name_the_directory_branch_scenario),