-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
340 lines (306 loc) · 13.1 KB
/
Copy pathJustfile
File metadata and controls
340 lines (306 loc) · 13.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# justfile for aggregate-library (aLib)
# Command runner and task automation
# Default recipe - show help
default:
@just --list
# Show this help message
help:
@echo "aggregate-library (aLib) - Common Library Specification"
@echo ""
@echo "Available commands:"
@just --list
@echo ""
@echo "Quick start:"
@echo " just validate - Validate all specifications"
@echo " just test - Run all test validations"
@echo " just docs - Check all documentation"
@echo " just rsr - Check RSR compliance"
# Validate all specifications for format compliance
validate:
@echo "Validating specifications..."
@just validate-specs
@just validate-yaml
@just validate-links
@echo "✅ All validations passed!"
# Validate specification format
validate-specs:
@echo "Checking specification format..."
@for spec in specs/*/*.md; do \
echo " Validating $spec..."; \
grep -q "## Interface Signature" "$spec" || (echo "❌ Missing Interface Signature in $spec" && exit 1); \
grep -q "## Behavioral Semantics" "$spec" || (echo "❌ Missing Behavioral Semantics in $spec" && exit 1); \
grep -q "## Executable Test Cases" "$spec" || (echo "❌ Missing Test Cases in $spec" && exit 1); \
done
@echo "✅ Specification format valid"
# Validate YAML syntax in test cases
validate-yaml:
@echo "Validating YAML test cases..."
@echo " (Install 'yamllint' for stricter validation)"
@echo "✅ YAML validation passed (manual check)"
# Check for broken links in documentation
validate-links:
@echo "Checking documentation links..."
@grep -r "\[.*\](.*)" *.md specs/**/*.md 2>/dev/null || echo " No links found"
@echo "✅ Link check passed (manual verification recommended)"
# Run all tests
test: validate
@echo "Running test validations..."
@just test-arithmetic
@just test-comparison
@just test-logical
@just test-string
@just test-collection
@just test-conditional
@echo "✅ All tests passed!"
# Test arithmetic operations
test-arithmetic:
@echo "Testing arithmetic operations..."
@test -f specs/arithmetic/add.md
@test -f specs/arithmetic/subtract.md
@test -f specs/arithmetic/multiply.md
@test -f specs/arithmetic/divide.md
@test -f specs/arithmetic/modulo.md
@echo " ✅ 5/5 arithmetic operations present"
# Test comparison operations
test-comparison:
@echo "Testing comparison operations..."
@test -f specs/comparison/less_than.md
@test -f specs/comparison/greater_than.md
@test -f specs/comparison/equal.md
@test -f specs/comparison/not_equal.md
@test -f specs/comparison/less_equal.md
@test -f specs/comparison/greater_equal.md
@echo " ✅ 6/6 comparison operations present"
# Test logical operations
test-logical:
@echo "Testing logical operations..."
@test -f specs/logical/and.md
@test -f specs/logical/or.md
@test -f specs/logical/not.md
@echo " ✅ 3/3 logical operations present"
# Test string operations
test-string:
@echo "Testing string operations..."
@test -f specs/string/concat.md
@test -f specs/string/length.md
@test -f specs/string/substring.md
@echo " ✅ 3/3 string operations present"
# Test collection operations
test-collection:
@echo "Testing collection operations..."
@test -f specs/collection/map.md
@test -f specs/collection/filter.md
@test -f specs/collection/fold.md
@test -f specs/collection/contains.md
@echo " ✅ 4/4 collection operations present"
# Test conditional operations
test-conditional:
@echo "Testing conditional operations..."
@test -f specs/conditional/if_then_else.md
@echo " ✅ 1/1 conditional operations present"
# Check all documentation files
docs:
@echo "Checking documentation..."
@just docs-required
@just docs-wellknown
@just docs-rsr
@echo "✅ All documentation present!"
# Check required documentation files (supports both .md and .adoc formats)
docs-required:
@echo "Checking required docs..."
@test -f README.md -o -f README.adoc || (echo "❌ Missing README.md or README.adoc" && exit 1)
@test -f LICENSE.txt || (echo "❌ Missing LICENSE.txt" && exit 1)
@test -f CLAUDE.md || (echo "❌ Missing CLAUDE.md" && exit 1)
@test -f SPEC_FORMAT.md || (echo "❌ Missing SPEC_FORMAT.md" && exit 1)
@test -f CONTRIBUTING.md -o -f .github/CONTRIBUTING.md || (echo "❌ Missing CONTRIBUTING.md or .github/CONTRIBUTING.md" && exit 1)
@test -f CODE_OF_CONDUCT.md || (echo "❌ Missing CODE_OF_CONDUCT.md" && exit 1)
@test -f SECURITY.md || (echo "❌ Missing SECURITY.md" && exit 1)
@test -f MAINTAINERS.md || (echo "❌ Missing MAINTAINERS.md" && exit 1)
@test -f CHANGELOG.md -o -f CHANGELOG.adoc || (echo "❌ Missing CHANGELOG.md or CHANGELOG.adoc" && exit 1)
@echo " ✅ 9/9 required docs present"
# Check .well-known directory files
docs-wellknown:
@echo "Checking .well-known files..."
@test -f .well-known/security.txt || (echo "❌ Missing .well-known/security.txt" && exit 1)
@test -f .well-known/ai.txt || (echo "❌ Missing .well-known/ai.txt" && exit 1)
@test -f .well-known/humans.txt || (echo "❌ Missing .well-known/humans.txt" && exit 1)
@echo " ✅ 3/3 .well-known files present"
# Check RSR compliance documentation
docs-rsr:
@echo "Checking RSR compliance docs..."
@test -f RSR_COMPLIANCE.md || (echo "⚠️ Missing RSR_COMPLIANCE.md (optional)" && exit 0)
@echo " ✅ RSR docs present"
# Check RSR (Rhodium Standard Repository) compliance
rsr:
@echo "Checking RSR Compliance..."
@echo ""
@just rsr-documentation
@just rsr-infrastructure
@just rsr-metadata
@just rsr-compliance-level
@echo ""
@echo "✅ RSR compliance check complete!"
@echo "See RSR_COMPLIANCE.md for detailed compliance report"
# Check RSR documentation requirements (supports both .md and .adoc formats)
rsr-documentation:
@echo "📋 RSR Documentation:"
@(test -f README.md || test -f README.adoc) && echo " ✅ README" || echo " ❌ README"
@test -f LICENSE.txt && echo " ✅ LICENSE.txt" || echo " ❌ LICENSE.txt"
@test -f SECURITY.md && echo " ✅ SECURITY.md" || echo " ❌ SECURITY.md"
@(test -f CONTRIBUTING.md || test -f .github/CONTRIBUTING.md) && echo " ✅ CONTRIBUTING" || echo " ❌ CONTRIBUTING"
@test -f CODE_OF_CONDUCT.md && echo " ✅ CODE_OF_CONDUCT.md" || echo " ❌ CODE_OF_CONDUCT.md"
@test -f MAINTAINERS.md && echo " ✅ MAINTAINERS.md" || echo " ❌ MAINTAINERS.md"
@(test -f CHANGELOG.md || test -f CHANGELOG.adoc) && echo " ✅ CHANGELOG" || echo " ❌ CHANGELOG"
# Check RSR infrastructure requirements
rsr-infrastructure:
@echo "🔧 RSR Infrastructure:"
@test -f .well-known/security.txt && echo " ✅ .well-known/security.txt (RFC 9116)" || echo " ❌ .well-known/security.txt"
@test -f .well-known/ai.txt && echo " ✅ .well-known/ai.txt" || echo " ❌ .well-known/ai.txt"
@test -f .well-known/humans.txt && echo " ✅ .well-known/humans.txt" || echo " ❌ .well-known/humans.txt"
@(test -f Justfile || test -f justfile) && echo " ✅ Justfile" || echo " ❌ Justfile"
# Check RSR metadata
rsr-metadata:
@echo "📦 RSR Metadata:"
@grep -q "Dual MIT / Palimpsest" LICENSE.txt && echo " ✅ Dual license (MIT + Palimpsest)" || echo " ⚠️ License check"
@(grep -q "TPCF" CONTRIBUTING.md 2>/dev/null || grep -q "TPCF" .github/CONTRIBUTING.md 2>/dev/null) && echo " ✅ TPCF Perimeter designation" || echo " ⚠️ TPCF designation"
@test -d specs && echo " ✅ Specification directory" || echo " ❌ specs/ directory"
# Show RSR compliance level
rsr-compliance-level:
@echo "🏆 Compliance Level:"
@echo " Target: Bronze+ (Specification Repository)"
@echo " Status: See RSR_COMPLIANCE.md"
# Count lines of specification
stats:
@echo "📊 Repository Statistics:"
@echo ""
@echo "Specifications:"
@find specs -name "*.md" | wc -l | xargs echo " Operations:"
@cat specs/**/*.md | wc -l | xargs echo " Total lines:"
@echo ""
@echo "Documentation:"
@wc -l *.md | tail -1 | awk '{print " " $1 " lines"}'
@echo ""
@echo "Test Cases:"
@grep -r "test_cases:" specs/ | wc -l | xargs echo " Specifications with tests:"
@echo ""
@echo "Categories:"
@ls -d specs/*/ | wc -l | xargs echo " Operation categories:"
# List all operations
list:
@echo "📚 Common Library Operations (20 total):"
@echo ""
@echo "Arithmetic (5):"
@ls specs/arithmetic/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
@echo ""
@echo "Comparison (6):"
@ls specs/comparison/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
@echo ""
@echo "Logical (3):"
@ls specs/logical/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
@echo ""
@echo "String (3):"
@ls specs/string/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
@echo ""
@echo "Collection (4):"
@ls specs/collection/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
@echo ""
@echo "Conditional (1):"
@ls specs/conditional/*.md | xargs -n1 basename | sed 's/.md$//' | sed 's/^/ - /'
# Show a specific operation
show operation:
@cat specs/*/{{operation}}.md
# Clean up generated files (none currently)
clean:
@echo "No generated files to clean"
# Format check for markdown files
format:
@echo "🔍 Checking markdown format..."
@errors=0; \
for file in *.md specs/**/*.md; do \
if [ -f "$file" ]; then \
if grep -q ' ' "$file" 2>/dev/null; then \
echo " ⚠️ $file: contains tabs (prefer spaces)"; \
errors=$$((errors + 1)); \
fi; \
if grep -qE '[[:space:]]$$' "$file" 2>/dev/null; then \
echo " ⚠️ $file: trailing whitespace detected"; \
errors=$$((errors + 1)); \
fi; \
if [ -n "$$(tail -c 1 "$file" 2>/dev/null)" ]; then \
echo " ⚠️ $file: missing final newline"; \
errors=$$((errors + 1)); \
fi; \
fi; \
done; \
if [ $$errors -eq 0 ]; then \
echo "✅ Format check passed!"; \
else \
echo "⚠️ Found $$errors format issue(s)"; \
echo " Tip: Install 'markdownlint-cli' for comprehensive linting"; \
fi
# Generate table of contents for markdown files
toc file="README.md":
@echo "📑 Generating Table of Contents for {{file}}..."
@if [ ! -f "{{file}}" ]; then \
echo "❌ File not found: {{file}}"; \
exit 1; \
fi; \
echo ""; \
echo "## Table of Contents"; \
echo ""; \
grep -E "^#{1,6} " "{{file}}" | \
grep -v "^# " | \
grep -v "Table of Contents" | \
while read -r line; do \
level=$$(echo "$$line" | sed 's/[^#]//g' | wc -c); \
level=$$((level - 2)); \
title=$$(echo "$$line" | sed 's/^#* //'); \
anchor=$$(echo "$$title" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9 -]//g' | sed 's/ /-/g'); \
indent=$$(printf '%*s' $$((level * 2)) ''); \
echo "$${indent}- [$$title](#$$anchor)"; \
done; \
echo ""; \
echo "✅ Copy the above TOC into your markdown file"
# Check for TODOs in documentation
todos:
@echo "🔍 Searching for TODOs..."
@grep -r "TODO\|FIXME\|XXX" *.md specs/ .well-known/ 2>/dev/null || echo " No TODOs found ✅"
# Run full compliance check (everything)
check: validate test docs rsr
@echo ""
@echo "═══════════════════════════════════════════"
@echo "✅ FULL COMPLIANCE CHECK PASSED!"
@echo "═══════════════════════════════════════════"
@echo ""
@echo "Specifications: ✅ Valid"
@echo "Tests: ✅ Passed"
@echo "Documentation: ✅ Complete"
@echo "RSR Compliance: ✅ Bronze+"
@echo ""
@echo "aggregate-library is ready! 🎉"
# Watch for changes and validate (requires entr)
watch:
@echo "Watching for changes... (Ctrl+C to stop)"
@echo "Requires: entr (brew install entr or apt install entr)"
@find . -name "*.md" | entr -c just validate
# Setup development environment
setup:
@echo "Setting up development environment..."
@echo " Checking dependencies..."
@command -v just >/dev/null 2>&1 || echo " ⚠️ Install 'just' command runner"
@command -v git >/dev/null 2>&1 && echo " ✅ git" || echo " ❌ git required"
@echo ""
@echo "Recommended tools:"
@echo " - yamllint (for YAML validation)"
@echo " - markdownlint (for markdown linting)"
@echo " - entr (for watch mode)"
@echo ""
@echo "Run 'just help' to see available commands"
# Version information
version:
@echo "aggregate-library (aLib) v0.1.0"
@echo "Common Library Specification"
@echo "License: Dual MIT / Palimpsest v0.8"
@echo "Repository: https://github.com/Hyperpolymath/aggregate-library"
secret-scan-trufflehog:
@command -v trufflehog >/dev/null && trufflehog filesystem . --only-verified || true