@christang/keel 5.138.0 → 5.139.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 +4 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- 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/pretooluse-guard.js +53 -7
- package/scripts/validate_plugin.py +108 -2
package/README.md
CHANGED
|
@@ -223,7 +223,10 @@ Declare one entry per glob; `*` matches within one `/` segment and `**` across t
|
|
|
223
223
|
other scope, this one is enforced: while any `push:` glob is declared, the Claude write guard checks
|
|
224
224
|
every `git push` a `Bash` call runs, with or without a task, and refuses one to any other branch, or
|
|
225
225
|
one whose target it cannot tell — `--all`, `--mirror`, `--tags`, a shell variable, no configured
|
|
226
|
-
push destination — naming `git push origin <branch>` instead. A
|
|
226
|
+
push destination — naming `git push origin <branch>` instead. A push that also carries annotated
|
|
227
|
+
tags — `--follow-tags`, or `push.followTags` set in git config — is a tag push (#327): no `push:`
|
|
228
|
+
glob allows it, so it is refused naming `--no-follow-tags`, unless every branch it pushes is
|
|
229
|
+
`push-protected`, where it is asked about like any protected push. A bare `push` keeps its old meaning,
|
|
227
230
|
and declaring it beside a `push:` glob is refused, because it would silently widen the glob. Codex
|
|
228
231
|
has no such hook, so there the scope is carried, not enforced.
|
|
229
232
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.139.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.139.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.139.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.139.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",
|
|
@@ -368,8 +368,13 @@ function findPushes(command, cwd) {
|
|
|
368
368
|
let cdBefore = false;
|
|
369
369
|
for (const words of shellSegments(command)) {
|
|
370
370
|
let i = 0;
|
|
371
|
-
|
|
372
|
-
while (i < words.length
|
|
371
|
+
const assigned = [];
|
|
372
|
+
while (i < words.length) {
|
|
373
|
+
const assignment = words[i].text.match(/^([A-Za-z_][A-Za-z0-9_]*)=/);
|
|
374
|
+
if (assignment) assigned.push(assignment[1]);
|
|
375
|
+
else if (!PREFIX_COMMANDS.has(words[i].text)) break;
|
|
376
|
+
i += 1;
|
|
377
|
+
}
|
|
373
378
|
const head = words[i] ? words[i].text : "";
|
|
374
379
|
if (head === "cd" || head === "pushd") {
|
|
375
380
|
cdBefore = true;
|
|
@@ -385,12 +390,16 @@ function findPushes(command, cwd) {
|
|
|
385
390
|
let dir = cwd;
|
|
386
391
|
i += 1;
|
|
387
392
|
let unknownGlobal = null;
|
|
393
|
+
let expandedConfig = null;
|
|
394
|
+
const config = [];
|
|
388
395
|
while (i < words.length && words[i].text.startsWith("-")) {
|
|
389
396
|
const option = words[i].text;
|
|
390
397
|
if (option === "-C" && words[i + 1]) {
|
|
391
398
|
dir = path.resolve(dir, words[i + 1].text);
|
|
392
399
|
i += 2;
|
|
393
400
|
} else if (option === "-c" && words[i + 1]) {
|
|
401
|
+
if (words[i + 1].expands) expandedConfig = words[i + 1].text;
|
|
402
|
+
config.push("-c", words[i + 1].text);
|
|
394
403
|
i += 2;
|
|
395
404
|
} else if (option === "--no-pager" || option === "-P") {
|
|
396
405
|
i += 1;
|
|
@@ -404,7 +413,18 @@ function findPushes(command, cwd) {
|
|
|
404
413
|
pushes.push({ undetermined: `the git option \`${unknownGlobal}\` is not one the guard reads` });
|
|
405
414
|
continue;
|
|
406
415
|
}
|
|
407
|
-
|
|
416
|
+
if (expandedConfig) {
|
|
417
|
+
pushes.push({ undetermined: `the git config \`-c ${expandedConfig}\` is expanded by the shell` });
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
// A GIT_CONFIG* assignment can turn on push.followTags for this command
|
|
421
|
+
// only, where the guard cannot read it (#327).
|
|
422
|
+
const configVar = assigned.find((name) => name.startsWith("GIT_CONFIG"));
|
|
423
|
+
if (configVar) {
|
|
424
|
+
pushes.push({ undetermined: `\`${configVar}\` sets git config the guard cannot read` });
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
pushes.push({ dir, cdBefore, config, args: words.slice(i + 1) });
|
|
408
428
|
}
|
|
409
429
|
return pushes;
|
|
410
430
|
}
|
|
@@ -429,6 +449,7 @@ function pushTargets(push) {
|
|
|
429
449
|
if (push.undetermined) return push;
|
|
430
450
|
const positionals = [];
|
|
431
451
|
let deleting = false;
|
|
452
|
+
let followTags = null;
|
|
432
453
|
for (let i = 0; i < push.args.length; i += 1) {
|
|
433
454
|
const word = push.args[i];
|
|
434
455
|
if (word.expands) return { undetermined: `\`${word.text}\` is expanded by the shell` };
|
|
@@ -444,6 +465,8 @@ function pushTargets(push) {
|
|
|
444
465
|
const name = text.includes("=") ? text.slice(0, text.indexOf("=")) : text;
|
|
445
466
|
if (PUSH_UNDETERMINED.has(name)) return { undetermined: `\`${name}\` pushes refs the guard cannot list` };
|
|
446
467
|
if (name === "-d" || name === "--delete") deleting = true;
|
|
468
|
+
if (name === "--follow-tags") followTags = true;
|
|
469
|
+
if (name === "--no-follow-tags") followTags = false;
|
|
447
470
|
if (PUSH_VALUED.has(name)) {
|
|
448
471
|
if (!text.includes("=")) i += 1;
|
|
449
472
|
continue;
|
|
@@ -458,6 +481,14 @@ function pushTargets(push) {
|
|
|
458
481
|
}
|
|
459
482
|
return { undetermined: `the push option \`${text}\` is not one the guard reads` };
|
|
460
483
|
}
|
|
484
|
+
// A push that carries annotated tags is a tag push (#327). git resolves the
|
|
485
|
+
// config itself, so boolean spellings, key case and `-c` order are its own.
|
|
486
|
+
let tags = null;
|
|
487
|
+
if (followTags === true) tags = "`--follow-tags`";
|
|
488
|
+
else if (followTags === null && gitOut(push.dir,
|
|
489
|
+
[...(push.config || []), "config", "--type=bool", "--get", "push.followTags"]) === "true") {
|
|
490
|
+
tags = "`push.followTags`";
|
|
491
|
+
}
|
|
461
492
|
const refspecs = positionals.slice(1);
|
|
462
493
|
const needsCurrent = () => {
|
|
463
494
|
if (push.cdBefore) return { undetermined: "the directory changes before it, so its branch is unknown here" };
|
|
@@ -467,7 +498,7 @@ function pushTargets(push) {
|
|
|
467
498
|
const unknown = needsCurrent();
|
|
468
499
|
if (unknown) return unknown;
|
|
469
500
|
const branch = pushDestination(push.dir);
|
|
470
|
-
return branch ? { targets: [branch] } : { undetermined: "the branch has no configured push destination" };
|
|
501
|
+
return branch ? { targets: [branch], tags } : { undetermined: "the branch has no configured push destination" };
|
|
471
502
|
}
|
|
472
503
|
const targets = [];
|
|
473
504
|
for (const raw of refspecs) {
|
|
@@ -486,7 +517,7 @@ function pushTargets(push) {
|
|
|
486
517
|
else if (dst.startsWith("refs/")) return { undetermined: `\`${raw}\` is not a branch` };
|
|
487
518
|
targets.push(dst);
|
|
488
519
|
}
|
|
489
|
-
return { targets };
|
|
520
|
+
return { targets, tags };
|
|
490
521
|
}
|
|
491
522
|
|
|
492
523
|
function checkPushes(event) {
|
|
@@ -495,6 +526,7 @@ function checkPushes(event) {
|
|
|
495
526
|
if (!/\bgit\b/.test(command) || !/\bpush\b/.test(command)) return 0;
|
|
496
527
|
const cwd = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
|
|
497
528
|
const asks = [];
|
|
529
|
+
let carriesTags = false;
|
|
498
530
|
for (const push of findPushes(command, cwd)) {
|
|
499
531
|
const top = gitOut(push.dir || cwd, ["rev-parse", "--show-toplevel"]);
|
|
500
532
|
if (!top) continue;
|
|
@@ -513,7 +545,20 @@ function checkPushes(event) {
|
|
|
513
545
|
);
|
|
514
546
|
return 0;
|
|
515
547
|
}
|
|
516
|
-
|
|
548
|
+
// A push carrying tags passes on no `push:` glob; only a protected
|
|
549
|
+
// branch's ask can carry it, so each branch must be a protected one.
|
|
550
|
+
if (result.tags && !result.targets.every((b) => protectedEntries.some((e) => globPattern(e.glob).test(b)))) {
|
|
551
|
+
deny(
|
|
552
|
+
`Keel push guard: this push also pushes annotated tags (${result.tags}), and `
|
|
553
|
+
+ `keel/config.yaml limits push to ${declared}; no \`push:\` grant covers tags. Push the `
|
|
554
|
+
+ "branch alone with `--no-follow-tags`, or ask the owner to publish the tags."
|
|
555
|
+
);
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
if (result.tags) carriesTags = true;
|
|
559
|
+
const unlisted = result.tags
|
|
560
|
+
? result.targets
|
|
561
|
+
: result.targets.filter((branch) => !globs.some((glob) => globPattern(glob).test(branch)));
|
|
517
562
|
const outside = [];
|
|
518
563
|
for (const branch of unlisted) {
|
|
519
564
|
const entry = protectedEntries.find((e) => globPattern(e.glob).test(branch));
|
|
@@ -554,9 +599,10 @@ function checkPushes(event) {
|
|
|
554
599
|
);
|
|
555
600
|
return 0;
|
|
556
601
|
}
|
|
602
|
+
const tagNote = carriesTags ? " This push also pushes annotated tags (`--follow-tags` or `push.followTags`)." : "";
|
|
557
603
|
ask(
|
|
558
604
|
`Keel push guard: ${branches} is a protected branch (keel/config.yaml `
|
|
559
|
-
+
|
|
605
|
+
+ `push-protected).${tagNote} Confirm only if the user approves this one push; the next push asks again.`
|
|
560
606
|
);
|
|
561
607
|
}
|
|
562
608
|
return 0;
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.139.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.139.0"
|
|
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
|
|
@@ -32164,6 +32164,111 @@ def validate_push_guard_redirects_scenario() -> int:
|
|
|
32164
32164
|
return 0
|
|
32165
32165
|
|
|
32166
32166
|
|
|
32167
|
+
def validate_push_guard_follow_tags_scenario() -> int:
|
|
32168
|
+
"""Issue #327: a push that carries annotated tags is a tag push.
|
|
32169
|
+
|
|
32170
|
+
The real hook denies `--follow-tags`, `push.followTags` from the repository
|
|
32171
|
+
config or `git -c`, and a `GIT_CONFIG*` assignment on a `push:` branch;
|
|
32172
|
+
turning tag carriage off restores the branch push; a protected branch is
|
|
32173
|
+
asked about with its tags; and nothing is checked without a push scope.
|
|
32174
|
+
"""
|
|
32175
|
+
label = "push-guard-follow-tags:"
|
|
32176
|
+
with tempfile.TemporaryDirectory(prefix="keel-push-follow-tags-") as raw:
|
|
32177
|
+
base = Path(raw)
|
|
32178
|
+
repo = mailbox_repository(base / "repo")
|
|
32179
|
+
pm = chat_worktree(repo, base / "pm")
|
|
32180
|
+
rtl = chat_worktree(repo, base / "rtl")
|
|
32181
|
+
env = chat_environment()
|
|
32182
|
+
run_keel(pm, "chat", "role", "--set", "iecc-pm", env=env)
|
|
32183
|
+
run_keel(rtl, "chat", "role", "--set", "rtl", env=env)
|
|
32184
|
+
hook_env = {
|
|
32185
|
+
k: v for k, v in os.environ.items()
|
|
32186
|
+
if k not in ("KEEL_CHAT_ROLE", "KEEL_MAIL_ROLE") and not k.startswith("GIT_CONFIG")
|
|
32187
|
+
}
|
|
32188
|
+
hook_env["CLAUDE_PLUGIN_ROOT"] = str(ROOT / PLUGIN_ROOT)
|
|
32189
|
+
|
|
32190
|
+
def declare(entries: list[str]) -> None:
|
|
32191
|
+
for cwd in (pm, rtl):
|
|
32192
|
+
write_authorize_config(cwd, "authorize:\n" + "".join(f" - {e}\n" for e in entries))
|
|
32193
|
+
|
|
32194
|
+
def decide(cwd: Path, command: str) -> dict:
|
|
32195
|
+
event = {"tool_name": "Bash", "tool_input": {"command": command}, "cwd": str(cwd), "permission_mode": "default"}
|
|
32196
|
+
result = subprocess.run(
|
|
32197
|
+
["node", str(ROOT / PLUGIN_ROOT / "scripts/pretooluse-guard.js")],
|
|
32198
|
+
cwd=cwd, env=hook_env, input=json.dumps(event), text=True, capture_output=True, check=False,
|
|
32199
|
+
)
|
|
32200
|
+
return pretooluse_decision(result) or {"permissionDecision": "pass"}
|
|
32201
|
+
|
|
32202
|
+
def expect(what: str, cwd: Path, command: str, want: str, needles: tuple[str, ...] = ()) -> bool:
|
|
32203
|
+
decision = decide(cwd, command)
|
|
32204
|
+
if decision.get("permissionDecision") != want:
|
|
32205
|
+
verdict = "allowed" if decision.get("permissionDecision") == "pass" else decision.get("permissionDecision")
|
|
32206
|
+
report(f"{label} {what} was {verdict}, not {want} ({command!r}): {decision!r}")
|
|
32207
|
+
return False
|
|
32208
|
+
reason = decision.get("permissionDecisionReason", "")
|
|
32209
|
+
for needle in needles:
|
|
32210
|
+
if needle not in reason:
|
|
32211
|
+
report(f"{label} {what} does not name {needle!r}: {reason!r}")
|
|
32212
|
+
return False
|
|
32213
|
+
return True
|
|
32214
|
+
|
|
32215
|
+
def set_follow_tags(value: str | None) -> None:
|
|
32216
|
+
args = ["config", "push.followTags", value] if value else ["config", "--unset", "push.followTags"]
|
|
32217
|
+
subprocess.run(["git", *args], cwd=rtl, check=False, capture_output=True)
|
|
32218
|
+
|
|
32219
|
+
declare(["push:flow-*"])
|
|
32220
|
+
branch = "origin flow-release"
|
|
32221
|
+
if not expect("--follow-tags push to a granted branch", rtl, f"git push --follow-tags {branch}", "deny",
|
|
32222
|
+
("--follow-tags", "--no-follow-tags")):
|
|
32223
|
+
report(f"{label} --follow-tags push to a granted branch was allowed")
|
|
32224
|
+
return 1
|
|
32225
|
+
if not expect("--follow-tags undone by --no-follow-tags", rtl,
|
|
32226
|
+
f"git push --follow-tags --no-follow-tags {branch}", "pass"):
|
|
32227
|
+
return 1
|
|
32228
|
+
if not expect("a plain push to a granted branch", rtl, f"git push {branch}", "pass"):
|
|
32229
|
+
return 1
|
|
32230
|
+
if not expect("git -c push.followTags=true", rtl, f"git -c push.followTags=true push {branch}", "deny",
|
|
32231
|
+
("push.followTags",)):
|
|
32232
|
+
return 1
|
|
32233
|
+
set_follow_tags("true")
|
|
32234
|
+
if not expect("a plain push under push.followTags=true", rtl, f"git push {branch}", "deny", ("push.followTags",)):
|
|
32235
|
+
return 1
|
|
32236
|
+
if not expect("git -c push.followTags=false over the config", rtl,
|
|
32237
|
+
f"git -c push.followTags=false push {branch}", "pass"):
|
|
32238
|
+
return 1
|
|
32239
|
+
set_follow_tags(None)
|
|
32240
|
+
if not expect("a GIT_CONFIG_COUNT assignment", rtl,
|
|
32241
|
+
f"GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=push.followTags GIT_CONFIG_VALUE_0=true git push {branch}",
|
|
32242
|
+
"deny", ("GIT_CONFIG_COUNT",)):
|
|
32243
|
+
return 1
|
|
32244
|
+
|
|
32245
|
+
if not expect("a GIT_CONFIG_COUNT assignment behind env", rtl,
|
|
32246
|
+
f"env GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=push.followTags GIT_CONFIG_VALUE_0=true git push {branch}",
|
|
32247
|
+
"deny", ("GIT_CONFIG_COUNT",)):
|
|
32248
|
+
return 1
|
|
32249
|
+
if not expect("a shell-expanded git -c", rtl, f'git -c "$CFG" push {branch}', "deny", ("expanded",)):
|
|
32250
|
+
return 1
|
|
32251
|
+
if not expect("a push to main behind `env FOO=1`", rtl, "env FOO=1 git push origin main", "deny", ("`main`",)):
|
|
32252
|
+
return 1
|
|
32253
|
+
|
|
32254
|
+
declare(["push:flow-*", "push-protected:main@iecc-pm"])
|
|
32255
|
+
if not expect("the coordinator's --follow-tags push to main", pm, "git push --follow-tags origin main", "ask",
|
|
32256
|
+
("`main`", "annotated tags")):
|
|
32257
|
+
return 1
|
|
32258
|
+
if not expect("another role's --follow-tags push to main", rtl, "git push --follow-tags origin main", "deny",
|
|
32259
|
+
("iecc-pm",)):
|
|
32260
|
+
return 1
|
|
32261
|
+
if not expect("a --follow-tags push to a granted branch beside a protected one", pm,
|
|
32262
|
+
f"git push --follow-tags {branch}", "deny", ("--no-follow-tags",)):
|
|
32263
|
+
return 1
|
|
32264
|
+
|
|
32265
|
+
declare(["commit"])
|
|
32266
|
+
if not expect("a --follow-tags push with no push scope", rtl, f"git push --follow-tags {branch}", "pass"):
|
|
32267
|
+
return 1
|
|
32268
|
+
report("push-guard-follow-tags scenario passed.")
|
|
32269
|
+
return 0
|
|
32270
|
+
|
|
32271
|
+
|
|
32167
32272
|
def validate_touch_write_guard_scenario() -> int:
|
|
32168
32273
|
with tempfile.TemporaryDirectory(
|
|
32169
32274
|
prefix="keel-touch-guard-", ignore_cleanup_errors=True
|
|
@@ -40948,6 +41053,7 @@ SCENARIOS: tuple = (
|
|
|
40948
41053
|
("touch-write-guard", validate_touch_write_guard_scenario),
|
|
40949
41054
|
("push-branch-guard", validate_push_branch_guard_scenario),
|
|
40950
41055
|
("push-guard-redirects", validate_push_guard_redirects_scenario),
|
|
41056
|
+
("push-guard-follow-tags", validate_push_guard_follow_tags_scenario),
|
|
40951
41057
|
("push-protected-guard", validate_push_protected_guard_scenario),
|
|
40952
41058
|
("touch-guard-record-layer", validate_touch_guard_record_layer_scenario),
|
|
40953
41059
|
("repo-action-mode", validate_repo_action_mode_scenario),
|