Skip to content

Commit 411dd3e

Browse files
committed
chore: add pre-commit checks and shell formatting
1 parent ae428b3 commit 411dd3e

8 files changed

Lines changed: 67 additions & 23 deletions

File tree

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-merge-conflict
6+
- id: check-json
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
args: [--markdown-linebreak-ext=md]
11+
- id: check-added-large-files
12+
13+
- repo: https://github.com/scop/pre-commit-shfmt
14+
rev: v3.11.0-1
15+
hooks:
16+
- id: shfmt
17+
args: [-w, -i, "2", -ci]
18+
files: ^(install\.sh|scripts/.*\.sh)$
19+
20+
- repo: https://github.com/shellcheck-py/shellcheck-py
21+
rev: v0.11.0.1
22+
hooks:
23+
- id: shellcheck
24+
files: ^(install\.sh|scripts/.*\.sh)$
25+
26+
- repo: https://github.com/igorshubovych/markdownlint-cli
27+
rev: v0.45.0
28+
hooks:
29+
- id: markdownlint
30+
files: \.md$
31+
exclude: ^memory/
32+
args: [--disable, MD013, MD033, MD041]

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ Each agent markdown should define:
2929
- Explain why the change exists.
3030
- Include before/after behavior when relevant.
3131
- Link issues when possible.
32+
33+
## Local Validation
34+
35+
This repo uses `pre-commit` for lightweight quality checks across shell, JSON/YAML, and markdown.
36+
37+
```bash
38+
python3 -m pip install --user pre-commit
39+
pre-commit install
40+
pre-commit run --all-files
41+
```

install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require_registry() {
4848
assert_profile_exists() {
4949
local profile_id="$1"
5050
require_registry
51-
if ! python3 - "$REGISTRY_PATH" "$profile_id" <<'PY'
51+
if ! python3 - "$REGISTRY_PATH" "$profile_id" <<'PY'; then
5252
import json
5353
import sys
5454
@@ -57,7 +57,6 @@ registry = json.load(open(registry_path, "r", encoding="utf-8"))
5757
ids = {p["id"] for p in registry.get("profiles", [])}
5858
raise SystemExit(0 if profile_id in ids else 1)
5959
PY
60-
then
6160
echo "Unknown profile: $profile_id"
6261
echo "Use --list-profiles to view valid profile IDs."
6362
exit 1
@@ -277,7 +276,8 @@ disable_profile() {
277276
current_csv="$(load_enabled_profiles)"
278277

279278
local updated_csv
280-
updated_csv="$(python3 - "$current_csv" "$profile_id" <<'PY'
279+
updated_csv="$(
280+
python3 - "$current_csv" "$profile_id" <<'PY'
281281
import sys
282282
283283
current_csv, profile_id = sys.argv[1], sys.argv[2]
@@ -287,7 +287,7 @@ if not filtered:
287287
filtered = ["core"]
288288
print(",".join(filtered))
289289
PY
290-
)"
290+
)"
291291

292292
install_with_csv "$updated_csv"
293293
}
@@ -324,7 +324,7 @@ uninstall_all() {
324324

325325
main() {
326326
case "${1:-}" in
327-
"" )
327+
"")
328328
install_with_csv "$(load_enabled_profiles)"
329329
;;
330330
--list-profiles)
@@ -360,7 +360,7 @@ main() {
360360
--uninstall)
361361
uninstall_all
362362
;;
363-
-h|--help)
363+
-h | --help)
364364
usage
365365
;;
366366
*)

scripts/council-lite.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ cmd_start() {
101101

102102
mkdir -p "$outdir"
103103

104-
cat > "$outfile" <<EOF
104+
cat >"$outfile" <<EOF
105105
# Council Lite Session - $stamp
106106
107107
## Goal
@@ -132,7 +132,7 @@ EOF
132132
main() {
133133
local command="${1:-}"
134134
case "$command" in
135-
""|"-h"|"--help")
135+
"" | "-h" | "--help")
136136
usage
137137
;;
138138
status)

scripts/git-porcelain.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
WORKSPACE="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
55

66
usage() {
7-
cat << 'EOF'
7+
cat <<'EOF'
88
Usage: git-porcelain.sh <command> [args]
99
1010
Commands:
@@ -37,7 +37,7 @@ EOF
3737
is_sensitive_path() {
3838
local path="$1"
3939
case "$path" in
40-
*.pem|*.key|*.p12|*.pfx|*.kube/config|*.env|*.env.*|*credentials*.json|*secrets*.json)
40+
*.pem | *.key | *.p12 | *.pfx | *.kube/config | *.env | *.env.* | *credentials*.json | *secrets*.json)
4141
return 0
4242
;;
4343
*)
@@ -127,20 +127,21 @@ cmd_pr_draft() {
127127
--head "$branch" \
128128
--draft \
129129
--title "$title" \
130-
--body "$(cat <<'EOF'
130+
--body "$(
131+
cat <<'EOF'
131132
## Summary
132133
- Describe the intent and context.
133134
134135
## Testing
135136
- [ ] Add the validation commands you ran.
136137
EOF
137-
)"
138+
)"
138139
}
139140

140141
main() {
141142
local command="${1:-}"
142143
case "$command" in
143-
""|"-h"|"--help")
144+
"" | "-h" | "--help")
144145
usage
145146
;;
146147
status)

scripts/handover.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ STAMP="$(date +%Y-%m-%d-%H%M)"
77
OUTFILE="$OUTDIR/HANDOVER-$STAMP.md"
88

99
if [[ "${1:-}" == "--help" ]]; then
10-
cat << 'EOF'
10+
cat <<'EOF'
1111
Usage: handover.sh [--print]
1212
1313
Creates a handover markdown file in memory/ with a repository snapshot.
@@ -32,7 +32,7 @@ if [[ -z "$COMMITS" ]]; then
3232
COMMITS="(no commits yet)"
3333
fi
3434

35-
cat > "$OUTFILE" << EOF
35+
cat >"$OUTFILE" <<EOF
3636
# Session Handover - $STAMP
3737
3838
## Workspace Snapshot

scripts/issue-pr-loop.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
WORKSPACE="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
55

66
usage() {
7-
cat << 'EOF'
7+
cat <<'EOF'
88
Usage: issue-pr-loop.sh <command> [args]
99
1010
Commands:
@@ -29,7 +29,7 @@ require_gh() {
2929
}
3030

3131
slugify() {
32-
python3 - << 'PY'
32+
python3 - <<'PY'
3333
import re
3434
import sys
3535
text = sys.stdin.read().strip().lower()
@@ -76,7 +76,8 @@ cmd_pr() {
7676
--head "$branch" \
7777
--draft \
7878
--title "${issue_title}" \
79-
--body "$(cat <<EOF
79+
--body "$(
80+
cat <<EOF
8081
Closes #$issue
8182
8283
## Summary
@@ -85,13 +86,13 @@ Closes #$issue
8586
## Testing
8687
- [ ] Add commands run locally
8788
EOF
88-
)"
89+
)"
8990
}
9091

9192
main() {
9293
local command="${1:-}"
9394
case "$command" in
94-
""|"-h"|"--help")
95+
"" | "-h" | "--help")
9596
usage
9697
;;
9798
start)

scripts/ops-check.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WORKSPACE="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
55
FAILURES=0
66

77
usage() {
8-
cat << 'EOF'
8+
cat <<'EOF'
99
Usage: ops-check.sh [--strict]
1010
1111
Runs stack-aware quality checks for Node.js, Python, and Terraform when detected.
@@ -60,7 +60,7 @@ has_tool() {
6060

6161
node_has_script() {
6262
local key="$1"
63-
python3 - << PY
63+
python3 - <<PY
6464
import json
6565
from pathlib import Path
6666
pkg = Path("$WORKSPACE/package.json")
@@ -144,7 +144,7 @@ check_python() {
144144
}
145145

146146
check_terraform() {
147-
if ! compgen -G "$WORKSPACE/*.tf" > /dev/null; then
147+
if ! compgen -G "$WORKSPACE/*.tf" >/dev/null; then
148148
return
149149
fi
150150

0 commit comments

Comments
 (0)