@christang/keel 5.197.1 → 5.198.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.197.1",
3
+ "version": "5.198.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.197.1 -->
1
+ <!-- keel:start version=5.198.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
package/bin/keel.js CHANGED
@@ -1300,6 +1300,27 @@ function updateCodexPlugin(options) {
1300
1300
  return true;
1301
1301
  }
1302
1302
 
1303
+ // The version the global prefix holds (#459 D1): what `npm install -g` wrote,
1304
+ // read rather than assumed, since an install that exits 0 once left the
1305
+ // prefix a release behind while the line said `updated`.
1306
+ function installedCli(npm) {
1307
+ const root = spawnSync(npm, ["root", "-g"], {
1308
+ encoding: "utf8",
1309
+ shell: process.platform === "win32",
1310
+ timeout: Number(process.env.KEEL_UPDATE_QUERY_TIMEOUT_MS) || 30 * 1000,
1311
+ });
1312
+ const dir = String(root.stdout || "").trim().split(/\r?\n/).pop();
1313
+ if (root.error || root.status !== 0 || !dir) {
1314
+ return { version: null, why: `npm root -g ${root.error ? root.error.message : `exited ${root.status} with ${dir ? "output" : "no output"}`}` };
1315
+ }
1316
+ const file = path.join(dir, "@christang", "keel", "package.json");
1317
+ try {
1318
+ return { version: JSON.parse(fs.readFileSync(file, "utf8")).version || null, file, why: `${file} names no version` };
1319
+ } catch (error) {
1320
+ return { version: null, file, why: `${file} cannot be read (${error.code || error.message})` };
1321
+ }
1322
+ }
1323
+
1303
1324
  function updateGlobalCli(options, npm, source) {
1304
1325
  if (options.dryRun) {
1305
1326
  process.stdout.write(
@@ -1321,6 +1342,7 @@ function updateGlobalCli(options, npm, source) {
1321
1342
  return true;
1322
1343
  }
1323
1344
 
1345
+ const before = installedCli(npm);
1324
1346
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "keel-update-"));
1325
1347
  try {
1326
1348
  const packArgs = [
@@ -1358,10 +1380,17 @@ function updateGlobalCli(options, npm, source) {
1358
1380
  const latest = packed && source === DEFAULT_UPDATE_SOURCE
1359
1381
  ? `the npm registry's latest here is ${packed[1]}; `
1360
1382
  : "";
1383
+ // What the prefix holds now decides the line (#459 D2–D4).
1384
+ const after = installedCli(npm);
1385
+ if (after.version && packed && after.version !== packed[1]) {
1386
+ updateLine("cli", "failed", `npm install -g ${path.basename(tarball)} exited 0, but ${after.file} holds ${after.version}`);
1387
+ return false;
1388
+ }
1389
+ const unverified = after.version ? "" : `; not verified: ${after.why}`;
1361
1390
  updateLine(
1362
1391
  "cli",
1363
- versionChange(PACKAGE_JSON.version, packed ? packed[1] : null),
1364
- `${latest}applies to the next command that runs keel`
1392
+ versionChange(before.version || PACKAGE_JSON.version, after.version || (packed ? packed[1] : null)),
1393
+ `${latest}applies to the next command that runs keel${unverified}`
1365
1394
  );
1366
1395
  return true;
1367
1396
  } catch (error) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.197.1",
3
+ "version": "5.198.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.197.1",
9
+ "version": "5.198.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.197.1",
5
+ "version": "5.198.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.197.1",
3
+ "version": "5.198.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.197.1",
3
+ "version": "5.198.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",
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
35
35
  os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
36
36
 
37
37
 
38
- PACKAGE_VERSION = "5.197.1"
38
+ PACKAGE_VERSION = "5.198.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.197.1"
41
+ PROTOCOL_VERSION = "5.198.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -484,8 +484,15 @@ def validate_update_pack_install_scenario() -> int:
484
484
  for line in call_log.read_text(encoding="utf-8").splitlines()
485
485
  if line.strip()
486
486
  ]
487
+ # `npm root -g` is read before packing and after installing (#459), and
488
+ # changes nothing; the calls that change something are still two.
489
+ reads = [call for call in calls if call[:2] == ["root", "-g"]]
490
+ calls = [call for call in calls if call[:2] != ["root", "-g"]]
491
+ if len(reads) != 2:
492
+ report(f"update-pack-install scenario read the global prefix {len(reads)} time(s), not before and after.")
493
+ return 1
487
494
  if len(calls) != 2:
488
- report("update-pack-install scenario expected exactly two npm calls.")
495
+ report("update-pack-install scenario expected exactly two npm calls that change something.")
489
496
  report(json.dumps(calls, indent=2))
490
497
  return 1
491
498
 
@@ -2568,6 +2575,14 @@ if (host === "npm") {
2568
2575
  fs.writeFileSync(path.join(dest, "christang-keel-5.1.0.tgz"), "");
2569
2576
  process.stdout.write(JSON.stringify([{ filename: "christang-keel-5.1.0.tgz" }]));
2570
2577
  }
2578
+ // FAKE_NPM_ROOT is the global prefix `npm root -g` names, and an
2579
+ // `install -g` writes the version FAKE_NPM_INSTALLS names there (#459).
2580
+ if (args[0] === "root" && process.env.FAKE_NPM_ROOT) process.stdout.write(`${process.env.FAKE_NPM_ROOT}\n`);
2581
+ if (args[0] === "install" && process.env.FAKE_NPM_ROOT && process.env.FAKE_NPM_INSTALLS) {
2582
+ const dir = path.join(process.env.FAKE_NPM_ROOT, "@christang", "keel");
2583
+ fs.mkdirSync(dir, { recursive: true });
2584
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify({ name: "@christang/keel", version: process.env.FAKE_NPM_INSTALLS }));
2585
+ }
2571
2586
  // FAKE_NPM_LATEST is what `npm view <package> version` prints, and
2572
2587
  // FAKE_NPM_VIEW_EXIT makes it exit with that status instead (#421).
2573
2588
  if (args[0] === "view") {
@@ -2821,7 +2836,7 @@ def validate_update_covers_installed_hosts_scenario() -> int:
2821
2836
 
2822
2837
  result, calls = update()
2823
2838
  expected = [
2824
- ["npm", "pack"], ["npm", "install", "-g"],
2839
+ ["npm", "root", "-g"], ["npm", "pack"], ["npm", "install", "-g"], ["npm", "root", "-g"],
2825
2840
  ["claude", "plugin", "marketplace", "update", "keel-marketplace"],
2826
2841
  ["claude", "plugin", "update", "keel@keel-marketplace"],
2827
2842
  ["codex", "plugin", "marketplace", "upgrade", "keel-marketplace"],
@@ -3297,6 +3312,60 @@ def validate_update_claude_refresh_retry_scenario() -> int:
3297
3312
  return 0
3298
3313
 
3299
3314
 
3315
+ def validate_update_verifies_installed_cli_scenario() -> int:
3316
+ """Issue #459: the CLI line reports what the global prefix holds.
3317
+
3318
+ An `npm install -g` that exits 0 while the prefix keeps another version
3319
+ is a failure, and the before version comes from the prefix, not from the
3320
+ copy of keel that happens to be running.
3321
+ """
3322
+ label = "update-verifies-installed-cli:"
3323
+ with tempfile.TemporaryDirectory(prefix="keel-update-459-", ignore_cleanup_errors=True) as raw:
3324
+ tmp = Path(raw)
3325
+ fake = tmp / "fake.js"
3326
+ write_text(fake, UPDATE_FAKE)
3327
+ npm = tmp / "fake-npm"
3328
+ write_text(npm, f'#!/bin/sh\nFAKE_HOST=npm exec node "{fake}" "$@"\n')
3329
+ npm.chmod(0o755)
3330
+ prefix = tmp / "global"
3331
+ installed = prefix / "@christang" / "keel" / "package.json"
3332
+
3333
+ def update(installs: str) -> tuple[subprocess.CompletedProcess[str], str]:
3334
+ write_text(installed, json.dumps({"name": "@christang/keel", "version": "5.0.0"}))
3335
+ env = dict(os.environ)
3336
+ env.update({
3337
+ "KEEL_UPDATE_NPM": str(npm), "KEEL_UPDATE_CLAUDE": str(tmp / "no-claude"),
3338
+ "KEEL_UPDATE_CODEX": str(tmp / "no-codex"), "FAKE_LOG": str(tmp / "log.jsonl"),
3339
+ "FAKE_STATE": str(tmp / "state.json"), "FAKE_NPM_ROOT": str(prefix), "FAKE_NPM_INSTALLS": installs,
3340
+ })
3341
+ env.pop("KEEL_UPDATE_SOURCE", None)
3342
+ result = subprocess.run(["node", str(ROOT / "bin/keel.js"), "--update"], cwd=tmp, env=env,
3343
+ text=True, capture_output=True, check=False, timeout=120)
3344
+ line = next((l for l in result.stdout.splitlines() if l.startswith("keel update: cli:")), "")
3345
+ return result, line
3346
+
3347
+ result, line = update("5.0.9")
3348
+ if "failed" not in line:
3349
+ report(f"{label} an install that left the prefix at 5.0.9 does not read failed: {line!r}")
3350
+ return 1
3351
+ for needle in (str(installed), "5.0.9"):
3352
+ if needle not in line:
3353
+ report(f"{label} the failed line does not name {needle!r}: {line!r}")
3354
+ return 1
3355
+ if result.returncode == 0:
3356
+ report(f"{label} an install that did not take left keel --update exiting 0.")
3357
+ return 1
3358
+ result, line = update("5.1.0")
3359
+ if "updated 5.0.0 -> 5.1.0" not in line:
3360
+ report(f"{label} an install that took does not read updated 5.0.0 -> 5.1.0: {line!r}")
3361
+ return 1
3362
+ if result.returncode != 0:
3363
+ report(f"{label} an install that took left keel --update exiting {result.returncode}: {result.stdout!r}")
3364
+ return 1
3365
+ report("update-verifies-installed-cli scenario passed.")
3366
+ return 0
3367
+
3368
+
3300
3369
  def validate_update_host_query_retry_scenario() -> int:
3301
3370
  """Issue #365: `codex plugin list --json` usually answers in about 1 s and
3302
3371
  sometimes took 58 s through the owner's proxy.
@@ -395,6 +395,7 @@ SCENARIOS: tuple = (
395
395
  ("update-covers-installed-hosts", hosts.validate_update_covers_installed_hosts_scenario),
396
396
  ("update-codex-refresh-retry", hosts.validate_update_codex_refresh_retry_scenario),
397
397
  ("update-host-query-retry", hosts.validate_update_host_query_retry_scenario),
398
+ ("update-verifies-installed-cli", hosts.validate_update_verifies_installed_cli_scenario),
398
399
  ("update-claude-refresh-retry", hosts.validate_update_claude_refresh_retry_scenario),
399
400
  ("update-host-query-timeout", hosts.validate_update_host_query_timeout_scenario),
400
401
  ("update-codex-from-disk", hosts.validate_update_codex_from_disk_scenario),