-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (117 loc) · 5.31 KB
/
Copy pathMakefile
File metadata and controls
132 lines (117 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.PHONY: setup validate validate-kits test-kits generate generate-check test coverage security ci clean search install-hooks help
help: ## Show this help message
@echo "agentic-coding-patterns — Available targets:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Examples:"
@echo " make setup # First-time setup"
@echo " make install-hooks # Install pre-commit hooks (opt-in)"
@echo " make validate # Before committing"
@echo " make ci # Full local CI check"
setup: ## Install dependencies (pip install -e .[dev])
pip install -e ".[dev]"
install-hooks: ## Install pre-commit hooks (opt-in for contributors)
@echo "Installing pre-commit hooks..."
@if git config --global --get core.hooksPath >/dev/null 2>&1; then \
echo "⚠️ Detected global core.hooksPath: $$(git config --global --get core.hooksPath)"; \
echo " Setting repo-local core.hooksPath to empty to override..."; \
git config core.hooksPath ""; \
pre-commit install; \
echo "✓ Pre-commit hooks installed"; \
echo " Note: Repo-local hooksPath set to override global"; \
else \
pre-commit install; \
echo "✓ Pre-commit hooks installed"; \
fi
@echo " Hooks will run automatically on git commit"
@echo " To skip hooks: git commit --no-verify"
validate: ## Run all validators (frontmatter + sensitive terms)
python scripts/validate_repo.py
validate-kits: ## Validate neutral acq-kits specs against the hybrid/v1 schema (strict: warnings fail)
python integrations/isolation/acq-kits/validate-kits.py --strict
test-kits: ## Run the acq-kits node test suites (usai-provider + paseo) + providers/usai emitters
@if command -v node >/dev/null 2>&1; then \
echo "==> usai-provider kit tests" && \
(cd integrations/isolation/acq-kits/usai-provider && node --test 'tests/**/*.test.mjs') && \
echo "==> paseo kit tests" && \
(cd "$(CURDIR)/integrations/isolation/acq-kits/paseo" && node --test 'tests/**/*.test.mjs') && \
echo "==> providers/usai catalog + emitter tests" && \
(cd "$(CURDIR)/integrations/providers/usai" && node --test 'tests/**/*.test.mjs'); \
else \
echo "⚠️ node not installed — skipping acq-kits node tests"; \
fi
scan-shell: ## Scan shell scripts + markdown bash blocks for unsafe patterns (#154)
python scripts/scan_unsafe_shell.py .
generate: ## Generate INDEX.yaml from patterns
python scripts/generate_index.py
python scripts/generate_catalog.py
generate-check: ## Verify INDEX.yaml is up to date (used in pre-commit)
python scripts/generate_index.py --check
python scripts/generate_catalog.py --check
search: ## Search patterns (e.g., make search TAG=security)
@if [ -z "$(QUERY)" ] && [ -z "$(TAG)" ] && [ -z "$(STATUS)" ] && [ -z "$(PERSONA)" ] && [ -z "$(TOOL)" ]; then \
echo "Usage: make search [QUERY=text] [TAG=tag] [STATUS=status] [PERSONA=persona] [TOOL=tool]"; \
echo ""; \
echo "Examples:"; \
echo " make search TAG=security"; \
echo " make search STATUS=recommended"; \
echo " make search QUERY='code review' TOOL=cursor"; \
else \
python scripts/search_patterns.py $(if $(QUERY),--query "$(QUERY)") $(if $(TAG),--tag $(TAG)) $(if $(STATUS),--status $(STATUS)) $(if $(PERSONA),--persona $(PERSONA)) $(if $(TOOL),--tool $(TOOL)); \
fi
security: ## Run security audit (pip-audit for CVEs)
pip-audit --skip-editable
test: ## Run pytest test suite
@if [ -d "scripts/tests" ] && [ "$$(ls -A scripts/tests/*.py 2>/dev/null)" ]; then \
PYTHONPATH=scripts pytest scripts/tests/ -v; \
else \
echo "⚠️ No tests found in scripts/tests/"; \
echo " Create tests to enable this check (see issue #16)"; \
fi
test-cases: ## Run pattern test cases (test-cases.yml validation)
python scripts/run_test_cases.py --verbose
coverage: ## Run tests with coverage report
PYTHONPATH=scripts python3 -m pytest scripts/tests/ \
--cov=scripts \
--cov-report=html \
--cov-report=term
ci: ## Full CI check (validate + security + test + pre-commit checks)
@echo "==> Running pre-commit checks (duplicates pre-commit hooks)..."
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit run --all-files; \
else \
echo "⚠️ pre-commit not installed, skipping hook checks"; \
echo " Install with: pip install pre-commit"; \
fi
@echo ""
@echo "==> Running validators..."
python scripts/validate_repo.py
@echo ""
@echo "==> Scanning for unsafe shell patterns..."
python scripts/scan_unsafe_shell.py .
@echo ""
@echo "==> Validating acq-kits (hybrid/v1 schema)..."
python integrations/isolation/acq-kits/validate-kits.py --strict
@echo ""
@echo "==> Running security audit..."
pip-audit --skip-editable
@echo ""
@echo "==> Running tests..."
@if [ -d "scripts/tests" ] && [ "$$(ls -A scripts/tests/*.py 2>/dev/null)" ]; then \
PYTHONPATH=scripts pytest scripts/tests/ -v; \
else \
echo "⚠️ No tests found — skipping"; \
fi
@echo ""
@echo "==> Running acq-kits node tests..."
@$(MAKE) --no-print-directory test-kits
@echo ""
@echo "==> Running pattern test cases..."
@$(MAKE) --no-print-directory test-cases
@echo ""
@echo "✓ All checks passed"
clean: ## Remove generated files and caches
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
rm -rf .pytest_cache/ .ruff_cache/