@christang/keel 5.99.5 → 5.99.6

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.99.5 -->
1
+ <!-- keel:start version=5.99.6 -->
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.99.5",
3
+ "version": "5.99.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.99.5",
9
+ "version": "5.99.6",
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.99.5",
5
+ "version": "5.99.6",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.99.5",
3
+ "version": "5.99.6",
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.99.5",
3
+ "version": "5.99.6",
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",
@@ -203,6 +203,30 @@ function protocolVersion(cwd) {
203
203
  return null;
204
204
  }
205
205
 
206
+ // Numeric X.Y.Z order; a string that is not one sorts as equal, so it never
207
+ // decides which side lags.
208
+ function olderVersion(a, b) {
209
+ const x = String(a).split(".").map(Number);
210
+ const y = String(b).split(".").map(Number);
211
+ if (x.length !== 3 || y.length !== 3 || [...x, ...y].some(Number.isNaN)) return false;
212
+ for (let i = 0; i < 3; i += 1) {
213
+ if (x[i] !== y[i]) return x[i] < y[i];
214
+ }
215
+ return false;
216
+ }
217
+
218
+ // The target `keel context` names in its protocol refresh (src/core/context.js
219
+ // installedTarget), so both surfaces print the same command.
220
+ function installedTarget(cwd) {
221
+ try {
222
+ if (/<!--\s*keel:start/.test(fs.readFileSync(path.join(cwd, "CLAUDE.md"), "utf8"))) return "claude";
223
+ } catch {
224
+ // No CLAUDE.md: not the Claude target.
225
+ }
226
+ if (fs.existsSync(path.join(cwd, ".opencode", "commands"))) return "opencode";
227
+ return "codex";
228
+ }
229
+
206
230
  // Three versions are comparable in any repository: the plugin executing this
207
231
  // hook, the CLI it just invoked, and the protocol version the repository
208
232
  // stamped into its managed block. Keel reports the disagreement and stops
@@ -254,9 +278,21 @@ function versionReport(cwd, cli, pathCli = null) {
254
278
  : "";
255
279
  // An update the host already installed needs only the reload (#172), so
256
280
  // naming the update command there sends the reader to what already happened.
257
- const remedy = pending
258
- ? `The host has already installed plugin ${pending}, so nothing needs updating.`
259
- : `Updating is ${plugin.remedy}, which Keel names and does not run.`;
281
+ // The remedy belongs to what lags (#240): a protocol block behind the
282
+ // runtime is fixed by the protocol refresh, and naming the plugin update
283
+ // there sends the reader to a command that changes nothing.
284
+ const newest = known.map(([, value]) => value).reduce((a, b) => (olderVersion(a, b) ? b : a));
285
+ const runtimeBehind = [plugin.version, cli].some((value) => value && olderVersion(value, newest));
286
+ const protocol = found.find(([name]) => name === "protocol")[1];
287
+ const protocolBehind = Boolean(protocol) && olderVersion(protocol, newest);
288
+ const parts = [];
289
+ if (pending) parts.push(`The host has already installed plugin ${pending}, so nothing needs updating.`);
290
+ else if (runtimeBehind || !protocolBehind) parts.push(`Updating is ${plugin.remedy}, which Keel names and does not run.`);
291
+ if (protocolBehind) {
292
+ parts.push(`The repository's protocol block is behind: refresh it with \`keel --install --target ${installedTarget(cwd)}\`, `
293
+ + "the command `keel context` names on its Protocol: line.");
294
+ }
295
+ const remedy = parts.join(" ");
260
296
  return `runtime versions disagree: ${named}${missing}. A session's hooks are `
261
297
  + "fixed when it loads the plugin, so an updated plugin applies after "
262
298
  + `\`/reload-plugins\` or at the next session start. ${remedy}${shadow}`;
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
47
47
  "scripts/validate_plugin.py",
48
48
  ]
49
49
 
50
- PACKAGE_VERSION = "5.99.5"
51
- PROTOCOL_VERSION = "5.99.5"
50
+ PACKAGE_VERSION = "5.99.6"
51
+ PROTOCOL_VERSION = "5.99.6"
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
@@ -19493,6 +19493,38 @@ def validate_runtime_version_drift_scenario() -> int:
19493
19493
  )
19494
19494
  return 1
19495
19495
 
19496
+ # The remedy belongs to what lags (#240): plugin and CLI behind the
19497
+ # protocol name the plugin update, and a protocol behind them names the
19498
+ # protocol refresh, never the plugin update that would change nothing.
19499
+ if "claude plugin update" not in channels["additionalContext"]:
19500
+ report(
19501
+ "runtime-version-drift a plugin behind the protocol does not name "
19502
+ f"the plugin update: {channels['additionalContext']!r}"
19503
+ )
19504
+ return 1
19505
+ lagging = tmp / "lagging-protocol"
19506
+ write_text(lagging / "openspec/changes/demo/tasks.md", task_contract_fixture())
19507
+ write_text(
19508
+ lagging / "CLAUDE.md",
19509
+ "<!-- keel:start version=5.2.0 -->\n## Session Start\n<!-- keel:end -->\n",
19510
+ )
19511
+ behind = run_session_start_hook(
19512
+ lagging, codex_event, keel_cli=stale_cli, plugin_root=stale_plugin
19513
+ )
19514
+ behind_text = session_start_context(behind) or ""
19515
+ if "keel --install --target claude" not in behind_text:
19516
+ report(
19517
+ "runtime-version-drift a protocol behind the plugin and CLI does not "
19518
+ f"name the protocol refresh: {behind_text!r}"
19519
+ )
19520
+ return 1
19521
+ if "claude plugin update" in behind_text:
19522
+ report(
19523
+ "runtime-version-drift a protocol behind the plugin and CLI still "
19524
+ f"names the plugin update, which changes nothing: {behind_text!r}"
19525
+ )
19526
+ return 1
19527
+
19496
19528
  # Silence when aligned, and silence that costs nothing else. The drift
19497
19529
  # sentence is lifted off the mismatched payload and the remainder must
19498
19530
  # be byte-identical to the aligned one: that is the comparison disabled