bigpowers 2.91.0 → 2.91.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.
Files changed (35) hide show
  1. package/.agents/skills/guard-git/SKILL.md +7 -2
  2. package/.cline/skills/guard-git/SKILL.md +7 -2
  3. package/.codebuddy/skills/guard-git/SKILL.md +7 -2
  4. package/.codex/skills/guard-git/SKILL.md +7 -2
  5. package/.copilot/skills/guard-git/SKILL.md +7 -2
  6. package/.cursor/rules/guard-git.mdc +7 -2
  7. package/.gemini/extensions/bigpowers/commands/prompts/guard-git.md +7 -2
  8. package/.gemini/extensions/bigpowers/gemini-extension.json +1 -1
  9. package/.gemini/extensions/bigpowers/skills/guard-git/SKILL.md +7 -2
  10. package/.hermes/skills/guard-git/SKILL.md +7 -2
  11. package/.kilocode/rules/guard-git.md +7 -2
  12. package/.mimocode/skills/guard-git/SKILL.md +7 -2
  13. package/.opencode/skills/guard-git/SKILL.md +7 -2
  14. package/.pi/package.json +1 -1
  15. package/.pi/prompts/guard-git.md +7 -2
  16. package/.pi/skills/guard-git/SKILL.md +7 -2
  17. package/.qwen/skills/guard-git/SKILL.md +7 -2
  18. package/.trae/skills/guard-git/SKILL.md +7 -2
  19. package/.windsurf/rules/guard-git.md +7 -2
  20. package/.zcode/skills/guard-git/SKILL.md +7 -2
  21. package/CHANGELOG.md +8 -0
  22. package/extensions/omp-hooks.ts +197 -58
  23. package/hooks/pre/bash.sh +54 -7
  24. package/hooks/pre-tool-use.sh +49 -11
  25. package/package.json +1 -1
  26. package/scripts/lib/__pycache__/atomic_write.cpython-310.pyc +0 -0
  27. package/scripts/lib/__pycache__/link_utils.cpython-310.pyc +0 -0
  28. package/scripts/lib/__pycache__/srp_engine_links.cpython-310.pyc +0 -0
  29. package/scripts/lib/__pycache__/srp_engine_okf.cpython-310.pyc +0 -0
  30. package/scripts/lib/git-argv.py +168 -0
  31. package/scripts/lib/golden-suite-gates.sh +2 -0
  32. package/scripts/omp-guard-probe.ts +46 -0
  33. package/scripts/test-guard-git-normalize.sh +189 -0
  34. package/skills/guard-git/SKILL.md +7 -2
  35. package/skills-lock.json +1 -1
@@ -0,0 +1,46 @@
1
+ // story: BUG-2026-11-03-guard-git-flag-normalize
2
+ // story: BUG-2026-11-03-guard-normalize-branch-context
3
+ // omp-guard-probe.ts — evaluate shell commands through the extension's guard,
4
+ // so the TypeScript rules can be held to the same fixture table as
5
+ // hooks/pre-tool-use.sh (scripts/test-guard-git-normalize.sh).
6
+ //
7
+ // Usage: echo '[{"command":"git status","branch":"main"}, …]' | node scripts/omp-guard-probe.ts
8
+ // Prints a JSON array of "block" | "allow", one per input row.
9
+ //
10
+ // It calls evaluateBashCall(), the same pure function the tool_call handler
11
+ // calls — destructive argv rules AND the protected-branch/commit rules. Probing
12
+ // only dangerousGitCommand() compared one rule against a whole hook, which is
13
+ // how "git push --force-with-lease origin main" passed here and failed there.
14
+ //
15
+ // The branch context is supplied per row instead of fixed: protected-branch
16
+ // rules answer differently on `main` than on a feature branch, so a hardcoded
17
+ // branch made the table agree in one direction only and the gate went red the
18
+ // moment it ran on `main`. The harness gives the shell hook the same per-row
19
+ // branch (a throwaway repo checked out on it) and strips GIT_BIGPOWERS_LAND, so
20
+ // neither verdict can depend on the machine or the checked-out branch.
21
+
22
+ import { readFileSync } from "node:fs";
23
+ import { evaluateBashCall } from "../extensions/omp-hooks.ts";
24
+
25
+ const source = readFileSync(new URL("../extensions/omp-hooks.ts", import.meta.url), "utf8");
26
+ const handlerStart = source.indexOf('pi.on("tool_call"');
27
+ if (handlerStart < 0) throw new Error("tool_call handler not found in extensions/omp-hooks.ts");
28
+ if (!source.slice(handlerStart).includes("evaluateBashCall(")) {
29
+ throw new Error("tool_call handler does not call evaluateBashCall() — the guard is not wired");
30
+ }
31
+
32
+ const DEFAULT_BRANCH = "fix/guard-git-normalize";
33
+ type Row = { command: string; branch?: string };
34
+
35
+ const input = JSON.parse(readFileSync(0, "utf8")) as Array<Row | string>;
36
+ const rows: Row[] = input.map((row) => (typeof row === "string" ? { command: row } : row));
37
+ const verdicts = rows.map((row) =>
38
+ evaluateBashCall(row.command, {
39
+ landMode: false,
40
+ hasRepo: true,
41
+ branchFor: () => row.branch ?? DEFAULT_BRANCH,
42
+ })
43
+ ? "block"
44
+ : "allow",
45
+ );
46
+ process.stdout.write(`${JSON.stringify(verdicts)}\n`);
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env bash
2
+ # story: BUG-2026-11-03-guard-git-flag-normalize
3
+ # test-guard-git-normalize.sh — the guard must judge git ARGV, not substrings (#184).
4
+ #
5
+ # Literal patterns miss `git -C repo <destructive>` and `reset -q --hard`: the
6
+ # destructive tokens survive, only their position changes. One fixture table
7
+ # pins four things:
8
+ #
9
+ # (a) the shell hook (hooks/pre-tool-use.sh) reaches the expected verdict
10
+ # (b) the TS extension reaches the same verdict — through evaluateBashCall(),
11
+ # the function the tool_call handler calls, so protected-branch and commit
12
+ # rules are compared too, not only the destructive-argv table
13
+ # (c) the two agree with each other on every row — that is what "consistent
14
+ # across Claude Code, Cursor and Gemini CLI modes" means
15
+ # (d) the rules that share the hook (commits, protected branch, JSON
16
+ # envelopes, the pi/OMP fallback) still behave
17
+ #
18
+ # Both sides run with GIT_BIGPOWERS_LAND stripped: land mode disables the
19
+ # protected-branch block, so an inherited value would let a developer's shell
20
+ # turn a red gate green (BUG-2026-11-03-guard-normalize-parity-vacuous).
21
+ #
22
+ # Both sides also run in a throwaway repo checked out on the row's `branch:`
23
+ # (default: a feature branch). Protected-branch rules answer differently on
24
+ # `main`, so pinning only the probe to a feature branch made the table agree in
25
+ # one direction and go red as soon as CI ran it on `main`
26
+ # (BUG-2026-11-03-guard-normalize-branch-context).
27
+ #
28
+ # The row loop runs inside one Python process: every row x (hook + probe) with a
29
+ # Python start per row cost ~70s on a pyenv host, which is too much for a gate.
30
+ #
31
+ # Usage: bash scripts/test-guard-git-normalize.sh
32
+
33
+ set -euo pipefail
34
+ source "$(dirname "${BASH_SOURCE[0]}")/lib/skill-common.sh"
35
+ resolve_repo_root
36
+ cd "$REPO_ROOT"
37
+ source scripts/lib/python-env.sh
38
+ source scripts/lib/test-assertions.sh
39
+ resolve_python
40
+ TA_PASS=0
41
+ TA_FAIL=0
42
+ FIXTURE="specs/verifications/fixtures/guard-git-normalize.yaml"
43
+
44
+ echo "=== test-guard-git-normalize.sh ==="
45
+
46
+ if [[ ! -f "$FIXTURE" ]]; then
47
+ ta_fail "fixture missing: $FIXTURE"
48
+ echo "$TA_PASS passed, $TA_FAIL failed"
49
+ exit 1
50
+ fi
51
+
52
+ REPORT=$($PYTHON - "$FIXTURE" <<'PY'
53
+ import json, os, subprocess, sys, tempfile, yaml
54
+
55
+ fixture = sys.argv[1]
56
+ # Ambient LAND mode disables the protected-branch block. A gate that depends on
57
+ # the developer's shell is not a gate (this masked a CI failure once).
58
+ ENV = {k: v for k, v in os.environ.items() if k != "GIT_BIGPOWERS_LAND"}
59
+ DEFAULT_BRANCH = "fix/guard-git-normalize"
60
+ cases = yaml.safe_load(open(fixture, encoding="utf-8"))["cases"]
61
+ rows = [{"command": c["command"], "branch": c.get("branch", DEFAULT_BRANCH)} for c in cases]
62
+
63
+ # (b) one node start for every row.
64
+ probe = subprocess.run(
65
+ ["node", "scripts/omp-guard-probe.ts"],
66
+ input=json.dumps(rows), capture_output=True, text=True,
67
+ )
68
+ if probe.returncode != 0:
69
+ print(f"PROBE_ERROR {probe.stderr.strip().splitlines()[-1][:300] if probe.stderr.strip() else 'no stderr'}")
70
+ sys.exit(0)
71
+ ts = json.loads(probe.stdout.strip().splitlines()[-1])
72
+
73
+
74
+ def make_repo(root, branch):
75
+ """A throwaway repo on `branch`, so the hook resolves that branch as HEAD."""
76
+ path = os.path.join(root, f"repo-{len(os.listdir(root))}")
77
+ def git(*args):
78
+ subprocess.run(["git", "-C", path, *args], check=True, capture_output=True)
79
+ subprocess.run(["git", "init", "-q", "-b", "main", path], check=True, capture_output=True)
80
+ git("config", "user.email", "fixture@example.com")
81
+ git("config", "user.name", "fixture")
82
+ git("commit", "-q", "--allow-empty", "-m", "init")
83
+ if branch != "main":
84
+ git("checkout", "-q", "-b", branch)
85
+ return path
86
+
87
+
88
+ hook = os.path.abspath("hooks/pre-tool-use.sh")
89
+ shell_fails = ts_fails = disagree = 0
90
+ with tempfile.TemporaryDirectory() as tmp:
91
+ repos = {}
92
+ for case, row, ts_verdict in zip(cases, rows, ts):
93
+ branch = row["branch"]
94
+ if branch not in repos:
95
+ repos[branch] = make_repo(tmp, branch)
96
+ payload = json.dumps({"command": row["command"]})
97
+ run = subprocess.run(
98
+ ["bash", hook], input=payload, capture_output=True, text=True,
99
+ env=ENV, cwd=repos[branch],
100
+ )
101
+ shell_verdict = "block" if run.returncode == 2 else "allow"
102
+ expected = case["verdict"]
103
+ if shell_verdict != expected:
104
+ shell_fails += 1
105
+ print(f"SHELL_FAIL expected={expected} got={shell_verdict} :: {row['command']}")
106
+ if ts_verdict != expected:
107
+ ts_fails += 1
108
+ print(f"TS_FAIL expected={expected} got={ts_verdict} :: {row['command']}")
109
+ if shell_verdict != ts_verdict:
110
+ disagree += 1
111
+ print(f"PARITY_FAIL shell={shell_verdict} ts={ts_verdict} :: {row['command']}")
112
+
113
+ print(f"RESULT rows={len(cases)} shell_fails={shell_fails} ts_fails={ts_fails} disagree={disagree}")
114
+ PY
115
+ )
116
+
117
+ if [[ "$REPORT" == PROBE_ERROR* ]]; then
118
+ ta_fail "TS probe failed: ${REPORT#PROBE_ERROR }"
119
+ else
120
+ # sed, not grep: grep exits 1 when there is nothing to show, and pipefail
121
+ # would turn a perfectly green run into a failure.
122
+ printf '%s\n' "$REPORT" | sed -n 's/^\(SHELL_FAIL\|TS_FAIL\|PARITY_FAIL\)/ \1/p'
123
+ read -r _ ROWS SHELL_FAILS TS_FAILS DISAGREE <<< "$(grep '^RESULT' <<< "$REPORT")"
124
+ ROWS=${ROWS#rows=}; SHELL_FAILS=${SHELL_FAILS#shell_fails=}
125
+ TS_FAILS=${TS_FAILS#ts_fails=}; DISAGREE=${DISAGREE#disagree=}
126
+
127
+ [ "${SHELL_FAILS:-1}" -eq 0 ] \
128
+ && ta_pass "(a) shell hook matches all $ROWS fixture rows" \
129
+ || ta_fail "(a) shell hook missed $SHELL_FAILS of $ROWS rows (see above)"
130
+ [ "${TS_FAILS:-1}" -eq 0 ] \
131
+ && ta_pass "(b) TS extension matches all $ROWS fixture rows" \
132
+ || ta_fail "(b) TS extension missed $TS_FAILS of $ROWS rows (see above)"
133
+ [ "${DISAGREE:-1}" -eq 0 ] \
134
+ && ta_pass "(c) shell and TS agree on all $ROWS rows" \
135
+ || ta_fail "(c) shell and TS disagree on $DISAGREE of $ROWS rows (see above)"
136
+ fi
137
+
138
+ # ── (d) the rules that share this hook must keep working ────────────────────
139
+ # The normalizer replaced the pattern loop in the same handler; a regression in
140
+ # the neighbouring checks (protected branches, Conventional Commits, the gemini
141
+ # JSON envelope, the pi/OMP fallback) would be invisible to the rows above.
142
+ #
143
+ # These run in a throwaway repo on a feature branch, like the rows: "a commit is
144
+ # allowed" is only true off `main`, and the gate itself runs on `main` after a
145
+ # merge. Duplicating the repo setup here keeps each block self-contained.
146
+ json_cmd() { $PYTHON -c 'import json,sys;print(json.dumps({"command": sys.argv[1]}))' "$1"; }
147
+ FEATURE_REPO="$($PYTHON - "$(mktemp -d)" <<'PY'
148
+ import subprocess, sys
149
+ path = sys.argv[1]
150
+ def git(*args):
151
+ subprocess.run(["git", "-C", path, *args], check=True, capture_output=True)
152
+ subprocess.run(["git", "init", "-q", "-b", "main", path], check=True, capture_output=True)
153
+ git("config", "user.email", "fixture@example.com")
154
+ git("config", "user.name", "fixture")
155
+ git("commit", "-q", "--allow-empty", "-m", "init")
156
+ git("checkout", "-q", "-b", "fix/guard-git-normalize")
157
+ print(path)
158
+ PY
159
+ )"
160
+ adjacent() { # name want_rc command [hook]
161
+ local name="$1" want="$2" command="$3" hook="${4:-}" rc
162
+ hook="${hook:-$REPO_ROOT/hooks/pre-tool-use.sh}"
163
+ cd "$FEATURE_REPO" || ta_fail "(d) $name: cannot enter fixture repo"
164
+ json_cmd "$command" | env -u GIT_BIGPOWERS_LAND bash "$hook" >/dev/null 2>&1 && rc=0 || rc=$?
165
+ cd "$REPO_ROOT" || true
166
+ [ "$rc" -eq "$want" ] || ta_fail "(d) $name: rc=$rc (want $want) — $command"
167
+ }
168
+ adjacent "plain status allowed" 0 "git status"
169
+ adjacent "conventional commit allowed" 0 'git commit -m "fix(scope): subject"'
170
+ adjacent "feature push allowed" 0 "git push origin feature/x"
171
+ adjacent "non-conventional commit blocked" 2 'git commit -m "bad message"'
172
+ rm -rf "$FEATURE_REPO"
173
+
174
+ DESTRUCTIVE="git reset --hard"
175
+ GEMINI_OUT=$(json_cmd "$DESTRUCTIVE" | env -u GIT_BIGPOWERS_LAND GIT_GUARDRAILS_MODE=gemini bash hooks/pre-tool-use.sh 2>&1)
176
+ echo "$GEMINI_OUT" | grep -q '"decision": *"deny"' \
177
+ || ta_fail "(d) gemini mode must emit deny JSON, got: $(echo "$GEMINI_OUT" | head -c 120)"
178
+
179
+ PI_OUT=$(json_cmd "$DESTRUCTIVE" | env -u GIT_BIGPOWERS_LAND bash hooks/pre/bash.sh 2>&1)
180
+ echo "$PI_OUT" | grep -q '"decision":"block"' \
181
+ || ta_fail "(d) pi/OMP fallback must emit block JSON, got: $(echo "$PI_OUT" | head -c 120)"
182
+
183
+ bash -n hooks/pre/bash.sh || ta_fail "(d) hooks/pre/bash.sh must parse"
184
+ grep -q "classify_git_argv" hooks/pre/bash.sh \
185
+ || ta_fail "(d) pi/OMP fallback must use the normalized classifier"
186
+ ta_pass "(d) adjacent rules: commits, pushes, gemini JSON, pi fallback"
187
+
188
+ echo "$TA_PASS passed, $TA_FAIL failed"
189
+ [[ "$TA_FAIL" -eq 0 ]]
@@ -13,7 +13,8 @@ Installs a shared hook that blocks destructive git operations and enforces workf
13
13
 
14
14
  ## What gets blocked/enforced
15
15
 
16
- - **Safety**: `git push --force`, `git reset --hard`, `git clean -f`, `git branch -D`, `git checkout .`, `git restore .`.
16
+ - **Safety**: force push (`-f`, `--force`, `+refspec`), `reset` with `--hard`, `clean` with any `-f*`, `branch -D` / `--delete --force`, `checkout`/`restore` that discard work (`-f`, `.` pathspec).
17
+ - **Argv, not substrings**: the hook tokenizes each command, strips git's global options (`-C <path>`, `-c k=v`, `--no-pager`, `--git-dir=…`) and judges the `(subcommand, arguments)` pair — so `git -C repo reset -q --hard` is blocked, while `git push --force-with-lease` is allowed. Rules live in `scripts/lib/git-argv.py`, mirrored in `extensions/omp-hooks.ts`; `scripts/test-guard-git-normalize.sh` fails if the two disagree.
17
18
  - **Discipline**: Blocks direct commits or pushes to protected branches (`main`, `master`) unless `GIT_BIGPOWERS_LAND=1` (set only by `scripts/land-branch.sh`).
18
19
  - **Allows**: `git push origin <feature-branch>` for backup/CI; solo land push to `main` only inside `land-branch.sh`.
19
20
  - **Standardization**: Enforces [Conventional Commits](https://www.conventionalcommits.org/) for all `git commit` commands.
@@ -38,7 +39,11 @@ Installs a shared hook that blocks destructive git operations and enforces workf
38
39
 
39
40
  ## Customization
40
41
 
41
- To add or remove patterns or protected branches, edit `pre-tool-use.sh`.
42
+ The rule table lives in `scripts/lib/git-argv.py` (shell hooks) and is mirrored in `extensions/omp-hooks.ts`. Add a rule to both and a row to `specs/verifications/fixtures/guard-git-normalize.yaml`.
43
+
44
+ The TS side is judged through `evaluateBashCall()` — the single pure function the `tool_call` handler calls — so the fixture covers **every** rule (destructive argv, protected-branch push, Conventional Commits), not just the argv table. The gate (`bash scripts/test-guard-git-normalize.sh`) runs both implementations with `GIT_BIGPOWERS_LAND` unset and fails if they disagree, so a verdict can never depend on the developer's shell.
45
+
46
+ Protected-branch rules answer differently on `main` than on a feature branch, so a row that touches commit/push semantics states its `branch:` and both sides are run in it (the shell hook in a throwaway repo checked out on that branch). A row without `branch:` is judged on a feature branch. Do not pin the branch inside either implementation — that is what made the gate pass on PRs and fail on `main`.
42
47
 
43
48
  ## Advanced
44
49
 
package/skills-lock.json CHANGED
@@ -158,7 +158,7 @@
158
158
  },
159
159
  "guard-git": {
160
160
  "description": "Block dangerous git commands (push, force push, reset --hard, clean, branch -D, checkout/restore .) and enforce Conventional Commits & Branch Protection before an AI agent runs them. Installs hook scripts for Claude Code, Cursor, Cursor CLI, and Gemini CLI; documents Google Antigravity Terminal deny lists. Use when the user wants git safety hooks, to block git push or destructive git in agents, or to mirror the same policy across AI coding tools.",
161
- "sha256": "e7083cba6d95a15f",
161
+ "sha256": "08b4b14a1134032e",
162
162
  "path": "skills/guard-git/SKILL.md"
163
163
  },
164
164
  "harden-vps": {