@jeiemgi/cckit 0.4.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +9 -1
- package/bin/cckit +18 -0
- package/cckit.config.json +2 -2
- package/package.json +1 -1
- package/scripts/benchmark/benchmark-test.sh +83 -0
- package/scripts/benchmark/gate.sh +55 -0
- package/scripts/benchmark/lib/bench-common.sh +70 -0
- package/scripts/benchmark/lib/model.sh +116 -0
- package/scripts/benchmark/report.sh +105 -0
- package/scripts/benchmark/run-quality.sh +102 -0
- package/scripts/benchmark/run.sh +166 -0
- package/scripts/benchmark/stop-check.sh +83 -0
- package/scripts/commitlint-test.sh +58 -0
- package/scripts/init.sh +26 -0
- package/scripts/kit-self-update.sh +55 -0
- package/scripts/lib/commitlint.sh +53 -0
- package/scripts/lib/kit-task-ops-test.sh +21 -0
- package/scripts/lib/kit-task-ops.sh +50 -2
- package/scripts/orchestrate.sh +8 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status.sh +53 -40
- package/scripts/task-sync.sh +13 -0
- package/scripts/ux-a11y-scan.sh +96 -0
- package/scripts/ux-ds-audit.sh +146 -0
- package/scripts/ux-graph-scan.sh +188 -0
- package/skills/kit-autopilot/SKILL.md +6 -1
- package/skills/kit-ux-audit/SKILL.md +241 -0
- package/skills/kit-ux-audit/references/a11y.md +79 -0
- package/skills/kit-ux-audit/references/consistency.md +106 -0
- package/skills/kit-ux-audit/references/graph-model.md +92 -0
- package/skills/kit-ux-audit/references/heuristics.md +157 -0
- package/skills/kit-ux-audit/references/report.md +172 -0
- package/templates/agents/ux.md +89 -0
- package/templates/benchmarks/SCHEMA.md +75 -0
- package/templates/benchmarks/abstain.jsonl +8 -0
- package/templates/benchmarks/adversarial.jsonl +8 -0
- package/templates/benchmarks/benchmark.config.json +14 -0
- package/templates/benchmarks/quality.jsonl +8 -0
- package/templates/benchmarks/retrieval.jsonl +7 -0
- package/templates/settings/settings.json.tmpl +9 -0
package/scripts/status.sh
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# status.sh - a thin
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
2
|
+
# status.sh - a thin status viewer: the board, active worktrees/branches, and the resume handoff on
|
|
3
|
+
# one screen. Output is MARKDOWN routed through the rendering seam (#82): rich via glow in a TTY,
|
|
4
|
+
# verbatim markdown otherwise (renders natively in Claude Code, always pipe-safe — no escape codes
|
|
5
|
+
# leak into a redirect). This is the lightweight cockpit; the rich opentui TUI is an OPTIONAL
|
|
6
|
+
# separate adapter — the core stays pure bash and dependency-light, so `cckit status` works anywhere.
|
|
6
7
|
set -euo pipefail
|
|
7
8
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
8
9
|
# shellcheck source=/dev/null
|
|
9
10
|
source "$ROOT/scripts/lib/ui.sh" 2>/dev/null || true
|
|
10
11
|
# shellcheck source=/dev/null
|
|
12
|
+
source "$ROOT/scripts/lib/render.sh" 2>/dev/null || true
|
|
13
|
+
# shellcheck source=/dev/null
|
|
11
14
|
source "$ROOT/scripts/lib/kit-config.sh" && load_kit_config
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
# _status_md — compose the whole dashboard as one markdown document on stdout.
|
|
17
|
+
_status_md() {
|
|
18
|
+
echo "# cckit status — $KIT_REPO"
|
|
19
|
+
echo "_base ${KIT_BASE_BRANCH:-main}_"
|
|
20
|
+
echo ""
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
# Board: open issues, blocked count. Fetch the board as a JSON ARRAY directly (#142) — the
|
|
23
|
+
# `task-sync --llm` output is TOON, not JSON, so piping it into `jq 'length'` mis-parses it (the
|
|
24
|
+
# leading `[N]` header reads as a 1-element array, then jq errors and the `|| echo 0` fallback
|
|
25
|
+
# concatenates onto the partial output, yielding a value like "1\n0" that breaks `[ "$open" -gt 8 ]`
|
|
26
|
+
# with "integer expression expected"). A clean JSON array keeps every count a single integer.
|
|
27
|
+
echo "## Board"
|
|
28
|
+
if command -v jq >/dev/null 2>&1 && command -v gh >/dev/null 2>&1; then
|
|
29
|
+
local board open blocked
|
|
30
|
+
board="$(gh issue list --repo "$KIT_REPO" --state open --limit 200 --json number,title,body 2>/dev/null \
|
|
31
|
+
| jq -c '[.[] | {number, title, blocked: ((.body // "") | test("Blocked by"))}]' 2>/dev/null || echo '[]')"
|
|
32
|
+
[ -n "$board" ] || board='[]'
|
|
33
|
+
open="$(printf '%s' "$board" | jq 'length' 2>/dev/null || echo 0)"
|
|
34
|
+
blocked="$(printf '%s' "$board" | jq '[.[]|select(.blocked)]|length' 2>/dev/null || echo 0)"
|
|
35
|
+
case "$open" in ''|*[!0-9]*) open=0 ;; esac # never let a non-integer reach the test below
|
|
36
|
+
case "$blocked" in ''|*[!0-9]*) blocked=0 ;; esac
|
|
37
|
+
echo "open issues: $open blocked: $blocked"
|
|
38
|
+
echo ""
|
|
39
|
+
printf '%s' "$board" | jq -r '.[:8][] | "- #\(.number) \(.title[0:56])"' 2>/dev/null || true
|
|
40
|
+
[ "$open" -gt 8 ] && echo "- … and $((open - 8)) more (\`cckit sync\`)"
|
|
41
|
+
else
|
|
42
|
+
echo "_(jq/gh absent — run \`cckit sync\`)_"
|
|
43
|
+
fi
|
|
44
|
+
echo ""
|
|
18
45
|
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[ -n "$board" ] || board='[]'
|
|
29
|
-
open="$(printf '%s' "$board" | jq 'length' 2>/dev/null || echo 0)"
|
|
30
|
-
blocked="$(printf '%s' "$board" | jq '[.[]|select(.blocked)]|length' 2>/dev/null || echo 0)"
|
|
31
|
-
case "$open" in ''|*[!0-9]*) open=0 ;; esac # never let a non-integer reach the test below
|
|
32
|
-
case "$blocked" in ''|*[!0-9]*) blocked=0 ;; esac
|
|
33
|
-
echo " open issues: $open blocked: $blocked"
|
|
34
|
-
printf '%s' "$board" | jq -r '.[:8][] | " #\(.number) \(.title[0:56])"' 2>/dev/null || true
|
|
35
|
-
[ "$open" -gt 8 ] && echo " ... and $((open - 8)) more (cckit sync)"
|
|
36
|
-
else
|
|
37
|
-
echo " (jq/gh absent - run cckit sync)"
|
|
38
|
-
fi
|
|
39
|
-
hr
|
|
46
|
+
# Worktrees + branches: SAFE-to-prune vs active (reuse the gc analysis). Kept in a fenced block so
|
|
47
|
+
# glow renders the aligned gc columns monospaced and the markdown stays faithful.
|
|
48
|
+
echo "## Worktrees and branches"
|
|
49
|
+
echo '```'
|
|
50
|
+
# shellcheck source=/dev/null
|
|
51
|
+
source "$ROOT/scripts/lib/kit-gc.sh"
|
|
52
|
+
kit_gc_analyze 2>/dev/null | grep -E 'SAFE|ACTIVE|PROTECTED|ORPHAN' | head -12 || echo "(clean)"
|
|
53
|
+
echo '```'
|
|
54
|
+
echo ""
|
|
40
55
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
source
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
# Resume handoff, if one is saved.
|
|
57
|
+
echo "## Resume handoff"
|
|
58
|
+
echo '```'
|
|
59
|
+
# shellcheck source=/dev/null
|
|
60
|
+
source "$ROOT/scripts/lib/handoff.sh"
|
|
61
|
+
handoff_read
|
|
62
|
+
echo '```'
|
|
63
|
+
}
|
|
47
64
|
|
|
48
|
-
|
|
49
|
-
sec "Resume handoff"
|
|
50
|
-
# shellcheck source=/dev/null
|
|
51
|
-
source "$ROOT/scripts/lib/handoff.sh"
|
|
52
|
-
handoff_read | sed 's/^/ /'
|
|
65
|
+
if command -v cckit_render >/dev/null 2>&1; then _status_md | cckit_render; else _status_md; fi
|
package/scripts/task-sync.sh
CHANGED
|
@@ -6,6 +6,10 @@ set -euo pipefail
|
|
|
6
6
|
source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
|
|
7
7
|
# Pure board-view render helpers (merge queue, stale flag, not-on-board flag, Project Status).
|
|
8
8
|
source "$(dirname "$0")/lib/board-view.sh"
|
|
9
|
+
# The rendering seam (#82): the human board is markdown, routed through cckit_render — rich via glow
|
|
10
|
+
# in a TTY, verbatim markdown otherwise (renders natively in Claude Code, pipe-safe).
|
|
11
|
+
source "$(dirname "$0")/lib/ui.sh" 2>/dev/null || true
|
|
12
|
+
source "$(dirname "$0")/lib/render.sh" 2>/dev/null || true
|
|
9
13
|
|
|
10
14
|
ROLE_FILTER=""; MS_FILTER=""
|
|
11
15
|
while [[ $# -gt 0 ]]; do
|
|
@@ -64,6 +68,9 @@ fi
|
|
|
64
68
|
PRS_JSON="$(gh pr list --repo "$KIT_REPO" --state open --limit 100 \
|
|
65
69
|
--json number,title,labels,isDraft,headRefName,reviewDecision,mergeable 2>/dev/null || echo '[]')"
|
|
66
70
|
|
|
71
|
+
# All human output is composed as markdown inside this function, then piped once through
|
|
72
|
+
# cckit_render (below) so the whole board — tables, headings, flags — renders as one document.
|
|
73
|
+
_board_human() {
|
|
67
74
|
echo "## Board — $KIT_REPO"
|
|
68
75
|
echo ""
|
|
69
76
|
|
|
@@ -126,3 +133,9 @@ if [ -f "$(dirname "$0")/lib/kit-local.sh" ]; then
|
|
|
126
133
|
2>/dev/null || echo "_(local digest unavailable)_"
|
|
127
134
|
fi
|
|
128
135
|
fi
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Emit the composed markdown through the rendering seam. cckit_render is rich (glow) only on a TTY;
|
|
139
|
+
# piped or in the Claude Code transcript it passes the markdown through verbatim (pipe-safe, no
|
|
140
|
+
# escape codes). Fall back to a plain call if render.sh was unavailable.
|
|
141
|
+
if command -v cckit_render >/dev/null 2>&1; then _board_human | cckit_render; else _board_human; fi
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ux-a11y-scan.sh — deterministic detector for /kit-ux-audit's `a11y` lane.
|
|
3
|
+
#
|
|
4
|
+
# Emits RAW occurrence lists of semantic-HTML and accessibility smells the `kit-ux-audit` skill
|
|
5
|
+
# classifies (see references/a11y.md). Pure grep/perl ($0, no model call, no grep -P), scoped to a
|
|
6
|
+
# path, macOS-safe. It never decides — it only finds. Static regex over TSX/JSX, so it flags
|
|
7
|
+
# candidates, not confirmed defects; the model confirms and prioritizes.
|
|
8
|
+
#
|
|
9
|
+
# usage: scripts/ux-a11y-scan.sh <path> [--exclude <regex>]
|
|
10
|
+
set -eu
|
|
11
|
+
|
|
12
|
+
USAGE="usage: ux-a11y-scan.sh <path> [--exclude <regex>]"
|
|
13
|
+
TARGET=""; EXCLUDE='__never__'
|
|
14
|
+
while [[ $# -gt 0 ]]; do
|
|
15
|
+
case "$1" in
|
|
16
|
+
--exclude)
|
|
17
|
+
[[ $# -ge 2 && -n "${2:-}" ]] || { echo "ux-a11y-scan: --exclude needs a value" >&2; exit 2; }
|
|
18
|
+
EXCLUDE="$2"; shift 2 ;;
|
|
19
|
+
-h|--help) sed -n 2,11p "$0"; exit 0 ;;
|
|
20
|
+
*) TARGET="$1"; shift ;;
|
|
21
|
+
esac
|
|
22
|
+
done
|
|
23
|
+
[[ -n "$TARGET" ]] || { echo "$USAGE" >&2; exit 2; }
|
|
24
|
+
[[ -e "$TARGET" ]] || { echo "ux-a11y-scan: no such path: $TARGET" >&2; exit 2; }
|
|
25
|
+
|
|
26
|
+
FILES=$(find "$TARGET" \( -name node_modules -o -name .next -o -name dist -o -name build \) -prune -o \
|
|
27
|
+
-type f \( -name '*.tsx' -o -name '*.jsx' \) -print | grep -Ev "$EXCLUDE" | sort)
|
|
28
|
+
COUNT=$(printf '%s\n' "$FILES" | grep -c . || true)
|
|
29
|
+
g() { printf '%s\n' "$FILES" | xargs grep -nE "$1" 2>/dev/null || true; }
|
|
30
|
+
section() { printf '\n## %s\n' "$1"; }
|
|
31
|
+
tally() { local n; n=$(printf '%s' "$1" | grep -c . || true); printf '(%s hits)\n' "$n"; }
|
|
32
|
+
|
|
33
|
+
echo "# ux-a11y-scan · $TARGET · $COUNT files · $(date +%F)"
|
|
34
|
+
[[ "$EXCLUDE" != "__never__" ]] && echo "excluding: $EXCLUDE"
|
|
35
|
+
|
|
36
|
+
# A1. Non-semantic interactive elements — a click/key handler on a <div>/<span>, or role="button"
|
|
37
|
+
# on a non-button without keyboard support. Should be <button> / <a>.
|
|
38
|
+
section "A1 NON_SEMANTIC_INTERACTIVE — onClick/onKeyDown on <div>/<span>, or role=button on a non-button (→ <button>/<a>)"
|
|
39
|
+
OUT=$(g '<(div|span|li|tr|td)\b[^>]*\bon(Click|KeyDown|KeyUp|KeyPress)='); tally "$OUT"; printf '%s\n' "$OUT"
|
|
40
|
+
printf -- '-- role="button|link|checkbox|tab" on a non-native element:\n'
|
|
41
|
+
g '<(div|span|li|a)\b[^>]*\brole="(button|link|checkbox|switch|tab|menuitem)"' || true
|
|
42
|
+
printf -- '-- redundant role on a native element (role="button" on <button>, role="link" on <a>):\n'
|
|
43
|
+
g '<button\b[^>]*\brole="button"|<a\b[^>]*\brole="link"|<nav\b[^>]*\brole="navigation"|<main\b[^>]*\brole="main"' || true
|
|
44
|
+
|
|
45
|
+
# A2. Missing text alternatives. (grep -E has no lookahead — filter with a second grep.)
|
|
46
|
+
section "A2 MISSING_TEXT_ALT — <img> without alt, decorative alt to confirm, icon-only SVG without a name"
|
|
47
|
+
printf -- '-- <img> with NO alt attribute on the line:\n'
|
|
48
|
+
g '<img\b' | grep -v 'alt=' || true
|
|
49
|
+
printf -- '-- <img alt=""> (decorative — confirm it carries no meaning):\n'
|
|
50
|
+
g '<img\b[^>]*\balt=""' || true
|
|
51
|
+
printf -- '-- <svg> as an image without aria-label/aria-labelledby/aria-hidden on the line:\n'
|
|
52
|
+
g '<svg\b' | grep -vE 'aria-label|aria-labelledby|aria-hidden|<title' || true
|
|
53
|
+
|
|
54
|
+
# A3. Unlabeled controls.
|
|
55
|
+
section "A3 UNLABELED_CONTROL — inputs without a name, icon-only buttons without a name"
|
|
56
|
+
printf -- '-- <input|select|textarea> with no id / aria-label / aria-labelledby on the line (needs a <label>):\n'
|
|
57
|
+
g '<(input|select|textarea)\b' | grep -vE '\b(id|aria-label|aria-labelledby)=' || true
|
|
58
|
+
printf -- '-- <label> without htmlFor on the line (implicit-wrap only if the control is nested — confirm):\n'
|
|
59
|
+
g '<label\b' | grep -v 'htmlFor=' || true
|
|
60
|
+
printf -- '-- <button> directly wrapping an icon/SVG with no aria-label on the line (same-line case):\n'
|
|
61
|
+
g '<button\b[^>]*>[[:space:]]*<([A-Z][A-Za-z]*Icon|svg)\b' | grep -v 'aria-label' || true
|
|
62
|
+
|
|
63
|
+
# A4. Heading order & landmarks.
|
|
64
|
+
section "A4 HEADING_LANDMARK — heading-level jumps, missing/duplicate landmarks, unnamed regions"
|
|
65
|
+
printf -- '-- files using <h3>/<h4>/<h5> but no <h1>/<h2> in the same file:\n'
|
|
66
|
+
printf '%s\n' "$FILES" | while IFS= read -r f; do
|
|
67
|
+
[[ -n "$f" ]] || continue
|
|
68
|
+
if grep -qE '<h[345]\b' "$f" && ! grep -qE '<h[12]\b' "$f"; then echo " $f"; fi
|
|
69
|
+
done
|
|
70
|
+
printf -- '-- more than one <main> in a file:\n'
|
|
71
|
+
printf '%s\n' "$FILES" | while IFS= read -r f; do
|
|
72
|
+
[[ -n "$f" ]] || continue
|
|
73
|
+
n=$(grep -oE '<main\b' "$f" | wc -l | tr -d ' '); [[ "${n:-0}" -gt 1 ]] && echo " $f ($n)"
|
|
74
|
+
done
|
|
75
|
+
printf -- '-- landmark typed as a styled <div> (className with nav/header/footer/sidebar/main):\n'
|
|
76
|
+
g '<div\b[^>]*className="[^"]*\b(navbar|nav-|sidebar|site-header|site-footer|app-header|app-footer|main-content)\b' || true
|
|
77
|
+
printf -- '-- <section> / <article> with no accessible name on the line (no aria-label/aria-labelledby):\n'
|
|
78
|
+
g '<(section|article)\b' | grep -vE 'aria-label|aria-labelledby' || true
|
|
79
|
+
|
|
80
|
+
# A5. Focus & keyboard.
|
|
81
|
+
section "A5 FOCUS_KEYBOARD — positive tabindex, hover-only handlers, focus removed, aria-hidden on interactives"
|
|
82
|
+
printf -- '-- positive tabIndex (creates an unpredictable tab order):\n'
|
|
83
|
+
g 'tabIndex=\{[1-9][0-9]*\}|tabindex="[1-9]' || true
|
|
84
|
+
printf -- '-- onMouseOver/onMouseEnter without a matching onFocus on the line (keyboard cannot trigger it):\n'
|
|
85
|
+
g 'onMouse(Over|Enter)=' | grep -v 'onFocus=' || true
|
|
86
|
+
printf -- '-- focus outline removed with no focus-visible replacement in the same file:\n'
|
|
87
|
+
printf '%s\n' "$FILES" | while IFS= read -r f; do
|
|
88
|
+
[[ -n "$f" ]] || continue
|
|
89
|
+
if grep -qE 'outline-none|outline:\s*none|outline:\s*0' "$f" && ! grep -qE 'focus-visible|focusVisible' "$f"; then echo " $f"; fi
|
|
90
|
+
done
|
|
91
|
+
printf -- '-- aria-hidden="true" on an element that also has a handler / tabIndex / href:\n'
|
|
92
|
+
g '<[a-zA-Z][^>]*\baria-hidden="true"[^>]*\b(onClick=|tabIndex=|href=)' || true
|
|
93
|
+
printf -- '-- autoFocus (moves focus on load — confirm it is wanted):\n'
|
|
94
|
+
g '\bautoFocus\b' || true
|
|
95
|
+
|
|
96
|
+
echo; echo "# end — classify with skills/kit-ux-audit/references/a11y.md"
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ux-ds-audit.sh — deterministic half of /kit-ux-audit's `consistency` lane.
|
|
3
|
+
#
|
|
4
|
+
# Nothing project-specific: the shared-UI barrel, the custom-class prefix and the theme css are all
|
|
5
|
+
# parameters (--primitives / --css-prefix / --css), so it runs against any design system.
|
|
6
|
+
#
|
|
7
|
+
# Emits RAW occurrence lists the `kit-ux-audit` skill classifies (LAYOUT / VISUAL / BEHAVIOR,
|
|
8
|
+
# variant proposals, sibling-screen comparison). Pure grep/perl ($0, no model call, no grep -P),
|
|
9
|
+
# scoped to a path, macOS-safe. This script never decides — it only finds.
|
|
10
|
+
#
|
|
11
|
+
# usage: scripts/ux-ds-audit.sh <path> [--exclude <regex>] [--primitives <index.ts>]
|
|
12
|
+
# [--css-prefix <prefix>] [--css <file.css>]
|
|
13
|
+
# <path> file or directory to audit (e.g. apps/web/src, apps/web/src/app/sign-in)
|
|
14
|
+
# --exclude regex of paths to skip (node_modules/.next/dist always skipped)
|
|
15
|
+
# --primitives the shared UI barrel to read primitive names from (default packages/ui/src/index.ts)
|
|
16
|
+
# --css-prefix custom-class prefix to hunt in TSX/JSX (no default; section 8's TSX hunt is
|
|
17
|
+
# skipped when omitted — the data-* and dead-CSS probes still run)
|
|
18
|
+
# --css theme css file(s) to cross-check custom classes against (repeatable)
|
|
19
|
+
set -eu # no pipefail: many probes end in a grep that legitimately finds nothing
|
|
20
|
+
|
|
21
|
+
USAGE="usage: ux-ds-audit.sh <path> [--exclude re] [--primitives index.ts] [--css-prefix p] [--css file]"
|
|
22
|
+
TARGET=""; EXCLUDE='__never__'; PRIMS="packages/ui/src/index.ts"; CSS_PREFIX=""; CSS_FILES=()
|
|
23
|
+
while [[ $# -gt 0 ]]; do
|
|
24
|
+
case "$1" in
|
|
25
|
+
--exclude|--primitives|--css-prefix|--css)
|
|
26
|
+
if [[ $# -lt 2 || -z "$2" ]]; then echo "ux-ds-audit: $1 needs a value" >&2; echo "$USAGE" >&2; exit 2; fi
|
|
27
|
+
case "$1" in
|
|
28
|
+
--exclude) EXCLUDE="$2" ;;
|
|
29
|
+
--primitives) PRIMS="$2" ;;
|
|
30
|
+
--css-prefix) CSS_PREFIX="$2" ;;
|
|
31
|
+
--css) CSS_FILES+=("$2") ;;
|
|
32
|
+
esac
|
|
33
|
+
shift 2 ;;
|
|
34
|
+
-h|--help) sed -n 2,20p "$0"; exit 0 ;;
|
|
35
|
+
*) TARGET="$1"; shift ;;
|
|
36
|
+
esac
|
|
37
|
+
done
|
|
38
|
+
[[ -n "$TARGET" ]] || { echo "$USAGE" >&2; exit 2; }
|
|
39
|
+
[[ -e "$TARGET" ]] || { echo "ux-ds-audit: no such path: $TARGET" >&2; exit 2; }
|
|
40
|
+
|
|
41
|
+
# The file set — TSX/JSX only, minus build output and the exclude regex.
|
|
42
|
+
files() {
|
|
43
|
+
find "$TARGET" \( -name node_modules -o -name .next -o -name dist -o -name build \) -prune -o \
|
|
44
|
+
-type f \( -name '*.tsx' -o -name '*.jsx' \) -print \
|
|
45
|
+
| grep -Ev "$EXCLUDE" | sort
|
|
46
|
+
}
|
|
47
|
+
FILES=$(files)
|
|
48
|
+
COUNT=$(printf '%s\n' "$FILES" | grep -c . || true)
|
|
49
|
+
g() { printf '%s\n' "$FILES" | xargs grep -nE "$1" 2>/dev/null || true; }
|
|
50
|
+
|
|
51
|
+
section() { printf '\n## %s\n' "$1"; }
|
|
52
|
+
tally() { local n; n=$(printf '%s' "$1" | grep -c . || true); printf '(%s hits)\n' "$n"; }
|
|
53
|
+
|
|
54
|
+
echo "# ux-ds-audit · $TARGET · $COUNT files · $(date +%F)"
|
|
55
|
+
[[ "$EXCLUDE" != "__never__" ]] && echo "excluding: $EXCLUDE"
|
|
56
|
+
echo "primitives barrel: $PRIMS · custom-class prefix: ${CSS_PREFIX:-(none — pass --css-prefix)}"
|
|
57
|
+
|
|
58
|
+
# 1. Shared-UI primitives rendered WITH a className — the variant-candidate pool.
|
|
59
|
+
section "1 PRIMITIVE_CLASSNAME — shared primitives carrying a className (classify LAYOUT / VISUAL / BEHAVIOR)"
|
|
60
|
+
if [[ -f "$PRIMS" ]]; then
|
|
61
|
+
NAMES=$(perl -0ne 'while(/export\s*\{([^}]*)\}/g){for(split /,/,$1){s/^\s+|\s+$//g; next if /^type\s/; next unless /^[A-Z]/; print "$_\n"}}' "$PRIMS" | sort -u | paste -sd'|' -)
|
|
62
|
+
export NAMES
|
|
63
|
+
OUT=$(printf '%s\n' "$FILES" | while IFS= read -r f; do perl -0ne '
|
|
64
|
+
my $names = $ENV{NAMES};
|
|
65
|
+
while (/<($names)\b((?:(?!(?<!=)>)[\s\S])*?)className=\s*(\{[^}]*\}|"[^"]*")/g) {
|
|
66
|
+
my ($c,$cls)=($1,$3); my $ln = (substr($_,0,$-[0]) =~ tr/\n//)+1;
|
|
67
|
+
$cls =~ s/\s+/ /g; print "$ARGV:$ln\t$c\t$cls\n";
|
|
68
|
+
}' "$f"; done)
|
|
69
|
+
tally "$OUT"; printf '%s\n' "$OUT"
|
|
70
|
+
printf '\nper component:\n'; printf '%s\n' "$OUT" | awk -F'\t' 'NF{c[$2]++} END{for(k in c) printf " %3d %s\n", c[k], k}' | sort -rn
|
|
71
|
+
else
|
|
72
|
+
echo "(primitives barrel not found: $PRIMS — pass --primitives; section skipped)"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# 2. Hand-rolled page headers: a heading carrying a type-* / display role.
|
|
76
|
+
section "2 HEADINGS — <h1-3> with a type-*/display role outside a PageHeader primitive (align? eyebrow? actions? → PageHeader variant)"
|
|
77
|
+
OUT=$(g '<h[1-3][^>]*className="[^"]*(type-(hero|section|h1|h2|display|title)|text-(3xl|4xl|5xl))'); tally "$OUT"; printf '%s\n' "$OUT"
|
|
78
|
+
|
|
79
|
+
# 3. Hand-rolled card surfaces: card chrome typed by hand on a non-Card element.
|
|
80
|
+
section "3 CARD_SURFACES — rounded + border + surface/elevated bg typed by hand (→ Card / Card asChild)"
|
|
81
|
+
OUT=$(g 'className="[^"]*rounded-(md|lg|xl|2xl)' | grep -E 'className="[^"]*border(-border)?-(default|subtle|muted)?' | grep -E 'className="[^"]*bg-(surface|elevated|card|background)' | grep -v '<Card' || true)
|
|
82
|
+
tally "$OUT"; printf '%s\n' "$OUT"
|
|
83
|
+
|
|
84
|
+
# 4. Hand-rolled skeletons.
|
|
85
|
+
section "4 SKELETONS — animate-pulse outside the UI package (→ Skeleton); per file + fill-token drift"
|
|
86
|
+
OUT=$(g 'animate-pulse'); tally "$OUT"
|
|
87
|
+
printf '%s\n' "$OUT" | cut -d: -f1 | sort | uniq -c | sort -rn | awk '{printf " %3d %s\n", $1, $2}'
|
|
88
|
+
printf 'fill tokens used: '; printf '%s\n' "$OUT" | grep -oE 'bg-[a-z-]+' | sort | uniq -c | sort -rn | awk '{printf "%s×%s ", $2, $1}'; echo
|
|
89
|
+
|
|
90
|
+
# 5. Status / live-region lines.
|
|
91
|
+
section "5 STATUS_LINES — role=status|alert / aria-live typed by hand (tone drift? → StatusText / Alert)"
|
|
92
|
+
OUT=$(g 'role="(status|alert)"|aria-live='); tally "$OUT"; printf '%s\n' "$OUT"
|
|
93
|
+
|
|
94
|
+
# 6. Raw controls + link-as-text recipes.
|
|
95
|
+
section "6 RAW_CONTROLS — raw <button|input|select|textarea> (→ Button/Input/…) and underline link recipes (→ TextLink)"
|
|
96
|
+
OUT=$(g '<(button|input|select|textarea)\b' | grep -v 'type="hidden"' || true); tally "$OUT"; printf '%s\n' "$OUT"
|
|
97
|
+
printf -- '-- underline links:\n'; OUT=$(g 'className="[^"]*\bunderline\b'); tally "$OUT"; printf '%s\n' "$OUT"
|
|
98
|
+
|
|
99
|
+
# 7. Card grids — distinct recipes, so page ↔ loading drift shows up.
|
|
100
|
+
section "7 CARD_GRIDS — grid grid-cols-* recipes (→ CardGrid variants; page vs loading.tsx must match)"
|
|
101
|
+
OUT=$(g 'className="[^"]*\bgrid\b[^"]*grid-cols-'); tally "$OUT"
|
|
102
|
+
printf '%s\n' "$OUT" | grep -oE 'className="[^"]*"' | perl -pe 's/\b(m[tbxy]?|p[tbxy]?)-[0-9.]+ ?//g; s/[ \t]+/ /g; s/ "/"/g' | sort | uniq -c | sort -rn | awk '{c=$1; $1=""; printf " %3d %s\n", c, $0}'
|
|
103
|
+
printf -- '-- occurrences:\n%s\n' "$OUT"
|
|
104
|
+
|
|
105
|
+
# 8. Custom theme classes + data-* styling hooks in TSX (variants in disguise vs page layout).
|
|
106
|
+
section "8 CUSTOM_CSS — custom classes and data-* styling hooks in TSX (restyling a primitive from outside = variant in disguise)"
|
|
107
|
+
if [[ -n "$CSS_PREFIX" ]]; then
|
|
108
|
+
OUT=$(g "\b${CSS_PREFIX}[a-z0-9-]+"); tally "$OUT"
|
|
109
|
+
printf '%s\n' "$OUT" | grep -oE "\b${CSS_PREFIX}[a-z0-9-]+" | sort | uniq -c | sort -rn | awk '{printf " %3d %s\n", $1, $2}'
|
|
110
|
+
printf -- '-- occurrences:\n%s\n' "$OUT"
|
|
111
|
+
else
|
|
112
|
+
echo "(no --css-prefix — skipping the TSX custom-class hunt; pass one to enable)"
|
|
113
|
+
fi
|
|
114
|
+
printf -- '-- data-* hooks (styling attributes, not Radix state):\n'; g '\bdata-[a-z-]+=(""|\{)' | grep -vE 'data-(slot|state|side|variant|size|orientation|disabled|testid)=' || true
|
|
115
|
+
if [[ -n "$CSS_PREFIX" && ${#CSS_FILES[@]} -gt 0 ]]; then
|
|
116
|
+
printf -- '-- defined in css but ZERO tsx references (dead):\n'
|
|
117
|
+
for css in "${CSS_FILES[@]}"; do
|
|
118
|
+
[[ -f "$css" ]] || { echo " (css not found: $css)"; continue; }
|
|
119
|
+
grep -oE "\.${CSS_PREFIX}[a-z0-9-]+" "$css" | sort -u | tr -d . | while read -r cls; do
|
|
120
|
+
n=$(printf '%s\n' "$FILES" | xargs grep -l "\b$cls\b" 2>/dev/null | wc -l | tr -d ' ')
|
|
121
|
+
if [[ "$n" == "0" ]]; then echo " $cls ($css)"; fi
|
|
122
|
+
done
|
|
123
|
+
done
|
|
124
|
+
printf -- '-- css rules that reach INTO a primitive (descendant selector on a data-slot / role):\n'
|
|
125
|
+
grep -nE "\.${CSS_PREFIX}[a-z0-9-]+[^{]*\[data-slot=|\.${CSS_PREFIX}[a-z0-9-]+[^{]*\[role=" "${CSS_FILES[@]}" 2>/dev/null || echo " (none)"
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# 9. Icon size/stroke props — metadata that should live in the primitive.
|
|
129
|
+
section "9 ICON_PROPS — <XxxIcon size={N} strokeWidth={S}> repeated tuples (→ the primitive owns icon sizing)"
|
|
130
|
+
OUT=$(g '<[A-Z][A-Za-z]*Icon\b'); tally "$OUT"
|
|
131
|
+
printf -- '-- occurrences (file:line):\n%s\n' "$OUT"
|
|
132
|
+
printf -- '-- size/stroke tuples:\n'
|
|
133
|
+
printf '%s\n' "$FILES" | xargs perl -0ne 'while(/<[A-Za-z]*Icon\b((?:(?!\/>)[\s\S])*?)\/>/g){my $a=$1; my ($s)=$a=~/size=\{(\d+)\}/; my ($w)=$a=~/strokeWidth=\{([\d.]+)\}/; printf "size=%s stroke=%s\n", $s//"-", $w//"-"}' 2>/dev/null | sort | uniq -c | sort -rn | awk '{printf " %3d %s %s\n", $1, $2, $3}'
|
|
134
|
+
|
|
135
|
+
# 10. Repeated className literals (3+ times, multi-word) — component candidates, with their locations.
|
|
136
|
+
section "10 REPEATED_CLASSNAMES — identical multi-utility className literals appearing 3+ times (→ component or variant)"
|
|
137
|
+
REPEATED=$(printf '%s\n' "$FILES" | xargs grep -ohE 'className="[^"]{24,}"' 2>/dev/null | sort | uniq -c | sort -rn | awk '$1>=3{c=$1; $1=""; sub(/^ /,""); printf "%d\t%s\n", c, $0}' | head -30)
|
|
138
|
+
printf '%s\n' "$REPEATED" | awk -F'\t' 'NF{printf " %3d %s\n", $1, $2}'
|
|
139
|
+
printf -- '-- occurrences (file:line) per repeated literal:\n'
|
|
140
|
+
printf '%s\n' "$REPEATED" | cut -f2 | while IFS= read -r lit; do
|
|
141
|
+
[[ -n "$lit" ]] || continue
|
|
142
|
+
printf ' %s\n' "$lit"
|
|
143
|
+
printf '%s\n' "$FILES" | xargs grep -nF -- "$lit" 2>/dev/null | cut -d: -f1,2 | sed 's|^| |'
|
|
144
|
+
done
|
|
145
|
+
|
|
146
|
+
echo; echo "# end — classify with skills/kit-ux-audit/references/consistency.md"
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ux-graph-scan.sh — deterministic, dependency-free half of /kit-ux-audit (flows lane).
|
|
3
|
+
#
|
|
4
|
+
# Two modes, no model call, no API key:
|
|
5
|
+
# --apps <root> enumerate app-like packages (react/next/vue + a dev script) -> JSON array
|
|
6
|
+
# --scan <dir> build an APPROXIMATE flows graph of one app -> graphify-out/.ux_graph.json
|
|
7
|
+
#
|
|
8
|
+
# The scan is regex over TS/TSX/JSX/Vue, not an AST. It is the fallback for when no
|
|
9
|
+
# graphify-out/graph.json exists; the skill marks the report "graph source: deterministic scan".
|
|
10
|
+
# macOS-safe (no grep -P). Requires: jq, perl. Sources scripts/lib/react-detect.sh for --apps.
|
|
11
|
+
set -eu # no pipefail: many probes end in a grep that legitimately finds nothing
|
|
12
|
+
|
|
13
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
14
|
+
USAGE="usage: ux-graph-scan.sh --apps <root> | --scan <dir> [--exclude <regex>]"
|
|
15
|
+
|
|
16
|
+
MODE=""; ARG=""; EXCLUDE='__never__'
|
|
17
|
+
while [[ $# -gt 0 ]]; do
|
|
18
|
+
case "$1" in
|
|
19
|
+
--apps) MODE="apps"; ARG="${2:-}"; shift 2 ;;
|
|
20
|
+
--scan) MODE="scan"; ARG="${2:-}"; shift 2 ;;
|
|
21
|
+
--exclude)
|
|
22
|
+
[[ $# -ge 2 && -n "${2:-}" ]] || { echo "ux-graph-scan: --exclude needs a value" >&2; exit 2; }
|
|
23
|
+
EXCLUDE="$2"; shift 2 ;;
|
|
24
|
+
-h|--help) echo "$USAGE"; exit 0 ;;
|
|
25
|
+
*) echo "ux-graph-scan: unknown arg: $1" >&2; echo "$USAGE" >&2; exit 2 ;;
|
|
26
|
+
esac
|
|
27
|
+
done
|
|
28
|
+
[[ -n "$MODE" && -n "$ARG" ]] || { echo "$USAGE" >&2; exit 2; }
|
|
29
|
+
command -v jq >/dev/null 2>&1 || { echo "ux-graph-scan: jq required" >&2; exit 3; }
|
|
30
|
+
command -v perl >/dev/null 2>&1 || { echo "ux-graph-scan: perl required" >&2; exit 3; }
|
|
31
|
+
|
|
32
|
+
# ----------------------------------------------------------------------------- apps
|
|
33
|
+
if [[ "$MODE" == "apps" ]]; then
|
|
34
|
+
[[ -d "$ARG" ]] || { echo "ux-graph-scan: no such dir: $ARG" >&2; exit 2; }
|
|
35
|
+
# shellcheck source=/dev/null
|
|
36
|
+
[[ -f "$HERE/lib/react-detect.sh" ]] && . "$HERE/lib/react-detect.sh"
|
|
37
|
+
printf '['
|
|
38
|
+
first=1
|
|
39
|
+
while IFS= read -r pkg; do
|
|
40
|
+
dir="$(dirname "$pkg")"
|
|
41
|
+
case "$dir" in *node_modules*|*/.next/*|*/dist/*) continue ;; esac
|
|
42
|
+
has_dev="$(jq -r '(.scripts.dev // .scripts.start // "") | if . == "" then "0" else "1" end' "$pkg" 2>/dev/null || echo 0)"
|
|
43
|
+
deps="$(jq -r '((.dependencies // {}) + (.devDependencies // {})) | keys[]?' "$pkg" 2>/dev/null || true)"
|
|
44
|
+
fw=""
|
|
45
|
+
printf '%s\n' "$deps" | grep -qx next && fw="next"
|
|
46
|
+
[[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx '@react-router/dev' && fw="react-router"
|
|
47
|
+
[[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx nuxt && fw="nuxt"
|
|
48
|
+
[[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx astro && fw="astro"
|
|
49
|
+
[[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx vue && fw="vue"
|
|
50
|
+
[[ -z "$fw" ]] && printf '%s\n' "$deps" | grep -qx react && fw="react"
|
|
51
|
+
[[ -n "$fw" && "$has_dev" == "1" ]] || continue
|
|
52
|
+
router="unknown"
|
|
53
|
+
if declare -f react_detect >/dev/null 2>&1; then
|
|
54
|
+
react_detect "$dir" || true
|
|
55
|
+
[[ "$fw" == "next" && -d "$dir/app" ]] && router="app-router"
|
|
56
|
+
[[ "$fw" == "next" && -d "$dir/pages" ]] && router="pages-router"
|
|
57
|
+
[[ "$REACT_ROUTER_LIB" == "true" ]] && router="react-router-lib"
|
|
58
|
+
fi
|
|
59
|
+
[[ "$fw" == "astro" && -d "$dir/src/pages" ]] && router="file-routes"
|
|
60
|
+
[[ ( "$fw" == "vue" || "$fw" == "nuxt" ) && -d "$dir/pages" ]] && router="file-routes"
|
|
61
|
+
name="$(jq -r '.name // ""' "$pkg" 2>/dev/null)"; [[ -n "$name" ]] || name="$(basename "$dir")"
|
|
62
|
+
[[ $first == 1 ]] || printf ','
|
|
63
|
+
first=0
|
|
64
|
+
jq -n --arg n "$name" --arg d "$dir" --arg f "$fw" --arg r "$router" \
|
|
65
|
+
'{name:$n, dir:$d, framework:$f, router:$r}'
|
|
66
|
+
done < <(find "$ARG" -name node_modules -prune -o -name package.json -type f -print 2>/dev/null | sort)
|
|
67
|
+
printf ']\n'
|
|
68
|
+
exit 0
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# ----------------------------------------------------------------------------- scan
|
|
72
|
+
[[ -d "$ARG" ]] || { echo "ux-graph-scan: no such dir: $ARG" >&2; exit 2; }
|
|
73
|
+
TARGET="$ARG"
|
|
74
|
+
OUTDIR="$TARGET/graphify-out"
|
|
75
|
+
mkdir -p "$OUTDIR"
|
|
76
|
+
OUT="$OUTDIR/.ux_graph.json"
|
|
77
|
+
|
|
78
|
+
FILES="$(find "$TARGET" \( -name node_modules -o -name .next -o -name dist -o -name build \) -prune -o \
|
|
79
|
+
-type f \( -name '*.tsx' -o -name '*.jsx' -o -name '*.ts' -o -name '*.vue' \) -print 2>/dev/null \
|
|
80
|
+
| grep -Ev "$EXCLUDE" | sort || true)"
|
|
81
|
+
NFILES="$(printf '%s\n' "$FILES" | grep -c . || true)"
|
|
82
|
+
|
|
83
|
+
# One perl pass over every file emits TSV rows the jq step below folds into nodes/edges.
|
|
84
|
+
# row kinds: N<TAB>id<TAB>kind<TAB>label<TAB>file<TAB>metaJson
|
|
85
|
+
# E<TAB>from<TAB>to<TAB>type<TAB>viaJson
|
|
86
|
+
# -0777 -n => one iteration per @ARGV file, $_ = whole file, $ARGV = that file.
|
|
87
|
+
perl -0777 -ne '
|
|
88
|
+
my $rel = $ARGV;
|
|
89
|
+
$rel =~ s{^\./}{};
|
|
90
|
+
# ---- node kind from path -------------------------------------------------
|
|
91
|
+
my $kind = "component";
|
|
92
|
+
my $isRoute = 0;
|
|
93
|
+
if ($rel =~ m{(?:^|/)(?:src/)?app/(?:.*/)?page\.(?:tsx|jsx|ts)$}) { $kind="screen"; $isRoute=1 }
|
|
94
|
+
elsif ($rel =~ m{(?:^|/)(?:src/)?pages/(?!_)[^.].*\.(?:tsx|jsx)$}) { $kind="screen"; $isRoute=1 }
|
|
95
|
+
elsif ($rel =~ m{(?:^|/)(?:src/)?routes/.*\.(?:tsx|jsx)$}) { $kind="screen"; $isRoute=1 }
|
|
96
|
+
elsif ($rel =~ m{\.route\.(?:tsx|jsx|ts)$}) { $kind="screen"; $isRoute=1 }
|
|
97
|
+
elsif ($rel =~ m{(?:^|/)(?:src/)?app/(?:.*/)?layout\.(?:tsx|jsx|ts)$}) { $kind="container" }
|
|
98
|
+
elsif ($rel =~ m{[Ll]ayout\.(?:tsx|jsx)$}) { $kind="container" }
|
|
99
|
+
my $id = "$kind:$rel";
|
|
100
|
+
# ---- route path -------------------------------------------------------
|
|
101
|
+
my $route = "";
|
|
102
|
+
if ($isRoute) {
|
|
103
|
+
($route = $rel) =~ s{^.*?(?:^|/)(?:src/app|src/pages|src/routes|app|pages|routes)/}{};
|
|
104
|
+
$route =~ s{/?(?:page|index|route)\.(?:tsx|jsx|ts)$}{};
|
|
105
|
+
$route =~ s{\.(?:tsx|jsx)$}{};
|
|
106
|
+
$route =~ s{\((\w+)\)/?}{}g; # route groups
|
|
107
|
+
$route =~ s{\[\.\.\.(\w+)\]}{*}g;
|
|
108
|
+
$route =~ s{\[(\w+)\]}{:$1}g;
|
|
109
|
+
$route = "/$route"; $route =~ s{//+}{/}g; $route =~ s{/$}{} ;
|
|
110
|
+
$route = "/" if $route eq "";
|
|
111
|
+
}
|
|
112
|
+
my $entry = ($route =~ m{^/(|dashboard|home|inicio|overview|app)$}) ? "true" : "false";
|
|
113
|
+
my $meta = sprintf(q({"route":"%s","entry":%s}), $route, $entry);
|
|
114
|
+
print "N\t$id\t$kind\t$route\t$rel\t$meta\n";
|
|
115
|
+
|
|
116
|
+
# ---- imports / renders ---------------------------------------------------
|
|
117
|
+
while (/import\s+(?:\*\s+as\s+\w+|\{[^}]*\}|\w+)\s+from\s+["'\''](\.[^"'\'']+|\@\/[^"'\'']+)["'\'']/g) {
|
|
118
|
+
my $spec = $1;
|
|
119
|
+
print "E\t$id\timport:$spec\timports\t{}\n";
|
|
120
|
+
}
|
|
121
|
+
# ---- navigation -------------------------------------------------------
|
|
122
|
+
while (/(?:href|to)=\s*["'\''](\/[A-Za-z0-9_\-\/:*]*)["'\'']/g) { print "E\t$id\troute:$1\tnavigates-to\t{}\n"; }
|
|
123
|
+
while (/(?:router\.push|router\.replace|redirect|navigate)\(\s*["'\''](\/[A-Za-z0-9_\-\/:*]*)["'\'']/g) { print "E\t$id\troute:$1\tnavigates-to\t{}\n"; }
|
|
124
|
+
my $navcnt = () = /<Link\b|useNavigate\(|router\.(push|replace)/g;
|
|
125
|
+
print "N\t$id.navmeta\t_navmeta\t\t$rel\t{\"nav\":$navcnt}\n" if $navcnt;
|
|
126
|
+
|
|
127
|
+
# ---- data reads / writes / mutations ----------------------------------
|
|
128
|
+
# prisma.<model>.<op>
|
|
129
|
+
while (/\bprisma\.(\w+)\.(\w+)/g) {
|
|
130
|
+
my ($m,$op)=($1,$2); my $ent = ucfirst($m); $ent =~ s/s$//;
|
|
131
|
+
my $t = ($op=~/delete|deleteMany|remove/i) ? "mutates" : ($op=~/create|update|upsert|insert|createMany|updateMany/i ? "writes" : "reads");
|
|
132
|
+
print "E\t$id\tdata-entity:$ent\t$t\t{\"op\":\"$op\"}\n";
|
|
133
|
+
}
|
|
134
|
+
# supabase .from("table")
|
|
135
|
+
while (/\.from\(\s*["'\''](\w+)["'\'']\s*\)/g) { my $ent=ucfirst($1); $ent=~s/s$//; print "E\t$id\tdata-entity:$ent\treads\t{}\n"; }
|
|
136
|
+
# react-query / swr hooks: useXxxQuery / useXxxMutation
|
|
137
|
+
while (/\buse(\w+?)(Query|Mutation|SuspenseQuery)\b/g) {
|
|
138
|
+
my ($ent,$hook)=($1,$2); next if $ent eq "";
|
|
139
|
+
my $t = ($hook eq "Mutation") ? "writes" : "reads";
|
|
140
|
+
$t = "mutates" if $ent =~ /Delete|Remove|Archive/;
|
|
141
|
+
$ent =~ s/(Delete|Remove|Archive|Create|Update|List|Get)//g; next if $ent eq "";
|
|
142
|
+
print "E\t$id\tdata-entity:$ent\t$t\t{\"via\":\"hook\"}\n";
|
|
143
|
+
}
|
|
144
|
+
# server actions / loaders
|
|
145
|
+
print "E\t$id\tdata-entity:_loader\treads\t{}\n" if /useLoaderData\(|createServerFn\(|export\s+async\s+function\s+loader/;
|
|
146
|
+
|
|
147
|
+
# ---- forms -----------------------------------------------------------
|
|
148
|
+
if (/useForm\s*\(|<Formik\b|<form\b|zodResolver\(/) {
|
|
149
|
+
my $fields = () = /<(input|select|textarea|Controller)\b|\bregister\(\s*["'\'']/g;
|
|
150
|
+
my $req = () = /\brequired\b|\.min\(1|nonempty\(/g;
|
|
151
|
+
my $multi = ($rel =~ /step|wizard|stepper/i) ? "true" : "false";
|
|
152
|
+
my $stepper= (/<Stepper\b|<Steps\b|currentStep|activeStep/) ? "true" : "false";
|
|
153
|
+
my $draft = (/autosave|useAutoSave|draft|localStorage\.setItem/) ? "true" : "false";
|
|
154
|
+
my $fid = "form:$rel";
|
|
155
|
+
printf("N\t%s\tform\t%s\t%s\t{\"fields\":%d,\"required\":%d,\"multi\":%s,\"stepper\":%s,\"draft\":%s}\n",
|
|
156
|
+
$fid, "form in $rel", $rel, $fields, $req, $multi, $stepper, $draft);
|
|
157
|
+
print "E\t$id\t$fid\trenders\t{}\n";
|
|
158
|
+
}
|
|
159
|
+
' -- $FILES > "$OUTDIR/.ux_scan_rows.tsv" 2>/dev/null || true
|
|
160
|
+
|
|
161
|
+
# Fold rows -> {meta,nodes,edges}. Import edges are resolved to file ids by suffix match in the
|
|
162
|
+
# skill's normalize step (graph-model.md); here we keep them raw but deduplicated.
|
|
163
|
+
jq -Rn --arg target "$TARGET" --arg n "$NFILES" '
|
|
164
|
+
[ inputs | select(length>0) | split("\t") ] as $rows
|
|
165
|
+
| ( [ $rows[] | select(.[0]=="N" and .[2]!="_navmeta") ]
|
|
166
|
+
| map({id:.[1], kind:.[2], label:(.[3]//""), file:.[4], meta:(try (.[5]|fromjson) catch {})})
|
|
167
|
+
| unique_by(.id) ) as $nodes
|
|
168
|
+
| ( [ $rows[] | select(.[0]=="E") ]
|
|
169
|
+
| map({from:.[1], to:.[2], type:.[3], meta:(try (.[4]|fromjson) catch {})})
|
|
170
|
+
| unique_by("\(.from)|\(.to)|\(.type)") ) as $edges
|
|
171
|
+
| { meta: {
|
|
172
|
+
target: $target, files_scanned: ($n|tonumber),
|
|
173
|
+
generated_at: (now | todateiso8601),
|
|
174
|
+
note: "approximate: regex scan, not an AST"
|
|
175
|
+
},
|
|
176
|
+
nodes: $nodes, edges: $edges,
|
|
177
|
+
stats: {
|
|
178
|
+
nodes: ($nodes|length), edges: ($edges|length),
|
|
179
|
+
screens: ([$nodes[]|select(.kind=="screen")]|length),
|
|
180
|
+
containers: ([$nodes[]|select(.kind=="container")]|length),
|
|
181
|
+
forms: ([$nodes[]|select(.kind=="form")]|length),
|
|
182
|
+
entities: ([$edges[]|select(.to|startswith("data-entity:"))|.to]|unique|length)
|
|
183
|
+
} }
|
|
184
|
+
' "$OUTDIR/.ux_scan_rows.tsv" > "$OUT"
|
|
185
|
+
|
|
186
|
+
rm -f "$OUTDIR/.ux_scan_rows.tsv"
|
|
187
|
+
SCREENS="$(jq -r '.stats.screens' "$OUT")"; EDGES="$(jq -r '.stats.edges' "$OUT")"
|
|
188
|
+
echo "ux-graph-scan: $NFILES files -> $OUT ($SCREENS screens, $EDGES edges) [approximate]"
|
|
@@ -26,12 +26,17 @@ scripts; it never reimplements looping or orchestration.
|
|
|
26
26
|
back to the human to confirm a planned step.** "Do these efforts with the new flow", an approved
|
|
27
27
|
`kit effort plan`, or a green wave are an **established plan**: execute it end to end —
|
|
28
28
|
build a wave → merge its PRs → close subs+parent → gc → launch the next wave — **without asking
|
|
29
|
-
"merge or review?"**. A planned merge is _execution_, not a new decision
|
|
29
|
+
"merge or review?"**. A planned merge is _execution_, not a new decision (the canonical "Error 1" incident: stalling an approved plan to ask for a routine merge).
|
|
30
30
|
|
|
31
31
|
- The human steers the **plan**, not each merge. Asking to confirm a routine planned merge is the error.
|
|
32
32
|
- A `risk:med` change the plan already approved (a product feature in the agreed scope) is **not** a
|
|
33
33
|
reason to stop — the plan blessed it. The risk-tiered review tiers
|
|
34
34
|
(`risk-tiered-review.md`) govern **ad-hoc** PRs, **not** execution of an approved plan.
|
|
35
|
+
- **The permission is shipped, not improvised.** `cckit init` scaffolds a **versioned**
|
|
36
|
+
`.claude/settings.json` (from `templates/settings/settings.json.tmpl`) whose explicit
|
|
37
|
+
`Bash(gh pr merge:*)` allow pre-authorizes the wave-merge — checked in, so it travels to every
|
|
38
|
+
worktree and collaborator (the gitignored `settings.local.json` does not). A captain merge that
|
|
39
|
+
still prompts means the project predates the template: re-run `cckit init --upgrade`.
|
|
35
40
|
|
|
36
41
|
### Ping the human ONLY on a genuine blocker
|
|
37
42
|
|