@christang/keel 5.162.0 → 5.163.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/.claude-plugin/plugin.json +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +18 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +87 -2
- package/src/core/chat/lifecycle.js +3 -2
- package/src/core/chat/wake.js +3 -2
- package/src/core/launchd.js +76 -0
- package/src/core/tick.js +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.163.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",
|
package/bin/keel.js
CHANGED
|
@@ -2314,12 +2314,30 @@ function runDoctor(options) {
|
|
|
2314
2314
|
printFastPrePushSurface(repo);
|
|
2315
2315
|
printSourceRepoCliResolution(repo);
|
|
2316
2316
|
printChatRoleDrift(repo);
|
|
2317
|
+
printLaunchdJobs();
|
|
2317
2318
|
|
|
2318
2319
|
return authorizationOk ? checkStatus : 1;
|
|
2319
2320
|
}
|
|
2320
2321
|
|
|
2321
2322
|
// Chat role bindings that drifted from where sessions run (#301 D3). Nothing
|
|
2322
2323
|
// is printed without a chat store that binds roles.
|
|
2324
|
+
// A launchd job that names a node an upgrade removed fails silently every
|
|
2325
|
+
// interval (#387); the report does not change doctor's exit status, since the
|
|
2326
|
+
// job belongs to the machine and not to this repository.
|
|
2327
|
+
function printLaunchdJobs() {
|
|
2328
|
+
const jobs = require("../src/core/launchd").inspectJobs();
|
|
2329
|
+
if (!jobs.length) return;
|
|
2330
|
+
const gone = jobs.filter((job) => !job.exists);
|
|
2331
|
+
for (const job of gone) {
|
|
2332
|
+
printDoctorLine(
|
|
2333
|
+
"launchd",
|
|
2334
|
+
"problem",
|
|
2335
|
+
`${job.name} runs ${job.program || "no program"}, which does not exist; re-create it with \`${job.recreate}\``
|
|
2336
|
+
);
|
|
2337
|
+
}
|
|
2338
|
+
if (!gone.length) printDoctorLine("launchd", "ok", `${jobs.length} dev.keel job${jobs.length === 1 ? "" : "s"}, each naming a node that exists`);
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2323
2341
|
function printChatRoleDrift(repo) {
|
|
2324
2342
|
let where = null;
|
|
2325
2343
|
try {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.163.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.163.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.163.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.
|
|
3
|
+
"version": "5.163.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",
|
|
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
|
|
|
49
49
|
"scripts/validate_plugin.py",
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
-
PACKAGE_VERSION = "5.
|
|
53
|
-
PROTOCOL_VERSION = "5.
|
|
52
|
+
PACKAGE_VERSION = "5.163.0"
|
|
53
|
+
PROTOCOL_VERSION = "5.163.0"
|
|
54
54
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
55
55
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
56
56
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -3365,6 +3365,90 @@ def validate_patrol_next_scenario() -> int:
|
|
|
3365
3365
|
return 0
|
|
3366
3366
|
|
|
3367
3367
|
|
|
3368
|
+
def validate_launchd_stable_node_scenario() -> int:
|
|
3369
|
+
"""Issue #387: a launchd job must name a node that outlives `brew upgrade`.
|
|
3370
|
+
|
|
3371
|
+
`keel tick task` printed `process.execPath`, Homebrew's versioned Cellar
|
|
3372
|
+
path, which is gone after an upgrade; launchd then fails silently every
|
|
3373
|
+
interval. The jobs now name the `node` on PATH that is the same binary (the
|
|
3374
|
+
symlink the package manager keeps current), leave plugin cache directories
|
|
3375
|
+
out of PATH, and `keel --doctor` reports a job whose node no longer exists.
|
|
3376
|
+
"""
|
|
3377
|
+
label = "launchd-stable-node:"
|
|
3378
|
+
with tempfile.TemporaryDirectory(prefix="keel-launchd-387-") as raw:
|
|
3379
|
+
base = Path(raw)
|
|
3380
|
+
rtl, cx, env, _ = chat_wake_scratch(base)
|
|
3381
|
+
real = os.path.realpath(shutil.which("node") or "node")
|
|
3382
|
+
versioned = base / "cellar" / "node" / "9.9.9" / "bin"
|
|
3383
|
+
versioned.mkdir(parents=True)
|
|
3384
|
+
(versioned / "node").symlink_to(real)
|
|
3385
|
+
stable = base / "bin"
|
|
3386
|
+
stable.mkdir()
|
|
3387
|
+
(stable / "node").symlink_to(versioned / "node")
|
|
3388
|
+
cache = base / "home" / ".claude" / "plugins" / "cache" / "keel-marketplace" / "keel" / "5.149.0" / "bin"
|
|
3389
|
+
cache.mkdir(parents=True)
|
|
3390
|
+
path = os.pathsep.join([str(cache), str(stable), os.environ.get("PATH", "")])
|
|
3391
|
+
env = {**env, "PATH": path}
|
|
3392
|
+
write_text(rtl / "openspec/specs/.keep", "")
|
|
3393
|
+
write_authorize_config(rtl, "patrol:\n role: rtl\n every: 60m\n runner: tick\n")
|
|
3394
|
+
subprocess.run(["git", "add", "-A"], cwd=rtl, check=True, capture_output=True)
|
|
3395
|
+
subprocess.run(["git", "commit", "-q", "-m", "tick"], cwd=rtl, check=True, capture_output=True)
|
|
3396
|
+
|
|
3397
|
+
def keel(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
3398
|
+
return subprocess.run([str(stable / "node"), str(ROOT / "bin" / "keel.js"), *args], cwd=cwd, env=env,
|
|
3399
|
+
text=True, capture_output=True, check=False)
|
|
3400
|
+
|
|
3401
|
+
def program(plist: str) -> str:
|
|
3402
|
+
return (re.search(r"<key>ProgramArguments</key>\s*<array>\s*<string>(.*?)</string>", plist, re.S) or [None, ""])[1]
|
|
3403
|
+
|
|
3404
|
+
def path_of(plist: str) -> str:
|
|
3405
|
+
return (re.search(r"<key>PATH</key>\s*<string>(.*?)</string>", plist, re.S) or [None, ""])[1]
|
|
3406
|
+
|
|
3407
|
+
task = keel(rtl, "tick", "task")
|
|
3408
|
+
if task.returncode != 0:
|
|
3409
|
+
report(f"{label} keel tick task failed: {task.stderr!r}")
|
|
3410
|
+
return 1
|
|
3411
|
+
if program(task.stdout) != str(stable / "node"):
|
|
3412
|
+
report(f"{label} the tick job names the versioned node: {program(task.stdout)!r}, not {str(stable / 'node')!r}")
|
|
3413
|
+
return 1
|
|
3414
|
+
if str(stable) not in path_of(task.stdout).split(os.pathsep) or "plugins/cache" in path_of(task.stdout):
|
|
3415
|
+
report(f"{label} the tick job's PATH is not the stable directories without the plugin cache: {path_of(task.stdout)!r}")
|
|
3416
|
+
return 1
|
|
3417
|
+
|
|
3418
|
+
added = keel(cx, "chat", "wake", "add")
|
|
3419
|
+
plists = sorted((base / "agents").glob("dev.keel.chat-wake.*.plist"))
|
|
3420
|
+
if added.returncode != 0 or len(plists) != 1:
|
|
3421
|
+
report(f"{label} keel chat wake add wrote {len(plists)} LaunchAgents: {(added.stdout + added.stderr).strip()!r}")
|
|
3422
|
+
return 1
|
|
3423
|
+
waker = plists[0].read_text(encoding="utf-8")
|
|
3424
|
+
if program(waker) != str(stable / "node"):
|
|
3425
|
+
report(f"{label} the chat waker's LaunchAgent names the versioned node: {program(waker)!r}")
|
|
3426
|
+
return 1
|
|
3427
|
+
if "plugins/cache" in path_of(waker):
|
|
3428
|
+
report(f"{label} the chat waker's LaunchAgent keeps a plugin cache directory in PATH: {path_of(waker)!r}")
|
|
3429
|
+
return 1
|
|
3430
|
+
|
|
3431
|
+
gone = base / "Cellar" / "node" / "0.0.0" / "bin" / "node"
|
|
3432
|
+
broken = base / "agents" / "dev.keel.tick.x.plist"
|
|
3433
|
+
broken.write_text(task.stdout[task.stdout.index("<?xml"):task.stdout.index("</plist>") + 8].replace(str(stable / "node"), str(gone)), encoding="utf-8")
|
|
3434
|
+
problem = keel(rtl, "--doctor")
|
|
3435
|
+
line = next((l for l in problem.stdout.splitlines() if l.startswith("launchd: problem")), "")
|
|
3436
|
+
for needle in ("dev.keel.tick.x.plist", str(gone), "keel tick task"):
|
|
3437
|
+
if needle not in line:
|
|
3438
|
+
report(f"{label} doctor does not name {needle!r} for a job whose node is gone: {problem.stdout!r}")
|
|
3439
|
+
return 1
|
|
3440
|
+
broken.write_text(broken.read_text(encoding="utf-8").replace(str(gone), str(stable / "node")), encoding="utf-8")
|
|
3441
|
+
fine = keel(rtl, "--doctor")
|
|
3442
|
+
if "launchd: ok" not in fine.stdout or "launchd: problem" in fine.stdout:
|
|
3443
|
+
report(f"{label} doctor does not report ok once the node exists: {fine.stdout!r}")
|
|
3444
|
+
return 1
|
|
3445
|
+
if "launchd-stable-node" not in {name for name, _ in SCENARIOS}:
|
|
3446
|
+
report(f"{label} scenario is not registered.")
|
|
3447
|
+
return 1
|
|
3448
|
+
report("launchd-stable-node scenario passed.")
|
|
3449
|
+
return 0
|
|
3450
|
+
|
|
3451
|
+
|
|
3368
3452
|
def validate_tick_runs_due_patrol_scenario() -> int:
|
|
3369
3453
|
"""The owner's CLI waker (2026-10-19, #356): `keel tick` runs the patrol when due.
|
|
3370
3454
|
|
|
@@ -42791,6 +42875,7 @@ SCENARIOS: tuple = (
|
|
|
42791
42875
|
("patrol-since-last", validate_patrol_since_last_scenario),
|
|
42792
42876
|
("patrol-next", validate_patrol_next_scenario),
|
|
42793
42877
|
("tick-runs-due-patrol", validate_tick_runs_due_patrol_scenario),
|
|
42878
|
+
("launchd-stable-node", validate_launchd_stable_node_scenario),
|
|
42794
42879
|
("patrol-exit-says-who-acts", validate_patrol_exit_says_who_acts_scenario),
|
|
42795
42880
|
("patrol-nudge", validate_patrol_nudge_scenario),
|
|
42796
42881
|
("patrol-escalate", validate_patrol_escalate_scenario),
|
|
@@ -125,8 +125,9 @@ function xml(text) {
|
|
|
125
125
|
|
|
126
126
|
function plistText() {
|
|
127
127
|
const cli = path.resolve(__dirname, "..", "..", "..", "bin", "keel.js");
|
|
128
|
-
const
|
|
129
|
-
const
|
|
128
|
+
const { stableNode, launchdPath } = require("../launchd");
|
|
129
|
+
const args = [stableNode(), cli, "chat", "bridge", "run"];
|
|
130
|
+
const environment = { PATH: launchdPath(process.env.PATH) };
|
|
130
131
|
if (process.env.KEEL_HOME) environment.KEEL_HOME = process.env.KEEL_HOME;
|
|
131
132
|
if (process.env.KEEL_CHAT_MACHINE) environment.KEEL_CHAT_MACHINE = process.env.KEEL_CHAT_MACHINE;
|
|
132
133
|
const log = path.join(bridgeDir(), "bridge.log");
|
package/src/core/chat/wake.js
CHANGED
|
@@ -125,8 +125,9 @@ function xml(text) {
|
|
|
125
125
|
|
|
126
126
|
function plistText(label, worktree, signal) {
|
|
127
127
|
const cli = path.resolve(__dirname, "..", "..", "..", "bin", "keel.js");
|
|
128
|
-
const
|
|
129
|
-
const
|
|
128
|
+
const { stableNode, launchdPath } = require("../launchd");
|
|
129
|
+
const args = [stableNode(), cli, "chat", "wake", "run", "--once", "--worktree", worktree];
|
|
130
|
+
const environment = { PATH: launchdPath(process.env.PATH) };
|
|
130
131
|
for (const key of ["KEEL_HOME", "KEEL_CHAT_CODEX"]) {
|
|
131
132
|
if (process.env[key]) environment[key] = process.env[key];
|
|
132
133
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// What the LaunchAgents Keel prints or writes (`keel tick task`, `keel chat
|
|
4
|
+
// wake add`, the chat bridge) name, so that they outlive a package upgrade
|
|
5
|
+
// (#387). A launchd job runs long after the shell that rendered it.
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
// `process.execPath` is the binary's real location, which `brew upgrade` moves
|
|
11
|
+
// (`/opt/homebrew/Cellar/node/<version>/bin/node`). The `node` a person types is
|
|
12
|
+
// the symlink the manager keeps current, so a name on PATH that resolves to this
|
|
13
|
+
// same binary is the one to write; when none does, the real path is all there is.
|
|
14
|
+
function stableNode(env = process.env) {
|
|
15
|
+
const exec = process.execPath;
|
|
16
|
+
let real;
|
|
17
|
+
try {
|
|
18
|
+
real = fs.realpathSync(exec);
|
|
19
|
+
} catch {
|
|
20
|
+
return exec;
|
|
21
|
+
}
|
|
22
|
+
for (const dir of String(env.PATH || "").split(path.delimiter)) {
|
|
23
|
+
if (!dir) continue;
|
|
24
|
+
const candidate = path.join(dir, "node");
|
|
25
|
+
try {
|
|
26
|
+
if (fs.realpathSync(candidate) === real) return candidate;
|
|
27
|
+
} catch {
|
|
28
|
+
// not on this directory
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return exec;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A Claude plugin cache directory belongs to one release (`…/keel/5.149.0/bin`)
|
|
35
|
+
// and is stale after the next update. The jobs call node and keel.js by
|
|
36
|
+
// absolute path, so nothing in it is needed.
|
|
37
|
+
const PLUGIN_CACHE = /[\\/]\.claude[\\/]plugins[\\/]cache[\\/]/;
|
|
38
|
+
|
|
39
|
+
function launchdPath(value) {
|
|
40
|
+
const text = value || "/usr/bin:/bin:/usr/sbin:/sbin";
|
|
41
|
+
return text.split(path.delimiter).filter((dir) => dir && !PLUGIN_CACHE.test(`${dir}${path.sep}`)).join(path.delimiter);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function agentsDir() {
|
|
45
|
+
return process.env.KEEL_CHAT_LAUNCH_AGENTS_DIR || path.join(os.homedir(), "Library", "LaunchAgents");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const RECREATE = [
|
|
49
|
+
[/^dev\.keel\.tick\./, "keel tick task"],
|
|
50
|
+
[/^dev\.keel\.chat-wake\./, "keel chat wake add"],
|
|
51
|
+
[/^dev\.keel\.chat-bridge/, "keel chat bridge install"],
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
// Each `dev.keel.*` LaunchAgent with the program it runs and whether that exists.
|
|
55
|
+
function inspectJobs() {
|
|
56
|
+
let names = [];
|
|
57
|
+
try {
|
|
58
|
+
names = fs.readdirSync(agentsDir()).filter((name) => /^dev\.keel\..*\.plist$/.test(name)).sort();
|
|
59
|
+
} catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return names.map((name) => {
|
|
63
|
+
let text = "";
|
|
64
|
+
try {
|
|
65
|
+
text = fs.readFileSync(path.join(agentsDir(), name), "utf8");
|
|
66
|
+
} catch {
|
|
67
|
+
// unreadable: reported as no program below
|
|
68
|
+
}
|
|
69
|
+
const match = text.match(/<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]*)<\/string>/);
|
|
70
|
+
const program = match ? match[1].replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&") : null;
|
|
71
|
+
const recreate = (RECREATE.find(([pattern]) => pattern.test(name)) || [null, "the command that wrote it"])[1];
|
|
72
|
+
return { name, program, exists: Boolean(program) && fs.existsSync(program), recreate };
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { stableNode, launchdPath, inspectJobs };
|
package/src/core/tick.js
CHANGED
|
@@ -9,6 +9,7 @@ const os = require("os");
|
|
|
9
9
|
const path = require("path");
|
|
10
10
|
const { spawnSync } = require("child_process");
|
|
11
11
|
const store = require("./chat/store");
|
|
12
|
+
const { stableNode, launchdPath } = require("./launchd");
|
|
12
13
|
|
|
13
14
|
const USAGE = "keel tick [--repo <path>] [--json] one model-free step: run the patrol when it is due\n"
|
|
14
15
|
+ " keel tick task [--json] [--repo <path>] print the launchd job that calls it";
|
|
@@ -126,7 +127,7 @@ function task(where) {
|
|
|
126
127
|
if (!found.worktree) throw new TickError(found.why);
|
|
127
128
|
const label = `dev.keel.tick.${where.project.replace(/[^A-Za-z0-9.-]/g, "-")}`;
|
|
128
129
|
const logs = path.join(where.root, "tick");
|
|
129
|
-
const args = [
|
|
130
|
+
const args = [stableNode(), KEEL, "tick", "--repo", found.worktree];
|
|
130
131
|
const plist = [
|
|
131
132
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
132
133
|
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
@@ -135,7 +136,7 @@ function task(where) {
|
|
|
135
136
|
" <key>Label</key>", ` <string>${xml(label)}</string>`,
|
|
136
137
|
" <key>ProgramArguments</key>", " <array>", ...args.map((arg) => ` <string>${xml(arg)}</string>`), " </array>",
|
|
137
138
|
" <key>WorkingDirectory</key>", ` <string>${xml(found.worktree)}</string>`,
|
|
138
|
-
" <key>EnvironmentVariables</key>", " <dict>", " <key>PATH</key>", ` <string>${xml(process.env.PATH
|
|
139
|
+
" <key>EnvironmentVariables</key>", " <dict>", " <key>PATH</key>", ` <string>${xml(launchdPath(process.env.PATH))}</string>`, " </dict>",
|
|
139
140
|
" <key>StartInterval</key>", ` <integer>${INTERVAL_SECONDS}</integer>`,
|
|
140
141
|
" <key>StandardOutPath</key>", ` <string>${xml(path.join(logs, "tick.log"))}</string>`,
|
|
141
142
|
" <key>StandardErrorPath</key>", ` <string>${xml(path.join(logs, "tick.err"))}</string>`,
|