-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
355 lines (299 loc) · 15.4 KB
/
justfile
File metadata and controls
355 lines (299 loc) · 15.4 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# Nix Darwin Configuration Manager
# Run 'just' to see available commands
set shell := ["bash", "-ec"]
# Auto-detect host
host := env_var_or_default("HOST", "hank-mbp-m4")
# Import namespaced modules
mod data "config/just/data.just"
mod nvim "config/just/nvim.just"
mod yazi "config/just/yazi.just"
mod agents "config/just/agents.just"
# Aliases
alias s := switch
# ═══════════════════════════════════════════════════════════════════════════════
# COMMANDS
# ═══════════════════════════════════════════════════════════════════════════════
# List available commands
default:
@just --list
# ═══════════════════════════════════════════════════════════════════════════════
# SYSTEM
# ═══════════════════════════════════════════════════════════════════════════════
# Rebuild and switch local system configuration
switch: _preflight _completions _check _audit
#!/usr/bin/env bash
set -euo pipefail
echo "Switching configuration..."
sudo darwin-rebuild switch --flake .#{{ host }}
# Auto-GC if > 10 generations (non-critical, don't fail on errors)
gen_count=$(sudo darwin-rebuild --list-generations 2>/dev/null | wc -l | tr -d ' ' || echo "0")
if [ "$gen_count" -gt 10 ]; then
echo ""
echo "Auto-cleaning old generations ($gen_count > 10)..."
sudo nix-collect-garbage --delete-older-than 7d || true
nix store optimise || true
fi
echo ""
echo "✓ System switched"
# Deploy everything: system + data sync
deploy: switch
@echo ""
@echo "Syncing data to GCS..."
@just data push
@echo ""
@echo "✓ Full deployment complete"
# Validate configuration without applying
check: _preflight _check _audit-fast
@echo "✓ All checks passed"
# Full vulnerability audit (vulnix + osv-scanner + Homebrew freshness)
# Fails on Critical or High severity. Report under audit-reports/.
audit:
@./scripts/security-audit.sh
# Run audit in warn-only mode (for advisory contexts; never fails)
audit-no-gate:
@./scripts/security-audit.sh --no-gate
# Quarterly disk inventory (read-only). Report under audit-reports/disk/.
# Independent of `just switch` / `just check` — disk hygiene shouldn't gate rebuild.
disk-audit:
@./scripts/disk-audit.sh
# Rollback to previous generation
rollback:
sudo darwin-rebuild switch --rollback
# ═══════════════════════════════════════════════════════════════════════════════
# DEVELOPMENT
# ═══════════════════════════════════════════════════════════════════════════════
# Enter development shell with pre-commit hooks
dev:
nix develop -c $SHELL
# Update flake inputs (followed by audit so new inputs are checked for CVEs)
update:
nix flake update
@echo ""
@echo "Running post-update security audit..."
@./scripts/security-audit.sh
# ═══════════════════════════════════════════════════════════════════════════════
# GITHUB ACTIONS (Local)
# ═══════════════════════════════════════════════════════════════════════════════
# Read act arguments from config
act_args := shell("grep -v '^#' config/act/actrc | tr '\n' ' '")
# Run GitHub Actions locally (arguments passed to act)
# Usage: just gha -j job_name
gha *ARGS:
act {{ act_args }} {{ ARGS }}
# List available GitHub Actions jobs
gha-list:
@just gha -l
# Watch mode for rapid iteration on a specific job
# Usage: just gha-watch job_name
gha-watch JOB:
@echo "Watching for changes to run {{ JOB }}..."
@watchexec -e yml,yaml,ts,js,json,nix -- \
just gha -j {{ JOB }}
# Show system status and health
status:
#!/usr/bin/env bash
set -euo pipefail
echo "═══════════════════════════════════════════════════════════════"
echo " System Status"
echo "═══════════════════════════════════════════════════════════════"
echo ""
echo "Host: {{ host }}"
echo "Generation: $(darwin-rebuild --list-generations 2>/dev/null | tail -1 || echo 'N/A')"
echo "Flake: $(nix flake metadata --json 2>/dev/null | jq -r '.url' || echo 'git+file://.')"
echo ""
echo "Checks:"
which nix > /dev/null && echo " ✓ Nix" || echo " ✗ Nix"
which darwin-rebuild > /dev/null && echo " ✓ darwin-rebuild" || echo " ✗ darwin-rebuild"
test -f flake.nix && echo " ✓ flake.nix" || echo " ✗ flake.nix"
dirty=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
[ "$dirty" -eq 0 ] && echo " ✓ Git clean" || echo " ! Git dirty ($dirty files)"
nix flake check --no-build > /dev/null 2>&1 && echo " ✓ Flake valid" || echo " ✗ Flake check failed"
echo ""
echo "Evolution:"
bun run config/agents/evolution/evolve.ts --json 2>/dev/null | jq -r '" Score: \(.score_percent)% | Trend: \(.trend) | Recommendation: \(.recommendation)"' 2>/dev/null || echo " Run: just evolve"
# Evolution system dashboard
evolve *ARGS:
@bun run config/agents/evolution/evolve.ts {{ ARGS }}
# Grade system health (TypeScript - Effect-based)
grade:
@bun run config/agents/evolution/grade.ts
# Analyze trends and detect regressions
trends *ARGS:
@bun run config/agents/evolution/trend-alert.ts {{ ARGS }}
# Synthesize lessons into CLAUDE.md update proposals
reflect:
@bun run config/agents/evolution/reflect.ts
# ═══════════════════════════════════════════════════════════════════════════════
# CLAUDE CODE
# ═══════════════════════════════════════════════════════════════════════════════
# Check for Claude Code pattern updates
upgrade-check:
@echo "Checking for Claude Code updates..."
@echo ""
@echo "1. Current settings.json hooks:"
@jq -r '.hooks | keys[]' config/agents/settings.json 2>/dev/null || echo " (unable to read)"
@echo ""
@echo "2. Current skills:"
@ls -1 config/agents/skills/ 2>/dev/null | head -10 || echo " (unable to list)"
@echo ""
@echo "See config/agents/skills/upgrade/SKILL.md for manual upgrade workflow."
# Show upgrade diff (placeholder)
upgrade-diff:
@echo "Upgrade diff not yet implemented."
@echo "Run: just upgrade-check"
# ═══════════════════════════════════════════════════════════════════════════════
# COPIER (Project Scaffolding)
# ═══════════════════════════════════════════════════════════════════════════════
# Regenerate versions.json from SSOT (run before copier copy)
build-copier-versions:
@echo "Generating versions.json from SSOT..."
@cd config/quality && tsx templates/copier-monorepo/scripts/build-versions.ts
@echo "✓ versions.json updated"
# Create a new project from SSOT template
# Usage: just new-project my-app --data include_mobile=true
new-project NAME *ARGS:
#!/usr/bin/env bash
set -euo pipefail
echo "Creating project: {{ NAME }}"
just build-copier-versions
pipx run copier copy ~/dotfiles/config/quality/templates/copier-monorepo ./{{ NAME }} \
--data project_name={{ NAME }} \
{{ ARGS }} \
--trust
echo ""
echo "✓ Project created: {{ NAME }}"
echo ""
echo "Next steps:"
echo " cd {{ NAME }}"
echo " pnpm install"
echo " pnpm dev"
# ═══════════════════════════════════════════════════════════════════════════════
# HIDDEN HELPERS
# ═══════════════════════════════════════════════════════════════════════════════
# Check for untracked nix/config files
[private]
_preflight:
#!/usr/bin/env bash
set -euo pipefail
untracked=$(git ls-files --others --exclude-standard modules/ config/ | head -20)
if [ -n "$untracked" ]; then
echo "Error: Untracked files in modules/ or config/:"
echo "$untracked" | sed 's/^/ /'
echo ""
echo "Flakes only see tracked files. Run: git add <files>"
exit 1
fi
[private]
_completions:
#!/usr/bin/env bash
set -euo pipefail
cd config/completions
[ -d node_modules ] || pnpm install --silent
# Generate completions (quiet mode - only show summary)
output=$(pnpm run generate 2>&1)
generated=$(echo "$output" | grep -o 'Generated [0-9]* completion' | head -1 || echo "Generated 0 completion")
echo "✓ Completions: $generated files"
# Auto-stage generated completions if changed (Nix only sees tracked files)
cd ../..
if ! git diff --quiet config/completions/generated/ 2>/dev/null; then
git add config/completions/generated/
echo " (auto-staged updated completions)"
fi
# Validate formatting (fail on diff) and run flake checks
[private]
_check:
@nix fmt -- --fail-on-change .
@nix flake check --no-build
# Full audit (vulnix + osv-scanner). Fails on Critical/High. Used by `just switch`.
[private]
_audit:
@./scripts/security-audit.sh
# Fast audit (vulnix only, skips lockfile scan). Used by `just check` for tighter inner loop.
[private]
_audit-fast:
@./scripts/security-audit.sh --fast
[private]
_gc:
sudo nix-collect-garbage --delete-older-than 7d
nix store optimise
# ═══════════════════════════════════════════════════════════════════════════════
# TEST SUITES (hidden)
# ═══════════════════════════════════════════════════════════════════════════════
[private]
_test-ai:
@bats tests/ai-cli.bats
[private]
_test-ai-static:
@bats tests/ai-cli.bats --filter-tags '!live'
[private]
_test-rx:
@bats tests/repomix.bats
[private]
_test-quality:
cd config/brain && bun test
[private]
_verify-paragon:
@./scripts/verify-paragon.sh
# ═══════════════════════════════════════════════════════════════════════════════
# NIX DEBUG (hidden)
# ═══════════════════════════════════════════════════════════════════════════════
[private]
_nix-check:
@./scripts/verify-nix-optimization.sh
# ═══════════════════════════════════════════════════════════════════════════════
# PERFORMANCE (hidden)
# ═══════════════════════════════════════════════════════════════════════════════
[private]
_perf-report:
@echo "PARAGON Guard Performance"
@echo "========================="
@if [ ! -f ~/.claude-metrics/perf.jsonl ]; then \
echo "No metrics yet."; \
exit 0; \
fi
@echo "Total: $$(wc -l < ~/.claude-metrics/perf.jsonl | tr -d ' ') checks"
@echo "Blocked: $$(grep -c '"result":"block"' ~/.claude-metrics/perf.jsonl 2>/dev/null || echo 0)"
@echo "Approved: $$(grep -c '"result":"approve"' ~/.claude-metrics/perf.jsonl 2>/dev/null || echo 0)"
[private]
_perf-clear:
@rm -f ~/.claude-metrics/perf.jsonl
@echo "Metrics cleared"
# ═══════════════════════════════════════════════════════════════════════════════
# VERSIONING (semver via git tags)
# ═══════════════════════════════════════════════════════════════════════════════
# Show current version from git tags
version:
@git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0 (no tags)"
# Tag a new patch release (0.9.0 → 0.9.1)
release-patch:
#!/usr/bin/env bash
set -euo pipefail
current=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
IFS='.' read -r major minor patch <<< "$current"
new="v${major}.${minor}.$((patch + 1))"
echo "Releasing: v${current} → ${new}"
git tag -a "$new" -m "Release ${new}"
git push origin "$new"
echo "✓ Tagged and pushed ${new}"
# Tag a new minor release (0.9.0 → 0.10.0)
release-minor:
#!/usr/bin/env bash
set -euo pipefail
current=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
IFS='.' read -r major minor patch <<< "$current"
new="v${major}.$((minor + 1)).0"
echo "Releasing: v${current} → ${new}"
git tag -a "$new" -m "Release ${new}"
git push origin "$new"
echo "✓ Tagged and pushed ${new}"
# Tag a new major release (0.9.0 → 1.0.0)
release-major:
#!/usr/bin/env bash
set -euo pipefail
current=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
IFS='.' read -r major minor patch <<< "$current"
new="v$((major + 1)).0.0"
echo "Releasing: v${current} → ${new}"
git tag -a "$new" -m "Release ${new}"
git push origin "$new"
echo "✓ Tagged and pushed ${new}"