navori 0.2.20 → 0.2.21
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/dist/assets/core/core-assets/agents/commit-pr-pilot.md +16 -2
- package/dist/assets/core/core-assets/agents/implementer.md +19 -0
- package/dist/assets/core/core-assets/agents/reviewer.md +5 -2
- package/dist/assets/core/core-assets/hooks/guard-destructive.sh +50 -5
- package/dist/assets/core/core-assets/hooks/quality-gate-pre-commit.sh +81 -24
- package/dist/assets/core/core-assets/managed/idioma-rol.md +3 -0
- package/dist/assets/core/core-assets/presets/vite-react-ts/managed/stack.md +1 -1
- package/dist/assets/core/core-assets/skills/pr-create.md +3 -1
- package/dist/assets/core/core-assets/skills/review-diff.md +19 -4
- package/dist/assets/plugins/cognitive/scripts/check-cognitive.sh +64 -7
- package/dist/assets/plugins/engram/managed/engram-protocol.md +1 -0
- package/dist/assets/plugins/jscpd/scripts/check-jscpd.sh +64 -7
- package/dist/assets/plugins/semgrep/scripts/check-semgrep.sh +64 -7
- package/dist/index.js +271 -265
- package/package.json +1 -1
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
# vs `{{branchBase}}` with the `auto` ruleset. Skips silently if semgrep or
|
|
4
4
|
# git are absent — the tool is optional.
|
|
5
5
|
#
|
|
6
|
-
# Triggered as a PreToolUse(Bash) hook (gated to git commit/push) and as a
|
|
6
|
+
# Triggered as a PreToolUse(Bash) hook (gated to git commit / push / gh pr create) and as a
|
|
7
7
|
# Stop hook (runs unconditionally at session close).
|
|
8
8
|
|
|
9
9
|
set -euo pipefail
|
|
10
10
|
|
|
11
|
-
# PreToolUse(Bash) passes the command — gate to commit/push. The Stop hook
|
|
11
|
+
# PreToolUse(Bash) passes the command — gate to commit / push / gh pr create. The Stop hook
|
|
12
12
|
# passes no command — run unconditionally at session close. Extract without
|
|
13
13
|
# hard-depending on jq (not preinstalled on macOS): try jq, then node (Claude
|
|
14
14
|
# Code's own runtime), then a best-effort sed unwrap. No command extracted →
|
|
@@ -24,11 +24,68 @@ extract_cmd() {
|
|
|
24
24
|
printf '%s' "$payload" | sed -n 's/.*"command"[[:space:]]*:[[:space:]]*"\(.*\)".*/\1/p'
|
|
25
25
|
}
|
|
26
26
|
cmd=$(extract_cmd)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
# --- shared gate detection (keep IN SYNC across sibling hooks) --------------
|
|
29
|
+
# Detect a `git commit` / `git push` / `gh pr create` invocation anywhere in a (possibly
|
|
30
|
+
# compound) command. Splits $1 on the shell separators && || ; | and newlines,
|
|
31
|
+
# strips leading whitespace plus simple `VAR=value` env prefixes from each
|
|
32
|
+
# segment, and returns 0 if ANY segment STARTS with `git commit`/`git push` on
|
|
33
|
+
# a word boundary. Replaces literal-prefix `case` matching, which silently
|
|
34
|
+
# skipped the gate for `cd x && git commit`, `echo y; git push`, or a leading
|
|
35
|
+
# space. Because it matches a segment START, a quoted `echo "git commit"` does
|
|
36
|
+
# NOT trigger it. Known limitation: it cannot see through `sh -c`, `eval`, or
|
|
37
|
+
# obfuscation — a seatbelt, not a sandbox. Body duplicated across the navori quality hooks (they render standalone — no
|
|
38
|
+
# shared lib). The quality-gate/jscpd/cognitive copies gate `git commit` ONLY;
|
|
39
|
+
# the semgrep copy also gates `git push` and `gh pr create` (remote-push
|
|
40
|
+
# security backstop). Keep in sync.
|
|
41
|
+
is_scan_trigger() {
|
|
42
|
+
local input="$1" segment
|
|
43
|
+
# FIX B: join `\<newline>` continuations into a space FIRST, so a command
|
|
44
|
+
# split across lines with a trailing backslash stays ONE logical segment
|
|
45
|
+
# (otherwise the subcommand/flag lands in a segment not starting with git).
|
|
46
|
+
input="${input//\\$'\n'/ }"
|
|
47
|
+
input="${input//&&/$'\n'}"
|
|
48
|
+
input="${input//||/$'\n'}"
|
|
49
|
+
input="${input//;/$'\n'}"
|
|
50
|
+
input="${input//|/$'\n'}"
|
|
51
|
+
# `<<<` feeds the already-expanded value as data — no re-evaluation — so a
|
|
52
|
+
# command that contains backticks/$() is inspected, never executed.
|
|
53
|
+
while IFS= read -r segment; do
|
|
54
|
+
segment="${segment#"${segment%%[![:space:]]*}"}" # strip leading ws
|
|
55
|
+
# FIX C: peel wrappers so `(git …`, `\git`, `command git …` and
|
|
56
|
+
# `VAR=val git …` all reduce to a plain `git …` before matching.
|
|
57
|
+
while [[ "$segment" == \(* ]]; do # strip leading ( runs
|
|
58
|
+
segment="${segment#\(}"
|
|
59
|
+
segment="${segment#"${segment%%[![:space:]]*}"}"
|
|
60
|
+
done
|
|
61
|
+
segment="${segment#\\}" # strip a leading backslash (\git)
|
|
62
|
+
while [[ "$segment" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; do # strip VAR=val prefixes
|
|
63
|
+
case "$segment" in
|
|
64
|
+
*[[:space:]]*)
|
|
65
|
+
segment="${segment#*[[:space:]]}"
|
|
66
|
+
segment="${segment#"${segment%%[![:space:]]*}"}"
|
|
67
|
+
;;
|
|
68
|
+
*) segment=""; break ;;
|
|
69
|
+
esac
|
|
70
|
+
done
|
|
71
|
+
if [[ "$segment" == command\ * ]]; then # strip a leading `command ` word
|
|
72
|
+
segment="${segment#command }"
|
|
73
|
+
segment="${segment#"${segment%%[![:space:]]*}"}"
|
|
74
|
+
fi
|
|
75
|
+
# FIX C: allow git global options between `git` and the subcommand
|
|
76
|
+
# (`git -c k=v commit`, `git -C /repo push`). Trailing boundary keeps
|
|
77
|
+
# `git commitgraph` / `git config …` from matching as commit/push.
|
|
78
|
+
if printf '%s' "$segment" | grep -qE '(^git([[:space:]]+-[a-zA-Z-]+(=[^[:space:]]+)?([[:space:]]+[^-][^[:space:]]*)?)*[[:space:]]+(commit|push)([[:space:]]|$))|(^gh[[:space:]]+pr[[:space:]]+create([[:space:]]|$))'; then
|
|
79
|
+
return 0
|
|
80
|
+
fi
|
|
81
|
+
done <<< "$input"
|
|
82
|
+
return 1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# No command extracted (empty $cmd) → run unconditionally (Stop hook path). A
|
|
86
|
+
# real command that is NOT a scanned op → skip. Anything else → scan.
|
|
87
|
+
if [ -n "$cmd" ] && ! is_scan_trigger "$cmd"; then
|
|
88
|
+
exit 0
|
|
32
89
|
fi
|
|
33
90
|
|
|
34
91
|
if ! command -v semgrep >/dev/null 2>&1; then
|