|
#!/bin/bash |
|
# |
|
# attendu-design-system-check — Ralph-style loop checking that new/changed |
|
# code uses @attendu/design-system components instead of raw HTML elements. |
|
# |
|
# Usage: |
|
# attendu-design-system-check |
|
# attendu-design-system-check 5 # custom max iterations |
|
# attendu-design-system-check 3 develop # custom base branch |
|
|
|
MAX_ITER="${1:-3}" |
|
BASE_BRANCH="${2:-main}" |
|
ITER=0 |
|
SIGNAL="ALL_CLEAN" |
|
TMPDIR_RALPH=$(mktemp -d) |
|
|
|
trap 'echo ""; echo "=== Interrupted. ==="; rm -rf "$TMPDIR_RALPH"; exit 130' INT TERM |
|
|
|
run_agent() { |
|
local label="$1" |
|
local outfile="$2" |
|
local prompt="$3" |
|
|
|
echo "[$label] Running..." |
|
echo "" |
|
|
|
claude -p --verbose --output-format stream-json --permission-mode acceptEdits "$prompt" 2>/dev/null \ |
|
| jq --unbuffered -rj 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text // empty' \ |
|
| tee "$outfile" |
|
|
|
echo "" |
|
} |
|
|
|
echo "=== Design System Usage Check ===" |
|
echo " Base: $BASE_BRANCH | Max iterations: $MAX_ITER" |
|
echo "" |
|
|
|
while [ "$ITER" -lt "$MAX_ITER" ]; do |
|
ITER=$((ITER + 1)) |
|
echo "--- Iteration $ITER/$MAX_ITER ---" |
|
|
|
DOUT="$TMPDIR_RALPH/ds.txt" |
|
|
|
# ── Agent: Design System Enforcer ─────────────────────────────── |
|
run_agent "DS Enforcer" "$DOUT" "You are enforcing usage of the @attendu/design-system component library. |
|
|
|
This project has a design system with these auto-imported components (no import needed): |
|
|
|
BUTTONS & CONTROLS: Button, ButtonGroup, Popover, Tooltip |
|
FORM & INPUT: TextInput, TextArea, NumberInput, PhoneInput, DatePicker, TimeInput, TimeRange, Select, Cascader, PlaceInput, Checkbox, CheckboxGroup, RadioGroup, ColorPicker, Switch, ToggleButtons, InputBlock |
|
LAYOUT: Form, Dialog, DialogHeader, Modal, Navigation, NavigationItem, Tabs, Stepper, ActionList, ActionListItem, DynamicList, DynamicListItem |
|
DATA DISPLAY: Avatar, Badge, Icon, StatTile, ProgressPie, EmptyState, Callout |
|
FILE & MEDIA: ImageUpload, AvatarChange, Thumbnail |
|
|
|
Inspect all changed .vue files on this branch vs $BASE_BRANCH: |
|
git diff $BASE_BRANCH -- '*.vue' |
|
git diff --cached -- '*.vue' |
|
|
|
In the CHANGED/NEW code (not pre-existing code), find raw HTML elements that should use design system components instead: |
|
<button> → <Button> |
|
<input> → <TextInput>, <NumberInput>, <PhoneInput>, etc. (match by type) |
|
<textarea> → <TextArea> |
|
<select> → <Select> |
|
<dialog> → <Dialog> |
|
<img> used as avatar → <Avatar> |
|
<a> styled as button → <Button> |
|
Raw checkbox/radio inputs → <Checkbox>, <RadioGroup> |
|
Raw toggle/switch → <Switch> |
|
Custom empty states → <EmptyState> |
|
Custom tooltips → <Tooltip> |
|
Custom popovers → <Popover> |
|
|
|
IMPORTANT: Only flag elements in code that was ADDED or CHANGED on this branch. Do not touch pre-existing code. Look at the actual source files to understand context — a raw <button> inside a design system component itself is fine, but a raw <button> in a page or app component should use <Button>. |
|
|
|
NEVER run git commit or git add. You may edit files to replace raw elements with design system components, but never commit. |
|
|
|
For each replacement, ensure you preserve all existing attributes, event handlers, classes, and slots. Check the component file to understand its props before replacing. |
|
|
|
If all changed code properly uses design system components: respond with ONLY the exact text ALL_CLEAN and nothing else." |
|
|
|
echo "" |
|
if grep -q "$SIGNAL" "$DOUT"; then |
|
echo "[DS Enforcer] All clean — design system components used properly." |
|
else |
|
echo "[DS Enforcer] Found and fixed raw HTML elements." |
|
fi |
|
echo "" |
|
|
|
# ── Check convergence ────────────────────────────────────────── |
|
if grep -q "$SIGNAL" "$DOUT"; then |
|
echo "=== Design system usage verified. Done! ===" |
|
rm -rf "$TMPDIR_RALPH" |
|
exit 0 |
|
fi |
|
|
|
done |
|
|
|
echo "=== Max iterations ($MAX_ITER) reached. ===" |
|
rm -rf "$TMPDIR_RALPH" |
|
exit 1 |