@christang/keel 5.88.0 → 5.89.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 +10 -4
- package/README.zh-CN.md +5 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +237 -38
- 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/plugins/keel/scripts/forward.js +126 -0
- package/plugins/keel/scripts/mail-hook.js +12 -0
- package/plugins/keel/scripts/pretooluse-guard.js +24 -2
- package/plugins/keel/scripts/session-start.js +84 -1
- package/scripts/validate_codex_receiving.py +155 -1
- package/scripts/validate_plugin.py +649 -2
package/README.md
CHANGED
|
@@ -59,8 +59,13 @@ claude plugin install keel@keel-marketplace
|
|
|
59
59
|
Updates arrive by themselves once a project is set up: `keel --init --target claude` (and
|
|
60
60
|
`keel --install`) declares auto-update for `keel-marketplace` in the project's
|
|
61
61
|
`.claude/settings.json`, which Claude reads before its own default of off. A new release is fetched
|
|
62
|
-
in the background after a session's first message
|
|
63
|
-
|
|
62
|
+
in the background after a session's first message. From 5.89.0 a running session's hooks use it at
|
|
63
|
+
their next call; its skills and agents follow after `/reload-plugins` or at the next start.
|
|
64
|
+
|
|
65
|
+
To update everything on a machine at once — the global CLI and the Claude and Codex plugins — run
|
|
66
|
+
`keel --update`. It prints one line per component saying what changed, when it takes effect, and
|
|
67
|
+
anything left for you; [docs/updating.md](docs/updating.md) has the details and what each host does
|
|
68
|
+
with a running session. To opt out, set that entry's `autoUpdate` to
|
|
64
69
|
`false`; Keel keeps a value the project states, and `keel --doctor` reports which one is declared.
|
|
65
70
|
|
|
66
71
|
Each release's notes also carry the entry Anthropic's official plugin directory would list for it,
|
|
@@ -76,8 +81,9 @@ keel --version
|
|
|
76
81
|
codex plugin add keel@<marketplace> # Codex
|
|
77
82
|
```
|
|
78
83
|
|
|
79
|
-
For Codex,
|
|
80
|
-
hook
|
|
84
|
+
For Codex, review the current hook definitions with `/hooks` in the CLI; installation does not
|
|
85
|
+
grant hook trust. A running Codex session uses an updated plugin at its next hook call, and a
|
|
86
|
+
release that changes the hook definitions needs that review again.
|
|
81
87
|
Bind a mailbox role with `keel mail role --set codex-maint`; trusted hooks announce
|
|
82
88
|
unread mail at session start and the next user input without marking it read.
|
|
83
89
|
If receiving hooks are unavailable, use `keel mail list` and `keel mail read`
|
package/README.zh-CN.md
CHANGED
|
@@ -49,7 +49,11 @@ claude plugin install keel@keel-marketplace
|
|
|
49
49
|
|
|
50
50
|
项目初始化后,更新会自己到来:`keel --init --target claude`(以及 `keel --install`)会在项目的
|
|
51
51
|
`.claude/settings.json` 里为 `keel-marketplace` 声明自动更新,Claude 先读这个声明,而不是它默认的"关闭"。
|
|
52
|
-
|
|
52
|
+
新版本会在会话发出第一条消息后在后台下载。从 5.89.0 起,正在运行的会话在下一次 hook 调用时就用上新版;
|
|
53
|
+
它的技能和 agent 要在 `/reload-plugins` 或下次启动后才更新。
|
|
54
|
+
|
|
55
|
+
想一次更新整台机器——全局 CLI、Claude 插件和 Codex 插件——就运行 `keel --update`。它为每个组件输出一行:
|
|
56
|
+
变了什么、何时生效、还剩什么要你做;细节和各宿主对运行中会话的行为见 [docs/updating.md](docs/updating.md)。
|
|
53
57
|
不想自动更新,就把那一项的 `autoUpdate` 设为 `false`;项目写明的值 Keel 会保留,`keel --doctor` 会报告当前声明的是哪一个。
|
|
54
58
|
|
|
55
59
|
每个版本的 release notes 里还附有 Anthropic 官方插件目录对应的条目,锁定到该版本 tag 指向的 commit。
|
package/bin/keel.js
CHANGED
|
@@ -119,7 +119,8 @@ Usage:
|
|
|
119
119
|
Defaults:
|
|
120
120
|
repo defaults to the current working directory.
|
|
121
121
|
target defaults to claude.
|
|
122
|
-
--update refreshes the global keel CLI
|
|
122
|
+
--update refreshes the global keel CLI and the Claude and Codex plugins it
|
|
123
|
+
finds installed, not project protocol files.
|
|
123
124
|
update source defaults to ${DEFAULT_UPDATE_SOURCE}.
|
|
124
125
|
|
|
125
126
|
Project layout:
|
|
@@ -990,21 +991,162 @@ function findPackedTarball(packStdout, tempDir) {
|
|
|
990
991
|
);
|
|
991
992
|
}
|
|
992
993
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
994
|
+
// One owner-run update for the machine (#204): the global CLI first, then
|
|
995
|
+
// the Keel plugin of each host that has one installed, through that host's own
|
|
996
|
+
// documented commands. Every component reports exactly one line saying what
|
|
997
|
+
// changed, when it applies, and what is left for the owner, because a plugin
|
|
998
|
+
// installed on disk is not a plugin the running sessions use, and the two used
|
|
999
|
+
// to be reported as the same thing. Hooks and projections never reach this.
|
|
1000
|
+
function updateLine(component, status, detail) {
|
|
1001
|
+
process.stdout.write(`keel update: ${component}: ${status} - ${detail}\n`);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function hostRun(executable, args) {
|
|
1005
|
+
return spawnSync(executable, args, {
|
|
1006
|
+
encoding: "utf8",
|
|
1007
|
+
shell: process.platform === "win32",
|
|
1008
|
+
timeout: 5 * 60 * 1000,
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function hostJson(executable, args) {
|
|
1013
|
+
const result = hostRun(executable, args);
|
|
1014
|
+
if (result.error || result.status !== 0) return null;
|
|
1015
|
+
try {
|
|
1016
|
+
return JSON.parse(result.stdout);
|
|
1017
|
+
} catch {
|
|
1018
|
+
return null;
|
|
996
1019
|
}
|
|
997
|
-
|
|
998
|
-
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// What each host reports about its installed Keel plugin, or null when the
|
|
1023
|
+
// host is absent or has none. Both hosts answer `plugin list --json`, in
|
|
1024
|
+
// different shapes (2026-10-03: Claude a list of {id, version, installPath},
|
|
1025
|
+
// Codex {installed: [{pluginId, version, marketplaceSource, source}]}).
|
|
1026
|
+
function claudeKeel(executable) {
|
|
1027
|
+
const listed = hostJson(executable, ["plugin", "list", "--json"]);
|
|
1028
|
+
const entry = (Array.isArray(listed) ? listed : [])
|
|
1029
|
+
.find((item) => item && typeof item.id === "string" && item.id.startsWith("keel@"));
|
|
1030
|
+
if (!entry) return null;
|
|
1031
|
+
return { id: entry.id, market: entry.id.slice("keel@".length), version: entry.version || null };
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function codexKeel(executable) {
|
|
1035
|
+
const listed = hostJson(executable, ["plugin", "list", "--json"]);
|
|
1036
|
+
const items = listed && Array.isArray(listed.installed) ? listed.installed : [];
|
|
1037
|
+
const entry = items.find((item) => item && item.name === "keel" && item.installed !== false);
|
|
1038
|
+
if (!entry) return null;
|
|
1039
|
+
const market = entry.marketplaceSource || {};
|
|
1040
|
+
return {
|
|
1041
|
+
id: entry.pluginId || `keel@${entry.marketplaceName}`,
|
|
1042
|
+
market: entry.marketplaceName,
|
|
1043
|
+
version: entry.version || null,
|
|
1044
|
+
sourceType: market.sourceType || "unknown",
|
|
1045
|
+
source: market.source || "",
|
|
1046
|
+
path: entry.source && entry.source.path ? entry.source.path : null,
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function readOrNull(file) {
|
|
1051
|
+
try {
|
|
1052
|
+
return fs.readFileSync(file);
|
|
1053
|
+
} catch {
|
|
1054
|
+
return null;
|
|
999
1055
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
function runHostSteps(component, name, executable, steps) {
|
|
1059
|
+
for (const args of steps) {
|
|
1060
|
+
const result = hostRun(executable, args);
|
|
1061
|
+
if (result.error || result.status !== 0) {
|
|
1062
|
+
const why = result.error ? result.error.message : `exited ${result.status}`;
|
|
1063
|
+
updateLine(component, "failed", `\`${name} ${args.join(" ")}\` ${why}`);
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1002
1066
|
}
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1003
1069
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1070
|
+
function versionChange(before, after) {
|
|
1071
|
+
return before && after && before !== after ? `updated ${before} -> ${after}` : `current ${after || before || "unknown"}`;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function updateClaudePlugin(options) {
|
|
1075
|
+
const component = "claude plugin";
|
|
1076
|
+
const executable = process.env.KEEL_UPDATE_CLAUDE || "claude";
|
|
1077
|
+
const installed = claudeKeel(executable);
|
|
1078
|
+
const id = installed ? installed.id : "keel@keel-marketplace";
|
|
1079
|
+
const market = installed ? installed.market : "keel-marketplace";
|
|
1080
|
+
const steps = [["plugin", "marketplace", "update", market], ["plugin", "update", id]];
|
|
1081
|
+
if (options.dryRun) {
|
|
1082
|
+
for (const args of steps) process.stdout.write(`keel: would run claude ${args.join(" ")}\n`);
|
|
1083
|
+
return true;
|
|
1084
|
+
}
|
|
1085
|
+
if (!installed) {
|
|
1086
|
+
updateLine(component, "absent", "Claude Code is not installed here or has no Keel plugin");
|
|
1087
|
+
return true;
|
|
1088
|
+
}
|
|
1089
|
+
if (!runHostSteps(component, "claude", executable, steps)) return false;
|
|
1090
|
+
const after = claudeKeel(executable);
|
|
1091
|
+
updateLine(
|
|
1092
|
+
component,
|
|
1093
|
+
versionChange(installed.version, after && after.version),
|
|
1094
|
+
"running sessions use it at their next hook call; their skills and agents after /reload-plugins"
|
|
1095
|
+
);
|
|
1096
|
+
return true;
|
|
1097
|
+
}
|
|
1007
1098
|
|
|
1099
|
+
function updateCodexPlugin(options) {
|
|
1100
|
+
const component = "codex plugin";
|
|
1101
|
+
const executable = process.env.KEEL_UPDATE_CODEX || "codex";
|
|
1102
|
+
const installed = codexKeel(executable);
|
|
1103
|
+
const id = installed ? installed.id : "keel@keel-marketplace";
|
|
1104
|
+
const market = installed ? installed.market : "keel-marketplace";
|
|
1105
|
+
const steps = [["plugin", "marketplace", "upgrade", market], ["plugin", "add", id]];
|
|
1106
|
+
if (options.dryRun) {
|
|
1107
|
+
for (const args of steps) process.stdout.write(`keel: would run codex ${args.join(" ")}\n`);
|
|
1108
|
+
return true;
|
|
1109
|
+
}
|
|
1110
|
+
if (!installed) {
|
|
1111
|
+
updateLine(component, "absent", "Codex is not installed here or has no Keel plugin");
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
// `codex plugin marketplace upgrade` refreshes Git marketplaces only. A
|
|
1115
|
+
// local one follows whatever its checkout holds, which is the owner's to
|
|
1116
|
+
// decide, so it is named rather than re-pointed.
|
|
1117
|
+
if (installed.sourceType !== "git") {
|
|
1118
|
+
updateLine(
|
|
1119
|
+
component,
|
|
1120
|
+
"manual",
|
|
1121
|
+
`its marketplace is a ${installed.sourceType} source (${installed.source}), which \`codex plugin `
|
|
1122
|
+
+ "marketplace upgrade` cannot refresh; to make it upgradable, run `codex plugin marketplace "
|
|
1123
|
+
+ `remove ${market}\` and then codex plugin marketplace add TanglmChris/keel --ref main`
|
|
1124
|
+
);
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
if (!runHostSteps(component, "codex", executable, [steps[0]])) return false;
|
|
1128
|
+
// Codex re-reads hook definitions at every call and trusts them by hash, so
|
|
1129
|
+
// a changed definition stops running until the owner reviews it. Compared
|
|
1130
|
+
// before `plugin add`, which deletes the old install's directory.
|
|
1131
|
+
const codexHome = process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
|
|
1132
|
+
const oldHooks = installed.version
|
|
1133
|
+
? readOrNull(path.join(codexHome, "plugins", "cache", market, "keel", installed.version, "hooks", "codex.json"))
|
|
1134
|
+
: null;
|
|
1135
|
+
const upgraded = codexKeel(executable);
|
|
1136
|
+
const newHooks = upgraded && upgraded.path ? readOrNull(path.join(upgraded.path, "hooks", "codex.json")) : null;
|
|
1137
|
+
const hooksChanged = oldHooks && newHooks && !oldHooks.equals(newHooks);
|
|
1138
|
+
if (!runHostSteps(component, "codex", executable, [steps[1]])) return false;
|
|
1139
|
+
const after = codexKeel(executable);
|
|
1140
|
+
updateLine(
|
|
1141
|
+
component,
|
|
1142
|
+
versionChange(installed.version, after && after.version),
|
|
1143
|
+
"running sessions use it at their next hook call"
|
|
1144
|
+
+ (hooksChanged ? "; its hook definitions changed, so Codex will ask you to review them in /hooks before they run" : "")
|
|
1145
|
+
);
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function updateGlobalCli(options, npm, source) {
|
|
1008
1150
|
if (options.dryRun) {
|
|
1009
1151
|
process.stdout.write(
|
|
1010
1152
|
`keel: would run ${formatCommand(npm, [
|
|
@@ -1022,7 +1164,7 @@ function runGlobalUpdate(options) {
|
|
|
1022
1164
|
"<packed-tarball>",
|
|
1023
1165
|
])}\n`
|
|
1024
1166
|
);
|
|
1025
|
-
return
|
|
1167
|
+
return true;
|
|
1026
1168
|
}
|
|
1027
1169
|
|
|
1028
1170
|
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "keel-update-"));
|
|
@@ -1039,14 +1181,10 @@ function runGlobalUpdate(options) {
|
|
|
1039
1181
|
stdio: ["inherit", "pipe", "inherit"],
|
|
1040
1182
|
shell: process.platform === "win32",
|
|
1041
1183
|
});
|
|
1042
|
-
if (packResult.error) {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
return 1;
|
|
1047
|
-
}
|
|
1048
|
-
if (packResult.status !== 0) {
|
|
1049
|
-
return typeof packResult.status === "number" ? packResult.status : 1;
|
|
1184
|
+
if (packResult.error || packResult.status !== 0) {
|
|
1185
|
+
const why = packResult.error ? packResult.error.message : `exited ${packResult.status}`;
|
|
1186
|
+
updateLine("cli", "failed", `npm pack ${source} ${why}`);
|
|
1187
|
+
return false;
|
|
1050
1188
|
}
|
|
1051
1189
|
|
|
1052
1190
|
const tarball = findPackedTarball(packResult.stdout, tempDir);
|
|
@@ -1054,21 +1192,47 @@ function runGlobalUpdate(options) {
|
|
|
1054
1192
|
stdio: "inherit",
|
|
1055
1193
|
shell: process.platform === "win32",
|
|
1056
1194
|
});
|
|
1057
|
-
if (installResult.error) {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
return 1;
|
|
1195
|
+
if (installResult.error || installResult.status !== 0) {
|
|
1196
|
+
const why = installResult.error ? installResult.error.message : `exited ${installResult.status}`;
|
|
1197
|
+
updateLine("cli", "failed", `npm install -g ${path.basename(tarball)} ${why}`);
|
|
1198
|
+
return false;
|
|
1062
1199
|
}
|
|
1063
|
-
|
|
1200
|
+
const packed = /-(\d+\.\d+\.\d+[^/]*?)\.tgz$/.exec(path.basename(tarball));
|
|
1201
|
+
updateLine("cli", versionChange(PACKAGE_JSON.version, packed ? packed[1] : null), "applies to the next command that runs keel");
|
|
1202
|
+
return true;
|
|
1064
1203
|
} catch (error) {
|
|
1065
|
-
|
|
1066
|
-
return
|
|
1204
|
+
updateLine("cli", "failed", error.message);
|
|
1205
|
+
return false;
|
|
1067
1206
|
} finally {
|
|
1068
1207
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
1069
1208
|
}
|
|
1070
1209
|
}
|
|
1071
1210
|
|
|
1211
|
+
function runGlobalUpdate(options) {
|
|
1212
|
+
if (options.repo !== null) {
|
|
1213
|
+
fail("--update refreshes the global keel CLI and does not accept a repo path");
|
|
1214
|
+
}
|
|
1215
|
+
if (options.target !== "claude") {
|
|
1216
|
+
fail("--update refreshes the global keel CLI and does not accept --target");
|
|
1217
|
+
}
|
|
1218
|
+
if (options.forceTemplateUpdate) {
|
|
1219
|
+
fail("--update does not accept --force-template-update; use keel --install --force-template-update for project files");
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
const source =
|
|
1223
|
+
options.updateSource || process.env.KEEL_UPDATE_SOURCE || DEFAULT_UPDATE_SOURCE;
|
|
1224
|
+
const npm = process.env.KEEL_UPDATE_NPM || npmCommand();
|
|
1225
|
+
|
|
1226
|
+
// Each step runs whatever the one before it did: a host that failed still
|
|
1227
|
+
// leaves the others to report, and any failure fails the command.
|
|
1228
|
+
const results = [
|
|
1229
|
+
updateGlobalCli(options, npm, source),
|
|
1230
|
+
updateClaudePlugin(options),
|
|
1231
|
+
updateCodexPlugin(options),
|
|
1232
|
+
];
|
|
1233
|
+
return results.every(Boolean) ? 0 : 1;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1072
1236
|
function runPython(script, args) {
|
|
1073
1237
|
if (!fs.existsSync(script)) {
|
|
1074
1238
|
process.stderr.write(`keel: missing packaged script: ${script}\n`);
|
|
@@ -1179,7 +1343,7 @@ function runProjectInit(options) {
|
|
|
1179
1343
|
}
|
|
1180
1344
|
}
|
|
1181
1345
|
if (openspecTools || keepSurfaces) {
|
|
1182
|
-
return
|
|
1346
|
+
return refreshInstalledTargetOverlays(repo, options.target, {
|
|
1183
1347
|
dryRun: options.dryRun,
|
|
1184
1348
|
}).status;
|
|
1185
1349
|
}
|
|
@@ -1639,6 +1803,20 @@ function refreshOpenSpecSurfaceOverlay(repo, target, options = {}) {
|
|
|
1639
1803
|
return { status: 0, ...counts };
|
|
1640
1804
|
}
|
|
1641
1805
|
|
|
1806
|
+
// A project's session usually refreshes through the one target it runs on,
|
|
1807
|
+
// while OpenSpec's own update rewrites every tool's surfaces at once. Each
|
|
1808
|
+
// target the repository carries is therefore refreshed, the selected one
|
|
1809
|
+
// first; a target with no surfaces is left uncreated (#204).
|
|
1810
|
+
function refreshInstalledTargetOverlays(repo, selected, options = {}) {
|
|
1811
|
+
const targets = [selected, ...installedOpenSpecTargets(repo).filter((t) => t !== selected)];
|
|
1812
|
+
let status = 0;
|
|
1813
|
+
for (const target of targets) {
|
|
1814
|
+
const result = refreshOpenSpecSurfaceOverlay(repo, target, options);
|
|
1815
|
+
if (result.status !== 0) status = result.status;
|
|
1816
|
+
}
|
|
1817
|
+
return { status };
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1642
1820
|
function hasCurrentOpenSpecOverlay(filePath) {
|
|
1643
1821
|
if (!fs.existsSync(filePath)) {
|
|
1644
1822
|
return false;
|
|
@@ -1648,9 +1826,30 @@ function hasCurrentOpenSpecOverlay(filePath) {
|
|
|
1648
1826
|
.includes(OPENSPEC_SURFACE_OVERLAY_START);
|
|
1649
1827
|
}
|
|
1650
1828
|
|
|
1829
|
+
// An overlay from another Keel version is present, not missing: it names the
|
|
1830
|
+
// gates of the version that wrote it, and the remedy is a refresh. Reporting
|
|
1831
|
+
// it as missing sent the reader looking for files that were there (#204).
|
|
1832
|
+
function hasStaleOpenSpecOverlay(filePath) {
|
|
1833
|
+
if (!fs.existsSync(filePath)) return false;
|
|
1834
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
1835
|
+
return OPENSPEC_SURFACE_OVERLAY_RE.test(content)
|
|
1836
|
+
&& !content.includes(OPENSPEC_SURFACE_OVERLAY_START);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1651
1839
|
function countOpenSpecOverlays(paths) {
|
|
1652
1840
|
const current = paths.filter(hasCurrentOpenSpecOverlay);
|
|
1653
|
-
|
|
1841
|
+
const stale = paths.filter(hasStaleOpenSpecOverlay);
|
|
1842
|
+
return { existing: current.length, stale: stale.length, total: paths.length };
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
function overlayStatus(counts) {
|
|
1846
|
+
if (counts.existing === counts.total) return "ok";
|
|
1847
|
+
return counts.stale > 0 && counts.existing + counts.stale === counts.total ? "stale" : "missing";
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
function overlayCountDetail(counts, location) {
|
|
1851
|
+
const stale = counts.stale > 0 ? `, ${counts.stale} from another Keel version` : "";
|
|
1852
|
+
return `${formatCount(counts, location)}${stale}`;
|
|
1654
1853
|
}
|
|
1655
1854
|
|
|
1656
1855
|
function overlayRemediation(target) {
|
|
@@ -1680,9 +1879,9 @@ function printAdditionalOverlayHealth(repo, selectedTarget) {
|
|
|
1680
1879
|
const name = { claude: "Claude", codex: "Codex", opencode: "OpenCode" }[target];
|
|
1681
1880
|
printDoctorLine(
|
|
1682
1881
|
`${name} Keel ${overlayActionLabel()} overlay`,
|
|
1683
|
-
|
|
1684
|
-
`${
|
|
1685
|
-
+ (
|
|
1882
|
+
overlayStatus(counts),
|
|
1883
|
+
`${overlayCountDetail(counts, "skills and commands")}`
|
|
1884
|
+
+ (overlayStatus(counts) === "ok" ? "" : `; ${overlayRemediation(target)}`)
|
|
1686
1885
|
);
|
|
1687
1886
|
}
|
|
1688
1887
|
}
|
|
@@ -1825,15 +2024,15 @@ function printTargetSurface(repo, target) {
|
|
|
1825
2024
|
);
|
|
1826
2025
|
const overlayCounts = countOpenSpecOverlays(overlayPaths);
|
|
1827
2026
|
const overlayDetail =
|
|
1828
|
-
|
|
2027
|
+
overlayStatus(overlayCounts) === "ok"
|
|
1829
2028
|
? formatCount(overlayCounts, `${overlayActionLabel()} skills and commands`)
|
|
1830
|
-
: `${
|
|
2029
|
+
: `${overlayCountDetail(
|
|
1831
2030
|
overlayCounts,
|
|
1832
2031
|
`${overlayActionLabel()} skills and commands`
|
|
1833
2032
|
)}; ${overlayRemediation(target)}`;
|
|
1834
2033
|
printDoctorLine(
|
|
1835
2034
|
`Keel ${overlayActionLabel()} overlay`,
|
|
1836
|
-
|
|
2035
|
+
overlayStatus(overlayCounts),
|
|
1837
2036
|
overlayDetail
|
|
1838
2037
|
);
|
|
1839
2038
|
|
|
@@ -2578,7 +2777,7 @@ function runAction(options) {
|
|
|
2578
2777
|
if (installStatus !== 0) {
|
|
2579
2778
|
return installStatus;
|
|
2580
2779
|
}
|
|
2581
|
-
return
|
|
2780
|
+
return refreshInstalledTargetOverlays(
|
|
2582
2781
|
path.resolve(options.repo || process.cwd()),
|
|
2583
2782
|
options.target,
|
|
2584
2783
|
{ dryRun: options.dryRun }
|
|
@@ -2625,7 +2824,7 @@ function runAction(options) {
|
|
|
2625
2824
|
}
|
|
2626
2825
|
// The overlay refresh is a Node-side step the installer's plan never sees,
|
|
2627
2826
|
// so without this `--check` reports an empty plan for a run that writes.
|
|
2628
|
-
return
|
|
2827
|
+
return refreshInstalledTargetOverlays(
|
|
2629
2828
|
path.resolve(options.repo || process.cwd()),
|
|
2630
2829
|
options.target,
|
|
2631
2830
|
{ dryRun: true }
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.89.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.89.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.89.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.89.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",
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Hand-off to an installed update (issue #204), Claude Code only.
|
|
4
|
+
//
|
|
5
|
+
// Claude binds a session's hooks to the version directory it loaded,
|
|
6
|
+
// <plugins>/cache/<marketplace>/<plugin>/<version>, and keeps that directory
|
|
7
|
+
// after an update, so a running session would go on executing these scripts
|
|
8
|
+
// until `/reload-plugins`. The host records what it installed in
|
|
9
|
+
// <plugins>/installed_plugins.json (#172). When that record names another
|
|
10
|
+
// install of this same plugin — a newer version with the same major, holding
|
|
11
|
+
// the same script — the loaded script runs that copy with the same arguments
|
|
12
|
+
// and input and relays what it printed and how it exited.
|
|
13
|
+
//
|
|
14
|
+
// Codex resolves the plugin root again at every hook call, so its sessions
|
|
15
|
+
// already run the installed version; its cache has no record beside the
|
|
16
|
+
// package root and no hand-off happens there.
|
|
17
|
+
//
|
|
18
|
+
// Anything unexpected is no hand-off: the loaded script then runs exactly as
|
|
19
|
+
// it would without this file. Local and offline; nothing is installed,
|
|
20
|
+
// fetched, or written.
|
|
21
|
+
|
|
22
|
+
const fs = require("fs");
|
|
23
|
+
const path = require("path");
|
|
24
|
+
const { spawnSync } = require("child_process");
|
|
25
|
+
|
|
26
|
+
const MARKER = "KEEL_HOOK_FORWARDED";
|
|
27
|
+
|
|
28
|
+
function pluginVersion(pluginDir) {
|
|
29
|
+
try {
|
|
30
|
+
const manifest = path.join(pluginDir, ".claude-plugin", "plugin.json");
|
|
31
|
+
const value = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
32
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parts(version) {
|
|
39
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version || "");
|
|
40
|
+
return match ? match.slice(1, 4).map(Number) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Only a newer release in the same major. A different major is allowed to
|
|
44
|
+
// change what a hook receives or returns, which a loaded script must not
|
|
45
|
+
// relay on the new copy's behalf.
|
|
46
|
+
function compatibleNewer(running, candidate) {
|
|
47
|
+
const a = parts(running);
|
|
48
|
+
const b = parts(candidate);
|
|
49
|
+
if (!a || !b || a[0] !== b[0]) return false;
|
|
50
|
+
for (let i = 1; i < 3; i += 1) {
|
|
51
|
+
if (b[i] !== a[i]) return b[i] > a[i];
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The one other install of this plugin the host recorded, compared through
|
|
57
|
+
// real paths the way session-start.js's pendingInstall does.
|
|
58
|
+
function recordedInstall(root) {
|
|
59
|
+
const record = path.join(root, "..", "..", "..", "..", "installed_plugins.json");
|
|
60
|
+
const plugins = JSON.parse(fs.readFileSync(record, "utf8")).plugins;
|
|
61
|
+
const found = new Set();
|
|
62
|
+
for (const entries of Object.values(plugins || {})) {
|
|
63
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
64
|
+
if (!entry || typeof entry.installPath !== "string") continue;
|
|
65
|
+
let installPath;
|
|
66
|
+
try {
|
|
67
|
+
installPath = fs.realpathSync(path.resolve(entry.installPath));
|
|
68
|
+
} catch {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (path.dirname(installPath) !== path.dirname(root)) continue;
|
|
72
|
+
if (installPath === root) continue;
|
|
73
|
+
found.add(installPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return found.size === 1 ? [...found][0] : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Where this script's newer copy is, or null for no hand-off.
|
|
80
|
+
function handOffTarget(scriptFile) {
|
|
81
|
+
if (process.env[MARKER]) return null;
|
|
82
|
+
try {
|
|
83
|
+
const scriptDir = path.dirname(fs.realpathSync(scriptFile));
|
|
84
|
+
const pluginDir = path.dirname(scriptDir);
|
|
85
|
+
const root = path.dirname(path.dirname(pluginDir));
|
|
86
|
+
// A Claude install is the tagged repository: its root carries the Claude
|
|
87
|
+
// manifest and the plugin under plugins/keel. A Codex install is the
|
|
88
|
+
// plugin directory itself and has neither.
|
|
89
|
+
if (!fs.existsSync(path.join(root, ".claude-plugin", "plugin.json"))) return null;
|
|
90
|
+
const running = pluginVersion(pluginDir);
|
|
91
|
+
if (!running) return null;
|
|
92
|
+
const other = recordedInstall(root);
|
|
93
|
+
if (!other) return null;
|
|
94
|
+
const relative = path.relative(root, path.join(scriptDir, path.basename(scriptFile)));
|
|
95
|
+
const script = path.join(other, relative);
|
|
96
|
+
const otherPlugin = path.join(other, path.relative(root, pluginDir));
|
|
97
|
+
const version = pluginVersion(otherPlugin);
|
|
98
|
+
if (!compatibleNewer(running, version) || !fs.existsSync(script)) return null;
|
|
99
|
+
return { script, root: other, running, version };
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Runs the newer copy of `scriptFile` with `input` on stdin when there is one.
|
|
106
|
+
// Returns its exit status after relaying its output, or null when there was no
|
|
107
|
+
// hand-off or the copy could not run to completion — a spawn error, a timeout,
|
|
108
|
+
// or a signal — in which case nothing has been written and the caller runs its
|
|
109
|
+
// own logic.
|
|
110
|
+
function handOff(scriptFile, input, timeoutMs) {
|
|
111
|
+
const target = handOffTarget(scriptFile);
|
|
112
|
+
if (!target) return null;
|
|
113
|
+
const budget = Number(process.env.KEEL_HOOK_FORWARD_TIMEOUT_MS || timeoutMs) || timeoutMs;
|
|
114
|
+
const result = spawnSync(process.execPath, [target.script, ...process.argv.slice(2)], {
|
|
115
|
+
input,
|
|
116
|
+
encoding: "utf8",
|
|
117
|
+
timeout: budget,
|
|
118
|
+
env: { ...process.env, [MARKER]: target.running, CLAUDE_PLUGIN_ROOT: target.root },
|
|
119
|
+
});
|
|
120
|
+
if (result.error || result.signal || typeof result.status !== "number") return null;
|
|
121
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
122
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
123
|
+
return result.status;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { handOff, handOffTarget, MARKER };
|
|
@@ -18,6 +18,16 @@ const fs = require("fs");
|
|
|
18
18
|
const path = require("path");
|
|
19
19
|
const { spawnSync } = require("child_process");
|
|
20
20
|
|
|
21
|
+
// A newer installed copy of this script runs in its place when the host has
|
|
22
|
+
// installed one (forward.js, #204). A copy of this script without forward.js
|
|
23
|
+
// beside it simply runs its own logic.
|
|
24
|
+
let handOff = () => null;
|
|
25
|
+
try {
|
|
26
|
+
({ handOff } = require("./forward"));
|
|
27
|
+
} catch {
|
|
28
|
+
// Copied on its own: no hand-off.
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
const EVENTS = new Set(["session-start", "user-prompt-submit", "file-changed", "session-end"]);
|
|
22
32
|
const TIMEOUT_MS = Number(process.env.KEEL_HOOK_TIMEOUT_MS || 8000) || 8000;
|
|
23
33
|
|
|
@@ -53,6 +63,8 @@ function main() {
|
|
|
53
63
|
const event = process.argv[2];
|
|
54
64
|
if (!EVENTS.has(event)) return 0;
|
|
55
65
|
const input = readStdin();
|
|
66
|
+
const handed = handOff(__filename, input, 9000);
|
|
67
|
+
if (handed !== null) return handed;
|
|
56
68
|
let cwd = process.cwd();
|
|
57
69
|
try {
|
|
58
70
|
const parsed = JSON.parse(input || "{}");
|