@christang/keel 5.131.0 → 5.132.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
@@ -79,9 +79,13 @@ OpenSpec CLI):
79
79
  ```bash
80
80
  npm install -g @christang/keel
81
81
  keel --version
82
- codex plugin add keel@<marketplace> # Codex
82
+ codex plugin marketplace add TanglmChris/keel --ref main --sparse .agents/plugins --sparse plugins/keel
83
+ codex plugin add keel@keel-marketplace # Codex
83
84
  ```
84
85
 
86
+ The `--sparse` paths make Codex fetch only the plugin rather than the whole repository, which a
87
+ slow link may not clone within Codex's 30-second limit.
88
+
85
89
  For Codex, review the current hook definitions with `/hooks` in the CLI; installation does not
86
90
  grant hook trust. A running Codex session uses an updated plugin at its next hook call, and a
87
91
  release that changes the hook definitions needs that review again.
package/README.zh-CN.md CHANGED
@@ -64,9 +64,12 @@ Anthropic 的插件目录里,Keel 以 `keel-openspec` 列出。每次发版都
64
64
  ```bash
65
65
  npm install -g @christang/keel
66
66
  keel --version
67
- codex plugin add keel@<marketplace> # Codex
67
+ codex plugin marketplace add TanglmChris/keel --ref main --sparse .agents/plugins --sparse plugins/keel
68
+ codex plugin add keel@keel-marketplace # Codex
68
69
  ```
69
70
 
71
+ `--sparse` 让 Codex 只拉插件本身,而不是整个仓库;网络慢时,整仓克隆可能超过 Codex 的 30 秒上限。
72
+
70
73
  全局装的 `keel` 在 PATH 里排在插件那份前面,所以在 Claude Code 里 agent 会用它。要么让它和插件同版本,
71
74
  要么卸掉(`npm rm -g @christang/keel`);两者版本不一致时,会话启动那一行会指出来。
72
75
 
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.131.0 -->
1
+ <!-- keel:start version=5.132.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
@@ -1035,6 +1035,12 @@ function claudeKeel(executable) {
1035
1035
  return { id: entry.id, market: entry.id.slice("keel@".length), version: entry.version || null };
1036
1036
  }
1037
1037
 
1038
+ // The Codex marketplace needs only its catalog and the plugin it names; a
1039
+ // sparse clone fetches those instead of the whole repository, which a slow
1040
+ // link cannot clone within Codex's 30 s limit (#329).
1041
+ const CODEX_SPARSE_PATHS = [".agents/plugins", "plugins/keel"];
1042
+ const CODEX_SPARSE_FLAGS = CODEX_SPARSE_PATHS.map((entry) => `--sparse ${entry}`).join(" ");
1043
+
1038
1044
  function codexKeel(executable) {
1039
1045
  const listed = hostJson(executable, ["plugin", "list", "--json"]);
1040
1046
  const items = listed && Array.isArray(listed.installed) ? listed.installed : [];
@@ -1059,6 +1065,11 @@ function readOrNull(file) {
1059
1065
  }
1060
1066
  }
1061
1067
 
1068
+ function hostFails(executable, args) {
1069
+ const result = hostRun(executable, args);
1070
+ return Boolean(result.error) || result.status !== 0;
1071
+ }
1072
+
1062
1073
  function runHostSteps(component, name, executable, steps) {
1063
1074
  for (const args of steps) {
1064
1075
  const result = hostRun(executable, args);
@@ -1124,11 +1135,22 @@ function updateCodexPlugin(options) {
1124
1135
  "manual",
1125
1136
  `its marketplace is a ${installed.sourceType} source (${installed.source}), which \`codex plugin `
1126
1137
  + "marketplace upgrade` cannot refresh; to make it upgradable, run `codex plugin marketplace "
1127
- + `remove ${market}\` and then codex plugin marketplace add TanglmChris/keel --ref main`
1138
+ + `remove ${market}\` and then codex plugin marketplace add TanglmChris/keel --ref main ${CODEX_SPARSE_FLAGS}`
1128
1139
  );
1129
1140
  return true;
1130
1141
  }
1131
- if (!runHostSteps(component, "codex", executable, [steps[0]])) return false;
1142
+ // The refresh clones over the network; one retry absorbs a dropped link (#329).
1143
+ if (hostFails(executable, steps[0]) && hostFails(executable, steps[0])) {
1144
+ const codexConfig = path.join(process.env.CODEX_HOME || path.join(os.homedir(), ".codex"), "config.toml");
1145
+ updateLine(
1146
+ component,
1147
+ "failed",
1148
+ `\`codex ${steps[0].join(" ")}\` failed twice; a slow link can exceed Codex's 30 s clone limit, and a sparse `
1149
+ + `marketplace fetches only the plugin: add sparse_paths = ${JSON.stringify(CODEX_SPARSE_PATHS)} `
1150
+ + `under [marketplaces.${market}] in ${codexConfig}`
1151
+ );
1152
+ return false;
1153
+ }
1132
1154
  // Codex re-reads hook definitions at every call and trusts them by hash, so
1133
1155
  // a changed definition stops running until the owner reviews it. Compared
1134
1156
  // before `plugin add`, which deletes the old install's directory.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.131.0",
3
+ "version": "5.132.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.131.0",
9
+ "version": "5.132.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.131.0",
5
+ "version": "5.132.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.131.0",
3
+ "version": "5.132.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.131.0",
3
+ "version": "5.132.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.131.0"
51
- PROTOCOL_VERSION = "5.131.0"
50
+ PACKAGE_VERSION = "5.132.0"
51
+ PROTOCOL_VERSION = "5.132.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
@@ -23140,7 +23140,16 @@ const state = fs.existsSync(stateFile) ? JSON.parse(fs.readFileSync(stateFile, "
23140
23140
  const save = () => fs.writeFileSync(stateFile, JSON.stringify(state));
23141
23141
  const version = state[host] || "5.0.0";
23142
23142
  const failOn = process.env[`FAKE_FAIL_${host.toUpperCase()}`] || "";
23143
- if (failOn && args.join(" ").includes(failOn)) process.exit(1);
23143
+ // FAKE_FAIL_TIMES_<HOST> limits the failures to the first N matching calls.
23144
+ const failTimes = Number(process.env[`FAKE_FAIL_TIMES_${host.toUpperCase()}`] || "Infinity");
23145
+ if (failOn && args.join(" ").includes(failOn)) {
23146
+ const failed = (state.failed && state.failed[host]) || 0;
23147
+ if (failed < failTimes) {
23148
+ state.failed = { ...(state.failed || {}), [host]: failed + 1 };
23149
+ save();
23150
+ process.exit(1);
23151
+ }
23152
+ }
23144
23153
  if (host === "npm") {
23145
23154
  if (args[0] === "pack") {
23146
23155
  const dest = args[args.indexOf("--pack-destination") + 1];
@@ -23269,8 +23278,8 @@ def validate_update_covers_installed_hosts_scenario() -> int:
23269
23278
  if "manual" not in codex_line:
23270
23279
  report(f"{label} a local Codex marketplace was not reported manual: {codex_line!r}")
23271
23280
  return 1
23272
- if "codex plugin marketplace add TanglmChris/keel --ref main" not in codex_line:
23273
- report(f"{label} the manual Codex line does not name the Git marketplace command: {codex_line!r}")
23281
+ if "codex plugin marketplace add TanglmChris/keel --ref main --sparse .agents/plugins --sparse plugins/keel" not in codex_line:
23282
+ report(f"{label} the manual Codex line does not name the sparse Git marketplace command (--sparse): {codex_line!r}")
23274
23283
  return 1
23275
23284
  if any(c[0] == "codex" for c in calls):
23276
23285
  report(f"{label} a local Codex marketplace still received commands: {calls!r}")
@@ -23322,6 +23331,97 @@ OVERLAY_BLOCK_RE = re.compile(
23322
23331
  )
23323
23332
 
23324
23333
 
23334
+ def validate_update_codex_refresh_retry_scenario() -> int:
23335
+ """Issue #329: a slow link can cut Codex's whole-repository marketplace clone.
23336
+
23337
+ `keel --update` retries the refresh once, and when it still fails, names the
23338
+ sparse marketplace paths that make it fetch only the plugin. Those paths
23339
+ hold the Codex catalog and the plugin it names, and the docs use them.
23340
+ """
23341
+ label = "update-codex-refresh-retry:"
23342
+ upgrade = ["codex", "plugin", "marketplace", "upgrade", "keel-marketplace"]
23343
+ add = ["codex", "plugin", "add", "keel@keel-marketplace"]
23344
+ with tempfile.TemporaryDirectory(prefix="keel-update-retry-", ignore_cleanup_errors=True) as raw:
23345
+ tmp = Path(raw)
23346
+ fake = tmp / "fake.js"
23347
+ write_text(fake, UPDATE_FAKE)
23348
+ launchers = {}
23349
+ for host in ("npm", "claude", "codex"):
23350
+ launcher = tmp / f"fake-{host}"
23351
+ write_text(launcher, f'#!/bin/sh\nFAKE_HOST={host} exec node "{fake}" "$@"\n')
23352
+ launcher.chmod(0o755)
23353
+ launchers[host] = launcher
23354
+
23355
+ def update(times: str):
23356
+ log, state = tmp / "log.jsonl", tmp / "state.json"
23357
+ for stale in (log, state):
23358
+ if stale.exists():
23359
+ stale.unlink()
23360
+ log.write_text("")
23361
+ env = dict(os.environ)
23362
+ env.update({
23363
+ "KEEL_UPDATE_NPM": str(launchers["npm"]), "KEEL_UPDATE_CLAUDE": str(launchers["claude"]),
23364
+ "KEEL_UPDATE_CODEX": str(launchers["codex"]), "CODEX_HOME": str(tmp / "codex-home"),
23365
+ "FAKE_LOG": str(log), "FAKE_STATE": str(state), "FAKE_CODEX_SOURCE": str(tmp / "codex-source"),
23366
+ "FAKE_FAIL_CODEX": "marketplace upgrade", "FAKE_FAIL_TIMES_CODEX": times,
23367
+ })
23368
+ env.pop("KEEL_UPDATE_SOURCE", None)
23369
+ result = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--update"], cwd=tmp, env=env,
23370
+ text=True, capture_output=True, check=False, timeout=60)
23371
+ calls = [json.loads(line) for line in log.read_text().splitlines() if line.strip()]
23372
+ line = [l for l in result.stdout.splitlines() if l.startswith("keel update: codex plugin:")]
23373
+ return result, calls, (line[0] if len(line) == 1 else "")
23374
+
23375
+ result, calls, line = update("1")
23376
+ runs = sum(1 for c in calls if c[:5] == upgrade)
23377
+ if runs != 2:
23378
+ report(f"{label} the Codex marketplace upgrade ran {runs} time(s) after one failure, not 2: {calls!r}")
23379
+ return 1
23380
+ if sum(1 for c in calls if c[:4] == add) != 1:
23381
+ report(f"{label} a refresh that succeeded on retry did not run plugin add once: {calls!r}")
23382
+ return 1
23383
+ if "5.0.0 -> 5.1.0" not in line:
23384
+ report(f"{label} a refresh that succeeded on retry did not report the new version: {line!r}")
23385
+ return 1
23386
+ if result.returncode != 0:
23387
+ report(f"{label} a refresh that succeeded on retry exited {result.returncode}: {result.stdout!r}")
23388
+ return 1
23389
+
23390
+ result, calls, line = update("9")
23391
+ runs = sum(1 for c in calls if c[:5] == upgrade)
23392
+ if runs != 2:
23393
+ report(f"{label} a lasting failure ran the upgrade {runs} time(s), not 2: {calls!r}")
23394
+ return 1
23395
+ if any(c[:4] == add for c in calls):
23396
+ report(f"{label} a lasting refresh failure still ran plugin add: {calls!r}")
23397
+ return 1
23398
+ if result.returncode == 0:
23399
+ report(f"{label} a lasting refresh failure left the exit status 0: {result.stdout!r}")
23400
+ return 1
23401
+ if "failed" not in line:
23402
+ report(f"{label} a lasting refresh failure was not reported failed: {line!r}")
23403
+ return 1
23404
+ for needle in ("sparse_paths", ".agents/plugins", "plugins/keel"):
23405
+ if needle not in line:
23406
+ report(f"{label} the failed Codex line does not name {needle}: {line!r}")
23407
+ return 1
23408
+
23409
+ catalog = json.loads((ROOT / ".agents/plugins/marketplace.json").read_text(encoding="utf-8"))
23410
+ paths = [entry["source"]["path"] for entry in catalog["plugins"] if entry["name"] == "keel"]
23411
+ if paths != ["./plugins/keel"]:
23412
+ report(f"{label} the Codex catalog's keel source is not under the sparse path plugins/keel: {paths!r}")
23413
+ return 1
23414
+ for relative in ("README.md", "README.zh-CN.md", "docs/updating.md"):
23415
+ if "--sparse .agents/plugins --sparse plugins/keel" not in (ROOT / relative).read_text(encoding="utf-8"):
23416
+ report(f"{label} {relative} does not add the Codex marketplace sparse.")
23417
+ return 1
23418
+ if "update-codex-refresh-retry" not in {name for name, _ in SCENARIOS}:
23419
+ report(f"{label} scenario is not registered.")
23420
+ return 1
23421
+ report("update-codex-refresh-retry scenario passed.")
23422
+ return 0
23423
+
23424
+
23325
23425
  def validate_refresh_covers_every_target_scenario() -> int:
23326
23426
  """Issue #204: a protocol refresh brings every installed target forward.
23327
23427
 
@@ -40416,6 +40516,7 @@ SCENARIOS: tuple = (
40416
40516
  ("guard-keeps-loaded-logic-under-manifest", validate_guard_keeps_loaded_logic_under_manifest_scenario),
40417
40517
  ("adopted-update-is-silent-unless-reload", validate_adopted_update_is_silent_unless_reload_scenario),
40418
40518
  ("update-covers-installed-hosts", validate_update_covers_installed_hosts_scenario),
40519
+ ("update-codex-refresh-retry", validate_update_codex_refresh_retry_scenario),
40419
40520
  ("refresh-covers-every-target", validate_refresh_covers_every_target_scenario),
40420
40521
  ("directory-branch-advances", validate_directory_branch_advances_scenario),
40421
40522
  ("release-notes-name-the-directory-branch", validate_release_notes_name_the_directory_branch_scenario),