-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (109 loc) · 5.28 KB
/
Makefile
File metadata and controls
125 lines (109 loc) · 5.28 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
.PHONY: all build test lint format format-check clean setup check-deps audit docs validate validate-memories validate-memories-ci
# Default target
all: lint test
# Build (no-op for this plugin, but included for consistency)
build:
@echo "No build step required for Claude Code plugins"
# Run tests
test:
@echo "Running tests..."
@python3 -m pytest tests/ -v 2>/dev/null || echo "No tests found or pytest not installed"
@echo "Validating hook outputs..."
@for hook in hooks/*.py; do \
echo " Testing $$hook..."; \
python3 "$$hook" --test 2>/dev/null || python3 -c "import sys; sys.path.insert(0, '.'); exec(open('$$hook').read())" 2>/dev/null || true; \
done
# Lint code
lint: validate
@echo "Linting Python files..."
@python3 -m ruff check hooks/ 2>/dev/null || python3 -m flake8 hooks/ 2>/dev/null || echo "Install ruff or flake8 for Python linting"
@echo "Checking markdown files..."
@command -v markdownlint >/dev/null 2>&1 && markdownlint '**/*.md' --ignore node_modules || echo "markdownlint not installed (optional)"
# Validate plugin structure
validate:
@echo "Validating plugin structure..."
@test -f .claude-plugin/plugin.json || (echo "ERROR: Missing .claude-plugin/plugin.json" && exit 1)
@echo " Plugin manifest exists"
@for cmd in commands/*.md; do \
grep -q "^---" "$$cmd" || (echo "ERROR: $$cmd missing frontmatter" && exit 1); \
done
@echo " Commands have frontmatter"
@for skill in skills/*/SKILL.md; do \
grep -q "^---" "$$skill" || (echo "ERROR: $$skill missing frontmatter" && exit 1); \
done
@echo " Skills have frontmatter"
@echo "Plugin validation passed!"
# Format code
format:
@echo "Formatting Python files..."
@python3 -m ruff format hooks/ 2>/dev/null || python3 -m black hooks/ 2>/dev/null || echo "Install ruff or black for formatting"
# Check formatting without changes
format-check:
@echo "Checking Python formatting..."
@python3 -m ruff format --check hooks/ 2>/dev/null || python3 -m black --check hooks/ 2>/dev/null || echo "Install ruff or black for format checking"
# Clean generated files
clean:
@echo "Cleaning..."
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.py[cod]" -delete 2>/dev/null || true
@find . -type f -name ".DS_Store" -delete 2>/dev/null || true
@echo "Clean complete"
# Setup development environment
setup:
@echo "Setting up development environment..."
@python3 -m pip install --upgrade pip
@python3 -m pip install ruff pytest pyyaml 2>/dev/null || echo "Some tools may not have installed"
@echo "Checking yq installation..."
@command -v yq >/dev/null 2>&1 || (echo "WARNING: yq not installed. Install: brew install yq (macOS) or apt install yq (Linux)" && echo "yq is required for mnemonic-query structured queries")
@command -v yq >/dev/null 2>&1 && echo " yq is installed"
@echo "Setup complete"
# Check dependencies
check-deps:
@echo "Checking required dependencies..."
@command -v rg >/dev/null 2>&1 && echo " ripgrep: installed" || echo " ripgrep: NOT FOUND (install: brew install ripgrep)"
@command -v yq >/dev/null 2>&1 && echo " yq: installed" || echo " yq: NOT FOUND (install: brew install yq)"
@command -v git >/dev/null 2>&1 && echo " git: installed" || echo " git: NOT FOUND"
@command -v python3 >/dev/null 2>&1 && echo " python3: installed" || echo " python3: NOT FOUND"
# Security audit
audit:
@echo "Running security audit..."
@python3 -m pip_audit 2>/dev/null || echo "pip-audit not installed (optional)"
@echo "Checking for hardcoded secrets..."
@grep -r "password\s*=" hooks/ --include="*.py" && echo "WARNING: Potential hardcoded password" || true
@grep -r "api_key\s*=" hooks/ --include="*.py" && echo "WARNING: Potential hardcoded API key" || true
@echo "Security audit complete"
# Build documentation
docs:
@echo "Documentation is in docs/ directory"
@echo "Files:"
@find docs -name "*.md" -type f
# Validate memory files against MIF schema
validate-memories:
@echo "Validating memory files..."
@./tools/mnemonic-validate --format markdown
# Validate memory files (CI mode - JSON output)
validate-memories-ci:
@./tools/mnemonic-validate --format json
# Validate only git-changed memory files
validate-memories-changed:
@echo "Validating changed memory files..."
@./tools/mnemonic-validate --changed --format markdown
# Help
help:
@echo "Available targets:"
@echo " all - Run lint and test (default)"
@echo " build - Build the project (no-op for plugins)"
@echo " test - Run tests"
@echo " lint - Lint code and validate plugin"
@echo " validate - Validate plugin structure"
@echo " validate-memories - Validate memory files against MIF schema"
@echo " validate-memories-ci - Validate memories (JSON output for CI)"
@echo " validate-memories-changed - Validate only git-modified memories"
@echo " format - Format Python code"
@echo " format-check - Check code formatting"
@echo " clean - Remove generated files"
@echo " setup - Set up development environment"
@echo " check-deps - Check required dependencies (yq, rg, git)"
@echo " audit - Run security audit"
@echo " docs - List documentation files"
@echo " help - Show this help"