@christang/keel 5.231.13 → 5.232.1
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/README.md +5 -3
- package/README.zh-CN.md +5 -3
- package/assets/bootstrap/AGENTS.md +2 -2
- package/bin/keel.js +196 -39
- 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/hooks.json +23 -0
- package/plugins/keel/plugin.json +10 -0
- package/plugins/keel/scripts/pretooluse-guard.js +42 -1
- package/plugins/keel/scripts/session-start.js +61 -9
- package/scripts/bump_version.js +3 -0
- package/scripts/install_to_repo.py +4 -3
- package/scripts/validation/agy.py +895 -0
- package/scripts/validation/baseline.py +19 -3
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/hosts.py +7 -3
- package/scripts/validation/registry.py +7 -0
- package/src/core/capabilities.js +65 -13
- package/src/core/gates.js +3 -3
- package/src/core/projection.js +1 -1
|
@@ -43,10 +43,28 @@ function readStdin() {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function cliHost(argv = process.argv.slice(2)) {
|
|
47
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
48
|
+
if (argv[i] === "--host" && argv[i + 1]) return argv[i + 1].trim().toLowerCase();
|
|
49
|
+
if (argv[i].startsWith("--host=")) return argv[i].slice("--host=".length).trim().toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isAgyEvent(event) {
|
|
55
|
+
if (cliHost() === "agy") return true;
|
|
56
|
+
return Boolean(event && typeof event === "object" && event.toolCall && typeof event.toolCall === "object");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let agyMode = cliHost() === "agy";
|
|
46
60
|
let denied = false;
|
|
47
61
|
|
|
48
62
|
function deny(reason) {
|
|
49
63
|
denied = true;
|
|
64
|
+
if (agyMode) {
|
|
65
|
+
process.stdout.write(`${JSON.stringify({ decision: "deny", reason })}\n`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
50
68
|
process.stdout.write(
|
|
51
69
|
`${JSON.stringify({
|
|
52
70
|
hookSpecificOutput: {
|
|
@@ -59,8 +77,13 @@ function deny(reason) {
|
|
|
59
77
|
}
|
|
60
78
|
|
|
61
79
|
// Hand the decision to the user for this one call (#280): the host asks, and
|
|
62
|
-
// nothing is stored, so the next call is asked again.
|
|
80
|
+
// nothing is stored, so the next call is asked again. On AGY, `force_ask`
|
|
81
|
+
// ignores any cached Always Allow rule so every protected push asks again.
|
|
63
82
|
function ask(reason) {
|
|
83
|
+
if (agyMode) {
|
|
84
|
+
process.stdout.write(`${JSON.stringify({ decision: "force_ask", reason })}\n`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
64
87
|
process.stdout.write(
|
|
65
88
|
`${JSON.stringify({
|
|
66
89
|
hookSpecificOutput: {
|
|
@@ -773,6 +796,7 @@ function main(suppliedEvent = null) {
|
|
|
773
796
|
} catch {
|
|
774
797
|
event = {};
|
|
775
798
|
}
|
|
799
|
+
agyMode = isAgyEvent(event);
|
|
776
800
|
const repo =
|
|
777
801
|
typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
|
|
778
802
|
|
|
@@ -784,6 +808,23 @@ function main(suppliedEvent = null) {
|
|
|
784
808
|
if (handed !== null) return handed;
|
|
785
809
|
}
|
|
786
810
|
|
|
811
|
+
// Normalize AGY `toolCall` payloads into the shared Touch and push evaluators.
|
|
812
|
+
// Pass-through returns 0 with empty stdout so AGY's own permission policy
|
|
813
|
+
// remains authoritative and is never bypassed by an explicit allow.
|
|
814
|
+
if (event.toolCall && typeof event.toolCall === "object") {
|
|
815
|
+
const toolName = event.toolCall.name;
|
|
816
|
+
const args = event.toolCall.args && typeof event.toolCall.args === "object"
|
|
817
|
+
? event.toolCall.args
|
|
818
|
+
: {};
|
|
819
|
+
if (toolName === "edit_file" || toolName === "write_file") {
|
|
820
|
+
event = { ...event, tool_name: "Edit", tool_input: { file_path: args.Path } };
|
|
821
|
+
} else if (toolName === "run_command") {
|
|
822
|
+
event = { ...event, tool_name: "Bash", tool_input: { command: args.CommandLine } };
|
|
823
|
+
} else {
|
|
824
|
+
return 0;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
787
828
|
if (event.tool_name === "apply_patch") {
|
|
788
829
|
const patch = typeof event.tool_input === "string" ? event.tool_input
|
|
789
830
|
: event.tool_input && (event.tool_input.command || event.tool_input.patch || event.tool_input.input);
|
|
@@ -36,6 +36,25 @@ const TIMEOUT_MS = Number(process.env.KEEL_HOOK_TIMEOUT_MS || 8000) || 8000;
|
|
|
36
36
|
const MAX_REASONS = 3;
|
|
37
37
|
const MAX_REASON_LENGTH = 300;
|
|
38
38
|
|
|
39
|
+
function cliHost(argv = process.argv.slice(2)) {
|
|
40
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
41
|
+
if (argv[i] === "--host" && argv[i + 1]) return argv[i + 1].trim().toLowerCase();
|
|
42
|
+
if (argv[i].startsWith("--host=")) return argv[i].slice("--host=".length).trim().toLowerCase();
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isAgyEvent(event) {
|
|
48
|
+
if (cliHost() === "agy") return true;
|
|
49
|
+
if (!event || typeof event !== "object") return false;
|
|
50
|
+
if (event.hookEventName === "SessionStart") return true;
|
|
51
|
+
if (typeof event.conversationId === "string" && event.conversationId) return true;
|
|
52
|
+
if (Array.isArray(event.workspacePaths)) return true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let agyMode = cliHost() === "agy";
|
|
57
|
+
|
|
39
58
|
function readStdin() {
|
|
40
59
|
try {
|
|
41
60
|
return fs.readFileSync(0, "utf8");
|
|
@@ -49,7 +68,18 @@ function readStdin() {
|
|
|
49
68
|
// channel, not a replacement: `additionalContext` still carries the full
|
|
50
69
|
// projection to the agent, and a host that does not recognize the field simply
|
|
51
70
|
// ignores it and leaves today's behavior intact.
|
|
71
|
+
// On AGY, SessionStart expects `injectSteps: [{ systemMessage: { systemMessage } }]`
|
|
72
|
+
// without `metadata` (probed on agy 1.5.20: adding `metadata.user_markdown`
|
|
73
|
+
// caused the injected step to be dropped).
|
|
52
74
|
function emit(context, humanMessage) {
|
|
75
|
+
if (agyMode) {
|
|
76
|
+
process.stdout.write(
|
|
77
|
+
`${JSON.stringify({
|
|
78
|
+
injectSteps: [{ systemMessage: { systemMessage: context } }],
|
|
79
|
+
})}\n`
|
|
80
|
+
);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
53
83
|
const payload = {};
|
|
54
84
|
if (humanMessage) payload.systemMessage = humanMessage;
|
|
55
85
|
payload.hookSpecificOutput = {
|
|
@@ -123,19 +153,29 @@ function precedentPointer(cwd) {
|
|
|
123
153
|
// Keel has verified; an unprobed target gets a description instead of an
|
|
124
154
|
// invented command line.
|
|
125
155
|
const HOST_UPDATE = "your host's own plugin update command";
|
|
156
|
+
const AGY_UPDATE = "updating your AGY Keel plugin source or reinstalling via `agy plugin`";
|
|
126
157
|
|
|
127
158
|
// The plugin's own manifest sits beside this script, so its version is read
|
|
128
159
|
// from `__dirname` rather than from CLAUDE_PLUGIN_ROOT: the path this file was
|
|
129
160
|
// loaded from is a fact, while an environment variable is a claim the host may
|
|
130
161
|
// not have made. Whichever target's manifest is present is the one that ran.
|
|
131
162
|
function pluginManifest() {
|
|
132
|
-
const targets =
|
|
133
|
-
[
|
|
134
|
-
|
|
135
|
-
|
|
163
|
+
const targets = agyMode
|
|
164
|
+
? [
|
|
165
|
+
["", AGY_UPDATE],
|
|
166
|
+
[".claude-plugin", "`claude plugin update`"],
|
|
167
|
+
[".codex-plugin", HOST_UPDATE],
|
|
168
|
+
]
|
|
169
|
+
: [
|
|
170
|
+
[".claude-plugin", "`claude plugin update`"],
|
|
171
|
+
[".codex-plugin", HOST_UPDATE],
|
|
172
|
+
["", AGY_UPDATE],
|
|
173
|
+
];
|
|
136
174
|
for (const [dir, remedy] of targets) {
|
|
137
175
|
try {
|
|
138
|
-
const manifest =
|
|
176
|
+
const manifest = dir
|
|
177
|
+
? path.join(__dirname, "..", dir, "plugin.json")
|
|
178
|
+
: path.join(__dirname, "..", "plugin.json");
|
|
139
179
|
const value = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
140
180
|
if (typeof value === "string" && value.trim()) {
|
|
141
181
|
return { version: value.trim(), remedy };
|
|
@@ -144,7 +184,7 @@ function pluginManifest() {
|
|
|
144
184
|
// A missing or unreadable manifest is undiscoverable, not drift.
|
|
145
185
|
}
|
|
146
186
|
}
|
|
147
|
-
return { version: null, remedy: HOST_UPDATE };
|
|
187
|
+
return { version: null, remedy: agyMode ? AGY_UPDATE : HOST_UPDATE };
|
|
148
188
|
}
|
|
149
189
|
|
|
150
190
|
// On Claude the plugin is the repository's tagged tree, cached at
|
|
@@ -310,9 +350,12 @@ function versionReport(cwd, cli, pathCli = null) {
|
|
|
310
350
|
+ "the command `keel context` names on its Protocol: line.");
|
|
311
351
|
}
|
|
312
352
|
const remedy = parts.join(" ");
|
|
353
|
+
const reloadAdvice = agyMode
|
|
354
|
+
? "at the next session start."
|
|
355
|
+
: "after `/reload-plugins` or at the next session start.";
|
|
313
356
|
return `runtime versions disagree: ${named}${missing}. A session's hooks are `
|
|
314
|
-
+
|
|
315
|
-
+
|
|
357
|
+
+ `fixed when it loads the plugin, so an updated plugin applies ${reloadAdvice} `
|
|
358
|
+
+ `${remedy}${shadow}`;
|
|
316
359
|
}
|
|
317
360
|
|
|
318
361
|
// A handed-off run (forward.js, #204) executes the installed version, so its
|
|
@@ -549,8 +592,17 @@ function main() {
|
|
|
549
592
|
} catch {
|
|
550
593
|
event = {};
|
|
551
594
|
}
|
|
595
|
+
agyMode = isAgyEvent(event);
|
|
596
|
+
const workspacePath =
|
|
597
|
+
Array.isArray(event.workspacePaths)
|
|
598
|
+
&& typeof event.workspacePaths[0] === "string"
|
|
599
|
+
&& event.workspacePaths[0]
|
|
600
|
+
? event.workspacePaths[0]
|
|
601
|
+
: "";
|
|
552
602
|
const cwd =
|
|
553
|
-
typeof event.cwd === "string" && event.cwd
|
|
603
|
+
typeof event.cwd === "string" && event.cwd
|
|
604
|
+
? event.cwd
|
|
605
|
+
: (workspacePath || process.cwd());
|
|
554
606
|
|
|
555
607
|
if (!fs.existsSync(path.join(cwd, "openspec"))) {
|
|
556
608
|
return shiftOnly(cwd);
|
package/scripts/bump_version.js
CHANGED
|
@@ -179,6 +179,9 @@ function main() {
|
|
|
179
179
|
|
|
180
180
|
bumpPackageFiles(newVersion);
|
|
181
181
|
bumpClaudeMarketplace(newVersion);
|
|
182
|
+
replaceInFile("plugins/keel/plugin.json", [
|
|
183
|
+
[`"version": "${oldVersion}"`, `"version": "${newVersion}"`],
|
|
184
|
+
]);
|
|
182
185
|
replaceInFile("plugins/keel/.claude-plugin/plugin.json", [
|
|
183
186
|
[`"version": "${oldVersion}"`, `"version": "${newVersion}"`],
|
|
184
187
|
]);
|
|
@@ -73,12 +73,13 @@ MANAGED_START = _bootstrap_marker()
|
|
|
73
73
|
CLAUDE_IMPORT_BLOCK = f"{MANAGED_START}\n@AGENTS.md\n{MANAGED_END}\n"
|
|
74
74
|
KEEL_HOOK_NAME = "keel-gate"
|
|
75
75
|
KEEL_HOOK_ROOT = Path(".claude") / "hooks" / KEEL_HOOK_NAME
|
|
76
|
-
SUPPORTED_TARGETS = ("claude", "codex", "opencode")
|
|
77
|
-
AGENT_PROTOCOL_TARGETS = {"codex", "opencode"}
|
|
76
|
+
SUPPORTED_TARGETS = ("claude", "codex", "opencode", "agy")
|
|
77
|
+
AGENT_PROTOCOL_TARGETS = {"codex", "opencode", "agy"}
|
|
78
78
|
TARGET_ADAPTER_PATHS = {
|
|
79
79
|
"claude": Path(".claude") / "keel" / "keel-adapter.js",
|
|
80
80
|
"codex": Path(".agents") / "keel" / "keel-adapter.js",
|
|
81
81
|
"opencode": Path(".opencode") / "keel" / "keel-adapter.js",
|
|
82
|
+
"agy": Path(".agents") / "keel" / "keel-adapter.js",
|
|
82
83
|
}
|
|
83
84
|
HANDOFF_FIELDS = {"schema", "owner", "action", "reason"}
|
|
84
85
|
HANDOFF_ACTIONS = {
|
|
@@ -1445,7 +1446,7 @@ def main() -> int:
|
|
|
1445
1446
|
parser.add_argument("repo", help="Target repository path.")
|
|
1446
1447
|
parser.add_argument(
|
|
1447
1448
|
"--target",
|
|
1448
|
-
choices=["both", "claude", "codex", "opencode"],
|
|
1449
|
+
choices=["both", "claude", "codex", "opencode", "agy"],
|
|
1449
1450
|
default="claude",
|
|
1450
1451
|
help="Protocol target to install. Defaults to claude; both is a legacy alias for claude.",
|
|
1451
1452
|
)
|